]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Rename mailbox_list_index_node.name to raw_name
authorSiavash Tavakoli <siavash.tavakoli@open-xchange.com>
Fri, 26 Feb 2021 16:03:50 +0000 (16:03 +0000)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 16 Mar 2021 15:14:23 +0000 (15:14 +0000)
To make it clear that the string is unescaped raw value, rename from
generic "name" to "raw_name".

src/lib-storage/list/mailbox-list-index-iter.c
src/lib-storage/list/mailbox-list-index-sync.c
src/lib-storage/list/mailbox-list-index.c
src/lib-storage/list/mailbox-list-index.h
src/lib-storage/list/mailbox-list-notify-tree.c

index 8719af67bbaa45b024e1482832ffddb1a681b087..a8bea53d664f70b27873634d9015fee4f8cf410d 100644 (file)
@@ -82,7 +82,7 @@ mailbox_list_index_update_info(struct mailbox_list_index_iterate_context *ctx)
                str_append_c(ctx->path,
                             mailbox_list_get_hierarchy_sep(ctx->ctx.list));
        }
-       str_append(ctx->path, node->name);
+       str_append(ctx->path, node->raw_name);
 
        ctx->info.vname = mailbox_list_get_vname(ctx->ctx.list, str_c(ctx->path));
        ctx->info.flags = node->children != NULL ?
