home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 362b.lha / uucp1_v1.05d / src / util / uident.c < prev    next >
C/C++ Source or Header  |  1990-04-08  |  1KB  |  67 lines

  1.  
  2. /*
  3.  *  UIDENT.C
  4.  *
  5.  *  $Header: Beta:src/uucp/src/GUtil/RCS/uident.c,v 1.1 90/02/02 11:58:56 dillon Exp Locker: dillon $
  6.  *
  7.  *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  8.  *
  9.  *  UIDENT files...
  10.  *
  11.  *  Searches for @($) <string> \0 and prints out
  12.  */
  13.  
  14. #include <stdio.h>
  15. #include <fcntl.h>
  16. #include "version.h"
  17.  
  18. IDENT(".02");
  19.  
  20. void FindIdent(char *, int);
  21.  
  22. char Buf[8192];
  23.  
  24. void
  25. main(ac, av)
  26. char **av;
  27. {
  28.     short i;
  29.     int fd;
  30.  
  31.     for (i = 1; i < ac; ++i) {
  32.     fd = open(av[i], O_RDONLY);
  33.     if (fd > 0)
  34.         FindIdent(av[i], fd);
  35.     else
  36.         printf("%-15s (unable to open)", av[i]);
  37.     puts("");
  38.     fflush(stdout);
  39.     if (fd > 0)
  40.         close(fd);
  41.     }
  42. }
  43.  
  44. void
  45. FindIdent(file, fd)
  46. char *file;
  47. int fd;
  48. {
  49.     long n;
  50.     long i;
  51.     long x = 0;
  52.  
  53.     while ((n = read(fd, Buf + x, sizeof(Buf) - x)) > 0) {
  54.     n += x;
  55.     for (i = n - 128; i >= 0; --i) {
  56.         if (Buf[i] == '@' && Buf[i+1] == '(' && Buf[i+2] == '$' && Buf[i+3] == ')') {
  57.         printf("%-15s %s\n", file, Buf + i);
  58.         }
  59.     }
  60.     x = 128;
  61.     if (n < x)
  62.         x = n;
  63.     movmem(Buf + n - x, Buf, x);
  64.     }
  65. }
  66.  
  67.