Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
folium-app
GitHub Repository: folium-app/Folium
Path: blob/a-new-beginning/SharedDependencies/Sources/glib/include/glib.h
2 views
1
#ifndef GLIB_SHIM_H
2
#define GLIB_SHIM_H
3
4
#include <stdint.h>
5
#include <stdbool.h>
6
#include <signal.h>
7
#include <stdio.h>
8
#include <stdarg.h>
9
#include <string.h>
10
#include <stddef.h>
11
12
#if defined(WIN32) || defined(_WIN32) || defined(_MSC_VER)
13
#define G_OS_WIN32 1
14
#endif
15
16
#define G_LITTLE_ENDIAN 0
17
#define G_BIG_ENDIAN 1
18
#define G_BYTE_ORDER G_LITTLE_ENDIAN
19
20
#define GUINT16_FROM_BE(n) ntohs(n)
21
#define GUINT16_TO_BE(n) htons(n)
22
#define GUINT32_FROM_BE(n) ntohl(n)
23
#define GUINT32_TO_BE(n) htonl(n)
24
25
#define GINT16_TO_BE(n) (int16_t) htons(n)
26
#define GINT16_FROM_BE(n) (int16_t) ntohs(n)
27
#define GINT32_TO_BE(n) (int32_t) htonl(n)
28
#define GINT32_FROM_BE(n) (int32_t) ntohl(n)
29
30
#define G_N_ELEMENTS(arr) (sizeof(arr) / sizeof(arr[0]))
31
32
#define G_GNUC_PRINTF(x, y)
33
34
#define GLIB_CHECK_VERSION(x, y, z) 1
35
#define G_STATIC_ASSERT(...)
36
#define g_assert assert
37
#define G_UNLIKELY(x) __builtin_expect(x, 0)
38
39
#define g_return_if_fail(expr) \
40
do { \
41
if (!(expr)) \
42
return; \
43
} while (false)
44
45
#define g_return_val_if_fail(expr, val) \
46
do { \
47
if (!(expr)) \
48
return (val); \
49
} while (false)
50
51
#define g_warn_if_reached() \
52
do { \
53
g_warning("g_warn_if_reached: Reached " __FILE__ ":%d", __LINE__); \
54
} while (false)
55
56
57
#define g_warn_if_fail(expr) \
58
do { \
59
if (!(expr)) \
60
g_warning("g_warn_if_fail: Expression '" #expr "' failed at " __FILE__ ":%d", __LINE__); \
61
} while (false)
62
63
#define g_assert_not_reached() \
64
do { \
65
assert(false && "g_assert_not_reached"); \
66
__builtin_unreachable(); \
67
} while (false)
68
69
#define GLIB_SIZEOF_VOID_P 8
70
#ifndef MAX
71
#define MAX(a, b) (a > b ? a : b)
72
#endif
73
#ifndef MIN
74
#define MIN(a, b) (a < b ? a : b)
75
#endif
76
77
#ifndef TRUE
78
#define TRUE true
79
#endif
80
#ifndef FALSE
81
#define FALSE false
82
#endif
83
84
typedef bool gboolean;
85
typedef char gchar;
86
typedef int gint;
87
typedef size_t gsize;
88
typedef void* gpointer;
89
90
//RSTSLIRP
91
#define g_debug(format, ...) //printf("[" G_LOG_DOMAIN ": debug] " format, ##__VA_ARGS__)
92
#define g_warning(format, ...) //printf("[" G_LOG_DOMAIN ": warning] " format, ##__VA_ARGS__)
93
#define g_error(format, ...) //printf("[" G_LOG_DOMAIN ": error] " format, ##__VA_ARGS__)
94
#define g_critical(format, ...) //printf("[" G_LOG_DOMAIN ": critical] " format, ##__VA_ARGS__)
95
96
#define g_new(type, count) (type*) (count > 0 ? malloc(sizeof(type) * count) : NULL)
97
#define g_new0(type, count) (type*) (count > 0 ? calloc(count, sizeof(type)) : NULL)
98
99
#define g_malloc malloc
100
#define g_malloc0(size) calloc(1, size)
101
#define g_realloc realloc
102
#define g_free free
103
104
#define g_getenv(var) getenv(var)
105
106
typedef struct GString {
107
gchar* str;
108
gsize len;
109
gsize allocated_len;
110
} GString;
111
112
typedef gchar** GStrv;
113
114
GString* g_string_new(gchar* initial);
115
gchar* g_string_free(GString* string, gboolean free_segment);
116
void g_string_append_printf(GString* gstr, const gchar* format, ...);
117
gchar* g_strstr_len(const gchar* haystack, int len, const gchar* needle);
118
gchar* g_strdup(const gchar* str);
119
#ifdef _MSC_VER
120
#define g_ascii_strcasecmp(a, b) stricmp(a, b)
121
#else
122
#define g_ascii_strcasecmp(a, b) strcasecmp(a, b)
123
#endif
124
125
#define g_str_has_prefix(str, pfx) (strncmp(str, pfx, strlen(pfx)) == 0)
126
#define g_snprintf snprintf
127
#define g_vsnprintf vsnprintf
128
129
gint g_strv_length(GStrv strings);
130
void g_strfreev(GStrv strings);
131
132
typedef uint32_t GRand;
133
gint g_rand_int_range(GRand* grand, gint min, gint max);
134
GRand* g_rand_new();
135
void g_rand_free(GRand* rand);
136
137
typedef struct GError {
138
const gchar* message;
139
} GError;
140
141
void g_error_free(GError* error);
142
#define g_strerror(err) strerror(err)
143
144
typedef void (*GSpawnChildSetupFunc)(gpointer ptr);
145
typedef enum GSpawnFlags {
146
G_SPAWN_SEARCH_PATH
147
} GSpawnFlags;
148
149
typedef gint GPid;
150
151
gboolean g_shell_parse_argv(const gchar* command_line, gint* argcp, gchar*** argvp, GError** error);
152
153
gboolean g_spawn_async_with_fds(const gchar *working_directory, gchar **argv,
154
gchar **envp, GSpawnFlags flags,
155
GSpawnChildSetupFunc child_setup,
156
gpointer user_data, GPid *child_pid, gint stdin_fd,
157
gint stdout_fd, gint stderr_fd, GError **error);
158
159
typedef struct { gchar* key; int value; } GDebugKey;
160
#define g_parse_debug_string(str, keys, nkeys) 0
161
162
163
#endif
164
165