home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / duucp-1.17 / AU-117b4-src.lha / src / util / uident.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-24  |  988 b   |  62 lines

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