* it what you wish.
*
* Evaluting a list of configuration filenames which have to be handled/parsed.
- * The order of this file list has been defined by
+ *
+ * The order of this file list has been defined by
* https://github.com/uapi-group/specifications/blob/main/specs/configuration_files_specification.md
*/
struct list_head **current_entry,
char **name);
-#endif
+#endif /* UTIL_LINUX_CONFIGS_H */
#if defined(HAVE_SCANDIRAT) && defined(HAVE_OPENAT)
#include <dirent.h>
#endif
+
#include "configs.h"
#include "list.h"
#include "fileutils.h"
char *filename;
};
-/* Checking for main configuration file
- *
+/* Checking for main configuration file
+ *
* Returning absolute path or NULL if not found
* The return value has to be freed by the caller.
*/
bool found = false;
char *path = NULL;
struct stat st;
-
+
if (config_suffix) {
if (asprintf(&path, "%s/%s/%s.%s", root, project, config_name, config_suffix) < 0)
return NULL;
return counter;
}
-#endif
+#endif /* HAVE_SCANDIRAT */
static void free_list_entry(struct file_element *element)
{
free(element);
}
-
int ul_configs_file_list(struct list_head *file_list,
const char *project,
const char *etc_subdir,
struct list_head *etc_entry = NULL, *usr_entry = NULL;
struct file_element *add_element = NULL, *usr_element = NULL, *etc_element = NULL;
int counter = 0;
-
+
INIT_LIST_HEAD(file_list);
if (!config_name){
#endif
list_for_each(etc_entry, &etc_file_list) {
+
etc_element = list_entry(etc_entry, struct file_element, file_list);
etc_basename = ul_basename(etc_element->filename);
+
list_for_each(usr_entry, &usr_file_list) {
+
usr_element = list_entry(usr_entry, struct file_element, file_list);
usr_basename = ul_basename(usr_element->filename);
+
if (strcmp(usr_basename, etc_basename) <= 0) {
if (strcmp(usr_basename, etc_basename) < 0) {
add_element = new_list_entry(usr_element->filename);