home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / OUTBOUND.C < prev    next >
Text File  |  1991-09-15  |  13KB  |  376 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 Bob Hartman             */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                         Outbound Manipulating                            */
  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. int add_request (char *, char *, char *, char *);
  51. int add_send (char *, char *, char *);
  52. int kill_node (char *);
  53.  
  54. int Overlay_Do_Get (BINK_SAVEP p, int x)
  55. {
  56. #ifndef MILQ
  57.     REGIONP r;
  58.     char node[51];
  59.     char file[13];
  60.     char password[9];
  61.     char flavor[2];
  62.     char sure[2];
  63. #endif
  64.  
  65. #ifndef MILQ
  66.     if (p != NULL)
  67.         {
  68.         r = p->region;
  69.  
  70.         /* First fill it all with blanks */
  71.         sb_fill (r, ' ', colors.popup);
  72.  
  73.         /* Now draw the box */
  74.         sb_box (r, boxtype, colors.popup);
  75.  
  76.         sb_move (r, 0, 1);
  77.         sb_puts (r, MSG_TXT(M_GET_FILE));
  78.  
  79.         /* Now do the fields */
  80.         sb_move (r, 1,2);
  81.         sb_puts (r, MSG_TXT(M_ADDRESS_TO_GET_FROM));
  82.         if (!sb_input_chars (r, 1, 23, node, 36))
  83.             {
  84.             sb_move (r, 2, 2);
  85.             sb_puts (r, MSG_TXT(M_FILE_TO_RECEIVE));
  86.             if (!sb_input_chars (r, 2, 23, file, 12))
  87.                 {
  88.                 sb_move (r, 3, 2);
  89.                 sb_puts (r, MSG_TXT(M_PASSWORD_TO_USE));
  90.                 (void) sb_input_chars (r, 3, 23, password, 8);
  91.                 sb_move (r, 4, 2);
  92.                 sb_puts (r, "Crash, Hold, Direct, Normal (C/H/D/N)?");
  93.                 (void) sb_input_chars (r, 4, 41, flavor, 1);
  94.                 sb_move (r, 5, 2);
  95.                 sb_puts (r, MSG_TXT(M_ARE_YOU_SURE));
  96.                 (void) sb_input_chars (r, 5, 23, sure, 1);
  97.                 if (sure[0] == (char)toupper (MSG_TXT(M_YES)[0]))
  98.                     x = add_request (node, file, password, flavor);
  99.                 }
  100.             }
  101.         }
  102. #else
  103.     DialogBox( MilqueRsrc, (LPSTR)"Get", MilqueMailerWnd, GetDlgPrc );
  104. #endif
  105.     /* Return value is never checked, just use x so lint and -W3 don't get mad */
  106.     return (x);
  107. }
  108.  
  109. int Overlay_Do_Send (BINK_SAVEP p, int x)
  110. {
  111. #ifndef MILQ
  112.     REGIONP r;
  113.     char node[51];
  114.     char file[51];
  115.     char flavor[2];
  116.     char sure[2];
  117. #endif
  118.  
  119. #ifndef MILQ
  120.     if (p != NULL)
  121.         {
  122.         r = p->region;
  123.  
  124.         /* First fill it all with blanks */
  125.         sb_fill (r, ' ', colors.popup);
  126.  
  127.         /* Now draw the box */
  128.         sb_box (r, boxtype, colors.popup);
  129.  
  130.         sb_move (r, 0, 1);
  131.         sb_puts (r, MSG_TXT(M_SEND_FILE));
  132.  
  133.         /* Now do the fields */
  134.         sb_move (r, 1,2);
  135.         sb_puts (r, MSG_TXT(M_ADDRESS_TO_SEND_TO));
  136.         if (!sb_input_chars (r, 1, 22, node, 47))
  137.             {
  138.             sb_move (r, 2, 2);
  139.             sb_puts (r, MSG_TXT(M_FILE_TO_SEND));
  140.             if (!sb_input_chars (r, 2, 22, file, 47))
  141.                 {
  142.                 sb_move (r, 3, 2);
  143.                 sb_puts (r, "Crash, Hold, Direct, Normal (C/H/D/N)?");
  144.                 (void) sb_input_chars (r, 3, 41, flavor, 1);
  145.                 sb_move (r, 4, 2);
  146.                 sb_puts (r, MSG_TXT(M_ARE_YOU_SURE));
  147.                 (void) sb_input_chars (r, 4, 22, sure, 1);
  148.                 if (sure[0] == (char)toupper (MSG_TXT(M_YES)[0]))
  149.                     x = add_send (node, file, flavor);
  150.                 }
  151.             }
  152.         }
  153. #else
  154.     DialogBox( MilqueRsrc, "Send", MilqueMailerWnd, SendDlgPrc );
  155. #endif
  156.  
  157.     /* Return value is never checked, just use x so lint and -W3 don't get mad */
  158.     return (x);
  159. }
  160.  
  161. int Overlay_Do_Kill (BINK_SAVEP p, int x)
  162. {
  163. #ifndef MILQ
  164.     REGIONP r;
  165.     char node[51];
  166.     char sure[2];
  167. #endif
  168.  
  169. #ifndef MILQ
  170.     if (p != NULL)
  171.         {
  172.         r = p->region;
  173.  
  174.         /* First fill it all with blanks */
  175.         sb_fill (r, ' ', colors.popup);
  176.  
  177.         /* Now draw the box */
  178.         sb_box (r, boxtype, colors.popup);
  179.  
  180.         sb_move (r, 0, 1);
  181.         sb_puts (r, MSG_TXT(M_KILL_MAIL));
  182.  
  183.         /* Now do the fields */
  184.         sb_move (r, 1,2);
  185.         sb_puts (r, MSG_TXT(M_ADDRESS_TO_KILL));
  186.         if (!sb_input_chars (r, 1, 19, node, 50))
  187.             {
  188.             sb_move (r, 2, 2);
  189.             sb_puts (r, MSG_TXT(M_KILL_ALL_MAIL));
  190.             sb_puts (r, MSG_TXT(M_ARE_YOU_SURE));
  191.             (void) sb_input_chars (r, 2, 38, sure, 1);
  192.             if (sure[0] == (char)toupper (MSG_TXT(M_YES)[0]))
  193.                 x = kill_node (node);
  194.             }
  195.         }
  196.  
  197.     /* Return value is never checked, just use x so lint and -W3 don't get mad */
  198.     return (x);
  199. #else
  200.     DialogBox( MilqueRsrc, (LPSTR)"Kill", MilqueMailerWnd, KillDlgPrc );
  201. #endif
  202. }
  203.  
  204. int Overlay_Do_Poll (BINK_SAVEP p, int x)
  205. {
  206. #ifndef MILQ
  207.     char node[51];
  208.     REGIONP r;
  209. #else
  210.     HDLG                hDlg;
  211.     HANDLE              Instance;
  212.     int                 Rslt;
  213. #endif
  214.  
  215.     happy_compiler = x;            /* Makes the compiler happy! */
  216. #ifndef MILQ
  217.     if (p != NULL)
  218.         {
  219.         r = p->region;
  220.  
  221.         /* First fill it all with blanks */
  222.         sb_fill (r, ' ', colors.popup);
  223.  
  224.         /* Now draw the box */
  225.         sb_box (r, boxtype, colors.popup);
  226.  
  227.         sb_move (r, 0, 1);
  228.         sb_puts (r, MSG_TXT (M_NODE_TO_POLL));
  229.  
  230.         /* Now do the fields */
  231.         sb_move (r, 1,2);
  232.         sb_puts (r, MSG_TXT (M_POLL_WHOM));
  233.         if (!sb_input_chars (r, 1, 14, node, 40))
  234.             {
  235.             return ( find_address (node, &next_addr));
  236.             }
  237.         }
  238.     return (FALSE);
  239. #else
  240.     return DialogBox( MilqueRsrc, (LPSTR)"Poll", MilqueMailerWnd, PollDlgPrc );
  241. #endif
  242.                                        /* The return is indeed checked in */
  243.                                        /* this case.  FALSE means I got no */
  244.                                        /* stinkin' address in next_addr. */
  245. }
  246.  
  247. int kill_node (char *node)
  248. {
  249.     ADDR addr;
  250.     char *HoldName;
  251.     char *p;
  252.     char fname[160];
  253.     struct FILEINFO fileinfo;
  254.  
  255.     if (find_address (node, &addr))
  256.         {
  257.         if (flag_file (TEST_AND_SET, &addr, 0))
  258.            {
  259.            return (-1);
  260.            }
  261.  
  262.         HoldName = HoldAreaNameMunge(&addr);
  263.  
  264.         (void) sprintf (fname, "%s%s.*", HoldName, Hex_Addr_Str (&addr));
  265.         if (!dfind (&fileinfo, fname, 0))
  266.             {
  267.             do
  268.                 {
  269.              /* Don't delete the .bsy flags yet */
  270.                 if ((p = strchr (fileinfo.name, '.')) != NULL)
  271.                     {
  272.                     if (strcmp (p, ".BSY") == 0)
  273.                        continue;
  274.                     }
  275.                 if (addr.Point != 0)
  276.                    {
  277.                    (void) sprintf (fname, "%s%04x%04x.PNT\\%s",
  278.                              HoldName, addr.Net, addr.Node, fileinfo.name);
  279.                    }
  280.                 else
  281.                    (void) sprintf (fname, "%s%s", HoldName, fileinfo.name);
  282.  
  283.                 (void) unlink (fname);
  284.                 } while (!dfind (&fileinfo, fname, 1));
  285.             }
  286.  
  287.         (void) flag_file (CLEAR_FLAG, &addr, 0);
  288.         return (0);
  289.         }
  290. /* else */
  291.    return (-1);
  292. }
  293.  
  294. int add_request (char *node, char *file, char *password, char *flavor)
  295. {
  296.     ADDR addr;
  297.     char *HoldName;
  298.     char fname[100];
  299.     FILE *f;
  300.  
  301.     if (find_address (node, &addr))
  302.         {
  303.         HoldName = HoldAreaNameMunge(&addr);
  304.  
  305.      /* Now see if we should send anything back to him */
  306.         (void) sprintf (fname, "%s%s.REQ", HoldName, Hex_Addr_Str (&addr));
  307.         if ((f = fopen (fname, "ab")) == NULL)
  308.             {
  309.             return (-2);
  310.             }
  311.  
  312.         (void) sprintf (fname, "%s", Full_Addr_Str (&(alias[0])));
  313.         (void) sprintf (junk, ";GET generated by node %s using %s", fname, ANNOUNCE);
  314.                                  /* A brutal Greylock Hack */
  315.         junk[75] = '\0';
  316.         (void) fprintf (f, "%s\r\n", junk);
  317.         (void) fprintf (f, "%s", file);
  318.         if (password[0] != '\0')
  319.             {
  320.             (void) fprintf (f, " !%s", password);
  321.             }
  322.         (void) fprintf (f, "\r\n");
  323.  
  324.         (void) fclose (f);
  325.  
  326.         (void) add_send (node, "", flavor);
  327.         return (0);
  328.         }
  329.  /* else */
  330.     return (-1);
  331. }
  332.  
  333. int add_send (char *node, char *file, char *flavor)
  334. {
  335.    ADDR addr;
  336.    char *HoldName;
  337.    char fname[100];
  338.    FILE *f;
  339.  
  340.    if ((flavor[0] != 'C') && (flavor[0] != 'H') && (flavor[0] != 'N') && (flavor[0] != 'D'))
  341.       return (-3);
  342.  
  343.    if (flavor[0] == 'N')
  344.       flavor[0] = 'F';
  345.  
  346.    flavor[1] = '\0';
  347.    if (find_address (node, &addr))
  348.       {
  349.       HoldName = HoldAreaNameMunge(&addr);
  350.       (void) sprintf (fname, "%s%s.%sLO", HoldName, Hex_Addr_Str (&addr), flavor);
  351.  
  352.       if ((f = fopen (fname, "ab")) == NULL)
  353.           {
  354.           return (-2);
  355.           }
  356.       else
  357.           {
  358.           if (file[0] != '\0')
  359.               {
  360.               (void) sprintf (fname, "%s", Full_Addr_Str (&(alias[0])));
  361.               (void) sprintf (junk, ";SEND generated by node %s using %s", fname, ANNOUNCE);
  362.                                        /* A brutal Greylock Hack */
  363.               junk[75] = '\0';
  364.               (void) fprintf (f, "%s\r\n", junk);
  365.               (void) fprintf (f, "%s\r\n", file);
  366.               }
  367.           (void) fclose (f);
  368.           }
  369.       return (0);
  370.       }
  371. /* else */
  372.    return (-1);
  373. }
  374.  
  375. 
  376.