1 /* filenames.c - Iterator for a list of filenames
3 * Copyright © 2010 Intel Corporation
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see https://www.gnu.org/licenses/ .
18 * Author: Carl Worth <cworth@cworth.org>
21 #include "notmuch-private.h"
23 struct _notmuch_filenames {
24 notmuch_string_node_t *iterator;
27 /* The notmuch_filenames_t iterates over a notmuch_string_list_t of
30 _notmuch_filenames_create (const void *ctx,
31 notmuch_string_list_t *list)
33 notmuch_filenames_t *filenames;
35 filenames = talloc (ctx, notmuch_filenames_t);
36 if (unlikely (filenames == NULL))
39 filenames->iterator = list->head;
40 (void) talloc_reference (filenames, list);
46 notmuch_filenames_valid (notmuch_filenames_t *filenames)
48 if (filenames == NULL)
51 return (filenames->iterator != NULL);
55 notmuch_filenames_get (notmuch_filenames_t *filenames)
57 if ((filenames == NULL) || (filenames->iterator == NULL))
60 return filenames->iterator->string;
64 notmuch_filenames_move_to_next (notmuch_filenames_t *filenames)
66 if ((filenames == NULL) || (filenames->iterator == NULL))
69 filenames->iterator = filenames->iterator->next;
73 notmuch_filenames_destroy (notmuch_filenames_t *filenames)
75 talloc_free (filenames);