1 Return-Path: <tomi.ollila@iki.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 6723C429E27
\r
6 for <notmuch@notmuchmail.org>; Tue, 13 Sep 2011 14:32:25 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\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 6ZNjiRMBJQ-i for <notmuch@notmuchmail.org>;
\r
16 Tue, 13 Sep 2011 14:32:24 -0700 (PDT)
\r
17 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])
\r
18 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 8BAAB431FB6
\r
21 for <notmuch@notmuchmail.org>; Tue, 13 Sep 2011 14:32:24 -0700 (PDT)
\r
22 Received: from localhost6.localdomain6 (entry3.nixu.fi [193.209.237.21])
\r
23 by taco2.nixu.fi (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id
\r
24 p8DLW8G2022252; Wed, 14 Sep 2011 00:32:14 +0300
\r
25 From: tomi.ollila@iki.fi
\r
26 To: notmuch@notmuchmail.org
\r
27 Subject: [PATCH 1/3] added function
\r
28 notmuch_talloc_g_key_file_get_string_list()
\r
29 Date: Wed, 14 Sep 2011 00:32:02 +0300
\r
30 Message-Id: <1315949524-4948-2-git-send-email-tomi.ollila@iki.fi>
\r
31 X-Mailer: git-send-email 1.7.3.4
\r
32 In-Reply-To: <1315949524-4948-1-git-send-email-tomi.ollila@iki.fi>
\r
33 References: <1315949524-4948-1-git-send-email-tomi.ollila@iki.fi>
\r
34 Cc: Tomi Ollila <tomi.ollila@iki.fi>
\r
35 X-BeenThere: notmuch@notmuchmail.org
\r
36 X-Mailman-Version: 2.1.13
\r
38 List-Id: "Use and development of the notmuch mail system."
\r
39 <notmuch.notmuchmail.org>
\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
41 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
43 List-Post: <mailto:notmuch@notmuchmail.org>
\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
47 X-List-Received-Date: Tue, 13 Sep 2011 21:32:25 -0000
\r
49 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
51 The function notmuch_talloc_g_key_file_get_string_list() wraps
\r
52 call to g_key_file_get_string_list() in a way that the returned
\r
53 string array is copied to talloc'd memory area. The returned
\r
54 pointer is itself also a talloc context, child of the context
\r
55 given as first argument.
\r
57 notmuch-config.c | 44 +++++++++++++++++++++++++++++++++++++++++---
\r
58 1 files changed, 41 insertions(+), 3 deletions(-)
\r
60 diff --git a/notmuch-config.c b/notmuch-config.c
\r
61 index 485fa72..706f481 100644
\r
62 --- a/notmuch-config.c
\r
63 +++ b/notmuch-config.c
\r
64 @@ -170,6 +170,44 @@ get_username_from_passwd_file (void *ctx)
\r
68 +/** XXX move to (not-yet-existent) notmuch-talloc.c, or somewhere */
\r
70 +notmuch_talloc_g_key_file_get_string_list (const void * ctx,
\r
71 + GKeyFile *key_file,
\r
72 + const gchar *group_name,
\r
78 + gchar ** strlist = g_key_file_get_string_list (key_file, group_name, key,
\r
84 + newlist = talloc_array (ctx, char *, l + 1);
\r
85 + if (newlist == NULL)
\r
87 + for (i = 0; i < l; i++) {
\r
88 + if ( (newlist[i] = talloc_strdup (newlist, strlist[i])) == NULL)
\r
91 + newlist[i] = NULL;
\r
92 + g_strfreev (strlist);
\r
99 + talloc_free (newlist);
\r
101 + g_strfreev (strlist);
\r
102 + *length = 0; /* like in g_key_file_get_string_list () */
\r
106 /* Open the named notmuch configuration file. If the filename is NULL,
\r
107 * the value of the environment variable $NOTMUCH_CONFIG will be used.
\r
108 * If $NOTMUCH_CONFIG is unset, the default configuration file
\r
109 @@ -229,7 +267,7 @@ notmuch_config_open (void *ctx,
\r
110 fprintf (stderr, "Out of memory.\n");
\r
115 talloc_set_destructor (config, notmuch_config_destructor);
\r
118 @@ -393,7 +431,7 @@ notmuch_config_open (void *ctx,
\r
121 /* Close the given notmuch_config_t object, freeing all resources.
\r
124 * Note: Any changes made to the configuration are *not* saved by this
\r
125 * function. To save changes, call notmuch_config_save before
\r
126 * notmuch_config_close.
\r
127 @@ -653,7 +691,7 @@ notmuch_config_command_get (void *ctx, char *item)
\r
128 } else if (strcmp(item, "user.other_email") == 0) {
\r
129 const char **other_email;
\r
133 other_email = notmuch_config_get_user_other_email (config, &length);
\r
134 for (i = 0; i < length; i++)
\r
135 printf ("%s\n", other_email[i]);
\r