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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
| | /* mailstore.c - Mailstore abstraction
*
* Copyright © 2010 Michal Sojka
*
* 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: Michal Sojka <sojkam1@fel.cvut.cz>
*/
#include <notmuch.h>
#include "mailstore-private.h"
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
/* Original notmuch mail store */
struct _notmuch_mailstore mailstore_files = {
.type = "files",
};
static notmuch_mailstore_t *available[] = {
&mailstore_files,
};
notmuch_mailstore_t *
notmuch_mailstore_get_by_type (const char *type)
{
unsigned i;
if (type == NULL)
return available[0];
for (i = 0; i < ARRAY_SIZE(available); i++) {
if (strcasecmp (type, available[i]->type) == 0)
return available[i];
}
return NULL;
}
const char *
notmuch_mailstore_get_type (notmuch_mailstore_t *mailstore)
{
if (!mailstore)
return NULL;
return mailstore->type;
}
void
notmuch_mailstore_count_files (notmuch_mailstore_t *mailstore,
const char *path, int *count,
volatile sig_atomic_t *interrupted)
{
mailstore->count_files (mailstore, path, count, interrupted);
}
notmuch_status_t
notmuch_mailstore_index_new (notmuch_mailstore_t *mailstore,
const char *path,
notmuch_indexing_context_t *ctx)
{
notmuch_private_status_t status;
status = mailstore->index_new (mailstore, path, ctx);
return COERCE_STATUS (status, "Index new");
}
FILE *
notmuch_mailstore_open_file (notmuch_mailstore_t *mailstore,
const char *filename)
{
if (mailstore->open_file)
return mailstore->open_file (mailstore, filename);
else
return NULL;
}
|