-static int adddirs(char path[PATH_MAX], size_t end)
-{
- int rc;
- DIR *dir;
- struct dirent ent, *result;
- size_t len;
-
- /* open the DIR now */
- dir = opendir(path);
- if (dir == NULL) {
- fprintf(stderr, "ERROR in scanning plugin directory %s, %m\n", path);
- return -1;
- }
- if (verbose)
- fprintf(stderr, "Scanning dir=[%s] for plugins\n", path);
-
- /* scan each entry */
- if (end)
- path[end++] = '/';
- for (;;) {
- readdir_r(dir, &ent, &result);
- if (result == NULL)
- break;
-
- len = strlen(ent.d_name);
- if (len + end >= PATH_MAX) {
- fprintf(stderr, "path too long for %s\n", ent.d_name);
- continue;
- }
- memcpy(&path[end], ent.d_name, len+1);
- if (ent.d_type == DT_DIR) {
- /* case of directories */
- if (ent.d_name[0] == '.') {
- if (len == 1)
- continue;
- if (ent.d_name[1] == '.' && len == 2)
- continue;
- }
- rc = adddirs(path, end+len);;
- } else if (ent.d_type == DT_REG) {
- /* case of files */
- if (!strstr(ent.d_name, ".so"))
- continue;
- rc = afb_apis_add_plugin(path);
- }
- }
- closedir(dir);
- return 0;
-}
-
-int afb_apis_add_directory(const char *path)