[PATCH] RFC: all deleting all properties with a given key
[notmuch-archives.git] / be / 3e5fc1569bedaf45a6318aa4786396f28fe690
1 Return-Path: <too@guru.guru-group.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 1377F431E64\r
6         for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 02:31:27 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 0h68VCfmcbNo for <notmuch@notmuchmail.org>;\r
16         Mon, 30 Jan 2012 02:31:26 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])\r
18         by olra.theworths.org (Postfix) with ESMTP id 04FA6431FBC\r
19         for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 02:31:25 -0800 (PST)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id 698A068056; Mon, 30 Jan 2012 12:31:28 +0200 (EET)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [PATCH] moved _config_(get|set)_list () functions earlyer in the file\r
25 Date: Mon, 30 Jan 2012 12:31:25 +0200\r
26 Message-Id: <1327919485-15027-1-git-send-email-tomi.ollila@iki.fi>\r
27 X-Mailer: git-send-email 1.7.6.1\r
28 In-Reply-To: <4F22EA91.4020006@cs.rpi.edu>\r
29 References: <4F22EA91.4020006@cs.rpi.edu>\r
30 Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
31 X-BeenThere: notmuch@notmuchmail.org\r
32 X-Mailman-Version: 2.1.13\r
33 Precedence: list\r
34 List-Id: "Use and development of the notmuch mail system."\r
35         <notmuch.notmuchmail.org>\r
36 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
37         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
38 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
39 List-Post: <mailto:notmuch@notmuchmail.org>\r
40 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
41 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
43 X-List-Received-Date: Mon, 30 Jan 2012 10:31:27 -0000\r
44 \r
45 Moved static functions _config_get_list () and _config_set_list ()\r
46 closer to the beginning of file so that their definition is known\r
47 (without adding forward declarations) in upcoming changes.\r
48 ---\r
49 \r
50 This addresses Ethan's comments. Thanks.\r
51 \r
52 s/_notmuch_/_config_/ and changed 'in further work' to 'in upcoming\r
53 changes' -- 'changes' being more generic that 'patches'.\r
54  notmuch-config.c |   84 +++++++++++++++++++++++++++---------------------------\r
55  1 files changed, 42 insertions(+), 42 deletions(-)\r
56 \r
57 diff --git a/notmuch-config.c b/notmuch-config.c\r
58 index 0ded6d7..a124e34 100644\r
59 --- a/notmuch-config.c\r
60 +++ b/notmuch-config.c\r
61 @@ -467,6 +467,48 @@ notmuch_config_save (notmuch_config_t *config)\r
62      return 0;\r
63  }\r
64  \r
65 +static const char **\r
66 +_config_get_list (notmuch_config_t *config,\r
67 +                 const char *section, const char *key,\r
68 +                 const char ***outlist, size_t *list_length, size_t *ret_length)\r
69 +{\r
70 +    assert(outlist);\r
71 +\r
72 +    if (*outlist == NULL) {\r
73 +\r
74 +       char **inlist = g_key_file_get_string_list (config->key_file,\r
75 +                                            section, key, list_length, NULL);\r
76 +       if (inlist) {\r
77 +           unsigned int i;\r
78 +\r
79 +           *outlist = talloc_size (config, sizeof (char *) * (*list_length + 1));\r
80 +\r
81 +           for (i = 0; i < *list_length; i++)\r
82 +               (*outlist)[i] = talloc_strdup (*outlist, inlist[i]);\r
83 +\r
84 +           (*outlist)[i] = NULL;\r
85 +\r
86 +           g_strfreev (inlist);\r
87 +       }\r
88 +    }\r
89 +\r
90 +    if (ret_length)\r
91 +       *ret_length = *list_length;\r
92 +\r
93 +    return *outlist;\r
94 +}\r
95 +\r
96 +static void\r
97 +_config_set_list (notmuch_config_t *config,\r
98 +                 const char *group, const char *name,\r
99 +                 const char *list[],\r
100 +                 size_t length, const char ***config_var )\r
101 +{\r
102 +    g_key_file_set_string_list (config->key_file, group, name, list, length);\r
103 +    talloc_free (*config_var);\r
104 +    *config_var = NULL;\r
105 +}\r
106 +\r
107  const char *\r
108  notmuch_config_get_database_path (notmuch_config_t *config)\r
109  {\r
110 @@ -551,37 +593,6 @@ notmuch_config_set_user_primary_email (notmuch_config_t *config,\r
111      config->user_primary_email = NULL;\r
112  }\r
113  \r
114 -static const char **\r
115 -_config_get_list (notmuch_config_t *config,\r
116 -                 const char *section, const char *key,\r
117 -                 const char ***outlist, size_t *list_length, size_t *ret_length)\r
118 -{\r
119 -    assert(outlist);\r
120 -\r
121 -    if (*outlist == NULL) {\r
122 -\r
123 -       char **inlist = g_key_file_get_string_list (config->key_file,\r
124 -                                            section, key, list_length, NULL);\r
125 -       if (inlist) {\r
126 -           unsigned int i;\r
127 -\r
128 -           *outlist = talloc_size (config, sizeof (char *) * (*list_length + 1));\r
129 -\r
130 -           for (i = 0; i < *list_length; i++)\r
131 -               (*outlist)[i] = talloc_strdup (*outlist, inlist[i]);\r
132 -\r
133 -           (*outlist)[i] = NULL;\r
134 -\r
135 -           g_strfreev (inlist);\r
136 -       }\r
137 -    }\r
138 -\r
139 -    if (ret_length)\r
140 -       *ret_length = *list_length;\r
141 -\r
142 -    return *outlist;\r
143 -}\r
144 -\r
145  const char **\r
146  notmuch_config_get_user_other_email (notmuch_config_t *config,   size_t *length)\r
147  {\r
148 @@ -598,17 +609,6 @@ notmuch_config_get_new_tags (notmuch_config_t *config,   size_t *length)\r
149                              &(config->new_tags_length), length);\r
150  }\r
151  \r
152 -static void\r
153 -_config_set_list (notmuch_config_t *config,\r
154 -                 const char *group, const char *name,\r
155 -                 const char *list[],\r
156 -                 size_t length, const char ***config_var )\r
157 -{\r
158 -    g_key_file_set_string_list (config->key_file, group, name, list, length);\r
159 -    talloc_free (*config_var);\r
160 -    *config_var = NULL;\r
161 -}\r
162 -\r
163  void\r
164  notmuch_config_set_user_other_email (notmuch_config_t *config,\r
165                                      const char *list[],\r
166 -- \r
167 1.7.8.2\r
168 \r