home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
OS2OMMM.SRC
/
ROUTE.C
< prev
next >
Wrap
Text File
|
1989-06-01
|
25KB
|
901 lines
/***************************************************************************/
/*** ***/
/*** oMMM - The Outbound Matrix Message Masher ***/
/*** Copyright 1989 BS Software ***/
/*** ***/
/*** FILENAME: ROUTE.C ***/
/*** ***/
/*** oMMM's Router ***/
/*** ***/
/*** Based on the original oMMM, a portion of ***/
/*** the Opus Computer-Based Conversation System ***/
/*** Copyright 1986, Wynn Wagner III ***/
/*** ***/
/***************************************************************************/
/*** ***/
/*** Tabs set at every 4th column ***/
/*** ***/
/***************************************************************************/
/*
Polytron Version Control System Comments:
The revision of this file is *** $Revision: 1.40 $ ***
History of changes from 1.30 release version
$Log: C:/OMMM/PROJFILE/ROUTE.C_V $
*
* Rev 1.40 12 Feb 1989 4:56:34 Marshall Presnell
* Public Release Version 1.40
*
* Rev 1.31 31 Jan 1989 0:58:40 Marshall Presnell
* oMMM 1.35 Beta Release Version
*
* Rev 1.30 23 Jan 1989 17:54:02 Marshall Presnell
* Public Source Code Release - Version 1.30
*/
/*--------------------------------------------------------------------------*/
/* Include files */
/*--------------------------------------------------------------------------*/
#include "ommm.h"
#ifdef MSC
# include <sys\types.h>
#endif
#include <sys\stat.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>
#include <fcntl.h>
#ifdef ZTC
# include <sys\stat.h>
#endif
/*--------------------------------------------------------------------------*/
/* Static function declarations */
/*--------------------------------------------------------------------------*/
static int pwd(void);
static void route_poll(void);
static void route_donorm(void);
static void route_leave(void);
static void route_one(void);
static void route_arc(void);
static void route_docrash(void);
static void route_hostroute(void);
static void route_send(void);
/*--------------------------------------------------------------------------*/
/* Static variable definitions */
/*--------------------------------------------------------------------------*/
#define NA -1
#define NL NULL
#define IL ((int) DO_ILLEGAL)
#define NONE 0
#define CONT 1
#define BREAK 2
static struct _router {
char * verb;
char mode;
NETADDRESS dest;
char thischar;
char * thisext1;
char * thisext2;
char * thisext3;
char * thisext4;
int (*spc_func) ();
int after_fn;
int AddFlag;
} r_matrix[] = {
/*
NOTE: This table does not contain tabs at all. This will allow all you non-
tab drinkers to read this beast without having to do severe
re-formatting.
V M Z N N C E E E E F A
e o o e o h x x x x u f A
r d n t d a t t t t n t d
b e e e r 1 2 3 4 c e d
--------------- ---- --- --- --- ---- ------ ------ ------ ------ ---- ---- -*/
#ifdef ADD_STUFF
"arcaddcm", 'C', IL, IL, IL, 'C', "FLO", NL, NL, NL, NL, NA, 1,
"arcadddirect", 'D', IL, IL, IL, 'D', "FLO", NL, NL, NL, NL, NA, 1,
"arcaddhold", 'H', IL, IL, IL, 'H', "FLO", NL, NL, NL, NL, NA, 1,
#endif
"arccm", 'C', IL, IL, IL, 'C', "FLO", NL, NL, NL, NL, NA, 0,
"arcdirect", 'D', IL, IL, IL, 'D', "FLO", NL, NL, NL, NL, NA, 0,
"archold", 'H', IL, IL, IL, 'H', "FLO", NL, NL, NL, NL, NA, 0,
"docm", 'Z', IL, IL, IL, NA, NL, NL, NL, NL, NL, NA, 0,
"hostroute", 'R', IL, IL, IL, NA, NL, NL, NL, NL, NL, NA, 0,
"leave", 'L', IL, IL, IL, NA, NL, NL, NL, NL, NL, NA, 0,
"normcm", '2', IL, IL, IL, 'C', "OUT", "FLO", "DUT", "DLO", NL, NA, 0,
"normdirect", 'N', IL, IL, IL, 'D', "OUT", "FLO", "", "", NL, NA, 0,
"normhold", '1', IL, IL, IL, 'H', "OUT", "FLO", "DUT", "DLO", NL, NA, 0,
#ifdef ADD_STUFF
"oneaddcm", 'c', IL, IL, IL, 'C', "FLO", NL, NL, NL, NL, NA, 1,
"oneadddirect", 'd', IL, IL, IL, 'D', "FLO", NL, NL, NL, NL, NA, 1,
"oneaddhold", 'h', IL, IL, IL, 'H', "FLO", NL, NL, NL, NL, NA, 1,
#endif
"onecm", 'c', IL, IL, IL, 'C', "FLO", NL, NL, NL, NL, NA, 0,
"onedirect", 'd', IL, IL, IL, 'D', "FLO", NL, NL, NL, NL, NA, 0,
"onehold", 'h', IL, IL, IL, 'H', "FLO", NL, NL, NL, NL, NA, 0,
"password", NA, NA, NA, NA, NA, NL, NL, NL, NL, pwd, CONT,0,
"poll", 'P', IL, IL, IL, NA, NL, NL, NL, NL, NL, NA, 0,
"route-to", 'r', IL, IL, IL, NA, NL, NL, NL, NL, NL, NA, 0,
"send", 'S', IL, IL, IL, NA, NL, NL, NL, NL, NL, NA, 0,
"uncm", '4', IL, IL, IL, 'o', "CUT", "CLO", "", "", NL, NA, 0,
"undirect", '5', IL, IL, IL, 'o', "DUT", "DLO", "", "", NL, NA, 0,
"unhold", '3', IL, IL, IL, 'o', "HUT", "HLO", "", "", NL, NA, 0,
#ifdef ADD_STUFF
"zooaddcm", 'C', IL, IL, IL, 'C', "FLO", NL, NL, NL, NL, NA, 1,
"zooadddirect", 'D', IL, IL, IL, 'D', "FLO", NL, NL, NL, NL, NA, 1,
"zooaddhold", 'H', IL, IL, IL, 'H', "FLO", NL, NL, NL, NL, NA, 1,
#endif
"zoocm", 'C', IL, IL, IL, 'C', "FLO", NL, NL, NL, NL, NA, 0,
"zoodirect", 'D', IL, IL, IL, 'D', "FLO", NL, NL, NL, NL, NA, 0,
"zoohold", 'H', IL, IL, IL, 'H', "FLO", NL, NL, NL, NL, NA, 0,
#ifdef ADD_STUFF
"z1addcm", 'c', IL, IL, IL, 'C', "FLO", NL, NL, NL, NL, NA, 1,
"z1adddirect", 'd', IL, IL, IL, 'D', "FLO", NL, NL, NL, NL, NA, 1,
"z1addhold", 'h', IL, IL, IL, 'H', "FLO", NL, NL, NL, NL, NA, 1,
#endif
"z1cm", 'c', IL, IL, IL, 'C', "FLO", NL, NL, NL, NL, NA, 0,
"z1direct", 'd', IL, IL, IL, 'D', "FLO", NL, NL, NL, NL, NA, 0,
"z1hold", 'h', IL, IL, IL, 'H', "FLO", NL, NL, NL, NL, NA, 0,
/* DO NOT REMOVE THE FOLLOWING LINE! ADD TO TABLE ABOVE THIS LINE! */
NULL, NA, NA, NA, NA, NA, NL, NL, NL, NL, NL, NA, 0
};
#ifdef ADD_STUFF
int AddFlag = 0;
#endif
int ArcType = 'a';
static char * sptr;
static FILE * fp;
static char s[100];
static char parm[100];
static char towhom[80];
static char oldname[80];
static char newname[80];
static char thisext1[4];
static char thisext2[4];
static char thisext3[4];
static char thisext4[4];
static char * p;
static char * q;
static char q1;
static int oth;
static int line = 0;
static int cur_sched = 0;
static char thischar;
static int ctr;
static int err;
static int CONTINUE = 0;
static int not_in_table;
/*--------------------------------------------------------------------------*/
/* LOCAL VARIABLES */
/*--------------------------------------------------------------------------*/
PW_PTR pw[100]; /* See MISC.C for reference */
int num_pw = 0; /* See MISC.C for reference */
/*--------------------------------------------------------------------------*/
/* External variable declarations */
/*--------------------------------------------------------------------------*/
extern NETADDRESS ctlnet[];
/****************************************************************************/
/*--------------------------------------------------------------------------*/
/* PWD LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
static int
pwd(void)
{
pw[num_pw] = (PW_PTR) calloc(1, sizeof(PW));
if (sscanf(sptr, "%d:%d/%d %s", pw[num_pw]->zone, pw[num_pw]->net, pw[num_pw]->node, oldname) != 4) {
sscanf(sptr, "%d/%d %s", pw[num_pw]->net, pw[num_pw]->node, oldname);
pw[num_pw]->zone = our_zone;
}
strupr(oldname);
pw[num_pw]->password = (char *) malloc(strlen(oldname) + 1);
strcpy(pw[num_pw++]->password, oldname);
return (0);
}
/*--------------------------------------------------------------------------*/
/* ROUTE POLL LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
static void
route_poll()
{
do {
cur.node = DO_ILLEGAL;
sptr = pull_address(sptr);
if ((cur.net == DO_ALL) || (cur.node == DO_ALL) || (cur.net == DO_OTHERS) || (cur.node == DO_OTHERS)) {
printf("ERR: can't use `ALL' or `OTHERS' in POLL , line %d\n", line);
sptr = pull_address(sptr);
continue;
}
if (cur.node == DO_ILLEGAL) {
continue;
}
printf("\rPOLL ");
if (cur.node == DO_OURNET) {
sprintf(towhom, "%s%04x*.?LO", holding_path, OURNET);
cur.net = OURNET;
} else {
sprintf(towhom, "%s%04x%04x.?LO", adjust_packet_path(cur.zone), cur.net, cur.node);
}
q1 = 'O';
if (dir_findfirst(towhom, NORMAL, &dta) == 0) {
do {
if (dta.name[9] != 'H') {
q1 = 0;
break;
}
} while (dir_findnext(&dta) == 0);
}
if (q1) {
towhom[strlen(towhom) - 3] = 'F';
outfile = fopen(towhom, "ab");
fclose(outfile);
outfile = NULL;
}
printf("%d:%d/%d", cur.zone,cur.net, cur.node);
} while (*sptr);
}
/*--------------------------------------------------------------------------*/
/* ROUTE HOSTROUTE LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
static void
route_hostroute()
{
#ifdef IBMC
char tnet[5];
char tnode[5];
#endif
ctr = 0;
hostloop:
/* Get a .OUT file name */
sprintf(towhom, "%s*.OUT", holding_path);
for (i = 0; i <= ctr; i++) {
if (!i) {
err = dir_findfirst(towhom, NORMAL, &dta);
} else {
err = dir_findnext(&dta);
}
}
if (!err) {
do {
/* Get the net/node number out */
# ifdef IBMC
sscanf(dta.name, "%4s%4s", tnet, tnode);
sscanf(tnet, "%04x", &cur.net);
sscanf(tnode, "%04x", &cur.node);
# else
sscanf(dta.name, "%04x%04x", &cur.net, &cur.node);
# endif
/* If it is to node 0, then skip it */
/* If it has a .FLO then loop again */
sprintf(towhom, "%s%04x%04x.FLO", holding_path, cur.net, cur.node);
if ((!dir_findfirst(towhom, NORMAL, &dta)) || (cur.node == 0) || (cur.net < 100)) {
++ctr;
goto hostloop;
}
for (i = 0; i < ALIAS_CNT; i++) {
if (ctlnet[i].net <= 0)
break;
if (ctlnet[i].net == cur.net) {
++ctr;
goto hostloop;
}
}
/* Add it to the x/0 packet */
sprintf(oldname, "%s%04x%04x.OUT", holding_path, cur.net, cur.node);
sprintf(newname, "%s%04x0000.OUT", holding_path, cur.net);
open_outfile('O', cur.net, 0, 0, 0);
fwrite("\0\0", 1,2,outfile);
fclose(outfile);
outfile = NULL;
append_out(oldname, newname);
/* Loop again */
sprintf(towhom, "%s*.OUT", holding_path);
for (i = 0; i <= ctr; i++) {
if (!i) {
err = dir_findfirst(towhom, NORMAL, &dta);
} else {
err = dir_findnext(&dta);
}
}
} while (!err);
}
}
/*--------------------------------------------------------------------------*/
/* ROUTE SEND LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
static void
route_send()
{
int status;
char * dfe;
char sfn[80];
char dfn[80];
# ifdef IBMC
char tnet[5];
char tnode[5];
# endif
do {
sptr = pull_address(sptr);
if (cur.net == DO_ILLEGAL) {
continue;
}
if (cur.net == DO_OURNET) {
sprintf(towhom, "%s%04x*.N*",adjust_packet_path(cur.zone),OURNET);
} else if (cur.net == DO_ALL) {
sprintf(towhom, "%s*.N*",adjust_packet_path(cur.zone));
} else if (cur.net == DO_OTHERS) {
sprintf(towhom, "%s*.N*",adjust_packet_path(cur.zone));
oth = 1;
} else if (cur.node == DO_ALL) {
sprintf(towhom, "%s%04x*.N*",adjust_packet_path(cur.zone),cur.net);
} else {
sprintf(towhom, "%s%04x%04x.N*",adjust_packet_path(cur.zone), cur.net, cur.node);
}
status = dir_findfirst(towhom,0,&dta);
if (status == 0) do {
# ifdef IBMC
if (sscanf(dta.name, "%4s%4s", tnet, tnode) != 2)
# else
if (sscanf(dta.name, "%04x%04x", &cur.net,&cur.node) != 2)
# endif
continue;
# ifdef IBMC
sscanf(tnet, "%04x", &cur.net);
sscanf(tnode, "%04x", &cur.node);
# endif
if (oth && (cur.net == OURNET))
continue;
sprintf(sfn,"%s%s",adjust_packet_path(cur.zone),dta.name);
strcpy(dfn,sfn);
if ((dfe = strrchr(dfn,'.')) != NULL)
dfe++;
if (*dfe != 'N')
continue;
if (*(dfe + 2) == 'T') {
*dfe = *(dfe + 1);
*(dfe + 1) = 'U';
}
if (*(dfe + 2) == 'O') {
*dfe = *(dfe + 1);
*(dfe + 1) = 'L';
}
if (*(dfe + 1) == 'Q') {
*dfe = *(dfe + 1);
*(dfe + 1) = 'E';
}
printf("SEND %d:%d/%d\n",cur.zone,cur.net,cur.node);
if (rename(sfn,dfn))
perror("can't rename");
} while((status = dir_findnext(&dta)) == 0);
} while (*sptr);
}
/*--------------------------------------------------------------------------*/
/* ROUTE DONORM LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
static void
route_donorm()
{
do {
sptr = pull_address(sptr);
if (cur.net == DO_ILLEGAL) {
continue;
}
if (cur.net == DO_OURNET) {
sprintf(towhom, "%04x*.%s", OURNET, thisext1);
} else if (cur.net == DO_ALL) {
sprintf(towhom, "*.%s", thisext1);
} else if (cur.net == DO_OTHERS) {
sprintf(towhom, "*.%s", thisext1);
} else if (cur.node == DO_ALL) {
sprintf(towhom, "%04x*.%s", cur.net, thisext1);
} else {
sprintf(towhom, "%04x%04x.%s", cur.net, cur.node, thisext1);
}
make_normal(cur.zone, towhom, thischar, 0);
if (cur.net == DO_OURNET) {
sprintf(towhom, "%04x*.%s", OURNET, thisext2);
} else if (cur.net == DO_ALL) {
sprintf(towhom, "*.%s", thisext2);
} else if (cur.net == DO_OTHERS) {
sprintf(towhom, "*.%s", thisext2);
} else if (cur.node == DO_ALL) {
sprintf(towhom, "%04x*.%s", cur.net, thisext2);
} else {
sprintf(towhom, "%04x%04x.%s", cur.net, cur.node, thisext2);
}
make_normal(cur.zone, towhom, thischar, 0);
if (cur.net == DO_OURNET) {
sprintf(towhom, "%04x*.%s", OURNET, thisext3);
} else if (cur.net == DO_ALL) {
sprintf(towhom, "*.%s", thisext3);
} else if (cur.net == DO_OTHERS) {
sprintf(towhom, "*.%s", thisext3);
} else if (cur.node == DO_ALL) {
sprintf(towhom, "%04x*.%s", cur.net, thisext3);
} else {
sprintf(towhom, "%04x%04x.%s", cur.net, cur.node, thisext3);
}
make_normal(cur.zone, towhom, thischar, 0);
if (cur.net == DO_OURNET) {
sprintf(towhom, "%04x*.%s", OURNET, thisext4);
} else if (cur.net == DO_ALL) {
sprintf(towhom, "*.%s", thisext4);
} else if (cur.net == DO_OTHERS) {
sprintf(towhom, "*.%s", thisext4);
} else if (cur.node == DO_ALL) {
sprintf(towhom, "%04x*.%s", cur.net, thisext4);
} else {
sprintf(towhom, "%04x%04x.%s", cur.net, cur.node, thisext4);
}
make_normal(cur.zone, towhom, thischar, 0);
} while (*sptr);
}
/*--------------------------------------------------------------------------*/
/* ROUTE LEAVE LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
static void
route_leave()
{
int status;
char * sfe;
char * dfe;
char sfn[80];
char dfn[80];
# ifdef IBMC
char tnet[5];
char tnode[5];
# endif
do {
oth = 0;
sptr = pull_address(sptr);
if (cur.net == DO_ILLEGAL) {
continue;
}
if (cur.net == DO_OURNET) {
sprintf(towhom, "%s%04x*.*", adjust_packet_path(cur.zone), OURNET);
cur.net = OURNET;
} else if (cur.net == DO_ALL) {
sprintf(towhom, "%s*.*", adjust_packet_path(cur.zone));
} else if (cur.net == DO_OTHERS) {
sprintf(towhom, "%s*.*", adjust_packet_path(cur.zone));
oth = 1;
} else if (cur.node == DO_ALL) {
sprintf(towhom, "%s%04x*.*", adjust_packet_path(cur.zone), cur.net);
} else {
sprintf(towhom, "%s%04x%04x.*", adjust_packet_path(cur.zone), cur.net, cur.node);
}
status = dir_findfirst(towhom,0,&dta);
if (status == 0) do {
# ifdef IBMC
if (sscanf(dta.name, "%4s%4s", tnet, tnode) != 2)
# else
if (sscanf(dta.name, "%04x%04x", &cur.net,&cur.node) != 2)
# endif
continue;
# ifdef IBMC
sscanf(tnet, "%04x", &cur.net);
sscanf(tnode, "%04x", &cur.node);
# endif
if (oth && (cur.net == OURNET))
continue;
sprintf(sfn,"%s%s",adjust_packet_path(cur.zone),dta.name);
strcpy(dfn,sfn);
if ((sfe = strrchr(dfn,'.')) != NULL)
sfe++;
if (*(sfe + 1) == 'R')
continue;
if ((dfe = strpbrk(sfe,"ODCHRF")) != NULL) {
*(dfe + 1) = *sfe;
*dfe = 'N';
}
printf("LEAVE %d:%d/%d\n",cur.zone,cur.net,cur.node);
if (rename(sfn,dfn))
perror("can't rename");
} while ((status = dir_findnext(&dta)) == 0);
} while (*sptr);
}
/*--------------------------------------------------------------------------*/
/* ROUTE ONE LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
static void
route_one()
{
# ifdef IBMC
char tnet[5];
char tnode[5];
# endif
do {
oth = 0;
sptr = pull_address(sptr);
if (cur.net == DO_ILLEGAL) {
continue;
}
if (cur.net == DO_OURNET) {
sprintf(towhom, "%04x*.%s", OURNET, thisext1);
} else if (cur.net == DO_ALL) {
sprintf(towhom, "*.%s", thisext1);
} else if (cur.net == DO_OTHERS) {
sprintf(towhom, "*.%s", thisext1);
} else if (cur.node == DO_ALL) {
sprintf(towhom, "%04x*.%s", cur.net, thisext1);
} else {
sprintf(towhom, "%04x%04x.%s", cur.net, cur.node, thisext1);
}
make_normal(cur.zone, towhom, thischar, 0);
if (cur.net == DO_OURNET) {
sprintf(towhom, "%s%04x*.OUT", holding_path, OURNET);
cur.net = OURNET;
} else if (cur.net == DO_ALL) {
sprintf(towhom, "%s*.OUT", holding_path);
} else if (cur.net == DO_OTHERS) {
sprintf(towhom, "%s*.OUT", holding_path);
oth = 1;
} else if (cur.node == DO_ALL) {
sprintf(towhom, "%s%04x*.OUT", holding_path, cur.net);
} else {
sprintf(towhom, "%s%04x%04x.OUT", adjust_packet_path(cur.zone), cur.net, cur.node);
}
loop2:
if (!dir_findfirst(towhom, NORMAL, &dta))
do {
if (((q1 = dta.name[strlen(dta.name) - 3]) != 'H') && (strchr("NMPR", q1) == NULL)) {
# ifdef IBMC
sscanf(dta.name, "%4s%4s", tnet, tnode);
sscanf(tnet, "%04x", &cur.net);
sscanf(tnode, "%04x", &cur.node);
# else
sscanf(dta.name, "%04x%04x", &cur.net, &cur.node);
# endif
if (oth && (cur.net == OURNET)) {
continue;
}
dest.zone = cur.zone;
dest.net = cur.net;
dest.node = cur.node;
printf("\rONE %d:%d/%d", cur.zone,cur.net, cur.node, p);
parm[0] = 0;
add_parm(parm);
archive(parm);
goto loop2;
}
} while (!dir_findnext(&dta));
} while (*sptr);
}
/*--------------------------------------------------------------------------*/
/* ROUTE ARC LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
static void
route_arc()
{
sptr = pull_address(sptr);
dest.zone = cur.zone;
if (dest.net == DO_ILLEGAL) {
if ((cur.net == DO_ALL) || (cur.node == DO_ALL) || (cur.net == DO_OTHERS) || (cur.node == DO_OTHERS)) {
printf("ERR: can't use `ALL' or `OTHERS' in ARC statement , line %d\n", line);
return;
}
}
if (dest.net == DO_ILLEGAL) {
if (cur.net == DO_ILLEGAL) {
return;
} else
dest = cur;
}
if (cur.net == DO_OURNET) {
sprintf(towhom, "%04x*.%s", OURNET, thisext1);
} else if (cur.net == DO_ALL) {
sprintf(towhom, "*.%s", thisext1);
} else if (cur.net == DO_OTHERS) {
sprintf(towhom, "*.%s", thisext1);
} else if (cur.node == DO_ALL) {
sprintf(towhom, "%04x*.%s", cur.net, thisext1);
} else {
sprintf(towhom, "%04x%04x.%s", cur.net, cur.node, thisext1);
}
make_normal(cur.zone, towhom, thischar, 0);
sprintf(towhom, "%s%04x%04x", adjust_packet_path(cur.zone), cur.net, cur.node);
memset(parm,0,sizeof parm);
add_parm(parm);
while (*sptr) {
sptr = pull_address(sptr);
add_parm(parm);
}
for (i = 0; parm[i]; i++) {
if (parm[i] == ' ') {
archive(parm);
memset(parm,0,sizeof parm);
break;
}
}
}
/*--------------------------------------------------------------------------*/
/* ROUTE DOCRASH LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
static void
route_docrash()
{
sprintf(towhom, "*.NC?");
make_normal(our_zone, towhom, 'O', 0);
}
/*--------------------------------------------------------------------------*/
/* DO ROUTING */
/*--------------------------------------------------------------------------*/
void
do_routing(char *route_name, int sched2)
{
if (!route_name[0]) {
printf("\nNo routefile given\n");
return;
}
mode = 0;
errno = 0;
fp = fopen(route_name, "rt");
if (errno) {
printf("\nCan't open route file (%s)\n", route_name);
return;
}
do {
s[0] = 0;
line++;
# ifdef ADD_STUFF
AddFlag = 0;
# endif
ArcType = 'a';
cur.zone = our_zone;
cur.net = ctlnet[0].net;
cur.node = ctlnet[1].node;
fgets(s, 90, fp);
strlwr(s);
sptr = stpblk(s);
for (i = 0; sptr[i]; i++) {
if (!isspace(sptr[i]) && ((sptr[i] == ';') || (sptr[i] < ' ')))
sptr[i] = 0;
}
if (!sptr[0]) {
continue;
}
/* We have a schedule statement */
if (!strncmp(sptr, "sched", 5)) {
sptr += 5;
while ((*sptr) && (!isspace(*sptr)))
++sptr;
while ((*sptr) && isspace(*sptr))
++sptr;
cur_sched = toupper(*sptr);
if (cur_sched == sched2)
cur_sched = 0;
continue;
}
/* If we are in the wrong schedule, just continue */
if (cur_sched) {
continue;
}
i = 0;
CONTINUE = 0;
not_in_table = 1;
while (r_matrix[i].verb != NULL) {
if (!strncmp(sptr, r_matrix[i].verb, strlen(r_matrix[i].verb))) {
not_in_table = 0;
sptr += strlen(r_matrix[i].verb);
AddFlag = r_matrix[i].AddFlag;
ArcType = r_matrix[i].verb[0];
if (r_matrix[i].mode != (char) NA) {
mode = r_matrix[i].mode;
}
if (r_matrix[i].dest.zone != NA) {
dest.zone = r_matrix[i].dest.zone;
}
if (r_matrix[i].dest.net != NA) {
dest.net = r_matrix[i].dest.net;
}
if (r_matrix[i].dest.node != NA) {
dest.node = r_matrix[i].dest.node;
}
if (r_matrix[i].thischar != (char) NA) {
thischar = r_matrix[i].thischar;
}
if (r_matrix[i].thisext1 != NL) {
strcpy(thisext1, r_matrix[i].thisext1);
}
if (r_matrix[i].thisext2 != NL) {
strcpy(thisext2, r_matrix[i].thisext2);
}
if (r_matrix[i].thisext3 != NL) {
strcpy(thisext3, r_matrix[i].thisext3);
}
if (r_matrix[i].thisext4 != NL) {
strcpy(thisext4, r_matrix[i].thisext4);
}
if (r_matrix[i].spc_func != NL) {
(*r_matrix[i].spc_func) (); /* This causes a warning */
/* It's safe to ignore it */
CONTINUE = 1;
}
}
i++;
}
if (not_in_table) {
if (!isdigit(*sptr)) {
mode = 0;
}
}
if (CONTINUE)
continue;
switch (mode) {
case 0:
printf("\nCan't figure out line #%d\n", line);
break;
case 'P': /* POLL, just send a dummy packet */
route_poll();
break;
case 'R': /* ROUTE, do host routing */
route_hostroute();
break;
case 'Z': /* DOCRASH, normalize crash nodes */
route_docrash();
break;
case 'S': /* SEND, normalize the listed nodes */
route_send();
break;
case '1': /* NORMHOLD/CRASH just make it held */
case '2':
case '3':
case '4':
case '5':
case 'N':
route_donorm();
break;
case 'L': /* LEAVE, rename the packets */
route_leave();
break;
case 'c': /* ONE*, do archiving */
case 'h':
case 'd':
route_one();
break;
case 'D': /* ARC*, do archiving */
case 'H':
case 'C':
default:
route_arc();
break;
}
} while (!feof(fp));
fclose(fp);
fp = NULL;
}
/*--------------------------------------------------------------------------*/
/* END OF FILE */
/*--------------------------------------------------------------------------*/