home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / OS2PLST.SRC / NAMES.C < prev    next >
Text File  |  1989-07-16  |  5KB  |  175 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 <sys/types.h>
  42. #include <sys/stat.h>
  43. #include <time.h>
  44. #include <stdlib.h>
  45. #include <string.h>
  46.  
  47. #include "types.h"
  48. #include "externs.h"
  49.  
  50. void
  51. do_names ()
  52. {
  53.    FILE *o1, *o2;
  54.    char b1[50];
  55.  
  56.    printf ("Sorting SysOp Name Data\n\n");
  57. #ifndef OS2
  58.    (void) system ("qsort Fidouser.$$1 /+1:41 /-61:5 /-41:13 /+55:6");
  59. #else
  60.    (void) system ("GSort Fidouser.$$1 /+1 41 +61 5 R +41 13 R +55 6 /G /Q");
  61. #endif
  62.    if ((o1 = fopen ("FIDOUSER.$$1", "r")) == NULL)
  63.       {
  64.       }
  65.    if ((o2 = fopen ("FIDOUSER.LST", "w")) == NULL)
  66.       {
  67.       }
  68.    b1[0] = '\0';
  69.    nnodes = 0;
  70.    printf ("\nDeleting Duplicate SysOp Names\n");
  71.    while (fgets (t_str, 127, o1) != NULL)
  72.       {
  73.       if (strncmp (t_str, b1, 40) == 0)
  74.          {
  75.          continue;
  76.          }
  77.       ++nnodes;
  78.       if (nnodes % 100 == 0)
  79.          printf ("\r%d", nnodes);
  80.       t_str[60] = '\n';
  81.       t_str[61] = '\0';
  82.       fputs (t_str, o2);
  83.       strncpy (b1, t_str, 40);
  84.       }
  85.    printf ("\r%d Unique SysOp Names Found in Network\n", nnodes);
  86.    fclose (o1);
  87.    fclose (o2);
  88.    unlink ("FIDOUSER.$$1");
  89. }
  90.  
  91. /* Just some random equation to determine likelihood of current address
  92.    being the correct default address for an individual (a good guess -
  93.    at least I hope so <grin>).    */
  94. void
  95. how_likely (p, dphone, addrs, node, n_baud)
  96. char *p;
  97. int dphone;
  98. int addrs[];
  99. int node;
  100. int n_baud;
  101. {
  102.    /* It is less likely if it is a coordinator node */
  103.    if (dphone || (node == 0))
  104.       {
  105.       likely = 6000;
  106.       }
  107.    else
  108.       {
  109.       likely = 8000;
  110.       }
  111.  
  112.    /* If its not in my zone, punish it */
  113.    if ((myzone > 0) && (addrs[0] != myzone))
  114.       likely -= 3000;
  115.  
  116.    /* If it is a "normal" net number, add something to it */
  117.    if ((addrs[2] >= 100) && (addrs[2] <= 999))
  118.       likely += 2000 + addrs[2];
  119.    /* If it is a region, that is better than a private net */
  120.    else if (addrs[2] < 100)
  121.       likely += 250;
  122.    /* Otherwise, it is probably bad news */
  123.    else
  124.       likely -= 1000;
  125.  
  126.    /* Prefer the higher baud rate */
  127.    likely += n_baud / 8;
  128.  
  129.    /* CM or XP or WZ is real nice */
  130.    if (strstr (p, "CM"))
  131.       {
  132.       likely += 2500;
  133.       }
  134.    else if (strstr (p, "XP"))
  135.       {
  136.       likely += 2500;
  137.       }
  138.    else if (strstr (p, "WZ"))
  139.       {
  140.       likely += 2500;
  141.       }
  142.  
  143.    /* Favor WZ a bit more */
  144.    if (strstr (p, "WZ"))
  145.       {
  146.       likely += 100;
  147.       }
  148.  
  149.    /* If it is mail only, then it is probably not his primary */
  150.    if (strstr (p, "MO"))
  151.       {
  152.       likely -= 100;
  153.       }
  154.  
  155.    /* Don't be fooled if has restricted hours, probably not primary */
  156.    if (strstr (p, "WK"))
  157.       {
  158.       likely -= 100;
  159.       }
  160.    if (strstr (p, "WE"))
  161.       {
  162.       likely -= 100;
  163.       }
  164.    if (strstr (p, "DA"))
  165.       {
  166.       likely -= 100;
  167.       }
  168.  
  169.    /* If it is a coordinator, punish it depending on what type of coord */
  170.    if (dphone)
  171.       likely -= (5 - dphone) * 75;
  172. }
  173.  
  174.  
  175.