home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / src / tools / tablelist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-28  |  1.9 KB  |  97 lines

  1. /*
  2.  *      List tables referenced by the specified tailor file
  3.  *
  4.  *      Command line:
  5.  *              tablelist [-t tailorfile]
  6.  *
  7.  */
  8.  
  9. #include "util.h"
  10. #include "mmdf.h"
  11. #include "ch.h"
  12. #include "dm.h"
  13. #include "chdbm.h"
  14.  
  15. extern Table **tb_list;  /* order tables searched         */
  16. extern Domain **dm_list; /* ordr domain tables searched  */
  17. extern Chan  **ch_tbsrch;  /* order chans searched         */
  18.  
  19. extern char *mmtailor;
  20.  
  21. /*
  22.  * Main procedure.
  23.  * process arguments, set flags and invoke file processing.
  24.  * clean up and exit properly.
  25.  */
  26.  
  27. main(argc, argv)
  28. char **argv;
  29. {
  30.     int ind;
  31.     char *p;
  32.     register Table  *tblptr;
  33.     char *prog;
  34.  
  35.     prog = argv[0];
  36.  
  37.     argv++; argc--;
  38.  
  39.     while(argc-- > 0)
  40.     {
  41.     p = *argv++;
  42.     if(*p == '-')
  43.     {
  44.         while(*++p)
  45.         switch(*p)
  46.         {
  47.             case 't':
  48.                 mmtailor = *argv++;
  49.                 break;
  50.  
  51.             default:
  52.                 fprintf (stderr,"Unknown flag %c\n",*p);
  53.                 break;
  54.         }
  55.     }
  56.     }
  57.  
  58.     mmdf_init(prog);
  59.  
  60.     /*
  61.      *  Check for existence first
  62.      */
  63.     for (ind = 0; dm_list[ind] != (Domain *)0; ind++)
  64.         check(dm_list[ind] -> dm_table);
  65.  
  66.     for (ind = 0; ch_tbsrch[ind] != (Chan *) 0; ind++)
  67.     {
  68.         check(ch_tbsrch[ind] -> ch_table);
  69.  
  70.         if ((tblptr = ch_tbsrch[ind] -> ch_insource) != (Table *) 0)
  71.         check(tblptr);
  72.         if ((tblptr = ch_tbsrch[ind] -> ch_outsource) != (Table *) 0)
  73.         check(tblptr);
  74.         if ((tblptr = ch_tbsrch[ind] -> ch_indest) != (Table *) 0)
  75.         check(tblptr);
  76.         if ((tblptr = ch_tbsrch[ind] -> ch_outdest) != (Table *) 0)
  77.         check(tblptr);
  78.     }
  79.  
  80.     for (ind = 0; (tblptr = tb_list[ind]) != (Table *) 0; ind++)
  81.         check (tblptr);
  82.     } 
  83.  
  84. check (tblptr)
  85. Table *tblptr;
  86. {
  87. #ifdef NAMESERVER
  88.     if ((tblptr -> tb_flags & TB_SRC) == TB_NS)
  89.     return;
  90. #endif /* NAMESERVER */
  91.     if (tblptr -> tb_fp == (FILE *)EOF)
  92.     return;             /* Already done */
  93.     printf("%s\n", tblptr -> tb_file);
  94.     tblptr -> tb_fp = (FILE *) EOF;
  95.     return;
  96. }
  97.