Annotation of researchv10no/cmd/refer/glue3.c, revision 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: while((n = read (fr2, out, outlen)) > 0) {
        !            29:        out += n;
        !            30:        outlen -= n;
        !            31: }
        !            32: *out = 0;
        !            33: close(fr2);
        !            34: }
        !            35: callhunt(in, out, arg, outlen)
        !            36:        char *in, *out, *arg;
        !            37: {
        !            38: # define ALEN 50
        !            39: char *argv[20], abuff[ALEN];
        !            40: extern int typeindex;
        !            41: int argc;
        !            42: extern char one[];
        !            43: extern int onelen;
        !            44: argv[0] = "hunt";
        !            45: argv[1] = "-i";
        !            46: argv[2] = in;
        !            47: argv[3] = "-t";
        !            48: argv[4] = out;
        !            49: argv[5] = (char *)outlen;
        !            50: argv[6] = "-T";
        !            51: argv[7] = "-F1";
        !            52: argv[8] = "-o";
        !            53: argv[9] = one;
        !            54: argv[10] = (char *)onelen;
        !            55: argv[11] = abuff; strcpy (abuff,arg);
        !            56: if (strlen(abuff) > ALEN)
        !            57:        err("abuff not big enough %d", strlen(abuff));
        !            58: argc = 6;
        !            59: huntmain (argc,argv);
        !            60: return(0);
        !            61: }
        !            62: dodeliv(in, out, arg, outlen)
        !            63:        char *in, *out, *arg;
        !            64: {
        !            65: # if D1
        !            66: fprintf(stderr, "in dodeliv, arg /%s/\n", arg?arg:"");
        !            67: # endif
        !            68: if (arg && arg[0])
        !            69:        chdir(arg);
        !            70: findline(in, out, outlen, 0L);
        !            71: restodir();
        !            72: }

unix.superglobalmegacorp.com

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