Annotation of researchv10no/cmd/dist/v10/connect.c, revision 1.1

1.1     ! root        1: /* usage: connect hostname (answer|send|notice) (in|out) program [ args ... ] */
        !             2: 
        !             3: #include <ipc.h>
        !             4: #include <string.h>
        !             5: #include "../paths.h"
        !             6: 
        !             7: int
        !             8: main(int argc, char *argv[])
        !             9: {
        !            10:        int fd;
        !            11:        char ignore;
        !            12: 
        !            13:        if (argc < 5)
        !            14:                return 1;
        !            15: 
        !            16:        chdir(SDIR);
        !            17: 
        !            18:        fd = ipcopen(ipcpath(argv[1], "dk", "dist"), "heavy bsdauth");
        !            19: 
        !            20:        /* when connecting to a TCP host, soak up the initial NUL byte that
        !            21:           the bsdauth option ought to have eaten for us.  (lynch presotto)  */
        !            22:        if (strncmp(ipcpath(argv[1], "dk", "dist"), "/cs/tcp!", 8) == 0)
        !            23:                read(fd, &ignore, 1);
        !            24: 
        !            25:        if (fd < 0) {
        !            26:                perror(argv[1]);
        !            27:                return 1;
        !            28:        }
        !            29: 
        !            30:        write(fd, argv[2], strlen(argv[2]) + 1);
        !            31: 
        !            32:        if (strchr(argv[3], 'i'))
        !            33:                dup2(fd, 0);
        !            34:        if (strchr(argv[3], 'o'))
        !            35:                dup2(fd, 1);
        !            36:        close(fd);
        !            37:        execv(argv[4], &argv[4]);
        !            38: }

unix.superglobalmegacorp.com

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