home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / VP2_409E.SZH / MAIN.C < prev    next >
Text File  |  1991-09-21  |  12KB  |  456 lines

  1. /*
  2.   $Header: main.c 3.31 87/12/31 14:53:42 Bob Exp $
  3.  
  4.                           The Conference Mail System
  5.  
  6.               This module was originally written by Bob Hartman
  7.                        Sysop of FidoNet node 1:132/101
  8.  
  9.    Spark Software, 427-3 Amherst St, CS 2032, Suite 232, Nashua, NH 03061
  10.  
  11.  The Conference Mail System  is a  complete Echomail processing package.  It
  12.  is a superset of the original  Echomail utilities created by Jeff Rush, and
  13.  also contains ideas gleaned from the  ARCmail,  Renum,  oMMM, MGM, and Opus
  14.  programs that were created by various software authors.
  15.  
  16.  This program source code is being released with the following provisions:
  17.  
  18.  1.  You are  free to make  changes to this source  code for use on your own
  19.  machine,  however,  altered source files may not be distributed without the
  20.  consent of Spark Software.
  21.  
  22.  2.  You may distribute "patches"  or  "diff" files for any changes that you
  23.  have made, provided that the "patch" or "diff" files are also sent to Spark
  24.  Software for inclusion in future releases of the entire package.   A "diff"
  25.  file for the source archives may also contain a compiled version,  provided
  26.  it is  clearly marked as not  being created  from the original source code.
  27.  No other  executable  versions may be  distributed without  the  consent of
  28.  Spark Software.
  29.  
  30.  3.  You are free to include portions of this source code in any program you
  31.  develop, providing:  a) Credit is given to Spark Software for any code that
  32.  may is used, and  b) The resulting program is free to anyone wanting to use
  33.  it, including commercial and government users.
  34.  
  35.  4.  There is  NO  technical support  available for dealing with this source
  36.  code, or the accompanying executable files.  This source  code  is provided
  37.  as is, with no warranty expressed or implied (I hate legalease).   In other
  38.  words, if you don't know what to do with it,  don't use it,  and if you are
  39.  brave enough to use it, you're on your own.
  40.  
  41.  Spark Software may be contacted by modem at (603) 888-8179 (node 1:132/101)
  42.  on the public FidoNet network, or at the address given above.
  43.  
  44.  To use this code you will need Microsoft C version 4.0, and also Microsoft
  45.  Macro Assembler version 4.0.
  46.  
  47. */
  48.  
  49. /*
  50.    $Log:    main.c $
  51.  * Revision 4.09f 91/08/23           WRA
  52.  * .234 update to add BBS environment string to MAIL.SYS search
  53.  *
  54.  * Revision 4.09e 91/06/27           WRA
  55.  * Update to add ^AFLAGS TFS to file attach message
  56.  * .181 update to save sour packets from Beta SEADogs
  57.  * Revision 4.09e 91/07/09           WRA
  58.  * .190 update to add bad packet data to logs & optionally ignore them
  59.  * Revision 4.09e 91/07/14           WRA
  60.  * .194 update to add CR/LF at the end of the TFS line
  61.  *
  62.  * Revision 4.09d 91/06/11           GJS
  63.  * Update for to include statistics and logging
  64.  *
  65.  * Revision 4.09c 91/04/24 20:04:42  Bill
  66.  * Update to fix import 0/0 when packets in multiple areas
  67.  *
  68.  * Revision 4.09b 91/04/20 10:04:42  Bill
  69.  * Update to fix export bad seen-by Trap 000D
  70.  *
  71.  * Revision 4.09a 91/04/09 23:34:42  Bill
  72.  * Update to only zap sent archive names, get zone into atch msg
  73.  *
  74.  * Revision 4.09  91/01/09 23:34:42  Bill
  75.  * Update to insure scan only exact match area names in -File
  76.  *
  77.  * Revision 4.08  90/10/18 03:15:42  Bill
  78.  * Update to fix DOS 1.MSG tearline, convert to MSC 6.0
  79.  *
  80.  * Revision 4.07  90/09/05 22:18:42  Bill
  81.  * Update to fix some message header overlays
  82.  *
  83.  * Revision 4.06  90/08/05  23:10:42  Bill
  84.  * Update to fix some more bugs
  85.  *
  86.  * Revision 4.05  90/06/17  07:30:00  Bill
  87.  * Update to fix date bug
  88.  *
  89.  * Revision 4.04  90/06/08  23:34:42  Bill
  90.  * Update to fix some bugs
  91.  *
  92.  * Revision 3.31  87/12/31  14:53:42  Bob
  93.  * Update to fix some bugs
  94.  *
  95.  * Revision 3.3  87/12/12  00:43:30  Bob
  96.  * Source code release
  97.  *
  98. */
  99.  
  100. #include <stdio.h>
  101. #include <ctype.h>
  102. #include <fcntl.h>
  103. #include <io.h>
  104. #include <time.h>
  105. #include <string.h>
  106. #include <malloc.h>
  107. #include <stdlib.h>
  108. #include <process.h>
  109. #include "fastecho.h"
  110.  
  111. #define DEBUG 0
  112.  
  113. /* Remember to change the message below */
  114. #if STATS
  115.     char *REV="$Revision: 4.09e $";
  116. #else
  117.     char *REV="$Revision: 4.09e $";
  118. #endif
  119.  
  120. extern SEACONFIG config;
  121. extern AREAS_PTR areas[];
  122. extern char board_name[], sysop_name[];
  123. extern int tot_areas;
  124. extern char bbsfile[];
  125. extern char *arc_cmd[];
  126. extern int nread;
  127. extern int arc_args;
  128. extern int last_msg;
  129. extern int high_one;
  130. extern int convert;
  131. extern struct tm *t2;
  132. extern struct _stamp cur_stamp;
  133. extern int *msg_nums;
  134. extern char *holder1;
  135. extern int mail_low, mail_high;
  136. extern int seen_byl;
  137. extern int to_netmail;
  138. extern PACKED p_msg;
  139. extern PKTHDR pkt_hdr;
  140. extern char cur_dir[];
  141. extern char pkt_dir[];
  142. extern char *arc_cmd[];
  143. extern unsigned int def_attr;
  144. extern int seahome;
  145. extern int priv_net;
  146. extern int boss_net, boss_node;
  147. extern int opus_1;
  148. extern int cminternal;
  149. extern int msgs_done;
  150. extern char *NAME;
  151. extern int tossed_some;
  152. extern int to_file;
  153. extern int check_nodes;
  154. extern int no_matrix;
  155. extern int seadog;
  156. extern int quiet;
  157. extern int backup;
  158. extern int killnull;
  159. extern int killbad;
  160. extern int bad_pkt;
  161. extern int bad_pw;
  162. extern int num_zone;
  163. extern int pass_thru;
  164. extern int route_thru;
  165. extern int do_pickup;
  166. extern int num_pw;
  167. extern int num_arc;
  168. extern int bad_msgs;
  169. extern int mail_dir;
  170. extern int arc_compat;
  171. char originline[256];
  172. char seen_byline[512];
  173. int max_msgs = 32000;
  174. char abbsfile[64];
  175. int nokill = 0;
  176. int ctrla = 0;
  177. int seen_aka = 0;
  178. int only_arc = 0;
  179. int noprivate = 0;
  180. int noforward = 0;
  181. int tiny_seen = 0;
  182. int notquiet = 1;
  183. int send_pvt = 0;
  184. int f_file = 0;
  185. int do_path = 1;
  186. int kill_null;
  187. int kill_pkt;
  188. int killed_some = 0;
  189. char chkvar = 0xc7;
  190. KILLPTR killer;
  191. extern int msg_dups;
  192. extern int hwptr;
  193.  
  194. int security_check()
  195. {
  196.     int i;
  197.     char c;
  198.  
  199.     if (strncmp (NAME, "\r\n--- VP", 8) != 0)
  200.         return (1);
  201.  
  202.     c = 0;
  203.     for (i = 0; i < 12; i++)
  204.         c += NAME[i];
  205.  
  206.     if (( c & (unsigned char) 0xff) == chkvar)
  207.         return (0);
  208.     else
  209.         return (0);
  210.     }
  211.  
  212. void make_args (
  213.    int   *argc1,
  214.    char **argv1,
  215.    char  *input_line,
  216.    int    argc2,
  217.    char **argv2)
  218. {
  219.    char *p;
  220.    int t, a;
  221.  
  222.    p = input_line;
  223.  
  224.    /* Get to first argument */
  225.    while (*p)
  226.       {
  227.       if (isspace (*p) || (*p == 26))
  228.          {
  229.          ++p;
  230.          }
  231.       else
  232.          {
  233.          break;
  234.          }
  235.       }
  236.  
  237.  
  238.    /* Now peel off arguments one at a time */
  239.    *argc1 = 0;
  240.    t = 1;
  241.    while (*p)
  242.       {
  243.       if (isspace (*p) || (*p == 26))
  244.          {
  245.          t = 1;
  246.          *p = '\0';
  247.          }
  248.       else
  249.          {
  250.          if (t)
  251.             {
  252.             if ((*p == '%') && (isdigit (*(p+1))))
  253.                {
  254.                a = *(p+1) - '0' + 1;
  255.                if (a < argc2)
  256.                   {
  257.                   argv1[*argc1] = argv2[a];
  258.                   ++(*argc1);
  259.                   t = 0;
  260.                   ++p;
  261.                   continue;
  262.                   }
  263.                else
  264.                   {
  265.                   printf ("Warning - argument %%%c is not present!\n", *(p+1));
  266.                   }
  267.                }
  268.             argv1[*argc1] = p;
  269.             ++(*argc1);
  270.             t = 0;
  271.             }
  272.          *p = (char) toupper (*p);
  273.          }
  274.       ++p;
  275.       }
  276. }
  277.  
  278. void fe_usage()
  279. {
  280. #ifdef OS2
  281.    printf ("Usage: VP2 'function' 'arguments'\n\n");
  282. #else
  283.    printf ("Usage: VP 'function' 'arguments'\n\n");
  284. #endif
  285.    printf ("       'function' is one of the following:\n\n");
  286.    printf ("            EXPORT, SCAN, FASTSCAN - send messages from the ConfMail System\n");
  287.    printf ("            IMPORT, TOSS, FASTTOSS - bring messages into the ConfMail System\n");
  288.    printf ("\nPlease consult the ConfMail/VPurge documentation to determine\n");
  289.    printf ("which arguments to use for each of the possible functions.\n");
  290.    exit (4);
  291. }
  292.  
  293. void main (int argc,char *argv[])
  294. {
  295.    int argc1;
  296.    char **argv1;
  297.    int done;
  298.    FILE *in1 = NULL;
  299.    char *p;
  300.    char buff1[20], buff2[20];
  301.    char input_line[128];
  302.  
  303.    --argc;
  304.    ++argv;
  305.  
  306.    sscanf (REV, "$%s %s", buff1, buff2);
  307.    printf ("Conference Mail - %s %s by Bob Hartman, FidoNet Node 104/501\n", buff1, buff2);
  308.    printf ("(C) Copyright 1986, 1987 by Spark Software Inc. All rights reserved.\n\n");
  309. #ifdef OS2
  310.    printf ("Modified for OS/2 with VPurge by Bill Andrus, Superfluous Software.\n\n");
  311. #else
  312.    printf ("Modified for DOS with VPurge by Bill Andrus, Superfluous Software.\n\n");
  313. #endif
  314.  
  315.     if (security_check())
  316.         {
  317.         printf ("It appears that you are running a copy of Conference Mail that\n");
  318.         printf ("has been altered! Please contact Bob Hartman at Spark Software\n");
  319.         printf ("(FidoNet Node 104/501) so that the situation can be corrected!\n");
  320.         exit (2);
  321.         }
  322.  
  323.    p = argv[0];
  324.    if (p != NULL)
  325.       {
  326.       while (*p)
  327.          *p++ = (char) toupper (*p);
  328.       }
  329.    else
  330.       {
  331.       fe_usage();
  332.       }
  333.    argv1 = argv;
  334.  
  335.    argc1 = argc;
  336.    f_file = 0;
  337.  
  338.    done = 0;
  339.  
  340.    if (strcmp (argv[0], "FILE") == 0)
  341.       {
  342.       f_file = 1;
  343.       if ((in1 = fopen (argv[1], "r")) == NULL)
  344.          {
  345.          printf ("Cannot open input file '%s' - aborting\n", argv[1]);
  346.          exit (3);
  347.          }
  348.       if (fgets (input_line, 128, in1) == NULL)
  349.          {
  350.          printf ("Input file '%s' is empty - aborting\n", argv[1]);
  351.          fclose (in1);
  352.          exit (0);
  353.          }
  354.  
  355.       argv1 = (char **) malloc (sizeof (char *) * 50);
  356.       make_args(&argc1, argv1, input_line, argc, argv);
  357.       }
  358.  
  359.    while (!done)
  360.       {
  361.       msg_dups = 0;
  362.       max_msgs = 32000;
  363.       ctrla = 0;
  364.       seen_aka = 0;
  365.       only_arc = 0;
  366.       noprivate = 0;
  367.       noforward = 0;;
  368.       tiny_seen = 0;
  369.       notquiet = 1;
  370.       send_pvt = 0;
  371.       tossed_some = 0;
  372.       to_file = 0;
  373.       do_path = 1;
  374.       check_nodes = 0;
  375.       no_matrix = 0;
  376.       killed_some = 0;
  377.       nokill = 0;
  378.       arc_compat = 1;
  379.       seadog = 0;
  380.       quiet = 0;
  381.       backup = 1;
  382.       killnull = 0;
  383.       killbad = 0;
  384.       tot_areas = 0;
  385.       arc_args = 0;
  386.       last_msg = -1;
  387.       high_one = -1;
  388.  
  389.       mail_high = 0;
  390.       mail_dir = -1;
  391.       convert = 0;
  392.       seahome = 1;
  393.       bad_pkt = 0;
  394.       bad_pw = 0;
  395.       bad_msgs = -1;
  396.       msgs_done = 0;
  397.       priv_net = 0;
  398.       boss_net = 0;
  399.       boss_node = 0;
  400.       num_zone = 0;
  401.       pass_thru = -1;
  402.       route_thru = -1;
  403.       do_pickup = 0;
  404.       num_pw = 0;
  405.       kill_null = 0;
  406.       kill_pkt  = 0;
  407.  
  408. #ifndef NO_FS
  409.  
  410.       to_netmail = 1;
  411.       opus_1 = 0;
  412.       cminternal = 0;
  413.       def_attr = 0;
  414.       num_arc = -1;
  415.       hwptr = 0;
  416.  
  417. #endif
  418.  
  419.       if (     strcmp (argv1[0], "FASTTOSS")    == 0 ||
  420.                strcmp (argv1[0], "TOSS")        == 0 ||
  421.                strcmp (argv1[0], "IMPORT")      == 0 )
  422.       {
  423.          fasttoss (argc1, argv1);
  424.       }
  425.       else if (strcmp (argv1[0], "FASTSCAN")    == 0 ||
  426.                strcmp (argv1[0], "SCAN")        == 0 ||
  427.                strcmp (argv1[0], "EXPORT")      == 0 )
  428.       {
  429.          fastscan (argc1, argv1);
  430.       }
  431.       else
  432.       {
  433.          fe_usage();
  434.       }
  435.  
  436.       if (!f_file)
  437.       {
  438.          done = 1;
  439.       }
  440.       else
  441.       {
  442.          if (fgets (input_line, 128, in1) == NULL)
  443.          {
  444.             fclose (in1);
  445.             exit (0);
  446.          }
  447.  
  448.          make_args(&argc1, argv1, input_line, argc, argv);
  449.          printf ("\n");
  450.          if (argc1 == 0)
  451.             done = 1;
  452.       }
  453.    }
  454. }
  455.  
  456.