- /* avoid duplicate entries */
- list_for_each_entry(list_loop, list) {
- if (strcmp(list_loop->name, name) == 0) {
- dbg(udev, "'%s' is already in the list\n", name);
- return list_loop;
+struct udev_list_entry *udev_list_entry_add(struct udev *udev, struct udev_list_node *list,
+ const char *name, const char *value,
+ int unique, int sort)
+{
+ struct udev_list_entry *entry_loop = NULL;
+ struct udev_list_entry *entry_new;
+
+ if (unique)
+ udev_list_entry_foreach(entry_loop, udev_list_get_entry(list)) {
+ if (strcmp(entry_loop->name, name) == 0) {
+ dbg(udev, "'%s' is already in the list\n", name);
+ free(entry_loop->value);
+ if (value == NULL) {
+ entry_loop->value = NULL;
+ dbg(udev, "'%s' value unset\n", name);
+ return entry_loop;
+ }
+ entry_loop->value = strdup(value);
+ if (entry_loop->value == NULL)
+ return NULL;
+ dbg(udev, "'%s' value replaced with '%s'\n", name, value);
+ return entry_loop;
+ }