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