Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 03 / 49caaccdefc1ea80db9dca660e4d9299ed9f7f
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 677E1429E27\r
6         for <notmuch@notmuchmail.org>; Tue, 24 Mar 2015 06:21:53 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 2.438\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 qiNPULoH3AwI for <notmuch@notmuchmail.org>;\r
16         Tue, 24 Mar 2015 06:21:51 -0700 (PDT)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18         [87.98.215.224])\r
19         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id E853E429E32\r
22         for <notmuch@notmuchmail.org>; Tue, 24 Mar 2015 06:21:40 -0700 (PDT)\r
23 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
24         4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
25         id 1YaOlO-0000pv-GQ; Tue, 24 Mar 2015 13:20:58 +0000\r
26 Received: (nullmailer pid 32642 invoked by uid 1000); Tue, 24 Mar 2015\r
27         13:19:47 -0000\r
28 From: David Bremner <david@tethera.net>\r
29 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
30 Subject: [Patch v5 8/8] lib: eliminate fprintf from _notmuch_message_file_open\r
31 Date: Tue, 24 Mar 2015 09:19:46 -0400\r
32 Message-Id: <1427203186-32194-8-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 2.1.4\r
34 In-Reply-To: <1427203186-32194-1-git-send-email-david@tethera.net>\r
35 References: <1426352554-4383-10-git-send-email-david@tethera.net>\r
36         <1427203186-32194-1-git-send-email-david@tethera.net>\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Tue, 24 Mar 2015 13:21:53 -0000\r
50 \r
51 You may wonder why _notmuch_message_file_open_ctx has two parameters.\r
52 This is because we need sometime to use a ctx which is a\r
53 notmuch_message_t. While we could get the database from this, there is\r
54 no easy way in C to tell type we are getting.\r
55 ---\r
56  lib/database.cc       |  2 +-\r
57  lib/message-file.c    | 11 +++++++----\r
58  lib/message.cc        |  3 ++-\r
59  lib/notmuch-private.h |  5 +++--\r
60  4 files changed, 13 insertions(+), 8 deletions(-)\r
61 \r
62 diff --git a/lib/database.cc b/lib/database.cc\r
63 index 155b5aa..85054df 100644\r
64 --- a/lib/database.cc\r
65 +++ b/lib/database.cc\r
66 @@ -2292,7 +2292,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,\r
67      if (ret)\r
68         return ret;\r
69  \r
70 -    message_file = _notmuch_message_file_open (filename);\r
71 +    message_file = _notmuch_message_file_open (notmuch, filename);\r
72      if (message_file == NULL)\r
73         return NOTMUCH_STATUS_FILE_ERROR;\r
74  \r
75 diff --git a/lib/message-file.c b/lib/message-file.c\r
76 index a41d9ad..8ac96e8 100644\r
77 --- a/lib/message-file.c\r
78 +++ b/lib/message-file.c\r
79 @@ -76,7 +76,8 @@ _notmuch_message_file_destructor (notmuch_message_file_t *message)\r
80  /* Create a new notmuch_message_file_t for 'filename' with 'ctx' as\r
81   * the talloc owner. */\r
82  notmuch_message_file_t *\r
83 -_notmuch_message_file_open_ctx (void *ctx, const char *filename)\r
84 +_notmuch_message_file_open_ctx (notmuch_database_t *notmuch,\r
85 +                               void *ctx, const char *filename)\r
86  {\r
87      notmuch_message_file_t *message;\r
88  \r
89 @@ -98,16 +99,18 @@ _notmuch_message_file_open_ctx (void *ctx, const char *filename)\r
90      return message;\r
91  \r
92    FAIL:\r
93 -    fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno));\r
94 +    _notmuch_database_log (notmuch, "Error opening %s: %s\n",\r
95 +                         filename, strerror (errno));\r
96      _notmuch_message_file_close (message);\r
97  \r
98      return NULL;\r
99  }\r
100  \r
101  notmuch_message_file_t *\r
102 -_notmuch_message_file_open (const char *filename)\r
103 +_notmuch_message_file_open (notmuch_database_t *notmuch,\r
104 +                           const char *filename)\r
105  {\r
106 -    return _notmuch_message_file_open_ctx (NULL, filename);\r
107 +    return _notmuch_message_file_open_ctx (notmuch, NULL, filename);\r
108  }\r
109  \r
110  void\r
111 diff --git a/lib/message.cc b/lib/message.cc\r
112 index a8ca988..5bc7aff 100644\r
113 --- a/lib/message.cc\r
114 +++ b/lib/message.cc\r
115 @@ -437,7 +437,8 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message)\r
116      if (unlikely (filename == NULL))\r
117         return;\r
118  \r
119 -    message->message_file = _notmuch_message_file_open_ctx (message, filename);\r
120 +    message->message_file = _notmuch_message_file_open_ctx (\r
121 +       _notmuch_message_database (message), message, filename);\r
122  }\r
123  \r
124  const char *\r
125 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
126 index dc58a2f..cc9ce12 100644\r
127 --- a/lib/notmuch-private.h\r
128 +++ b/lib/notmuch-private.h\r
129 @@ -358,11 +358,12 @@ typedef struct _notmuch_message_file notmuch_message_file_t;\r
130   * Returns NULL if any error occurs.\r
131   */\r
132  notmuch_message_file_t *\r
133 -_notmuch_message_file_open (const char *filename);\r
134 +_notmuch_message_file_open (notmuch_database_t *notmuch, const char *filename);\r
135  \r
136  /* Like notmuch_message_file_open but with 'ctx' as the talloc owner. */\r
137  notmuch_message_file_t *\r
138 -_notmuch_message_file_open_ctx (void *ctx, const char *filename);\r
139 +_notmuch_message_file_open_ctx (notmuch_database_t *notmuch,\r
140 +                               void *ctx, const char *filename);\r
141  \r
142  /* Close a notmuch message previously opened with notmuch_message_open. */\r
143  void\r
144 -- \r
145 2.1.4\r
146 \r