Annotation of researchv10no/cmd/town/mark.c, revision 1.1.1.1

1.1       root        1: # include "stdio.h"
                      2: # include "assert.h"
                      3: # include "cbt.h"
                      4: main(argc,argv)
                      5:        char *argv[];
                      6: {
                      7: bfile *bloc;
                      8: FILE *fpat, *find;
                      9: char name[100], loc[100], ibuff[100];
                     10: mbuf key, val;
                     11: double lat, lng, atof();
                     12: long atol(), lb;
                     13: int x, y, k, found;
                     14: bloc = bopen("//usr/spool/town/ustowns", 0);
                     15: find = fopen("//usr/spool/town/hapindex", "r");
                     16: assert(bloc!=NULL);
                     17: assert(find!=NULL);
                     18: while (gets(name))
                     19:        {
                     20:        fpat = fopen("//usr/spool/town/haplist", "r");
                     21:        key.mdata = name; key.mlen = strlen(name);
                     22:        k = bseek(bloc, key);
                     23:        if (k!=1) continue;
                     24:        val.mdata = loc;
                     25:        bread(bloc, NULL, &val);
                     26:        val.mdata[val.mlen]=0;
                     27:        lat = atof(val.mdata);
                     28:        lng = atof(val.mdata+7);
                     29:        x = lat/4.;
                     30:        y = lng/4.;
                     31:        sprintf(loc, "%02d.%02d", x, y);
                     32:        rewind (find);
                     33:        while (fgets(ibuff, 100, find))
                     34:                {
                     35:                if (strncmp(ibuff, loc, 5)==0)
                     36:                        break;
                     37:                }
                     38:        if (feof(find))continue;
                     39:        lb = atol(ibuff+6);
                     40:        fseek (fpat, lb, 0);
                     41:        found=0;
                     42:        while (fgets(ibuff, 100, fpat))
                     43:                {
                     44:                if (strncmp(loc, ibuff, 5)!=0)
                     45:                        break;
                     46:                if (strncmp(name, ibuff+6, strlen(name)))
                     47:                        continue;
                     48:                lb = ftell (fpat);
                     49:                found=1;
                     50:                break;
                     51:                }
                     52:        fclose(fpat);
                     53:        if (found)
                     54:                {
                     55:                k = open("//usr/spool/town/haplist", 2);
                     56:                if (k>0)
                     57:                        {
                     58:                        lseek (k, lb-3, 0);
                     59:                        write (k, "x", 1);
                     60:                        close(k);
                     61:                        }
                     62:                }
                     63:        }
                     64: }

unix.superglobalmegacorp.com

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