static void conf_devices_load(const char *dirname, nfc_context *context) { DIR *d = opendir(dirname); if (!d) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Unable to open directory: %s", dirname); } else { struct dirent *de; #ifdef WIN32 while ((de = readdir(d)) != NULL) { #else struct dirent entry; struct dirent *result; while ((readdir_r(d, &entry, &result) == 0) && (result != NULL)) { de = &entry; #endif if (de->d_name[0] != '.') { const size_t filename_len = strlen(de->d_name); const size_t extension_len = strlen(".conf"); if ((filename_len > extension_len) && (strncmp(".conf", de->d_name + (filename_len - extension_len), extension_len) == 0)) { char filename[BUFSIZ] = LIBNFC_DEVICECONFDIR"/"; strcat(filename, de->d_name); struct stat s; if (stat(filename, &s) == -1) { perror("stat"); continue; } if (S_ISREG(s.st_mode)) { conf_parse_file(filename, conf_keyvalue_device, context); } } } } closedir(d); } } void conf_load(nfc_context *context) { conf_parse_file(LIBNFC_CONFFILE, conf_keyvalue_context, context); conf_devices_load(LIBNFC_DEVICECONFDIR, context); }
void conf_load(nfc_context *context) { conf_parse_file(LIBNFC_CONFFILE, conf_keyvalue_context, context); conf_devices_load(LIBNFC_DEVICECONFDIR, context); }