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