Bug Summary

File:frontends/gtk/resources.c
Warning:line 367, column 15
Assigned value is garbage or undefined

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name resources.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/var/lib/jenkins/workspace/scan-build-netsurf -resource-dir /usr/lib/llvm-14/lib/clang/14.0.6 -I . -I include -I build/Linux-gtk2 -I frontends -I content/handlers -D WITH_JPEG -U WITH_PDF_EXPORT -D LIBICONV_PLUG -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -I /usr/include/x86_64-linux-gnu -D WITH_CURL -D WITH_OPENSSL -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -D UTF8PROC_EXPORTS -D WITH_UTF8PROC -D WITH_WEBP -I /usr/include/libpng16 -D WITH_PNG -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include/ -D WITH_BMP -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -D WITH_GIF -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -D WITH_NS_SVG -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -D WITH_NSSPRITE -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -D WITH_NSPSL -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -D WITH_NSLOG -D NETSURF_UA_FORMAT_STRING="Mozilla/5.0 (%s) NetSurf/%d.%d" -D NETSURF_HOMEPAGE="about:welcome" -D NETSURF_LOG_LEVEL=VERBOSE -D NETSURF_BUILTIN_LOG_FILTER="(level:WARNING || cat:jserrors)" -D NETSURF_BUILTIN_VERBOSE_FILTER="(level:VERBOSE || cat:jserrors)" -D STMTEXPR=1 -I /usr/include/librsvg-2.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libpng16 -I /usr/include/x86_64-linux-gnu -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/freetype2 -D WITH_RSVG -I /usr/include/gtk-2.0 -I /usr/lib/x86_64-linux-gnu/gtk-2.0/include -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/atk-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -D gtk -D nsgtk -D G_DISABLE_SINGLE_INCLUDES -D G_DISABLE_DEPRECATED -D GTK_DISABLE_SINGLE_INCLUDES -D GTK_MULTIHEAD_SAFE -D PANGO_DISABLE_DEPRECATED -D GTK_DISABLE_DEPRECATED -D _XOPEN_SOURCE=700 -D _POSIX_C_SOURCE=200809L -D _BSD_SOURCE -D _DEFAULT_SOURCE -D _NETBSD_SOURCE -D GTK_RESPATH="/var/lib/jenkins/artifacts-x86_64-linux-gnu/share/netsurf/:./frontends/gtk/res/" -D WITH_GRESOURCE -D DUK_OPT_HAVE_CUSTOM_H -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.6/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wwrite-strings -Wno-unused-parameter -Wno-unused-but-set-variable -std=c99 -fconst-strings -fdebug-compilation-dir=/var/lib/jenkins/workspace/scan-build-netsurf -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-display-progress -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/lib/jenkins/workspace/scan-build-netsurf/clangScanBuildReports/2024-12-18-105127-2905466-1 -x c frontends/gtk/resources.c
1/*
2 * Copyright 2015 Vincent Sanders <vince@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf 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
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * \file
21 * Implementation of gtk builtin resource handling.
22 *
23 * This presents a unified interface to the rest of the codebase to
24 * obtain resources. Note this is not anything to do with the resource
25 * scheme handling beyond possibly providing the underlying data.
26 *
27 */
28
29#include <stdlib.h>
30#include <string.h>
31#include <gtk1/gtk1.h>
32
33#include "utils/log.h"
34#include "utils/filepath.h"
35
36#include "gtk/compat.h"
37#include "gtk/resources.h"
38
39/** log contents of gresource /org/netsource */
40#ifdef WITH_GRESOURCE1
41#define SHOW_GRESOURCE
42#undef SHOW_GRESOURCE
43#endif
44
45#ifdef WITH_BUILTIN_PIXBUF
46#ifdef __GNUC__4
47extern const guint8 menu_cursor_pixdata[] __attribute__ ((__aligned__ (4)));
48extern const guint8 favicon_pixdata[] __attribute__ ((__aligned__ (4)));
49extern const guint8 netsurf_pixdata[] __attribute__ ((__aligned__ (4)));
50#else
51extern const guint8 menu_cursor_pixdata[];
52extern const guint8 favicon_pixdata[];
53extern const guint8 netsurf_pixdata[];
54#endif
55#endif
56
57/** type of resource entry */
58enum nsgtk_resource_type_e {
59 NSGTK_RESOURCE_FILE, /**< entry is a file on disc */
60 NSGTK_RESOURCE_GLIB, /**< entry is a gresource accessed by path */
61 NSGTK_RESOURCE_DIRECT, /**< entry is a gresource accesed by gbytes */
62 NSGTK_RESOURCE_INLINE, /**< entry is compiled in accessed by pointer */
63};
64
65/** resource entry */
66struct nsgtk_resource_s {
67 const char *name;
68 unsigned int len;
69 enum nsgtk_resource_type_e type;
70 char *path;
71};
72
73#define RES_ENTRY(name){ name, sizeof((name)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) } { name, sizeof((name)) - 1, NSGTK_RESOURCE_FILE, NULL((void*)0) }
74
75/** resources that are used for gtk builder */
76static struct nsgtk_resource_s ui_resource[] = {
77 RES_ENTRY("netsurf"){ "netsurf", sizeof(("netsurf")) - 1, NSGTK_RESOURCE_FILE, ((
void*)0) }
,
78 RES_ENTRY("tabcontents"){ "tabcontents", sizeof(("tabcontents")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
79 RES_ENTRY("password"){ "password", sizeof(("password")) - 1, NSGTK_RESOURCE_FILE, (
(void*)0) }
,
80 RES_ENTRY("toolbar"){ "toolbar", sizeof(("toolbar")) - 1, NSGTK_RESOURCE_FILE, ((
void*)0) }
,
81 RES_ENTRY("downloads"){ "downloads", sizeof(("downloads")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
82 RES_ENTRY("globalhistory"){ "globalhistory", sizeof(("globalhistory")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
83 RES_ENTRY("localhistory"){ "localhistory", sizeof(("localhistory")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
84 RES_ENTRY("options"){ "options", sizeof(("options")) - 1, NSGTK_RESOURCE_FILE, ((
void*)0) }
,
85 RES_ENTRY("hotlist"){ "hotlist", sizeof(("hotlist")) - 1, NSGTK_RESOURCE_FILE, ((
void*)0) }
,
86 RES_ENTRY("cookies"){ "cookies", sizeof(("cookies")) - 1, NSGTK_RESOURCE_FILE, ((
void*)0) }
,
87 RES_ENTRY("viewdata"){ "viewdata", sizeof(("viewdata")) - 1, NSGTK_RESOURCE_FILE, (
(void*)0) }
,
88 RES_ENTRY("warning"){ "warning", sizeof(("warning")) - 1, NSGTK_RESOURCE_FILE, ((
void*)0) }
,
89 RES_ENTRY("pageinfo"){ "pageinfo", sizeof(("pageinfo")) - 1, NSGTK_RESOURCE_FILE, (
(void*)0) }
,
90 { NULL((void*)0), 0, NSGTK_RESOURCE_FILE, NULL((void*)0) },
91};
92
93/** resources that are used as pixbufs */
94static struct nsgtk_resource_s pixbuf_resource[] = {
95 RES_ENTRY("favicon.png"){ "favicon.png", sizeof(("favicon.png")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
96 RES_ENTRY("netsurf.xpm"){ "netsurf.xpm", sizeof(("netsurf.xpm")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
97 RES_ENTRY("menu_cursor.png"){ "menu_cursor.png", sizeof(("menu_cursor.png")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
98 RES_ENTRY("icons/local-history.png"){ "icons/local-history.png", sizeof(("icons/local-history.png"
)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
99 RES_ENTRY("icons/show-cookie.png"){ "icons/show-cookie.png", sizeof(("icons/show-cookie.png")) -
1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
100 RES_ENTRY("icons/24x24/actions/page-info-insecure.png"){ "icons/24x24/actions/page-info-insecure.png", sizeof(("icons/24x24/actions/page-info-insecure.png"
)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
101 RES_ENTRY("icons/24x24/actions/page-info-internal.png"){ "icons/24x24/actions/page-info-internal.png", sizeof(("icons/24x24/actions/page-info-internal.png"
)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
102 RES_ENTRY("icons/24x24/actions/page-info-local.png"){ "icons/24x24/actions/page-info-local.png", sizeof(("icons/24x24/actions/page-info-local.png"
)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
103 RES_ENTRY("icons/24x24/actions/page-info-secure.png"){ "icons/24x24/actions/page-info-secure.png", sizeof(("icons/24x24/actions/page-info-secure.png"
)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
104 RES_ENTRY("icons/24x24/actions/page-info-warning.png"){ "icons/24x24/actions/page-info-warning.png", sizeof(("icons/24x24/actions/page-info-warning.png"
)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
105 RES_ENTRY("icons/48x48/actions/page-info-insecure.png"){ "icons/48x48/actions/page-info-insecure.png", sizeof(("icons/48x48/actions/page-info-insecure.png"
)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
106 RES_ENTRY("icons/48x48/actions/page-info-internal.png"){ "icons/48x48/actions/page-info-internal.png", sizeof(("icons/48x48/actions/page-info-internal.png"
)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
107 RES_ENTRY("icons/48x48/actions/page-info-local.png"){ "icons/48x48/actions/page-info-local.png", sizeof(("icons/48x48/actions/page-info-local.png"
)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
108 RES_ENTRY("icons/48x48/actions/page-info-secure.png"){ "icons/48x48/actions/page-info-secure.png", sizeof(("icons/48x48/actions/page-info-secure.png"
)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
109 RES_ENTRY("icons/48x48/actions/page-info-warning.png"){ "icons/48x48/actions/page-info-warning.png", sizeof(("icons/48x48/actions/page-info-warning.png"
)) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
110 RES_ENTRY("throbber/throbber0.png"){ "throbber/throbber0.png", sizeof(("throbber/throbber0.png")
) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
111 RES_ENTRY("throbber/throbber1.png"){ "throbber/throbber1.png", sizeof(("throbber/throbber1.png")
) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
112 RES_ENTRY("throbber/throbber2.png"){ "throbber/throbber2.png", sizeof(("throbber/throbber2.png")
) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
113 RES_ENTRY("throbber/throbber3.png"){ "throbber/throbber3.png", sizeof(("throbber/throbber3.png")
) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
114 RES_ENTRY("throbber/throbber4.png"){ "throbber/throbber4.png", sizeof(("throbber/throbber4.png")
) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
115 RES_ENTRY("throbber/throbber5.png"){ "throbber/throbber5.png", sizeof(("throbber/throbber5.png")
) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
116 RES_ENTRY("throbber/throbber6.png"){ "throbber/throbber6.png", sizeof(("throbber/throbber6.png")
) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
117 RES_ENTRY("throbber/throbber7.png"){ "throbber/throbber7.png", sizeof(("throbber/throbber7.png")
) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
118 RES_ENTRY("throbber/throbber8.png"){ "throbber/throbber8.png", sizeof(("throbber/throbber8.png")
) - 1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
119 { NULL((void*)0), 0, NSGTK_RESOURCE_FILE, NULL((void*)0) },
120};
121
122/** resources that are used for direct data access */
123static struct nsgtk_resource_s direct_resource[] = {
124 RES_ENTRY("welcome.html"){ "welcome.html", sizeof(("welcome.html")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
125 RES_ENTRY("credits.html"){ "credits.html", sizeof(("credits.html")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
126 RES_ENTRY("licence.html"){ "licence.html", sizeof(("licence.html")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
127 RES_ENTRY("default.css"){ "default.css", sizeof(("default.css")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
128 RES_ENTRY("adblock.css"){ "adblock.css", sizeof(("adblock.css")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
129 RES_ENTRY("internal.css"){ "internal.css", sizeof(("internal.css")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
130 RES_ENTRY("quirks.css"){ "quirks.css", sizeof(("quirks.css")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
131 RES_ENTRY("netsurf.png"){ "netsurf.png", sizeof(("netsurf.png")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
132 RES_ENTRY("default.ico"){ "default.ico", sizeof(("default.ico")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
133 RES_ENTRY("icons/arrow-l.png"){ "icons/arrow-l.png", sizeof(("icons/arrow-l.png")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
134 RES_ENTRY("icons/content.png"){ "icons/content.png", sizeof(("icons/content.png")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
135 RES_ENTRY("icons/directory2.png"){ "icons/directory2.png", sizeof(("icons/directory2.png")) - 1
, NSGTK_RESOURCE_FILE, ((void*)0) }
,
136 RES_ENTRY("icons/directory.png"){ "icons/directory.png", sizeof(("icons/directory.png")) - 1,
NSGTK_RESOURCE_FILE, ((void*)0) }
,
137 RES_ENTRY("icons/hotlist-add.png"){ "icons/hotlist-add.png", sizeof(("icons/hotlist-add.png")) -
1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
138 RES_ENTRY("icons/hotlist-rmv.png"){ "icons/hotlist-rmv.png", sizeof(("icons/hotlist-rmv.png")) -
1, NSGTK_RESOURCE_FILE, ((void*)0) }
,
139 RES_ENTRY("icons/search.png"){ "icons/search.png", sizeof(("icons/search.png")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
140 RES_ENTRY("languages"){ "languages", sizeof(("languages")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
141 RES_ENTRY("accelerators"){ "accelerators", sizeof(("accelerators")) - 1, NSGTK_RESOURCE_FILE
, ((void*)0) }
,
142 RES_ENTRY("Messages"){ "Messages", sizeof(("Messages")) - 1, NSGTK_RESOURCE_FILE, (
(void*)0) }
,
143 { NULL((void*)0), 0, NSGTK_RESOURCE_FILE, NULL((void*)0) },
144};
145
146
147/* exported interface documented in gtk/resources.h */
148GdkCursor *nsgtk_create_menu_cursor(void)
149{
150 GdkCursor *cursor = NULL((void*)0);
151 GdkPixbuf *pixbuf;
152 nserror res;
153
154 res = nsgdk_pixbuf_new_from_resname("menu_cursor.png", &pixbuf);
155 if (res == NSERROR_OK) {
156 cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(),
157 pixbuf, 0, 3);
158 g_object_unref(pixbuf);
159 }
160
161 return cursor;
162}
163
164
165/**
166 * locate a resource
167 *
168 * The way GTK accesses resource files has changed greatly between
169 * releases. This initilises the interface that hides all the
170 * implementation details from the rest of the code.
171 *
172 * If the GResource is not enabled or the item cannot be found in the
173 * compiled in resources the files will be loaded directly from disc
174 * instead.
175 *
176 * \param respath A string vector containing the valid resource search paths
177 * \param resource A resource entry to initialise
178 */
179static nserror
180init_resource(char **respath, struct nsgtk_resource_s *resource)
181{
182 char *resname;
183#ifdef WITH_GRESOURCE1
184 int resnamelen;
185 gboolean present;
186 const gchar * const *langv;
187 int langc = 0;
188
189 langv = g_get_language_names();
190
191 /* look for resource under per language paths */
192 while (langv[langc] != NULL((void*)0)) {
7
Assuming the condition is false
8
Loop condition is false. Execution continues on line 225
193 /* allocate and fill a full resource name path buffer */
194 resnamelen = snprintf(NULL((void*)0), 0,
195 "/org/netsurf/%s/%s",
196 langv[langc], resource->name);
197 resname = malloc(resnamelen + 1);
198 if (resname == NULL((void*)0)) {
199 return NSERROR_NOMEM;
200 }
201 snprintf(resname, resnamelen + 1,
202 "/org/netsurf/%s/%s",
203 langv[langc], resource->name);
204
205 /* check if resource is present */
206 present = g_resources_get_info(resname,
207 G_RESOURCE_LOOKUP_FLAGS_NONE,
208 NULL((void*)0), NULL((void*)0), NULL((void*)0));
209 if (present == TRUE(!(0))) {
210 /* found an entry in the resources */
211 resource->path = resname;
212 resource->type = NSGTK_RESOURCE_GLIB;
213 NSLOG(netsurf, INFO, "Found gresource path %s",do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 214
, }; nslog__log(&_nslog_ctx, "Found gresource path %s", resource
->path); } } while(0)
214 resource->path)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 214
, }; nslog__log(&_nslog_ctx, "Found gresource path %s", resource
->path); } } while(0)
;
215 return NSERROR_OK;
216 }
217 NSLOG(netsurf, DEEPDEBUG,do { if (NSLOG_LEVEL_DEEPDEBUG >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_DEEPDEBUG, "frontends/gtk/resources.c", sizeof(
"frontends/gtk/resources.c") - 1, __PRETTY_FUNCTION__, sizeof
(__PRETTY_FUNCTION__) - 1, 218, }; nslog__log(&_nslog_ctx
, "gresource \"%s\" not found", resname); } } while(0)
218 "gresource \"%s\" not found", resname)do { if (NSLOG_LEVEL_DEEPDEBUG >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_DEEPDEBUG, "frontends/gtk/resources.c", sizeof(
"frontends/gtk/resources.c") - 1, __PRETTY_FUNCTION__, sizeof
(__PRETTY_FUNCTION__) - 1, 218, }; nslog__log(&_nslog_ctx
, "gresource \"%s\" not found", resname); } } while(0)
;
219 free(resname);
220
221 langc++;
222 }
223
224 /* allocate and fill a full resource name path buffer with no language*/
225 resnamelen = snprintf(NULL((void*)0), 0, "/org/netsurf/%s", resource->name);
226 resname = malloc(resnamelen + 1);
227 if (resname == NULL((void*)0)) {
9
Assuming 'resname' is equal to NULL
10
Taking true branch
228 return NSERROR_NOMEM;
11
Returning without writing to 'resource->type'
229 }
230 snprintf(resname, resnamelen + 1, "/org/netsurf/%s", resource->name);
231
232 present = g_resources_get_info(resname,
233 G_RESOURCE_LOOKUP_FLAGS_NONE,
234 NULL((void*)0), NULL((void*)0), NULL((void*)0));
235 if (present == TRUE(!(0))) {
236 /* found an entry in the resources */
237 resource->path = resname;
238 resource->type = NSGTK_RESOURCE_GLIB;
239 NSLOG(netsurf, INFO, "Found gresource path %s",do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 240
, }; nslog__log(&_nslog_ctx, "Found gresource path %s", resource
->path); } } while(0)
240 resource->path)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 240
, }; nslog__log(&_nslog_ctx, "Found gresource path %s", resource
->path); } } while(0)
;
241 return NSERROR_OK;
242 }
243 NSLOG(netsurf, DEEPDEBUG, "gresource \"%s\" not found", resname)do { if (NSLOG_LEVEL_DEEPDEBUG >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_DEEPDEBUG, "frontends/gtk/resources.c", sizeof(
"frontends/gtk/resources.c") - 1, __PRETTY_FUNCTION__, sizeof
(__PRETTY_FUNCTION__) - 1, 243, }; nslog__log(&_nslog_ctx
, "gresource \"%s\" not found", resname); } } while(0)
;
244 free(resname);
245
246#endif
247
248 /* look for file on disc */
249 resname = filepath_find(respath, resource->name);
250 if (resname != NULL((void*)0)) {
251 /* found an entry on the path */
252 resource->path = resname;
253 resource->type = NSGTK_RESOURCE_FILE;
254
255 NSLOG(netsurf, INFO,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 256
, }; nslog__log(&_nslog_ctx, "Found file resource path %s"
, resource->path); } } while(0)
256 "Found file resource path %s", resource->path)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 256
, }; nslog__log(&_nslog_ctx, "Found file resource path %s"
, resource->path); } } while(0)
;
257 return NSERROR_OK;
258 }
259
260 NSLOG(netsurf, INFO, "Unable to find resource %s on resource path",do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 261
, }; nslog__log(&_nslog_ctx, "Unable to find resource %s on resource path"
, resource->name); } } while(0)
261 resource->name)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 261
, }; nslog__log(&_nslog_ctx, "Unable to find resource %s on resource path"
, resource->name); } } while(0)
;
262
263 return NSERROR_NOT_FOUND;
264}
265
266/**
267 * locate and setup a direct resource
268 *
269 * Direct resources have general type of NSGTK_RESOURCE_GLIB but have
270 * g_resources_lookup_data() applied and the result stored so the data
271 * can be directly accessed without additional processing.
272 *
273 * \param respath A string vector containing the valid resource search paths
274 * \param resource A resource entry to initialise
275 */
276static nserror
277init_direct_resource(char **respath, struct nsgtk_resource_s *resource)
278{
279 nserror res;
280
281 res = init_resource(respath, resource);
282
283#ifdef WITH_GRESOURCE1
284 if ((res == NSERROR_OK) &&
285 (resource->type == NSGTK_RESOURCE_GLIB)) {
286 /* found gresource we can convert */
287 GBytes *data;
288
289 data = g_resources_lookup_data(resource->path,
290 G_RESOURCE_LOOKUP_FLAGS_NONE,
291 NULL((void*)0));
292 if (data != NULL((void*)0)) {
293 resource->type = NSGTK_RESOURCE_DIRECT;
294 resource->path = (char *)data;
295 }
296 }
297#endif
298
299 return res;
300}
301
302/**
303 * locate a pixbuf resource
304 *
305 * Pixbuf resources can be compiled inline
306 *
307 * \param respath A string vector containing the valid resource search paths
308 * \param resource A resource entry to initialise
309 */
310static nserror
311init_pixbuf_resource(char **respath, struct nsgtk_resource_s *resource)
312{
313#ifdef WITH_BUILTIN_PIXBUF
314 if (strncmp(resource->name, "menu_cursor.png", resource->len) == 0) {
315 resource->path = (char *)&menu_cursor_pixdata[0];
316 resource->type = NSGTK_RESOURCE_INLINE;
317 NSLOG(netsurf, INFO, "Found builtin for %s", resource->name)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 317
, }; nslog__log(&_nslog_ctx, "Found builtin for %s", resource
->name); } } while(0)
;
318 return NSERROR_OK;
319 }
320
321 if (strncmp(resource->name, "netsurf.xpm", resource->len) == 0) {
322 resource->path = (char *)&netsurf_pixdata[0];
323 resource->type = NSGTK_RESOURCE_INLINE;
324 NSLOG(netsurf, INFO, "Found builtin for %s", resource->name)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 324
, }; nslog__log(&_nslog_ctx, "Found builtin for %s", resource
->name); } } while(0)
;
325 return NSERROR_OK;
326 }
327
328 if (strncmp(resource->name, "favicon.png", resource->len) == 0) {
329 resource->path = (char *)&favicon_pixdata[0];
330 resource->type = NSGTK_RESOURCE_INLINE;
331 NSLOG(netsurf, INFO, "Found builtin for %s", resource->name)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 331
, }; nslog__log(&_nslog_ctx, "Found builtin for %s", resource
->name); } } while(0)
;
332 return NSERROR_OK;
333 }
334#endif
335 return init_resource(respath, resource);
336}
337
338/**
339 * locate a ui resource
340 *
341 * UI resources need their resource name changing to account for gtk versions
342 *
343 * \param respath A string vector containing the valid resource search paths
344 * \param ui_res A resource entry to initialise
345 */
346static nserror init_ui_resource(char **respath, struct nsgtk_resource_s *ui_res)
347{
348 int resnamelen;
349 char *resname;
350 struct nsgtk_resource_s resource;
351 nserror res;
352
353 resnamelen = ui_res->len + 10; /* allow for the expanded ui name */
354
355 resname = malloc(resnamelen);
356 if (resname == NULL((void*)0)) {
4
Assuming 'resname' is not equal to NULL
5
Taking false branch
357 return NSERROR_NOMEM;
358 }
359 snprintf(resname, resnamelen, "%s.ui", ui_res->name);
360 resource.name = resname;
361 resource.len = ui_res->len;
362 resource.path = NULL((void*)0);
363
364 res = init_resource(respath, &resource);
6
Calling 'init_resource'
12
Returning from 'init_resource'
365
366 ui_res->path = resource.path;
367 ui_res->type = resource.type;
13
Assigned value is garbage or undefined
368
369 free(resname);
370
371 return res;
372}
373
374/**
375 * Find a resource entry by name.
376 *
377 * \param resname The resource name to match.
378 * \param resource The list of resources entries to search.
379 */
380static struct nsgtk_resource_s *
381find_resource_from_name(const char *resname, struct nsgtk_resource_s *resource)
382{
383 /* find resource from name */
384 while ((resource->name != NULL((void*)0)) &&
385 ((resname[0] != resource->name[0]) ||
386 (strncmp(resource->name, resname, resource->len) != 0))) {
387 resource++;
388 }
389 return resource;
390}
391
392#ifdef SHOW_GRESOURCE
393/**
394 * Debug dump of all resources compiled in via GResource.
395 */
396static void list_gresource(void)
397{
398 const char *nspath = "/org/netsurf";
399 char **reslist;
400 char **cur;
401 GError* gerror = NULL((void*)0);
402 reslist = g_resources_enumerate_children(nspath,
403 G_RESOURCE_LOOKUP_FLAGS_NONE,
404 &gerror);
405 if (gerror) {
406 NSLOG(netsurf, INFO, "gerror %s", gerror->message)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 406
, }; nslog__log(&_nslog_ctx, "gerror %s", gerror->message
); } } while(0)
;
407 g_error_free(gerror);
408
409 } else {
410 cur = reslist;
411 while (cur != NULL((void*)0) && *cur != NULL((void*)0)) {
412 NSLOG(netsurf, INFO, "gres %s", *cur)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 412
, }; nslog__log(&_nslog_ctx, "gres %s", *cur); } } while(
0)
;
413 cur++;
414 }
415 g_strfreev(reslist);
416 }
417}
418#endif
419
420/**
421 * Initialise UI resource table
422 *
423 */
424/* exported interface documented in gtk/resources.h */
425nserror nsgtk_init_resources(char **respath)
426{
427 struct nsgtk_resource_s *resource;
428 nserror res;
429
430#ifdef SHOW_GRESOURCE
431 list_gresource();
432#endif
433
434 /* iterate the ui resource table and initialise all its members */
435 resource = &ui_resource[0];
436 while (resource->name != NULL((void*)0)) {
1
Assuming field 'name' is not equal to NULL
2
Loop condition is true. Entering loop body
437 res = init_ui_resource(respath, resource);
3
Calling 'init_ui_resource'
438 if (res != NSERROR_OK) {
439 return res;
440 }
441 resource++;
442 }
443
444 /* iterate the pixbuf resource table and initialise all its members */
445 resource = &pixbuf_resource[0];
446 while (resource->name != NULL((void*)0)) {
447 res = init_pixbuf_resource(respath, resource);
448 if (res != NSERROR_OK) {
449 return res;
450 }
451 resource++;
452 }
453
454 /* iterate the direct resource table and initialise all its members */
455 resource = &direct_resource[0];
456 while (resource->name != NULL((void*)0)) {
457 res = init_direct_resource(respath, resource);
458 if (res != NSERROR_OK) {
459 return res;
460 }
461 resource++;
462 }
463
464 return NSERROR_OK;
465}
466
467
468/* exported interface documented in gtk/resources.h */
469nserror
470nsgdk_pixbuf_new_from_resname(const char *resname, GdkPixbuf **pixbuf_out)
471{
472 struct nsgtk_resource_s *resource;
473 GdkPixbuf *new_pixbuf = NULL((void*)0);
474 GError* error = NULL((void*)0);
475
476 resource = find_resource_from_name(resname, &pixbuf_resource[0]);
477 if (resource->name == NULL((void*)0)) {
478 return NSERROR_NOT_FOUND;
479 }
480
481 switch (resource->type) {
482 case NSGTK_RESOURCE_FILE:
483 new_pixbuf = gdk_pixbuf_new_from_file(resource->path, &error);
484 break;
485
486 case NSGTK_RESOURCE_GLIB:
487#ifdef WITH_GRESOURCE1
488 new_pixbuf = gdk_pixbuf_new_from_resource(resource->path, &error);
489#endif
490 break;
491
492 case NSGTK_RESOURCE_INLINE:
493#ifdef WITH_BUILTIN_PIXBUF
494 new_pixbuf = gdk_pixbuf_new_from_inline(-1, (const guint8 *)resource->path, FALSE(0), &error);
495#endif
496 break;
497
498 case NSGTK_RESOURCE_DIRECT:
499 /* pixbuf resources are not currently direct */
500 break;
501 }
502
503 if (new_pixbuf == NULL((void*)0)) {
504 if (error != NULL((void*)0)) {
505 NSLOG(netsurf, INFO,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 509
, }; nslog__log(&_nslog_ctx, "Unable to create pixbuf from file for %s with path %s \"%s\""
, resource->name, resource->path, error->message); }
} while(0)
506 "Unable to create pixbuf from file for %s with path %s \"%s\"",do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 509
, }; nslog__log(&_nslog_ctx, "Unable to create pixbuf from file for %s with path %s \"%s\""
, resource->name, resource->path, error->message); }
} while(0)
507 resource->name,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 509
, }; nslog__log(&_nslog_ctx, "Unable to create pixbuf from file for %s with path %s \"%s\""
, resource->name, resource->path, error->message); }
} while(0)
508 resource->path,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 509
, }; nslog__log(&_nslog_ctx, "Unable to create pixbuf from file for %s with path %s \"%s\""
, resource->name, resource->path, error->message); }
} while(0)
509 error->message)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 509
, }; nslog__log(&_nslog_ctx, "Unable to create pixbuf from file for %s with path %s \"%s\""
, resource->name, resource->path, error->message); }
} while(0)
;
510 g_error_free(error);
511 } else {
512 NSLOG(netsurf, INFO,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 515
, }; nslog__log(&_nslog_ctx, "Unable to create pixbuf from file for %s with path %s"
, resource->name, resource->path); } } while(0)
513 "Unable to create pixbuf from file for %s with path %s",do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 515
, }; nslog__log(&_nslog_ctx, "Unable to create pixbuf from file for %s with path %s"
, resource->name, resource->path); } } while(0)
514 resource->name,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 515
, }; nslog__log(&_nslog_ctx, "Unable to create pixbuf from file for %s with path %s"
, resource->name, resource->path); } } while(0)
515 resource->path)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 515
, }; nslog__log(&_nslog_ctx, "Unable to create pixbuf from file for %s with path %s"
, resource->name, resource->path); } } while(0)
;
516 }
517 return NSERROR_INIT_FAILED;
518 }
519 *pixbuf_out = new_pixbuf;
520
521 return NSERROR_OK;
522}
523
524/* exported interface documented in gtk/resources.h */
525nserror
526nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out)
527{
528 GtkBuilder *new_builder;
529 struct nsgtk_resource_s *ui_res;
530 GError* error = NULL((void*)0);
531
532 ui_res = find_resource_from_name(resname, &ui_resource[0]);
533 if (ui_res->name == NULL((void*)0)) {
534 return NSERROR_NOT_FOUND;
535 }
536
537 new_builder = gtk_builder_new();
538
539 if (ui_res->type == NSGTK_RESOURCE_FILE) {
540 if (!gtk_builder_add_from_file(new_builder,
541 ui_res->path,
542 &error)) {
543 NSLOG(netsurf, INFO,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 547
, }; nslog__log(&_nslog_ctx, "Unable to add UI builder from file for %s with path %s \"%s\""
, ui_res->name, ui_res->path, error->message); } } while
(0)
544 "Unable to add UI builder from file for %s with path %s \"%s\"",do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 547
, }; nslog__log(&_nslog_ctx, "Unable to add UI builder from file for %s with path %s \"%s\""
, ui_res->name, ui_res->path, error->message); } } while
(0)
545 ui_res->name,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 547
, }; nslog__log(&_nslog_ctx, "Unable to add UI builder from file for %s with path %s \"%s\""
, ui_res->name, ui_res->path, error->message); } } while
(0)
546 ui_res->path,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 547
, }; nslog__log(&_nslog_ctx, "Unable to add UI builder from file for %s with path %s \"%s\""
, ui_res->name, ui_res->path, error->message); } } while
(0)
547 error->message)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 547
, }; nslog__log(&_nslog_ctx, "Unable to add UI builder from file for %s with path %s \"%s\""
, ui_res->name, ui_res->path, error->message); } } while
(0)
;
548 g_error_free(error);
549 g_object_unref(G_OBJECT(new_builder)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_builder)), (((GType) ((20) << (2))))))))
);
550 return NSERROR_INIT_FAILED;
551 }
552 } else {
553 if (!nsgtk_builder_add_from_resource(new_builder,
554 ui_res->path,
555 &error)) {
556 NSLOG(netsurf, INFO,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 560
, }; nslog__log(&_nslog_ctx, "Unable to add UI builder from resource for %s with path %s \"%s\""
, ui_res->name, ui_res->path, error->message); } } while
(0)
557 "Unable to add UI builder from resource for %s with path %s \"%s\"",do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 560
, }; nslog__log(&_nslog_ctx, "Unable to add UI builder from resource for %s with path %s \"%s\""
, ui_res->name, ui_res->path, error->message); } } while
(0)
558 ui_res->name,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 560
, }; nslog__log(&_nslog_ctx, "Unable to add UI builder from resource for %s with path %s \"%s\""
, ui_res->name, ui_res->path, error->message); } } while
(0)
559 ui_res->path,do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 560
, }; nslog__log(&_nslog_ctx, "Unable to add UI builder from resource for %s with path %s \"%s\""
, ui_res->name, ui_res->path, error->message); } } while
(0)
560 error->message)do { if (NSLOG_LEVEL_INFO >= NSLOG_LEVEL_VERBOSE) { static
nslog_entry_context_t _nslog_ctx = { &__nslog_category_netsurf
, NSLOG_LEVEL_INFO, "frontends/gtk/resources.c", sizeof("frontends/gtk/resources.c"
) - 1, __PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 1, 560
, }; nslog__log(&_nslog_ctx, "Unable to add UI builder from resource for %s with path %s \"%s\""
, ui_res->name, ui_res->path, error->message); } } while
(0)
;
561 g_error_free(error);
562 g_object_unref(G_OBJECT(new_builder)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((new_builder)), (((GType) ((20) << (2))))))))
);
563 return NSERROR_INIT_FAILED;
564 }
565 }
566
567 *builder_out = new_builder;
568
569 return NSERROR_OK;
570}
571
572/* exported interface documented in gtk/resources.h */
573nserror
574nsgtk_data_from_resname(const char *resname,
575 const uint8_t ** data_out,
576 size_t *data_size_out)
577{
578#ifdef WITH_GRESOURCE1
579 struct nsgtk_resource_s *resource;
580 GBytes *data;
581 const gchar *buffer;
582 gsize buffer_length;
583
584 resource = find_resource_from_name(resname, &direct_resource[0]);
585 if ((resource->name == NULL((void*)0)) ||
586 (resource->type != NSGTK_RESOURCE_DIRECT)) {
587 return NSERROR_NOT_FOUND;
588 }
589
590 data = (GBytes *)resource->path;
591
592 buffer_length = 0;
593 buffer = g_bytes_get_data(data, &buffer_length);
594
595 if (buffer == NULL((void*)0)) {
596 return NSERROR_NOMEM;
597 }
598
599 *data_out = (const uint8_t *)buffer;
600 *data_size_out = (size_t)buffer_length;
601
602 return NSERROR_OK;
603#else
604 /** \todo consider adding compiled inline resources for things
605 * other than pixbufs.
606 */
607 return NSERROR_NOT_FOUND;
608#endif
609}
610
611/* exported interface documented in gtk/resources.h */
612nserror
613nsgtk_path_from_resname(const char *resname, const char **path_out)
614{
615 struct nsgtk_resource_s *resource;
616
617 resource = find_resource_from_name(resname, &direct_resource[0]);
618 if ((resource->name == NULL((void*)0)) ||
619 (resource->type != NSGTK_RESOURCE_FILE)) {
620 return NSERROR_NOT_FOUND;
621 }
622
623 *path_out = (const char *)resource->path;
624
625 return NSERROR_OK;
626}