home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / program / c / plstsrc / parselst.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-07  |  53.1 KB  |  1,667 lines

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