Annotation of researchv10no/cmd/btree/btdelete.c, revision 1.1

1.1     ! root        1: /* read keys from stdin, and delete the records from argv[1] */
        !             2: #include "stdio.h"
        !             3: #include "cbt.h"
        !             4: 
        !             5: char buf[NDSZ];
        !             6: bfile *bf;
        !             7: mbuf key;
        !             8: 
        !             9: main(argc, argv)
        !            10: char **argv;
        !            11: {      char *p;
        !            12:        int c = 0;
        !            13:        if(argc != 2) {
        !            14:                fprintf(stderr, "usage: delete b-tree < keys\n");
        !            15:                exit(1);
        !            16:        }
        !            17:        if((bf = bopen(argv[1], 2)) == NULL) {
        !            18:                perror(argv[1]);
        !            19:                exit(1);
        !            20:        }
        !            21:        key.mdata = buf;
        !            22: loop:
        !            23:        if(c == EOF) {
        !            24:                bclose(bf);
        !            25:                exit(0);
        !            26:        }
        !            27:        for(p = buf; (c = getchar()) != '\n' && c != EOF; *p++ = c)
        !            28:                ;
        !            29:        *p = 0;
        !            30:        key.mlen = p - buf;
        !            31:        if(key.mlen == 0)
        !            32:                goto loop;
        !            33:        if(!bdelete(bf, key))
        !            34:                fprintf(stderr, "not in file:%s\n", buf);
        !            35:        goto loop;
        !            36: }
        !            37: static struct D { struct D *a; char *b;} VER = {&VER,"\n81/8/9:btdelete.c\n"};
        !            38: /*0010110100010101*/

unix.superglobalmegacorp.com

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