home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / B_WZSEND.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  8KB  |  188 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. /*                    BinkleyTerm "SendWaZOO" Processor                     */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*    For complete  details  of the licensing restrictions, please refer    */
  17. /*    to the License  agreement,  which  is published in its entirety in    */
  18. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  19. /*                                                                          */
  20. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  21. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  22. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  23. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  24. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  25. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  26. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  27. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  28. /*                                                                          */
  29. /*                                                                          */
  30. /* You can contact Bit Bucket Software Co. at any one of the following      */
  31. /* addresses:                                                               */
  32. /*                                                                          */
  33. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  34. /* P.O. Box 460398                AlterNet 7:491/0                          */
  35. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  36. /*                                Internet f491.n343.z1.fidonet.org         */
  37. /*                                                                          */
  38. /* Please feel free to contact us at any time to share your comments about  */
  39. /* our software and/or licensing policies.                                  */
  40. /*                                                                          */
  41. /*                                                                          */
  42. /*  This module is based largely on a similar module in OPUS-CBCS V1.03b.   */
  43. /*  The original work is (C) Copyright 1987, Wynn Wagner III. The original  */
  44. /*  author has graciously allowed us to use his code in this work.          */
  45. /*                                                                          */
  46. /*--------------------------------------------------------------------------*/
  47.  
  48. /* Include this file before any other includes or defines! */
  49.  
  50. #include "includes.h"
  51.  
  52. #define rb_plus "r+b"
  53.  
  54. int get_ZedZap (char *, FILE *);
  55. int send_ZedZap (char *, char *, int, int);
  56. int get_ZedZip (char *, FILE *);
  57. int send_ZedZip (char *, char *, int, int);
  58.  
  59.  
  60. int WaZOO_callback (char *);
  61. int WaZOO_time (long);
  62.  
  63. static int fsent;
  64.  
  65. #define NUM_FLAGS 4
  66.  
  67.  
  68. /*--------------------------------------------------------------------------*/
  69. /* SEND WaZOO (send another WaZOO-capable Opus its mail)                    */
  70. /*   returns TRUE (1) for good xfer, FALSE (0) for bad                      */
  71. /*   use instead of n_bundle and n_attach for WaZOO Opera                   */
  72. /*--------------------------------------------------------------------------*/
  73. int send_WaZOO ()
  74. {
  75.    char fname[80];
  76.    char s[80];
  77.    char *HoldName;
  78.    int c;
  79.    int check_again;
  80.    struct stat buf;
  81.  
  82.    fsent = 0;
  83.  
  84.    HoldName = HoldAreaNameMunge(&called_addr);
  85.    check_again = 0;
  86.  
  87. just_make_sure:
  88.    /*--------------------------------------------------------------------*/
  89.    /* Send all waiting ?UT files (mail packets)                          */
  90.    /*--------------------------------------------------------------------*/
  91.    *ext_flags = 'O';
  92.    for (c = 0; c < NUM_FLAGS; c++)
  93.       {
  94. #ifndef JACK_DECKER
  95.       if (caller && (ext_flags[c] == 'H'))
  96.          continue;
  97. #endif
  98.  
  99.       (void) sprintf (fname,
  100.                "%s%s.%cUT",
  101.                HoldName, Hex_Addr_Str (&called_addr), ext_flags[c]);
  102.  
  103.       if (!stat (fname, &buf))
  104.          {
  105.  
  106.          /*--- Build a dummy PKT file name */
  107.          invent_pkt_name (s);
  108.  
  109.          /*--- Tell ZModem to handle this as a SEND AS then DELETE */
  110.          status_line (MSG_TXT(M_PACKET_MSG));
  111.  
  112.          if (!Send_Zmodem (fname, s, fsent++, DO_WAZOO))
  113.             {
  114.             net_problems = 1;
  115.             return FALSE;
  116.             }
  117.           CLEAR_IOERR ();
  118.           (void) unlink (fname);
  119.          }
  120.       }                                          /* for */
  121.  
  122.    /*--------------------------------------------------------------------*/
  123.    /* Send files listed in ?LO files (attached files)                    */
  124.    /*--------------------------------------------------------------------*/
  125.    *ext_flags = 'F';
  126.    if (!do_FLOfile (ext_flags, WaZOO_callback))
  127.       {
  128.       return FALSE;
  129.       }
  130.  
  131.    if (fsent && !check_again)
  132.       {
  133.       check_again = 1;
  134.       goto just_make_sure;
  135.       }
  136.  
  137.    /*--------------------------------------------------------------------*/
  138.    /* Send our File requests to other system                             */
  139.    /*--------------------------------------------------------------------*/
  140.    if (requests_ok)
  141.       {
  142.       (void) sprintf (fname, request_template, HoldName, Hex_Addr_Str (&called_addr));
  143.       if (!stat (fname, &buf))
  144.          {
  145.          if (!(((unsigned) remote_capabilities) & WZ_FREQ))
  146.             status_line (MSG_TXT(M_FREQ_DECLINED));
  147.          else
  148.             {
  149.             status_line (MSG_TXT(M_OUT_REQUESTS));
  150.             ++made_request;
  151.             if (Send_Zmodem (fname, NULL, fsent++, DO_WAZOO))
  152.                (void) unlink (fname);
  153.             }
  154.          }
  155.       }
  156.  
  157.    fsent = respond_to_file_requests (fsent, WaZOO_callback, WaZOO_time);
  158.  
  159.    if (!fsent)
  160.       status_line (MSG_TXT(M_NOTHING_TO_SEND), Full_Addr_Str (&called_addr));
  161.  
  162.  
  163.    (void) Send_Zmodem (NULL, NULL, ((fsent) ? END_BATCH : NOTHING_TO_DO), DO_WAZOO);
  164.  
  165.    sent_mail = 1;
  166.  
  167.    return TRUE;
  168.  
  169. }                                                /* WaZOO */
  170.  
  171. /*
  172.  * WaZOO_callback () -- send requested file using WaZOO method.
  173.  *
  174.  *
  175.  */
  176. int WaZOO_callback (char *reqs)
  177. {
  178.    return (Send_Zmodem (reqs, NULL, fsent++, DO_WAZOO));
  179. }
  180.  
  181. int WaZOO_time (long filesize)
  182. {
  183.    int i;
  184.    i = (int) (filesize * 10 / cur_baud.rate_value * 100 / 95);
  185.    return (i);
  186. }
  187.  
  188.