/* 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 */ #include #include "mailstore-private.h" #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0])) static notmuch_mailstore_t *available[] = { &mailstore_files, &mailstore_maildir, }; 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) { return mailstore->open_file (mailstore, filename); }