[PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 53 / 45012626801f22531136105c565c733e5bb332
1 Return-Path: <glasse@cs.rpi.edu>\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 BA90B429E4D\r
6         for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:13:16 -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.54\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.54 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         RCVD_IN_BL_SPAMCOP_NET=1.246, RCVD_IN_DNSWL_MED=-2.3,\r
14         RCVD_IN_SORBS_WEB=0.614] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id 7QlhXPbf2Al2 for <notmuch@notmuchmail.org>;\r
18         Wed, 15 Feb 2012 14:13:13 -0800 (PST)\r
19 Received: from cliffclavin.cs.rpi.edu (cliffclavin.cs.rpi.edu\r
20  [128.113.126.25])      (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
21         (No client certificate requested)       by olra.theworths.org (Postfix) with ESMTPS\r
22  id 01E6D429E48 for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:13:12 -0800\r
23  (PST)\r
24 X-Hash:\r
25  S|a2909afab59f13fda5255d225e711418d0302a88|16748bbaf3acbf9f453a2d52848ce009\r
26 X-Countries: Cameroon, United States\r
27 X-SMTP-From: accepted <glasse@cs.rpi.edu> [195.24.209.20] [195.24.209.20]\r
28         (localhost) {Cameroon}\r
29 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=cs.rpi.edu; h=from\r
30         :to:cc:subject:date:message-id:in-reply-to:references; s=\r
31         default; i=glasse@cs.rpi.edu; t=1329343991; x=1329948791; l=4398;\r
32         bh=5+o6UHFRfrHjxJ956HhG8NvJO+A=; b=sDhJAIuW1pOJg/8HeFT6RTo\r
33         TnXPJ1uHI2FTUhINON/hfIxlDcK9h4vzJ50owdFnT8p3z8VQwsmOl4PfJgYYeAqg\r
34         NMkSs+J7aamb6dfO5zcQnm4tDysfFYtHL0acttDy/oVtqAO/+VNfMk053iHcRms+\r
35         PiS54SvuwMiaCDH0mkt4=\r
36 DomainKey-Signature: a=rsa-sha1; c=nofws; d=cs.rpi.edu; h=from:to:cc\r
37         :subject:date:message-id:in-reply-to:references; q=dns; s=\r
38         default; b=K5NQY77/tVz51x/iW5/NG/0HAjejEgiy4hGZNK8S4R2hgehhcyle4\r
39         +gqp3cvqOPK5rdPMlEdbC1ZjqsnGmulh7HL/of2oy+STcTecAfXDQjjGXXeQ8XGG\r
40         hAYt/CR2Yj/dQtriNLKJG9kDc+RfraLQq9PvoWz25++YcXVInK6S3o=\r
41 X-Spam-Info: -2.7; ALL_TRUSTED,AWL,BAYES_00\r
42 X-Spam-Scanned-By: cliffclavin.cs.rpi.edu using SpamAssassin 3.2.5 (hard limit\r
43         15)\r
44 Authentication-Results: cliffclavin.cs.rpi.edu;\r
45         DKIM=neutral (none) header.from=glasse@cs.rpi.edu;\r
46         SPF=neutral (mfrom;\r
47         Mechanism '?all' matched) smtp.mail=glasse@cs.rpi.edu\r
48 X-Auth-Passed: cliffclavin.cs.rpi.edu:q1FMCjUm008878 Auth:glasse\r
49 X-Virus-Scanned-By: cliffclavin.cs.rpi.edu\r
50 Received: from localhost ([195.24.209.20]) (authenticated bits=0)\r
51         by cliffclavin.cs.rpi.edu (8.14.3/8.14.3) with ESMTP id q1FMCjUm008878\r
52         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO);\r
53         Wed, 15 Feb 2012 17:12:56 -0500 (EST)\r
54         (envelope-from glasse@cs.rpi.edu)\r
55 From: Ethan Glasser-Camp <glasse@cs.rpi.edu>\r
56 To: notmuch@notmuchmail.org\r
57 Subject: [RFC PATCH 12/13] Close files using notmuch_mailstore_close instead\r
58         of fclose\r
59 Date: Wed, 15 Feb 2012 17:02:05 -0500\r
60 Message-Id: <1329343326-16410-13-git-send-email-glasse@cs.rpi.edu>\r
61 X-Mailer: git-send-email 1.7.5.4\r
62 In-Reply-To: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>\r
63 References: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>\r
64 X-Scanned-By: MIMEDefang 2.67 on 128.113.126.25\r
65 Cc: Ethan Glasser-Camp <ethan@betacantrips.com>\r
66 X-BeenThere: notmuch@notmuchmail.org\r
67 X-Mailman-Version: 2.1.13\r
68 Precedence: list\r
69 List-Id: "Use and development of the notmuch mail system."\r
70         <notmuch.notmuchmail.org>\r
71 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
72         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
73 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
74 List-Post: <mailto:notmuch@notmuchmail.org>\r
75 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
76 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
77         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
78 X-List-Received-Date: Wed, 15 Feb 2012 22:13:16 -0000\r
79 \r
80 From: Ethan Glasser-Camp <ethan@betacantrips.com>\r
81 \r
82 This requires a little bit of juggling in lib/sha1.c. Wrapper\r
83 functions provide the FILE*. Instead of closing the file immediately\r
84 ourselves, we let the wrapper functions close it.\r
85 \r
86 Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>\r
87 ---\r
88  lib/message-file.c |    6 ++++--\r
89  lib/sha1.c         |   14 ++++++++------\r
90  mime-node.c        |    4 +++-\r
91  notmuch-show.c     |    8 ++++----\r
92  4 files changed, 19 insertions(+), 13 deletions(-)\r
93 \r
94 diff --git a/lib/message-file.c b/lib/message-file.c\r
95 index 61f4d04..51c77f9 100644\r
96 --- a/lib/message-file.c\r
97 +++ b/lib/message-file.c\r
98 @@ -34,6 +34,7 @@ typedef struct {\r
99  \r
100  struct _notmuch_message_file {\r
101      /* File object */\r
102 +    notmuch_mailstore_t *mailstore;\r
103      FILE *file;\r
104  \r
105      /* Header storage */\r
106 @@ -86,7 +87,7 @@ _notmuch_message_file_destructor (notmuch_message_file_t *message)\r
107         g_hash_table_destroy (message->headers);\r
108  \r
109      if (message->file)\r
110 -       fclose (message->file);\r
111 +       notmuch_mailstore_close (message->mailstore, message->file);\r
112  \r
113      return 0;\r
114  }\r
115 @@ -105,6 +106,7 @@ _notmuch_message_file_open_ctx (void *ctx, notmuch_mailstore_t *mailstore,\r
116  \r
117      talloc_set_destructor (message, _notmuch_message_file_destructor);\r
118  \r
119 +    message->mailstore = mailstore;\r
120      message->file = notmuch_mailstore_open (mailstore, filename);\r
121      if (message->file == NULL)\r
122         goto FAIL;\r
123 @@ -363,7 +365,7 @@ notmuch_message_file_get_header (notmuch_message_file_t *message,\r
124      }\r
125  \r
126      if (message->parsing_finished) {\r
127 -        fclose (message->file);\r
128 +       notmuch_mailstore_close (message->mailstore, message->file);\r
129          message->file = NULL;\r
130      }\r
131  \r
132 diff --git a/lib/sha1.c b/lib/sha1.c\r
133 index ea25999..4266720 100644\r
134 --- a/lib/sha1.c\r
135 +++ b/lib/sha1.c\r
136 @@ -87,7 +87,6 @@ _notmuch_sha1_of_filep (FILE *file)\r
137             if (feof (file)) {\r
138                 break;\r
139             } else if (ferror (file)) {\r
140 -               fclose (file);\r
141                 return NULL;\r
142             }\r
143         } else {\r
144 @@ -99,8 +98,6 @@ _notmuch_sha1_of_filep (FILE *file)\r
145  \r
146      result = _hex_of_sha1_digest (digest);\r
147  \r
148 -    fclose (file);\r
149 -\r
150      return result;\r
151  }\r
152  \r
153 @@ -117,9 +114,12 @@ char *\r
154  notmuch_sha1_of_file (const char *filename)\r
155  {\r
156      FILE *file;\r
157 +    char *ret;\r
158  \r
159      file = fopen (filename, "r");\r
160 -    return _notmuch_sha1_of_filep (file);\r
161 +    ret = _notmuch_sha1_of_filep (file);\r
162 +    fclose (file);\r
163 +    return ret;\r
164  }\r
165  \r
166  /* Create a hexadecimal string version of the SHA-1 digest of the\r
167 @@ -135,7 +135,9 @@ char *\r
168  notmuch_sha1_of_message (notmuch_mailstore_t *mailstore, const char *filename)\r
169  {\r
170      FILE *file;\r
171 -\r
172 +    char *ret;\r
173      file = notmuch_mailstore_open (mailstore, filename);\r
174 -    return _notmuch_sha1_of_filep (file);\r
175 +    ret = _notmuch_sha1_of_filep (file);\r
176 +    notmuch_mailstore_close (mailstore, file);\r
177 +    return ret;\r
178  }\r
179 diff --git a/mime-node.c b/mime-node.c\r
180 index 856fc3b..db37189 100644\r
181 --- a/mime-node.c\r
182 +++ b/mime-node.c\r
183 @@ -27,6 +27,7 @@\r
184  typedef struct mime_node_context {\r
185      /* Per-message resources.  These are allocated internally and must\r
186       * be destroyed. */\r
187 +    notmuch_mailstore_t *mailstore;\r
188      FILE *file;\r
189      GMimeStream *stream;\r
190      GMimeParser *parser;\r
191 @@ -54,7 +55,7 @@ _mime_node_context_free (mime_node_context_t *res)\r
192         g_object_unref (res->stream);\r
193  \r
194      if (res->file)\r
195 -       fclose (res->file);\r
196 +       notmuch_mailstore_close (res->mailstore, res->file);\r
197  \r
198      return 0;\r
199  }\r
200 @@ -90,6 +91,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,\r
201      }\r
202      talloc_set_destructor (mctx, _mime_node_context_free);\r
203  \r
204 +    mctx->mailstore = mailstore;\r
205      mctx->file = notmuch_mailstore_open (mailstore, filename);\r
206      if (! mctx->file) {\r
207         fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno));\r
208 diff --git a/notmuch-show.c b/notmuch-show.c\r
209 index 0d2a246..2e8e4c9 100644\r
210 --- a/notmuch-show.c\r
211 +++ b/notmuch-show.c\r
212 @@ -309,7 +309,7 @@ format_message_mbox (const void *ctx,\r
213  \r
214      printf ("\n");\r
215  \r
216 -    fclose (file);\r
217 +    notmuch_mailstore_close (mailstore, file);\r
218  }\r
219  \r
220  static void\r
221 @@ -966,18 +966,18 @@ do_show_single (void *ctx,\r
222             size = fread (buf, 1, sizeof (buf), file);\r
223             if (ferror (file)) {\r
224                 fprintf (stderr, "Error: Read failed from %s\n", filename);\r
225 -               fclose (file);\r
226 +               notmuch_mailstore_close (mailstore, file);\r
227                 return 1;\r
228             }\r
229  \r
230             if (fwrite (buf, size, 1, stdout) != 1) {\r
231                 fprintf (stderr, "Error: Write failed\n");\r
232 -               fclose (file);\r
233 +               notmuch_mailstore_close (mailstore, file);\r
234                 return 1;\r
235             }\r
236         }\r
237  \r
238 -       fclose (file);\r
239 +       notmuch_mailstore_close (mailstore, file);\r
240  \r
241      } else {\r
242  \r
243 -- \r
244 1.7.5.4\r
245 \r