Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 61 / 7d8bb2bfdf5af59006105386c7d464d5f83310
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 7CF98429E36\r
6         for <notmuch@notmuchmail.org>; Fri, 27 Mar 2015 15:14:25 -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 s6QGJSwTY0zt for <notmuch@notmuchmail.org>;\r
16         Fri, 27 Mar 2015 15:14:23 -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 4F44F429E35\r
22         for <notmuch@notmuchmail.org>; Fri, 27 Mar 2015 15:14:23 -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 1YbcVa-0000FF-98; Fri, 27 Mar 2015 22:13:42 +0000\r
26 Received: (nullmailer pid 1821 invoked by uid 1000); Fri, 27 Mar 2015\r
27         22:12:15 -0000\r
28 From: David Bremner <david@tethera.net>\r
29 To: notmuch@notmuchmail.org\r
30 Subject: [Patch v6 8/8] lib: eliminate fprintf from _notmuch_message_file_open\r
31 Date: Fri, 27 Mar 2015 23:12:00 +0100\r
32 Message-Id: <1427494320-1483-9-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 2.1.4\r
34 In-Reply-To: <1427494320-1483-1-git-send-email-david@tethera.net>\r
35 References: <1427494320-1483-1-git-send-email-david@tethera.net>\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.13\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40         <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Fri, 27 Mar 2015 22:14:25 -0000\r
49 \r
50 You may wonder why _notmuch_message_file_open_ctx has two parameters.\r
51 This is because we need sometime to use a ctx which is a\r
52 notmuch_message_t. While we could get the database from this, there is\r
53 no easy way in C to tell type we are getting.\r
54 ---\r
55  lib/database.cc       |  2 +-\r
56  lib/message-file.c    | 11 +++++++----\r
57  lib/message.cc        |  3 ++-\r
58  lib/notmuch-private.h |  5 +++--\r
59  4 files changed, 13 insertions(+), 8 deletions(-)\r
60 \r
61 diff --git a/lib/database.cc b/lib/database.cc\r
62 index e40674a..9f66b5f 100644\r
63 --- a/lib/database.cc\r
64 +++ b/lib/database.cc\r
65 @@ -2307,7 +2307,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,\r
66      if (ret)\r
67         return ret;\r
68  \r
69 -    message_file = _notmuch_message_file_open (filename);\r
70 +    message_file = _notmuch_message_file_open (notmuch, filename);\r
71      if (message_file == NULL)\r
72         return NOTMUCH_STATUS_FILE_ERROR;\r
73  \r
74 diff --git a/lib/message-file.c b/lib/message-file.c\r
75 index a41d9ad..8ac96e8 100644\r
76 --- a/lib/message-file.c\r
77 +++ b/lib/message-file.c\r
78 @@ -76,7 +76,8 @@ _notmuch_message_file_destructor (notmuch_message_file_t *message)\r
79  /* Create a new notmuch_message_file_t for 'filename' with 'ctx' as\r
80   * the talloc owner. */\r
81  notmuch_message_file_t *\r
82 -_notmuch_message_file_open_ctx (void *ctx, const char *filename)\r
83 +_notmuch_message_file_open_ctx (notmuch_database_t *notmuch,\r
84 +                               void *ctx, const char *filename)\r
85  {\r
86      notmuch_message_file_t *message;\r
87  \r
88 @@ -98,16 +99,18 @@ _notmuch_message_file_open_ctx (void *ctx, const char *filename)\r
89      return message;\r
90  \r
91    FAIL:\r
92 -    fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno));\r
93 +    _notmuch_database_log (notmuch, "Error opening %s: %s\n",\r
94 +                         filename, strerror (errno));\r
95      _notmuch_message_file_close (message);\r
96  \r
97      return NULL;\r
98  }\r
99  \r
100  notmuch_message_file_t *\r
101 -_notmuch_message_file_open (const char *filename)\r
102 +_notmuch_message_file_open (notmuch_database_t *notmuch,\r
103 +                           const char *filename)\r
104  {\r
105 -    return _notmuch_message_file_open_ctx (NULL, filename);\r
106 +    return _notmuch_message_file_open_ctx (notmuch, NULL, filename);\r
107  }\r
108  \r
109  void\r
110 diff --git a/lib/message.cc b/lib/message.cc\r
111 index a8ca988..5bc7aff 100644\r
112 --- a/lib/message.cc\r
113 +++ b/lib/message.cc\r
114 @@ -437,7 +437,8 @@ _notmuch_message_ensure_message_file (notmuch_message_t *message)\r
115      if (unlikely (filename == NULL))\r
116         return;\r
117  \r
118 -    message->message_file = _notmuch_message_file_open_ctx (message, filename);\r
119 +    message->message_file = _notmuch_message_file_open_ctx (\r
120 +       _notmuch_message_database (message), message, filename);\r
121  }\r
122  \r
123  const char *\r
124 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
125 index dc58a2f..cc9ce12 100644\r
126 --- a/lib/notmuch-private.h\r
127 +++ b/lib/notmuch-private.h\r
128 @@ -358,11 +358,12 @@ typedef struct _notmuch_message_file notmuch_message_file_t;\r
129   * Returns NULL if any error occurs.\r
130   */\r
131  notmuch_message_file_t *\r
132 -_notmuch_message_file_open (const char *filename);\r
133 +_notmuch_message_file_open (notmuch_database_t *notmuch, const char *filename);\r
134  \r
135  /* Like notmuch_message_file_open but with 'ctx' as the talloc owner. */\r
136  notmuch_message_file_t *\r
137 -_notmuch_message_file_open_ctx (void *ctx, const char *filename);\r
138 +_notmuch_message_file_open_ctx (notmuch_database_t *notmuch,\r
139 +                               void *ctx, const char *filename);\r
140  \r
141  /* Close a notmuch message previously opened with notmuch_message_open. */\r
142  void\r
143 -- \r
144 2.1.4\r
145 \r