home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Tools / tables / tjoin / tjoin.y < prev    next >
Encoding:
Text File  |  1991-12-18  |  2.1 KB  |  116 lines

  1. %union {
  2.     char *str;
  3. }
  4.  
  5. %token  <str> STRING
  6.  
  7. %type    <str>    host
  8. %%
  9. file        :    line
  10.         |       file line
  11.         ;
  12.  
  13. line        :    '\n'
  14.         |    STRING ':' hostlist '\n' {
  15.                 /* Direct Connet or AR hosts */
  16.                 if (CheckHost ($1) != 0)
  17.                     StoreHost ($1);
  18.                     else
  19.                     FreeHostInfo (HostList);
  20.                 free ($1);
  21.                 HostList = NULL;
  22.                 }
  23.         |    STRING ':' '(' chanlist ')' '\n' {
  24.                 if (CheckChan (ChanList) != 0)
  25.                     StoreChans ($1);
  26.                     else
  27.                     FreeChanInfo (ChanList);
  28.                 free ($1);
  29.                 ChanList = NULL;
  30.                 }
  31.         |    error '\n' {
  32.                 crapline ();
  33.                 HostList = NULL;
  34.                 ChanList = NULL;
  35.                 }
  36.         ;
  37.  
  38. hostlist    :    host {
  39.                 StartHostList ($1);
  40.                 ChanList = NULL;
  41.                 }
  42.         |    hostlist ',' host {
  43.                 AddToHostList ($3);
  44.                 ChanList = NULL;
  45.                 }
  46.         ;
  47.  
  48. host        :    STRING '(' ')' {
  49.                 /* This is an Application Relay */
  50.                 $$ = $1;
  51.                 }
  52.         |    STRING '(' chanlist ')' {
  53.                 /* This is a Direct Connect */
  54.                 $$ = $1;
  55.                 }
  56.         ;
  57.  
  58. chanlist    :    STRING {
  59.                 StartChanList ($1);
  60.                 }
  61.         |    chanlist ',' STRING {
  62.                 AddToChanList ($3);
  63.                 }
  64.         ;
  65.  
  66. %%
  67.  
  68. #include        <stdio.h>
  69. #include    "tjoin.h"
  70.  
  71. extern  int     yylineno;
  72.  
  73. int    PrintNode (), CheckARs ();
  74. SBUFF    *InitStringStore ();
  75.  
  76. char    *av0, *MyName;
  77. HOST    *HostList = NULL;    /* Stores Host info on input line basis */
  78. CHAN    *ChanList = NULL;    /* Stores Chan info on input host basis */
  79. CHAN    *ValidChanList = NULL;
  80. MTA    *MtaTree = NULL;    /* Root of in core database */
  81. SBUFF    *ARStringStore, *HostStringStore;
  82. int    Debug = 0, PrintRoute = 0, DirectFirst = 0, ComplexOutput = 0;
  83.  
  84. main (argc, argv)
  85. int     argc;
  86. char    *argv [];
  87. {
  88.     register int    i;
  89.  
  90.     av0 = argv [0];
  91.     MyName = NULL;
  92.     for (i = 1; i < argc; i++) {
  93.         if (*argv [i] == '-')
  94.             DoFlag (&argv [i][1]);
  95.             else
  96.             if (MyName == NULL)
  97.                 MyName = argv [i];
  98.                 else
  99.                 DefineChan (argv [i]);
  100.     }
  101.     if (ValidChanList == NULL)
  102.         Usage ();
  103.     ARStringStore = InitStringStore ();
  104.     HostStringStore = InitStringStore ();
  105.     yyparse ();
  106.     WalkTree (MtaTree, CheckARs);
  107.     /*
  108.      * Now that all AR names point to MTA structs - Zap space used
  109.      * to store names.
  110.      */
  111.     FreeStringStore (ARStringStore);
  112.     if (Debug == 2)    DebugTree (MtaTree, 0);
  113.     WalkTree (MtaTree, PrintNode);
  114.     exit (0);
  115. }
  116.