home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / OS2PLST.SRC / PARSELST.C < prev    next >
Text File  |  1990-05-08  |  37KB  |  1,769 lines

  1. /*
  2.                               Nodelist Parser
  3.  
  4.               This module was originally written by Bob Hartman
  5.                        Sysop of FidoNet node 1:132/101
  6.  
  7.    Spark Software, 427-3 Amherst St, CS 2032, Suite 232, Nashua, NH 03061
  8.  
  9.  This program source code is being released with the following provisions:
  10.  
  11.  1.  You are  free to make    changes to this source    code for use on your own
  12.  machine,  however,  altered source files may not be distributed without the
  13.  consent of Spark Software.
  14.  
  15.  2.  You may distribute "patches"  or  "diff" files for any changes that you
  16.  have made, provided that the "patch" or "diff" files are also sent to Spark
  17.  Software for inclusion in future releases of the entire package.    A "diff"
  18.  file for the source archives may also contain a compiled version,    provided
  19.  it is    clearly marked as not  being created  from the original source code.
  20.  No other  executable  versions may be    distributed without  the  consent of
  21.  Spark Software.
  22.  
  23.  3.  You are free to include portions of this source code in any program you
  24.  develop, providing:  a) Credit is given to Spark Software for any code that
  25.  may is used, and  b) The resulting program is free to anyone wanting to use
  26.  it, including commercial and government users.
  27.  
  28.  4.  There is  NO  technical support  available for dealing with this source
  29.  code, or the accompanying executable files.  This source  code  is provided
  30.  as is, with no warranty expressed or implied (I hate legalease).    In other
  31.  words, if you don't know what to do with it,  don't use it,  and if you are
  32.  brave enough to use it, you're on your own.
  33.  
  34.  Spark Software may be contacted by modem at (603) 888-8179 (node 1:132/101)
  35.  on the public FidoNet network, or at the address given above.
  36.  
  37. */
  38.  
  39. #include <stdio.h>
  40. #include <ctype.h>
  41. #include <fcntl.h>
  42. #include <sys/types.h>
  43. #include <sys/stat.h>
  44. #include <time.h>
  45. #include <malloc.h>
  46. #include <string.h>
  47. #include <io.h>
  48. #include <stdlib.h>
  49.  
  50. /* Should we generate an Opus style nodelist output */
  51.  
  52. #include "types.h"
  53. #include "externs.h"
  54.  
  55. #ifndef OS2
  56. #define open fast_open
  57. #define close fast_close
  58. #define read fast_read
  59. #define write fast_write
  60. #endif
  61.  
  62. #ifndef OS2
  63.  
  64. char           *REV = "$Revision: 1.31 $";      /* Used in my code for my RCS
  65.                                                  * program */
  66. #else
  67.  
  68. char           *REV = "$Revision: 1.31-OS/2 $";      /* Used in my code for my RCS
  69.                                                  * program */
  70. #endif
  71.  
  72. struct _node    new_node;
  73. struct _oldnode old_node;
  74. struct netls    seanet;
  75. struct nodels    seanode;
  76. struct extrastuff bt_node;
  77. struct nidxs   *seaidx;
  78. struct nidxs   *seaptr;
  79. struct qidx     qbbsidx;
  80. struct qdat     qbbsnode;
  81. long            seanodecnt;
  82. int             seacnt;
  83. long            seanetcnt;
  84.  
  85. char            buf[256];
  86. char            prn_first_line[256];
  87. char            txt_first_line[256];
  88. int             prn_pg_lines;
  89. int             txt_pg_lines;
  90. int             prn_pagenum;
  91. int             txt_pagenum;
  92. int             cmdbaud = 0;
  93.  
  94. static FILE    *nodelist_bbs, *nodelist_fon, *fidouser_$$1;
  95. static int       nodelist_dat, nodelist_idx, nodelist_sys;
  96. static FILE    *nodelist_prn, *nodelist_txt;
  97. static int       netlist_dog, nodelist_dog, index_dog;
  98. static int       nodelist_ext;
  99. static int       qnl_idx_bbs, qnl_dat_bbs;
  100.  
  101. /* extern int      *cmp(); */
  102.  
  103. main (argc, argv)
  104. int             argc;
  105. char           *argv[];
  106.  
  107. {
  108.    char            buff1[20], buff2[20];        /* Junk buffers */
  109.    char         *s,*config_file ="PARSELST.CFG";
  110.    char         *mylist=NULL,*pvtlist=NULL;
  111.    char         *nodelist,editnl=0,cl_nodelist=0;
  112.    int             i;
  113.  
  114.    sscanf (REV, "$%s %s", buff1, buff2);
  115.    fprintf (stderr, "ParseLst - %s %s by Bob Hartman, SysOp of FidoNet Node 1:132/101\n", buff1, buff2);
  116.    fprintf (stderr, "This program is placed in the  Public Domain  as part of the BBS project.\n");
  117.    fprintf (stderr, "For information on BBS (Bit Bucket Software), contact 132/101 or 141/491.\n\n");
  118.  
  119.    if (argc > 1){
  120.        for (i=1;i<argc;i++) {
  121.            s=argv[i];
  122.            if ((s[0] == '/') || (s[0] == '-')) {
  123.                switch(tolower(s[1])) {
  124.  
  125. #ifndef OS2
  126.                    case 'e' :    editnl++;
  127.                                  break;
  128. #endif
  129.  
  130.                    case 'n' :    nodelist=(s+2);
  131.                                  strupr(nodelist);
  132.                                  cl_nodelist++;
  133.                                  break;
  134.  
  135.                    case 'c' :    config_file=s+2;
  136.                                  strupr (config_file);
  137.                                  break;
  138.  
  139.                    case 'm' :   mylist=(s+2);
  140.                                 strupr(mylist);
  141.                                 break;
  142.  
  143.                    case 'p' :   pvtlist=s+2;
  144.                                 strupr(pvtlist);
  145.                                 break;
  146.  
  147.                    case 'b' :   cmdbaud=atoi(&s[2]);
  148.                                 break;
  149.  
  150.                    default:      printf("Don't understand %s\n\n",s);
  151.                                  break;
  152.  
  153.                                  }
  154.                              }
  155.                          }
  156.                      }
  157. #ifndef OS2
  158.       if (editnl > 0)
  159.          {
  160.          printf ("Using EditNL to update Nodelist\n");
  161.          system ("EditNL");
  162.          printf ("\n");
  163.          }
  164.      else    edit();
  165. #else
  166.      edit();
  167. #endif
  168.  
  169.    strcpy (country, "1");
  170.  
  171.    /* Need to find the correct file to use */
  172.    fn = &fn_head;
  173.    if (cl_nodelist > 0)
  174.       {
  175.       fn->fname = nodelist;
  176.       strupr (fn->fname);
  177.       }
  178.    else
  179.       {
  180.       nfile_name (&(fn->fname));
  181.       }
  182.    fn->next = NULL;
  183.    fn->private = 0;
  184.  
  185.    ph = ph_head;
  186.    bd = bd_head;
  187.    dl = dl_head;
  188.    co = co_head;
  189.    et = et_head;
  190.  
  191.    /* Parse configuration file */
  192.    parse_config (config_file,mylist,pvtlist);
  193.  
  194.    if (cmdbaud > 0)
  195.       maxbaud = cmdbaud;
  196.  
  197.    /* Open output files */
  198.    open_outfiles ();
  199.  
  200.    /* Set up the output type */
  201.    if (out_type == -1)
  202.       {
  203.       if (myzone > 0)
  204.          out_type = 0;
  205.       else
  206.          out_type = 1;
  207.       }
  208.  
  209.    fn = &fn_head;
  210.    while (fn != NULL)
  211.       {
  212.       process_file (1);
  213.       }
  214.  
  215.    /* Close all the files */
  216.    if (nodelist_bbs != NULL)
  217.       {
  218.       fclose (nodelist_bbs);
  219.       }
  220.    if (nodelist_fon != NULL)
  221.       {
  222.       fclose (nodelist_fon);
  223.       }
  224.    if (fidouser_$$1 != NULL)
  225.       {
  226.       fclose (fidouser_$$1);
  227.       }
  228.    if (nodelist_dat != -1)
  229.       {
  230.       close (nodelist_dat);
  231.       }
  232.    if (nodelist_sys != -1)
  233.       {
  234.       close (nodelist_sys);
  235.       }
  236.    if (nodelist_idx != -1)
  237.       {
  238.       close (nodelist_idx);
  239.       }
  240.    if (nodelist_ext != -1)
  241.       {
  242.       close (nodelist_ext);
  243.       }
  244.    if (nodelist_prn != NULL)
  245.       {
  246.       fclose (nodelist_prn);
  247.       }
  248.    if (nodelist_txt != NULL)
  249.       {
  250.       fclose (nodelist_txt);
  251.       }
  252.    if (nodelist_dog != -1)
  253.       {
  254.       close (nodelist_dog);
  255.       }
  256.    if (qnl_idx_bbs != -1)
  257.       {
  258.       close (qnl_idx_bbs);
  259.       }
  260.    if (qnl_dat_bbs != -1)
  261.       {
  262.       close (qnl_dat_bbs);
  263.       }
  264.    if (netlist_dog != -1)
  265.       {
  266.       if (seanet.numnodes)
  267.          {
  268.          write (netlist_dog, (char *) &seanet, sizeof (struct netls));
  269.          }
  270.       close (netlist_dog);
  271.  
  272.       if (seaidx != NULL)
  273.          {
  274.          printf ("\nSorting for INDEX.DOG\n");
  275.          qsort (seaidx, seacnt, sizeof (struct nidxs), cmp);
  276.          unlink ("INDEX.DOG");
  277.          if ((index_dog = open ("INDEX.DOG", O_WRONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE)) == -1)
  278.             {
  279.             printf ("Error opening INDEX.DOG - not generated\n");
  280.             unlink ("INDEX.DOG");
  281.             }
  282.          else
  283.             {
  284.             write (index_dog, (char *) seaidx, sizeof (struct nidxs) * seacnt);
  285.             close (index_dog);
  286.             }
  287.          }
  288.       else
  289.          {
  290.          /* Have to get rid of this to make sure no one gets confused */
  291.          unlink ("INDEX.DOG");
  292.          }
  293.       }
  294.  
  295.    printf ("\rProcessing Completed Without Errors.\n\n");
  296.  
  297.    /* Do any additional processing that might be needed */
  298.    if (doreport)
  299.       {
  300.       size_report ();
  301.       }
  302.  
  303.    if (fidouser_$$1 != NULL)
  304.       {
  305.       do_names ();
  306.       }
  307.    return (0);
  308. }
  309.  
  310. void
  311. open_outfiles ()
  312. {
  313.    int               i;
  314.  
  315.    if (nlist)
  316.       {
  317.       if ((nodelist_bbs = fopen ("NODELIST.BBS", "w")) == NULL)
  318.          {
  319.          printf ("Error opening output file\n");
  320.          exit (1);
  321.          }
  322.       }
  323.    else
  324.       {
  325.       nodelist_bbs = NULL;
  326.       }
  327.  
  328.    /* Open the NODELIST.FON file? */
  329.    if (rdata)
  330.       {
  331.       if ((nodelist_fon = fopen ("NODELIST.FON", "w")) == NULL)
  332.          {
  333.          printf ("Error opening NODELIST.FON - not generated\n");
  334.          }
  335.       }
  336.    else
  337.       {
  338.       nodelist_fon = NULL;
  339.       }
  340.  
  341.    /* Open the Fidouser.$$1 file */
  342.    if (udata)
  343.       {
  344.       if ((fidouser_$$1 = fopen ("FIDOUSER.$$1", "w")) == NULL)
  345.          {
  346.          printf ("Error opening FIDOUSER.$$1 - not generated\n");
  347.          }
  348.       }
  349.    else
  350.       {
  351.       fidouser_$$1 = NULL;
  352.       }
  353.  
  354.    nodelist_dat = -1;
  355.    nodelist_idx = -1;
  356.  
  357.    if (newopus)
  358.       {
  359.       unlink ("NODELIST.DAT");
  360.       if ((nodelist_dat = open ("NODELIST.DAT", O_WRONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE)) == -1)
  361.          {
  362.          printf ("Error opening NODELIST.DAT - not generated\n");
  363.          }
  364.       else
  365.          {
  366.          unlink ("NODELIST.IDX");
  367.          if ((nodelist_idx = open ("NODELIST.IDX", O_WRONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE)) == -1)
  368.             {
  369.             printf ("Error opening NODELIST.IDX - NODELIST.DAT not generated\n");
  370.             close (nodelist_dat);
  371.             nodelist_dat = -1;
  372.             }
  373.          else
  374.             {
  375.             /* Write out the start of the .SYS file */
  376.             memset (&new_node, 0, sizeof (struct _node));
  377.             new_node.number = 6;
  378.             new_node.net = -1;
  379.             strcpy (new_node.name, "ParseLst");
  380.             strcpy (new_node.city, "1:132/101 in Nashua, NH USA");
  381.             write (nodelist_dat, (char *) &new_node, sizeof (struct _node));
  382.  
  383.             /* Write out the start of the .IDX file */
  384.             i = 5;
  385.             write (nodelist_idx, (char *) &i, sizeof (int));
  386.             i = -1;
  387.             write (nodelist_idx, (char *) &i, sizeof (int));
  388.             }
  389.          }
  390.       }
  391.    else
  392.       {
  393.       nodelist_dat = -1;
  394.       nodelist_idx = -1;
  395.       }
  396.  
  397.    nodelist_sys = -1;
  398.  
  399.    if (oldopus)
  400.       {
  401.       unlink ("NODELIST.SYS");
  402.       if ((nodelist_sys = open ("NODELIST.SYS", O_WRONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE)) == -1)
  403.          {
  404.          printf ("Error opening NODELIST.SYS - not generated\n");
  405.          }
  406.       else
  407.          {
  408.          if (nodelist_idx == -1)
  409.             {
  410.             unlink ("NODELIST.IDX");
  411.             if ((nodelist_idx = open ("NODELIST.IDX", O_WRONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE)) == -1)
  412.                {
  413.                printf ("Error opening NODELIST.IDX - NODELIST.SYS not generated\n");
  414.                close (nodelist_sys);
  415.                nodelist_sys = -1;
  416.                }
  417.             else
  418.                {
  419.                /* Write out the start of the .IDX file */
  420.                i = 5;
  421.                write (nodelist_idx, (char *) &i, sizeof (int));
  422.                i = -1;
  423.                write (nodelist_idx, (char *) &i, sizeof (int));
  424.                }
  425.             }
  426.  
  427.          /* Write out the start of the .SYS file */
  428.          memset (&old_node, 0, sizeof (struct _oldnode));
  429.          old_node.number = 5;
  430.          old_node.net = -1;
  431.          strcpy (old_node.name, "ParseLst");
  432.          strcpy (old_node.city, "1:132/101 in Nashua, NH USA");
  433.          write (nodelist_sys, (char *) &old_node, sizeof (struct _oldnode));
  434.          }
  435.       }
  436.    else
  437.       {
  438.       nodelist_sys = -1;
  439.       }
  440.  
  441.    nodelist_ext = -1;
  442.  
  443.    if (binkley)
  444.       {
  445.       unlink ("NODELIST.EXT");
  446.       if ((nodelist_ext = open ("NODELIST.EXT", O_WRONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE)) == -1)
  447.          {
  448.          printf ("Error opening NODELIST.EXT - not generated\n");
  449.          }
  450.       else
  451.          {
  452.          if (nodelist_idx == -1)
  453.             {
  454.             unlink ("NODELIST.IDX");
  455.             if ((nodelist_idx = open ("NODELIST.IDX", O_WRONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE)) == -1)
  456.                {
  457.                printf ("Error opening NODELIST.IDX - NODELIST.EXT not generated\n");
  458.                close (nodelist_ext);
  459.                nodelist_ext = -1;
  460.                }
  461.             else
  462.                {
  463.                /* Write out the start of the .IDX file */
  464.                i = 7;
  465.                write (nodelist_idx, (char *) &i, sizeof (int));
  466.                i = -1;
  467.                write (nodelist_idx, (char *) &i, sizeof (int));
  468.                }
  469.             }
  470.  
  471.          /* Write out the start of the .EXT file */
  472.          memset (&bt_node, 0, sizeof (struct extrastuff));
  473.          strcpy (bt_node.password, "ParseLst");
  474.          write (nodelist_ext, (char *) &bt_node, sizeof (struct extrastuff));
  475.          }
  476.       }
  477.    else
  478.       {
  479.       nodelist_ext = -1;
  480.       }
  481.  
  482.    if (sealist)
  483.       {
  484.       unlink ("NODELIST.DOG");
  485.       if ((nodelist_dog = open ("NODELIST.DOG", O_WRONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE)) == -1)
  486.          {
  487.          printf ("Error opening NODELIST.DOG - not generated\n");
  488.          }
  489.       else
  490.          {
  491.          unlink ("NETLIST.DOG");
  492.          if ((netlist_dog = open ("NETLIST.DOG", O_WRONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE)) == -1)
  493.             {
  494.             printf ("Error opening NETLIST.DOG - NODELIST.DOG not generated\n");
  495.             close (nodelist_dog);
  496.             nodelist_dog = -1;
  497.             seanetcnt = sizeof (struct netls);
  498.             }
  499.          else
  500.             {
  501.             /* Write out the start of the NETLIST.DOG file */
  502.             memset (&seanet, 0, sizeof (struct netls));
  503.             write (netlist_dog, (char *) &seanet, sizeof (struct netls));
  504.             }
  505.          }
  506.  
  507.       if ((seaidx = calloc (sizeof (struct nidxs), 4000)) == NULL)
  508.          {
  509.          printf ("Could not allocate space for INDEX.DOG - not generating\n");
  510.          seaptr = NULL;
  511.          }
  512.       else
  513.          {
  514.          seaptr = seaidx;
  515.          }
  516.       }
  517.    else
  518.       {
  519.       nodelist_dog = -1;
  520.       netlist_dog = -1;
  521.       }
  522.  
  523.    if (quickbbs)
  524.       {
  525.       unlink ("QNL_DAT.BBS");
  526.       if ((qnl_dat_bbs = open ("QNL_DAT.BBS", O_WRONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE)) == -1)
  527.          {
  528.          printf ("Error opening QNL_DAT.BBS - not generated\n");
  529.          }
  530.       else
  531.          {
  532.          unlink ("QNL_IDX.BBS");
  533.          if ((qnl_idx_bbs = open ("QNL_IDX.BBS", O_WRONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE)) == -1)
  534.             {
  535.             printf ("Error opening QNL_IDX.BBS - QNL_DAT.BBS not generated\n");
  536.             close (qnl_dat_bbs);
  537.             qnl_dat_bbs = -1;
  538.             }
  539.          }
  540.       }
  541.    else
  542.       {
  543.       qnl_idx_bbs = -1;
  544.       qnl_dat_bbs = -1;
  545.       }
  546.  
  547.    if (fidoprn)
  548.       {
  549.       if ((nodelist_prn = fopen ("NODELIST.PRN", "w")) != NULL)
  550.          prn_pg_lines = 100;
  551.       }
  552.    if (fidotxt)
  553.       {
  554.       if ((nodelist_txt = fopen ("NODELIST.TXT", "w")) != NULL)
  555.          txt_pg_lines = 100;
  556.       }
  557. }
  558.  
  559. void
  560. process_file (times)
  561. int             times;
  562. {
  563.    int               n_num;
  564.    int               n_cost;
  565.    int               n_baud;
  566.    int               node;
  567.    int               addrs[4];
  568.    char            this_file[64];
  569.    char            def_phone[30];
  570.    char            def_flags[30];
  571.    int               def_cost;
  572.    int               def_baud;
  573.    int               cur_addr_lev;
  574.    int               did_cost;
  575.    int               i;
  576.    int               did_phone;
  577. /* int               done; */
  578.    char            buff[128];
  579. /*     int             f;*/
  580.    FILE           *f;
  581. /* char           *p, *p1, *p2, *p3; */
  582.    char           *p, *p1, *p2;
  583.    int               dphone;
  584.    char            b1[50];
  585.    char            b2[50];
  586.    char            b3[50];
  587.    char            b4[50];
  588.    char            b5[50];
  589.    char            b6[50];
  590.    char            b7[128];
  591.    char            pn1[20], pn2[20], pn3[20];
  592.    char            orig_phone[30];
  593.    int               pvt, hold, skip, def, n_out, this_list;
  594. /* PWTRP           tpw;
  595.    PHTRP           tph;
  596.    BDTRP           tbd;
  597.    DLTRP           tdl;
  598.    COTRP           tco;
  599.    ETTRP           tep;
  600.    FNLSTP           tfn;  */
  601.    char            ntyp;
  602.    char           *mymalloc ();
  603.    extern char      *strchr ();
  604.  
  605.    /* Open the next filename */
  606.    f = NULL;
  607.    cur_addr_lev = 0;
  608.    if ((f = fopen (fn->fname, "r")) == NULL)
  609. /*     if ((f = open (fn->fname, O_RDONLY|O_BINARY)) == -1)*/
  610.       {
  611.       printf ("\rCould not open Nodelist File '%s' - Exiting\n", fn->fname);
  612.       exit (1);
  613.       }
  614.  
  615.    this_list = fn->private;
  616.  
  617.    if (times)
  618.       {
  619.       printf ("\nProcessing Nodelist File '%s'\n", fn->fname);
  620.       fgets (buf,256, f);
  621. /*        get_data (buf, f);*/
  622.       p1 = buf + strlen (buf) - 1;
  623.       while ((p1 >= buf) && (*p1 != ':'))
  624.          --p1;
  625.       if (p1 >= buf)
  626.          {
  627.          strcpy (p1, "-- Page");
  628.          sprintf (prn_first_line, "Bulletin Board Listing from %s", buf + 3);
  629.          sprintf (txt_first_line, "%s", buf + 3);
  630.          }
  631.       else
  632.          {
  633.          prn_first_line[0] = '\0';
  634.          txt_first_line[0] = '\0';
  635.          }
  636.  
  637.       if ((nodelist_prn != NULL) && !this_list)
  638.          {
  639.          ++prn_pagenum;
  640.          fprintf (nodelist_prn, "%s %d\n\n", prn_first_line, prn_pagenum);
  641.          }
  642.  
  643.       if ((nodelist_txt != NULL) && !this_list)
  644.          {
  645.          ++txt_pagenum;
  646.          fprintf (nodelist_txt, "%s %d\n\n", txt_first_line, txt_pagenum);
  647.          }
  648.       }
  649.    else
  650.       printf ("\nAdding Nodelist File '%s' to Zone %d\n", fn->fname, myzone);
  651.    strcpy (this_file, fn->fname);
  652.  
  653.    /* Show that we are not skipping here */
  654.    skip = -1;
  655.  
  656.    addrs[0] = addrs[1] = addrs[2] = addrs[3] = (myzone > 0) ? myzone : 1;
  657.  
  658.    while (1)
  659.       {
  660.       if (fgets (buf, 256, f) == NULL)
  661. /*        if (get_data (buf, f))*/
  662.          break;
  663.  
  664.       pvt = 0;
  665.       dphone = 0;
  666.       n_cost = 0;
  667.       did_cost = 0;
  668.       hold = 0;
  669.       ntyp = 'L';
  670.       def = 0;
  671.       likely = 0;
  672.  
  673.       p = buff;
  674.       p1 = buf;
  675.       while (*p1)
  676.          {
  677.          if (!isspace (*p1))
  678.             *p++ = *p1;
  679.          ++p1;
  680.          }
  681.       *p++ = '\n';
  682.       *p = '\0';
  683.       p = buff;
  684.  
  685.       if (*p == ';')
  686.          {
  687.          if (comments)
  688.             {
  689.             fputs (buf, stdout);
  690.             }
  691.  
  692.          if ((!this_list) && (buf[1] == 'A'))
  693.             {
  694.             if ((nodelist_prn != NULL) && (prn_pg_lines == 100))
  695.                fputs (buf + 2, nodelist_prn);
  696.             if ((nodelist_txt != NULL) && (txt_pg_lines == 100))
  697.                fputs (buf + 2, nodelist_txt);
  698.             }
  699.          continue;
  700.          }
  701.  
  702.       nnodes++;
  703.  
  704.       /* Modifier (Host, Region, etc.) */
  705.       p = nextfield (p, b1);
  706.  
  707.       /* Node number (or region or zone) */
  708.       p = nextfield (p, b2);
  709.       n_num = atoi (b2);
  710.  
  711.       /* Did we get anything? */
  712.       if (b1[0] != '\0')
  713.          {
  714.          /* Is it something we need to worry about? */
  715.          if (stricmp (b1, "zone") == 0)
  716.             {
  717.             if ((myzone > 0) && (addrs[0] == myzone) && nzones)
  718.                {
  719.                if (fn != NULL)
  720.                   fn = fn->next;
  721.                i = 0;
  722.                while (fn != NULL)
  723.                   {
  724.                   process_file (0);
  725.                   i = 1;
  726.                   }
  727.                if (i)
  728.                   printf ("\nReturning to finish file '%s'\n", this_file);
  729.                }
  730.  
  731.             ++nzones;
  732.             if (out_type == 0)
  733.                {
  734.                if (usezone)
  735.                   strcpy (b1, "ZONE ");
  736.                else
  737.                   strcpy (b1, "REGION ");
  738.                dphone = 1;
  739.                }
  740.             else
  741.                {
  742.                if (usezone)
  743.                   strcpy (b1, "ZONE ");
  744.                else
  745.                   strcpy (b1, "REGION ");
  746.                dphone = 1;
  747.                if (myzone > 0)
  748.                   {
  749.                   if (n_num != myzone)
  750.                      {
  751.                      skip = 1;
  752.                      }
  753.                   else
  754.                      {
  755.                      skip = 0;
  756.                      }
  757.                   }
  758.                }
  759.             ntyp = 'Z';
  760.             }
  761.          else
  762.          if (stricmp (b1, "region") == 0)
  763.             {
  764.             ++nregions;
  765.             spec_word (b1);
  766.             dphone = 2;
  767.             if (skip == 1)
  768.                skip = 2;
  769.             }
  770.          else
  771.          if (stricmp (b1, "host") == 0)
  772.             {
  773.             ++nnets;
  774.             spec_word (b1);
  775.             dphone = 3;
  776.             if (skip == 1)
  777.                skip = 2;
  778.             ntyp = 'I';
  779.             }
  780.          else
  781.          if (stricmp (b1, "hub") == 0)
  782.             {
  783.             ++nhubs;
  784.             if (out_type)
  785.                spec_word (b1);
  786.             else
  787.                b1[0] = '\0';
  788.             dphone = 4;
  789.             if (skip == 1)
  790.                skip = 2;
  791.             ntyp = 'H';
  792.             }
  793.          else
  794.          if (stricmp (b1, "pvt") == 0)
  795.             {
  796.             /* It is just a private node */
  797.             b1[0] = '\0';
  798.             pvt = 1;
  799.             }
  800.          else
  801.          if (stricmp (b1, "hold") == 0)
  802.             {
  803.             /* It is on hold */
  804.             b1[0] = '\0';
  805.             hold = 1;
  806.             }
  807.          else
  808.             {
  809.             ++ndown;
  810.             /* It is something we don't understand, or the node is down */
  811.             continue;
  812.             }
  813.          }
  814.  
  815.       if (dphone)
  816.          {
  817.          addrs[dphone - 1] = n_num;
  818.          for (i = dphone; i < 4; i++)
  819.             {
  820.             addrs[i] = n_num;
  821.             }
  822.          cur_addr_lev = dphone;
  823.          if (dphone < 4)
  824.             {
  825.             printf ("\rZone %2d, Region %2d, Net %5d", addrs[0], addrs[1], addrs[2]);
  826.             node = 0;
  827.             }
  828.          else
  829.             {
  830.             node = n_num;
  831.             }
  832.          }
  833.       else
  834.          {
  835.          node = n_num;
  836.          }
  837.  
  838.       /* Translate the node type if necessary */
  839.       if (b1[0] == '\0')
  840.          {
  841.          et = et_head;
  842.          while (et != NULL)
  843.             {
  844.             if (((addrs[0] == et->zone) || (et->zone == -1)) &&
  845.                (addrs[2] == et->net) && (node == et->node))
  846.                {
  847.                switch (et->etype)
  848.                   {
  849.                   case 'I':
  850.                      strcpy (b1, "IGATE ");
  851.                      break;
  852.                   case 'O':
  853.                      strcpy (b1, "OGATE ");
  854.                      break;
  855.                   case 'G':
  856.                      strcpy (b1, "GATE ");
  857.                      break;
  858.                   case 'H':
  859.                      strcpy (b1, "HUB ");
  860.                      break;
  861.                   }
  862.                ntyp = et->etype;
  863.                break;
  864.                }
  865.             et = et->next;
  866.             }
  867.          }
  868.  
  869.       /* Board name */
  870.       p = nextfield (p, b2);
  871.  
  872.       /* Location */
  873.       p = nextfield (p, b3);
  874.  
  875.       /* Sysop name */
  876.       p = nextfield (p, b4);
  877.  
  878.       /* Phone number */
  879.       p = nextfield (p, b5);
  880.       strcpy (orig_phone, b5);
  881.  
  882.       /* Determine the cost for this node */
  883.       co = co_head;
  884.       while (co != NULL)
  885.          {
  886.          if (strnicmp (b5, co->mstr, co->mlen) == 0)
  887.             {
  888.             n_cost = co->cost;
  889.             did_cost = 1;
  890.             break;
  891.             }
  892.          co = co->next;
  893.          }
  894.  
  895.       /* If we didn't get a match, then it gets intl cost */
  896.       if ((!did_cost) && (co == NULL) &&
  897.          (strnicmp (country, b5, strlen (country)) == 0))
  898.          {
  899.          did_cost = 1;
  900.          }
  901.  
  902.       /* Translate the phone number if possible via phone translations */
  903.       did_phone = 0;
  904.       ph = ph_head;
  905.       while (ph != NULL)
  906.          {
  907.          if (((addrs[0] == ph->zone) || (ph->zone == -1)) &&
  908.             (addrs[2] == ph->net) && (node == ph->node))
  909.             {
  910.             did_phone = 1;
  911.             strcpy (b5, ph->num);
  912.             break;
  913.             }
  914.          ph = ph->next;
  915.          }
  916.  
  917.       if (dphone)
  918.          {
  919.          if (isdigit (b5[0]) || (ph != NULL))
  920.             {
  921.             strcpy (def_phone, b5);
  922.             }
  923.          else
  924.             {
  925.             /* Bad news - an unlisted where we need a phone number */
  926.             ++ndown;
  927.             continue;
  928.             }
  929.          }
  930.  
  931.       /* If this guy is unpublished, put something in there */
  932.       if (((!isdigit (b5[0])) || (hold)) && (ph == NULL))
  933.          {
  934.          if (cur_addr_lev >= 3)
  935.             {
  936.             strcpy (b5, def_phone);
  937.             def = 1;
  938.             ++nredirect;
  939.             }
  940.          else
  941.             {
  942.             /* No dice - he is unpublished in a region or zone */
  943.             ++ndown;
  944.             continue;
  945.             }
  946.          }
  947.  
  948.       /* Determine the cost for this node */
  949.       if (!did_cost)
  950.          {
  951.          co = co_head;
  952.          while (co != NULL)
  953.             {
  954.             if (strnicmp (b5, co->mstr, co->mlen) == 0)
  955.                {
  956.                n_cost = co->cost;
  957.                did_cost = 1;
  958.                break;
  959.                }
  960.             co = co->next;
  961.             }
  962.          }
  963.  
  964.       /* Determine some things from the phone number */
  965.       p1 = b5;
  966.       p2 = pn1;
  967.       while ((*p1) && isdigit (*p1))
  968.          {
  969.          *p2++ = *p1++;
  970.          }
  971.       *p2 = '\0';
  972.  
  973.       if (*p1 != '\0')
  974.          ++p1;
  975.  
  976.       p2 = pn2;
  977.       while ((*p1) && isdigit (*p1))
  978.          {
  979.          *p2++ = *p1++;
  980.          }
  981.       *p2 = '\0';
  982.  
  983.       if (*p1 != '\0')
  984.          ++p1;
  985.  
  986.       p2 = pn3;
  987.       while ((*p1) && isdigit (*p1))
  988.          {
  989.          *p2++ = *p1++;
  990.          }
  991.       *p2 = '\0';
  992.  
  993.       if (*p1 != '\0')
  994.          ++p1;
  995.  
  996.       if (pn1[0] == '\0')
  997.          {
  998.          pn1[0] = '1';
  999.          pn1[1] = '\0';
  1000.          }
  1001.  
  1002.       if (pn2[0] == '\0')
  1003.          {
  1004.          pn2[0] = '1';
  1005.          pn2[1] = '\0';
  1006.          }
  1007.  
  1008.       if (pn3[0] == '\0')
  1009.          {
  1010.          pn3[0] = '1';
  1011.          pn3[1] = '\0';
  1012.          }
  1013.  
  1014.       /* Translate the number if possible via dial translations */
  1015.       dl = dl_head;
  1016.       while (dl != NULL)
  1017.          {
  1018.          if (strnicmp (b5, dl->mstr, dl->mlen) == 0)
  1019.             {
  1020.             strcpy (b7, &b5[dl->mlen]);
  1021.             sprintf (b5, "%s%s%s", dl->pre, b7, dl->post);
  1022.             break;
  1023.             }
  1024.          dl = dl->next;
  1025.          }
  1026.  
  1027.       if ((dl == NULL) && (!did_phone) && (strnicmp (country, b5, strlen (country)) != 0))
  1028.          {
  1029.          sprintf (b7, "%s%s%s", intl_pre_dl, b5, intl_post_dl);
  1030.          strcpy (b5, b7);
  1031.          }
  1032.  
  1033.       /* Determine the cost for this node */
  1034.       if (!did_cost)
  1035.          {
  1036.          co = co_head;
  1037.          while (co != NULL)
  1038.             {
  1039.             if (strnicmp (b5, co->mstr, co->mlen) == 0)
  1040.                {
  1041.                n_cost = co->cost;
  1042.                did_cost = 1;
  1043.                break;
  1044.                }
  1045.             co = co->next;
  1046.             }
  1047.          }
  1048.  
  1049.       /* If we didn't get a match, then it gets intl cost */
  1050.       if (!did_cost)
  1051.          {
  1052.          n_cost = intl_cost;
  1053.          }
  1054.  
  1055.       /* Baud rate */
  1056.       p = nextfield (p, b6);
  1057.       n_baud = atoi (b6);
  1058.  
  1059.       /* If necessary, translate the baud rate */
  1060.       bd = bd_head;
  1061.       while (bd != NULL)
  1062.          {
  1063.          if (((addrs[0] == bd->zone) || (bd->zone == -1)) &&
  1064.             (addrs[2] == bd->net) && (node == bd->node))
  1065.             {
  1066.             n_baud = bd->baud;
  1067.             break;
  1068.             }
  1069.          bd = bd->next;
  1070.          }
  1071.  
  1072.       /* Fix the baud rate downward if necessary */
  1073.       if (n_baud > maxbaud)
  1074.          {
  1075.          n_baud = maxbaud;
  1076.          }
  1077.  
  1078.       /* Get rid of the newline at the end */
  1079.       p1 = p;
  1080.       while ((*p1) && (!isspace (*p1)))
  1081.          {
  1082.          ++p1;
  1083.          }
  1084.       *p1 = '\0';
  1085.  
  1086.       if (dphone)
  1087.          {
  1088.          strcpy (def_flags, p);
  1089.          def_baud = n_baud;
  1090.          def_cost = n_cost;
  1091.          }
  1092.  
  1093.       if (def)
  1094.          {
  1095.          strcpy (p, def_flags);
  1096.          n_baud = def_baud;
  1097.          n_cost = def_cost;
  1098.          }
  1099.  
  1100.       /* Put the results into the proper files */
  1101.       if (skip < 2)
  1102.          {
  1103.          /* Print out the results in NODELIST.BBS format */
  1104.          if (nodelist_bbs != NULL)
  1105.             {
  1106.             if (nodash)
  1107.                {
  1108.                undash (b5);
  1109.                }
  1110.  
  1111.             fprintf (nodelist_bbs, "%s%d %d %d %s %s %s\n", b1, n_num, n_cost, n_baud, b2, b5, b3);
  1112.             }
  1113.  
  1114.          /* Output to NODELIST.FON */
  1115.          if (nodelist_fon != NULL)
  1116.             {
  1117.             /* Convert to upper case */
  1118.             strupr (p);
  1119.  
  1120.             /* Print it out in NODELIST.FON format */
  1121.             fprintf (nodelist_fon, "%4d %4d %3s %3s %3s %4d %c %s\n",
  1122.                      addrs[2], node, pn1, pn2, pn3, n_baud, ntyp,
  1123.                      (*p == '\0') ? "-" : p);
  1124.             }
  1125.  
  1126.          if (nodelist_dat != -1)
  1127.             {
  1128.             memset (&new_node, 0, sizeof (struct _node));
  1129.             new_node.number = node;
  1130.             new_node.net = addrs[2];
  1131.             new_node.cost = n_cost;
  1132.             new_node.rate = n_baud / 300;
  1133.             new_node.realcost = n_cost;
  1134.             strncpy (new_node.name, b2, 33);
  1135.             p1 = new_node.name;
  1136.             while ((p1 = strchr (p1, '_')) != NULL)
  1137.                {
  1138.                *p1 = ' ';
  1139.                }
  1140.  
  1141.             strncpy (new_node.phone, b5, 39);
  1142.             strncpy (new_node.city, b3, 29);
  1143.             p1 = new_node.city;
  1144.             while ((p1 = strchr (p1, '_')) != NULL)
  1145.                {
  1146.                *p1 = ' ';
  1147.                }
  1148.  
  1149.             /* Stick in a password if there is one */
  1150.             pw = pw_head;
  1151.             while (pw != NULL)
  1152.                {
  1153.                if (((addrs[0] == pw->zone) || (pw->zone == -1)) &&
  1154.                   (addrs[2] == pw->net) && (node == pw->node))
  1155.                   {
  1156.                   strncpy (new_node.password, &(pw->pw[1]), 8);
  1157.                   break;
  1158.                   }
  1159.                pw = pw->next;
  1160.                }
  1161.  
  1162.             if (cur_addr_lev == 4)
  1163.                {
  1164.                new_node.hubnode = addrs[3];
  1165.                }
  1166.             else
  1167.                {
  1168.                new_node.hubnode = 0;
  1169.                }
  1170.  
  1171.             new_node.modem = 0;
  1172.             if (strstr (p, "HST"))
  1173.                {
  1174.                new_node.modem |= M_HST;
  1175.                }
  1176.             if (strstr (p, "PEP"))
  1177.                {
  1178.                new_node.modem |= M_PEP;
  1179.                }
  1180.  
  1181.             new_node.flags1 = 0;
  1182.  
  1183.             switch (dphone)
  1184.                {
  1185.                case 0:
  1186.                   break;
  1187.  
  1188.                case 1:
  1189.                   new_node.flags1 |= B_zone;
  1190.                   break;
  1191.  
  1192.                case 2:
  1193.                   new_node.flags1 |= B_region;
  1194.                   break;
  1195.  
  1196.                case 3:
  1197.                   new_node.flags1 |= B_host;
  1198.                   break;
  1199.  
  1200.                case 4:
  1201.                   new_node.flags1 |= B_hub;
  1202.                   break;
  1203.                }
  1204.  
  1205.             if (strstr (p, "CM"))
  1206.                {
  1207.                new_node.flags1 |= B_CM;
  1208.                }
  1209.  
  1210.             /* Stick in a CM flag is there is one done manually */
  1211.             cm = cm_head;
  1212.             while (cm != NULL)
  1213.                {
  1214.                if (((addrs[0] == cm->zone) || (cm->zone == -1)) &&
  1215.                   (addrs[2] == cm->net) && (node == cm->node))
  1216.                   {
  1217.                   new_node.flags1 |= B_CM;
  1218.                   break;
  1219.                   }
  1220.                cm = cm->next;
  1221.                }
  1222.  
  1223.             write (nodelist_dat, (char *) &new_node, sizeof (struct _node));
  1224.             }
  1225.  
  1226.          if (qnl_dat_bbs != -1)
  1227.             {
  1228.             memset (&qbbsnode, 0, sizeof (struct qdat));
  1229.             qbbsidx.zone = addrs[0];
  1230.             qbbsidx.net = addrs[2];
  1231.             qbbsidx.node = node;
  1232.             qbbsidx.nodetype = qbbsnode.nodetype = dphone;
  1233.             if ((dphone == 1) && (b1[0] == 'R'))
  1234.                {
  1235.                qbbsidx.nodetype = qbbsnode.nodetype = 2;
  1236.                }
  1237.  
  1238.             write (qnl_idx_bbs, (char *) &qbbsidx, sizeof (struct qidx));
  1239.  
  1240.             qbbsnode.zone = addrs[0];
  1241.             qbbsnode.net = addrs[2];
  1242.             qbbsnode.node = node;
  1243.  
  1244.             strncpy (qbbsnode.name, b2, 20);
  1245.             p1 = qbbsnode.name;
  1246.             while ((p1 = strchr (p1, '_')) != NULL)
  1247.                {
  1248.                *p1 = ' ';
  1249.                }
  1250.             qbbsnode.namesize = strlen (b2);
  1251.             if (qbbsnode.namesize > 20)
  1252.                qbbsnode.namesize = 20;
  1253.  
  1254.             strncpy (qbbsnode.city, b3, 40);
  1255.             p1 = qbbsnode.city;
  1256.             while ((p1 = strchr (p1, '_')) != NULL)
  1257.                {
  1258.                *p1 = ' ';
  1259.                }
  1260.             qbbsnode.citysize = strlen (b3);
  1261.             if (qbbsnode.citysize > 40)
  1262.                qbbsnode.citysize = 40;
  1263.  
  1264.             strncpy (qbbsnode.phone, b5, 40);
  1265.             qbbsnode.phonesize = strlen (b5);
  1266.             if (qbbsnode.phonesize > 40)
  1267.                qbbsnode.phonesize = 40;
  1268.  
  1269.             /* Stick in a password if there is one */
  1270.             pw = pw_head;
  1271.             while (pw != NULL)
  1272.                {
  1273.                if (((addrs[0] == pw->zone) || (pw->zone == -1)) &&
  1274.                   (addrs[2] == pw->net) && (node == pw->node))
  1275.                   {
  1276.                   strncpy (qbbsnode.password, &(pw->pw[1]), 8);
  1277.                   qbbsnode.passwordsize = strlen (&(pw->pw[1]));
  1278.                   if (qbbsnode.passwordsize > 8)
  1279.                      qbbsnode.passwordsize = 8;
  1280.                   break;
  1281.                   }
  1282.                pw = pw->next;
  1283.                }
  1284.  
  1285.             qbbsnode.flags = 0;
  1286.  
  1287.             switch (dphone)
  1288.                {
  1289.                case 0:
  1290.                   break;
  1291.  
  1292.                case 1:
  1293.                   qbbsnode.flags |= B_zone;
  1294.                   break;
  1295.  
  1296.                case 2:
  1297.                   qbbsnode.flags |= B_region;
  1298.                   break;
  1299.  
  1300.                case 3:
  1301.                   qbbsnode.flags |= B_host;
  1302.                   break;
  1303.  
  1304.                case 4:
  1305.                   qbbsnode.flags |= B_hub;
  1306.                   break;
  1307.                }
  1308.  
  1309.             if (strstr (p, "CM"))
  1310.                {
  1311.                qbbsnode.flags |= B_CM;
  1312.                }
  1313.  
  1314.             /* Stick in a CM flag is there is one done manually */
  1315.             cm = cm_head;
  1316.             while (cm != NULL)
  1317.                {
  1318.                if (((addrs[0] == cm->zone) || (cm->zone == -1)) &&
  1319.                   (addrs[2] == cm->net) && (node == cm->node))
  1320.                   {
  1321.                   qbbsnode.flags |= B_CM;
  1322.                   break;
  1323.                   }
  1324.                cm = cm->next;
  1325.                }
  1326.  
  1327.             qbbsnode.baudrate = n_baud;
  1328.             qbbsnode.cost = n_cost;
  1329.  
  1330.             write (qnl_dat_bbs, (char *) &qbbsnode, sizeof (struct qdat));
  1331.             }
  1332.  
  1333.          if (nodelist_ext != -1)
  1334.             {
  1335.             memset (&bt_node, 0, sizeof (struct extrastuff));
  1336.  
  1337.             /* Stick in a password if there is one */
  1338.             pw = pw_head;
  1339.             while (pw != NULL)
  1340.                {
  1341.                if (((addrs[0] == pw->zone) || (pw->zone == -1)) &&
  1342.                   (addrs[2] == pw->net) && (node == pw->node))
  1343.                   {
  1344.                   strncpy (bt_node.password, &(pw->pw[1]), 8);
  1345.                   break;
  1346.                   }
  1347.                pw = pw->next;
  1348.                }
  1349.  
  1350.             bt_node.flags1 = 0;
  1351.  
  1352.             switch (dphone)
  1353.                {
  1354.                case 0:
  1355.                   break;
  1356.  
  1357.                case 1:
  1358.                   bt_node.flags1 |= B_zone;
  1359.                   break;
  1360.  
  1361.                case 2:
  1362.                   bt_node.flags1 |= B_region;
  1363.                   break;
  1364.  
  1365.                case 3:
  1366.                   bt_node.flags1 |= B_host;
  1367.                   break;
  1368.  
  1369.                case 4:
  1370.                   bt_node.flags1 |= B_hub;
  1371.                   break;
  1372.                }
  1373.  
  1374.             if (strstr (p, "CM"))
  1375.                {
  1376.                bt_node.flags1 |= B_CM;
  1377.                }
  1378.  
  1379.             /* Stick in a CM flag is there is one done manually */
  1380.             cm = cm_head;
  1381.             while (cm != NULL)
  1382.                {
  1383.                if (((addrs[0] == cm->zone) || (cm->zone == -1)) &&
  1384.                   (addrs[2] == cm->net) && (node == cm->node))
  1385.                   {
  1386.                   bt_node.flags1 |= B_CM;
  1387.                   break;
  1388.                   }
  1389.                cm = cm->next;
  1390.                }
  1391.  
  1392.             write (nodelist_ext, (char *) &bt_node, sizeof (struct extrastuff));
  1393.             }
  1394.  
  1395.          if (nodelist_dog != -1)
  1396.             {
  1397.             if (node <= 0)
  1398.                {
  1399.                if (seanet.numnodes)
  1400.                   {
  1401.                   write (netlist_dog, (char *) &seanet, sizeof (struct netls));
  1402.                   seanetcnt += sizeof (struct netls);
  1403.                   }
  1404.  
  1405.                memset (&seanet, 0, sizeof (struct netls));
  1406.                seanet.netnum = addrs[2];
  1407.                strncpy (seanet.netname, b2, 13);
  1408.                p1 = seanet.netname;
  1409.                while ((p1 = strchr (p1, '_')) != NULL)
  1410.                   {
  1411.                   *p1 = ' ';
  1412.                   }
  1413.  
  1414.                strncpy (seanet.netcity, b3, 39);
  1415.                p1 = seanet.netcity;
  1416.                while ((p1 = strchr (p1, '_')) != NULL)
  1417.                   {
  1418.                   *p1 = ' ';
  1419.                   }
  1420.  
  1421.                seanet.nodeptr = seanodecnt;
  1422.                }
  1423.  
  1424.             if (seacnt < 4000)
  1425.                {
  1426.                if (seaptr != NULL)
  1427.                   {
  1428.                   seaptr->idxnet = addrs[2];
  1429.                   seaptr->idxnode = node;
  1430.                   seaptr->netlptr = seanetcnt;
  1431.                   seaptr->nodelptr = seanodecnt;
  1432.                   ++seaptr;
  1433.                   }
  1434.                }
  1435.             else
  1436.                {
  1437.                seacnt = 3999;
  1438.                }
  1439.  
  1440.             memset (&seanode, 0, sizeof (struct nodels));
  1441.             seanode.nodenum = node;
  1442.             strncpy (seanode.nodename, b2, 13);
  1443.             p1 = seanode.nodename;
  1444.             while ((p1 = strchr (p1, '_')) != NULL)
  1445.                {
  1446.                *p1 = ' ';
  1447.                }
  1448.  
  1449.             strncpy (seanode.nodecity, b3, 39);
  1450.             p1 = seanode.nodecity;
  1451.             while ((p1 = strchr (p1, '_')) != NULL)
  1452.                {
  1453.                *p1 = ' ';
  1454.                }
  1455.  
  1456.             strncpy (seanode.nodephone, b5, 39);
  1457.             if (cur_addr_lev == 4)
  1458.                {
  1459.                seanode.havehub = 1;
  1460.                seanode.nodehub = addrs[3];
  1461.                }
  1462.             seanode.nodecost = n_cost;
  1463.             seanode.nodebaud = n_baud;
  1464.             write (nodelist_dog, (char *) &seanode, sizeof (struct nodels));
  1465.             ++seanet.numnodes;
  1466.             seanodecnt += sizeof (struct nodels);
  1467.             ++seacnt;
  1468.             }
  1469.  
  1470.          if (nodelist_sys != -1)
  1471.             {
  1472.             memset (&old_node, 0, sizeof (struct _oldnode));
  1473.             old_node.number = node;
  1474.             old_node.net = addrs[2];
  1475.             old_node.cost = n_cost;
  1476.             old_node.rate = n_baud;
  1477.             strncpy (old_node.name, b2, 19);
  1478.             p1 = old_node.name;
  1479.             while ((p1 = strchr (p1, '_')) != NULL)
  1480.                {
  1481.                *p1 = ' ';
  1482.                }
  1483.  
  1484.             strncpy (old_node.phone, b5, 39);
  1485.             strncpy (old_node.city, b3, 39);
  1486.             p1 = old_node.city;
  1487.             while ((p1 = strchr (p1, '_')) != NULL)
  1488.                {
  1489.                *p1 = ' ';
  1490.                }
  1491.  
  1492.             /* Stick in a password if there is one */
  1493.             pw = pw_head;
  1494.             while (pw != NULL)
  1495.                {
  1496.                if (((addrs[0] == pw->zone) || (pw->zone == -1)) &&
  1497.                   (addrs[2] == pw->net) && (node == pw->node))
  1498.                   {
  1499.                   strncpy (&(old_node.city[strlen (old_node.city) + 1]), pw->pw, 8);
  1500.                   break;
  1501.                   }
  1502.                pw = pw->next;
  1503.                }
  1504.  
  1505.             write (nodelist_sys, (char *) &old_node, sizeof (struct _oldnode));
  1506.             }
  1507.  
  1508.          if (nodelist_idx != -1)
  1509.             {
  1510.             if ((node == 0) && (dphone <= 2))
  1511.                {
  1512.                if ((ntyp != 'Z') || (!usezone))
  1513.                   n_out = -1;
  1514.                else
  1515.                   n_out = -2;
  1516.                }
  1517.             else
  1518.                {
  1519.                n_out = node;
  1520.                }
  1521.  
  1522.             write (nodelist_idx, (char *) &n_out, sizeof (int));
  1523.             write (nodelist_idx, (char *) &addrs[2], sizeof (int));
  1524.             }
  1525.  
  1526.          if (dphone == 3)
  1527.             {
  1528.             seanet.havehost = 1;
  1529.             seanet.nethost = 0;
  1530.             }
  1531.  
  1532.          if ((ntyp == 'G') || (ntyp == 'I'))
  1533.             {
  1534.             seanet.havegate = 1;
  1535.             seanet.netgate = node;
  1536.             }
  1537.          }
  1538.  
  1539.       /* Print out the Nodelist.Prn file */
  1540.       if ((!this_list) && (nodelist_prn != NULL) && !def)
  1541.          {
  1542.          ++prn_pg_lines;
  1543.  
  1544.          if (dphone && (dphone <= 3) && (prn_pg_lines >= 40))
  1545.             {
  1546.             header (1);
  1547.             prn_pg_lines = 4;
  1548.             }
  1549.  
  1550.          if (prn_pg_lines >= 60)
  1551.             {
  1552.             header (1);
  1553.             prn_pg_lines = 4;
  1554.             }
  1555.  
  1556.          fprintf (nodelist_prn,
  1557.                   "%-10.10s %4d %-20.20s %-20.20s %-25.25s %-20.20s %4d %-20.20s\n",
  1558.                   b1, n_num, b2, orig_phone, b3, b4, n_baud, p);
  1559.          }
  1560.  
  1561.       /* Print out the Nodelist.Txt file */
  1562.       if ((!this_list) && (nodelist_txt != NULL) && !def)
  1563.          {
  1564.          ++txt_pg_lines;
  1565.  
  1566.          if (dphone && (dphone <= 3) && (txt_pg_lines >= 40))
  1567.             {
  1568.             header (0);
  1569.             txt_pg_lines = 4;
  1570.             }
  1571.  
  1572.          if (txt_pg_lines >= 60)
  1573.             {
  1574.             header (0);
  1575.             txt_pg_lines = 4;
  1576.             }
  1577.  
  1578.          fprintf (nodelist_txt,
  1579.                   "%-10.10s %4d %-20.20s %-17.17s %-19.19s %4d\n",
  1580.                   b1, n_num, b2, orig_phone, b3, n_baud);
  1581.          }
  1582.  
  1583.       /* Print out the Fidouser.$$1 file */
  1584.       if (fidouser_$$1 != NULL)
  1585.          {
  1586.          /* Should we just be on our way? */
  1587.          if ((myzone > 0) && (myzone != addrs[0]) && (udata == 2))
  1588.             {
  1589.             continue;
  1590.             }
  1591.  
  1592.          how_likely (p, dphone, addrs, node, n_baud);
  1593.  
  1594.          /* If this is a bad place, make it horrible */
  1595.          if (hold || pvt || def)
  1596.             likely = 100;
  1597.  
  1598.          p = b4;
  1599.          b1[1] = b2[1] = b3[1] = b5[1] = '\0';
  1600.          p1 = b1;
  1601.          while ((*p) && (*p != '_'))
  1602.             {
  1603.             *p1++ = *p++;
  1604.             }
  1605.          *p1 = '\0';
  1606.  
  1607.          if (*p != '\0')
  1608.             ++p;
  1609.  
  1610.          p1 = b2;
  1611.          while ((*p) && (*p != '_'))
  1612.             {
  1613.             *p1++ = *p++;
  1614.             }
  1615.          *p1 = '\0';
  1616.  
  1617.          if (*p != '\0')
  1618.             ++p;
  1619.  
  1620.          p1 = b3;
  1621.          while ((*p) && (*p != '_'))
  1622.             {
  1623.             *p1++ = *p++;
  1624.             }
  1625.          *p1 = '\0';
  1626.  
  1627.          p1 = b5;
  1628.          while ((*p) && (*p != '_'))
  1629.             {
  1630.             *p1++ = *p++;
  1631.             }
  1632.          *p1 = '\0';
  1633.  
  1634.          if (*p == '_')
  1635.             continue;
  1636.  
  1637.          b5[0] = toupper (b5[0]);
  1638.          b3[0] = toupper (b3[0]);
  1639.          b2[0] = toupper (b2[0]);
  1640.          b1[0] = toupper (b1[0]);
  1641.          strlwr (&b5[1]);
  1642.          strlwr (&b3[1]);
  1643.          strlwr (&b2[1]);
  1644.          strlwr (&b1[1]);
  1645.          if (b5[0] != '\0')
  1646.             {
  1647.             sprintf (buff, "%s, %s %s %s", b5, b1, b2, b3);
  1648.             }
  1649.          else
  1650.          if (b3[0] != '\0')
  1651.             {
  1652.             sprintf (buff, "%s, %s %s", b3, b1, b2);
  1653.             }
  1654.          else
  1655.          if (b2[0] != '\0')
  1656.             {
  1657.             sprintf (buff, "%s, %s", b2, b1);
  1658.             }
  1659.          else
  1660.          if (b1[0] != '\0')
  1661.             {
  1662.             sprintf (buff, "%s", b1);
  1663.             }
  1664.          else
  1665.             {
  1666.             continue;
  1667.             }
  1668.          if ((myzone > 0) && (myzone != addrs[0]))
  1669.             {
  1670.             sprintf (b5, "%d:%d", addrs[0], addrs[2]);
  1671.             }
  1672.          else
  1673.             {
  1674.             sprintf (b5, "%d", addrs[2]);
  1675.             }
  1676.  
  1677.          fprintf (fidouser_$$1, "%-40.40s%13.13s/%-6d%5d\n", buff, b5, node, likely);
  1678.          }
  1679.       }
  1680.  
  1681. /*     close (f); */
  1682.    fclose (f);
  1683.    if (fn != NULL)
  1684.       fn = fn->next;
  1685. }
  1686.  
  1687. void
  1688. header (which)
  1689. int which;
  1690. {
  1691.    if (which == 1)
  1692.       {
  1693.       if (prn_pagenum != 0)
  1694.          {
  1695.          fprintf (nodelist_prn, " \n");
  1696.          }
  1697.       ++prn_pagenum;
  1698.       fprintf (nodelist_prn, "%s %d\n", prn_first_line, prn_pagenum);
  1699.       fprintf (nodelist_prn, "Type       Node Board's Name         Phone Number         City                      Sysop's Name         Baud Flags\n");
  1700.       fprintf (nodelist_prn, "====       ==== ============         ============         ====                      ============         ==== =====\n\n");
  1701.       }
  1702.    else if (which == 0)
  1703.       {
  1704.       if (txt_pagenum != 0)
  1705.          {
  1706.          fprintf (nodelist_txt, " \n");
  1707.          }
  1708.       ++txt_pagenum;
  1709.       fprintf (nodelist_txt, "%s %d\n", txt_first_line, txt_pagenum);
  1710.       fprintf (nodelist_txt, "Type       Node Board's Name         Phone Number      City                Baud\n");
  1711.       fprintf (nodelist_txt, "====       ==== ============         ============      ====                ====\n");
  1712.       }
  1713. }
  1714.  
  1715. /*
  1716. char mybuf[4097];
  1717. char *myptr = mybuf;
  1718. int got_tok;
  1719. get_data (buffer, f)
  1720. char *buffer;
  1721. int f;
  1722. {
  1723.    char *s;
  1724.    char *save;
  1725.    int n;
  1726.  
  1727.    s = NULL;
  1728.    if (got_tok)
  1729.       {
  1730.       s = strtok (NULL, "\n");
  1731.       }
  1732.  
  1733.    got_tok = 0;
  1734.    if (s != NULL)
  1735.       {
  1736.       save = myptr;
  1737.       myptr = s + strlen (s) + 1;
  1738.       if (myptr < mybuf + 4097)
  1739.          strcpy (buffer, s);
  1740.       else
  1741.          {
  1742.          s = NULL;
  1743.          myptr = save;
  1744.          }
  1745.       }
  1746.  
  1747.    if (s == NULL)
  1748.       {
  1749.       strcpy (buffer, myptr);
  1750.       if ((n = read (f, mybuf, 4096)) <= 0)
  1751.          return (1);
  1752.  
  1753.       mybuf[n] = '\0';
  1754.  
  1755.       myptr = mybuf;
  1756.       s = strtok (myptr, "\n");
  1757.       if (s == NULL)
  1758.          return (1);
  1759.  
  1760.       strcat (buffer, s);
  1761.       myptr = s + strlen (s) + 1;
  1762.       }
  1763.  
  1764.    got_tok = 1;
  1765.    return (0);
  1766. }
  1767. */
  1768.  
  1769.