gvariant: Fix a potential memcpy(NULL) call
[platform/upstream/glib.git] / glib / gkeyfile.h
1 /* gkeyfile.h - desktop entry file parser
2  *
3  *  Copyright 2004 Red Hat, Inc.
4  *
5  *  Ray Strode <halfline@hawaii.rr.com>
6  *
7  * GLib is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * GLib is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with GLib; see the file COPYING.LIB.  If not,
19  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  *   Boston, MA 02111-1307, USA.
21  */
22
23 #ifndef __G_KEY_FILE_H__
24 #define __G_KEY_FILE_H__
25
26 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
27 #error "Only <glib.h> can be included directly."
28 #endif
29
30 #include <glib/gerror.h>
31
32 G_BEGIN_DECLS
33
34 typedef enum
35 {
36   G_KEY_FILE_ERROR_UNKNOWN_ENCODING,
37   G_KEY_FILE_ERROR_PARSE,
38   G_KEY_FILE_ERROR_NOT_FOUND,
39   G_KEY_FILE_ERROR_KEY_NOT_FOUND,
40   G_KEY_FILE_ERROR_GROUP_NOT_FOUND,
41   G_KEY_FILE_ERROR_INVALID_VALUE
42 } GKeyFileError;
43
44 #define G_KEY_FILE_ERROR g_key_file_error_quark()
45
46 GLIB_AVAILABLE_IN_ALL
47 GQuark g_key_file_error_quark (void);
48
49 typedef struct _GKeyFile GKeyFile;
50
51 typedef enum
52 {
53   G_KEY_FILE_NONE              = 0,
54   G_KEY_FILE_KEEP_COMMENTS     = 1 << 0,
55   G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1
56 } GKeyFileFlags;
57
58 GLIB_AVAILABLE_IN_ALL
59 GKeyFile *g_key_file_new                    (void);
60 GLIB_AVAILABLE_IN_ALL
61 GKeyFile *g_key_file_ref                    (GKeyFile             *key_file);
62 GLIB_AVAILABLE_IN_ALL
63 void      g_key_file_unref                  (GKeyFile             *key_file);
64 GLIB_AVAILABLE_IN_ALL
65 void      g_key_file_free                   (GKeyFile             *key_file);
66 GLIB_AVAILABLE_IN_ALL
67 void      g_key_file_set_list_separator     (GKeyFile             *key_file,
68                                              gchar                 separator);
69 GLIB_AVAILABLE_IN_ALL
70 gboolean  g_key_file_load_from_file         (GKeyFile             *key_file,
71                                              const gchar          *file,
72                                              GKeyFileFlags         flags,
73                                              GError              **error);
74 GLIB_AVAILABLE_IN_ALL
75 gboolean  g_key_file_load_from_data         (GKeyFile             *key_file,
76                                              const gchar          *data,
77                                              gsize                 length,
78                                              GKeyFileFlags         flags,
79                                              GError              **error);
80 GLIB_AVAILABLE_IN_ALL
81 gboolean g_key_file_load_from_dirs          (GKeyFile             *key_file,
82                                              const gchar          *file,
83                                              const gchar         **search_dirs,
84                                              gchar               **full_path,
85                                              GKeyFileFlags         flags,
86                                              GError              **error);
87 GLIB_AVAILABLE_IN_ALL
88 gboolean g_key_file_load_from_data_dirs     (GKeyFile             *key_file,
89                                              const gchar          *file,
90                                              gchar               **full_path,
91                                              GKeyFileFlags         flags,
92                                              GError              **error);
93 GLIB_AVAILABLE_IN_ALL
94 gchar    *g_key_file_to_data                (GKeyFile             *key_file,
95                                              gsize                *length,
96                                              GError              **error) G_GNUC_MALLOC;
97 GLIB_AVAILABLE_IN_2_40
98 gboolean  g_key_file_save_to_file           (GKeyFile             *key_file,
99                                              const gchar          *filename,
100                                              GError              **error);
101 GLIB_AVAILABLE_IN_ALL
102 gchar    *g_key_file_get_start_group        (GKeyFile             *key_file) G_GNUC_MALLOC;
103 GLIB_AVAILABLE_IN_ALL
104 gchar   **g_key_file_get_groups             (GKeyFile             *key_file,
105                                              gsize                *length) G_GNUC_MALLOC;
106 GLIB_AVAILABLE_IN_ALL
107 gchar   **g_key_file_get_keys               (GKeyFile             *key_file,
108                                              const gchar          *group_name,
109                                              gsize                *length,
110                                              GError              **error) G_GNUC_MALLOC;
111 GLIB_AVAILABLE_IN_ALL
112 gboolean  g_key_file_has_group              (GKeyFile             *key_file,
113                                              const gchar          *group_name);
114 GLIB_AVAILABLE_IN_ALL
115 gboolean  g_key_file_has_key                (GKeyFile             *key_file,
116                                              const gchar          *group_name,
117                                              const gchar          *key,
118                                              GError              **error);
119 GLIB_AVAILABLE_IN_ALL
120 gchar    *g_key_file_get_value              (GKeyFile             *key_file,
121                                              const gchar          *group_name,
122                                              const gchar          *key,
123                                              GError              **error) G_GNUC_MALLOC;
124 GLIB_AVAILABLE_IN_ALL
125 void      g_key_file_set_value              (GKeyFile             *key_file,
126                                              const gchar          *group_name,
127                                              const gchar          *key,
128                                              const gchar          *value);
129 GLIB_AVAILABLE_IN_ALL
130 gchar    *g_key_file_get_string             (GKeyFile             *key_file,
131                                              const gchar          *group_name,
132                                              const gchar          *key,
133                                              GError              **error) G_GNUC_MALLOC;
134 GLIB_AVAILABLE_IN_ALL
135 void      g_key_file_set_string             (GKeyFile             *key_file,
136                                              const gchar          *group_name,
137                                              const gchar          *key,
138                                              const gchar          *string);
139 GLIB_AVAILABLE_IN_ALL
140 gchar    *g_key_file_get_locale_string      (GKeyFile             *key_file,
141                                              const gchar          *group_name,
142                                              const gchar          *key,
143                                              const gchar          *locale,
144                                              GError              **error) G_GNUC_MALLOC;
145 GLIB_AVAILABLE_IN_ALL
146 void      g_key_file_set_locale_string      (GKeyFile             *key_file,
147                                              const gchar          *group_name,
148                                              const gchar          *key,
149                                              const gchar          *locale,
150                                              const gchar          *string);
151 GLIB_AVAILABLE_IN_ALL
152 gboolean  g_key_file_get_boolean            (GKeyFile             *key_file,
153                                              const gchar          *group_name,
154                                              const gchar          *key,
155                                              GError              **error);
156 GLIB_AVAILABLE_IN_ALL
157 void      g_key_file_set_boolean            (GKeyFile             *key_file,
158                                              const gchar          *group_name,
159                                              const gchar          *key,
160                                              gboolean              value);
161 GLIB_AVAILABLE_IN_ALL
162 gint      g_key_file_get_integer            (GKeyFile             *key_file,
163                                              const gchar          *group_name,
164                                              const gchar          *key,
165                                              GError              **error);
166 GLIB_AVAILABLE_IN_ALL
167 void      g_key_file_set_integer            (GKeyFile             *key_file,
168                                              const gchar          *group_name,
169                                              const gchar          *key,
170                                              gint                  value);
171 GLIB_AVAILABLE_IN_ALL
172 gint64    g_key_file_get_int64              (GKeyFile             *key_file,
173                                              const gchar          *group_name,
174                                              const gchar          *key,
175                                              GError              **error);
176 GLIB_AVAILABLE_IN_ALL
177 void      g_key_file_set_int64              (GKeyFile             *key_file,
178                                              const gchar          *group_name,
179                                              const gchar          *key,
180                                              gint64                value);
181 GLIB_AVAILABLE_IN_ALL
182 guint64   g_key_file_get_uint64             (GKeyFile             *key_file,
183                                              const gchar          *group_name,
184                                              const gchar          *key,
185                                              GError              **error);
186 GLIB_AVAILABLE_IN_ALL
187 void      g_key_file_set_uint64             (GKeyFile             *key_file,
188                                              const gchar          *group_name,
189                                              const gchar          *key,
190                                              guint64               value);
191 GLIB_AVAILABLE_IN_ALL
192 gdouble   g_key_file_get_double             (GKeyFile             *key_file,
193                                              const gchar          *group_name,
194                                              const gchar          *key,
195                                              GError              **error);
196 GLIB_AVAILABLE_IN_ALL
197 void      g_key_file_set_double             (GKeyFile             *key_file,
198                                              const gchar          *group_name,
199                                              const gchar          *key,
200                                              gdouble               value);
201 GLIB_AVAILABLE_IN_ALL
202 gchar   **g_key_file_get_string_list        (GKeyFile             *key_file,
203                                              const gchar          *group_name,
204                                              const gchar          *key,
205                                              gsize                *length,
206                                              GError              **error) G_GNUC_MALLOC;
207 GLIB_AVAILABLE_IN_ALL
208 void      g_key_file_set_string_list        (GKeyFile             *key_file,
209                                              const gchar          *group_name,
210                                              const gchar          *key,
211                                              const gchar * const   list[],
212                                              gsize                 length);
213 GLIB_AVAILABLE_IN_ALL
214 gchar   **g_key_file_get_locale_string_list (GKeyFile             *key_file,
215                                              const gchar          *group_name,
216                                              const gchar          *key,
217                                              const gchar          *locale,
218                                              gsize                *length,
219                                              GError              **error) G_GNUC_MALLOC;
220 GLIB_AVAILABLE_IN_ALL
221 void      g_key_file_set_locale_string_list (GKeyFile             *key_file,
222                                              const gchar          *group_name,
223                                              const gchar          *key,
224                                              const gchar          *locale,
225                                              const gchar * const   list[],
226                                              gsize                 length);
227 GLIB_AVAILABLE_IN_ALL
228 gboolean *g_key_file_get_boolean_list       (GKeyFile             *key_file,
229                                              const gchar          *group_name,
230                                              const gchar          *key,
231                                              gsize                *length,
232                                              GError              **error) G_GNUC_MALLOC;
233 GLIB_AVAILABLE_IN_ALL
234 void      g_key_file_set_boolean_list       (GKeyFile             *key_file,
235                                              const gchar          *group_name,
236                                              const gchar          *key,
237                                              gboolean              list[],
238                                              gsize                 length);
239 GLIB_AVAILABLE_IN_ALL
240 gint     *g_key_file_get_integer_list       (GKeyFile             *key_file,
241                                              const gchar          *group_name,
242                                              const gchar          *key,
243                                              gsize                *length,
244                                              GError              **error) G_GNUC_MALLOC;
245 GLIB_AVAILABLE_IN_ALL
246 void      g_key_file_set_double_list        (GKeyFile             *key_file,
247                                              const gchar          *group_name,
248                                              const gchar          *key,
249                                              gdouble               list[],
250                                              gsize                 length);
251 GLIB_AVAILABLE_IN_ALL
252 gdouble  *g_key_file_get_double_list        (GKeyFile             *key_file,
253                                              const gchar          *group_name,
254                                              const gchar          *key,
255                                              gsize                *length,
256                                              GError              **error) G_GNUC_MALLOC;
257 GLIB_AVAILABLE_IN_ALL
258 void      g_key_file_set_integer_list       (GKeyFile             *key_file,
259                                              const gchar          *group_name,
260                                              const gchar          *key,
261                                              gint                  list[],
262                                              gsize                 length);
263 GLIB_AVAILABLE_IN_ALL
264 gboolean  g_key_file_set_comment            (GKeyFile             *key_file,
265                                              const gchar          *group_name,
266                                              const gchar          *key,
267                                              const gchar          *comment,
268                                              GError              **error);
269 GLIB_AVAILABLE_IN_ALL
270 gchar    *g_key_file_get_comment            (GKeyFile             *key_file,
271                                              const gchar          *group_name,
272                                              const gchar          *key,
273                                              GError              **error) G_GNUC_MALLOC;
274
275 GLIB_AVAILABLE_IN_ALL
276 gboolean  g_key_file_remove_comment         (GKeyFile             *key_file,
277                                              const gchar          *group_name,
278                                              const gchar          *key,
279                                              GError              **error);
280 GLIB_AVAILABLE_IN_ALL
281 gboolean  g_key_file_remove_key             (GKeyFile             *key_file,
282                                              const gchar          *group_name,
283                                              const gchar          *key,
284                                              GError              **error);
285 GLIB_AVAILABLE_IN_ALL
286 gboolean  g_key_file_remove_group           (GKeyFile             *key_file,
287                                              const gchar          *group_name,
288                                              GError              **error);
289
290 /* Defines for handling freedesktop.org Desktop files */
291 #define G_KEY_FILE_DESKTOP_GROUP                "Desktop Entry"
292
293 #define G_KEY_FILE_DESKTOP_KEY_TYPE             "Type"
294 #define G_KEY_FILE_DESKTOP_KEY_VERSION          "Version"
295 #define G_KEY_FILE_DESKTOP_KEY_NAME             "Name"
296 #define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME     "GenericName"
297 #define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY       "NoDisplay"
298 #define G_KEY_FILE_DESKTOP_KEY_COMMENT          "Comment"
299 #define G_KEY_FILE_DESKTOP_KEY_ICON             "Icon"
300 #define G_KEY_FILE_DESKTOP_KEY_HIDDEN           "Hidden"
301 #define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN     "OnlyShowIn"
302 #define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN      "NotShowIn"
303 #define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC         "TryExec"
304 #define G_KEY_FILE_DESKTOP_KEY_EXEC             "Exec"
305 #define G_KEY_FILE_DESKTOP_KEY_PATH             "Path"
306 #define G_KEY_FILE_DESKTOP_KEY_TERMINAL         "Terminal"
307 #define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE        "MimeType"
308 #define G_KEY_FILE_DESKTOP_KEY_CATEGORIES       "Categories"
309 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY   "StartupNotify"
310 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass"
311 #define G_KEY_FILE_DESKTOP_KEY_URL              "URL"
312 #define G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE "DBusActivatable"
313 #define G_KEY_FILE_DESKTOP_KEY_ACTIONS          "Actions"
314
315 #define G_KEY_FILE_DESKTOP_TYPE_APPLICATION     "Application"
316 #define G_KEY_FILE_DESKTOP_TYPE_LINK            "Link"
317 #define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY       "Directory"
318
319 G_END_DECLS
320
321 #endif /* __G_KEY_FILE_H__ */