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

1.1     ! root        1: /* usage: dispatch <ipc args> */
        !             2: /* TODO: connect input to /dev/null if peer wants no output,
        !             3:    connect output to logfile if peer wants no input.  */
        !             4: 
        !             5: #include <ipc.h>
        !             6: #include <string.h>
        !             7: #include "../paths.h"
        !             8: 
        !             9: int
        !            10: main(int argc, char *argv[])
        !            11: {
        !            12:        char c, d;
        !            13:        char *args[4];
        !            14:        int fd;
        !            15: 
        !            16:        if (chdir(LDIR) < 0)
        !            17:                return 1;
        !            18: 
        !            19:        (args[1] = strchr(argv[1], '=')) && ++args[1];
        !            20:        (args[2] = strchr(argv[2], '=')) && ++args[2];
        !            21:        args[3] = 0;
        !            22: 
        !            23:        if (read(0, &c, 1) != 1)
        !            24:                return 1;
        !            25:        do
        !            26:                if (read(0, &d, 1) != 1)
        !            27:                        return 1;
        !            28:        while (d);
        !            29: 
        !            30:        fd = open("/dev/null", 1);
        !            31:        dup2(fd, 2);
        !            32:        if (fd > 2)
        !            33:                close(fd);
        !            34: 
        !            35:        switch (c) {
        !            36:        case 's':
        !            37:                args[0] = "showq";
        !            38:                execv("showq", args);
        !            39:                break;
        !            40:        case 't':
        !            41:                args[0] = "transmit";
        !            42:                execv("transmit", args);
        !            43:                break;
        !            44:        case 'n':
        !            45:                args[0] = "notice";
        !            46:                execv("notice", args);
        !            47:                break;
        !            48:        }
        !            49: 
        !            50:        return 1;
        !            51: }

unix.superglobalmegacorp.com

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