unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob ae02c12369c33fda2ac840c139ef02098121e9c8 2093 bytes (raw)
name: lib/mailstore.c 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 
/* mailstore.c - code to access individual messages
 *
 * Copyright © 2009 Carl Worth
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see http://www.gnu.org/licenses/ .
 *
 * Author: Carl Worth <cworth@cworth.org>
 */
#include <uriparser/Uri.h>
#include <stdio.h>

#include "notmuch-private.h"

static FILE *
notmuch_mailstore_basic_open (const char *filename)
{
    return fopen (filename, "r");
}

FILE *
notmuch_mailstore_open (const char *filename)
{
    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
notmuch_mailstore_close (FILE *file)
{
    return fclose (file);
}

debug log:

solving ae02c12 ...
found ae02c12 in https://yhetil.org/notmuch/1340656899-5644-4-git-send-email-ethan@betacantrips.com/
found 48acd47 in https://yhetil.org/notmuch/1341160790-14525-2-git-send-email-ethan@betacantrips.com/ ||
	https://yhetil.org/notmuch/1340656899-5644-2-git-send-email-ethan@betacantrips.com/

applying [1/2] https://yhetil.org/notmuch/1341160790-14525-2-git-send-email-ethan@betacantrips.com/
diff --git a/lib/mailstore.c b/lib/mailstore.c
new file mode 100644
index 0000000..48acd47

Checking patch lib/mailstore.c...
Applied patch lib/mailstore.c cleanly.

skipping https://yhetil.org/notmuch/1340656899-5644-2-git-send-email-ethan@betacantrips.com/ for 48acd47
index at:
100644 48acd47efba0ed8c4dde5637a43ebbf1e9beb226	lib/mailstore.c

applying [2/2] https://yhetil.org/notmuch/1340656899-5644-4-git-send-email-ethan@betacantrips.com/
diff --git a/lib/mailstore.c b/lib/mailstore.c
index 48acd47..ae02c12 100644

Checking patch lib/mailstore.c...
Applied patch lib/mailstore.c cleanly.

index at:
100644 ae02c12369c33fda2ac840c139ef02098121e9c8	lib/mailstore.c

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).