Annotation of coherent/g/usr/bin/script/gpstty.c, revision 1.1.1.1

1.1       root        1: #include <errno.h>
                      2: #include <fcntl.h>
                      3: 
                      4: static char PtyName[32] = "/dev/ptyXY";
                      5: static char TtyName[32] = "/dev/ttyXY";
                      6: 
                      7: int getpseudotty(m, s)
                      8: char *m, *s;
                      9: {
                     10:        register char *l, *d;
                     11:        int index, f;
                     12:    
                     13:        index = strlen(PtyName) - 2;
                     14:        for (l = "pqrstuvwxyz"; *l; ++l) {
                     15:                for (d = "0123456789abcdef"; *d; ++d) {
                     16:                        PtyName[index] = *l;
                     17:                        PtyName[index+1] = *d;
                     18:                        if ((f = open(PtyName, O_RDWR)) != -1) {
                     19:                                strcpy(m, PtyName);
                     20:                                TtyName[index] = *l;
                     21:                                TtyName[index+1] = *d;
                     22:                                strcpy(s, TtyName);
                     23:                                return f;
                     24:                        } else {
                     25:                                perror("script: opening master");
                     26:                                if(errno == ENXIO)
                     27:                                        break;
                     28:                        }
                     29:                }
                     30:        }
                     31:        return -1;
                     32: }

unix.superglobalmegacorp.com

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