home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / VP2_409E.SZH / FASTSCAN.C < prev    next >
Text File  |  1991-08-22  |  25KB  |  794 lines

  1. /*
  2.   $Header: fastscan.c 3.32 87/12/31 15:01:04 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:    fastscan.c $
  51.  * Revision 4.09d 91/06/11            GJS
  52.  * Update for to include statistics and logging
  53.  *
  54.  * Revision 3.32  87/12/31  15:01:04  Bob
  55.  * Fixed bug dealing with -O not setting cur_dir
  56.  *
  57.  * Revision 3.31  87/12/31  14:54:30  Bob
  58.  * Fixed bug in -I switch usage
  59.  *
  60.  * Revision 3.3  87/12/12  00:42:02  Bob
  61.  * Source code release
  62.  *
  63. */
  64.  
  65. #include <stdio.h>
  66. #include <ctype.h>
  67. #include <fcntl.h>
  68. #include <io.h>
  69. #include <time.h>
  70. #include <string.h>
  71. #include <stdlib.h>
  72. #include <malloc.h>
  73. #include <math.h>
  74. #include <process.h>
  75. #include "fastecho.h"
  76.  
  77. #if STATS
  78.    #include "stats.h"
  79. #endif
  80.  
  81. #define DEBUG 0
  82.  
  83. extern char *REV;
  84. extern char *NAME;
  85. extern SEACONFIG config;
  86. extern AREAS_PTR areas[];
  87. extern char board_name[], sysop_name[];
  88. extern int tot_areas;
  89. extern char bbsfile[];
  90. extern char *arc_cmd[];
  91. extern int nread;
  92. extern int arc_args;
  93. extern int last_msg;
  94. extern int high_one;
  95. extern int convert;
  96. extern struct tm *t2;
  97. extern struct _stamp cur_stamp;
  98. extern int *msg_nums;
  99. extern char *holder1;
  100. extern int f_file;
  101. extern int mail_low, mail_high;
  102. extern int seen_byl;
  103. extern int to_netmail;
  104. extern PACKED p_msg;
  105. extern PKTHDR pkt_hdr;
  106. extern char cur_dir[];
  107. extern char pkt_dir[];
  108. extern unsigned int def_attr;
  109. extern int seahome;
  110. extern int priv_net;
  111. extern int boss_net, boss_node;
  112. extern int opus_1;
  113. extern int cminternal;
  114. extern int msgs_done;
  115. extern char tearline[];
  116. extern char originline[];
  117. extern char seen_byline[];
  118. extern int max_msgs;
  119. extern char abbsfile[];
  120. extern int ctrla;
  121. extern int seen_aka;
  122. extern int only_arc;
  123. extern int noprivate;
  124. extern int noforward;
  125. extern int tiny_seen;
  126. extern int notquiet;
  127. extern int send_pvt;
  128. extern int hwptr;
  129. extern int do_path;
  130. extern char *SEENBYSTR;
  131. extern char *PATHSTR;
  132. extern int path_nets[];
  133. extern int path_nodes[];
  134. extern int tot_path;
  135. extern PW_PTR pw[];
  136. extern int num_pw;
  137. extern int tot_scanned;
  138. extern WBUFFER wbuffs[];
  139. extern int scan_file;
  140. extern int arc_compat;
  141. extern char tmpjunk[];
  142. extern char *noareasbbs;
  143.  
  144. void fastscan (int argc,char *argv[])
  145. {
  146. /*  int i, j, k, l, exit_code, ctla, sbl; */
  147.     int i, j, k, l, exit_code;
  148.     long t1, t1a, t1b;
  149.     char buff1[20], buff2[20];
  150.     FILE *ifile;
  151.  
  152.     #if STATS
  153.        LogBegin ("Export");
  154.     #endif
  155.  
  156.     ifile = NULL;
  157.     printf ("Exporting Messages from Conference Mail System:\n\n");
  158.     seen_aka = 2;
  159.  
  160.     holder1 = malloc ((unsigned) (NUMBLOCKS*1024 + sizeof (MSG)));
  161.     if (holder1 == NULL)
  162.         {
  163.         printf ("Could not malloc() message space, aborting\n");
  164.         exit (2);
  165.         }
  166.     msg_nums = (int *) malloc ((unsigned) (NUMMSGS * sizeof (int)));
  167.     if (msg_nums == NULL)
  168.         {
  169.         printf ("Could not malloc() message number space, aborting\n");
  170.         free (holder1);
  171.         exit (2);
  172.         }
  173.  
  174.     if (get_sea_config (&config) == -1)
  175.         {
  176.         if (get_fido_config (&config) == -1)
  177.             {
  178.             #if STATS
  179.                LogExit(2);
  180.             #else
  181.                exit (2);
  182.             #endif
  183.             }
  184.         }
  185.  
  186.     tot_scanned = 0;
  187.  
  188.     if (argc > 1)
  189.         {
  190.         if ((argv[1][0] != '-') && (argv[1][0] != '/'))
  191.             {
  192.             strcpy (abbsfile, argv[1]);
  193.             ++argv;
  194.             --argc;
  195.             }
  196.         else
  197.             {
  198.             printf (noareasbbs);
  199.             strcpy (abbsfile, "AREAS.BBS");
  200.             }
  201.         while ((argc > 1) && ((argv[1][0] == '-') || (argv[1][0] == '/')))
  202.             {
  203.             ++argv;
  204.             --argc;
  205.             switch (argv[0][1])
  206.                 {
  207.                 case 'A':
  208.                 case 'a':
  209.                     to_netmail = 0;
  210.                     arc_args = 0;
  211.                     if (argc > 1)
  212.                         {
  213.                         while (--argc)
  214.                             {
  215.                             arc_cmd[arc_args++] = argv[1];
  216.                             ++argv;
  217.                             }
  218.                         }
  219.                     break;
  220.  
  221.                 case 'B':
  222.                 case 'b':
  223.                     arc_compat = 0;
  224.                     break;
  225.  
  226.                 case 'C':
  227.                 case 'c':
  228.                     def_attr |= MSGCRASH;
  229.                     break;
  230.  
  231.                 case 'D':
  232.                 case 'd':
  233.                     strcpy (cur_dir, argv[1]);
  234.                     if (cur_dir[strlen(cur_dir)-1] != '\\')
  235.                         strcat (cur_dir, "\\");
  236.                     --argc;
  237.                     ++argv;
  238.                     seahome = 0;
  239.                     break;
  240.  
  241.                 case 'F':
  242.                 case 'f':
  243.                     #if STATS
  244.                        if ((ifile = fopen (argv[1], "rb")) == NULL)
  245.                           {
  246.                           printf(LogMessage(1, "Cannot open '%s' for input - exiting\n", argv[1]));
  247.                           LogExit(2);
  248.                           }
  249.                     #else
  250.                        if ((ifile = fopen (argv[1], "r")) == NULL)
  251.                           {
  252.                           printf ("Cannot open '%s' for input - exiting\n", argv[1]);
  253.                           exit (2);
  254.                           }
  255.                     #endif
  256.                     --argc;
  257.                     ++argv;
  258.                     break;
  259.  
  260.                 case 'G':
  261.                 case 'g':
  262.                     do_path = 0;
  263.                     break;
  264.  
  265.                 case 'H':
  266.                 case 'h':
  267.                     def_attr |= MSGHOLD;
  268.                     break;
  269.  
  270.                 case 'I':
  271.                 case 'i':
  272.                     cminternal = 1;
  273.                     break;
  274.  
  275.                 case 'K':
  276.                 case 'k':
  277.                     ctrla = 1;
  278.                     break;
  279.  
  280.                 case 'M':
  281.                 case 'm':
  282.                     max_msgs = atoi (argv[1]);
  283.                     ++argv;
  284.                     --argc;
  285.                     break;
  286.  
  287.                 case 'N':
  288.                 case 'n':
  289.                     if ((argv[0][2] == 'p') || (argv[0][2] == 'P'))
  290.                         {
  291.                         noprivate = 1;
  292.                         break;
  293.                         }
  294.                     else if ((argv[0][2] == 'f') || (argv[0][2] == 'F'))
  295.                         {
  296.                         noforward = 1;
  297.                         break;
  298.                         }
  299.                     break;
  300.  
  301.                 case 'O':
  302.                 case 'o':
  303.                     opus_1 = 1;
  304.                     to_netmail = 0;
  305.                     strcpy (pkt_dir, argv[1]);
  306.                     if (pkt_dir[strlen(pkt_dir)-1] != '\\')
  307.                         strcat (pkt_dir, "\\");
  308.                     strcpy (cur_dir, argv[1]);
  309.                     if (cur_dir[strlen(cur_dir)-1] != '\\')
  310.                         strcat (cur_dir, "\\");
  311.                     --argc;
  312.                     ++argv;
  313.                     break;
  314.  
  315.                 case 'P':
  316.                 case 'p':
  317.                     strcpy (pkt_dir, argv[1]);
  318.                     if (pkt_dir[strlen(pkt_dir)-1] != '\\')
  319.                         strcat (pkt_dir, "\\");
  320.                     --argc;
  321.                     ++argv;
  322.                     break;
  323.  
  324.                 case 'Q':
  325.                 case 'q':
  326.                     notquiet = 0;
  327.                     break;
  328.  
  329.                 case 'R':
  330.                 case 'r':
  331.                     send_pvt = 1;
  332.                     break;
  333.  
  334.                 case 'S':
  335.                 case 's':
  336.                     seen_aka = atoi (argv[1]) + 1;
  337.                     ++argv;
  338.                     --argc;
  339.                     break;
  340.  
  341.                 case 'T':
  342.                 case 't':
  343.                     tiny_seen = 1;
  344.                     break;
  345.  
  346.                 case '!':
  347.                     only_arc = 1;
  348.                     break;
  349.  
  350.                 default:
  351.                     if (isdigit(argv[0][1]))
  352.                         {
  353.                         hwptr = atoi (&(argv[0][1]));
  354.                         if (hwptr < 2)
  355.                             break;
  356.                         }
  357.                     printf ("Don't understand '%s'\n", argv[0]);
  358.                     (void) fs_usage ();
  359.                 }
  360.             }
  361.         if (argc > 1)
  362.             {
  363.             (void) fs_usage ();
  364.             }
  365.         }
  366.     else
  367.         {
  368.         printf (noareasbbs);
  369.         strcpy (abbsfile, "AREAS.BBS");
  370.         }
  371.  
  372.     if (arc_args == 0)
  373.         {
  374. #ifndef OS2
  375.         arc_args = 3;
  376.         if (((arc_cmd[0] = malloc (6)) == NULL) ||
  377.             ((arc_cmd[1] = malloc (5)) == NULL) ||
  378.             ((arc_cmd[2] = malloc (2)) == NULL))
  379. #else
  380.         arc_args = 2;
  381.         if (((arc_cmd[0] = malloc (5)) == NULL) ||
  382.             ((arc_cmd[1] = malloc (3)) == NULL))
  383. #endif
  384.             {
  385.             printf ("Out of memory compiling ARC command - exiting\n");
  386.             exit (2);
  387.             }
  388. #ifndef OS2
  389.         strcpy (arc_cmd[0], "PKARC");
  390.         strcpy (arc_cmd[1], "-OCT");
  391.         strcpy (arc_cmd[2], "A");
  392. #else
  393.         strcpy (arc_cmd[0], "ARC2");
  394.         strcpy (arc_cmd[1], "A5");
  395. #endif
  396.         }
  397.  
  398.     if (((arc_cmd[arc_args] = malloc (80)) == NULL) ||
  399.         ((arc_cmd[arc_args+1] = malloc (80)) == NULL))
  400.         {
  401.         printf ("Out of memory compiling ARC command - exiting\n");
  402.         exit (2);
  403.         }
  404.  
  405.  
  406.    if (cminternal && (arc_args == 0))
  407.       {
  408.       printf ("Cannot use -I without -A - exiting\n");
  409.       exit (2);
  410.       }
  411.  
  412.     sprintf (sysop_name, "Sysop of %d/%d", config.net[1], config.node[1]);
  413.     strcpy  (board_name, "Unknown Board - Node");
  414.  
  415.    /* Strip out duplicate AKA's */
  416.    for (i = 1; i < config.num_addrs; i++)
  417.       {
  418.       for (j = i+1; j <= config.num_addrs; j++)
  419.          {
  420.          if ((config.net[i] == config.net[j]) &&
  421.              (config.node[i] == config.node[j]))
  422.             {
  423.             /* Found a duplicate AKA */
  424.             for (k = j+1; k <= config.num_addrs; k++)
  425.                {
  426.                config.net[k-1] = config.net[k];
  427.                config.node[k-1] = config.node[k];
  428.                }
  429.             --config.num_addrs;
  430.             break;
  431.             }
  432.          }
  433.       }
  434.  
  435.     /* Save how many are the default */
  436.     seen_aka = seen_aka>config.num_addrs?config.num_addrs:seen_aka;
  437.  
  438.     if (compile_areas ((unsigned char *)abbsfile) != 0)
  439.         {
  440.         #if STATS
  441.            printf (LogMessage(1, "Could not process AREAS file\n"));
  442.            LogExit(2);
  443.         #else
  444.            printf ("Could not process AREAS file\n");
  445.            exit (2);
  446.         #endif
  447.         }
  448.  
  449.    /* Now read areas from file if necessary */
  450.    if (ifile != NULL)
  451.       {
  452.       while (fgets (tmpjunk, 200, ifile) != NULL)
  453.          {
  454.          #if STATS
  455.             tmpjunk[strcspn(tmpjunk, "\r")] = 0;
  456.          #endif
  457.          for (i = 0; i < tot_areas; i++)
  458.             {
  459.             /* Did we match the name? */
  460.             #if STATS
  461.                if (stricmp(tmpjunk, areas[i]->area_name) == 0)
  462.             #else
  463.                if ((strlen(areas[i]->area_name) == strcspn(tmpjunk, "\r"))
  464.                 && (strnicmp(tmpjunk, areas[i]->area_name, strlen(areas[i]->area_name)) == 0))
  465.             #endif
  466.                {
  467.                /* Mark as unavailable now, and switch it later */
  468.                areas[i]->flags |= NOT_AVAIL;
  469.                }
  470.             }
  471.          }
  472.  
  473.       /* Swap the state of the available flag */
  474.       for (i = 0; i < tot_areas; i++)
  475.          {
  476.          if (areas[i]->flags & NOT_AVAIL)
  477.             {
  478.             areas[i]->flags &= ~NOT_AVAIL;
  479.             }
  480.          else
  481.             {
  482.             areas[i]->flags |= NOT_AVAIL;
  483.             }
  484.          }
  485.  
  486.       fclose (ifile);
  487.       }
  488.  
  489.     /* Now set up the default nodes */
  490.     for (i = 0; i < tot_areas; i++)
  491.         {
  492.         for (j = 1; j <= seen_aka; j++)
  493.             {
  494.             areas[i]->zone[areas[i]->num_nodes]   = config.zone[j];
  495.             areas[i]->net[areas[i]->num_nodes]    = config.net[j];
  496.             areas[i]->node[areas[i]->num_nodes]   = config.node[j];
  497.             areas[i]->handle[areas[i]->num_nodes] = -1;
  498.             areas[i]->aname[areas[i]->num_nodes]  = areas[i]->area_name;
  499.  
  500.             #if STATS
  501.                 areas[i]->msgs_scanned[areas[i]->num_nodes] = 0;
  502.             #endif
  503.  
  504.             ++areas[i]->num_nodes;
  505.             }
  506.         sort_em (&(areas[i]->zone[0]), &(areas[i]->net[0]), &(areas[i]->node[0]),
  507.             areas[i]->num_nodes, 1, &(areas[i]->handle[0]), &(areas[i]->aname[0]));
  508.         }
  509.  
  510.    sscanf (REV, "$%s %s", buff1, buff2);
  511.  
  512.     sprintf (tearline, NAME, buff2);
  513.  
  514.     /* Set up the data for the current time stamp */
  515.     t1 = time(NULL);
  516.     t2 = localtime (&t1);
  517.     cur_stamp.date = ((t2->tm_year - 80)<<9) + ((t2->tm_mon+1)<<5) + t2->tm_mday;
  518.     cur_stamp.time = (t2->tm_hour<<11) + (t2->tm_min<<5) + (t2->tm_sec>>1);
  519.  
  520.     /* If we are going to packet, set some extra stuff up */
  521.     if (!to_netmail)
  522.         {
  523.         pkt_hdr.orig_net  = config.net[1];
  524.         pkt_hdr.orig_node = config.node[1];
  525.         pkt_hdr.month     = t2->tm_mon;
  526.         pkt_hdr.day       = t2->tm_mday;
  527.         pkt_hdr.year      = t2->tm_year;
  528.         pkt_hdr.hour      = t2->tm_hour;
  529.         pkt_hdr.minute    = t2->tm_min;
  530.         pkt_hdr.second    = t2->tm_sec;
  531.         pkt_hdr.rate        = 0;
  532.         pkt_hdr.ver        = PKTVER;
  533.         pkt_hdr.product   = MYPRODUCT;
  534.       pkt_hdr.rev_lev   = (char) ((REV[11]-'0')*(unsigned)10+(REV[13]-'0'));
  535.       for (i = 0; i < 8; i++)
  536.          pkt_hdr.password[i] = 0;
  537.         for (i = 0; i < 20; i++)
  538.             pkt_hdr.extra[i] = 0;
  539.       pkt_hdr.pr_data = (long) REV[14];
  540.         p_msg.ver = PKTVER;
  541.         p_msg.orig_node = config.node[1];
  542.         p_msg.orig_net = config.net[1];
  543.         p_msg.cost = 0;
  544.         }
  545.  
  546.     (void) high_msg (config.mailpath, &mail_high, &mail_low);
  547.     printf ("MAIL area '%s' has highest message %d\n", config.mailpath, mail_high);
  548.  
  549.    exit_code = 0;
  550.  
  551.     seen_byline[0] = '\r';
  552.     if (!only_arc)
  553.         {
  554.         for (i = 0; i < tot_areas; i++)
  555.             {
  556.             /* If we have no nodes to process for this one then skip it */
  557.             if ( (areas[i]->num_nodes == seen_aka) &&
  558.             (!((areas[i]->flags & ROUTETHRU) || (areas[i]->flags & MAIL_DIR))))
  559.                 {
  560.             continue;
  561.             }
  562.  
  563.          if ((areas[i]->flags & MAIL_DIR) && (to_netmail))
  564.             {
  565.             printf ("Area MAIL_DIR not going to ARCmail - not processed\n");
  566.             }
  567.          else if ((*(areas[i]->msgs_in_area) == -1) || !(areas[i]->flags & SIBLING))
  568.             {
  569.             if (!(areas[i]->flags & NOT_AVAIL))
  570.                {
  571.                 create_seen(&seen_byline[1], &(areas[i]->net[0]), &(areas[i]->node[0]),
  572.                     areas[i]->num_nodes, 1, SEENBYSTR);
  573.  
  574.                if (do_path)
  575.                   {
  576.                   seen_byl = strlen (seen_byline);
  577.                   sprintf (&(seen_byline[seen_byl-2]), "\001PATH: %d/%d\r\n\r\n",
  578.                      config.net[1], config.node[1]);
  579.                   seen_byl = strlen (seen_byline);
  580.                   }
  581.  
  582. #if DEBUG
  583. printf ("seen_byline = %d chars long and it is \n'%s'\n", strlen(seen_byline), seen_byline);
  584. #endif
  585.                make_originline (areas[i]);
  586.                   exit_code = scan (areas[i]);
  587.                }
  588.             }
  589.          else
  590.             {
  591.             printf ("Area '%s' already scanned under an alias name\n", areas[i]->area_name);
  592.             }
  593.  
  594.          /* Now write null bytes and close open files */
  595.          if (!to_netmail)
  596.             {
  597.             k = i + 1;
  598.             for (j = 0; j < areas[i]->num_nodes; j++)
  599.                {
  600.                if (areas[i]->handle[j] > 0)
  601.                   {
  602.                   if ((i < tot_areas - 1) && (exit_code == 0))
  603.                      {
  604.                      for (l = 0; l < areas[k]->num_nodes; l++)
  605.                         {
  606.                         if ((areas[i]->net[j] == areas[k]->net[l]) &&
  607.                             (areas[i]->node[j] == areas[k]->node[l]))
  608.                            {
  609.                            areas[k]->handle[l] = areas[i]->handle[j];
  610.                            break;
  611.                            }
  612.                         }
  613.                      if (l < areas[k]->num_nodes)
  614.                         continue;
  615.                      }
  616.                   (void) fast_write (areas[i]->handle[j], "\0\0", 2);
  617.                   (void) fast_close (areas[i]->handle[j]);
  618.                   areas[i]->handle[j] = -1;
  619.                   }
  620.                }
  621.             }
  622.  
  623.          if (exit_code >= 1)
  624.                 {
  625.                 break;
  626.                 }
  627.             }
  628.         }
  629.  
  630.     free(holder1);
  631.     free((char *) msg_nums);
  632.  
  633.    t1b = time(NULL);
  634.  
  635.    /* Free up our buffer pointers since we don't need them any more */
  636.    for (i = 0; i < 20; i++)
  637.       {
  638.       if (wbuffs[i].wbuff != NULL)
  639.          {
  640.          _ffree (wbuffs[i].wbuff);
  641.          wbuffs[i].wbuff = NULL;
  642.          wbuffs[i].wptr = NULL;
  643.          wbuffs[i].wsize = -1;
  644.          }
  645.       }
  646.  
  647.     /* If we have to do the ARCmail, go and do it */
  648.     if ((!to_netmail) && ((!opus_1) || cminternal))
  649.         {
  650.         arc_cmd[arc_args+2] = NULL;
  651.         arc_a ();
  652.         free (arc_cmd[arc_args]);
  653.         free (arc_cmd[arc_args+1]);
  654.         }
  655.  
  656.    t1a = time(NULL);
  657.    t1a = t1a - t1b;
  658.    t1b = t1b - t1;
  659.    printf ("\nExporting %d messages created %d outbound messages and took %02ld:", tot_scanned, msgs_done, t1b/3600);
  660.    t1b = t1b%3600;
  661.    printf ("%02ld:", t1b/60);
  662.    t1b = t1b%60;
  663.    printf ("%02ld\n", t1b);
  664.    if (!to_netmail && !opus_1)
  665.       {
  666.       printf ("ARCmailing the packets took %02ld:", t1a/3600);
  667.       t1a = t1a%3600;
  668.       printf ("%02ld:", t1a/60);
  669.       t1a = t1a%60;
  670.       printf ("%02ld\n", t1a);
  671.       }
  672.  
  673.    if (!f_file)
  674.       #if STATS
  675.          LogExit(exit_code);
  676.       #else
  677.          exit(exit_code);
  678.       #endif
  679.  
  680.    for (i = 0; i < tot_areas; i++)
  681.       {
  682.       free (areas[i]->msg_path);
  683.       free (areas[i]->area_name);
  684.       if (!(areas[i]->flags & SIBLING))
  685.          free ((char *) areas[i]->msgs_in_area);
  686.       free ((char *) areas[i]->net);
  687.       free ((char *) areas[i]->node);
  688.       free ((char *) areas[i]->handle);
  689.       free ((char *) areas[i]->aname);
  690.       free ((char *) areas[i]);
  691.       }
  692.    for (i = 0; i < num_pw; i++)
  693.       {
  694.       free (pw[i]->password);
  695.       free (pw[i]);
  696.       }
  697.  
  698.     }
  699.  
  700. void fs_usage ()
  701. {
  702. #ifdef OS2
  703.     printf ("Usage: VP2 EXPORT file -c/h -k -t -d dir -p dir -m max# -n[p/f] -s # -a arccmd\n");
  704. #else
  705.     printf ("Usage:  VP EXPORT file -c/h -k -t -d dir -p dir -m max# -n[p/f] -s # -a arccmd\n");
  706. #endif /* OS2 */
  707. #ifndef NOHELP
  708.     printf ("       where file is the filename to use for AREAS.BBS\n");
  709.     printf ("       -c/h      can be either -c for CRASH or -h for HOLD\n");
  710.     printf ("       -k        use the IFNA ^A kludge\n");
  711.     printf ("       -t        use 'tiny' seen-by lines\n");
  712.     printf ("       -d dir    uses directory 'dir' for creating arcmail files\n");
  713.     printf ("       -p dir    uses directory 'dir' for temporary packet files\n");
  714.     printf ("       -m max#   only generate max# messages\n");
  715.     printf ("       -n[p/f]   can be either -np or -nf for not sending private\n");
  716.     printf ("                 messages, or not forwarding messages\n");
  717.     printf ("       -s #      put the first # AKA's into the SEEN-BY list\n");
  718.     printf ("       -a arccmd executes 'arccmd' as the command for creating the\n");
  719.     printf ("                 ARCmail files.\n");
  720.     printf ("Examples:\n");
  721. #ifdef OS2
  722.     printf ("      VP2 EXPORT MYAREAS.BBS -m 300\n");
  723.     printf ("      VP2 EXPORT -m 300 -k -s 2\n");
  724.     printf ("      VP2 EXPORT -d C:\\OPUS -p E:\\TMP -m 300 -a ARC2 A5\n");
  725. #else
  726.     printf ("       VP EXPORT MYAREAS.BBS -m 300\n");
  727.     printf ("       VP EXPORT -m 300 -k -s 2\n");
  728.     printf ("       VP EXPORT -d C:\\OPUS -p E:\\TMP -m 300 -a ARC A\n");
  729. #endif /* OS2 */
  730. #endif /* NOHELP */
  731.     exit (2);
  732. }
  733.  
  734. void make_originline(AREAS_PTR which)
  735. {
  736.    char fname[100], msg_str[15], *bname;
  737.    int f, i, t;
  738.  
  739.    bname = board_name;
  740.    sprintf (fname, "%s\\ORIGIN", which->msg_path);
  741.     (void) filedir (fname, 0, msg_str, 0);
  742.    if (msg_str[0] != '\0')
  743.       {
  744.       /* Open file */
  745.       if ((f = open (fname, O_RDONLY|O_BINARY)) == -1)
  746.          {
  747.          for (i = which->num_nodes-1; i >= 0; i--)
  748.             {
  749.             if (which->handle[i] > 0)
  750.                {
  751.                break;
  752.                }
  753.             }
  754.          if (i >= 0)
  755.             {
  756.             (void) fast_write (which->handle[i], "\0\0", 2);
  757.             (void) fast_close (which->handle[i]);
  758.             which->handle[i] = -1;
  759.             f = open (fname, O_RDONLY|O_BINARY);
  760.             }
  761.          }
  762.  
  763.       if (f != -1)
  764.          {
  765.          /* read 80 bytes */
  766.          t = fast_read (f, fname, 80);
  767.          /* close file */
  768.          (void) fast_close (f);
  769.          /* place \0 at either \r \n ^z or 80 chars */
  770.          for (i = 0; i < t; i++)
  771.             {
  772.             if ((fname[i] == '\r') || (fname[i] == '\n') || (fname[i] == 26))
  773.                break;
  774.             }
  775.          fname[i] = '\0';
  776.          bname = fname;
  777.          }
  778.       }
  779.  
  780.     sprintf (originline, "\r\n%s * Origin: %s (%d:", tearline, bname,
  781.       (config.zone[1] != 0)?config.zone[1]:1);
  782.    if (boss_net <= 0)
  783.       sprintf (&originline[strlen(originline)], "%d/%d)", config.net[1],
  784.          config.node[1]);
  785.    else
  786.       sprintf (&originline[strlen(originline)], "%d/%d.%d)", boss_net,
  787.          boss_node, config.node[1]);
  788.  
  789. #if DEBUG
  790. printf ("Origin line = %d chars long and it is\n'%s'\n", strlen(originline), originline);
  791. #endif
  792.  
  793. }
  794.