Annotation of researchv10no/cmd/face/scaffold.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include "faces.h"
        !             3: #include "faceproto.h"
        !             4: 
        !             5: main(argc, argv)
        !             6: int argc;
        !             7: char **argv;
        !             8: {
        !             9:        register File *f;
        !            10:        register int i;
        !            11:        char *a[10];
        !            12:        int na;
        !            13:        char buf[100];
        !            14: 
        !            15:        while (fgets(buf, sizeof(buf), stdin)) {
        !            16:                buf[strlen(buf)-1] = 0; /* stupid newline */
        !            17:                if ((na = getmfields(buf, a, 10)) <= 0)
        !            18:                        continue;
        !            19:                switch (a[0][0]) {
        !            20:                case 'i':
        !            21:                        if (na < 3) {
        !            22:                                printf("i pfile mfile\n");
        !            23:                                continue;
        !            24:                        }
        !            25:                        maketree(a[1], a[2]);
        !            26:                        printf("%ld\n", (long)sbrk(0));
        !            27:                        continue;
        !            28: 
        !            29:                case 'f':
        !            30:                        if (na < 2) {
        !            31:                                printf("f file\n");
        !            32:                                continue;
        !            33:                        }
        !            34:                        if ((f = lookfile(a[1])) == NULL) {
        !            35:                                printf("%s: not found\n", a[1]);
        !            36:                                continue;
        !            37:                        }
        !            38:                        if (isdir(f))
        !            39:                                printf("ino %d links %d dir nalloc %d nfiles %d\n",
        !            40:                                        f->ino, f->nlinks, f->nalloc, f->nfiles);
        !            41:                        else
        !            42:                                printf("ino %d links %d file %s\n",
        !            43:                                        f->ino, f->nlinks, f->data);
        !            44:                        continue;
        !            45: 
        !            46:                case 'd':
        !            47:                case 'l':
        !            48:                        if (na < 2) {
        !            49:                                printf("%c dir\n", a[0][0]);
        !            50:                                continue;
        !            51:                        }
        !            52:                        if ((f = lookfile(a[1])) == NULL) {
        !            53:                                printf("%s: not found\n", a[1]);
        !            54:                                continue;
        !            55:                        }
        !            56:                        if (!isdir(f)) {
        !            57:                                printf("%s: not directory\n", a[1]);
        !            58:                                continue;
        !            59:                        }
        !            60:                        if (a[0][0] == 'd')
        !            61:                                dirdata(f);
        !            62:                        for (i = 0; i < f->nfiles; i++)
        !            63:                                if (a[0][0] == 'd')
        !            64:                                        printf("%s\n", f->data+(i*FDLEN)+FD_NAME);
        !            65:                                else
        !            66:                                        printf("%s\n", f->dir[i].name);
        !            67:                        continue;
        !            68: 
        !            69:                case 'D':
        !            70:                        if (na < 2) {
        !            71:                                printf("D dir\n");
        !            72:                                continue;
        !            73:                        }
        !            74:                        if ((f = lookfile(a[1])) == NULL) {
        !            75:                                printf("%s: not found\n", a[1]);
        !            76:                                continue;
        !            77:                        }
        !            78:                        if (!isdir(f)) {
        !            79:                                printf("%s: not directory\n", a[1]);
        !            80:                                continue;
        !            81:                        }
        !            82:                        dirdata(f);
        !            83:                        printf("%ld\n", sbrk(0));
        !            84:                        continue;
        !            85: 
        !            86:                default:
        !            87:                        printf("?\n");
        !            88:                        continue;
        !            89:                }
        !            90:        }
        !            91:        exit(0);
        !            92: }

unix.superglobalmegacorp.com

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