Annotation of researchv8dc/dk/libc/dkctlchan.c, revision 1.1.1.1

1.1       root        1: #include <sys/ioctl.h>
                      2: #include <stdio.h>
                      3: 
                      4: static char *names[] = {
                      5:        "/dev/dk/dk0%c%d",
                      6:        "/dev/dk/dk2%c%d",
                      7:        "/dev/dk/dk%c%d",
                      8:        0
                      9: };
                     10: 
                     11: static char *namefmt;
                     12: static char alph[] = "0123456789abcdefghijklmnopqrstuvwxyz";
                     13: 
                     14: /*
                     15:  * open channel 1 to controller
                     16:  *   leave record of file name
                     17:  */
                     18: dkctlchan(traffic)
                     19: register traffic;
                     20: {
                     21:        register i ;
                     22:        extern int rdk_ld, dkp_ld ;
                     23:        char dk01file[32];
                     24: 
                     25:        namefmt = traffic? names[1]:names[0];
                     26:        sprintf(dk01file, namefmt, alph[0], 1);
                     27:        i = open(dk01file, 2) ;
                     28:        if (i < 0) {
                     29:                namefmt = names[2];
                     30:                sprintf(dk01file, namefmt, alph[0], 1);
                     31:                i = open(dk01file, 2);
                     32:                if (i < 0)
                     33:                        return (i) ;
                     34:        }
                     35:        if (ioctl(i, FIOLOOKLD, 0) != rdk_ld) {
                     36:                if (dkproto(i, dkp_ld) < 0) {
                     37:                        fprintf(stderr, "can't start dkp on %s\n", dk01file) ;
                     38:                        close(i) ;
                     39:                        return (-1) ;
                     40:                }
                     41:                if (ioctl(i, FIOPUSHLD, &rdk_ld) < 0) {
                     42:                        fprintf(stderr, "can't push rdk_ld on %s\n", dk01file) ;
                     43:                        close(i) ;
                     44:                        return (-1) ;
                     45:                }
                     46:                if (ioctl(i, DIOCLHN, (char *)0) < 0) {
                     47:                        fprintf(stderr, "can't be manager on %s\n", dk01file) ;
                     48:                        close(i);
                     49:                        return(-1);
                     50:                }
                     51:        }
                     52:        return (i) ;
                     53: }
                     54: 
                     55: /*
                     56:  * find the file name corresponding to a given channel.
                     57:  * assumes dkctlchan has been called.
                     58:  * Used for incoming calls.
                     59:  */
                     60: 
                     61: char *
                     62: dkfilename(chan)
                     63: {
                     64:        static char name[64];
                     65: 
                     66:        if (namefmt==NULL)
                     67:                return(NULL);
                     68:        sprintf(name, namefmt, alph[chan/10], chan%10);
                     69:        return(name);
                     70: }

unix.superglobalmegacorp.com

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