Annotation of 41BSD/cmd/refer/glue3.c, revision 1.1.1.1

1.1       root        1: # include "refer..c"
                      2: corout(in, out, rprog, arg, outlen)
                      3:        char *in, *out, *rprog;
                      4: {
                      5: # define move(x, y) close(y); dup(x); close(x);
                      6: int pipev[2], fr1, fr2, fw1, fw2, n;
                      7: 
                      8: if (strcmp (rprog, "hunt") ==0)
                      9:        return(callhunt(in, out, arg, outlen));
                     10: if (strcmp (rprog, "deliv")==0)
                     11:        return(dodeliv(in, out, arg, outlen));
                     12: pipe (pipev); fr1= pipev[0]; fw1 = pipev[1];
                     13: pipe (pipev); fr2= pipev[0]; fw2 = pipev[1];
                     14: if (fork()==0)
                     15:        {
                     16:        close (fw1); close (fr2);
                     17:        move (fr1, 0);
                     18:        move (fw2, 1);
                     19:        if (rprog[0]!= '/')
                     20:                chdir("/usr/lib/refer");
                     21:        execl(rprog, "deliv", arg, 0);
                     22:        err ("Can't run %s", rprog);
                     23:        }
                     24: close(fw2); close(fr1);
                     25: write (fw1, in , strlen(in));
                     26: close(fw1);
                     27: wait(0);
                     28: n = read (fr2, out, outlen);
                     29: out[n]=0;
                     30: close(fr2);
                     31: }
                     32: callhunt(in, out, arg, outlen)
                     33:        char *in, *out, *arg;
                     34: {
                     35: # define ALEN 50
                     36: char *argv[20], abuff[ALEN];
                     37: extern int typeindex;
                     38: int argc;
                     39: extern char one[];
                     40: extern int onelen;
                     41: argv[0] = "hunt";
                     42: argv[1] = "-i";
                     43: argv[2] = in;
                     44: argv[3] = "-t";
                     45: argv[4] = out;
                     46: argv[5] = outlen;
                     47: argv[6] = "-T";
                     48: argv[7] = "-F1";
                     49: argv[8] = "-o";
                     50: argv[9] = one;
                     51: argv[10] = onelen;
                     52: argv[11] = abuff; strcpy (abuff,arg);
                     53: if (strlen(abuff) > ALEN)
                     54:        err("abuff not big enough %d", strlen(abuff));
                     55: argc = 6;
                     56: huntmain (argc,argv);
                     57: return(0);
                     58: }
                     59: dodeliv(in, out, arg, outlen)
                     60:        char *in, *out, *arg;
                     61: {
                     62: # if D1
                     63: fprintf(stderr, "in dodeliv, arg /%s/\n", arg?arg:"");
                     64: # endif
                     65: if (arg && arg[0])
                     66:        chdir(arg);
                     67: findline(in, out, outlen, 0L);
                     68: restodir();
                     69: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.