home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / B_WZSEND.C < prev    next >
C/C++ Source or Header  |  1991-10-17  |  8KB  |  207 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-90, 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.240.    */
  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:132/491, 1:141/491  */
  34. /* P.O. Box 460398                AlterNet 7:491/0                          */
  35. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  36. /*                                Internet f491.n132.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 <stdio.h>
  49. #include <signal.h>
  50. #include <ctype.h>
  51. #include <conio.h>
  52. #include <string.h>
  53. #include <stdlib.h>
  54. #include <sys\types.h>
  55. #include <sys\stat.h>
  56. #include <errno.h>
  57.  
  58. #define WAZOO_SECTION
  59. #include "com.h"
  60. #include "xfer.h"
  61. #include "zmodem.h"
  62. #include "keybd.h"
  63. #include "sbuf.h"
  64. #include "sched.h"
  65. #include "externs.h"
  66. #include "prototyp.h"
  67. #include "defines.h"
  68.  
  69. #define rb_plus "r+b"
  70.  
  71. int get_ZedZap (char *, FILE *);
  72. int send_ZedZap (char *, char *, int, int);
  73. int get_ZedZip (char *, FILE *);
  74. int send_ZedZip (char *, char *, int, int);
  75.  
  76.  
  77. int WaZOO_callback (char *);
  78. static int fsent;
  79.  
  80. #define NUM_FLAGS 4
  81.  
  82.  
  83. /*--------------------------------------------------------------------------*/
  84. /* SEND WaZOO (send another WaZOO-capable Opus its mail)                    */
  85. /*   returns TRUE (1) for good xfer, FALSE (0) for bad                      */
  86. /*   use instead of n_bundle and n_attach for WaZOO Opera                   */
  87. /*--------------------------------------------------------------------------*/
  88. int send_WaZOO ()
  89. {
  90.    char fname[80];
  91.    char s[80];
  92.    char *HoldName;
  93.    int c;
  94.    int check_again;
  95.    struct stat buf;
  96.  
  97.  
  98.    fsent = 0;
  99.  
  100.    if (flag_file (TEST_AND_SET, &called_addr, 1))
  101.       goto done_send;
  102.  
  103.    HoldName = HoldAreaNameMunge(&called_addr);
  104.    check_again = 0;
  105.  
  106. just_make_sure:
  107.    /*--------------------------------------------------------------------*/
  108.    /* Send all waiting ?UT files (mail packets)                          */
  109.    /*--------------------------------------------------------------------*/
  110.    *ext_flags = 'O';
  111.    for (c = 0; c < NUM_FLAGS; c++)
  112.       {
  113. #ifndef JACK_DECKER
  114.       if (caller && (ext_flags[c] == 'H'))
  115.          continue;
  116. #endif
  117.  
  118.       (void) sprintf (fname,
  119.                "%s%s.%cUT",
  120.                HoldName, Hex_Addr_Str (&called_addr), ext_flags[c]);
  121.  
  122.       if (!stat (fname, &buf))
  123.          {
  124.  
  125.          /*--- Build a dummy PKT file name */
  126.          invent_pkt_name (s);
  127.  
  128.          /*--- Tell ZModem to handle this as a SEND AS then DELETE */
  129.          status_line (msgtxt[M_PACKET_MSG]);
  130.  
  131.          if (!Send_Zmodem (fname, s, fsent++, DO_WAZOO))
  132.             {
  133.             net_problems = 1;
  134.             flag_file (CLEAR_FLAG, &called_addr, 1);
  135.             return FALSE;
  136.             }
  137.           CLEAR_IOERR ();
  138.           (void) unlink (fname);
  139.          }
  140.       }                                          /* for */
  141.  
  142.    /*--------------------------------------------------------------------*/
  143.    /* Send files listed in ?LO files (attached files)                    */
  144.    /*--------------------------------------------------------------------*/
  145.    *ext_flags = 'F';
  146.    if (!do_FLOfile (ext_flags, WaZOO_callback))
  147.       {
  148.       flag_file (CLEAR_FLAG, &called_addr, 1);
  149.       return FALSE;
  150.       }
  151.  
  152.    if (fsent && !check_again)
  153.       {
  154.       check_again = 1;
  155.       goto just_make_sure;
  156.       }
  157.  
  158.    /*--------------------------------------------------------------------*/
  159.    /* Send our File requests to other system                             */
  160.    /*--------------------------------------------------------------------*/
  161.    if (requests_ok)
  162.       {
  163.       (void) sprintf (fname, request_template, HoldName, Hex_Addr_Str (&called_addr));
  164.       if (!stat (fname, &buf))
  165.          {
  166.          if (!(((unsigned) remote_capabilities) & WZ_FREQ))
  167.             status_line (msgtxt[M_FREQ_DECLINED]);
  168.          else
  169.             {
  170.             status_line (msgtxt[M_OUT_REQUESTS]);
  171.             ++made_request;
  172.             if (Send_Zmodem (fname, NULL, fsent++, DO_WAZOO))
  173.                (void) unlink (fname);
  174.             }
  175.          }
  176.       }
  177.  
  178.    fsent = respond_to_file_requests (fsent, WaZOO_callback);
  179.  
  180.    flag_file (CLEAR_FLAG, &called_addr, 1);
  181.  
  182. done_send:
  183.  
  184.    if (!fsent)
  185.       status_line (msgtxt[M_NOTHING_TO_SEND], Full_Addr_Str (&called_addr));
  186.  
  187.  
  188.    (void) Send_Zmodem (NULL, NULL, ((fsent) ? END_BATCH : NOTHING_TO_DO), DO_WAZOO);
  189.  
  190.    sent_mail = 1;
  191.  
  192.    return TRUE;
  193.  
  194. }                                                /* WaZOO */
  195.  
  196. /*
  197.  * WaZOO_callback () -- send requested file using WaZOO method.
  198.  *
  199.  *
  200.  */
  201. int WaZOO_callback (reqs)
  202. char *reqs;
  203. {
  204.    return (Send_Zmodem (reqs, NULL, fsent++, DO_WAZOO));
  205. }
  206.  
  207.