Fix minor mem leak in test case
[platform/upstream/glib.git] / gio / gresource.h
1 /* GIO - GLib Input, Output and Streaming Library
2  *
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17  *
18  * Author: Alexander Larsson <alexl@redhat.com>
19  */
20
21 #ifndef __G_RESOURCE_H__
22 #define __G_RESOURCE_H__
23
24 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25 #error "Only <gio/gio.h> can be included directly."
26 #endif
27
28 #include <gio/giotypes.h>
29
30 G_BEGIN_DECLS
31
32 /**
33  * G_TYPE_RESOURCE:
34  *
35  * The #GType for #GResource.
36  */
37 #define G_TYPE_RESOURCE (g_resource_get_type ())
38
39
40 /**
41  * G_RESOURCE_ERROR:
42  *
43  * Error domain for #GResource. Errors in this domain will be from the
44  * #GResourceError enumeration. See #GError for more information on
45  * error domains.
46  */
47 #define G_RESOURCE_ERROR (g_resource_error_quark ())
48 GLIB_AVAILABLE_IN_2_32
49 GQuark g_resource_error_quark (void);
50
51 typedef struct _GStaticResource GStaticResource;
52
53 struct _GStaticResource {
54   const guint8 *data;
55   gsize data_len;
56   GResource *resource;
57   GStaticResource *next;
58   gpointer padding;
59 };
60
61 GLIB_AVAILABLE_IN_2_32
62 GType         g_resource_get_type            (void) G_GNUC_CONST;
63 GLIB_AVAILABLE_IN_2_32
64 GResource *   g_resource_new_from_data       (GBytes                *data,
65                                               GError               **error);
66 GLIB_AVAILABLE_IN_2_32
67 GResource *   g_resource_ref                 (GResource             *resource);
68 GLIB_AVAILABLE_IN_2_32
69 void          g_resource_unref               (GResource             *resource);
70 GLIB_AVAILABLE_IN_2_32
71 GResource *   g_resource_load                (const gchar           *filename,
72                                               GError               **error);
73 GLIB_AVAILABLE_IN_2_32
74 GInputStream *g_resource_open_stream         (GResource             *resource,
75                                               const char            *path,
76                                               GResourceLookupFlags   lookup_flags,
77                                               GError               **error);
78 GLIB_AVAILABLE_IN_2_32
79 GBytes *      g_resource_lookup_data         (GResource             *resource,
80                                               const char            *path,
81                                               GResourceLookupFlags   lookup_flags,
82                                               GError               **error);
83 GLIB_AVAILABLE_IN_2_32
84 char **       g_resource_enumerate_children  (GResource             *resource,
85                                               const char            *path,
86                                               GResourceLookupFlags   lookup_flags,
87                                               GError               **error);
88 GLIB_AVAILABLE_IN_2_32
89 gboolean      g_resource_get_info            (GResource             *resource,
90                                               const char            *path,
91                                               GResourceLookupFlags   lookup_flags,
92                                               gsize                 *size,
93                                               guint32               *flags,
94                                               GError               **error);
95
96 GLIB_AVAILABLE_IN_2_32
97 void          g_resources_register           (GResource             *resource);
98 GLIB_AVAILABLE_IN_2_32
99 void          g_resources_unregister         (GResource             *resource);
100 GLIB_AVAILABLE_IN_2_32
101 GInputStream *g_resources_open_stream        (const char            *path,
102                                               GResourceLookupFlags   lookup_flags,
103                                               GError               **error);
104 GLIB_AVAILABLE_IN_2_32
105 GBytes *      g_resources_lookup_data        (const char            *path,
106                                               GResourceLookupFlags   lookup_flags,
107                                               GError               **error);
108 GLIB_AVAILABLE_IN_2_32
109 char **       g_resources_enumerate_children (const char            *path,
110                                               GResourceLookupFlags   lookup_flags,
111                                               GError               **error);
112 GLIB_AVAILABLE_IN_2_32
113 gboolean      g_resources_get_info           (const char            *path,
114                                               GResourceLookupFlags   lookup_flags,
115                                               gsize                 *size,
116                                               guint32               *flags,
117                                               GError               **error);
118
119
120 GLIB_AVAILABLE_IN_2_32
121 void          g_static_resource_init          (GStaticResource *static_resource);
122 GLIB_AVAILABLE_IN_2_32
123 void          g_static_resource_fini          (GStaticResource *static_resource);
124 GLIB_AVAILABLE_IN_2_32
125 GResource    *g_static_resource_get_resource  (GStaticResource *static_resource);
126
127 G_END_DECLS
128
129 #endif /* __G_RESOURCE_H__ */