home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 October / PCO_10.ISO / filesbbs / bsrc_260.arj / SRC.ZIP / download.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-20  |  4.9 KB  |  130 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*              (C) Copyright 1987-96, Bit Bucket Software Co.              */
  11. /*                                                                          */
  12. /*          This module was originally written by Vince Perriello           */
  13. /*                                                                          */
  14. /*               BinkleyTerm Terminal/Script Download Module                */
  15. /*                                                                          */
  16. /*                                                                          */
  17. /*    For complete  details  of the licensing restrictions, please refer    */
  18. /*    to the License  agreement,  which  is published in its entirety in    */
  19. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.260.    */
  20. /*                                                                          */
  21. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  22. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  23. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  24. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  25. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  26. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  27. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  28. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  29. /*                                                                          */
  30. /*                                                                          */
  31. /* You can contact Bit Bucket Software Co. at any one of the following      */
  32. /* addresses:                                                               */
  33. /*                                                                          */
  34. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  35. /* P.O. Box 460398                AlterNet 7:42/1491                        */
  36. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  37. /*                                Internet f491.n343.z1.fidonet.org         */
  38. /*                                                                          */
  39. /* Please feel free to contact us at any time to share your comments about  */
  40. /* our software and/or licensing policies.                                  */
  41. /*                                                                          */
  42. /*--------------------------------------------------------------------------*/
  43.  
  44. /* Include this file before any other includes or defines! */
  45.  
  46. #include "includes.h"
  47.  
  48. #ifdef HAVE_HYDRA
  49. #include "hydra.h"
  50. #endif
  51.  
  52. /*
  53.  * Handle downloads from terminal mode.
  54.  *
  55.  * If filespec is NULL and we need a filename, ask for it.
  56.  * Otherwise, assume that the spec we got is OK and use it.
  57.  */
  58.  
  59. int 
  60. Download (char *filepath, int prot, char *extern_ptr)
  61. {
  62.     int k;
  63.     int err = 1;
  64.     unsigned save1, save2, save3;
  65.  
  66.     if ((prot == 'X') || (prot == 'Y') || extern_ptr != NULL)
  67.         if (filepath != NULL)
  68.             strcpy (junk, filepath);
  69.         else
  70.         {
  71.             scr_printf (MSG_TXT (M_FILE_TO_RECEIVE));
  72.             junk[0] = '\0';
  73.             (void) fgets (junk, 100, stdin);
  74.             if ((junk[0] == '\0') || (junk[0] == '\n'))
  75.                 return (0);
  76.             k = strlen (junk);
  77.             if (k <= 1)
  78.                 return (0);
  79.             junk[--k] = '\0';
  80.         }
  81.  
  82.     save1 = comm_bits;
  83.     save2 = parity;
  84.     save3 = stop_bits;
  85.     comm_bits = BITS_8;
  86.     parity = NO_PARITY;
  87.     stop_bits = STOP_1;
  88.     program_baud ();
  89.     XON_DISABLE ();
  90.  
  91.     /* If external protocol requested, call it */
  92.  
  93.     if (extern_ptr != NULL)
  94.         do_extern ("Get", prot, junk);
  95.     else
  96.         switch (prot)
  97.         {
  98.  
  99. #ifdef HAVE_HYDRA
  100.         case 'H':
  101.             hydra_init (hydra_options);
  102.             err = (hydra (NULL, NULL) == XFER_ABORT) ? FALSE : TRUE;
  103.             hydra_deinit();
  104.             break;
  105. #endif /* HAVE_HYDRA */
  106.  
  107.         case 'X':
  108.         case 'Y':
  109.             err = Xmodem_Receive_File (download_path, junk);
  110.             break;
  111.  
  112.         case 'Z':
  113.             err = get_Zmodem (download_path, NULL);
  114.             break;
  115.  
  116.         default:
  117.             err = Batch_Receive (download_path);
  118.             break;
  119.         }
  120.  
  121.     comm_bits = save1;
  122.     parity = save2;
  123.     stop_bits = save3;
  124.     program_baud ();
  125.     XON_ENABLE ();
  126.     gong ();
  127.  
  128.     return (err);
  129. }
  130.