#include #include #include int readplugins(void) { struct dirent *de; DIR *dr = opendir("/usr/share/thing/plugins/"); if (dr == NULL) { printf("Could not open plugin capability directory " "(/usr/share/thing/plugins/)"); return 1; } while ((de = readdir(dr)) != NULL) { // if filename shorter than x.toml -> 6 if (sizeof(de->d_name) / sizeof(de->d_name[0]) - 1 < 6) continue; // if it ends with toml char *ext = strrchr(de->d_name, '.'); if (!(strcmp(ext, ".toml"))) printf("%s\n", de->d_name); } closedir(dr); return 0; }