void getnams (void) { register COLLECTION *c; char buf[STRINGLENGTH]; register FILE *f; char *p,*q; for (c = firstC; c && c->Chtree != NULL; c = c->Cnext); if (c == NULL) return; (void) sprintf (buf,FILEHOSTS,DEFDIR); f = fopen (buf,"r"); if (f == NULL) logquit (1,"Can't open %s",buf); while ((p = fgets (buf,STRINGLENGTH,f)) != NULL) { if ((q = strchr (p,'\n'))) *q = '\0'; if (strchr ("#;:",*p)) continue; q = (char *)nxtarg (&p,"= \t"); p = (char *)skipover (p," \t"); if (*p == '=') p++; p = (char *)skipover (p," \t"); if (*p == '\0') goaway ("error in collection/host file"); do { if (strcmp (c->Cname, q) == 0) { do { q = (char *)nxtarg (&p,", \t"); p = (char *)skipover (p," \t"); if (*p == ',') p++; p = (char *)skipover (p," \t"); (void) Tinsert (&c->Chtree,q,FALSE); } while (*p != '\0'); } while ((c = c->Cnext) != NULL && c->Chtree != NULL); } while (c != NULL); for (c = firstC; c && c->Chtree != NULL; c = c->Cnext); if (c == NULL) break; } (void) fclose (f); if (c == NULL) return; do { logerr ("Host for collection %s not found",c->Cname); while ((c = c->Cnext) != NULL && c->Chtree != NULL); } while (c); logquit (1,"Hosts not found for all collections"); }
int main(int argc, char **argv) { SCAN_COLLECTION * volatile c; /* Avoid longjmp clobbering */ volatile int errs; #ifdef RLIMIT_DATA struct rlimit dlim; if (getrlimit(RLIMIT_DATA, &dlim) == -1) goaway("Error getting resource limit (%s)", strerror(errno)); if (dlim.rlim_cur != dlim.rlim_max) { dlim.rlim_cur = dlim.rlim_max; if (setrlimit(RLIMIT_DATA, &dlim) == -1) goaway("Error setting resource limit (%s)", strerror(errno)); } #endif errs = init(argc, argv); /* process arguments */ if (errs) { fprintf(stderr, "supscan: %d collections had errors", errs); return 1; } for (c = firstC; c; c = c->Cnext) { collname = c->Cname; basedir = c->Cbase; prefix = c->Cprefix; if (chdir(basedir) < 0) { fprintf(stderr, "supscan: Can't chdir to %s (%s)", basedir, strerror(errno)); return 1; } scantime = time(NULL); if (!quiet) printf("SUP Scan for %s starting at %s", collname, ctime(&scantime)); (void) fflush(stdout); if (!setjmp(sjbuf)) { makescanlists(); /* record names in scan files */ scantime = time(NULL); if (!quiet) printf("SUP Scan for %s completed at %s", collname, ctime(&scantime)); } else { fprintf(stderr, "SUP: Scan for %s aborted at %s", collname, ctime(&scantime)); errs++; } if (!quiet) (void) fflush(stdout); } while ((c = firstC) != NULL) { firstC = firstC->Cnext; free(c->Cname); free(c->Cbase); if (c->Cprefix) free(c->Cprefix); free(c); } return errs ? 1 : 0; }