home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / OS2OMMM.SRC / OMMM.C < prev    next >
Text File  |  1989-06-01  |  12KB  |  443 lines

  1. /***************************************************************************/
  2. /***                                                                     ***/
  3. /***               oMMM - The Outbound Matrix Message Masher             ***/
  4. /***                      Copyright 1989 BS Software                     ***/
  5. /***                                                                     ***/
  6. /***                            FILENAME: OMMM.C                         ***/
  7. /***                                                                     ***/
  8. /***                      Mainline oMMM function and help                 ***/
  9. /***                                                                     ***/
  10. /***                 Based on the original oMMM, a portion of             ***/
  11. /***               the Opus Computer-Based Conversation System             ***/
  12. /***                     Copyright 1986, Wynn Wagner III                 ***/
  13. /***                                                                     ***/
  14. /***************************************************************************/
  15. /***                                                                     ***/
  16. /***                    Tabs set at every 4th column                     ***/
  17. /***                                                                     ***/
  18. /***************************************************************************/
  19.  
  20. /*
  21.     Polytron Version Control System Comments:
  22.  
  23.     The revision of this file is *** $Revision:   1.40    $ ***
  24.  
  25.     History of changes from 1.30 release version
  26.  
  27.     $Log:    C:/OMMM/PROJFILE/OMMM.C_V  $
  28.  *
  29.  *      Rev 1.40BP 2 June 1989 23:21:00    Bill Andrus
  30.  * Public Release Version 1.40BP (OS/2 Protect Mode, Bound)
  31.  *
  32.  *      Rev 1.40     12 Feb 1989  4:55:40    Marshall Presnell
  33.  * Public Release Version 1.40
  34.  *
  35.  *      Rev 1.31     31 Jan 1989  0:57:48    Marshall Presnell
  36.  * oMMM 1.35 Beta Release Version
  37.  *
  38.  *      Rev 1.30     23 Jan 1989 17:53:52    Marshall Presnell
  39.  * Public Source Code Release - Version 1.30
  40.  
  41. */
  42.  
  43. /*--------------------------------------------------------------------------*/
  44. /* Include files                                                            */
  45. /*--------------------------------------------------------------------------*/
  46.  
  47. #include    "ommm.h"
  48. #include    <myaddr.h>
  49.  
  50. #ifdef    MSC
  51. #    include <sys\types.h>
  52. #    include <direct.h>
  53. #endif
  54.  
  55. #include    <sys\stat.h>
  56. #include    <time.h>
  57. #include    <string.h>
  58. #include    <stdlib.h>
  59.  
  60. #ifdef    TURBO_C
  61. #    include <ctype.h>
  62. #    include <dir.h>
  63. #endif
  64.  
  65. #ifdef    ZTC
  66. #    include <direct.h>
  67. #    include <ctype.h>
  68. #endif
  69.  
  70. /*--------------------------------------------------------------------------*/
  71. /* Static function declarations                                             */
  72. /*--------------------------------------------------------------------------*/
  73.  
  74. static void extended_help(void);
  75. static void version_identifier(void);
  76. static void load_cfg_file(void);
  77.  
  78. /*--------------------------------------------------------------------------*/
  79. /* Static variable definitions                                                */
  80. /*--------------------------------------------------------------------------*/
  81.  
  82. static char * help[] = {
  83.     "Creates `.OUT' and `.FLO' files for outbound matrix traffic. Certain preset",
  84.     "data can be specified in the OMMM.CFG file (indicated by \"+\'s\" below)\n",
  85.  
  86.     "     USAGE: oMMM -iINFOPATH  -mMESSAGEPATH  -hHOLDPATH -pPRESCANPATH",
  87.     "                 -cROUTEFILE -sCHAR -zZONE -f -n -o -q\n",
  88.  
  89.     "         CHAR .......... a single character for this schedule tag",
  90.     "       + INFOPATH ...... the Opus .PRM file to use for network information",
  91.     "       + MESSAGEPATH ... the sub-directory containing outbound messages",
  92.     "       + HOLDPATH ...... the sub-directory for the OUT/FLO files",
  93.     "       + PRESCANPATH ... the file with routing information to be used",
  94.     "                         before message scanning takes place",
  95.     "       + ROUTEFILE ..... the file with routing information",
  96.     "       + ZONE .......... the zone number for our zone",
  97.     "         -f tells oMMM to make all 'no-send' packets normal again",
  98.     "       + -n tells oMMM not to forward messages from other nodes",
  99.     "       + -o tells oMMM to use the old .MO? extensions and not .TU1, etc.",
  100.     "       + -a tells oMMM to use pkarc instead of arca",
  101.     "       + -g tells oMMM to gate route interzone messages",
  102.     "         -q tells oMMM to run quietly (and marginally faster).\n",
  103.  
  104.     "EXAMPLE: oMMM -iOpus.Prm -mD:\\NET -hC:\\Opus\\Outbound -cMatrix.Ctl -d -z1 -n",
  105.     NULL
  106. };
  107.  
  108. static char         info_path[80];
  109. static char         nowtime[25];
  110. static char         route_file[80];
  111. static unsigned int normalize        = 0;
  112. static int            quiet_mode        = 0;
  113.  
  114. /*--------------------------------------------------------------------------*/
  115. /* Local Variable Definitions                                                */
  116. /*--------------------------------------------------------------------------*/
  117.  
  118. NETADDRESS    ctlnet[15]; /* See: ROUTEMSC, MISC, ARCHIVE, ROUTE, OMMMSCAN    */
  119.  
  120. #ifdef    ZTC
  121.     int     _okbigbuf = 0;
  122. #endif
  123.  
  124. /*--------------------------------------------------------------------------*/
  125. /* External variable declarations                                            */
  126. /*--------------------------------------------------------------------------*/
  127.  
  128.   /*  ... NONE ...    */
  129.  
  130. /*--------------------------------------------------------------------------*/
  131. /* Local definitions                                                        */
  132. /*--------------------------------------------------------------------------*/
  133.  
  134. #define   same(a,b)   (!strcmp((a),(b)))
  135.  
  136. /****************************************************************************/
  137.  
  138. /*--------------------------------------------------------------------------*/
  139. /* EXTENDED HELP                                           LOCAL FUNCTION    */
  140. /*--------------------------------------------------------------------------*/
  141.  
  142.  static void
  143. extended_help()
  144. {
  145.     int     q = 0;
  146.  
  147.     while (help[q] != NULL)
  148.         puts(help[q++]);
  149.     exit(1);
  150. }
  151.  
  152. /*--------------------------------------------------------------------------*/
  153. /* VERSION IDENTIFIER                                       LOCAL FUNCTION    */
  154. /*--------------------------------------------------------------------------*/
  155.  
  156.  static void
  157. version_identifier()
  158. {
  159.  
  160.     /*    This one module uses an include file called <myaddr.h> in the standard
  161.         include file path. It contains one line, as follows:
  162.  
  163.         #define MYADDRESS    "1:133/401 - StarBase Operations"
  164.  
  165.         (or whatever node number YOU have)
  166.  
  167.         Please create this file to compile this source code. - Also, please
  168.         do NOT use someone else's node number -- it's not too nice!
  169.     */
  170.  
  171.     printf("\noMMM Version %s\n",VERSION);
  172.     printf("Compiled at node %s\n",MYADDRESS);
  173.     printf("Compile Timestamp: %s  %s\n",__DATE__,__TIME__);
  174.     exit(0);
  175. }
  176.  
  177. /*--------------------------------------------------------------------------*/
  178. /* LOAD CFG FILE                                           LOCAL FUNCTION    */
  179. /*--------------------------------------------------------------------------*/
  180.  
  181.  void
  182. load_cfg_file()
  183. {
  184.     char    line[129];
  185.     int     lineno = 0;
  186.     char *    tok;
  187.     FILE *    cfg;
  188.  
  189.     cfg = fopen("oMMM.CFG","r");
  190.     if (cfg == NULL)
  191.         return;
  192.     printf("Reading oMMM.CFG file");
  193.     while (1) {
  194.         if (fgets(line,128,cfg) == NULL)
  195.             break;
  196.         putchar('.');
  197.         lineno++;
  198.         if (line[0] == ';' || line[0] == '\0')
  199.             continue;
  200.         tok = strtok(line," \t\n:");
  201.         if (tok == NULL || *tok == ';')
  202.             continue;
  203.         strlwr(tok);
  204.         if (same(tok,"infopath")) {
  205.             tok = strtok(NULL," \t;\n");
  206.             strcpy(info_path,tok);
  207.             fancy_str(info_path);
  208.         } else if (same(tok,"messagepath")) {
  209.             tok = strtok(NULL," \t;\n");
  210.             strcpy(message_path,tok);
  211.             add_backslash(message_path);
  212.         } else if (same(tok,"holdpath")) {
  213.             tok = strtok(NULL," \t;\n");
  214.             strcpy(holding_path,tok);
  215.             add_backslash(holding_path);
  216.         } else if (same(tok,"prescanpath")) {
  217.             tok = strtok(NULL," \t;\n");
  218.             strcpy(pre_route,tok);
  219.             fancy_str(pre_route);
  220.         } else if (same(tok,"routefile")) {
  221.             tok = strtok(NULL," \t;\n");
  222.             strcpy(route_file,tok);
  223.             fancy_str(route_file);
  224.         } else if (same(tok,"zone")) {
  225.             tok = strtok(NULL," \t;\n");
  226.             our_zone = atoi(tok);
  227.         } else if (same(tok,"forward")) {
  228.             noforward = 0;
  229.         } else if (same(tok,"mo?")) {
  230.             oldstyle = 1;
  231.         } else if (same(tok,"gateroute")) {
  232.             use_gates = 1;
  233.         } else if (same(tok,"arca")) {
  234.             pkarc = 0;
  235.         } else if (same(tok,"pkarc")) {
  236.             pkarc = 1;
  237.         } else {
  238.             printf("Error (line %d)\n",lineno);
  239.             printf("Unknown command \"%s\" in OMMM.CFG file\n",tok);
  240.             exit(1);
  241.         }
  242.     }
  243.     fclose(cfg);
  244.     cfg = NULL;
  245.     putchar('\n');
  246. }
  247.  
  248. /*--------------------------------------------------------------------------*/
  249. /* MAIN                                                                     */
  250. /*--------------------------------------------------------------------------*/
  251.  
  252.  void
  253. main(int argc,char * argv[])
  254. {
  255.     register int    i;
  256.     register char * sptr;
  257.     char            sched1[2];
  258.     long            t1;
  259.     struct tm *     t2;
  260.  
  261.     fprintf(stderr,"oMMM [%s] - Copyright 1989 BS Software; All rights reserved\n",VERSION);
  262.  
  263. #    ifdef TURBO_C
  264.         directvideo = 0;
  265. #    endif
  266.  
  267.     if (argc<2)
  268.         extended_help();
  269.  
  270.     getcwd(info_path,79);
  271.     add_backslash(info_path);
  272.  
  273.     date_conv       = 0;
  274.     our_zone       = 0;
  275.     holding_path[0]=message_path[0]=sched1[0]=route_file[0]=pre_route[0] = 0;
  276.  
  277.     load_cfg_file();
  278.  
  279.     for(i=1; i<argc; i++) {
  280.         sptr = argv[i];
  281.         if (sptr[0]=='-') {
  282.             switch(toupper(sptr[1])) {
  283.  
  284.                 case '?':
  285.                     version_identifier();
  286.                     break;
  287.  
  288.                 case 'A':
  289.                     pkarc = 1;
  290.                     break;
  291.  
  292.                 case 'C':
  293.                     sptr+=2;
  294.                     strcpy(route_file,sptr);
  295.                     fancy_str(route_file);
  296.                     break;
  297.  
  298.                 case 'D':
  299.                     date_conv = 0;
  300.                     break;
  301.  
  302.                 case 'F':
  303.                     normalize = 1;
  304.                     break;
  305.  
  306.                 case 'G':
  307.                     use_gates = 1;
  308.                     break;
  309.  
  310.                 case 'H':
  311.                     sptr+=2;
  312.                     strcpy(holding_path,sptr);
  313.                     add_backslash(holding_path);
  314.                     break;
  315.  
  316.                 case 'I':
  317.                     sptr+=2;
  318.                     strcpy(info_path,sptr);
  319.                     fancy_str(info_path);
  320.                     break;
  321.  
  322.                 case 'K':
  323.                     puts("-k not fully supported yet");
  324.                     keepmsgs = 1;
  325.                     break;
  326.  
  327.                 case 'M':
  328.                     sptr+=2;
  329.                     strcpy(message_path,sptr);
  330.                     add_backslash(message_path);
  331.                     break;
  332.  
  333.                 case 'N':
  334.                     noforward = 1;
  335.                     break;
  336.  
  337.                 case 'O':
  338.                     oldstyle = 1;
  339.                     break;
  340.  
  341.                 case 'P':
  342.                     sptr+=2;
  343.                     strcpy(pre_route,sptr);
  344.                     fancy_str(pre_route);
  345.                     break;
  346.  
  347.                 case 'Q':
  348.                     printf("Quiet mode\n");
  349.                     quiet_mode = 1;
  350.                     break;
  351.  
  352.                 case 'S':
  353.                     sptr+=2;
  354.                     sched1[0] = (char) toupper(*sptr);
  355.                     sched1[1] = '\0';
  356.                     break;
  357.  
  358. #                ifdef TURBO_C
  359.                 case 'V':
  360.                     directvideo = 1;
  361.                     break;
  362. #                endif
  363.  
  364.                 case 'Z':
  365.                     sptr+=2;
  366.                     our_zone = atoi(sptr);
  367.                     break;
  368.  
  369.                 default:
  370.                     extended_help();
  371.             }
  372.         } else
  373.             extended_help();
  374.     }
  375.  
  376.     errno = 0;
  377.  
  378.     if (!info_path[0]) {
  379.         printf("No .PRM file specified.\n");
  380.         exit(1);
  381.     }
  382.  
  383.     if (!message_path[0]) {
  384.         printf ("No MESSAGE PATH specified.\n");
  385.         exit(1);
  386.     }
  387.  
  388.     if (!holding_path[0]) {
  389.         printf("No HOLD PATH specified.\n");
  390.         exit(1);
  391.     }
  392.  
  393.  
  394.     if (sched1[0])
  395.         printf("oMMM processing schedule '%c' ", sched1[0]);
  396.  
  397.     if (!quiet_mode) {
  398.         printf("with\n");
  399.         printf("Info path:    %s\n",info_path);
  400.         printf("Message path: %s\n",message_path);
  401.         printf("Hold path:    %s\n",holding_path);
  402.         printf("Route file:   %s\n",route_file);
  403.  
  404.         printf("oMMM will %snormalize the holding area first\n", normalize?"":"not ");
  405.         printf("oMMM will %sforward messages for other systems\n", noforward?"not ":"");
  406.         printf("oMMM will %suse old style ARCmail names\n", oldstyle?"":"not ");
  407.         printf("oMMM will %sgate route interzone messages\n", use_gates?"":"not ");
  408.         printf("oMMM will use %s to pack ARCmail\n",pkarc?"pkarc":"arca");
  409.     } else {
  410.         printf("\n");
  411.     }
  412.  
  413.     getnet(info_path);
  414.  
  415.     if (!quiet_mode)
  416.         printf("Primary address is %d:%d/%d\n",our_zone,OURNET,OURNODE);
  417.  
  418.     cur.net  = ctlnet[0].net;
  419.     cur.node = ctlnet[0].node;
  420.  
  421.     /* Set up the data for the current time stamp */
  422.  
  423.     t1 = time(NULL);
  424.     t2 = localtime (&t1);
  425.     sprintf (nowtime, "%02d %3.3s %02d  %02d:%02d:%02d",
  426.     t2->tm_mday, _months[t2->tm_mon], t2->tm_year,
  427.     t2->tm_hour, t2->tm_min, t2->tm_sec);
  428.  
  429.     if (normalize)
  430.         make_normal(our_zone,"*.N*",'O',1);
  431.     if (pre_route[0])
  432.         do_routing (pre_route,'\0');
  433.  
  434.     if (scan_messages())
  435.         make_bundle();
  436.  
  437.     do_routing(route_file,(unsigned char)sched1[0]);
  438. }
  439.  
  440. /*--------------------------------------------------------------------------*/
  441. /*                                  END OF FILE                                */
  442. /*--------------------------------------------------------------------------*/
  443.