home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / PLST_133.SZH / NAMES.C < prev    next >
Text File  |  1991-09-20  |  5KB  |  164 lines

  1. /*
  2.                               Nodelist Parser
  3.  
  4.               This module was originally written by Bob Hartman
  5.                        Sysop of FidoNet node 1:104/501
  6.  
  7.  This program source code is being released with the following provisions:
  8.  
  9.  1.  You are  free to make  changes to this source  code for use on your own
  10.  machine,  however,  altered source files may not be distributed without the
  11.  consent of Spark Software.
  12.  
  13.  2.  You may distribute "patches"  or  "diff" files for any changes that you
  14.  have made, provided that the "patch" or "diff" files are also sent to Spark
  15.  Software for inclusion in future releases of the entire package.   A "diff"
  16.  file for the source archives may also contain a compiled version,  provided
  17.  it is  clearly marked as not  being created  from the original source code.
  18.  No other  executable  versions may be  distributed without  the  consent of
  19.  Spark Software.
  20.  
  21.  3.  You are free to include portions of this source code in any program you
  22.  develop, providing:  a) Credit is given to Spark Software for any code that
  23.  may is used, and  b) The resulting program is free to anyone wanting to use
  24.  it, including commercial and government users.
  25.  
  26.  4.  There is  NO  technical support  available for dealing with this source
  27.  code, or the accompanying executable files.  This source  code  is provided
  28.  as is, with no warranty expressed or implied (I hate legalease).   In other
  29.  words, if you don't know what to do with it,  don't use it,  and if you are
  30.  brave enough to use it, you're on your own.
  31.  
  32. */
  33.  
  34. #include <stdio.h>
  35. #include <ctype.h>
  36. #include <sys/types.h>
  37. #include <sys/stat.h>
  38. #include <time.h>
  39. #include <stdlib.h>
  40. #include <string.h>
  41.  
  42. #include "types.h"
  43. #include "externs.h"
  44.  
  45. void
  46. do_names ()
  47. {
  48.    FILE *o1, *o2;
  49.    char b1[50];
  50.  
  51.    printf ("Sorting SysOp Name Data\n\n");
  52. #ifndef OS2
  53.    (void) system ("qsort Fidouser.$$1 /+1:41 /-61:5 /-41:13 /+55:6");
  54. #else
  55.    (void) system ("QSort Fidouser.$$1 /+1:41 /-61:5 /-41:13 /+55:6");
  56. #endif
  57.    if ((o1 = fopen ("FIDOUSER.$$1", "r")) == NULL)
  58.       {
  59.       }
  60.    if ((o2 = fopen ("FIDOUSER.LST", "w")) == NULL)
  61.       {
  62.       }
  63.    b1[0] = '\0';
  64.    nnodes = 0;
  65.    printf ("\nDeleting Duplicate SysOp Names\n");
  66.    while (fgets (t_str, 127, o1) != NULL)
  67.       {
  68.       if (strncmp (t_str, b1, 40) == 0)
  69.          {
  70.          continue;
  71.          }
  72.       ++nnodes;
  73.       if (nnodes % 100 == 0)
  74.          printf ("\r%d", nnodes);
  75.       t_str[60] = '\n';
  76.       t_str[61] = '\0';
  77.       fputs (t_str, o2);
  78.       strncpy (b1, t_str, 40);
  79.       }
  80.    printf ("\r%d Unique SysOp Names Found in Network\n", nnodes);
  81.    fclose (o1);
  82.    fclose (o2);
  83.    unlink ("FIDOUSER.$$1");
  84. }
  85.  
  86. /* Just some random equation to determine likelihood of current address
  87.    being the correct default address for an individual (a good guess -
  88.    at least I hope so <grin>).  */
  89. void how_likely (char *p,int dphone,int *addrs,int node,int n_baud)
  90. {
  91.    /* It is less likely if it is a coordinator node */
  92.    if (dphone || (node == 0))
  93.       {
  94.       likely = 6000;
  95.       }
  96.    else
  97.       {
  98.       likely = 8000;
  99.       }
  100.  
  101.    /* If its not in my zone, punish it */
  102.    if ((myzone > 0) && (addrs[0] != myzone))
  103.       likely -= 3000;
  104.  
  105.    /* If it is a "normal" net number, add something to it */
  106.    if ((addrs[2] >= 100) && (addrs[2] <= 999))
  107.       likely += 2000 + addrs[2];
  108.    /* If it is a region, that is better than a private net */
  109.    else if (addrs[2] < 100)
  110.       likely += 250;
  111.    /* Otherwise, it is probably bad news */
  112.    else
  113.       likely -= 1000;
  114.  
  115.    /* Prefer the higher baud rate */
  116.    likely += n_baud / 8;
  117.  
  118.    /* CM or XP or WZ is real nice */
  119.    if (strstr (p, "CM"))
  120.       {
  121.       likely += 2500;
  122.       }
  123.    else if (strstr (p, "XP"))
  124.       {
  125.       likely += 2500;
  126.       }
  127.    else if (strstr (p, "WZ"))
  128.       {
  129.       likely += 2500;
  130.       }
  131.  
  132.    /* Favor WZ a bit more */
  133.    if (strstr (p, "WZ"))
  134.       {
  135.       likely += 100;
  136.       }
  137.  
  138.    /* If it is mail only, then it is probably not his primary */
  139.    if (strstr (p, "MO"))
  140.       {
  141.       likely -= 100;
  142.       }
  143.  
  144.    /* Don't be fooled if has restricted hours, probably not primary */
  145.    if (strstr (p, "WK"))
  146.       {
  147.       likely -= 100;
  148.       }
  149.    if (strstr (p, "WE"))
  150.       {
  151.       likely -= 100;
  152.       }
  153.    if (strstr (p, "DA"))
  154.       {
  155.       likely -= 100;
  156.       }
  157.  
  158.    /* If it is a coordinator, punish it depending on what type of coord */
  159.    if (dphone)
  160.       likely -= (5 - dphone) * 75;
  161. }
  162.  
  163.  
  164.