home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / AZTEC-C / FIND.C < prev    next >
C/C++ Source or Header  |  2000-06-30  |  3KB  |  133 lines

  1. /*
  2.  * FIND is a progam was writen to help maintain files on my hard disc.
  3.  * This program should run on any CP/M 2.2 or higher revision machine.
  4.  * It was developed using CP/M 3.0 and the AZTEC C compiler vers. 1.06B.
  5.  *
  6.  * To compile:
  7.  *            cc -dTINY find.c
  8.  *            as find.asm
  9.  *            ln find.o t.lib c.lib
  10.  * 
  11.  * As this program was a quick ditch effort, I welcome any and all 
  12.  * modifications that anyone makes to it.  For example, anbiguous(* , ?)
  13.  * filenames are not extracted from the DMA address after the bdos
  14.  * call to "search filename".  The program also does not allow the
  15.  * user to search specific user areas, it assumes a scan of user 0
  16.  * thru user 15.
  17.  *
  18.  * Have fun with it, but this program is not for resale in any form.
  19.  *
  20.  * Please send any ideas/changes/reactions to me in mail.  Do not post.
  21.  *
  22.  * Jeff Gibson                     UUCP: {cepu,ihnp4,noao,uiucdcs}!bradley!jmg
  23.  * Bradley University              ARPA: cepu!bradley!jmg@UCLA-LOCUS
  24.  * Peoria, IL 61625                PH: (309) 692-9069
  25.  *
  26.  */
  27. #include "stdio.h"
  28.  
  29. int  drive_range[17],
  30.      DRIVES;
  31.  
  32. main(argc, argv)
  33. int argc;
  34. char *argv[];
  35. {
  36.   char  fn[36],
  37.         drive_name;
  38.         
  39.   int   i,
  40.         old_user,
  41.         new_user,
  42.         found, 
  43.         drive;
  44.   
  45.  
  46.   if (--argc < 1)
  47.    {
  48.      printf("\nusage:  find -drives abcdefghijklmnop filename\n");
  49.      bios(0);
  50.    }
  51.   
  52.   DRIVES = found = FALSE;
  53.   
  54.   *++argv;
  55.   if  (*argv[0] == '-')
  56.    {
  57.      check(*argv);
  58.      com_line(*++argv);
  59.    }
  60.   else
  61.     {
  62.       *--argv;
  63.       drive_range[0] = 0; 
  64.       drive_range[1] = -1;
  65.     }
  66.   fcbinit(*++argv, &fn);
  67.   old_user = getusr();
  68.   i = 0;
  69.   putchar('\n');
  70.   while (drive_range[i] != -1)
  71.    {
  72.       fn[0] = drive_range[i];
  73.       for (new_user=0; new_user < 16; new_user++)
  74.        {
  75.           if  (bdos(11) == 1)                 /* check for key strike */
  76.              if  (getchar() == 0x03)          /* abort on ^C */
  77.                 bios(0);
  78.           setusr(new_user);
  79.           if  (bdos(17, fn) != 0xff)
  80.            {
  81.              found = TRUE;
  82.              if  (drive_range[i] == 0)
  83.                 drive_name = (char)(drive_range[i] + 65);
  84.              else
  85.                 drive_name = (char)(drive_range[i] + 64);
  86.              printf("%s: USER %d  DRIVE %c\n", *argv, new_user, drive_name);
  87.            }
  88.        }
  89.       i++;
  90.    }
  91.  if  (!found)
  92.     printf("%s: was not found\n", *argv);
  93.  setusr(old_user);
  94.  bios(0);
  95. }
  96.  
  97. check(argv)
  98. char argv[];
  99. {
  100.     if  (tolower(argv[1]) == 'd')
  101.        DRIVES = TRUE;
  102.     else
  103.       {
  104.         printf ("\nERROR in argument\n");
  105.         bios(0);
  106.       }
  107. }
  108.  
  109.             
  110. com_line(line)
  111. char line[];
  112. {
  113.    int i, j;
  114.      
  115.    if  (DRIVES)
  116.     {
  117.       i = 0;
  118.       j = 0;
  119.       while  (tolower(line[i]) >= 'a' && tolower(line[i]) <= 'p')
  120.        {
  121.            drive_range[j] = (int)(tolower(line[i++]) - 0x60);
  122.            j++;
  123.        } 
  124.       drive_range[j] = -1;
  125.     }
  126.    else
  127.      {
  128.         printf("ERROR --- illegal drive specification.\n");
  129.         bios(0);
  130.      }
  131. }
  132.  
  133.