home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / tnos / tnos100s / bug.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-30  |  989 b   |  47 lines

  1. // make executable with the command:
  2. //        bcc -ms bug.c \borlandc\lib\wildargs.obj
  3.  
  4. #include <stdio.h>
  5.  
  6. #define NULLFILE (FILE *) 0
  7. #define NULLCHAR (char *) 0
  8.  
  9. /* a mailbox entry */
  10. struct let {
  11.     long    start;
  12.     long    size;
  13.     long    bid;
  14.     int    status;
  15. };
  16.  
  17. main (argc, argv)
  18. int argc;
  19. char *argv[];
  20. {
  21. register FILE *cfp;
  22. char buf[256];
  23. struct let lt;
  24. int cnt, k;
  25.  
  26.     for (k = 1; k < argc; k++)    {
  27.         sprintf (buf, "CONTROL\\%s", argv[k]);
  28.         if (strstr (buf, ".TXT") || strstr (buf, ".txt"))
  29.             strcpy (&buf[strlen(buf) - 3], "ctl");
  30.         else
  31.             strcat (buf, ".ctl");
  32.         if((cfp = fopen(buf,"rb")) == NULLFILE)    {
  33.             printf ("Can't open control file '%s'\n", buf);
  34.             continue;
  35.         }
  36.         printf ("Reading Control File: '%s'\n", buf);
  37.         cnt = 1;
  38.         while(fread(<,sizeof(struct let),1, cfp) != NULLCHAR){
  39.             printf ("Entry #%-d: start=%-ld, size=%-ld, bid=%-ld, status=%-d\n",
  40.                 cnt, lt.start, lt.size, lt.bid, lt.status);
  41.             cnt++;
  42.         }
  43.         fclose(cfp);
  44.     }
  45. }
  46.  
  47.