Annotation of researchv10no/cmd/refer/update/runup2.c, revision 1.1.1.1

1.1       root        1: # include "runup.h"
                      2: # include "sys/types.h"
                      3: # include "sys/dir.h"
                      4: # include "sys/stat.h"
                      5: # define NB 100
                      6: struct bibfile bibs[NB];
                      7: # define BIBCH 1000
                      8: char bibbuff[BIBCH];
                      9: char *bibcp = bibbuff;
                     10: 
                     11: readbib()
                     12: {
                     13: glist();
                     14: # if D1
                     15:                printf("List of bib files\n");
                     16:                { struct bibfile *bp;;
                     17:                for(bp=bibs; bp->bibfno>=0; bp++)
                     18:                        printf("  bib%d\n", bp->bibfno);
                     19:                }
                     20: # endif
                     21: gdata();
                     22: # if D1
                     23:                printf("Contents\n");
                     24:                {struct bibfile *bp;
                     25:                for(bp=bibs; bp->bibfno>=0; bp++)
                     26:                        printf("bib%d is %s %ld,%d\n",
                     27:                                bp->bibfno, bp->bibfref, bp->bibfstrt,bp->bibfleng);
                     28:                }
                     29: # endif
                     30: }
                     31: glist()
                     32: {
                     33: struct bibfile *bibp = bibs;
                     34: int fd;
                     35: struct stat sbuf;
                     36: char ftr[100];
                     37: long tref;
                     38: struct direct dir;
                     39: sprintf(ftr, "%s/Ind.ib", Master);
                     40: assert(stat (ftr, &sbuf)==0);
                     41: tref=sbuf.st_mtime;
                     42: fd = open(".", 0);
                     43: assert(fd>0);
                     44: while(read(fd, &dir, sizeof(dir))==sizeof(dir))
                     45:        {
                     46:        if (dir.d_ino==0)
                     47:                continue;
                     48:        if (strncmp(dir.d_name, "bib", 3) != SAME)
                     49:                continue;
                     50:        strncpy(ftr, dir.d_name, 14);
                     51:        assert(stat(ftr, &sbuf) ==0);
                     52:        if (sbuf.st_mtime<=tref)
                     53:                {
                     54:                fprintf(stderr, "File %s too old - reenter change\n", ftr);
                     55:                continue;
                     56:                }
                     57:        bibp++->bibfno = atoi(dir.d_name+3);
                     58:        assert(bibp<bibs+NB);
                     59:        }
                     60: bibp -> bibfno = -1;
                     61: close(fd);
                     62: }
                     63: gdata()
                     64: {
                     65: struct bibfile *bibp, *bp;
                     66: FILE *fb;
                     67: int junk1, junk2, leng;
                     68: long start;
                     69: char junk[20], junk3[20], name[50], *np;
                     70: char fnam[20], bibln[100];
                     71: for(bibp=bibs; bibp->bibfno>=0; bibp++)
                     72:        {
                     73:        sprintf(fnam, "bib%03d", bibp->bibfno);
                     74:        fb = fopen(fnam, "r");
                     75:        assert(fb!=NULL);
                     76:        assert(fgets(bibln, 100, fb)!=0);
                     77:        sscanf(bibln, "%s %s %d %d %s %ld %d",
                     78:                junk, name, &junk1, &junk2, junk3, &start, &leng);
                     79:        assert(name[0]=='/');
                     80:        fclose(fb);
                     81:        for(bp=bibs; bp<bibp; bp++)
                     82:                {
                     83:                if (strcmp(name, bp->bibfref)==SAME)
                     84:                        {
                     85:                        bibp->bibfref = bp->bibfref;
                     86:                        break;
                     87:                        }
                     88:                }
                     89:        if (bp==bibp) /* not previously used file name */
                     90:                {
                     91:                bibp->bibfref = bibcp;
                     92:                np=name;
                     93:                while (*bibcp++ = *np++);
                     94:                }
                     95:        bibp->bibfstrt = start;
                     96:        bibp->bibfleng = leng;
                     97:        }
                     98: }

unix.superglobalmegacorp.com

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