libreport  2.3.0
A tool to inform users about various problems on the running system
libreport_types.h
1 /*
2  Copyright (C) 2013 ABRT team
3  Copyright (C) 2013 RedHat Inc
4 
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 2 of the License, or
8  (at your option) any later version.
9 
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.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 #ifndef LIBREPORT_TYPES_H_
20 #define LIBREPORT_TYPES_H_
21 
22 #include <stdbool.h>
23 #include <glib.h>
24 
25 typedef gchar **string_vector_ptr_t;
26 
27 #define string_vector_new_from_string libreport_string_vector_new_from_string
28 string_vector_ptr_t string_vector_new_from_string(const char *vector);
29 #define string_vector_free libreport_string_vector_free
30 void string_vector_free(string_vector_ptr_t vector);
31 
32 typedef GHashTable map_string_t;
33 #define new_map_string libreport_new_map_string
34 map_string_t *new_map_string(void);
35 #define free_map_string libreport_free_map_string
36 void free_map_string(map_string_t *ms);
37 #define size_map_string libreport_size_map_string
38 static inline
39 unsigned size_map_string(map_string_t *ms)
40 {
41  if (ms == NULL)
42  return 0;
43 
44  return g_hash_table_size(ms);
45 }
46 #define insert_map_string_item libreport_insert_map_string_item
47 static inline
48 void insert_map_string(map_string_t *ms, char *key, char *value)
49 {
50  g_hash_table_insert(ms, key, value);
51 }
52 #define replace_map_string_item libreport_replace_map_string_item
53 static inline
54 void replace_map_string_item(map_string_t *ms, char *key, char *value)
55 {
56  g_hash_table_replace(ms, key, value);
57 }
58 #define remove_map_string_item libreport_remove_map_string_item
59 static inline
60 void remove_map_string_item(map_string_t *ms, const char *key)
61 {
62  g_hash_table_remove(ms, key);
63 }
64 #define get_map_string_item_or_empty libreport_get_map_string_item_or_empty
65 const char *get_map_string_item_or_empty(map_string_t *ms, const char *key);
66 #define get_map_string_item_or_NULL libreport_get_map_string_item_or_NULL
67 static inline
68 const char *get_map_string_item_or_NULL(map_string_t *ms, const char *key)
69 {
70  return (const char*)g_hash_table_lookup(ms, key);
71 }
72 
73 #define set_map_string_item_from_bool libreport_set_map_string_item_from_bool
74 void set_map_string_item_from_bool(map_string_t *ms, const char *key, int value);
75 #define try_get_map_string_item_as_bool libreport_try_get_map_string_item_as_bool
76 int try_get_map_string_item_as_bool(map_string_t *ms, const char *key, int *value);
77 
78 #define set_map_string_item_from_int libreport_set_map_string_item_from_int
79 void set_map_string_item_from_int(map_string_t *ms, const char *key, int value);
80 #define try_get_map_string_item_as_int libreport_try_get_map_string_item_as_int
81 int try_get_map_string_item_as_int(map_string_t *ms, const char *key, int *value);
82 
83 #define set_map_string_item_from_string libreport_set_map_string_item_from_string
84 void set_map_string_item_from_string(map_string_t *ms, const char *key, const char *value);
85 #define try_get_map_string_item_as_string libreport_try_get_map_string_item_as_string
86 int try_get_map_string_item_as_string(map_string_t *ms, const char *key, char **value);
87 
88 #define set_map_string_item_from_string_vector libreport_set_map_string_item_from_string_vector
89 void set_map_string_item_from_string_vector(map_string_t *ms, const char *key, string_vector_ptr_t value);
90 #define try_get_map_string_item_as_string_vector libreport_try_get_map_string_item_as_string_vector
91 int try_get_map_string_item_as_string_vector(map_string_t *ms, const char *key, string_vector_ptr_t *value);
92 
93 
94 typedef GHashTableIter map_string_iter_t;
95 #define init_map_string_iter libreport_init_map_string_iter
96 static inline
97 void init_map_string_iter(map_string_iter_t *iter, map_string_t *ms)
98 {
99  g_hash_table_iter_init(iter, ms);
100 }
101 #define next_map_string_iter libreport_next_map_string_iter
102 static inline
103 int next_map_string_iter(map_string_iter_t *iter, const char **key, const char **value)
104 {
105  return g_hash_table_iter_next(iter, (gpointer *)key, (gpointer *)value);
106 }
107 
108 #endif /* LIBREPORT_TYPES_H_ */