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"
20 #define move(x, y) close(y); dup(x); close(x);
23 extern long findline();
24 extern void huntmain();
25 extern void restodir();
27 static int callhunt(char *, char *, char *, int);
28 static int dodeliv(char *, char *, char *, int);
31 corout(char *in
, char *out
, char *rprog
, char *arg
, int outlen
)
33 int pipev
[2], fr1
, fr2
, fw1
, fw2
, n
;
36 fprintf(stderr
, "in corout, rprog /%s/ in /%s/\n",
37 rprog
? rprog
: "", strlen(in
) ? in
: "");
40 if (strcmp(rprog
, "hunt") == 0)
41 return (callhunt(in
, out
, arg
, outlen
));
42 if (strcmp(rprog
, "deliv") == 0)
43 return (dodeliv(in
, out
, arg
, outlen
));
56 chdir("/usr/lib/refer");
57 execl(rprog
, "deliv", arg
, 0);
58 err(gettext("Can't run %s"), rprog
);
63 write(fw1
, in
, strlen(in
));
66 n
= read(fr2
, out
, outlen
);
75 callhunt(char *in
, char *out
, char *arg
, int outlen
)
77 char *argv
[20], abuff
[ALEN
];
87 argv
[5] = (char *)outlen
;
92 argv
[10] = (char *)onelen
;
95 if (strlen(abuff
) > ALEN
)
96 err("abuff not big enough %d", strlen(abuff
));
103 dodeliv(char *in
, char *out
, char *arg
, int outlen
)
108 fprintf(stderr
, "in dodeliv, arg /%s/\n", arg
?arg
:"");
113 mlen
= findline(in
, &mout
, outlen
, 0L);
116 strncpy(out
, mout
, outlen
);