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