Debian Codegraph @

src/runtime.c

raw symbols SCIP
1 /*
2 * Copyright (c) 2017-2022 Joris Vink <[email protected]>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #include <sys/param.h>
18 #include <sys/types.h>
19
20 #include "kore.h"cxx . . $ `<file>/include/kore/kore.h`/
21
22 #if !defined(KORE_NO_HTTP)
23 #include "http.h"cxx . . $ `<file>/include/kore/http.h`/
24 #endif
25
26 #if defined(KORE_USE_PYTHON)
27 #include "python_api.h"
28 #endif
29
30 static void native_runtime_executecxx . . $ native_runtime_execute(5d22bdacc48458e8).(void *);
31 static int native_runtime_onloadcxx . . $ native_runtime_onload(7fb3b8e28157cebd).(void *, int);
32 static void native_runtime_signalcxx . . $ native_runtime_signal(d0320739773070f2).(void *, int);
33 static void native_runtime_connectcxx . . $ native_runtime_connect(faac6bd4fab3515f).(void *, struct connectioncxx . . $ connection# *);
34 static void native_runtime_configurecxx . . $ native_runtime_configure(df26e177ba16e28c).(void *, int, char **);
35 #if !defined(KORE_NO_HTTP)
36 static int native_runtime_http_requestcxx . . $ native_runtime_http_request(ee121ca6d86ae7d3).(void *, struct http_requestcxx . . $ http_request# *);
37 static void native_runtime_http_request_freecxx . . $ native_runtime_http_request_free(ed945ae527a0d9f).(void *, struct http_requestcxx . . $ http_request# *);
38 static void native_runtime_http_body_chunkcxx . . $ native_runtime_http_body_chunk(5cca61f3a47f1d5e).(void *, struct http_requestcxx . . $ http_request# *,
39 const void *, size_t);
40 static int native_runtime_validatorcxx . . $ native_runtime_validator(f3a98330e6b5e6c6).(void *, struct http_requestcxx . . $ http_request# *,
41 const void *);
42
43 static void native_runtime_wsmessagecxx . . $ native_runtime_wsmessage(f8da54d2f2accb61).(void *, struct connectioncxx . . $ connection# *, u_int8_tcxx . . $ u_int8_t#,
44 const void *, size_t);
45 #endif
46
47 struct kore_runtimecxx . . $ kore_runtime# kore_native_runtimecxx . . $ kore_native_runtime. = {
48 KORE_RUNTIME_NATIVEcxx . . $ `include/kore/kore.h:274:9`!,
49 #if !defined(KORE_NO_HTTP)
50 .http_request = native_runtime_http_requestcxx . . $ native_runtime_http_request(ee121ca6d86ae7d3).,
51 .http_request_free = native_runtime_http_request_freecxx . . $ native_runtime_http_request_free(ed945ae527a0d9f).,
52 .http_body_chunk = native_runtime_http_body_chunkcxx . . $ native_runtime_http_body_chunk(5cca61f3a47f1d5e).,
53 .validator = native_runtime_validatorcxx . . $ native_runtime_validator(f3a98330e6b5e6c6).,
54 .wsconnect = native_runtime_connectcxx . . $ native_runtime_connect(faac6bd4fab3515f).,
55 .wsmessage = native_runtime_wsmessagecxx . . $ native_runtime_wsmessage(f8da54d2f2accb61).,
56 .wsdisconnect = native_runtime_connectcxx . . $ native_runtime_connect(faac6bd4fab3515f).,
57 #endif
58 .onload = native_runtime_onloadcxx . . $ native_runtime_onload(7fb3b8e28157cebd).,
59 .signal = native_runtime_signalcxx . . $ native_runtime_signal(d0320739773070f2).,
60 .connect = native_runtime_connectcxx . . $ native_runtime_connect(faac6bd4fab3515f).,
61 .execute = native_runtime_executecxx . . $ native_runtime_execute(5d22bdacc48458e8).,
62 .configure = native_runtime_configurecxx . . $ native_runtime_configure(df26e177ba16e28c).
63 };
64
65 struct kore_runtime_callcxx . . $ kore_runtime_call# *
66 kore_runtime_getcallcxx . . $ kore_runtime_getcall(b514b5951ac4d62f).(const char *symbol)
67 {
68 void *ptr;
69 struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall;
70 struct kore_runtimecxx . . $ kore_runtime# *runtime;
71
72 ptr = kore_module_getsymcxx . . $ kore_module_getsym(49a0dbba971d1b15).(symbol, &runtime);
73 if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
74 return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
75
76 rcall = kore_malloccxx . . $ kore_malloc(bfcfa4d6b7f7ef64).(sizeof(*rcall));
77 rcall->addrcxx . . $ kore_runtime_call#addr. = ptr;
78 rcall->runtimecxx . . $ kore_runtime_call#runtime. = runtime;
79
80 return (rcall);
81 }
82
83 void
84 kore_runtime_executecxx . . $ kore_runtime_execute(5bf3e738821b3e09).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall)
85 {
86 rcall->runtimecxx . . $ kore_runtime_call#runtime.->executecxx . . $ kore_runtime#execute.(rcall->addrcxx . . $ kore_runtime_call#addr.);
87 }
88
89 void
90 kore_runtime_configurecxx . . $ kore_runtime_configure(eedb5d87327531fa).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall, int argc, char **argv)
91 {
92 rcall->runtimecxx . . $ kore_runtime_call#runtime.->configurecxx . . $ kore_runtime#configure.(rcall->addrcxx . . $ kore_runtime_call#addr., argc, argv);
93 }
94
95 int
96 kore_runtime_onloadcxx . . $ kore_runtime_onload(c29b8bc328b374).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall, int action)
97 {
98 return (rcall->runtimecxx . . $ kore_runtime_call#runtime.->onloadcxx . . $ kore_runtime#onload.(rcall->addrcxx . . $ kore_runtime_call#addr., action));
99 }
100
101 void
102 kore_runtime_connectcxx . . $ kore_runtime_connect(7abb6533877ecf95).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall, struct connectioncxx . . $ connection# *c)
103 {
104 rcall->runtimecxx . . $ kore_runtime_call#runtime.->connectcxx . . $ kore_runtime#connect.(rcall->addrcxx . . $ kore_runtime_call#addr., c);
105 }
106
107 void
108 kore_runtime_signalcxx . . $ kore_runtime_signal(dd2e1fd639e9b421).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall, int sig)
109 {
110 rcall->runtimecxx . . $ kore_runtime_call#runtime.->signalcxx . . $ kore_runtime#signal.(rcall->addrcxx . . $ kore_runtime_call#addr., sig);
111 }
112
113 #if !defined(KORE_NO_HTTP)
114 int
115 kore_runtime_http_requestcxx . . $ kore_runtime_http_request(2cad211aba5d4032).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall,
116 struct http_requestcxx . . $ http_request# *req)
117 {
118 return (rcall->runtimecxx . . $ kore_runtime_call#runtime.->http_requestcxx . . $ kore_runtime#http_request.(rcall->addrcxx . . $ kore_runtime_call#addr., req));
119 }
120
121 void
122 kore_runtime_http_request_freecxx . . $ kore_runtime_http_request_free(b2fab79a8cd0cb0d).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall,
123 struct http_requestcxx . . $ http_request# *req)
124 {
125 rcall->runtimecxx . . $ kore_runtime_call#runtime.->http_request_freecxx . . $ kore_runtime#http_request_free.(rcall->addrcxx . . $ kore_runtime_call#addr., req);
126 }
127
128 void
129 kore_runtime_http_body_chunkcxx . . $ kore_runtime_http_body_chunk(37447da8dc885054).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall,
130 struct http_requestcxx . . $ http_request# *req, const void *data, size_t len)
131 {
132 rcall->runtimecxx . . $ kore_runtime_call#runtime.->http_body_chunkcxx . . $ kore_runtime#http_body_chunk.(rcall->addrcxx . . $ kore_runtime_call#addr., req, data, len);
133 }
134
135 int
136 kore_runtime_validatorcxx . . $ kore_runtime_validator(4393986cf857ca4).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall,
137 struct http_requestcxx . . $ http_request# *req, const void *data)
138 {
139 return (rcall->runtimecxx . . $ kore_runtime_call#runtime.->validatorcxx . . $ kore_runtime#validator.(rcall->addrcxx . . $ kore_runtime_call#addr., req, data));
140 }
141
142 void
143 kore_runtime_wsconnectcxx . . $ kore_runtime_wsconnect(7abb6533877ecf95).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall, struct connectioncxx . . $ connection# *c)
144 {
145 rcall->runtimecxx . . $ kore_runtime_call#runtime.->wsconnectcxx . . $ kore_runtime#wsconnect.(rcall->addrcxx . . $ kore_runtime_call#addr., c);
146 }
147
148 void
149 kore_runtime_wsmessagecxx . . $ kore_runtime_wsmessage(d015b3a583ab822f).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall, struct connectioncxx . . $ connection# *c,
150 u_int8_tcxx . . $ u_int8_t# op, const void *data, size_t len)
151 {
152 rcall->runtimecxx . . $ kore_runtime_call#runtime.->wsmessagecxx . . $ kore_runtime#wsmessage.(rcall->addrcxx . . $ kore_runtime_call#addr., c, op, data, len);
153 }
154
155 void
156 kore_runtime_wsdisconnectcxx . . $ kore_runtime_wsdisconnect(7abb6533877ecf95).(struct kore_runtime_callcxx . . $ kore_runtime_call# *rcall, struct connectioncxx . . $ connection# *c)
157 {
158 rcall->runtimecxx . . $ kore_runtime_call#runtime.->wsdisconnectcxx . . $ kore_runtime#wsdisconnect.(rcall->addrcxx . . $ kore_runtime_call#addr., c);
159 }
160 #endif
161
162 static void
163 native_runtime_executecxx . . $ native_runtime_execute(5d22bdacc48458e8).(void *addr)
164 {
165 void (*cb)(void);
166
167 *(void **)&(cb) = addr;
168 cb();
169 }
170
171 static void
172 native_runtime_configurecxx . . $ native_runtime_configure(df26e177ba16e28c).(void *addr, int argc, char **argv)
173 {
174 void (*cb)(int, char **);
175
176 *(void **)&(cb) = addr;
177 cb(argc, argv);
178 }
179
180 static void
181 native_runtime_connectcxx . . $ native_runtime_connect(faac6bd4fab3515f).(void *addr, struct connectioncxx . . $ connection# *c)
182 {
183 void (*cb)(struct connectioncxx . . $ connection# *);
184
185 *(void **)&(cb) = addr;
186 cb(c);
187 }
188
189 static int
190 native_runtime_onloadcxx . . $ native_runtime_onload(7fb3b8e28157cebd).(void *addr, int action)
191 {
192 int (*cb)(int);
193
194 *(void **)&(cb) = addr;
195 return (cb(action));
196 }
197
198 static void
199 native_runtime_signalcxx . . $ native_runtime_signal(d0320739773070f2).(void *addr, int sig)
200 {
201 void (*cb)(int);
202
203 *(void **)&(cb) = addr;
204 cb(sig);
205 }
206
207 #if !defined(KORE_NO_HTTP)
208 static int
209 native_runtime_http_requestcxx . . $ native_runtime_http_request(ee121ca6d86ae7d3).(void *addr, struct http_requestcxx . . $ http_request# *req)
210 {
211 int (*cb)(struct http_requestcxx . . $ http_request# *);
212
213 *(void **)&(cb) = addr;
214 return (cb(req));
215 }
216
217 static void
218 native_runtime_http_request_freecxx . . $ native_runtime_http_request_free(ed945ae527a0d9f).(void *addr, struct http_requestcxx . . $ http_request# *req)
219 {
220 int (*cb)(struct http_requestcxx . . $ http_request# *);
221
222 *(void **)&(cb) = addr;
223 cb(req);
224 }
225
226 static void
227 native_runtime_http_body_chunkcxx . . $ native_runtime_http_body_chunk(5cca61f3a47f1d5e).(void *addr, struct http_requestcxx . . $ http_request# *req,
228 const void *data, size_t len)
229 {
230 void (*cb)(struct http_requestcxx . . $ http_request# *, const void *, size_t);
231
232 *(void **)&(cb) = addr;
233
234 cb(req, data, len);
235 }
236
237 static int
238 native_runtime_validatorcxx . . $ native_runtime_validator(f3a98330e6b5e6c6).(void *addr, struct http_requestcxx . . $ http_request# *req, const void *data)
239 {
240 int (*cb)(struct http_requestcxx . . $ http_request# *, const void *);
241
242 *(void **)&(cb) = addr;
243 return (cb(req, data));
244 }
245
246 static void
247 native_runtime_wsmessagecxx . . $ native_runtime_wsmessage(f8da54d2f2accb61).(void *addr, struct connectioncxx . . $ connection# *c, u_int8_tcxx . . $ u_int8_t# op,
248 const void *data, size_t len)
249 {
250 void (*cb)(struct connectioncxx . . $ connection# *, u_int8_tcxx . . $ u_int8_t#, const void *, size_t);
251
252 *(void **)&(cb) = addr;
253 cb(c, op, data, len);
254
255 }
256 #endif