2 * Copyright 2017 Gary Mills
3 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
4 * Use is subject to license terms.
7 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
8 /* All Rights Reserved */
11 * Copyright (c) 1980 Regents of the University of California.
12 * All rights reserved. The Berkeley software License Agreement
13 * specifies the terms and conditions for redistribution.
23 grepcall(char *in
, char *out
, char *arg
)
25 char line
[200], *s
, argig
[100], *cv
[50];
28 int c
, alph
= 0, nv
= 0;
32 strcpy(inp
= inb
, in
);
34 sprintf(gfile
, "/tmp/rj%dg", getpid());
35 for (cv
[nv
++] = "fgrep"; c
= *inp
; inp
++) {
40 alph
= (c
== 0) ? 0 : alph
+1;
49 if (open(argig
, 0) != 0)
50 err("Can't read fgrep index %s", argig
);
53 if (creat(gfile
, 0666) != 1)
54 err("Can't write fgrep output %s", gfile
);
64 gf
= fopen(gfile
, "r");
66 err("can't read fgrep output %s", gfile
);
67 while (fgets(line
, 100, gf
) == line
) {
69 for (s
= line
; *s
&& (*s
!= '\t'); s
++)
79 while (!feof(gf
) && getc(gf
) != '\n')