home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
VP2SRC.ZIP
/
SCAN.C
< prev
next >
Wrap
Text File
|
1991-04-20
|
41KB
|
1,180 lines
/*
$Header: scan.c 3.31 87/12/31 14:53:56 Bob Exp $
The Conference Mail System
This module was originally written by Bob Hartman
Sysop of FidoNet node 1:132/101
Spark Software, 427-3 Amherst St, CS 2032, Suite 232, Nashua, NH 03061
The Conference Mail System is a complete Echomail processing package. It
is a superset of the original Echomail utilities created by Jeff Rush, and
also contains ideas gleaned from the ARCmail, Renum, oMMM, MGM, and Opus
programs that were created by various software authors.
This program source code is being released with the following provisions:
1. You are free to make changes to this source code for use on your own
machine, however, altered source files may not be distributed without the
consent of Spark Software.
2. You may distribute "patches" or "diff" files for any changes that you
have made, provided that the "patch" or "diff" files are also sent to Spark
Software for inclusion in future releases of the entire package. A "diff"
file for the source archives may also contain a compiled version, provided
it is clearly marked as not being created from the original source code.
No other executable versions may be distributed without the consent of
Spark Software.
3. You are free to include portions of this source code in any program you
develop, providing: a) Credit is given to Spark Software for any code that
may is used, and b) The resulting program is free to anyone wanting to use
it, including commercial and government users.
4. There is NO technical support available for dealing with this source
code, or the accompanying executable files. This source code is provided
as is, with no warranty expressed or implied (I hate legalease). In other
words, if you don't know what to do with it, don't use it, and if you are
brave enough to use it, you're on your own.
Spark Software may be contacted by modem at (603) 888-8179 (node 1:132/101)
on the public FidoNet network, or at the address given above.
To use this code you will need Microsoft C version 4.0, and also Microsoft
Macro Assembler version 4.0.
*/
/*
$Log: scan.c $
* Revision 3.31 87/12/31 14:53:56 Bob
* Fixed bug dealing with nulls embedded in messages
*
* Revision 3.3 87/12/12 00:44:48 Bob
* Source code release
*
*/
#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
#include <io.h>
#include <time.h>
#include <string.h>
#include <sys\types.h>
#include <sys\stat.h>
#include "fastecho.h"
#define DEBUG 0
extern char *no_msgs;
extern SEACONFIG config;
extern AREAS_PTR areas[];
extern char board_name[], sysop_name[];
extern int tot_areas;
extern char bbsfile[];
extern char *arc_cmd[];
extern int nread;
extern int arc_args;
extern int last_msg;
extern int high_one;
extern int convert;
extern int notquiet;
extern char seen_byline[];
extern char originline[];
extern char tearline[];
extern int max_msgs;
extern int ctrla;
extern unsigned int def_attr;
extern int boss_net, boss_node;
extern int noforward;
extern int noprivate;
extern int tiny_seen;
extern int priv_net;
extern int zone_net[];
extern int zone_node[];
extern int num_zone;
extern int send_pvt;
extern char tmpjunk[];
extern int *msg_nums;
extern int do_path;
extern int last_opened;
extern struct _stamp zero_stamp;
char *holder1;
int mail_low;
extern int mail_high;
char *seen_by;
char *origin;
char *tear;
char *holder;
int originl;
int seen_byl;
int msgl;
int seen_zones[MAXSEEN];
int seen_nets[MAXSEEN];
int seen_nodes[MAXSEEN];
int path_nets[MAXPATH];
int path_nodes[MAXPATH];
int tot_path;
int not_seen[MAXNODES];
int tot_seen;
int tot_scanned;
char arealine[80];
int areal;
MSG_PTR h;
extern int msgs_done;
extern char *SEENBYSTR;
extern char *PATHSTR;
int scan (AREAS_PTR which)
{
int i, j, k, l, foo, foo1, foo3;
char *t1, *q1, *s1;
char *ptr;
int f;
int totread;
int done;
int new_net, new_node, new_zone, new_point;
int sbl, ctla;
char *last_name;
char fname[80], fname1[80];
f = 0;
last_name = which->area_name;
last_opened = -1;
#if DEBUG
printf ("Going to do area name '%s'\n", which->area_name);
#endif
/* Get the high water mark */
get_hw (which);
/* Get the list of messages in this area */
get_msg_lst (msg_nums, &last_msg, which->msg_path, 0);
/* Special case when we have no messages */
if (last_msg == 0)
{
#if DEBUG
printf ("really no messages\n");
#endif
printf (no_msgs, which->area_name);
set_hw (1, which);
return (0);
}
if (high_one >= msg_nums[last_msg-1])
{
#if DEBUG
printf ("high_one = %d, last = %d\n", high_one, msg_nums[last_msg - 1]);
#endif
printf (no_msgs, which->area_name);
/* Set the high water mark properly for next time (if necessary) */
if (high_one != msg_nums[last_msg-1])
set_hw (msg_nums[last_msg-1], which);
return (0);
}
else
high_one = find_msg (high_one, last_msg, 0);
/* Save how many we started with */
foo3 = msgs_done;
printf ("Processing messages numbered %d-%d in message area '%s'\n",
msg_nums[high_one], msg_nums[last_msg-1], which->area_name);
#if DEBUG
printf ("V_Purge is '%s'\n", (which->flags & V_PURGE)?("ON"):("OFF"));
#endif
/* Save the directory name we are working in */
strcpy (fname, which->msg_path);
/* Point to where we will be sticking in the file name */
t1 = fname + strlen (fname);
/* Point to the start of message text */
holder = holder1+sizeof(MSG);
/* Point to the message header */
h = (MSG_PTR) holder1;
/* Set up the area name */
if (ctrla)
{
sprintf (arealine, "\001AREA: %s\r", which->area_name);
}
else
{
sprintf (arealine, "AREA:%s\r", which->area_name);
}
areal = strlen (arealine);
/* Process the messages from here to the end */
for (i = high_one; i < last_msg; i++)
{
/* If we have done too many messages, quit */
if (msgs_done >= max_msgs)
{
break;
}
/* Close the files that might be open */
if (f>0)
{
(void) fast_close (f);
f = 0;
}
/* set up message name */
sprintf (t1, "\\%d.MSG", msg_nums[i]);
#if DEBUG
printf ("Doing file %s\n", fname);
#endif
/* Open the message file */
if((f = open (fname, O_RDWR|O_BINARY)) == -1)
{
printf ("\r%s could not open - continuing\n", fname);
continue;
}
/* Read the whole thing in */
if ((totread = fast_read (f, holder1, NUMBLOCKS*1024+sizeof(MSG))) <= (sizeof (MSG)))
{
printf ("\r%s is a null message - continuing\n", fname);
continue;
}
if (totread >= NUMBLOCKS*1024+sizeof(MSG)-10)
{
printf ("\r%s is too big a message - continuing\n", fname);
continue;
}
#if DEBUG
printf ("Read %d chars in message\n", totread-sizeof(MSG));
#endif
/* Now process the header to see if we should scan it at all */
if ((h->attr & MSGSENT) || (h->orig_net <= -1) || (h->orig < -1))
{
#if DEBUG
printf ("Did not send because header did not pass\n");
#endif
continue;
}
h->date[19] = 0;
h->_date_written = h->_date_arrived = zero_stamp;
++tot_scanned;
if (h->attr & MSGPRIVATE)
{
#ifndef VPURGE
if ((which->flags & PASS_THRU) || (which->flags & ROUTETHRU))
#else /* VPURGE */
if ((which->flags & PASS_THRU) || (which->flags & ROUTETHRU)
|| (which->flags & V_PURGE))
#endif /* VPURGE */
{
goto reg_echo;
}
if (send_pvt && h->reply && (h->attr & MSGLOCAL))
{
for (j = 1; j <= config.num_addrs; j++)
{
if ((h->orig == config.node[j]) && (h->orig_net == config.net[j]))
break;
}
if (j <= config.num_addrs)
{
/* We have a private reply that should go via netmail */
/* Create a message file in the netmail area with this info */
*(holder1+totread) = '\0';
ptr = holder1+totread;
++totread;
while ((*ptr == '\0') || ((*ptr & 0x7f) == '\r') || ((*ptr & 0x7f) == '\n'))
{
--ptr;
--totread;
}
/* Now check again if it is a null message */
if (totread <= sizeof (MSG))
{
printf ("\r%s is a null message - continuing\n", fname);
continue;
}
msgl = totread - sizeof (MSG);
find_orig (totread);
if (!originl)
{
origin = originline;
originl = strlen (originline);
}
strcpy (tmpjunk, h->to);
/* Set the SENT bit in the message in the echomail area */
(void) fast_lseek (f, 0L, SEEK_SET);
h->attr |= MSGSENT;
(void) fast_write (f, (char *) h, sizeof(MSG));
(void) fast_close (f);
printf ("\r%s:%d.MSG -=> ", which->area_name, msg_nums[i]);
(void) write_reply (which);
printf (" Forwarded to %s\n", h->to);
/* Get the original message and find the originating net/node */
done = 0;
while (!done)
{
sprintf (t1, "\\%d.MSG", h->reply);
/* Open the message file */
if((f = open (fname, O_RDWR|O_BINARY)) == -1)
{
printf ("\r%s could not open - continuing\n", fname);
sprintf (fname1, "%s\\%d.MSG", config.mailpath, mail_high);
unlink (fname1);
--mail_high;
continue;
}
/* Read the whole thing in */
if ((totread = fast_read (f, holder1, NUMBLOCKS*1024+sizeof(MSG))) <= (sizeof (MSG)))
{
(void) fast_close (f);
printf ("\r%s is a null message - continuing\n", fname);
sprintf (fname1, "%s\\%d.MSG", config.mailpath, mail_high);
unlink (fname1);
--mail_high;
continue;
}
(void) fast_close (f);
if ((h->reply == 0) || (strcmp (h->from, tmpjunk) == 0))
done = 1;
}
if (strcmp (h->from, tmpjunk) != 0)
{
printf ("\r%s:%d.MSG No valid recipient message for private reply - sent regular echomail\n",
which->area_name, msg_nums[i]);
sprintf (fname1, "%s\\%d.MSG", config.mailpath, mail_high);
unlink (fname1);
--mail_high;
sprintf (t1, "\\%d.MSG", msg_nums[i]);
/* Open the message file */
if((f = open (fname, O_RDWR|O_BINARY)) == -1)
{
printf ("\r%s could not open - continuing\n", fname);
continue;
}
/* Read the whole thing in */
totread = fast_read (f, holder1, NUMBLOCKS*1024+sizeof(MSG));
goto reg_echo;
}
find_orig(totread);
if (originl == 0)
{
printf ("\r%s:%d.MSG No Origin for private reply - continuing\n",
which->area_name, msg_nums[i]);
sprintf (fname1, "%s\\%d.MSG", config.mailpath, mail_high);
unlink (fname1);
--mail_high;
sprintf (t1, "\\%d.MSG", msg_nums[i]);
/* Open the message file */
if((f = open (fname, O_RDWR|O_BINARY)) == -1)
{
printf ("\r%s could not open - continuing\n", fname);
continue;
}
/* Read the whole thing in */
totread = fast_read (f, holder1, NUMBLOCKS*1024+sizeof(MSG));
goto reg_echo;
}
new_zone = 0;
new_net = 0;
new_node = 0;
new_point = 0;
s1 = origin+originl-1;
while ((s1 > origin) && (*s1 != '('))
--s1;
if (*s1 != '(')
{
printf ("\r%s:%d.MSG Cannot find original node for private reply - sent regular echomail\n",
which->area_name, msg_nums[i]);
sprintf (fname1, "%s\\%d.MSG", config.mailpath, mail_high);
unlink (fname1);
--mail_high;
sprintf (t1, "\\%d.MSG", msg_nums[i]);
/* Open the message file */
if((f = open (fname, O_RDWR|O_BINARY)) == -1)
{
printf ("\r%s could not open - continuing\n", fname);
continue;
}
/* Read the whole thing in */
totread = fast_read (f, holder1, NUMBLOCKS*1024+sizeof(MSG));
goto reg_echo;
}
while ((!isdigit (*s1)) && (s1 < origin+originl-1))
++s1;
if (sscanf (s1, "%d:%d/%d.%d", &new_zone, &new_net, &new_node, &new_point) != 4)
{
new_zone = 0;
new_net = 0;
new_node = 0;
if (sscanf (s1, "%d:%d/%d", &new_zone, &new_net, &new_node) != 3)
{
new_zone = 0;
new_net = 0;
if (sscanf (s1, "%d/%d.%d", &new_net, &new_node, &new_point) != 3)
{
new_net = 0;
new_node = 0;
if (sscanf (s1, "%d/%d", &new_net, &new_node) != 2)
{
printf ("\r%s:%d.MSG Cannot find original node for private reply - sent regular echomail\n",
which->area_name, msg_nums[i]);
sprintf (fname1, "%s\\%d.MSG", config.mailpath, mail_high);
unlink (fname1);
--mail_high;
sprintf (t1, "\\%d.MSG", msg_nums[i]);
/* Open the message file */
if((f = open (fname, O_RDWR|O_BINARY)) == -1)
{
printf ("\r%s could not open - continuing\n", fname);
continue;
}
/* Read the whole thing in */
totread = fast_read (f, holder1, NUMBLOCKS*1024+sizeof(MSG));
goto reg_echo;
}
}
}
}
/* Change the destination net/node in the netmail message */
sprintf (fname1, "%s\\%d.msg", config.mailpath, mail_high);
/* Open the message file */
if((f = open (fname1, O_RDWR|O_BINARY)) == -1)
{
printf ("\r%s could not open - sent regular echomail\n", fname1);
unlink (fname1);
--mail_high;
sprintf (t1, "\\%d.MSG", msg_nums[i]);
/* Open the message file */
if((f = open (fname, O_RDWR|O_BINARY)) == -1)
{
printf ("\r%s could not open - continuing\n", fname);
continue;
}
/* Read the whole thing in */
totread = fast_read (f, holder1, NUMBLOCKS*1024+sizeof(MSG));
goto reg_echo;
}
/* Read the whole thing in */
if (fast_read (f, holder1, sizeof(MSG)) < (sizeof (MSG)))
{
(void) fast_close(f);
printf ("\r%s is a null message - sent regular echomail\n", fname1);
unlink (fname1);
--mail_high;
sprintf (t1, "\\%d.MSG", msg_nums[i]);
/* Open the message file */
if((f = open (fname, O_RDWR|O_BINARY)) == -1)
{
printf ("\r%s could not open - continuing\n", fname);
continue;
}
/* Read the whole thing in */
totread = fast_read (f, holder1, NUMBLOCKS*1024+sizeof(MSG));
goto reg_echo;
}
if ((new_zone == 0) ||
(new_zone == (config.zone[1] == 0 ? 1 : config.zone[1])))
{
h->dest_net = new_net;
h->dest = new_node;
new_zone = 0;
}
else
{
h->dest_net = (config.zone[1] == 0 ? 1 : config.zone[1]);
h->dest = new_zone;
}
h->reply = 0;
h->up = 0;
h->attr &= ~MSGSENT;
h->attr |= MSGKILL|MSGLOCAL;
(void) fast_lseek (f, 0L, SEEK_SET);
(void) fast_write (f, (char *) h, sizeof (MSG));
if (new_zone || (new_point > 0))
{
(void) fast_lseek (f, -3L, SEEK_END);
if (new_zone)
{
sprintf (fname1, "\r\001INTL %d:%d/%d %d:%d/%d",
new_zone, new_net, new_node,
config.zone[1]?1:config.zone[1],config.net[1],
config.node[1]);
(void) fast_write (f, (char *) fname1, strlen (fname1));
}
if (new_point > 0)
{
sprintf (fname1, "\r\001TOPT %d", new_point);
(void) fast_write (f, (char *) fname1, strlen (fname1));
}
fast_write (f, "\r\n\r\n", 5);
}
continue;
}
}
else if (noprivate)
{
continue;
}
}
reg_echo:
q1 = holder;
if (*q1 == 1)
{
++q1;
}
while ((isspace ((*q1)&0x7f)) || (*q1 == 1))
++q1;
/* If we got here, then the header is fine, now try to find the rest */
if (((totread - sizeof(MSG)) >= 6) &&
(strncmp ("NOECHO", q1, 6) == 0))
{
printf ("\r%s is a NOECHO message - continuing\n", fname);
continue;
}
*(holder1+totread) = '\0';
ptr = holder1+totread;
++totread;
while ((*ptr == '\0') || ((*ptr & 0x7f) == '\r') || ((*ptr & 0x7f) == '\n'))
{
--ptr;
--totread;
}
/* Now check again if it is a null message */
if (totread <= sizeof (MSG))
{
printf ("\r%s is a null message - continuing\n", fname);
continue;
}
msgl = totread - sizeof (MSG);
/* Get rid of any embedded null characters */
ptr = holder1 + sizeof (MSG);
l = 0;
while (l < msgl)
{
j = strlen (ptr);
l += j;
if (l < msgl)
{
ptr = ptr + j;
*ptr = ' ';
}
}
if ((which->flags & ROUTETHRU) || (which->flags & MAIL_DIR))
{
/* If it is us, then continue on */
for (l = 1; l <= config.num_addrs; l++)
{
if ( (config.net[l] == h->dest_net)
&&(config.node[l] == h->dest))
{
break;
}
}
if ((l <= config.num_addrs) ||
(h->attr & MSGFILE) ||
(h->attr & MSGFRQ) ||
(h->attr & MSGURQ) ||
(h->attr & MSGSENT))
{
continue;
}
h->attr &= NO_CLEAR;
h->attr |= def_attr;
if (notquiet)
printf ("\r%s:%04d.MSG -=> Node %4d/%-4d", which->area_name,
msg_nums[i], h->dest_net, h->dest);
originl = 0;
seen_byl = 0;
if (write_it (which, -1))
{
fast_close (f);
return (2);
}
if (which->flags & MAIL_DIR)
{
if ((h->attr & MSGKILL) || (h->attr & MSGFWD))
{
unlink (fname);
}
else
{
h->attr |= MSGSENT;
(void) fast_lseek (f, 0L, SEEK_SET);
(void) fast_write (f, (unsigned char *)h, sizeof (MSG));
}
}
continue;
}
/* Now find the origin line */
find_orig(totread);
#if DEBUG
printf ("origin line is of length %d and it is\n", originl);
if (originl > 0)
{
sprintf (fname1, "%%%d.%ds\n", originl, originl);
printf (fname1, origin);
}
#endif
/* Now find the seen-by's */
find_seen(totread);
#if DEBUG
printf ("seen-by's are of length %d and they are\n", seen_byl);
if (seen_byl>0)
{
sprintf (fname1, "%%%d.%ds\n", seen_byl, seen_byl);
printf (fname1, seen_by);
}
#endif
/* Do we have a valid message? */
if (seen_by != origin)
{
/* This is for a message that has been scanned already */
#if DEBUG
printf ("message %d has already been scanned\n", msg_nums[i]);
#endif
if (noforward)
{
continue;
}
/* Get the seen-by list */
get_seen_bys (seen_by, seen_byl, SEENBYSTR, seen_nets, seen_nodes, &tot_seen);
/* Get the PATH: line */
if (do_path)
{
get_seen_bys (seen_by, seen_byl, PATHSTR, path_nets, path_nodes, &tot_path);
}
#if DEBUG
printf ("%d SEEN-BYS:\n", tot_seen);
for (j = 0; j < tot_seen; j++)
printf ("%d/%d ", seen_nets[j], seen_nodes[j]);
printf ("\n");
#endif
/* OK, now step through the nodes we process and if they are not */
/* in the seen-by list we mark it for future reference */
foo = 0;
foo1 = 0;
for (j = 0; j < which->num_nodes; j++)
{
for (k = foo; k < tot_seen; k++)
{
if ((seen_nets[k] == which->net[j]) &&
(seen_nodes[k] == which->node[j]))
{
foo = k + 1;
break;
}
}
if (k == tot_seen)
{
foo1++;
not_seen[j] = 1;
}
else
not_seen[j] = 0;
}
/* Did we add any nodes? */
if (foo1)
{
/* We did, so now add them to the seen-bys */
for (j = 0; j < which->num_nodes; j++)
{
if (not_seen[j])
{
seen_nets[tot_seen] = which->net[j];
seen_nodes[tot_seen] = which->node[j];
++tot_seen;
}
}
/* Re-sort the seen-bys */
sort_em (seen_zones, seen_nets, seen_nodes, tot_seen, 0, 0, NULL);
/* Create the new seen-by list */
create_seen (seen_by, seen_nets, seen_nodes, tot_seen, 1, SEENBYSTR);
/* Put in the path if necessary */
if (do_path)
{
sbl = seen_byl;
if (tot_path > 0)
{
ctla = ctrla;
ctrla = 1;
create_seen (&(seen_by[seen_byl-2]), path_nets, path_nodes, tot_path, 1, PATHSTR);
ctrla = ctla;
seen_byl += sbl - 2;
}
path_nets[tot_path] = config.net[1];
path_nodes[tot_path] = config.node[1];
++tot_path;
}
/* If the new seen_by is less then the old, then we have */
/* to delete the message and create it again so that the */
/* end of the message is in the proper place */
#ifndef VPURGE
if (!(which->flags & PASS_THRU))
#else /* VPURGE */
if (!((which->flags & PASS_THRU) || (which->flags & V_PURGE)))
#endif /* VPURGE */
{
if (stricmp (h->from, "sysop") == 0)
{
if (h->attr & MSGLOCAL)
{
strcpy (h->from, sysop_name);
}
else
{
/* Apparently we have a person trying to enter a message
through the back door */
sprintf (h->from, "Sysop (Apparently From %d/%d)", h->orig_net, h->orig);
}
}
if (seen_byl+originl+msgl+sizeof(MSG) < totread)
{
#if DEBUG
printf ("special case where message is shorter\n");
#endif
/* Close the old handle */
(void) fast_close (f);
/* Remove the file so we can start again */
unlink (fname);
/* Reopen the file for writing */
f = open (fname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
/* Write out the header and message stuff */
(void) fast_write (f, (char *) h, sizeof(MSG)+msgl);
}
/* Write out the new message into the proper area */
write_msg (f);
}
if (do_path)
{
ctla = ctrla;
ctrla = 1;
create_seen (&(seen_by[sbl-2]), path_nets, path_nodes, tot_path, 1, PATHSTR);
ctrla = ctla;
seen_byl += sbl - 2;
}
/* Do we have tiny seen-bys? */
if (tiny_seen)
{
create_seen (seen_by, &(which->net[0]),
&(which->node[0]), which->num_nodes, 1, SEENBYSTR);
if (do_path)
{
ctla = ctrla;
sbl = seen_byl;
ctrla = 1;
create_seen (&(seen_by[seen_byl-2]), path_nets, path_nodes, tot_path, 1, PATHSTR);
ctrla = ctla;
seen_byl += sbl - 2;
}
}
/* If we are dealing with a private net, new seen-bys */
if (priv_net)
{
if (tiny_seen)
{
create_seen (seen_by, &(which->net[0]),
&(which->node[0]), which->num_nodes, 0, SEENBYSTR);
if (do_path)
{
ctla = ctrla;
sbl = seen_byl;
ctrla = 1;
create_seen (&(seen_by[seen_byl-2]), path_nets, path_nodes, tot_path, 1, PATHSTR);
ctrla = ctla;
seen_byl += sbl - 2;
}
}
else
{
/* Create the new seen-by list */
create_seen (seen_by, seen_nets, seen_nodes, tot_seen, 0, SEENBYSTR);
if (do_path)
{
ctla = ctrla;
sbl = seen_byl;
ctrla = 1;
create_seen (&(seen_by[seen_byl-2]), path_nets, path_nodes, tot_path, 1, PATHSTR);
ctrla = ctla;
seen_byl += sbl - 2;
}
}
}
/* Set up the message header for putting into netmail area */
h->orig_net = config.net[1];
h->orig = config.node[1];
h->attr = (h->attr & MSGPRIVATE) | MSGKILL;
h->reply = h->up = 0;
/* For each node not yet scanned, write out the message */
for (j = 0; j < which->num_nodes; j++)
{
if (not_seen[j])
{
/* If it is us, then continue on */
for (l = 1; l <= config.num_addrs; l++)
{
if ( (config.net[l] == which->net[j])
&&(config.node[l] == which->node[j]))
{
break;
}
}
/* Was it to us? */
if (l <= config.num_addrs)
continue;
if (num_zone &&
(zone_net[0] == which->net[j]) &&
(zone_node[0] == which->node[j]))
{
create_seen (seen_by, &(zone_net[1]), &(zone_node[1]), num_zone-1, 0, SEENBYSTR);
if (do_path)
{
ctla = ctrla;
sbl = seen_byl;
ctrla = 1;
create_seen (&(seen_by[seen_byl-2]), path_nets, path_nodes, tot_path, 1, PATHSTR);
ctrla = ctla;
seen_byl += sbl - 2;
}
}
if (notquiet)
printf ("\r%s:%04d.MSG -=> Node %4d/%-4d", which->area_name,
msg_nums[i], which->net[j], which->node[j]);
if ((which->flags & PARENT) && (last_name != which->aname[j]))
{
last_name = which->aname[j];
/* Set up the area name */
if (ctrla)
{
sprintf (arealine, "\001AREA: %s\r", which->aname[j]);
}
else
{
sprintf (arealine, "AREA:%s\r", which->aname[j]);
}
areal = strlen (arealine);
}
if (write_it (which, j))
{
/* Now set the high water mark for next time */
set_hw (msg_nums[i-1], which);
return (2);
}
if (num_zone &&
(zone_net[0] == which->net[j]) &&
(zone_node[0] == which->node[j]))
{
if (tiny_seen)
{
create_seen (seen_by, &(which->net[0]),
&(which->node[0]), which->num_nodes, 1, SEENBYSTR);
}
/* If we are dealing with a private net, new seen-bys */
if (priv_net)
{
if (tiny_seen)
{
create_seen (seen_by, &(which->net[0]),
&(which->node[0]), which->num_nodes, 0, SEENBYSTR);
}
else
{
/* Create the new seen-by list */
create_seen (seen_by, seen_nets, seen_nodes, tot_seen, 0, SEENBYSTR);
}
}
else
{
create_seen (seen_by, seen_nets, seen_nodes, tot_seen, 1, SEENBYSTR);
}
}
}
}
}
}
else
{
/* It appears that this message has not yet been scanned */
#if DEBUG
printf ("message %d has not yet been scanned\n", msg_nums[i]);
#endif
/* No origin line, point at ours */
if (!originl)
{
origin = originline;
originl = strlen (originline);
}
/* Point at our seen-bys */
seen_by = seen_byline;
seen_byl = strlen (seen_byline);
/* If the new seen_by is less then the old, then we have */
/* to delete the message and create it again so that the */
/* end of the message is in the proper place */
#ifndef VPURGE
if (!(which->flags & PASS_THRU))
#else /* VPURGE */
if (!((which->flags & PASS_THRU) || (which->flags & V_PURGE)))
#endif /* VPURGE */
{
if (h->attr & MSGLOCAL)
{
if (stricmp (h->from, "sysop") == 0)
{
strcpy (h->from, sysop_name);
}
}
else
{
/* Apparently we have a person trying to enter a message
through the back door */
sprintf (&(sysop_name[50]), "%s Of %d/%d", h->from,
h->orig_net, h->orig);
strncpy (h->from, &(sysop_name[50]), 35);
h->from[35] = '\0';
}
if (seen_byl+originl+msgl+sizeof(MSG) < totread)
{
/* Close the old handle */
(void) fast_close (f);
/* Remove the file so we can start again */
unlink (fname);
/* Reopen the file for writing */
f = open (fname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IREAD|S_IWRITE);
/* Write out the header and message stuff */
(void) fast_write (f, (char *) h, sizeof(MSG)+msgl);
}
/* Write back the message with new seen-bys etc */
write_msg (f);
}
/* If we have a private network, new seen-by's */
if (priv_net)
{
create_seen(&seen_byline[1], &(which->net[0]), &(which->node[0]),
which->num_nodes, 0, SEENBYSTR);
if (do_path)
{
seen_byl = strlen (seen_byline);
sprintf (&(seen_byline[seen_byl-2]), "\001PATH: %d/%d\r\n\r\n",
config.net[1], config.node[1]);
seen_byl = strlen (seen_byline);
}
}
/* Set up the message header for putting into netmail area */
h->orig_net = config.net[1];
h->orig = config.node[1];
h->attr = (h->attr & MSGPRIVATE) | MSGKILL;
h->reply = h->up = 0;
/* Now write out the message for each node that has not seen it */
for (j = 0; j < which->num_nodes; j++)
{
/* If it is us, then continue on */
for (l = 1; l <= config.num_addrs; l++)
{
if ( (config.net[l] == which->net[j])
&&(config.node[l] == which->node[j]))
{
break;
}
}
/* Was it to us? */
if (l <= config.num_addrs)
continue;
if (num_zone &&
(zone_net[0] == which->net[j]) &&
(zone_node[0] == which->node[j]))
{
create_seen (&seen_byline[1], &(zone_net[1]), &(zone_node[1]), num_zone-1, 0, SEENBYSTR);
if (do_path)
{
seen_byl = strlen (seen_byline);
sprintf (&(seen_byline[seen_byl-2]), "\001PATH: %d/%d\r\n\r\n",
config.net[1], config.node[1]);
seen_byl = strlen (seen_byline);
}
}
if (notquiet)
printf ("\r%s:%04d.MSG -=> Node %4d/%-4d", which->area_name,
msg_nums[i], which->net[j], which->node[j]);
/* Change the name if necessary */
if ((which->flags & PARENT) && (last_name != which->aname[j]))
{
last_name = which->aname[j];
/* Set up the area name */
if (ctrla)
{
sprintf (arealine, "\001AREA: %s\r", which->aname[j]);
}
else
{
sprintf (arealine, "AREA:%s\r", which->aname[j]);
}
areal = strlen (arealine);
}
if (write_it (which, j))
{
/* Now set the high water mark for next time */
set_hw (msg_nums[i-1], which);
return (2);
}
if (num_zone &&
(zone_net[0] == which->net[j]) &&
(zone_node[0] == which->node[j]))
{
if (priv_net)
{
create_seen(&seen_byline[1], &(which->net[0]), &(which->node[0]),
which->num_nodes, 0, SEENBYSTR);
}
else
{
create_seen(&seen_byline[1], &(which->net[0]), &(which->node[0]),
which->num_nodes, 1, SEENBYSTR);
}
}
}
}
}
/* Close the files */
if (f>0)
(void) fast_close (f);
/* Now set the high water mark for next time */
set_hw (msg_nums[i-1], which);
/* Output a newline if we did any messages */
if (foo3 != msgs_done)
putchar('\n');
if (msgs_done >= max_msgs)
{
printf ("\nMaximum message count exceeded - exiting\n");
return (1);
}
#ifdef VPURGE
#if DEBUG
printf ("V_Purge is still '%s'\n", (which->flags & V_PURGE)?("ON"):("OFF"));
#endif
if (which->flags & V_PURGE)
{
for (i = 0; i < last_msg; i++)
{
sprintf (t1, "\\%d.MSG", msg_nums[i]);
unlink(fname);
}
set_hw (1, which);
}
#endif /* VPURGE */
return (0);
}