Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / 95 / a72d7b950cf444e29cec5de6a72569077178a9
1 Return-Path: <ethan.glasser.camp@gmail.com>\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 7A984431FB6\r
6         for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:43:10 -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: 1.061\r
10 X-Spam-Level: *\r
11 X-Spam-Status: No, score=1.061 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.246,\r
14         RCVD_IN_DNSWL_LOW=-0.7, 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 zc7qx8WG8fMo for <notmuch@notmuchmail.org>;\r
18         Mon, 25 Jun 2012 13:43:10 -0700 (PDT)\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
20         [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id A39F6431FAF\r
23         for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:43:09 -0700 (PDT)\r
24 Received: by mail-we0-f181.google.com with SMTP id j55so3641437wer.26\r
25         for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:43:09 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=Z20noZo9CmdhF3xNEx6AIp1+NTNjmVStMvabHH2Ivhg=;\r
29         b=wFmQDjRxxF3iz8LUddnW6kGLgwMGqAhgH/NcH1lyacAO/GneFMZcTpJwVFKauw4Q9n\r
30         D/6Lu8HHV/QW+UqGeGMr9658BBx1+/UtZ7Qr9j2cyU4pZWwA/KePn0hBOxqPBq4E8SXK\r
31         G6L9HsNqlesxuIbnJcFU0a1M7NLpOJZv5FNg8kXX1woTNPAp0T4F+stw9XBr2APWfOLc\r
32         oymhnXDHDgThzDlTXlJTol/O2WMcrbnMcZr89ouYEGwv9VPTHFtLvef7+xnmhWf3zDes\r
33         /gqsZrAKIdRYEc/k3zSErE3Fm/DU+2kYBW2gM5Tgr/6LToRxL+mqzS8+/Ae1Kz79ogc4\r
34         DITg==\r
35 Received: by 10.180.83.196 with SMTP id s4mr27101743wiy.15.1340656989241;\r
36         Mon, 25 Jun 2012 13:43:09 -0700 (PDT)\r
37 Received: from localhost ([195.24.209.21])\r
38         by mx.google.com with ESMTPS id fu8sm18745841wib.5.2012.06.25.13.42.58\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Mon, 25 Jun 2012 13:43:08 -0700 (PDT)\r
41 From: Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [RFC PATCH 03/14] mailstore can read from maildir: URLs\r
44 Date: Mon, 25 Jun 2012 16:41:28 -0400\r
45 Message-Id: <1340656899-5644-4-git-send-email-ethan@betacantrips.com>\r
46 X-Mailer: git-send-email 1.7.9.5\r
47 In-Reply-To: <1340656899-5644-1-git-send-email-ethan@betacantrips.com>\r
48 References: <1340656899-5644-1-git-send-email-ethan@betacantrips.com>\r
49 X-Mailman-Approved-At: Tue, 26 Jun 2012 03:51:54 -0700\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Mon, 25 Jun 2012 20:43:10 -0000\r
63 \r
64 No code uses this yet.\r
65 \r
66 Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>\r
67 ---\r
68  lib/mailstore.c |   37 ++++++++++++++++++++++++++++++++++++-\r
69  1 file changed, 36 insertions(+), 1 deletion(-)\r
70 \r
71 diff --git a/lib/mailstore.c b/lib/mailstore.c\r
72 index 48acd47..ae02c12 100644\r
73 --- a/lib/mailstore.c\r
74 +++ b/lib/mailstore.c\r
75 @@ -17,14 +17,49 @@\r
76   *\r
77   * Author: Carl Worth <cworth@cworth.org>\r
78   */\r
79 +#include <uriparser/Uri.h>\r
80  #include <stdio.h>\r
81  \r
82  #include "notmuch-private.h"\r
83  \r
84 +static FILE *\r
85 +notmuch_mailstore_basic_open (const char *filename)\r
86 +{\r
87 +    return fopen (filename, "r");\r
88 +}\r
89 +\r
90  FILE *\r
91  notmuch_mailstore_open (const char *filename)\r
92  {\r
93 -    return fopen (filename, "r");\r
94 +    FILE *ret = NULL;\r
95 +    UriUriA parsed;\r
96 +    UriParserStateA state;\r
97 +    state.uri = &parsed;\r
98 +    if (uriParseUriA (&state, filename) != URI_SUCCESS) {\r
99 +        /* Failure. Fall back to fopen and hope for the best. */\r
100 +        ret = notmuch_mailstore_basic_open (filename);\r
101 +        goto DONE;\r
102 +    }\r
103 +\r
104 +    if (parsed.scheme.first == NULL) {\r
105 +        /* No scheme. Probably not really a URL but just an ordinary filename.\r
106 +         * Fall back to fopen for backwards compatibility. */\r
107 +        ret = notmuch_mailstore_basic_open (filename);\r
108 +        goto DONE;\r
109 +    }\r
110 +\r
111 +    if (0 == strncmp (parsed.scheme.first, "maildir",\r
112 +                      parsed.scheme.afterLast-parsed.scheme.first)) {\r
113 +        /* Maildir URI of the form maildir:///path/to/file.\r
114 +         * We want to fopen("/path/to/file").\r
115 +         * pathHead starts at "path/to/file". */\r
116 +        ret = notmuch_mailstore_basic_open (parsed.pathHead->text.first - 1);\r
117 +        goto DONE;\r
118 +    }\r
119 +\r
120 +DONE:\r
121 +    uriFreeUriMembersA (&parsed);\r
122 +    return ret;\r
123  }\r
124  \r
125  int\r
126 -- \r
127 1.7.9.5\r
128 \r