[RFC PATCH 03/14] mailstore can read from maildir: URLs
authorEthan Glasser-Camp <ethan.glasser.camp@gmail.com>
Mon, 25 Jun 2012 20:41:28 +0000 (16:41 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:49 +0000 (09:47 -0800)
95/a72d7b950cf444e29cec5de6a72569077178a9 [new file with mode: 0644]

diff --git a/95/a72d7b950cf444e29cec5de6a72569077178a9 b/95/a72d7b950cf444e29cec5de6a72569077178a9
new file mode 100644 (file)
index 0000000..d6c6bb0
--- /dev/null
@@ -0,0 +1,128 @@
+Return-Path: <ethan.glasser.camp@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7A984431FB6\r
+       for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:43:10 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.061\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.061 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_BL_SPAMCOP_NET=1.246,\r
+       RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SORBS_WEB=0.614] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id zc7qx8WG8fMo for <notmuch@notmuchmail.org>;\r
+       Mon, 25 Jun 2012 13:43:10 -0700 (PDT)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id A39F6431FAF\r
+       for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:43:09 -0700 (PDT)\r
+Received: by mail-we0-f181.google.com with SMTP id j55so3641437wer.26\r
+       for <notmuch@notmuchmail.org>; Mon, 25 Jun 2012 13:43:09 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=Z20noZo9CmdhF3xNEx6AIp1+NTNjmVStMvabHH2Ivhg=;\r
+       b=wFmQDjRxxF3iz8LUddnW6kGLgwMGqAhgH/NcH1lyacAO/GneFMZcTpJwVFKauw4Q9n\r
+       D/6Lu8HHV/QW+UqGeGMr9658BBx1+/UtZ7Qr9j2cyU4pZWwA/KePn0hBOxqPBq4E8SXK\r
+       G6L9HsNqlesxuIbnJcFU0a1M7NLpOJZv5FNg8kXX1woTNPAp0T4F+stw9XBr2APWfOLc\r
+       oymhnXDHDgThzDlTXlJTol/O2WMcrbnMcZr89ouYEGwv9VPTHFtLvef7+xnmhWf3zDes\r
+       /gqsZrAKIdRYEc/k3zSErE3Fm/DU+2kYBW2gM5Tgr/6LToRxL+mqzS8+/Ae1Kz79ogc4\r
+       DITg==\r
+Received: by 10.180.83.196 with SMTP id s4mr27101743wiy.15.1340656989241;\r
+       Mon, 25 Jun 2012 13:43:09 -0700 (PDT)\r
+Received: from localhost ([195.24.209.21])\r
+       by mx.google.com with ESMTPS id fu8sm18745841wib.5.2012.06.25.13.42.58\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Mon, 25 Jun 2012 13:43:08 -0700 (PDT)\r
+From: Ethan Glasser-Camp <ethan.glasser.camp@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC PATCH 03/14] mailstore can read from maildir: URLs\r
+Date: Mon, 25 Jun 2012 16:41:28 -0400\r
+Message-Id: <1340656899-5644-4-git-send-email-ethan@betacantrips.com>\r
+X-Mailer: git-send-email 1.7.9.5\r
+In-Reply-To: <1340656899-5644-1-git-send-email-ethan@betacantrips.com>\r
+References: <1340656899-5644-1-git-send-email-ethan@betacantrips.com>\r
+X-Mailman-Approved-At: Tue, 26 Jun 2012 03:51:54 -0700\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 25 Jun 2012 20:43:10 -0000\r
+\r
+No code uses this yet.\r
+\r
+Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+---\r
+ lib/mailstore.c |   37 ++++++++++++++++++++++++++++++++++++-\r
+ 1 file changed, 36 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/lib/mailstore.c b/lib/mailstore.c\r
+index 48acd47..ae02c12 100644\r
+--- a/lib/mailstore.c\r
++++ b/lib/mailstore.c\r
+@@ -17,14 +17,49 @@\r
+  *\r
+  * Author: Carl Worth <cworth@cworth.org>\r
+  */\r
++#include <uriparser/Uri.h>\r
+ #include <stdio.h>\r
+ \r
+ #include "notmuch-private.h"\r
+ \r
++static FILE *\r
++notmuch_mailstore_basic_open (const char *filename)\r
++{\r
++    return fopen (filename, "r");\r
++}\r
++\r
+ FILE *\r
+ notmuch_mailstore_open (const char *filename)\r
+ {\r
+-    return fopen (filename, "r");\r
++    FILE *ret = NULL;\r
++    UriUriA parsed;\r
++    UriParserStateA state;\r
++    state.uri = &parsed;\r
++    if (uriParseUriA (&state, filename) != URI_SUCCESS) {\r
++        /* Failure. Fall back to fopen and hope for the best. */\r
++        ret = notmuch_mailstore_basic_open (filename);\r
++        goto DONE;\r
++    }\r
++\r
++    if (parsed.scheme.first == NULL) {\r
++        /* No scheme. Probably not really a URL but just an ordinary filename.\r
++         * Fall back to fopen for backwards compatibility. */\r
++        ret = notmuch_mailstore_basic_open (filename);\r
++        goto DONE;\r
++    }\r
++\r
++    if (0 == strncmp (parsed.scheme.first, "maildir",\r
++                      parsed.scheme.afterLast-parsed.scheme.first)) {\r
++        /* Maildir URI of the form maildir:///path/to/file.\r
++         * We want to fopen("/path/to/file").\r
++         * pathHead starts at "path/to/file". */\r
++        ret = notmuch_mailstore_basic_open (parsed.pathHead->text.first - 1);\r
++        goto DONE;\r
++    }\r
++\r
++DONE:\r
++    uriFreeUriMembersA (&parsed);\r
++    return ret;\r
+ }\r
+ \r
+ int\r
+-- \r
+1.7.9.5\r
+\r