#include #include /* for the direct structure */ #include #include #include #include "ant.h" /* for LinkList */ #include "libCfg_local.h" LinkList LoadSCFs (char *path) { DIR *dirp; struct dirent *direntp; StrHier S; LinkList L; char *pos; int len, count; L = NULL; if (path == NULL) return NULL; if ((dirp = opendir(path)) == NULL) { return NULL; } count = 0; while ( (direntp = readdir( dirp )) != NULL ) { if ((len = strlen(direntp->d_name)) < 5) continue; if ((pos = strstr(direntp->d_name, ".SCF")) == NULL) continue; count++; } if (count <= 0) return NULL; if (!(S = StrHierCreateNodes(count))) { return NULL; } count = 0; rewinddir(dirp); while ( (direntp = readdir( dirp )) != NULL ) { if ((len = strlen(direntp->d_name)) < 5) continue; if ((pos = strstr(direntp->d_name, ".SCF")) == NULL) continue; S[count].str = strdup(direntp->d_name); S[count].number = count+1; S[count].GetNextItems = SCFNextItems; L = LinkAppend(L, (void *)&S[count++]); } (void)closedir( dirp ); return L; }