Annotation of researchv10dc/cmd/daemon/phone.dpd.c, revision 1.1

1.1     ! root        1: #
        !             2: /*
        !             3:  * dpd -- data-phone daemon dispatcher
        !             4:  *
        !             5:  */
        !             6: 
        !             7: #define        SPIDER  0
        !             8: #define        PHONE   1
        !             9: #define        LPD     0
        !            10: #define        FGET    0
        !            11: 
        !            12: char   dname[] = "DPDP";
        !            13: char   dpd[]   = "/usr/spool/dpd";
        !            14: char   dfname[30] = "/usr/spool/dpd/";
        !            15: char   lock[]  = "/usr/spool/dpd/lock";
        !            16: char   error[] = "/usr/spool/dpd/errors";
        !            17: 
        !            18: #include       "daemon.c"
        !            19: #include       "gcos.c"
        !            20: 
        !            21: /*
        !            22:  * The remaining part is the data phone interface.
        !            23:  */
        !            24: 
        !            25: #define        NCONERR 4
        !            26: #define        BUSY    -1
        !            27: #define        TIMEOUT -2
        !            28: #define        BADID   -3
        !            29: #define        ERROR   -4
        !            30: char   conerr[NCONERR+1][8] = {"BUSY","TIMEOUT","BAD ID","ERROR","UNKNOWN"};
        !            31: 
        !            32: #define        FC4     0104
        !            33: #define        FC10    0110
        !            34: #define        OC      0100
        !            35: #define        ACKOC   0102
        !            36: #define        MCBCD   0110
        !            37: #define        MCBIN   0120
        !            38: #define        RS      036
        !            39: #define        ETX     03
        !            40: #define        MASK6   077
        !            41: 
        !            42: char   snumbf[]        = "/usr/spool/dpd/snumb";
        !            43: char   scard[] = "H$      snumb   XXxxx,31\036\003";
        !            44: char   rcd[]   = "H$*$rcd\036\003";
        !            45: 
        !            46: FILE   *cfb = NULL;
        !            47: int    snum    = 0;
        !            48: int    ioc;
        !            49: 
        !            50: dem_con()
        !            51: {
        !            52:        int i;
        !            53: 
        !            54:        if((i = connect(phone_id)) < 0) {
        !            55:                if((i = -i) > NCONERR+1)  i = NCONERR+1;
        !            56:                logerr("Can't reach GCOS: %-8s", conerr[i-1]);
        !            57:                return(i);
        !            58:        }
        !            59:        if((ioc = gerts(FC4, OC, rcd, NULL)) != ACKOC){
        !            60:                dem_dis();
        !            61:                logerr("Bad ACK on rcd: ACK-OC = %-11o", ioc);
        !            62:                return(1);
        !            63:        }
        !            64:        return(0);
        !            65: }
        !            66: 
        !            67: dem_dis()
        !            68: {
        !            69:        gerts_dis();
        !            70:        FCLOSE(dfb);
        !            71:        FCLOSE(cfb);
        !            72: }
        !            73: 
        !            74: dem_open(file)
        !            75: char   *file;
        !            76: {
        !            77: }
        !            78: 
        !            79: dem_close()
        !            80: {
        !            81: }
        !            82: 
        !            83: get_snumb()
        !            84: {
        !            85:        FILE *f;
        !            86:        int i, temp;
        !            87: 
        !            88:                if((f = fopen(snumbf, "r")) != NULL){
        !            89:                        fread((char *)&snum, 2, 1, f);
        !            90:                        fclose(f);
        !            91:                }
        !            92:                snum++;
        !            93:                scard[16] = phone_id[0];
        !            94:                scard[17] = phone_id[1];
        !            95:                temp = snum;
        !            96:                for(i = 20; i > 17; i--){
        !            97:                        scard[i] = (temp % 10) | '0';
        !            98:                        temp = temp/10;
        !            99:                }
        !           100:                scard[21] = ',';
        !           101:                if(temp > 0)
        !           102:                        snum = 0;
        !           103:                if((f = fopen(snumbf, "w")) == NULL)
        !           104:                        trouble("Can't write %s", snumbf);
        !           105:                fwrite((char *)&snum, 2, 1, f);
        !           106:                fclose(f);
        !           107:                gwrite(FC4, scard, 25);
        !           108:                snumb = &scard[16];
        !           109:                scard[21] = 0;
        !           110: }
        !           111: 
        !           112: lwrite()
        !           113: {
        !           114:                line[0] = MCBCD;
        !           115:                line[linel++] = RS;
        !           116:                if(line[1] == '$')
        !           117:                        gwrite(FC4, line, linel);
        !           118:                else
        !           119:                        gwrite(FC10, line, linel);
        !           120: }
        !           121: 
        !           122: 
        !           123: sascii(fff)
        !           124: {
        !           125:        static char obuf[400];
        !           126:        int io, j1, j2;
        !           127:        int c1, c2, eof;
        !           128:        int temp;
        !           129:        extern char gcset[];
        !           130: 
        !           131:        if((cfb = fopen(&line[1], "r")) == NULL){
        !           132:                logerr("Can't open %s", &line[1]);
        !           133:                return(0);
        !           134:        }
        !           135:        io = eof = 0;
        !           136:        if(fff)
        !           137:                c1 = ff;
        !           138:        else
        !           139:            if((c1 = getc(cfb)) == EOF)
        !           140:                eof = 1;
        !           141:        while(eof == 0){
        !           142:            for(j1 = 1; j1 <= 2; j1++){
        !           143:                obuf[io++] = MCBIN;
        !           144:                for(j2 = 1; j2 <= 52; j2++){
        !           145:                        obuf[io++] = gcset[c1>>3 & MASK6];
        !           146:                        if((c2 = getc(cfb)) == EOF){
        !           147:                            c2 = 0;
        !           148:                            eof = 1;
        !           149:                        }
        !           150:                        temp = (c1<<3 | (c2>>6 & 07));
        !           151:                        obuf[io++] = gcset[temp & MASK6];
        !           152:                        obuf[io++] = gcset[c2 & MASK6];
        !           153:                        if((c1 = getc(cfb)) == EOF)
        !           154:                            eof = 1;
        !           155:                        if(eof)
        !           156:                            break;
        !           157:                }
        !           158:                obuf[io++] = RS;
        !           159:                if(eof)
        !           160:                        break;
        !           161:            }
        !           162:            gwrite(FC10, obuf, io);
        !           163:            io = 0;
        !           164:        }
        !           165:        FCLOSE(cfb);
        !           166:        return(0);
        !           167: }
        !           168: 
        !           169: gwrite(fc, b, n)
        !           170: int    fc;
        !           171: char   *b;
        !           172: int    n;
        !           173: {
        !           174:        register i;
        !           175:        static char outbuf[402];
        !           176: 
        !           177:        b[n] = ETX;
        !           178:        ioc = gerts(fc, OC, b, outbuf);
        !           179:        for(i = 0; i <= 10; i++){
        !           180:                if(ioc == ACKOC){
        !           181:                        snsum += n-2;
        !           182:                        return;
        !           183:                }
        !           184: #ifdef DEBUG
        !           185:                for(i = 1; outbuf[i] != ETX && i < 400; i++) ;
        !           186:                outbuf[i+1] = 0;
        !           187:                fprintf(stderr, "ioc=%o, fc=%o, buf='%s'.\n",
        !           188:                        ioc, outbuf[0], &outbuf[1]);
        !           189: #endif
        !           190:                if(ioc != 0100)
        !           191:                        break;
        !           192:                ioc = gerts(0115, OC, NULL, outbuf);
        !           193:        }
        !           194:        trouble("write error: ioc =%6o, pid %-6s",
        !           195:                ioc, dfname+LPID);
        !           196: }
        !           197: 
        !           198: /* VARARGS */
        !           199: trouble(s, a1, a2, a3, a4)
        !           200: char   *s;
        !           201: int    a1, a2, a3, a4;
        !           202: {
        !           203: 
        !           204:        FCLOSE(dfb);
        !           205:        FCLOSE(cfb);
        !           206:        if(retcode != 0)
        !           207:                gerts_dis();
        !           208:        logerr(s, a1, a2, a3, a4);
        !           209:        longjmp(env, 1);
        !           210: }

unix.superglobalmegacorp.com

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