static UtilHashTable * gatherNameSpaces(char *dn, UtilHashTable * ns, int first) { DIR *dir, *dir_test; struct dirent *de; char *n = NULL; int l; ClassRegister *cr; if (ns == NULL) { ns = UtilFactory->newHashTable(61, UtilHashTable_charKey | UtilHashTable_ignoreKeyCase); nsBaseLen = strlen(dn) + 1; } dir = opendir(dn); if (dir) while ((de = readdir(dir)) != NULL) { if (strcmp(de->d_name, ".") == 0) continue; if (strcmp(de->d_name, "..") == 0) continue; l = strlen(dn) + strlen(de->d_name) + 4; n = (char *) malloc(l + 8); strcpy(n, dn); strcat(n, "/"); strcat(n, de->d_name); dir_test = opendir(n); if (dir_test == NULL) { free(n); continue; } closedir(dir_test); cr = newClassRegister(n); if (cr) { ns->ft->put(ns, strdup(n + nsBaseLen), cr); gatherNameSpaces(n, ns, 0); } free(n); } else if (first) { mlogf(M_ERROR, M_SHOW, "--- Repository %s not found\n", dn); } closedir(dir); return ns; }
static UtilHashTable *buildClassRegisters() { char *dir; char *dn; setupControl(configfile); if (getControlChars("registrationDir",&dir)) { dir = "/var/lib/sfcb/registration"; } dn=(char*)alloca(strlen(dir)+32); strcpy(dn,dir); if (dir[strlen(dir)-1]!='/') strcat(dn,"/"); strcat(dn,"repository"); return gatherNameSpaces(dn,NULL,1); }
static UtilHashTable * buildClassRegisters() { return gatherNameSpaces(); }