- list_for_each_entry(loop_file, file_list, list) {
- if (strcmp(loop_file->name, filename) > 0) {
- break;
+ if (sort)
+ list_for_each_entry(loop_name, name_list, node) {
+ if (sort && strcmp(loop_name->name, name) > 0)
+ break;
+ }
+
+ new_name = malloc(sizeof(struct name_entry));
+ if (new_name == NULL) {
+ dbg("error malloc");
+ return -ENOMEM;
+ }
+
+ strlcpy(new_name->name, name, sizeof(new_name->name));
+ dbg("adding '%s'", new_name->name);
+ list_add_tail(&new_name->node, &loop_name->node);
+
+ return 0;
+}
+
+int name_list_key_add(struct list_head *name_list, const char *key, const char *value)
+{
+ struct name_entry *loop_name;
+ struct name_entry *new_name;
+
+ list_for_each_entry(loop_name, name_list, node) {
+ if (strncmp(loop_name->name, key, strlen(key)) == 0) {
+ dbg("key already present '%s', replace it", loop_name->name);
+ snprintf(loop_name->name, sizeof(loop_name->name), "%s=%s", key, value);
+ loop_name->name[sizeof(loop_name->name)-1] = '\0';
+ return 0;