|
|
1.1 root 1: #ifndef lint
2: static char *sccsid = "@(#)glue3.c 4.2 (Berkeley) 4/24/88";
3: #endif
4:
5: #include "refer..c"
6: #define move(x, y) close(y); dup(x); close(x);
7:
8: corout(in, out, rprog, arg, outlen)
9: char *in, *out, *rprog;
10: {
11: int pipev[2], fr1, fr2, fw1, fw2, n;
12:
13: if (strcmp (rprog, "hunt") ==0)
14: return(callhunt(in, out, arg, outlen));
15: if (strcmp (rprog, "deliv")==0)
16: return(dodeliv(in, out, arg, outlen));
17: pipe (pipev);
18: fr1= pipev[0];
19: fw1 = pipev[1];
20: pipe (pipev);
21: fr2= pipev[0];
22: fw2 = pipev[1];
23: if (fork()==0)
24: {
25: close (fw1);
26: close (fr2);
27: move (fr1, 0);
28: move (fw2, 1);
29: if (rprog[0]!= '/')
30: chdir("/usr/lib/refer");
31: execl(rprog, "deliv", arg, 0);
32: err ("Can't run %s", rprog);
33: }
34: close(fw2);
35: close(fr1);
36: write (fw1, in , strlen(in));
37: close(fw1);
38: wait(0);
39: n = read (fr2, out, outlen);
40: out[n]=0;
41: close(fr2);
42: }
43:
44: # define ALEN 50
45:
46: callhunt(in, out, arg, outlen)
47: char *in, *out, *arg;
48: {
49: char *argv[20], abuff[ALEN];
50: extern int typeindex;
51: int argc;
52: extern char one[];
53: extern int onelen;
54: argv[0] = "hunt";
55: argv[1] = "-i";
56: argv[2] = in;
57: argv[3] = "-t";
58: argv[4] = out;
59: argv[5] = (char *)outlen; /* Horrid kludge, see option parsing
60: in huntmain() in glue1.c. */
61: argv[6] = "-T";
62: argv[7] = "-F1";
63: argv[8] = "-o";
64: argv[9] = one;
65: argv[10] = (char *)onelen; /* Horrid kludge again */
66: argv[11] = abuff;
67: strcpy (abuff,arg);
68: if (strlen(abuff) > ALEN)
69: err("abuff not big enough %d", strlen(abuff));
70: argc = 6;
71: huntmain (argc,argv);
72: return(0);
73: }
74:
75: dodeliv(in, out, arg, outlen)
76: char *in, *out, *arg;
77: {
78: # if D1
79: fprintf(stderr, "in dodeliv, arg /%s/\n", arg?arg:"");
80: # endif
81: if (arg && arg[0])
82: chdir(arg);
83: findline(in, out, outlen, 0L);
84: restodir();
85: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.