home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / comms / comprgs / aplst160.zoo / NLV.zoo / NLV.c < prev   
C/C++ Source or Header  |  1989-08-08  |  3KB  |  133 lines

  1. /* Used to view the Version6 and Paragon nodelists */
  2.  
  3. /* Written by Todd Kover of Insufficient Memory Software */
  4.  
  5. /* FidoNet 1:261/5016.0@FidoNet */
  6.  
  7. #include <stdio.h>
  8.  
  9. struct _node            /* Version6 Nodelist */
  10. {
  11.  int net;
  12.  int node;
  13.  int cost;
  14.  char name[34];
  15.  char phone[40];
  16.  char city[30];
  17.  char password[8];
  18.  int realcost;
  19.  int hubnode;
  20.  char rate;
  21.  char modem;
  22.  unsigned int flags1;
  23.  int reserved;
  24. };
  25.  
  26. #define B_hub        0x0001
  27. #define B_host        0x0002
  28. #define B_region    0x0004
  29. #define B_hold        0x0008
  30. #define B_unlisted    0x0010
  31. #define B_down        0x0020
  32. #define B_CM        0x0040
  33. #define B_NA        0x0080
  34. #define B_Europe    0x0100
  35. #define B_Pacific    0x0200
  36.  
  37. #define M_HST        0x0001
  38. #define M_PEP        0x0002
  39.  
  40. struct _pnode                /* Paragon Nodelist */
  41. {
  42.  int type;
  43.  int zone;
  44.  int net;
  45.  int node;
  46.  int rnet;
  47.  int rnode;
  48.  int baud;
  49.  int cost;
  50.  int route;
  51.  char bbsname[50];
  52.  char bbsloc[30];
  53.  char bbsnumber[20];
  54.  char password[10];
  55.  int flags;
  56.  char res1;
  57.  char res2;
  58.  char res3;
  59.  char res4;
  60. };
  61.  
  62. extern void *malloc();
  63.  
  64. main(argc,argv)
  65. int argc;
  66. char *argv[];
  67. {
  68.  struct _node *node;
  69.  struct _pnode *pnode;
  70.  FILE *nlfile;
  71.  char listtype;
  72.  
  73.  if(((argc!=2)&&(argc!=3)))
  74.   { puts("\nNodeList Viewer by Todd Kover of 1:261/5016.0");
  75.     puts("Usage: NLV <nodelist.dat filename> [p|b]\n");
  76.     puts("         (b = Version6 nodelist; p = Paragon nodelist)\n");
  77.     exit(1); }
  78.  
  79.  listtype='b';
  80.  if(argc==3)
  81.   { if(tolower(argv[2][0])=='p')
  82.      listtype='p'; printf("%c",argv[2][0]); } 
  83.  
  84.  if(listtype=='b')
  85.   {      
  86.    if(!(node=malloc(sizeof(struct _node))))
  87.     { puts("Malloc() error!"); exit(2); }
  88.   
  89.    if(!(nlfile=fopen(argv[1],"r")))
  90.     { printf("Problem opening \"%s\"",argv[1]); free(node); exit(3); }
  91.  
  92.    while(!(feof(nlfile))||!(ferror(nlfile)))
  93.     {
  94.      setmem(node,sizeof(struct _node),0);
  95.      fread(node,sizeof(struct _node),1,nlfile);
  96.      printf("-------------------------------------------------\n");
  97.      printf("%d/%d $%d @%d\n",node->net,node->node,node->cost,node->rate);
  98.      printf("BBS: %s\nPhone: %s\n",node->name,node->phone);
  99.      printf("City: %s\nPassword: %s\n",node->city,node->password);
  100.      printf("\nRealCost: %d Hub: %d/%d ",node->realcost,node->net,node->hubnode);
  101.      
  102.      printf("flags1: %d; modem: %d\n",node->flags1,node->modem);
  103.     }
  104.    fclose(nlfile);
  105.    free(node);
  106.   }
  107.  if(listtype=='p')
  108.   {
  109.    if(!(pnode=malloc(sizeof(struct _pnode))))
  110.     { puts("Malloc() error!"); exit(2); }
  111.     
  112.    if(!(nlfile=fopen(argv[1],"r")))
  113.     { printf("Problem opening \"%s\"",argv[1]); free(pnode); exit(3); }
  114.     
  115.    while(!(feof(nlfile))||!(ferror(nlfile)))
  116.     {
  117.      fread(pnode,sizeof(struct _pnode),1,nlfile);
  118.      printf("-------------------------------------------------\n");
  119.      printf("Type: %d @%d:%d/%d\n",pnode->type,pnode->zone,
  120.              pnode->net,pnode->node);
  121.      printf("RN: %d/%d $%d @%d\n",pnode->rnet,pnode->rnode,pnode->cost,
  122.              pnode->baud);
  123.      printf("Route: %d\n",pnode->route);
  124.      printf("BBSName: %s\nBBSLoc:  %s\n",pnode->bbsname,pnode->bbsloc);
  125.      printf("BBSNum:  %s\nPassW:   %s\n",pnode->bbsnumber,pnode->password);
  126.      printf("Flags %d\nRes1: %c Res2: %c Res3: %c Res4: %c\n",pnode->flags,
  127.              pnode->res1,pnode->res2,pnode->res3,pnode->res4);
  128.     }
  129.    fclose(nlfile);
  130.    free(pnode);
  131.   }
  132. }
  133.