Annotation of coherent/b/lib/libc/gen/nlist.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Get entries from name list.
        !             3:  */
        !             4: 
        !             5: #include <stdio.h>
        !             6: #include <l.out.h>
        !             7: #include <canon.h>
        !             8: 
        !             9: nlist(fn, nlp)
        !            10: char *fn;
        !            11: struct nlist *nlp;
        !            12: {
        !            13:        register struct nlist *np;
        !            14:        register int ntodo = 0;
        !            15:        struct FILE *lfp;
        !            16:        struct ldheader lh;
        !            17:        struct ldsym ste;
        !            18:        fsize_t symsize;
        !            19:        register int n;
        !            20: 
        !            21:        for (np = nlp; np->n_name[0] != '\0'; np++) {
        !            22:                np->n_type = np->n_value = 0;
        !            23:                ntodo++;
        !            24:        }
        !            25:        if ((lfp = fopen(fn, "r")) == NULL)
        !            26:                return;
        !            27:        n = fread(&lh, sizeof lh, 1, lfp);
        !            28:        canint(lh.l_magic);
        !            29:        if (n!=1 || lh.l_magic!=L_MAGIC) {
        !            30:                fclose(lfp);
        !            31:                return;
        !            32:        }
        !            33:        for (n=0; n<=L_SYM; n++)
        !            34:                cansize(lh.l_ssize[n]);
        !            35:        symsize = sizeof lh + lh.l_ssize[L_SHRI] + lh.l_ssize[L_SHRD]
        !            36:            + lh.l_ssize[L_PRVI] + lh.l_ssize[L_PRVD] + lh.l_ssize[L_DEBUG];
        !            37:        fseek(lfp, symsize, 0);
        !            38:        symsize = lh.l_ssize[L_SYM];
        !            39:        for ( ; symsize>0 && ntodo; symsize -= sizeof ste) {
        !            40:                if (fread(&ste, sizeof ste, 1, lfp) != 1)
        !            41:                        break;
        !            42:                for (np = nlp; np->n_name[0] != '\0'; np++)
        !            43:                        if (strncmp(np->n_name, ste.ls_id, NCPLN) == 0) {
        !            44:                                canint(ste.ls_type);
        !            45:                                canvaddr(ste.ls_addr);
        !            46:                                np->n_type = ste.ls_type;
        !            47:                                np->n_value = ste.ls_addr;
        !            48:                                if (--ntodo == 0)
        !            49:                                        break;
        !            50:                        }
        !            51:        }
        !            52:        fclose(lfp);
        !            53: }

unix.superglobalmegacorp.com

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