Annotation of researchv10no/cmd/learn/start.c, revision 1.1

1.1     ! root        1: #include "stdio.h"
        !             2: #include "lrnref"
        !             3: #include "sys/types.h"
        !             4: #include "sys/dir.h"
        !             5: 
        !             6: #define        ND      64
        !             7: 
        !             8: start(lesson)
        !             9: char *lesson;
        !            10: {
        !            11:        struct direct dv[ND], *dm, *dp;
        !            12:        int f, c, n;
        !            13:        char where [100];
        !            14: 
        !            15:        f = open(".", 0);
        !            16:        n = read(f, dv, ND*sizeof(*dp));
        !            17:        n /= sizeof(*dp);
        !            18:        if (n==ND)
        !            19:                fprintf(stderr, "lesson too long\n");
        !            20:        dm = dv+n;
        !            21:        for(dp=dv; dp<dm; dp++)
        !            22:                if (dp->d_ino) {
        !            23:                        n = strlen(dp->d_name);
        !            24:                        if (dp->d_name[n-2] == '.' && dp->d_name[n-1] == 'c')
        !            25:                                continue;
        !            26:                        c = dp->d_name[0];
        !            27:                        if (c>='a' && c<= 'z')
        !            28:                                unlink(dp->d_name);
        !            29:                }
        !            30:        close(f);
        !            31:        if (ask)
        !            32:                return;
        !            33:        sprintf(where, "../../%s/L%s", sname, lesson);
        !            34:        if (access(where, 04)==0)       /* there is a file */
        !            35:                return;
        !            36:        fprintf(stderr, "No lesson %s\n",lesson);
        !            37:        wrapup(1);
        !            38: }
        !            39: 
        !            40: fcopy(new,old)
        !            41: char *new, *old;
        !            42: {
        !            43:        char b[512];
        !            44:        int n, fn, fo;
        !            45:        fn = creat(new, 0666);
        !            46:        fo = open(old,0);
        !            47:        if (fo<0) return;
        !            48:        if (fn<0) return;
        !            49:        while ( (n=read(fo, b, 512)) > 0)
        !            50:                write(fn, b, n);
        !            51:        close(fn);
        !            52:        close(fo);
        !            53: }

unix.superglobalmegacorp.com

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