Debian Codegraph @

vendored-meson/meson/test cases/frameworks/7 gnome/resources/simple-main.c

raw
1 #include<stdio.h>
2 #include<string.h>
3 #include<gio/gio.h>
4 #include"simple-resources.h"
5
6 #define EXPECTED "This is a resource.\n"
7
8 int main(int argc, char **argv) {
9 simple_resources_get_resource();
10
11 GError *err = NULL;
12 GBytes *data = g_resources_lookup_data("/com/example/myprog/res1.txt",
13 G_RESOURCE_LOOKUP_FLAGS_NONE, &err);
14
15 if(data == NULL) {
16 fprintf(stderr, "Data lookup failed: %s\n", err->message);
17 return 1;
18 }
19 if(strcmp(g_bytes_get_data(data, NULL), EXPECTED) != 0) {
20 fprintf(stderr, "Resource contents are wrong:\n %s\n",
21 (const char*)g_bytes_get_data(data, NULL));
22 return 1;
23 }
24 fprintf(stdout, "All ok.\n");
25 g_bytes_unref(data);
26 return 0;
27 }