2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
24 grepcall(char *in
, char *out
, char *arg
)
26 char line
[200], *s
, argig
[100], *cv
[50];
29 int c
, oldc
= 0, alph
= 0, nv
= 0;
33 strcpy(inp
= inb
, in
);
35 sprintf(gfile
, "/tmp/rj%dg", getpid());
37 fprintf(stderr
, "in grepcall, gfile %s in %o out %o\n",
40 for (cv
[nv
++] = "fgrep"; c
= *inp
; inp
++) {
45 alph
= (c
== 0) ? 0 : alph
+1;
53 fprintf(stderr
, "%d args set up\n", nv
);
58 if (open(argig
, 0) != 0)
59 err("Can't read fgrep index %s", argig
);
62 if (creat(gfile
, 0666) != 1)
63 err("Can't write fgrep output %s", gfile
);
66 fprintf(stderr
, "fgrep returned, output is..\n");
77 fprintf(stderr
, "back from fgrep\n");
79 gf
= fopen(gfile
, "r");
81 err("can't read fgrep output %s", gfile
);
82 while (fgets(line
, 100, gf
) == line
) {
85 fprintf(stderr
, "read line as //%s//\n", line
);
87 for (s
= line
; *s
&& (*s
!= '\t'); s
++)
96 fprintf(stderr
, "out now /%s/\n", out
);
100 fprintf(stderr
, "line %o s %o s-1 %o\n", line
, s
, s
[-1]);
103 while (!feof(gf
) && getc(gf
) != '\n')
108 fprintf(stderr
, "back from reading %, out %s\n", out
);