@@ -133,7 +133,7 @@ mailbox_list_index_update_next(struct mailbox_list_index_iterate_context *ctx,
        struct mailbox_list_index_node *node = ctx->next_node;
 
        if (!ctx->prefix_inbox_list && ctx->ctx.list->ns->prefix_len > 0 &&
-           strcmp(node->name, "INBOX") == 0 && node->parent == NULL &&
+           strcmp(node->raw_name, "INBOX") == 0 && node->parent == NULL &&
            node->children != NULL) {
                /* prefix/INBOX has children */
                ctx->prefix_inbox_list = TRUE;
@@ -147,7 +147,7 @@ mailbox_list_index_update_next(struct mailbox_list_index_iterate_context *ctx,
                while (node->next == NULL) {
                        node = node->parent;
                        if (node != NULL) {
-                               ctx->parent_len -= strlen(node->name);
+                               ctx->parent_len -= strlen(node->raw_name);
                                if (node->parent != NULL)
                                        ctx->parent_len--;
                        }
index ad5f98105b3476acaf8f2fcbeee89a7ecc287470..90318c83c7d4efdfe5e9bef9785afbbf9cd88479 100644 (file)
@@ -68,7 +68,7 @@ mailbox_list_index_node_add(struct mailbox_list_index_sync_context *ctx,
                MAILBOX_LIST_INDEX_FLAG_SYNC_EXISTS;
        /* we don't bother doing name deduplication here, even though it would
           be possible. */
-       node->name = dup_name = p_strdup(ctx->ilist->mailbox_pool, name);
+       node->raw_name = dup_name = p_strdup(ctx->ilist->mailbox_pool, name);
        node->name_id = ++ctx->ilist->highest_name_id;
        node->uid = ctx->next_uid++;
 
index 471424ddad6c716663a7e9ca04113d762505dca7..8069191bc9a1a54412e4d994bbe2deea40faee77 100644 (file)
@@ -118,7 +118,7 @@ mailbox_list_index_node_find_sibling(struct mailbox_list_index_node *node,
                                     const char *name)
 {
        while (node != NULL) {
-               if (strcmp(node->name, name) == 0)
+               if (strcmp(node->raw_name, name) == 0)
                        return node;
                node = node->next;
        }
@@ -172,7 +172,7 @@ void mailbox_list_index_node_get_path(const struct mailbox_list_index_node *node
                mailbox_list_index_node_get_path(node->parent, sep, str);
                str_append_c(str, sep);
        }
-       str_append(str, node->name);
+       str_append(str, node->raw_name);
 }
 
 void mailbox_list_index_node_unlink(struct mailbox_list_index *ilist,
@@ -255,7 +255,7 @@ mailbox_list_index_generate_name(struct mailbox_list_index *ilist,
        guid_128_generate(guid);
        name = p_strdup_printf(ilist->mailbox_pool, "%s%s", prefix,
                               guid_128_to_string(guid));
-       node->name = name;
+       node->raw_name = name;
        node->flags |= MAILBOX_LIST_INDEX_FLAG_CORRUPTED_NAME;
 
        hash_table_insert(ilist->mailbox_names,
@@ -268,13 +268,13 @@ static int mailbox_list_index_node_cmp(const struct mailbox_list_index_node *n1,
                                       const struct mailbox_list_index_node *n2)
 {
        return  n1->parent == n2->parent &&
-               strcmp(n1->name, n2->name) == 0 ? 0 : -1;
+               strcmp(n1->raw_name, n2->raw_name) == 0 ? 0 : -1;
 }
 
 static unsigned int
 mailbox_list_index_node_hash(const struct mailbox_list_index_node *node)
 {
-       return str_hash(node->name) ^
+       return str_hash(node->raw_name) ^
                POINTER_CAST_TO(node->parent, unsigned int);
 }
 
@@ -333,9 +333,9 @@ static int mailbox_list_index_parse_records(struct mailbox_list_index *ilist,
                        node->name_id = ++ilist->highest_name_id;
                        node->corrupted_ext = TRUE;
                }
-               node->name = hash_table_lookup(ilist->mailbox_names,
+               node->raw_name = hash_table_lookup(ilist->mailbox_names,
                                               POINTER_CAST(irec->name_id));
-               if (node->name == NULL) {
+               if (node->raw_name == NULL) {
                        *error_r = t_strdup_printf(
                                "name_id=%u not in index header", irec->name_id);
                        if (ilist->has_backing_store)
@@ -352,7 +352,7 @@ static int mailbox_list_index_parse_records(struct mailbox_list_index *ilist,
                        node->flags |= MAILBOX_LIST_INDEX_FLAG_NOSELECT;
                        *error_r = t_strdup_printf(
                                "mailbox '%s' (uid=%u) is missing GUID - "
-                               "marking it non-selectable", node->name, node->uid);
+                               "marking it non-selectable", node->raw_name, node->uid);
                        node->corrupted_flags = TRUE;
                }
                if (!ilist->has_backing_store && !guid_128_is_empty(irec->guid) &&
@@ -361,7 +361,7 @@ static int mailbox_list_index_parse_records(struct mailbox_list_index *ilist,
                        node->flags &= ENUM_NEGATE(MAILBOX_LIST_INDEX_FLAG_NONEXISTENT | MAILBOX_LIST_INDEX_FLAG_NOSELECT);
                        *error_r = t_strdup_printf(
                                "non-selectable mailbox '%s' (uid=%u) already has GUID - "
-                               "marking it selectable", node->name, node->uid);
+                               "marking it selectable", node->raw_name, node->uid);
                        node->corrupted_flags = TRUE;
                }
 
@@ -398,7 +398,7 @@ static int mailbox_list_index_parse_records(struct mailbox_list_index *ilist,
                        } else if (node_has_parent(parent, node)) {
                                *error_r = t_strdup_printf(
                                        "parent_uid=%u loops to node itself (%s)",
-                                       uid, node->name);
+                                       uid, node->raw_name);
                                if (ilist->has_backing_store)
                                        break;
                                /* just place it under the root */
@@ -409,18 +409,18 @@ static int mailbox_list_index_parse_records(struct mailbox_list_index *ilist,
                                parent->children = node;
                                continue;
                        }
-               } else if (strcasecmp(node->name, "INBOX") == 0) {
+               } else if (strcasecmp(node->raw_name, "INBOX") == 0) {
                        ilist->rebuild_on_missing_inbox = FALSE;
                }
                if (hash_table_lookup(duplicate_hash, node) == NULL)
                        hash_table_insert(duplicate_hash, node, node);
                else {
-                       const char *old_name = node->name;
+                       const char *old_name = node->raw_name;
 
                        if (ilist->has_backing_store) {
                                *error_r = t_strdup_printf(
                                        "Duplicate mailbox '%s' in index",
-                                       node->name);
+                                       node->raw_name);
                                break;
                        }
 
@@ -429,10 +429,10 @@ static int mailbox_list_index_parse_records(struct mailbox_list_index *ilist,
                        node->corrupted_ext = TRUE;
                        node->name_id = ++ilist->highest_name_id;
                        mailbox_list_index_generate_name(ilist, node,
-                               t_strconcat(node->name, "-duplicate-", NULL));
+                               t_strconcat(node->raw_name, "-duplicate-", NULL));
                        *error_r = t_strdup_printf(
                                "Duplicate mailbox '%s' in index, renaming to %s",
-                               old_name, node->name);
+                               old_name, node->raw_name);
                }
                node->next = ilist->mailbox_tree;
                ilist->mailbox_tree = node;
index 427c431a0442f05d59481a7b3666ec14ba867618..1fab30e4b326205606f12fbca5583e9618cf8f1e 100644 (file)
@@ -93,7 +93,7 @@ struct mailbox_list_index_node {
        bool corrupted_ext;
        /* flags are corrupted on disk - need to update it */
        bool corrupted_flags;
-       const char *name;
+       const char *raw_name;
 };
 
 struct mailbox_list_index {
index 956cec58962dcc9d7522bf47f44605492a598a87..2ba89aab18907c1d82a6b58072c1ec410ca8a189 100644 (file)
@@ -47,7 +47,7 @@ mailbox_list_notify_node_build(struct mailbox_list_notify_tree *tree,
        size_t prefix_len;
        bool created;
 
-       str_append(path, index_node->name);
+       str_append(path, index_node->raw_name);
 
        node = mailbox_tree_get(tree->mailboxes, str_c(path), &created);
        nnode = (struct mailbox_notify_node *)node;