- munmap(buf, bufsize);
-}
-
-/* return number of chars until the next newline, skip escaped newline */
-size_t buf_get_line(const char *buf, size_t buflen, size_t cur)
-{
- int escape = 0;
- size_t count;
-
- for (count = cur; count < buflen; count++) {
- if (!escape && buf[count] == '\n')
- break;
-
- if (buf[count] == '\\')
- escape = 1;
- else
- escape = 0;
- }
-
- return count - cur;
-}
-
-void no_trailing_slash(char *path)
-{
- size_t len;
-
- len = strlen(path);
- while (len > 0 && path[len-1] == '/')
- path[--len] = '\0';
-}
-
-struct files {
- struct list_head list;
- char name[NAME_SIZE];
-};
-
-/* sort files in lexical order */
-static int file_list_insert(char *filename, struct list_head *file_list)
-{
- struct files *loop_file;
- struct files *new_file;
-
- list_for_each_entry(loop_file, file_list, list) {
- if (strcmp(loop_file->name, filename) > 0) {
- break;
+ 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;