home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / VP2SRC.ZIP / MAIN.C < prev    next >
Text File  |  1991-04-24  |  11KB  |  435 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.09c 91/04/24 20:04:42  Bill
  52.  * Update to fix import 0/0 when packets in multiple areas
  53.  *
  54.  * Revision 4.09b 91/04/20 10:04:42  Bill
  55.  * Update to fix export bad seen-by Trap 000D
  56.  *
  57.  * Revision 4.09a 91/04/09 23:34:42  Bill
  58.  * Update to only zap sent archive names, get zone into atch msg
  59.  *
  60.  * Revision 4.09  91/01/09 23:34:42  Bill
  61.  * Update to insure scan only exact match area names in -File
  62.  *
  63.  * Revision 4.08  90/10/18 03:15:42  Bill
  64.  * Update to fix DOS 1.MSG tearline, convert to MSC 6.0
  65.  *
  66.  * Revision 4.07  90/09/05 22:18:42  Bill
  67.  * Update to fix some message header overlays
  68.  *
  69.  * Revision 4.06  90/08/05  23:10:42  Bill
  70.  * Update to fix some more bugs
  71.  *
  72.  * Revision 4.05  90/06/17  07:30:00  Bill
  73.  * Update to fix date bug
  74.  *
  75.  * Revision 4.04  90/06/08  23:34:42  Bill
  76.  * Update to fix some bugs
  77.  *
  78.  * Revision 3.31  87/12/31  14:53:42  Bob
  79.  * Update to fix some bugs
  80.  *
  81.  * Revision 3.3  87/12/12  00:43:30  Bob
  82.  * Source code release
  83.  *
  84. */
  85.  
  86. #include <stdio.h>
  87. #include <ctype.h>
  88. #include <fcntl.h>
  89. #include <io.h>
  90. #include <time.h>
  91. #include <string.h>
  92. #include <malloc.h>
  93. #include <stdlib.h>
  94. #include <process.h>
  95. #include "fastecho.h"
  96.  
  97. #define DEBUG 0
  98.  
  99. /* Remember to change the message below */
  100. char *REV="$Revision: 4.09c $";
  101.  
  102. extern SEACONFIG config;
  103. extern AREAS_PTR areas[];
  104. extern char board_name[], sysop_name[];
  105. extern int tot_areas;
  106. extern char bbsfile[];
  107. extern char *arc_cmd[];
  108. extern int nread;
  109. extern int arc_args;
  110. extern int last_msg;
  111. extern int high_one;
  112. extern int convert;
  113. extern struct tm *t2;
  114. extern struct _stamp cur_stamp;
  115. extern int *msg_nums;
  116. extern char *holder1;
  117. extern int mail_low, mail_high;
  118. extern int seen_byl;
  119. extern int to_netmail;
  120. extern PACKED p_msg;
  121. extern PKTHDR pkt_hdr;
  122. extern char cur_dir[];
  123. extern char pkt_dir[];
  124. extern char *arc_cmd[];
  125. extern unsigned int def_attr;
  126. extern int seahome;
  127. extern int priv_net;
  128. extern int boss_net, boss_node;
  129. extern int opus_1;
  130. extern int cminternal;
  131. extern int msgs_done;
  132. extern char *NAME;
  133. extern int tossed_some;
  134. extern int to_file;
  135. extern int check_nodes;
  136. extern int no_matrix;
  137. extern int seadog;
  138. extern int quiet;
  139. extern int backup;
  140. extern int killnull;
  141. extern int killbad;
  142. extern int bad_pkt;
  143. extern int bad_pw;
  144. extern int num_zone;
  145. extern int pass_thru;
  146. extern int route_thru;
  147. extern int do_pickup;
  148. extern int num_pw;
  149. extern int num_arc;
  150. extern int bad_msgs;
  151. extern int mail_dir;
  152. extern int arc_compat;
  153. char originline[256];
  154. char seen_byline[512];
  155. int max_msgs = 32000;
  156. char abbsfile[64];
  157. int nokill = 0;
  158. int ctrla = 0;
  159. int seen_aka = 0;
  160. int only_arc = 0;
  161. int noprivate = 0;
  162. int noforward = 0;
  163. int tiny_seen = 0;
  164. int notquiet = 1;
  165. int send_pvt = 0;
  166. int f_file = 0;
  167. int do_path = 1;
  168. int kill_null;
  169. int killed_some = 0;
  170. char chkvar = 0xc7;
  171. KILLPTR killer;
  172. extern int msg_dups;
  173. extern int hwptr;
  174.  
  175. int security_check()
  176. {
  177.     int i;
  178.     char c;
  179.  
  180.     if (strncmp (NAME, "\r\n--- VPurge", 12) != 0)
  181.         return (1);
  182.  
  183.     c = 0;
  184.     for (i = 0; i < 12; i++)
  185.         c += NAME[i];
  186.  
  187.     if (( c & (unsigned char) 0xff) == chkvar)
  188.         return (0);
  189.     else
  190.         return (0);
  191.     }
  192.  
  193. void make_args (
  194.    int   *argc1,
  195.    char **argv1,
  196.    char  *input_line,
  197.    int    argc2,
  198.    char **argv2)
  199. {
  200.    char *p;
  201.    int t, a;
  202.  
  203.    p = input_line;
  204.  
  205.    /* Get to first argument */
  206.    while (*p)
  207.       {
  208.       if (isspace (*p) || (*p == 26))
  209.          {
  210.          ++p;
  211.          }
  212.       else
  213.          {
  214.          break;
  215.          }
  216.       }
  217.  
  218.  
  219.    /* Now peel off arguments one at a time */
  220.    *argc1 = 0;
  221.    t = 1;
  222.    while (*p)
  223.       {
  224.       if (isspace (*p) || (*p == 26))
  225.          {
  226.          t = 1;
  227.          *p = '\0';
  228.          }
  229.       else
  230.          {
  231.          if (t)
  232.             {
  233.             if ((*p == '%') && (isdigit (*(p+1))))
  234.                {
  235.                a = *(p+1) - '0' + 1;
  236.                if (a < argc2)
  237.                   {
  238.                   argv1[*argc1] = argv2[a];
  239.                   ++(*argc1);
  240.                   t = 0;
  241.                   ++p;
  242.                   continue;
  243.                   }
  244.                else
  245.                   {
  246.                   printf ("Warning - argument %%%c is not present!\n", *(p+1));
  247.                   }
  248.                }
  249.             argv1[*argc1] = p;
  250.             ++(*argc1);
  251.             t = 0;
  252.             }
  253.          *p = (char) toupper (*p);
  254.          }
  255.       ++p;
  256.       }
  257. }
  258.  
  259. void fe_usage()
  260. {
  261. #ifdef OS2
  262.    printf ("Usage: VP2 'function' 'arguments'\n\n");
  263. #else
  264.    printf ("Usage: VP 'function' 'arguments'\n\n");
  265. #endif
  266.    printf ("       'function' is one of the following:\n\n");
  267.    printf ("            EXPORT, SCAN, FASTSCAN - send messages from VPurge System\n");
  268.    printf ("            IMPORT, TOSS, FASTTOSS - bring messages into VPurge System\n");
  269.    printf ("\nPlease consult the Conference Mail documentation to determine\n");
  270.    printf ("which arguments to use for each of the possible functions.\n");
  271.    exit (4);
  272. }
  273.  
  274. void main (int argc,char *argv[])
  275. {
  276.    int argc1;
  277.    char **argv1;
  278.    int done;
  279.    FILE *in1;
  280.    char *p;
  281.    char buff1[20], buff2[20];
  282.    char input_line[128];
  283.  
  284.    --argc;
  285.    ++argv;
  286.  
  287.    sscanf (REV, "$%s %s", buff1, buff2);
  288.    printf ("Conference Mail - %s %s by Bob Hartman, FidoNet Node 132/101\n", buff1, buff2);
  289.    printf ("(C) Copyright 1986, 1987 by Spark Software Inc. All rights reserved.\n\n");
  290. #ifdef OS2
  291.    printf ("Modified for OS/2 with VPurge by Bill Andrus, Superfluous Software.\n\n");
  292. #else
  293.    printf ("Modified for DOS with VPurge by Bill Andrus, Superfluous Software.\n\n");
  294. #endif
  295.  
  296.     if (security_check())
  297.         {
  298.         printf ("It appears that you are running a copy of Conference Mail that\n");
  299.         printf ("has been altered! Please contact Bob Hartman at Spark Software\n");
  300.         printf ("(FidoNet Node 132/101) so that the situation can be corrected!\n");
  301.         exit (2);
  302.         }
  303.  
  304.    p = argv[0];
  305.    if (p != NULL)
  306.       {
  307.       while (*p)
  308.          *p++ = (char) toupper (*p);
  309.       }
  310.    else
  311.       {
  312.       fe_usage();
  313.       }
  314.    argv1 = argv;
  315.  
  316.    argc1 = argc;
  317.    f_file = 0;
  318.  
  319.    done = 0;
  320.  
  321.    if (strcmp (argv[0], "FILE") == 0)
  322.       {
  323.       f_file = 1;
  324.       if ((in1 = fopen (argv[1], "r")) == NULL)
  325.          {
  326.          printf ("Cannot open input file '%s' - aborting\n", argv[1]);
  327.          exit (3);
  328.          }
  329.       if (fgets (input_line, 128, in1) == NULL)
  330.          {
  331.          printf ("Input file '%s' is empty - aborting\n", argv[1]);
  332.          fclose (in1);
  333.          exit (0);
  334.          }
  335.  
  336.       argv1 = (char **) malloc (sizeof (char *) * 50);
  337.       make_args(&argc1, argv1, input_line, argc, argv);
  338.       }
  339.  
  340.    while (!done)
  341.       {
  342.       msg_dups = 0;
  343.       max_msgs = 32000;
  344.       ctrla = 0;
  345.       seen_aka = 0;
  346.       only_arc = 0;
  347.       noprivate = 0;
  348.       noforward = 0;;
  349.       tiny_seen = 0;
  350.       notquiet = 1;
  351.       send_pvt = 0;
  352.       tossed_some = 0;
  353.       to_file = 0;
  354.       do_path = 1;
  355.       check_nodes = 0;
  356.       no_matrix = 0;
  357.       killed_some = 0;
  358.       nokill = 0;
  359.       arc_compat = 1;
  360.       seadog = 0;
  361.       quiet = 0;
  362.       backup = 1;
  363.       killnull = 0;
  364.       killbad = 0;
  365.       tot_areas = 0;
  366.       arc_args = 0;
  367.       last_msg = -1;
  368.       high_one = -1;
  369.       mail_high = 0;
  370.       mail_dir = -1;
  371.       convert = 0;
  372.       seahome = 1;
  373.       bad_pkt = 0;
  374.       bad_pw = 0;
  375.       bad_msgs = -1;
  376.       msgs_done = 0;
  377.       priv_net = 0;
  378.       boss_net = 0;
  379.       boss_node = 0;
  380.       num_zone = 0;
  381.       pass_thru = -1;
  382.       route_thru = -1;
  383.       do_pickup = 0;
  384.       num_pw = 0;
  385.       kill_null = 0;
  386.  
  387. #ifndef NO_FS
  388.  
  389.       to_netmail = 1;
  390.       opus_1 = 0;
  391.       cminternal = 0;
  392.       def_attr = 0;
  393.       num_arc = -1;
  394.       hwptr = 0;
  395.  
  396. #endif
  397.  
  398.       if (     strcmp (argv1[0], "FASTTOSS")    == 0 ||
  399.                strcmp (argv1[0], "TOSS")        == 0 ||
  400.                strcmp (argv1[0], "IMPORT")      == 0 )
  401.       {
  402.          fasttoss (argc1, argv1);
  403.       }
  404.       else if (strcmp (argv1[0], "FASTSCAN")    == 0 ||
  405.                strcmp (argv1[0], "SCAN")        == 0 ||
  406.                strcmp (argv1[0], "EXPORT")      == 0 )
  407.       {
  408.          fastscan (argc1, argv1);
  409.       }
  410.       else
  411.       {
  412.          fe_usage();
  413.       }
  414.  
  415.       if (!f_file)
  416.       {
  417.          done = 1;
  418.       }
  419.       else
  420.       {
  421.          if (fgets (input_line, 128, in1) == NULL)
  422.          {
  423.             fclose (in1);
  424.             exit (0);
  425.          }
  426.  
  427.          make_args(&argc1, argv1, input_line, argc, argv);
  428.          printf ("\n");
  429.          if (argc1 == 0)
  430.             done = 1;
  431.       }
  432.    }
  433. }
  434.  
  435.