void load_labels(const char *PQ) { const char *fname[2]; static char *definedp = "1"; static char *undefinedp = "0"; if (!hash_lookup((unsigned char *)PQ,label_table)) { char *f = malloc(strlen(PQ)+1), *fproj = NULL, *fid = NULL; strcpy(f, PQ); fproj = f; fid = strchr(fproj,':'); *fid++ = '\0'; current_PQ = PQ; current_proj = fproj; fname[0] = l2_expand(fproj, fid, "xtf"); fname[1] = NULL; if (!access(fname[0],R_OK)) { loading_links = 1; hash_insert((unsigned char*)PQ,definedp,label_table); runexpat(i_list, fname, sH, eH); } else { hash_insert((unsigned char*)PQ,undefinedp,label_table); if (check_links) vnotice("disabling label-checking because %s was not found", PQ); } } }
int check_and_register(const char *id, int set_ok) { unsigned char *vec; unsigned int vmax; long idnum = strtoul(id+1,NULL,10); unsigned int v, b; int tab[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; /* The vector is created by Perl's vec() function; perldoc -f vec for more info */ v = idnum/8; b = tab[idnum%8]; if (*id == 'P') { vec = pvec; vmax = 1000000; } else if (*id == 'Q') { vec = qvec; vmax = QVEC_SIZ; } else return 0; if (idnum < vmax && set_ok) { if (BIT_ISSET(vec[v],b)) { vwarning("duplicate ID: %s", id); return 1; } else { BIT_SET(vec[v],b); } } #if 1 /* issue this as a notice so it doesn't affect error status */ if (*id == 'P' && (idnum > max_cat_id || !(BIT_ISSET(catvec[v],b)))) { if (strlen(id) > 7) { vwarning("%s: malformed ID; text will be ignored",id); return 1; } else vnotice("%s not in main catalog (new P-IDs may not register for 48 hours)",id); } #else else { vwarning("%s: ID too big (max %d)",id,vmax); return 1; } #endif return 0; }