home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
OS2OMMM.SRC
/
OMMM.C
< prev
next >
Wrap
Text File
|
1989-06-01
|
12KB
|
443 lines
/***************************************************************************/
/*** ***/
/*** oMMM - The Outbound Matrix Message Masher ***/
/*** Copyright 1989 BS Software ***/
/*** ***/
/*** FILENAME: OMMM.C ***/
/*** ***/
/*** Mainline oMMM function and help ***/
/*** ***/
/*** 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/OMMM.C_V $
*
* Rev 1.40BP 2 June 1989 23:21:00 Bill Andrus
* Public Release Version 1.40BP (OS/2 Protect Mode, Bound)
*
* Rev 1.40 12 Feb 1989 4:55:40 Marshall Presnell
* Public Release Version 1.40
*
* Rev 1.31 31 Jan 1989 0:57:48 Marshall Presnell
* oMMM 1.35 Beta Release Version
*
* Rev 1.30 23 Jan 1989 17:53:52 Marshall Presnell
* Public Source Code Release - Version 1.30
*/
/*--------------------------------------------------------------------------*/
/* Include files */
/*--------------------------------------------------------------------------*/
#include "ommm.h"
#include <myaddr.h>
#ifdef MSC
# include <sys\types.h>
# include <direct.h>
#endif
#include <sys\stat.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#ifdef TURBO_C
# include <ctype.h>
# include <dir.h>
#endif
#ifdef ZTC
# include <direct.h>
# include <ctype.h>
#endif
/*--------------------------------------------------------------------------*/
/* Static function declarations */
/*--------------------------------------------------------------------------*/
static void extended_help(void);
static void version_identifier(void);
static void load_cfg_file(void);
/*--------------------------------------------------------------------------*/
/* Static variable definitions */
/*--------------------------------------------------------------------------*/
static char * help[] = {
"Creates `.OUT' and `.FLO' files for outbound matrix traffic. Certain preset",
"data can be specified in the OMMM.CFG file (indicated by \"+\'s\" below)\n",
" USAGE: oMMM -iINFOPATH -mMESSAGEPATH -hHOLDPATH -pPRESCANPATH",
" -cROUTEFILE -sCHAR -zZONE -f -n -o -q\n",
" CHAR .......... a single character for this schedule tag",
" + INFOPATH ...... the Opus .PRM file to use for network information",
" + MESSAGEPATH ... the sub-directory containing outbound messages",
" + HOLDPATH ...... the sub-directory for the OUT/FLO files",
" + PRESCANPATH ... the file with routing information to be used",
" before message scanning takes place",
" + ROUTEFILE ..... the file with routing information",
" + ZONE .......... the zone number for our zone",
" -f tells oMMM to make all 'no-send' packets normal again",
" + -n tells oMMM not to forward messages from other nodes",
" + -o tells oMMM to use the old .MO? extensions and not .TU1, etc.",
" + -a tells oMMM to use pkarc instead of arca",
" + -g tells oMMM to gate route interzone messages",
" -q tells oMMM to run quietly (and marginally faster).\n",
"EXAMPLE: oMMM -iOpus.Prm -mD:\\NET -hC:\\Opus\\Outbound -cMatrix.Ctl -d -z1 -n",
NULL
};
static char info_path[80];
static char nowtime[25];
static char route_file[80];
static unsigned int normalize = 0;
static int quiet_mode = 0;
/*--------------------------------------------------------------------------*/
/* Local Variable Definitions */
/*--------------------------------------------------------------------------*/
NETADDRESS ctlnet[15]; /* See: ROUTEMSC, MISC, ARCHIVE, ROUTE, OMMMSCAN */
#ifdef ZTC
int _okbigbuf = 0;
#endif
/*--------------------------------------------------------------------------*/
/* External variable declarations */
/*--------------------------------------------------------------------------*/
/* ... NONE ... */
/*--------------------------------------------------------------------------*/
/* Local definitions */
/*--------------------------------------------------------------------------*/
#define same(a,b) (!strcmp((a),(b)))
/****************************************************************************/
/*--------------------------------------------------------------------------*/
/* EXTENDED HELP LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
static void
extended_help()
{
int q = 0;
while (help[q] != NULL)
puts(help[q++]);
exit(1);
}
/*--------------------------------------------------------------------------*/
/* VERSION IDENTIFIER LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
static void
version_identifier()
{
/* This one module uses an include file called <myaddr.h> in the standard
include file path. It contains one line, as follows:
#define MYADDRESS "1:133/401 - StarBase Operations"
(or whatever node number YOU have)
Please create this file to compile this source code. - Also, please
do NOT use someone else's node number -- it's not too nice!
*/
printf("\noMMM Version %s\n",VERSION);
printf("Compiled at node %s\n",MYADDRESS);
printf("Compile Timestamp: %s %s\n",__DATE__,__TIME__);
exit(0);
}
/*--------------------------------------------------------------------------*/
/* LOAD CFG FILE LOCAL FUNCTION */
/*--------------------------------------------------------------------------*/
void
load_cfg_file()
{
char line[129];
int lineno = 0;
char * tok;
FILE * cfg;
cfg = fopen("oMMM.CFG","r");
if (cfg == NULL)
return;
printf("Reading oMMM.CFG file");
while (1) {
if (fgets(line,128,cfg) == NULL)
break;
putchar('.');
lineno++;
if (line[0] == ';' || line[0] == '\0')
continue;
tok = strtok(line," \t\n:");
if (tok == NULL || *tok == ';')
continue;
strlwr(tok);
if (same(tok,"infopath")) {
tok = strtok(NULL," \t;\n");
strcpy(info_path,tok);
fancy_str(info_path);
} else if (same(tok,"messagepath")) {
tok = strtok(NULL," \t;\n");
strcpy(message_path,tok);
add_backslash(message_path);
} else if (same(tok,"holdpath")) {
tok = strtok(NULL," \t;\n");
strcpy(holding_path,tok);
add_backslash(holding_path);
} else if (same(tok,"prescanpath")) {
tok = strtok(NULL," \t;\n");
strcpy(pre_route,tok);
fancy_str(pre_route);
} else if (same(tok,"routefile")) {
tok = strtok(NULL," \t;\n");
strcpy(route_file,tok);
fancy_str(route_file);
} else if (same(tok,"zone")) {
tok = strtok(NULL," \t;\n");
our_zone = atoi(tok);
} else if (same(tok,"forward")) {
noforward = 0;
} else if (same(tok,"mo?")) {
oldstyle = 1;
} else if (same(tok,"gateroute")) {
use_gates = 1;
} else if (same(tok,"arca")) {
pkarc = 0;
} else if (same(tok,"pkarc")) {
pkarc = 1;
} else {
printf("Error (line %d)\n",lineno);
printf("Unknown command \"%s\" in OMMM.CFG file\n",tok);
exit(1);
}
}
fclose(cfg);
cfg = NULL;
putchar('\n');
}
/*--------------------------------------------------------------------------*/
/* MAIN */
/*--------------------------------------------------------------------------*/
void
main(int argc,char * argv[])
{
register int i;
register char * sptr;
char sched1[2];
long t1;
struct tm * t2;
fprintf(stderr,"oMMM [%s] - Copyright 1989 BS Software; All rights reserved\n",VERSION);
# ifdef TURBO_C
directvideo = 0;
# endif
if (argc<2)
extended_help();
getcwd(info_path,79);
add_backslash(info_path);
date_conv = 0;
our_zone = 0;
holding_path[0]=message_path[0]=sched1[0]=route_file[0]=pre_route[0] = 0;
load_cfg_file();
for(i=1; i<argc; i++) {
sptr = argv[i];
if (sptr[0]=='-') {
switch(toupper(sptr[1])) {
case '?':
version_identifier();
break;
case 'A':
pkarc = 1;
break;
case 'C':
sptr+=2;
strcpy(route_file,sptr);
fancy_str(route_file);
break;
case 'D':
date_conv = 0;
break;
case 'F':
normalize = 1;
break;
case 'G':
use_gates = 1;
break;
case 'H':
sptr+=2;
strcpy(holding_path,sptr);
add_backslash(holding_path);
break;
case 'I':
sptr+=2;
strcpy(info_path,sptr);
fancy_str(info_path);
break;
case 'K':
puts("-k not fully supported yet");
keepmsgs = 1;
break;
case 'M':
sptr+=2;
strcpy(message_path,sptr);
add_backslash(message_path);
break;
case 'N':
noforward = 1;
break;
case 'O':
oldstyle = 1;
break;
case 'P':
sptr+=2;
strcpy(pre_route,sptr);
fancy_str(pre_route);
break;
case 'Q':
printf("Quiet mode\n");
quiet_mode = 1;
break;
case 'S':
sptr+=2;
sched1[0] = (char) toupper(*sptr);
sched1[1] = '\0';
break;
# ifdef TURBO_C
case 'V':
directvideo = 1;
break;
# endif
case 'Z':
sptr+=2;
our_zone = atoi(sptr);
break;
default:
extended_help();
}
} else
extended_help();
}
errno = 0;
if (!info_path[0]) {
printf("No .PRM file specified.\n");
exit(1);
}
if (!message_path[0]) {
printf ("No MESSAGE PATH specified.\n");
exit(1);
}
if (!holding_path[0]) {
printf("No HOLD PATH specified.\n");
exit(1);
}
if (sched1[0])
printf("oMMM processing schedule '%c' ", sched1[0]);
if (!quiet_mode) {
printf("with\n");
printf("Info path: %s\n",info_path);
printf("Message path: %s\n",message_path);
printf("Hold path: %s\n",holding_path);
printf("Route file: %s\n",route_file);
printf("oMMM will %snormalize the holding area first\n", normalize?"":"not ");
printf("oMMM will %sforward messages for other systems\n", noforward?"not ":"");
printf("oMMM will %suse old style ARCmail names\n", oldstyle?"":"not ");
printf("oMMM will %sgate route interzone messages\n", use_gates?"":"not ");
printf("oMMM will use %s to pack ARCmail\n",pkarc?"pkarc":"arca");
} else {
printf("\n");
}
getnet(info_path);
if (!quiet_mode)
printf("Primary address is %d:%d/%d\n",our_zone,OURNET,OURNODE);
cur.net = ctlnet[0].net;
cur.node = ctlnet[0].node;
/* Set up the data for the current time stamp */
t1 = time(NULL);
t2 = localtime (&t1);
sprintf (nowtime, "%02d %3.3s %02d %02d:%02d:%02d",
t2->tm_mday, _months[t2->tm_mon], t2->tm_year,
t2->tm_hour, t2->tm_min, t2->tm_sec);
if (normalize)
make_normal(our_zone,"*.N*",'O',1);
if (pre_route[0])
do_routing (pre_route,'\0');
if (scan_messages())
make_bundle();
do_routing(route_file,(unsigned char)sched1[0]);
}
/*--------------------------------------------------------------------------*/
/* END OF FILE */
/*--------------------------------------------------------------------------*/