1 /* GNU Mailutils -- a suite of utilities for electronic mail
2    Copyright (C) 2007-2021 Free Software Foundation, Inc.
3 
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 3 of the License, or (at your option) any later version.
8 
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13 
14    You should have received a copy of the GNU Lesser General
15    Public License along with this library.  If not, see
16    <http://www.gnu.org/licenses/>. */
17 
18 #ifndef _MAILUTILS_ASSOC_H
19 #define _MAILUTILS_ASSOC_H
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #include <mailutils/types.h>
26 
27 #define MU_ASSOC_COPY_KEY 0x01
28 #define MU_ASSOC_ICASE    0x02
29 
30 int mu_assoc_create (mu_assoc_t *passoc, int flags);
31 void mu_assoc_destroy (mu_assoc_t *passoc);
32 void mu_assoc_clear (mu_assoc_t assoc);
33 int mu_assoc_lookup (mu_assoc_t assoc, const char *name, void *dataptr);
34 void *mu_assoc_get (mu_assoc_t assoc, const char *name);
35 int mu_assoc_install (mu_assoc_t assoc, const char *name, void *value);
36 
37 int mu_assoc_lookup_ref (mu_assoc_t assoc, const char *name, void *dataptr);
38 int mu_assoc_install_ref (mu_assoc_t assoc, const char *name, void *pval);
39 int mu_assoc_install_ref2 (mu_assoc_t assoc, const char *name,
40 			   void *ret_val, const char **ret_name);
41 
42 int mu_assoc_get_iterator (mu_assoc_t assoc, mu_iterator_t *piterator);
43 int mu_assoc_remove (mu_assoc_t assoc, const char *name);
44 int mu_assoc_set_destroy_item (mu_assoc_t assoc, mu_deallocator_t fn);
45 int mu_assoc_count (mu_assoc_t assoc, size_t *pcount);
46 int mu_assoc_is_empty (mu_assoc_t assoc);
47 
48 typedef int (*mu_assoc_action_t) (char const *, void *, void *);
49 int mu_assoc_foreach (mu_assoc_t assoc, mu_assoc_action_t action, void *data);
50 
51 typedef int (*mu_assoc_comparator_t) (const char *, const void *,
52 				      const char *, const void *,
53 				      void *);
54 
55 int mu_assoc_sort_r (mu_assoc_t assoc, mu_assoc_comparator_t cmp, void *data);
56 
57 int mu_assoc_mark (mu_assoc_t asc, int (*cond) (char const *, void *, void *),
58 		   void *data);
59 int mu_assoc_set_mark (mu_assoc_t asc, char const *name, int mark);
60 int mu_assoc_head_set_mark (mu_assoc_t asc, int mark);
61 int mu_assoc_tail_set_mark (mu_assoc_t asc, int mark);
62 int mu_assoc_pop (mu_assoc_t asc, char const *name, void *ret_val);
63 int mu_assoc_shift (mu_assoc_t asc, char const *name, void *ret_val);
64 
65 int mu_assoc_sweep (mu_assoc_t asc);
66 int mu_assoc_sweep_unset (mu_assoc_t asc);
67 
68 void mu_assoc_pull (mu_assoc_t a, mu_assoc_t b);
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif /* _MAILUTILS_ASSOC_H */
75 
76 
77