Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / e7 / 83fe223a54fc07ccdd16fab806a5f30ecd7f8c
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 114D9431FC0\r
6         for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 02:12:04 -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 iL4C7Z46cBaL for <notmuch@notmuchmail.org>;\r
16         Thu, 26 Jan 2012 02:12:02 -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 93EF1431FAE\r
19         for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 02:12:02 -0800 (PST)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id CA9CF68056; Thu, 26 Jan 2012 12:12:00 +0200 (EET)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [PATCH 1/2] moved _notmuch_get_list () and _notmuch_set_list () up in\r
25         file\r
26 Date: Thu, 26 Jan 2012 12:11:57 +0200\r
27 Message-Id: <1327572718-13411-1-git-send-email-tomi.ollila@iki.fi>\r
28 X-Mailer: git-send-email 1.7.6.1\r
29 In-Reply-To: <8762g0sj6f.fsf@praet.org>\r
30 References: <8762g0sj6f.fsf@praet.org>\r
31 Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.13\r
34 Precedence: list\r
35 List-Id: "Use and development of the notmuch mail system."\r
36         <notmuch.notmuchmail.org>\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
38         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
40 List-Post: <mailto:notmuch@notmuchmail.org>\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
44 X-List-Received-Date: Thu, 26 Jan 2012 10:12:04 -0000\r
45 \r
46 Moved _notmuch_get_list () and _notmuch_set_list () to a location\r
47 in notmuch-config.c so that new functions that will be located \r
48 before the old location of those functions can also use these.\r
49 ---\r
50 \r
51 This patch is independent of the next one (just required by it)\r
52 and can (should) be pushed early.\r
53 \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.6.4\r
168 \r