/work/fu-genesys-usbhub-struct.c
Line | Count | Source |
1 | | /* |
2 | | * This file is auto-generated, do not modify! |
3 | | * |
4 | | * SPDX-License-Identifier: LGPL-2.1-or-later |
5 | | */ |
6 | | |
7 | | #include "config.h" |
8 | | |
9 | | #include <glib.h> |
10 | | |
11 | | #include "fu-genesys-usbhub-struct.h" |
12 | | #include "fu-byte-array.h" |
13 | | #include "fu-mem-private.h" |
14 | | #include "fu-string.h" |
15 | | |
16 | | #ifdef G_LOG_DOMAIN |
17 | | #undef G_LOG_DOMAIN |
18 | | #endif |
19 | 0 | #define G_LOG_DOMAIN "FuStruct" |
20 | | |
21 | | /** |
22 | | * fu_genesys_ts_version_to_string: |
23 | | * @val: value, e.g. %FU_GENESYS_TS_VERSION_BONDING |
24 | | * |
25 | | * Converts an enumerated value to a string. |
26 | | * |
27 | | * Returns: identifier string |
28 | | **/ |
29 | | const gchar * |
30 | | fu_genesys_ts_version_to_string(FuGenesysTsVersion val) |
31 | 0 | { |
32 | 0 | if (val == FU_GENESYS_TS_VERSION_DYNAMIC_9_BYTE) |
33 | 0 | return "dynamic-9-byte"; |
34 | 0 | if (val == FU_GENESYS_TS_VERSION_BONDING) |
35 | 0 | return "bonding"; |
36 | 0 | if (val == FU_GENESYS_TS_VERSION_BONDING_QC) |
37 | 0 | return "bonding-qc"; |
38 | 0 | if (val == FU_GENESYS_TS_VERSION_VENDOR_SUPPORT) |
39 | 0 | return "vendor-support"; |
40 | 0 | if (val == FU_GENESYS_TS_VERSION_MULTI_TOKEN) |
41 | 0 | return "multi-token"; |
42 | 0 | if (val == FU_GENESYS_TS_VERSION_DYNAMIC_2ND) |
43 | 0 | return "dynamic-2nd"; |
44 | 0 | if (val == FU_GENESYS_TS_VERSION_RESERVED) |
45 | 0 | return "reserved"; |
46 | 0 | if (val == FU_GENESYS_TS_VERSION_DYNAMIC_13_BYTE) |
47 | 0 | return "dynamic-13-byte"; |
48 | 0 | if (val == FU_GENESYS_TS_VERSION_BRAND_PROJECT) |
49 | 0 | return "brand-project"; |
50 | 0 | return NULL; |
51 | 0 | } |
52 | | |
53 | | /** |
54 | | * fu_genesys_fw_status_to_string: |
55 | | * @val: value, e.g. %FU_GENESYS_FW_STATUS_BANK1 |
56 | | * |
57 | | * Converts an enumerated value to a string. |
58 | | * |
59 | | * Returns: identifier string |
60 | | **/ |
61 | | const gchar * |
62 | | fu_genesys_fw_status_to_string(FuGenesysFwStatus val) |
63 | 0 | { |
64 | 0 | if (val == FU_GENESYS_FW_STATUS_MASK) |
65 | 0 | return "mask"; |
66 | 0 | if (val == FU_GENESYS_FW_STATUS_BANK1) |
67 | 0 | return "bank1"; |
68 | 0 | if (val == FU_GENESYS_FW_STATUS_BANK2) |
69 | 0 | return "bank2"; |
70 | 0 | return NULL; |
71 | 0 | } |
72 | | |
73 | | /** |
74 | | * fu_genesys_vs_codesign_check_to_string: |
75 | | * @val: value, e.g. %FU_GENESYS_VS_CODESIGN_CHECK_SCALER |
76 | | * |
77 | | * Converts an enumerated value to a string. |
78 | | * |
79 | | * Returns: identifier string |
80 | | **/ |
81 | | const gchar * |
82 | | fu_genesys_vs_codesign_check_to_string(FuGenesysVsCodesignCheck val) |
83 | 0 | { |
84 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_UNSUPPORTED) |
85 | 0 | return "unsupported"; |
86 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_SCALER) |
87 | 0 | return "scaler"; |
88 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_FW) |
89 | 0 | return "fw"; |
90 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_MASTER) |
91 | 0 | return "master"; |
92 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_RESERVED) |
93 | 0 | return "reserved"; |
94 | 0 | if (val == FU_GENESYS_VS_CODESIGN_CHECK_HW) |
95 | 0 | return "hw"; |
96 | 0 | return NULL; |
97 | 0 | } |
98 | | |
99 | | /** |
100 | | * fu_genesys_vs_hid_isp_to_string: |
101 | | * @val: value, e.g. %FU_GENESYS_VS_HID_ISP_SUPPORT |
102 | | * |
103 | | * Converts an enumerated value to a string. |
104 | | * |
105 | | * Returns: identifier string |
106 | | **/ |
107 | | static const gchar * |
108 | | fu_genesys_vs_hid_isp_to_string(FuGenesysVsHidIsp val) |
109 | 0 | { |
110 | 0 | if (val == FU_GENESYS_VS_HID_ISP_UNSUPPORTED) |
111 | 0 | return "unsupported"; |
112 | 0 | if (val == FU_GENESYS_VS_HID_ISP_SUPPORT) |
113 | 0 | return "support"; |
114 | 0 | if (val == FU_GENESYS_VS_HID_ISP_CODESIGN_N_RESET) |
115 | 0 | return "codesign-n-reset"; |
116 | 0 | return NULL; |
117 | 0 | } |
118 | | |
119 | | /** |
120 | | * fu_genesys_fw_codesign_to_string: |
121 | | * @val: value, e.g. %FU_GENESYS_FW_CODESIGN_RSA |
122 | | * |
123 | | * Converts an enumerated value to a string. |
124 | | * |
125 | | * Returns: identifier string |
126 | | **/ |
127 | | const gchar * |
128 | | fu_genesys_fw_codesign_to_string(FuGenesysFwCodesign val) |
129 | 0 | { |
130 | 0 | if (val == FU_GENESYS_FW_CODESIGN_NONE) |
131 | 0 | return "none"; |
132 | 0 | if (val == FU_GENESYS_FW_CODESIGN_RSA) |
133 | 0 | return "rsa"; |
134 | 0 | if (val == FU_GENESYS_FW_CODESIGN_ECDSA) |
135 | 0 | return "ecdsa"; |
136 | 0 | return NULL; |
137 | 0 | } |
138 | | |
139 | | /** |
140 | | * fu_genesys_fw_type_to_string: |
141 | | * @val: value, e.g. %FU_GENESYS_FW_TYPE_DEV_BRIDGE |
142 | | * |
143 | | * Converts an enumerated value to a string. |
144 | | * |
145 | | * Returns: identifier string |
146 | | **/ |
147 | | const gchar * |
148 | | fu_genesys_fw_type_to_string(FuGenesysFwType val) |
149 | 29.7k | { |
150 | 29.7k | if (val == FU_GENESYS_FW_TYPE_HUB) |
151 | 1.52k | return "hub"; |
152 | 28.2k | if (val == FU_GENESYS_FW_TYPE_DEV_BRIDGE) |
153 | 16.9k | return "dev-bridge"; |
154 | 11.3k | if (val == FU_GENESYS_FW_TYPE_PD) |
155 | 11.2k | return "pd"; |
156 | 38 | if (val == FU_GENESYS_FW_TYPE_CODESIGN) |
157 | 38 | return "codesign"; |
158 | 0 | if (val == FU_GENESYS_FW_TYPE_INSIDE_HUB_COUNT) |
159 | 0 | return "inside-hub-count"; |
160 | 0 | if (val == FU_GENESYS_FW_TYPE_SCALER) |
161 | 0 | return "scaler"; |
162 | 0 | return NULL; |
163 | 0 | } |
164 | | /** |
165 | | * fu_struct_genesys_firmware_hdr_ref: (skip): |
166 | | **/ |
167 | | FuStructGenesysFirmwareHdr * |
168 | | fu_struct_genesys_firmware_hdr_ref(FuStructGenesysFirmwareHdr *st) |
169 | 0 | { |
170 | 0 | g_return_val_if_fail(st != NULL, NULL); |
171 | 0 | st->refcount++; |
172 | 0 | return st; |
173 | 0 | } |
174 | | /** |
175 | | * fu_struct_genesys_firmware_hdr_unref: (skip): |
176 | | **/ |
177 | | void |
178 | | fu_struct_genesys_firmware_hdr_unref(FuStructGenesysFirmwareHdr *st) |
179 | 203k | { |
180 | 203k | g_return_if_fail(st != NULL); |
181 | 203k | if (st->refcount == 0) { |
182 | 0 | g_critical("FuStructGenesysFirmwareHdr refcount already zero"); |
183 | 0 | return; |
184 | 0 | } |
185 | 203k | if (--st->refcount > 0) |
186 | 0 | return; |
187 | 203k | if (st->buf != NULL) |
188 | 203k | g_byte_array_unref(st->buf); |
189 | 203k | g_free(st); |
190 | 203k | } |
191 | | /** |
192 | | * fu_struct_genesys_firmware_hdr_new_internal: (skip): |
193 | | **/ |
194 | | static FuStructGenesysFirmwareHdr * |
195 | | fu_struct_genesys_firmware_hdr_new_internal(void) |
196 | 203k | { |
197 | 203k | FuStructGenesysFirmwareHdr *st = g_new0(FuStructGenesysFirmwareHdr, 1); |
198 | 203k | st->refcount = 1; |
199 | 203k | return st; |
200 | 203k | } |
201 | | |
202 | | /* getters */ |
203 | | /** |
204 | | * fu_struct_genesys_firmware_hdr_get_magic: (skip): |
205 | | **/ |
206 | | static gchar * |
207 | | fu_struct_genesys_firmware_hdr_get_magic(const FuStructGenesysFirmwareHdr *st) |
208 | 171k | { |
209 | 171k | g_return_val_if_fail(st != NULL, NULL); |
210 | 171k | return fu_memstrsafe(st->buf->data, st->buf->len, 252, 4, NULL); |
211 | 171k | } |
212 | | |
213 | | /* setters */ |
214 | | static gboolean |
215 | | fu_struct_genesys_firmware_hdr_validate_internal(FuStructGenesysFirmwareHdr *st, GError **error) |
216 | 172k | { |
217 | 172k | g_return_val_if_fail(st != NULL, FALSE); |
218 | 172k | if (strncmp((const gchar *) (st->buf->data + 252), "XROM", 4) != 0) { |
219 | 171k | g_autofree gchar *str = fu_struct_genesys_firmware_hdr_get_magic(st); |
220 | 171k | g_set_error(error, |
221 | 171k | FWUPD_ERROR, |
222 | 171k | FWUPD_ERROR_INVALID_DATA, |
223 | 171k | "constant FuStructGenesysFirmwareHdr.magic was not valid, " |
224 | 171k | "expected 'XROM' and got '%s'", |
225 | 171k | str); |
226 | 171k | return FALSE; |
227 | 171k | } |
228 | 1.66k | return TRUE; |
229 | 172k | } |
230 | | /** |
231 | | * fu_struct_genesys_firmware_hdr_validate_stream: (skip): |
232 | | **/ |
233 | | gboolean |
234 | | fu_struct_genesys_firmware_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error) |
235 | 203k | { |
236 | 203k | g_autoptr(FuStructGenesysFirmwareHdr) st = fu_struct_genesys_firmware_hdr_new_internal(); |
237 | 203k | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
238 | 203k | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
239 | 203k | st->buf = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error); |
240 | 203k | if (st->buf == NULL) { |
241 | 0 | g_prefix_error(error, "FuStructGenesysFirmwareHdr failed read of 0x%x: ", (guint) 256); |
242 | 0 | return FALSE; |
243 | 0 | } |
244 | 203k | if (st->buf->len != 256) { |
245 | 31.0k | g_set_error(error, |
246 | 31.0k | FWUPD_ERROR, |
247 | 31.0k | FWUPD_ERROR_INVALID_DATA, |
248 | 31.0k | "FuStructGenesysFirmwareHdr requested 0x%x and got 0x%x", |
249 | 31.0k | (guint) 256, |
250 | 31.0k | (guint) st->buf->len); |
251 | 31.0k | return FALSE; |
252 | 31.0k | } |
253 | 172k | return fu_struct_genesys_firmware_hdr_validate_internal(st, error); |
254 | 203k | } |
255 | | /** |
256 | | * fu_struct_genesys_dev_firmware_hdr_ref: (skip): |
257 | | **/ |
258 | | FuStructGenesysDevFirmwareHdr * |
259 | | fu_struct_genesys_dev_firmware_hdr_ref(FuStructGenesysDevFirmwareHdr *st) |
260 | 0 | { |
261 | 0 | g_return_val_if_fail(st != NULL, NULL); |
262 | 0 | st->refcount++; |
263 | 0 | return st; |
264 | 0 | } |
265 | | /** |
266 | | * fu_struct_genesys_dev_firmware_hdr_unref: (skip): |
267 | | **/ |
268 | | void |
269 | | fu_struct_genesys_dev_firmware_hdr_unref(FuStructGenesysDevFirmwareHdr *st) |
270 | 28.6k | { |
271 | 28.6k | g_return_if_fail(st != NULL); |
272 | 28.6k | if (st->refcount == 0) { |
273 | 0 | g_critical("FuStructGenesysDevFirmwareHdr refcount already zero"); |
274 | 0 | return; |
275 | 0 | } |
276 | 28.6k | if (--st->refcount > 0) |
277 | 0 | return; |
278 | 28.6k | if (st->buf != NULL) |
279 | 28.6k | g_byte_array_unref(st->buf); |
280 | 28.6k | g_free(st); |
281 | 28.6k | } |
282 | | /** |
283 | | * fu_struct_genesys_dev_firmware_hdr_new_internal: (skip): |
284 | | **/ |
285 | | static FuStructGenesysDevFirmwareHdr * |
286 | | fu_struct_genesys_dev_firmware_hdr_new_internal(void) |
287 | 28.6k | { |
288 | 28.6k | FuStructGenesysDevFirmwareHdr *st = g_new0(FuStructGenesysDevFirmwareHdr, 1); |
289 | 28.6k | st->refcount = 1; |
290 | 28.6k | return st; |
291 | 28.6k | } |
292 | | |
293 | | /* getters */ |
294 | | /** |
295 | | * fu_struct_genesys_dev_firmware_hdr_get_magic: (skip): |
296 | | **/ |
297 | | static gchar * |
298 | | fu_struct_genesys_dev_firmware_hdr_get_magic(const FuStructGenesysDevFirmwareHdr *st) |
299 | 11.4k | { |
300 | 11.4k | g_return_val_if_fail(st != NULL, NULL); |
301 | 11.4k | return fu_memstrsafe(st->buf->data, st->buf->len, 252, 4, NULL); |
302 | 11.4k | } |
303 | | |
304 | | /* setters */ |
305 | | static gboolean |
306 | | fu_struct_genesys_dev_firmware_hdr_validate_internal(FuStructGenesysDevFirmwareHdr *st, GError **error) |
307 | 28.4k | { |
308 | 28.4k | g_return_val_if_fail(st != NULL, FALSE); |
309 | 28.4k | if (strncmp((const gchar *) (st->buf->data + 252), "HOST", 4) != 0) { |
310 | 11.4k | g_autofree gchar *str = fu_struct_genesys_dev_firmware_hdr_get_magic(st); |
311 | 11.4k | g_set_error(error, |
312 | 11.4k | FWUPD_ERROR, |
313 | 11.4k | FWUPD_ERROR_INVALID_DATA, |
314 | 11.4k | "constant FuStructGenesysDevFirmwareHdr.magic was not valid, " |
315 | 11.4k | "expected 'HOST' and got '%s'", |
316 | 11.4k | str); |
317 | 11.4k | return FALSE; |
318 | 11.4k | } |
319 | 16.9k | return TRUE; |
320 | 28.4k | } |
321 | | /** |
322 | | * fu_struct_genesys_dev_firmware_hdr_validate_stream: (skip): |
323 | | **/ |
324 | | gboolean |
325 | | fu_struct_genesys_dev_firmware_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error) |
326 | 28.6k | { |
327 | 28.6k | g_autoptr(FuStructGenesysDevFirmwareHdr) st = fu_struct_genesys_dev_firmware_hdr_new_internal(); |
328 | 28.6k | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
329 | 28.6k | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
330 | 28.6k | st->buf = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error); |
331 | 28.6k | if (st->buf == NULL) { |
332 | 0 | g_prefix_error(error, "FuStructGenesysDevFirmwareHdr failed read of 0x%x: ", (guint) 256); |
333 | 0 | return FALSE; |
334 | 0 | } |
335 | 28.6k | if (st->buf->len != 256) { |
336 | 240 | g_set_error(error, |
337 | 240 | FWUPD_ERROR, |
338 | 240 | FWUPD_ERROR_INVALID_DATA, |
339 | 240 | "FuStructGenesysDevFirmwareHdr requested 0x%x and got 0x%x", |
340 | 240 | (guint) 256, |
341 | 240 | (guint) st->buf->len); |
342 | 240 | return FALSE; |
343 | 240 | } |
344 | 28.4k | return fu_struct_genesys_dev_firmware_hdr_validate_internal(st, error); |
345 | 28.6k | } |
346 | | /** |
347 | | * fu_struct_genesys_pd_firmware_hdr_ref: (skip): |
348 | | **/ |
349 | | FuStructGenesysPdFirmwareHdr * |
350 | | fu_struct_genesys_pd_firmware_hdr_ref(FuStructGenesysPdFirmwareHdr *st) |
351 | 0 | { |
352 | 0 | g_return_val_if_fail(st != NULL, NULL); |
353 | 0 | st->refcount++; |
354 | 0 | return st; |
355 | 0 | } |
356 | | /** |
357 | | * fu_struct_genesys_pd_firmware_hdr_unref: (skip): |
358 | | **/ |
359 | | void |
360 | | fu_struct_genesys_pd_firmware_hdr_unref(FuStructGenesysPdFirmwareHdr *st) |
361 | 11.8k | { |
362 | 11.8k | g_return_if_fail(st != NULL); |
363 | 11.8k | if (st->refcount == 0) { |
364 | 0 | g_critical("FuStructGenesysPdFirmwareHdr refcount already zero"); |
365 | 0 | return; |
366 | 0 | } |
367 | 11.8k | if (--st->refcount > 0) |
368 | 0 | return; |
369 | 11.8k | if (st->buf != NULL) |
370 | 11.8k | g_byte_array_unref(st->buf); |
371 | 11.8k | g_free(st); |
372 | 11.8k | } |
373 | | /** |
374 | | * fu_struct_genesys_pd_firmware_hdr_new_internal: (skip): |
375 | | **/ |
376 | | static FuStructGenesysPdFirmwareHdr * |
377 | | fu_struct_genesys_pd_firmware_hdr_new_internal(void) |
378 | 11.8k | { |
379 | 11.8k | FuStructGenesysPdFirmwareHdr *st = g_new0(FuStructGenesysPdFirmwareHdr, 1); |
380 | 11.8k | st->refcount = 1; |
381 | 11.8k | return st; |
382 | 11.8k | } |
383 | | |
384 | | /* getters */ |
385 | | /** |
386 | | * fu_struct_genesys_pd_firmware_hdr_get_magic: (skip): |
387 | | **/ |
388 | | static gchar * |
389 | | fu_struct_genesys_pd_firmware_hdr_get_magic(const FuStructGenesysPdFirmwareHdr *st) |
390 | 376 | { |
391 | 376 | g_return_val_if_fail(st != NULL, NULL); |
392 | 376 | return fu_memstrsafe(st->buf->data, st->buf->len, 252, 4, NULL); |
393 | 376 | } |
394 | | |
395 | | /* setters */ |
396 | | static gboolean |
397 | | fu_struct_genesys_pd_firmware_hdr_validate_internal(FuStructGenesysPdFirmwareHdr *st, GError **error) |
398 | 11.6k | { |
399 | 11.6k | g_return_val_if_fail(st != NULL, FALSE); |
400 | 11.6k | if (strncmp((const gchar *) (st->buf->data + 252), "PRDY", 4) != 0) { |
401 | 376 | g_autofree gchar *str = fu_struct_genesys_pd_firmware_hdr_get_magic(st); |
402 | 376 | g_set_error(error, |
403 | 376 | FWUPD_ERROR, |
404 | 376 | FWUPD_ERROR_INVALID_DATA, |
405 | 376 | "constant FuStructGenesysPdFirmwareHdr.magic was not valid, " |
406 | 376 | "expected 'PRDY' and got '%s'", |
407 | 376 | str); |
408 | 376 | return FALSE; |
409 | 376 | } |
410 | 11.2k | return TRUE; |
411 | 11.6k | } |
412 | | /** |
413 | | * fu_struct_genesys_pd_firmware_hdr_validate_stream: (skip): |
414 | | **/ |
415 | | gboolean |
416 | | fu_struct_genesys_pd_firmware_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error) |
417 | 11.8k | { |
418 | 11.8k | g_autoptr(FuStructGenesysPdFirmwareHdr) st = fu_struct_genesys_pd_firmware_hdr_new_internal(); |
419 | 11.8k | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
420 | 11.8k | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
421 | 11.8k | st->buf = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error); |
422 | 11.8k | if (st->buf == NULL) { |
423 | 0 | g_prefix_error(error, "FuStructGenesysPdFirmwareHdr failed read of 0x%x: ", (guint) 256); |
424 | 0 | return FALSE; |
425 | 0 | } |
426 | 11.8k | if (st->buf->len != 256) { |
427 | 240 | g_set_error(error, |
428 | 240 | FWUPD_ERROR, |
429 | 240 | FWUPD_ERROR_INVALID_DATA, |
430 | 240 | "FuStructGenesysPdFirmwareHdr requested 0x%x and got 0x%x", |
431 | 240 | (guint) 256, |
432 | 240 | (guint) st->buf->len); |
433 | 240 | return FALSE; |
434 | 240 | } |
435 | 11.6k | return fu_struct_genesys_pd_firmware_hdr_validate_internal(st, error); |
436 | 11.8k | } |
437 | | /** |
438 | | * fu_struct_genesys_ts_static_ref: (skip): |
439 | | **/ |
440 | | FuStructGenesysTsStatic * |
441 | | fu_struct_genesys_ts_static_ref(FuStructGenesysTsStatic *st) |
442 | 0 | { |
443 | 0 | g_return_val_if_fail(st != NULL, NULL); |
444 | 0 | st->refcount++; |
445 | 0 | return st; |
446 | 0 | } |
447 | | /** |
448 | | * fu_struct_genesys_ts_static_unref: (skip): |
449 | | **/ |
450 | | void |
451 | | fu_struct_genesys_ts_static_unref(FuStructGenesysTsStatic *st) |
452 | 1.52k | { |
453 | 1.52k | g_return_if_fail(st != NULL); |
454 | 1.52k | if (st->refcount == 0) { |
455 | 0 | g_critical("FuStructGenesysTsStatic refcount already zero"); |
456 | 0 | return; |
457 | 0 | } |
458 | 1.52k | if (--st->refcount > 0) |
459 | 0 | return; |
460 | 1.52k | if (st->buf != NULL) |
461 | 1.52k | g_byte_array_unref(st->buf); |
462 | 1.52k | g_free(st); |
463 | 1.52k | } |
464 | | /** |
465 | | * fu_struct_genesys_ts_static_new_internal: (skip): |
466 | | **/ |
467 | | static FuStructGenesysTsStatic * |
468 | | fu_struct_genesys_ts_static_new_internal(void) |
469 | 1.52k | { |
470 | 1.52k | FuStructGenesysTsStatic *st = g_new0(FuStructGenesysTsStatic, 1); |
471 | 1.52k | st->refcount = 1; |
472 | 1.52k | return st; |
473 | 1.52k | } |
474 | | |
475 | | /* getters */ |
476 | | /** |
477 | | * fu_struct_genesys_ts_static_get_tool_string_version: (skip): |
478 | | **/ |
479 | | FuGenesysTsVersion |
480 | | fu_struct_genesys_ts_static_get_tool_string_version(const FuStructGenesysTsStatic *st) |
481 | 0 | { |
482 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
483 | 0 | return st->buf->data[0]; |
484 | 0 | } |
485 | | /** |
486 | | * fu_struct_genesys_ts_static_get_mask_project_code: (skip): |
487 | | **/ |
488 | | gchar * |
489 | | fu_struct_genesys_ts_static_get_mask_project_code(const FuStructGenesysTsStatic *st) |
490 | 0 | { |
491 | 0 | g_return_val_if_fail(st != NULL, NULL); |
492 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 1, 4, NULL); |
493 | 0 | } |
494 | | /** |
495 | | * fu_struct_genesys_ts_static_get_mask_project_hardware: (skip): |
496 | | **/ |
497 | | gchar * |
498 | | fu_struct_genesys_ts_static_get_mask_project_hardware(const FuStructGenesysTsStatic *st) |
499 | 0 | { |
500 | 0 | g_return_val_if_fail(st != NULL, NULL); |
501 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL); |
502 | 0 | } |
503 | | /** |
504 | | * fu_struct_genesys_ts_static_get_mask_project_firmware: (skip): |
505 | | **/ |
506 | | gchar * |
507 | | fu_struct_genesys_ts_static_get_mask_project_firmware(const FuStructGenesysTsStatic *st) |
508 | 0 | { |
509 | 0 | g_return_val_if_fail(st != NULL, NULL); |
510 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 6, 2, NULL); |
511 | 0 | } |
512 | | /** |
513 | | * fu_struct_genesys_ts_static_get_mask_project_ic_type: (skip): |
514 | | **/ |
515 | | gchar * |
516 | | fu_struct_genesys_ts_static_get_mask_project_ic_type(const FuStructGenesysTsStatic *st) |
517 | 0 | { |
518 | 0 | g_return_val_if_fail(st != NULL, NULL); |
519 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 8, 6, NULL); |
520 | 0 | } |
521 | | /** |
522 | | * fu_struct_genesys_ts_static_get_running_project_code: (skip): |
523 | | **/ |
524 | | gchar * |
525 | | fu_struct_genesys_ts_static_get_running_project_code(const FuStructGenesysTsStatic *st) |
526 | 0 | { |
527 | 0 | g_return_val_if_fail(st != NULL, NULL); |
528 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 14, 4, NULL); |
529 | 0 | } |
530 | | /** |
531 | | * fu_struct_genesys_ts_static_get_running_project_hardware: (skip): |
532 | | **/ |
533 | | gchar * |
534 | | fu_struct_genesys_ts_static_get_running_project_hardware(const FuStructGenesysTsStatic *st) |
535 | 0 | { |
536 | 0 | g_return_val_if_fail(st != NULL, NULL); |
537 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 18, 1, NULL); |
538 | 0 | } |
539 | | /** |
540 | | * fu_struct_genesys_ts_static_get_running_project_firmware: (skip): |
541 | | **/ |
542 | | gchar * |
543 | | fu_struct_genesys_ts_static_get_running_project_firmware(const FuStructGenesysTsStatic *st) |
544 | 0 | { |
545 | 0 | g_return_val_if_fail(st != NULL, NULL); |
546 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 19, 2, NULL); |
547 | 0 | } |
548 | | /** |
549 | | * fu_struct_genesys_ts_static_get_running_project_ic_type: (skip): |
550 | | **/ |
551 | | gchar * |
552 | | fu_struct_genesys_ts_static_get_running_project_ic_type(const FuStructGenesysTsStatic *st) |
553 | 0 | { |
554 | 0 | g_return_val_if_fail(st != NULL, NULL); |
555 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 21, 6, NULL); |
556 | 0 | } |
557 | | /** |
558 | | * fu_struct_genesys_ts_static_get_firmware_version: (skip): |
559 | | **/ |
560 | | gchar * |
561 | | fu_struct_genesys_ts_static_get_firmware_version(const FuStructGenesysTsStatic *st) |
562 | 0 | { |
563 | 0 | g_return_val_if_fail(st != NULL, NULL); |
564 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 27, 4, NULL); |
565 | 0 | } |
566 | | |
567 | | /* setters */ |
568 | | /** |
569 | | * fu_struct_genesys_ts_static_set_tool_string_version: (skip): |
570 | | **/ |
571 | | void |
572 | | fu_struct_genesys_ts_static_set_tool_string_version(FuStructGenesysTsStatic *st, FuGenesysTsVersion value) |
573 | 0 | { |
574 | 0 | g_return_if_fail(st != NULL); |
575 | 0 | st->buf->data[0] = value; |
576 | 0 | } |
577 | | /** |
578 | | * fu_struct_genesys_ts_static_set_mask_project_code: (skip): |
579 | | **/ |
580 | | gboolean |
581 | | fu_struct_genesys_ts_static_set_mask_project_code(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
582 | 0 | { |
583 | 0 | gsize len; |
584 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
585 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
586 | 0 | if (value == NULL) { |
587 | 0 | memset(st->buf->data + 1, 0x0, 4); |
588 | 0 | return TRUE; |
589 | 0 | } |
590 | 0 | len = strlen(value); |
591 | 0 | if (len > 4) { |
592 | 0 | g_set_error(error, |
593 | 0 | FWUPD_ERROR, |
594 | 0 | FWUPD_ERROR_INVALID_DATA, |
595 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_code (0x%x bytes)", |
596 | 0 | value, (guint) len, (guint) 4); |
597 | 0 | return FALSE; |
598 | 0 | } |
599 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 1, (const guint8 *)value, len, 0x0, len, error); |
600 | 0 | } |
601 | | /** |
602 | | * fu_struct_genesys_ts_static_set_mask_project_hardware: (skip): |
603 | | **/ |
604 | | gboolean |
605 | | fu_struct_genesys_ts_static_set_mask_project_hardware(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
606 | 0 | { |
607 | 0 | gsize len; |
608 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
609 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
610 | 0 | if (value == NULL) { |
611 | 0 | memset(st->buf->data + 5, 0x0, 1); |
612 | 0 | return TRUE; |
613 | 0 | } |
614 | 0 | len = strlen(value); |
615 | 0 | if (len > 1) { |
616 | 0 | g_set_error(error, |
617 | 0 | FWUPD_ERROR, |
618 | 0 | FWUPD_ERROR_INVALID_DATA, |
619 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_hardware (0x%x bytes)", |
620 | 0 | value, (guint) len, (guint) 1); |
621 | 0 | return FALSE; |
622 | 0 | } |
623 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 5, (const guint8 *)value, len, 0x0, len, error); |
624 | 0 | } |
625 | | /** |
626 | | * fu_struct_genesys_ts_static_set_mask_project_firmware: (skip): |
627 | | **/ |
628 | | gboolean |
629 | | fu_struct_genesys_ts_static_set_mask_project_firmware(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
630 | 0 | { |
631 | 0 | gsize len; |
632 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
633 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
634 | 0 | if (value == NULL) { |
635 | 0 | memset(st->buf->data + 6, 0x0, 2); |
636 | 0 | return TRUE; |
637 | 0 | } |
638 | 0 | len = strlen(value); |
639 | 0 | if (len > 2) { |
640 | 0 | g_set_error(error, |
641 | 0 | FWUPD_ERROR, |
642 | 0 | FWUPD_ERROR_INVALID_DATA, |
643 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_firmware (0x%x bytes)", |
644 | 0 | value, (guint) len, (guint) 2); |
645 | 0 | return FALSE; |
646 | 0 | } |
647 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 6, (const guint8 *)value, len, 0x0, len, error); |
648 | 0 | } |
649 | | /** |
650 | | * fu_struct_genesys_ts_static_set_mask_project_ic_type: (skip): |
651 | | **/ |
652 | | gboolean |
653 | | fu_struct_genesys_ts_static_set_mask_project_ic_type(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
654 | 0 | { |
655 | 0 | gsize len; |
656 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
657 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
658 | 0 | if (value == NULL) { |
659 | 0 | memset(st->buf->data + 8, 0x0, 6); |
660 | 0 | return TRUE; |
661 | 0 | } |
662 | 0 | len = strlen(value); |
663 | 0 | if (len > 6) { |
664 | 0 | g_set_error(error, |
665 | 0 | FWUPD_ERROR, |
666 | 0 | FWUPD_ERROR_INVALID_DATA, |
667 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.mask_project_ic_type (0x%x bytes)", |
668 | 0 | value, (guint) len, (guint) 6); |
669 | 0 | return FALSE; |
670 | 0 | } |
671 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 8, (const guint8 *)value, len, 0x0, len, error); |
672 | 0 | } |
673 | | /** |
674 | | * fu_struct_genesys_ts_static_set_running_project_code: (skip): |
675 | | **/ |
676 | | gboolean |
677 | | fu_struct_genesys_ts_static_set_running_project_code(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
678 | 0 | { |
679 | 0 | gsize len; |
680 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
681 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
682 | 0 | if (value == NULL) { |
683 | 0 | memset(st->buf->data + 14, 0x0, 4); |
684 | 0 | return TRUE; |
685 | 0 | } |
686 | 0 | len = strlen(value); |
687 | 0 | if (len > 4) { |
688 | 0 | g_set_error(error, |
689 | 0 | FWUPD_ERROR, |
690 | 0 | FWUPD_ERROR_INVALID_DATA, |
691 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_code (0x%x bytes)", |
692 | 0 | value, (guint) len, (guint) 4); |
693 | 0 | return FALSE; |
694 | 0 | } |
695 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 14, (const guint8 *)value, len, 0x0, len, error); |
696 | 0 | } |
697 | | /** |
698 | | * fu_struct_genesys_ts_static_set_running_project_hardware: (skip): |
699 | | **/ |
700 | | gboolean |
701 | | fu_struct_genesys_ts_static_set_running_project_hardware(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
702 | 0 | { |
703 | 0 | gsize len; |
704 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
705 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
706 | 0 | if (value == NULL) { |
707 | 0 | memset(st->buf->data + 18, 0x0, 1); |
708 | 0 | return TRUE; |
709 | 0 | } |
710 | 0 | len = strlen(value); |
711 | 0 | if (len > 1) { |
712 | 0 | g_set_error(error, |
713 | 0 | FWUPD_ERROR, |
714 | 0 | FWUPD_ERROR_INVALID_DATA, |
715 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_hardware (0x%x bytes)", |
716 | 0 | value, (guint) len, (guint) 1); |
717 | 0 | return FALSE; |
718 | 0 | } |
719 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 18, (const guint8 *)value, len, 0x0, len, error); |
720 | 0 | } |
721 | | /** |
722 | | * fu_struct_genesys_ts_static_set_running_project_firmware: (skip): |
723 | | **/ |
724 | | gboolean |
725 | | fu_struct_genesys_ts_static_set_running_project_firmware(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
726 | 0 | { |
727 | 0 | gsize len; |
728 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
729 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
730 | 0 | if (value == NULL) { |
731 | 0 | memset(st->buf->data + 19, 0x0, 2); |
732 | 0 | return TRUE; |
733 | 0 | } |
734 | 0 | len = strlen(value); |
735 | 0 | if (len > 2) { |
736 | 0 | g_set_error(error, |
737 | 0 | FWUPD_ERROR, |
738 | 0 | FWUPD_ERROR_INVALID_DATA, |
739 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_firmware (0x%x bytes)", |
740 | 0 | value, (guint) len, (guint) 2); |
741 | 0 | return FALSE; |
742 | 0 | } |
743 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 19, (const guint8 *)value, len, 0x0, len, error); |
744 | 0 | } |
745 | | /** |
746 | | * fu_struct_genesys_ts_static_set_running_project_ic_type: (skip): |
747 | | **/ |
748 | | gboolean |
749 | | fu_struct_genesys_ts_static_set_running_project_ic_type(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
750 | 0 | { |
751 | 0 | gsize len; |
752 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
753 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
754 | 0 | if (value == NULL) { |
755 | 0 | memset(st->buf->data + 21, 0x0, 6); |
756 | 0 | return TRUE; |
757 | 0 | } |
758 | 0 | len = strlen(value); |
759 | 0 | if (len > 6) { |
760 | 0 | g_set_error(error, |
761 | 0 | FWUPD_ERROR, |
762 | 0 | FWUPD_ERROR_INVALID_DATA, |
763 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.running_project_ic_type (0x%x bytes)", |
764 | 0 | value, (guint) len, (guint) 6); |
765 | 0 | return FALSE; |
766 | 0 | } |
767 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 21, (const guint8 *)value, len, 0x0, len, error); |
768 | 0 | } |
769 | | /** |
770 | | * fu_struct_genesys_ts_static_set_firmware_version: (skip): |
771 | | **/ |
772 | | gboolean |
773 | | fu_struct_genesys_ts_static_set_firmware_version(FuStructGenesysTsStatic *st, const gchar *value, GError **error) |
774 | 0 | { |
775 | 0 | gsize len; |
776 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
777 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
778 | 0 | if (value == NULL) { |
779 | 0 | memset(st->buf->data + 27, 0x0, 4); |
780 | 0 | return TRUE; |
781 | 0 | } |
782 | 0 | len = strlen(value); |
783 | 0 | if (len > 4) { |
784 | 0 | g_set_error(error, |
785 | 0 | FWUPD_ERROR, |
786 | 0 | FWUPD_ERROR_INVALID_DATA, |
787 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsStatic.firmware_version (0x%x bytes)", |
788 | 0 | value, (guint) len, (guint) 4); |
789 | 0 | return FALSE; |
790 | 0 | } |
791 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 27, (const guint8 *)value, len, 0x0, len, error); |
792 | 0 | } |
793 | | /** |
794 | | * fu_struct_genesys_ts_static_new: (skip): |
795 | | **/ |
796 | | FuStructGenesysTsStatic * |
797 | | fu_struct_genesys_ts_static_new(void) |
798 | 0 | { |
799 | 0 | FuStructGenesysTsStatic *st = fu_struct_genesys_ts_static_new_internal(); |
800 | 0 | st->buf = g_byte_array_sized_new(31); |
801 | 0 | fu_byte_array_set_size(st->buf, 31, 0x0); |
802 | 0 | return st; |
803 | 0 | } |
804 | | /** |
805 | | * fu_struct_genesys_ts_static_to_string: (skip): |
806 | | **/ |
807 | | static gchar * |
808 | | fu_struct_genesys_ts_static_to_string(const FuStructGenesysTsStatic *st) |
809 | 0 | { |
810 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsStatic:\n"); |
811 | 0 | g_return_val_if_fail(st != NULL, NULL); |
812 | 0 | { |
813 | 0 | const gchar *tmp = fu_genesys_ts_version_to_string(fu_struct_genesys_ts_static_get_tool_string_version(st)); |
814 | 0 | if (tmp != NULL) { |
815 | 0 | g_string_append_printf(str, " tool_string_version: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_static_get_tool_string_version(st), tmp); |
816 | 0 | } else { |
817 | 0 | g_string_append_printf(str, " tool_string_version: 0x%x\n", (guint) fu_struct_genesys_ts_static_get_tool_string_version(st)); |
818 | 0 | } |
819 | 0 | } |
820 | 0 | { |
821 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_code(st); |
822 | 0 | if (tmp != NULL) |
823 | 0 | g_string_append_printf(str, " mask_project_code: %s\n", tmp); |
824 | 0 | } |
825 | 0 | { |
826 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_hardware(st); |
827 | 0 | if (tmp != NULL) |
828 | 0 | g_string_append_printf(str, " mask_project_hardware: %s\n", tmp); |
829 | 0 | } |
830 | 0 | { |
831 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_firmware(st); |
832 | 0 | if (tmp != NULL) |
833 | 0 | g_string_append_printf(str, " mask_project_firmware: %s\n", tmp); |
834 | 0 | } |
835 | 0 | { |
836 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_mask_project_ic_type(st); |
837 | 0 | if (tmp != NULL) |
838 | 0 | g_string_append_printf(str, " mask_project_ic_type: %s\n", tmp); |
839 | 0 | } |
840 | 0 | { |
841 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_code(st); |
842 | 0 | if (tmp != NULL) |
843 | 0 | g_string_append_printf(str, " running_project_code: %s\n", tmp); |
844 | 0 | } |
845 | 0 | { |
846 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_hardware(st); |
847 | 0 | if (tmp != NULL) |
848 | 0 | g_string_append_printf(str, " running_project_hardware: %s\n", tmp); |
849 | 0 | } |
850 | 0 | { |
851 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_firmware(st); |
852 | 0 | if (tmp != NULL) |
853 | 0 | g_string_append_printf(str, " running_project_firmware: %s\n", tmp); |
854 | 0 | } |
855 | 0 | { |
856 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_running_project_ic_type(st); |
857 | 0 | if (tmp != NULL) |
858 | 0 | g_string_append_printf(str, " running_project_ic_type: %s\n", tmp); |
859 | 0 | } |
860 | 0 | { |
861 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_static_get_firmware_version(st); |
862 | 0 | if (tmp != NULL) |
863 | 0 | g_string_append_printf(str, " firmware_version: %s\n", tmp); |
864 | 0 | } |
865 | 0 | if (str->len > 0) |
866 | 0 | g_string_set_size(str, str->len - 1); |
867 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
868 | 0 | } |
869 | | static gboolean |
870 | | fu_struct_genesys_ts_static_validate_internal(FuStructGenesysTsStatic *st, GError **error) |
871 | 1.41k | { |
872 | 1.41k | g_return_val_if_fail(st != NULL, FALSE); |
873 | 1.41k | return TRUE; |
874 | 1.41k | } |
875 | | static gboolean |
876 | | fu_struct_genesys_ts_static_parse_internal(FuStructGenesysTsStatic *st, GError **error) |
877 | 1.41k | { |
878 | 1.41k | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
879 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_static_to_string(st); |
880 | 0 | g_debug("%s", str); |
881 | 0 | } |
882 | 1.41k | if (!fu_struct_genesys_ts_static_validate_internal(st, error)) |
883 | 0 | return FALSE; |
884 | 1.41k | return TRUE; |
885 | 1.41k | } |
886 | | |
887 | | /** |
888 | | * fu_struct_genesys_ts_static_parse: (skip): |
889 | | **/ |
890 | | FuStructGenesysTsStatic * |
891 | | fu_struct_genesys_ts_static_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
892 | 0 | { |
893 | 0 | g_autoptr(FuStructGenesysTsStatic) st = fu_struct_genesys_ts_static_new_internal(); |
894 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
895 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
896 | 0 | if (!fu_memchk_read(bufsz, offset, 31, error)) { |
897 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsStatic: "); |
898 | 0 | return NULL; |
899 | 0 | } |
900 | 0 | st->buf = g_byte_array_new(); |
901 | 0 | g_byte_array_append(st->buf, buf + offset, 31); |
902 | 0 | if (!fu_struct_genesys_ts_static_parse_internal(st, error)) |
903 | 0 | return NULL; |
904 | 0 | return g_steal_pointer(&st); |
905 | 0 | } |
906 | | /** |
907 | | * fu_struct_genesys_ts_static_parse_stream: (skip): |
908 | | **/ |
909 | | FuStructGenesysTsStatic * |
910 | | fu_struct_genesys_ts_static_parse_stream(GInputStream *stream, gsize offset, GError **error) |
911 | 1.52k | { |
912 | 1.52k | g_autoptr(FuStructGenesysTsStatic) st = fu_struct_genesys_ts_static_new_internal(); |
913 | 1.52k | st->buf = fu_input_stream_read_byte_array(stream, offset, 31, NULL, error); |
914 | 1.52k | if (st->buf == NULL) { |
915 | 0 | g_prefix_error(error, "FuStructGenesysTsStatic failed read of 0x%x: ", (guint) 31); |
916 | 0 | return NULL; |
917 | 0 | } |
918 | 1.52k | if (st->buf->len != 31) { |
919 | 111 | g_set_error(error, |
920 | 111 | FWUPD_ERROR, |
921 | 111 | FWUPD_ERROR_INVALID_DATA, |
922 | 111 | "FuStructGenesysTsStatic requested 0x%x and got 0x%x", |
923 | 111 | (guint) 31, |
924 | 111 | (guint) st->buf->len); |
925 | 111 | return NULL; |
926 | 111 | } |
927 | 1.41k | if (!fu_struct_genesys_ts_static_parse_internal(st, error)) |
928 | 0 | return NULL; |
929 | 1.41k | return g_steal_pointer(&st); |
930 | 1.41k | } |
931 | | /** |
932 | | * fu_struct_genesys_ts_dynamic_gl3523_ref: (skip): |
933 | | **/ |
934 | | FuStructGenesysTsDynamicGl3523 * |
935 | | fu_struct_genesys_ts_dynamic_gl3523_ref(FuStructGenesysTsDynamicGl3523 *st) |
936 | 0 | { |
937 | 0 | g_return_val_if_fail(st != NULL, NULL); |
938 | 0 | st->refcount++; |
939 | 0 | return st; |
940 | 0 | } |
941 | | /** |
942 | | * fu_struct_genesys_ts_dynamic_gl3523_unref: (skip): |
943 | | **/ |
944 | | void |
945 | | fu_struct_genesys_ts_dynamic_gl3523_unref(FuStructGenesysTsDynamicGl3523 *st) |
946 | 0 | { |
947 | 0 | g_return_if_fail(st != NULL); |
948 | 0 | if (st->refcount == 0) { |
949 | 0 | g_critical("FuStructGenesysTsDynamicGl3523 refcount already zero"); |
950 | 0 | return; |
951 | 0 | } |
952 | 0 | if (--st->refcount > 0) |
953 | 0 | return; |
954 | 0 | if (st->buf != NULL) |
955 | 0 | g_byte_array_unref(st->buf); |
956 | 0 | g_free(st); |
957 | 0 | } |
958 | | /** |
959 | | * fu_struct_genesys_ts_dynamic_gl3523_new_internal: (skip): |
960 | | **/ |
961 | | static FuStructGenesysTsDynamicGl3523 * |
962 | | fu_struct_genesys_ts_dynamic_gl3523_new_internal(void) |
963 | 0 | { |
964 | 0 | FuStructGenesysTsDynamicGl3523 *st = g_new0(FuStructGenesysTsDynamicGl3523, 1); |
965 | 0 | st->refcount = 1; |
966 | 0 | return st; |
967 | 0 | } |
968 | | |
969 | | /* getters */ |
970 | | /** |
971 | | * fu_struct_genesys_ts_dynamic_gl3523_get_running_mode: (skip): |
972 | | **/ |
973 | | gchar * |
974 | | fu_struct_genesys_ts_dynamic_gl3523_get_running_mode(const FuStructGenesysTsDynamicGl3523 *st) |
975 | 0 | { |
976 | 0 | g_return_val_if_fail(st != NULL, NULL); |
977 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL); |
978 | 0 | } |
979 | | /** |
980 | | * fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number: (skip): |
981 | | **/ |
982 | | gchar * |
983 | | fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number(const FuStructGenesysTsDynamicGl3523 *st) |
984 | 0 | { |
985 | 0 | g_return_val_if_fail(st != NULL, NULL); |
986 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL); |
987 | 0 | } |
988 | | /** |
989 | | * fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number: (skip): |
990 | | **/ |
991 | | gchar * |
992 | | fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number(const FuStructGenesysTsDynamicGl3523 *st) |
993 | 0 | { |
994 | 0 | g_return_val_if_fail(st != NULL, NULL); |
995 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL); |
996 | 0 | } |
997 | | /** |
998 | | * fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status: (skip): |
999 | | **/ |
1000 | | gchar * |
1001 | | fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status(const FuStructGenesysTsDynamicGl3523 *st) |
1002 | 0 | { |
1003 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1004 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL); |
1005 | 0 | } |
1006 | | /** |
1007 | | * fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status: (skip): |
1008 | | **/ |
1009 | | gchar * |
1010 | | fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status(const FuStructGenesysTsDynamicGl3523 *st) |
1011 | 0 | { |
1012 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1013 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL); |
1014 | 0 | } |
1015 | | /** |
1016 | | * fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status: (skip): |
1017 | | **/ |
1018 | | gchar * |
1019 | | fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status(const FuStructGenesysTsDynamicGl3523 *st) |
1020 | 0 | { |
1021 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1022 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL); |
1023 | 0 | } |
1024 | | /** |
1025 | | * fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status: (skip): |
1026 | | **/ |
1027 | | gchar * |
1028 | | fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status(const FuStructGenesysTsDynamicGl3523 *st) |
1029 | 0 | { |
1030 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1031 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL); |
1032 | 0 | } |
1033 | | /** |
1034 | | * fu_struct_genesys_ts_dynamic_gl3523_get_charging: (skip): |
1035 | | **/ |
1036 | | gchar * |
1037 | | fu_struct_genesys_ts_dynamic_gl3523_get_charging(const FuStructGenesysTsDynamicGl3523 *st) |
1038 | 0 | { |
1039 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1040 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL); |
1041 | 0 | } |
1042 | | /** |
1043 | | * fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status: (skip): |
1044 | | **/ |
1045 | | gchar * |
1046 | | fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3523 *st) |
1047 | 0 | { |
1048 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1049 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL); |
1050 | 0 | } |
1051 | | /** |
1052 | | * fu_struct_genesys_ts_dynamic_gl3523_get_bonding: (skip): |
1053 | | **/ |
1054 | | gchar * |
1055 | | fu_struct_genesys_ts_dynamic_gl3523_get_bonding(const FuStructGenesysTsDynamicGl3523 *st) |
1056 | 0 | { |
1057 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1058 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 9, 1, NULL); |
1059 | 0 | } |
1060 | | |
1061 | | /* setters */ |
1062 | | /** |
1063 | | * fu_struct_genesys_ts_dynamic_gl3523_to_string: (skip): |
1064 | | **/ |
1065 | | static gchar * |
1066 | | fu_struct_genesys_ts_dynamic_gl3523_to_string(const FuStructGenesysTsDynamicGl3523 *st) |
1067 | 0 | { |
1068 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3523:\n"); |
1069 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1070 | 0 | { |
1071 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_running_mode(st); |
1072 | 0 | if (tmp != NULL) |
1073 | 0 | g_string_append_printf(str, " running_mode: %s\n", tmp); |
1074 | 0 | } |
1075 | 0 | { |
1076 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number(st); |
1077 | 0 | if (tmp != NULL) |
1078 | 0 | g_string_append_printf(str, " ss_port_number: %s\n", tmp); |
1079 | 0 | } |
1080 | 0 | { |
1081 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number(st); |
1082 | 0 | if (tmp != NULL) |
1083 | 0 | g_string_append_printf(str, " hs_port_number: %s\n", tmp); |
1084 | 0 | } |
1085 | 0 | { |
1086 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status(st); |
1087 | 0 | if (tmp != NULL) |
1088 | 0 | g_string_append_printf(str, " ss_connection_status: %s\n", tmp); |
1089 | 0 | } |
1090 | 0 | { |
1091 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status(st); |
1092 | 0 | if (tmp != NULL) |
1093 | 0 | g_string_append_printf(str, " hs_connection_status: %s\n", tmp); |
1094 | 0 | } |
1095 | 0 | { |
1096 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status(st); |
1097 | 0 | if (tmp != NULL) |
1098 | 0 | g_string_append_printf(str, " fs_connection_status: %s\n", tmp); |
1099 | 0 | } |
1100 | 0 | { |
1101 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status(st); |
1102 | 0 | if (tmp != NULL) |
1103 | 0 | g_string_append_printf(str, " ls_connection_status: %s\n", tmp); |
1104 | 0 | } |
1105 | 0 | { |
1106 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_charging(st); |
1107 | 0 | if (tmp != NULL) |
1108 | 0 | g_string_append_printf(str, " charging: %s\n", tmp); |
1109 | 0 | } |
1110 | 0 | { |
1111 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status(st); |
1112 | 0 | if (tmp != NULL) |
1113 | 0 | g_string_append_printf(str, " non_removable_port_status: %s\n", tmp); |
1114 | 0 | } |
1115 | 0 | { |
1116 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_bonding(st); |
1117 | 0 | if (tmp != NULL) |
1118 | 0 | g_string_append_printf(str, " bonding: %s\n", tmp); |
1119 | 0 | } |
1120 | 0 | if (str->len > 0) |
1121 | 0 | g_string_set_size(str, str->len - 1); |
1122 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1123 | 0 | } |
1124 | | static gboolean |
1125 | | fu_struct_genesys_ts_dynamic_gl3523_validate_internal(FuStructGenesysTsDynamicGl3523 *st, GError **error) |
1126 | 0 | { |
1127 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1128 | 0 | return TRUE; |
1129 | 0 | } |
1130 | | static gboolean |
1131 | | fu_struct_genesys_ts_dynamic_gl3523_parse_internal(FuStructGenesysTsDynamicGl3523 *st, GError **error) |
1132 | 0 | { |
1133 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1134 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3523_to_string(st); |
1135 | 0 | g_debug("%s", str); |
1136 | 0 | } |
1137 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3523_validate_internal(st, error)) |
1138 | 0 | return FALSE; |
1139 | 0 | return TRUE; |
1140 | 0 | } |
1141 | | |
1142 | | /** |
1143 | | * fu_struct_genesys_ts_dynamic_gl3523_parse: (skip): |
1144 | | **/ |
1145 | | FuStructGenesysTsDynamicGl3523 * |
1146 | | fu_struct_genesys_ts_dynamic_gl3523_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1147 | 0 | { |
1148 | 0 | g_autoptr(FuStructGenesysTsDynamicGl3523) st = fu_struct_genesys_ts_dynamic_gl3523_new_internal(); |
1149 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1150 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1151 | 0 | if (!fu_memchk_read(bufsz, offset, 10, error)) { |
1152 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl3523: "); |
1153 | 0 | return NULL; |
1154 | 0 | } |
1155 | 0 | st->buf = g_byte_array_new(); |
1156 | 0 | g_byte_array_append(st->buf, buf + offset, 10); |
1157 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3523_parse_internal(st, error)) |
1158 | 0 | return NULL; |
1159 | 0 | return g_steal_pointer(&st); |
1160 | 0 | } |
1161 | | /** |
1162 | | * fu_struct_genesys_ts_dynamic_gl3590_ref: (skip): |
1163 | | **/ |
1164 | | FuStructGenesysTsDynamicGl3590 * |
1165 | | fu_struct_genesys_ts_dynamic_gl3590_ref(FuStructGenesysTsDynamicGl3590 *st) |
1166 | 0 | { |
1167 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1168 | 0 | st->refcount++; |
1169 | 0 | return st; |
1170 | 0 | } |
1171 | | /** |
1172 | | * fu_struct_genesys_ts_dynamic_gl3590_unref: (skip): |
1173 | | **/ |
1174 | | void |
1175 | | fu_struct_genesys_ts_dynamic_gl3590_unref(FuStructGenesysTsDynamicGl3590 *st) |
1176 | 0 | { |
1177 | 0 | g_return_if_fail(st != NULL); |
1178 | 0 | if (st->refcount == 0) { |
1179 | 0 | g_critical("FuStructGenesysTsDynamicGl3590 refcount already zero"); |
1180 | 0 | return; |
1181 | 0 | } |
1182 | 0 | if (--st->refcount > 0) |
1183 | 0 | return; |
1184 | 0 | if (st->buf != NULL) |
1185 | 0 | g_byte_array_unref(st->buf); |
1186 | 0 | g_free(st); |
1187 | 0 | } |
1188 | | /** |
1189 | | * fu_struct_genesys_ts_dynamic_gl3590_new_internal: (skip): |
1190 | | **/ |
1191 | | static FuStructGenesysTsDynamicGl3590 * |
1192 | | fu_struct_genesys_ts_dynamic_gl3590_new_internal(void) |
1193 | 0 | { |
1194 | 0 | FuStructGenesysTsDynamicGl3590 *st = g_new0(FuStructGenesysTsDynamicGl3590, 1); |
1195 | 0 | st->refcount = 1; |
1196 | 0 | return st; |
1197 | 0 | } |
1198 | | |
1199 | | /* getters */ |
1200 | | /** |
1201 | | * fu_struct_genesys_ts_dynamic_gl3590_get_running_mode: (skip): |
1202 | | **/ |
1203 | | gchar * |
1204 | | fu_struct_genesys_ts_dynamic_gl3590_get_running_mode(const FuStructGenesysTsDynamicGl3590 *st) |
1205 | 0 | { |
1206 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1207 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL); |
1208 | 0 | } |
1209 | | /** |
1210 | | * fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number: (skip): |
1211 | | **/ |
1212 | | gchar * |
1213 | | fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number(const FuStructGenesysTsDynamicGl3590 *st) |
1214 | 0 | { |
1215 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1216 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL); |
1217 | 0 | } |
1218 | | /** |
1219 | | * fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number: (skip): |
1220 | | **/ |
1221 | | gchar * |
1222 | | fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number(const FuStructGenesysTsDynamicGl3590 *st) |
1223 | 0 | { |
1224 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1225 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL); |
1226 | 0 | } |
1227 | | /** |
1228 | | * fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status: (skip): |
1229 | | **/ |
1230 | | gchar * |
1231 | | fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status(const FuStructGenesysTsDynamicGl3590 *st) |
1232 | 0 | { |
1233 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1234 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL); |
1235 | 0 | } |
1236 | | /** |
1237 | | * fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status: (skip): |
1238 | | **/ |
1239 | | gchar * |
1240 | | fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status(const FuStructGenesysTsDynamicGl3590 *st) |
1241 | 0 | { |
1242 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1243 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL); |
1244 | 0 | } |
1245 | | /** |
1246 | | * fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status: (skip): |
1247 | | **/ |
1248 | | gchar * |
1249 | | fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status(const FuStructGenesysTsDynamicGl3590 *st) |
1250 | 0 | { |
1251 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1252 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL); |
1253 | 0 | } |
1254 | | /** |
1255 | | * fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status: (skip): |
1256 | | **/ |
1257 | | gchar * |
1258 | | fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status(const FuStructGenesysTsDynamicGl3590 *st) |
1259 | 0 | { |
1260 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1261 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL); |
1262 | 0 | } |
1263 | | /** |
1264 | | * fu_struct_genesys_ts_dynamic_gl3590_get_charging: (skip): |
1265 | | **/ |
1266 | | gchar * |
1267 | | fu_struct_genesys_ts_dynamic_gl3590_get_charging(const FuStructGenesysTsDynamicGl3590 *st) |
1268 | 0 | { |
1269 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1270 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL); |
1271 | 0 | } |
1272 | | /** |
1273 | | * fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status: (skip): |
1274 | | **/ |
1275 | | gchar * |
1276 | | fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3590 *st) |
1277 | 0 | { |
1278 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1279 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL); |
1280 | 0 | } |
1281 | | /** |
1282 | | * fu_struct_genesys_ts_dynamic_gl3590_get_bonding: (skip): |
1283 | | **/ |
1284 | | guint8 |
1285 | | fu_struct_genesys_ts_dynamic_gl3590_get_bonding(const FuStructGenesysTsDynamicGl3590 *st) |
1286 | 0 | { |
1287 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1288 | 0 | return st->buf->data[9]; |
1289 | 0 | } |
1290 | | |
1291 | | /* setters */ |
1292 | | /** |
1293 | | * fu_struct_genesys_ts_dynamic_gl3590_to_string: (skip): |
1294 | | **/ |
1295 | | static gchar * |
1296 | | fu_struct_genesys_ts_dynamic_gl3590_to_string(const FuStructGenesysTsDynamicGl3590 *st) |
1297 | 0 | { |
1298 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3590:\n"); |
1299 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1300 | 0 | { |
1301 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_running_mode(st); |
1302 | 0 | if (tmp != NULL) |
1303 | 0 | g_string_append_printf(str, " running_mode: %s\n", tmp); |
1304 | 0 | } |
1305 | 0 | { |
1306 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number(st); |
1307 | 0 | if (tmp != NULL) |
1308 | 0 | g_string_append_printf(str, " ss_port_number: %s\n", tmp); |
1309 | 0 | } |
1310 | 0 | { |
1311 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number(st); |
1312 | 0 | if (tmp != NULL) |
1313 | 0 | g_string_append_printf(str, " hs_port_number: %s\n", tmp); |
1314 | 0 | } |
1315 | 0 | { |
1316 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status(st); |
1317 | 0 | if (tmp != NULL) |
1318 | 0 | g_string_append_printf(str, " ss_connection_status: %s\n", tmp); |
1319 | 0 | } |
1320 | 0 | { |
1321 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status(st); |
1322 | 0 | if (tmp != NULL) |
1323 | 0 | g_string_append_printf(str, " hs_connection_status: %s\n", tmp); |
1324 | 0 | } |
1325 | 0 | { |
1326 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status(st); |
1327 | 0 | if (tmp != NULL) |
1328 | 0 | g_string_append_printf(str, " fs_connection_status: %s\n", tmp); |
1329 | 0 | } |
1330 | 0 | { |
1331 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status(st); |
1332 | 0 | if (tmp != NULL) |
1333 | 0 | g_string_append_printf(str, " ls_connection_status: %s\n", tmp); |
1334 | 0 | } |
1335 | 0 | { |
1336 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_charging(st); |
1337 | 0 | if (tmp != NULL) |
1338 | 0 | g_string_append_printf(str, " charging: %s\n", tmp); |
1339 | 0 | } |
1340 | 0 | { |
1341 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status(st); |
1342 | 0 | if (tmp != NULL) |
1343 | 0 | g_string_append_printf(str, " non_removable_port_status: %s\n", tmp); |
1344 | 0 | } |
1345 | 0 | g_string_append_printf(str, " bonding: 0x%x\n", |
1346 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl3590_get_bonding(st)); |
1347 | 0 | if (str->len > 0) |
1348 | 0 | g_string_set_size(str, str->len - 1); |
1349 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1350 | 0 | } |
1351 | | static gboolean |
1352 | | fu_struct_genesys_ts_dynamic_gl3590_validate_internal(FuStructGenesysTsDynamicGl3590 *st, GError **error) |
1353 | 0 | { |
1354 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1355 | 0 | return TRUE; |
1356 | 0 | } |
1357 | | static gboolean |
1358 | | fu_struct_genesys_ts_dynamic_gl3590_parse_internal(FuStructGenesysTsDynamicGl3590 *st, GError **error) |
1359 | 0 | { |
1360 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1361 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3590_to_string(st); |
1362 | 0 | g_debug("%s", str); |
1363 | 0 | } |
1364 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3590_validate_internal(st, error)) |
1365 | 0 | return FALSE; |
1366 | 0 | return TRUE; |
1367 | 0 | } |
1368 | | |
1369 | | /** |
1370 | | * fu_struct_genesys_ts_dynamic_gl3590_parse: (skip): |
1371 | | **/ |
1372 | | FuStructGenesysTsDynamicGl3590 * |
1373 | | fu_struct_genesys_ts_dynamic_gl3590_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1374 | 0 | { |
1375 | 0 | g_autoptr(FuStructGenesysTsDynamicGl3590) st = fu_struct_genesys_ts_dynamic_gl3590_new_internal(); |
1376 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1377 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1378 | 0 | if (!fu_memchk_read(bufsz, offset, 10, error)) { |
1379 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl3590: "); |
1380 | 0 | return NULL; |
1381 | 0 | } |
1382 | 0 | st->buf = g_byte_array_new(); |
1383 | 0 | g_byte_array_append(st->buf, buf + offset, 10); |
1384 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3590_parse_internal(st, error)) |
1385 | 0 | return NULL; |
1386 | 0 | return g_steal_pointer(&st); |
1387 | 0 | } |
1388 | | /** |
1389 | | * fu_struct_genesys_ts_dynamic_gl359030_ref: (skip): |
1390 | | **/ |
1391 | | FuStructGenesysTsDynamicGl359030 * |
1392 | | fu_struct_genesys_ts_dynamic_gl359030_ref(FuStructGenesysTsDynamicGl359030 *st) |
1393 | 0 | { |
1394 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1395 | 0 | st->refcount++; |
1396 | 0 | return st; |
1397 | 0 | } |
1398 | | /** |
1399 | | * fu_struct_genesys_ts_dynamic_gl359030_unref: (skip): |
1400 | | **/ |
1401 | | void |
1402 | | fu_struct_genesys_ts_dynamic_gl359030_unref(FuStructGenesysTsDynamicGl359030 *st) |
1403 | 0 | { |
1404 | 0 | g_return_if_fail(st != NULL); |
1405 | 0 | if (st->refcount == 0) { |
1406 | 0 | g_critical("FuStructGenesysTsDynamicGl359030 refcount already zero"); |
1407 | 0 | return; |
1408 | 0 | } |
1409 | 0 | if (--st->refcount > 0) |
1410 | 0 | return; |
1411 | 0 | if (st->buf != NULL) |
1412 | 0 | g_byte_array_unref(st->buf); |
1413 | 0 | g_free(st); |
1414 | 0 | } |
1415 | | /** |
1416 | | * fu_struct_genesys_ts_dynamic_gl359030_new_internal: (skip): |
1417 | | **/ |
1418 | | static FuStructGenesysTsDynamicGl359030 * |
1419 | | fu_struct_genesys_ts_dynamic_gl359030_new_internal(void) |
1420 | 0 | { |
1421 | 0 | FuStructGenesysTsDynamicGl359030 *st = g_new0(FuStructGenesysTsDynamicGl359030, 1); |
1422 | 0 | st->refcount = 1; |
1423 | 0 | return st; |
1424 | 0 | } |
1425 | | |
1426 | | /* getters */ |
1427 | | /** |
1428 | | * fu_struct_genesys_ts_dynamic_gl359030_get_running_mode: (skip): |
1429 | | **/ |
1430 | | gchar * |
1431 | | fu_struct_genesys_ts_dynamic_gl359030_get_running_mode(const FuStructGenesysTsDynamicGl359030 *st) |
1432 | 0 | { |
1433 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1434 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL); |
1435 | 0 | } |
1436 | | /** |
1437 | | * fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number: (skip): |
1438 | | **/ |
1439 | | gchar * |
1440 | | fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number(const FuStructGenesysTsDynamicGl359030 *st) |
1441 | 0 | { |
1442 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1443 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL); |
1444 | 0 | } |
1445 | | /** |
1446 | | * fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number: (skip): |
1447 | | **/ |
1448 | | gchar * |
1449 | | fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number(const FuStructGenesysTsDynamicGl359030 *st) |
1450 | 0 | { |
1451 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1452 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL); |
1453 | 0 | } |
1454 | | /** |
1455 | | * fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status: (skip): |
1456 | | **/ |
1457 | | gchar * |
1458 | | fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status(const FuStructGenesysTsDynamicGl359030 *st) |
1459 | 0 | { |
1460 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1461 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL); |
1462 | 0 | } |
1463 | | /** |
1464 | | * fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status: (skip): |
1465 | | **/ |
1466 | | gchar * |
1467 | | fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status(const FuStructGenesysTsDynamicGl359030 *st) |
1468 | 0 | { |
1469 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1470 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL); |
1471 | 0 | } |
1472 | | /** |
1473 | | * fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status: (skip): |
1474 | | **/ |
1475 | | gchar * |
1476 | | fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status(const FuStructGenesysTsDynamicGl359030 *st) |
1477 | 0 | { |
1478 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1479 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL); |
1480 | 0 | } |
1481 | | /** |
1482 | | * fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status: (skip): |
1483 | | **/ |
1484 | | gchar * |
1485 | | fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status(const FuStructGenesysTsDynamicGl359030 *st) |
1486 | 0 | { |
1487 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1488 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL); |
1489 | 0 | } |
1490 | | /** |
1491 | | * fu_struct_genesys_ts_dynamic_gl359030_get_charging: (skip): |
1492 | | **/ |
1493 | | gchar * |
1494 | | fu_struct_genesys_ts_dynamic_gl359030_get_charging(const FuStructGenesysTsDynamicGl359030 *st) |
1495 | 0 | { |
1496 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1497 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL); |
1498 | 0 | } |
1499 | | /** |
1500 | | * fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status: (skip): |
1501 | | **/ |
1502 | | gchar * |
1503 | | fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status(const FuStructGenesysTsDynamicGl359030 *st) |
1504 | 0 | { |
1505 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1506 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL); |
1507 | 0 | } |
1508 | | /** |
1509 | | * fu_struct_genesys_ts_dynamic_gl359030_get_bonding: (skip): |
1510 | | **/ |
1511 | | guint8 |
1512 | | fu_struct_genesys_ts_dynamic_gl359030_get_bonding(const FuStructGenesysTsDynamicGl359030 *st) |
1513 | 0 | { |
1514 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1515 | 0 | return st->buf->data[9]; |
1516 | 0 | } |
1517 | | /** |
1518 | | * fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status: (skip): |
1519 | | **/ |
1520 | | FuGenesysFwStatus |
1521 | | fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(const FuStructGenesysTsDynamicGl359030 *st) |
1522 | 0 | { |
1523 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1524 | 0 | return st->buf->data[10]; |
1525 | 0 | } |
1526 | | /** |
1527 | | * fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status: (skip): |
1528 | | **/ |
1529 | | FuGenesysFwStatus |
1530 | | fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(const FuStructGenesysTsDynamicGl359030 *st) |
1531 | 0 | { |
1532 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1533 | 0 | return st->buf->data[11]; |
1534 | 0 | } |
1535 | | /** |
1536 | | * fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version: (skip): |
1537 | | **/ |
1538 | | guint16 |
1539 | | fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version(const FuStructGenesysTsDynamicGl359030 *st) |
1540 | 0 | { |
1541 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1542 | 0 | return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN); |
1543 | 0 | } |
1544 | | |
1545 | | /* setters */ |
1546 | | /** |
1547 | | * fu_struct_genesys_ts_dynamic_gl359030_to_string: (skip): |
1548 | | **/ |
1549 | | static gchar * |
1550 | | fu_struct_genesys_ts_dynamic_gl359030_to_string(const FuStructGenesysTsDynamicGl359030 *st) |
1551 | 0 | { |
1552 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl359030:\n"); |
1553 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1554 | 0 | { |
1555 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_running_mode(st); |
1556 | 0 | if (tmp != NULL) |
1557 | 0 | g_string_append_printf(str, " running_mode: %s\n", tmp); |
1558 | 0 | } |
1559 | 0 | { |
1560 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number(st); |
1561 | 0 | if (tmp != NULL) |
1562 | 0 | g_string_append_printf(str, " ss_port_number: %s\n", tmp); |
1563 | 0 | } |
1564 | 0 | { |
1565 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number(st); |
1566 | 0 | if (tmp != NULL) |
1567 | 0 | g_string_append_printf(str, " hs_port_number: %s\n", tmp); |
1568 | 0 | } |
1569 | 0 | { |
1570 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status(st); |
1571 | 0 | if (tmp != NULL) |
1572 | 0 | g_string_append_printf(str, " ss_connection_status: %s\n", tmp); |
1573 | 0 | } |
1574 | 0 | { |
1575 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status(st); |
1576 | 0 | if (tmp != NULL) |
1577 | 0 | g_string_append_printf(str, " hs_connection_status: %s\n", tmp); |
1578 | 0 | } |
1579 | 0 | { |
1580 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status(st); |
1581 | 0 | if (tmp != NULL) |
1582 | 0 | g_string_append_printf(str, " fs_connection_status: %s\n", tmp); |
1583 | 0 | } |
1584 | 0 | { |
1585 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status(st); |
1586 | 0 | if (tmp != NULL) |
1587 | 0 | g_string_append_printf(str, " ls_connection_status: %s\n", tmp); |
1588 | 0 | } |
1589 | 0 | { |
1590 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_charging(st); |
1591 | 0 | if (tmp != NULL) |
1592 | 0 | g_string_append_printf(str, " charging: %s\n", tmp); |
1593 | 0 | } |
1594 | 0 | { |
1595 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status(st); |
1596 | 0 | if (tmp != NULL) |
1597 | 0 | g_string_append_printf(str, " non_removable_port_status: %s\n", tmp); |
1598 | 0 | } |
1599 | 0 | g_string_append_printf(str, " bonding: 0x%x\n", |
1600 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl359030_get_bonding(st)); |
1601 | 0 | { |
1602 | 0 | const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(st)); |
1603 | 0 | if (tmp != NULL) { |
1604 | 0 | g_string_append_printf(str, " hub_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(st), tmp); |
1605 | 0 | } else { |
1606 | 0 | g_string_append_printf(str, " hub_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(st)); |
1607 | 0 | } |
1608 | 0 | } |
1609 | 0 | { |
1610 | 0 | const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(st)); |
1611 | 0 | if (tmp != NULL) { |
1612 | 0 | g_string_append_printf(str, " dev_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(st), tmp); |
1613 | 0 | } else { |
1614 | 0 | g_string_append_printf(str, " dev_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(st)); |
1615 | 0 | } |
1616 | 0 | } |
1617 | 0 | g_string_append_printf(str, " dev_fw_version: 0x%x\n", |
1618 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version(st)); |
1619 | 0 | if (str->len > 0) |
1620 | 0 | g_string_set_size(str, str->len - 1); |
1621 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1622 | 0 | } |
1623 | | static gboolean |
1624 | | fu_struct_genesys_ts_dynamic_gl359030_validate_internal(FuStructGenesysTsDynamicGl359030 *st, GError **error) |
1625 | 0 | { |
1626 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1627 | 0 | return TRUE; |
1628 | 0 | } |
1629 | | static gboolean |
1630 | | fu_struct_genesys_ts_dynamic_gl359030_parse_internal(FuStructGenesysTsDynamicGl359030 *st, GError **error) |
1631 | 0 | { |
1632 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1633 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl359030_to_string(st); |
1634 | 0 | g_debug("%s", str); |
1635 | 0 | } |
1636 | 0 | if (!fu_struct_genesys_ts_dynamic_gl359030_validate_internal(st, error)) |
1637 | 0 | return FALSE; |
1638 | 0 | return TRUE; |
1639 | 0 | } |
1640 | | |
1641 | | /** |
1642 | | * fu_struct_genesys_ts_dynamic_gl359030_parse: (skip): |
1643 | | **/ |
1644 | | FuStructGenesysTsDynamicGl359030 * |
1645 | | fu_struct_genesys_ts_dynamic_gl359030_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1646 | 0 | { |
1647 | 0 | g_autoptr(FuStructGenesysTsDynamicGl359030) st = fu_struct_genesys_ts_dynamic_gl359030_new_internal(); |
1648 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1649 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1650 | 0 | if (!fu_memchk_read(bufsz, offset, 14, error)) { |
1651 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl359030: "); |
1652 | 0 | return NULL; |
1653 | 0 | } |
1654 | 0 | st->buf = g_byte_array_new(); |
1655 | 0 | g_byte_array_append(st->buf, buf + offset, 14); |
1656 | 0 | if (!fu_struct_genesys_ts_dynamic_gl359030_parse_internal(st, error)) |
1657 | 0 | return NULL; |
1658 | 0 | return g_steal_pointer(&st); |
1659 | 0 | } |
1660 | | /** |
1661 | | * fu_struct_genesys_ts_dynamic_gl3525_ref: (skip): |
1662 | | **/ |
1663 | | FuStructGenesysTsDynamicGl3525 * |
1664 | | fu_struct_genesys_ts_dynamic_gl3525_ref(FuStructGenesysTsDynamicGl3525 *st) |
1665 | 0 | { |
1666 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1667 | 0 | st->refcount++; |
1668 | 0 | return st; |
1669 | 0 | } |
1670 | | /** |
1671 | | * fu_struct_genesys_ts_dynamic_gl3525_unref: (skip): |
1672 | | **/ |
1673 | | void |
1674 | | fu_struct_genesys_ts_dynamic_gl3525_unref(FuStructGenesysTsDynamicGl3525 *st) |
1675 | 0 | { |
1676 | 0 | g_return_if_fail(st != NULL); |
1677 | 0 | if (st->refcount == 0) { |
1678 | 0 | g_critical("FuStructGenesysTsDynamicGl3525 refcount already zero"); |
1679 | 0 | return; |
1680 | 0 | } |
1681 | 0 | if (--st->refcount > 0) |
1682 | 0 | return; |
1683 | 0 | if (st->buf != NULL) |
1684 | 0 | g_byte_array_unref(st->buf); |
1685 | 0 | g_free(st); |
1686 | 0 | } |
1687 | | /** |
1688 | | * fu_struct_genesys_ts_dynamic_gl3525_new_internal: (skip): |
1689 | | **/ |
1690 | | static FuStructGenesysTsDynamicGl3525 * |
1691 | | fu_struct_genesys_ts_dynamic_gl3525_new_internal(void) |
1692 | 0 | { |
1693 | 0 | FuStructGenesysTsDynamicGl3525 *st = g_new0(FuStructGenesysTsDynamicGl3525, 1); |
1694 | 0 | st->refcount = 1; |
1695 | 0 | return st; |
1696 | 0 | } |
1697 | | |
1698 | | /* getters */ |
1699 | | /** |
1700 | | * fu_struct_genesys_ts_dynamic_gl3525_get_running_mode: (skip): |
1701 | | **/ |
1702 | | gchar * |
1703 | | fu_struct_genesys_ts_dynamic_gl3525_get_running_mode(const FuStructGenesysTsDynamicGl3525 *st) |
1704 | 0 | { |
1705 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1706 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL); |
1707 | 0 | } |
1708 | | /** |
1709 | | * fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number: (skip): |
1710 | | **/ |
1711 | | gchar * |
1712 | | fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number(const FuStructGenesysTsDynamicGl3525 *st) |
1713 | 0 | { |
1714 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1715 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL); |
1716 | 0 | } |
1717 | | /** |
1718 | | * fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number: (skip): |
1719 | | **/ |
1720 | | gchar * |
1721 | | fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number(const FuStructGenesysTsDynamicGl3525 *st) |
1722 | 0 | { |
1723 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1724 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL); |
1725 | 0 | } |
1726 | | /** |
1727 | | * fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status: (skip): |
1728 | | **/ |
1729 | | gchar * |
1730 | | fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status(const FuStructGenesysTsDynamicGl3525 *st) |
1731 | 0 | { |
1732 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1733 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL); |
1734 | 0 | } |
1735 | | /** |
1736 | | * fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status: (skip): |
1737 | | **/ |
1738 | | gchar * |
1739 | | fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status(const FuStructGenesysTsDynamicGl3525 *st) |
1740 | 0 | { |
1741 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1742 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL); |
1743 | 0 | } |
1744 | | /** |
1745 | | * fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status: (skip): |
1746 | | **/ |
1747 | | gchar * |
1748 | | fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status(const FuStructGenesysTsDynamicGl3525 *st) |
1749 | 0 | { |
1750 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1751 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL); |
1752 | 0 | } |
1753 | | /** |
1754 | | * fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status: (skip): |
1755 | | **/ |
1756 | | gchar * |
1757 | | fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status(const FuStructGenesysTsDynamicGl3525 *st) |
1758 | 0 | { |
1759 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1760 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL); |
1761 | 0 | } |
1762 | | /** |
1763 | | * fu_struct_genesys_ts_dynamic_gl3525_get_charging: (skip): |
1764 | | **/ |
1765 | | gchar * |
1766 | | fu_struct_genesys_ts_dynamic_gl3525_get_charging(const FuStructGenesysTsDynamicGl3525 *st) |
1767 | 0 | { |
1768 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1769 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL); |
1770 | 0 | } |
1771 | | /** |
1772 | | * fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status: (skip): |
1773 | | **/ |
1774 | | gchar * |
1775 | | fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3525 *st) |
1776 | 0 | { |
1777 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1778 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL); |
1779 | 0 | } |
1780 | | /** |
1781 | | * fu_struct_genesys_ts_dynamic_gl3525_get_bonding: (skip): |
1782 | | **/ |
1783 | | guint8 |
1784 | | fu_struct_genesys_ts_dynamic_gl3525_get_bonding(const FuStructGenesysTsDynamicGl3525 *st) |
1785 | 0 | { |
1786 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1787 | 0 | return st->buf->data[9]; |
1788 | 0 | } |
1789 | | /** |
1790 | | * fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status: (skip): |
1791 | | **/ |
1792 | | FuGenesysFwStatus |
1793 | | fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(const FuStructGenesysTsDynamicGl3525 *st) |
1794 | 0 | { |
1795 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1796 | 0 | return st->buf->data[10]; |
1797 | 0 | } |
1798 | | /** |
1799 | | * fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status: (skip): |
1800 | | **/ |
1801 | | FuGenesysFwStatus |
1802 | | fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(const FuStructGenesysTsDynamicGl3525 *st) |
1803 | 0 | { |
1804 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1805 | 0 | return st->buf->data[11]; |
1806 | 0 | } |
1807 | | /** |
1808 | | * fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version: (skip): |
1809 | | **/ |
1810 | | guint16 |
1811 | | fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version(const FuStructGenesysTsDynamicGl3525 *st) |
1812 | 0 | { |
1813 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1814 | 0 | return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN); |
1815 | 0 | } |
1816 | | /** |
1817 | | * fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status: (skip): |
1818 | | **/ |
1819 | | FuGenesysFwStatus |
1820 | | fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(const FuStructGenesysTsDynamicGl3525 *st) |
1821 | 0 | { |
1822 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1823 | 0 | return st->buf->data[14]; |
1824 | 0 | } |
1825 | | /** |
1826 | | * fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version: (skip): |
1827 | | **/ |
1828 | | guint16 |
1829 | | fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version(const FuStructGenesysTsDynamicGl3525 *st) |
1830 | 0 | { |
1831 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
1832 | 0 | return fu_memread_uint16(st->buf->data + 15, G_LITTLE_ENDIAN); |
1833 | 0 | } |
1834 | | |
1835 | | /* setters */ |
1836 | | /** |
1837 | | * fu_struct_genesys_ts_dynamic_gl3525_to_string: (skip): |
1838 | | **/ |
1839 | | static gchar * |
1840 | | fu_struct_genesys_ts_dynamic_gl3525_to_string(const FuStructGenesysTsDynamicGl3525 *st) |
1841 | 0 | { |
1842 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3525:\n"); |
1843 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1844 | 0 | { |
1845 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_running_mode(st); |
1846 | 0 | if (tmp != NULL) |
1847 | 0 | g_string_append_printf(str, " running_mode: %s\n", tmp); |
1848 | 0 | } |
1849 | 0 | { |
1850 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number(st); |
1851 | 0 | if (tmp != NULL) |
1852 | 0 | g_string_append_printf(str, " ss_port_number: %s\n", tmp); |
1853 | 0 | } |
1854 | 0 | { |
1855 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number(st); |
1856 | 0 | if (tmp != NULL) |
1857 | 0 | g_string_append_printf(str, " hs_port_number: %s\n", tmp); |
1858 | 0 | } |
1859 | 0 | { |
1860 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status(st); |
1861 | 0 | if (tmp != NULL) |
1862 | 0 | g_string_append_printf(str, " ss_connection_status: %s\n", tmp); |
1863 | 0 | } |
1864 | 0 | { |
1865 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status(st); |
1866 | 0 | if (tmp != NULL) |
1867 | 0 | g_string_append_printf(str, " hs_connection_status: %s\n", tmp); |
1868 | 0 | } |
1869 | 0 | { |
1870 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status(st); |
1871 | 0 | if (tmp != NULL) |
1872 | 0 | g_string_append_printf(str, " fs_connection_status: %s\n", tmp); |
1873 | 0 | } |
1874 | 0 | { |
1875 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status(st); |
1876 | 0 | if (tmp != NULL) |
1877 | 0 | g_string_append_printf(str, " ls_connection_status: %s\n", tmp); |
1878 | 0 | } |
1879 | 0 | { |
1880 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_charging(st); |
1881 | 0 | if (tmp != NULL) |
1882 | 0 | g_string_append_printf(str, " charging: %s\n", tmp); |
1883 | 0 | } |
1884 | 0 | { |
1885 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status(st); |
1886 | 0 | if (tmp != NULL) |
1887 | 0 | g_string_append_printf(str, " non_removable_port_status: %s\n", tmp); |
1888 | 0 | } |
1889 | 0 | g_string_append_printf(str, " bonding: 0x%x\n", |
1890 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl3525_get_bonding(st)); |
1891 | 0 | { |
1892 | 0 | const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(st)); |
1893 | 0 | if (tmp != NULL) { |
1894 | 0 | g_string_append_printf(str, " hub_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(st), tmp); |
1895 | 0 | } else { |
1896 | 0 | g_string_append_printf(str, " hub_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(st)); |
1897 | 0 | } |
1898 | 0 | } |
1899 | 0 | { |
1900 | 0 | const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(st)); |
1901 | 0 | if (tmp != NULL) { |
1902 | 0 | g_string_append_printf(str, " pd_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(st), tmp); |
1903 | 0 | } else { |
1904 | 0 | g_string_append_printf(str, " pd_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(st)); |
1905 | 0 | } |
1906 | 0 | } |
1907 | 0 | g_string_append_printf(str, " pd_fw_version: 0x%x\n", |
1908 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version(st)); |
1909 | 0 | { |
1910 | 0 | const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(st)); |
1911 | 0 | if (tmp != NULL) { |
1912 | 0 | g_string_append_printf(str, " dev_fw_status: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(st), tmp); |
1913 | 0 | } else { |
1914 | 0 | g_string_append_printf(str, " dev_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(st)); |
1915 | 0 | } |
1916 | 0 | } |
1917 | 0 | g_string_append_printf(str, " dev_fw_version: 0x%x\n", |
1918 | 0 | (guint) fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version(st)); |
1919 | 0 | if (str->len > 0) |
1920 | 0 | g_string_set_size(str, str->len - 1); |
1921 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
1922 | 0 | } |
1923 | | static gboolean |
1924 | | fu_struct_genesys_ts_dynamic_gl3525_validate_internal(FuStructGenesysTsDynamicGl3525 *st, GError **error) |
1925 | 0 | { |
1926 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
1927 | 0 | return TRUE; |
1928 | 0 | } |
1929 | | static gboolean |
1930 | | fu_struct_genesys_ts_dynamic_gl3525_parse_internal(FuStructGenesysTsDynamicGl3525 *st, GError **error) |
1931 | 0 | { |
1932 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
1933 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3525_to_string(st); |
1934 | 0 | g_debug("%s", str); |
1935 | 0 | } |
1936 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3525_validate_internal(st, error)) |
1937 | 0 | return FALSE; |
1938 | 0 | return TRUE; |
1939 | 0 | } |
1940 | | |
1941 | | /** |
1942 | | * fu_struct_genesys_ts_dynamic_gl3525_parse: (skip): |
1943 | | **/ |
1944 | | FuStructGenesysTsDynamicGl3525 * |
1945 | | fu_struct_genesys_ts_dynamic_gl3525_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
1946 | 0 | { |
1947 | 0 | g_autoptr(FuStructGenesysTsDynamicGl3525) st = fu_struct_genesys_ts_dynamic_gl3525_new_internal(); |
1948 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
1949 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
1950 | 0 | if (!fu_memchk_read(bufsz, offset, 17, error)) { |
1951 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl3525: "); |
1952 | 0 | return NULL; |
1953 | 0 | } |
1954 | 0 | st->buf = g_byte_array_new(); |
1955 | 0 | g_byte_array_append(st->buf, buf + offset, 17); |
1956 | 0 | if (!fu_struct_genesys_ts_dynamic_gl3525_parse_internal(st, error)) |
1957 | 0 | return NULL; |
1958 | 0 | return g_steal_pointer(&st); |
1959 | 0 | } |
1960 | | /** |
1961 | | * fu_struct_genesys_ts_firmware_info_ref: (skip): |
1962 | | **/ |
1963 | | FuStructGenesysTsFirmwareInfo * |
1964 | | fu_struct_genesys_ts_firmware_info_ref(FuStructGenesysTsFirmwareInfo *st) |
1965 | 0 | { |
1966 | 0 | g_return_val_if_fail(st != NULL, NULL); |
1967 | 0 | st->refcount++; |
1968 | 0 | return st; |
1969 | 0 | } |
1970 | | /** |
1971 | | * fu_struct_genesys_ts_firmware_info_unref: (skip): |
1972 | | **/ |
1973 | | void |
1974 | | fu_struct_genesys_ts_firmware_info_unref(FuStructGenesysTsFirmwareInfo *st) |
1975 | 0 | { |
1976 | 0 | g_return_if_fail(st != NULL); |
1977 | 0 | if (st->refcount == 0) { |
1978 | 0 | g_critical("FuStructGenesysTsFirmwareInfo refcount already zero"); |
1979 | 0 | return; |
1980 | 0 | } |
1981 | 0 | if (--st->refcount > 0) |
1982 | 0 | return; |
1983 | 0 | if (st->buf != NULL) |
1984 | 0 | g_byte_array_unref(st->buf); |
1985 | 0 | g_free(st); |
1986 | 0 | } |
1987 | | /** |
1988 | | * fu_struct_genesys_ts_firmware_info_new_internal: (skip): |
1989 | | **/ |
1990 | | static FuStructGenesysTsFirmwareInfo * |
1991 | | fu_struct_genesys_ts_firmware_info_new_internal(void) |
1992 | 0 | { |
1993 | 0 | FuStructGenesysTsFirmwareInfo *st = g_new0(FuStructGenesysTsFirmwareInfo, 1); |
1994 | 0 | st->refcount = 1; |
1995 | 0 | return st; |
1996 | 0 | } |
1997 | | |
1998 | | /* getters */ |
1999 | | /** |
2000 | | * fu_struct_genesys_ts_firmware_info_get_tool_version: (skip): |
2001 | | **/ |
2002 | | const guint8 * |
2003 | | fu_struct_genesys_ts_firmware_info_get_tool_version(const FuStructGenesysTsFirmwareInfo *st, gsize *bufsz) |
2004 | 0 | { |
2005 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2006 | 0 | if (bufsz != NULL) |
2007 | 0 | *bufsz = 6; |
2008 | 0 | return st->buf->data + 0; |
2009 | 0 | } |
2010 | | /** |
2011 | | * fu_struct_genesys_ts_firmware_info_get_address_mode: (skip): |
2012 | | **/ |
2013 | | guint8 |
2014 | | fu_struct_genesys_ts_firmware_info_get_address_mode(const FuStructGenesysTsFirmwareInfo *st) |
2015 | 0 | { |
2016 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2017 | 0 | return st->buf->data[6]; |
2018 | 0 | } |
2019 | | /** |
2020 | | * fu_struct_genesys_ts_firmware_info_get_build_fw_time: (skip): |
2021 | | **/ |
2022 | | gchar * |
2023 | | fu_struct_genesys_ts_firmware_info_get_build_fw_time(const FuStructGenesysTsFirmwareInfo *st) |
2024 | 0 | { |
2025 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2026 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 7, 12, NULL); |
2027 | 0 | } |
2028 | | /** |
2029 | | * fu_struct_genesys_ts_firmware_info_get_update_fw_time: (skip): |
2030 | | **/ |
2031 | | gchar * |
2032 | | fu_struct_genesys_ts_firmware_info_get_update_fw_time(const FuStructGenesysTsFirmwareInfo *st) |
2033 | 0 | { |
2034 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2035 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 19, 12, NULL); |
2036 | 0 | } |
2037 | | |
2038 | | /* setters */ |
2039 | | /** |
2040 | | * fu_struct_genesys_ts_firmware_info_to_string: (skip): |
2041 | | **/ |
2042 | | static gchar * |
2043 | | fu_struct_genesys_ts_firmware_info_to_string(const FuStructGenesysTsFirmwareInfo *st) |
2044 | 0 | { |
2045 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsFirmwareInfo:\n"); |
2046 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2047 | 0 | { |
2048 | 0 | gsize bufsz = 0; |
2049 | 0 | const guint8 *buf = fu_struct_genesys_ts_firmware_info_get_tool_version(st, &bufsz); |
2050 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
2051 | 0 | for (gsize i = 0; i < bufsz; i++) |
2052 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
2053 | 0 | g_string_append_printf(str, " tool_version: 0x%s\n", tmp->str); |
2054 | 0 | } |
2055 | 0 | g_string_append_printf(str, " address_mode: 0x%x\n", |
2056 | 0 | (guint) fu_struct_genesys_ts_firmware_info_get_address_mode(st)); |
2057 | 0 | { |
2058 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_firmware_info_get_build_fw_time(st); |
2059 | 0 | if (tmp != NULL) |
2060 | 0 | g_string_append_printf(str, " build_fw_time: %s\n", tmp); |
2061 | 0 | } |
2062 | 0 | { |
2063 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_firmware_info_get_update_fw_time(st); |
2064 | 0 | if (tmp != NULL) |
2065 | 0 | g_string_append_printf(str, " update_fw_time: %s\n", tmp); |
2066 | 0 | } |
2067 | 0 | if (str->len > 0) |
2068 | 0 | g_string_set_size(str, str->len - 1); |
2069 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
2070 | 0 | } |
2071 | | static gboolean |
2072 | | fu_struct_genesys_ts_firmware_info_validate_internal(FuStructGenesysTsFirmwareInfo *st, GError **error) |
2073 | 0 | { |
2074 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2075 | 0 | return TRUE; |
2076 | 0 | } |
2077 | | static gboolean |
2078 | | fu_struct_genesys_ts_firmware_info_parse_internal(FuStructGenesysTsFirmwareInfo *st, GError **error) |
2079 | 0 | { |
2080 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
2081 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_firmware_info_to_string(st); |
2082 | 0 | g_debug("%s", str); |
2083 | 0 | } |
2084 | 0 | if (!fu_struct_genesys_ts_firmware_info_validate_internal(st, error)) |
2085 | 0 | return FALSE; |
2086 | 0 | return TRUE; |
2087 | 0 | } |
2088 | | |
2089 | | /** |
2090 | | * fu_struct_genesys_ts_firmware_info_parse: (skip): |
2091 | | **/ |
2092 | | FuStructGenesysTsFirmwareInfo * |
2093 | | fu_struct_genesys_ts_firmware_info_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
2094 | 0 | { |
2095 | 0 | g_autoptr(FuStructGenesysTsFirmwareInfo) st = fu_struct_genesys_ts_firmware_info_new_internal(); |
2096 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
2097 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
2098 | 0 | if (!fu_memchk_read(bufsz, offset, 31, error)) { |
2099 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsFirmwareInfo: "); |
2100 | 0 | return NULL; |
2101 | 0 | } |
2102 | 0 | st->buf = g_byte_array_new(); |
2103 | 0 | g_byte_array_append(st->buf, buf + offset, 31); |
2104 | 0 | if (!fu_struct_genesys_ts_firmware_info_parse_internal(st, error)) |
2105 | 0 | return NULL; |
2106 | 0 | return g_steal_pointer(&st); |
2107 | 0 | } |
2108 | | /** |
2109 | | * fu_struct_genesys_ts_vendor_support_ref: (skip): |
2110 | | **/ |
2111 | | FuStructGenesysTsVendorSupport * |
2112 | | fu_struct_genesys_ts_vendor_support_ref(FuStructGenesysTsVendorSupport *st) |
2113 | 0 | { |
2114 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2115 | 0 | st->refcount++; |
2116 | 0 | return st; |
2117 | 0 | } |
2118 | | /** |
2119 | | * fu_struct_genesys_ts_vendor_support_unref: (skip): |
2120 | | **/ |
2121 | | void |
2122 | | fu_struct_genesys_ts_vendor_support_unref(FuStructGenesysTsVendorSupport *st) |
2123 | 0 | { |
2124 | 0 | g_return_if_fail(st != NULL); |
2125 | 0 | if (st->refcount == 0) { |
2126 | 0 | g_critical("FuStructGenesysTsVendorSupport refcount already zero"); |
2127 | 0 | return; |
2128 | 0 | } |
2129 | 0 | if (--st->refcount > 0) |
2130 | 0 | return; |
2131 | 0 | if (st->buf != NULL) |
2132 | 0 | g_byte_array_unref(st->buf); |
2133 | 0 | g_free(st); |
2134 | 0 | } |
2135 | | /** |
2136 | | * fu_struct_genesys_ts_vendor_support_new_internal: (skip): |
2137 | | **/ |
2138 | | static FuStructGenesysTsVendorSupport * |
2139 | | fu_struct_genesys_ts_vendor_support_new_internal(void) |
2140 | 0 | { |
2141 | 0 | FuStructGenesysTsVendorSupport *st = g_new0(FuStructGenesysTsVendorSupport, 1); |
2142 | 0 | st->refcount = 1; |
2143 | 0 | return st; |
2144 | 0 | } |
2145 | | |
2146 | | /* getters */ |
2147 | | /** |
2148 | | * fu_struct_genesys_ts_vendor_support_get_version: (skip): |
2149 | | **/ |
2150 | | gchar * |
2151 | | fu_struct_genesys_ts_vendor_support_get_version(const FuStructGenesysTsVendorSupport *st) |
2152 | 0 | { |
2153 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2154 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 2, NULL); |
2155 | 0 | } |
2156 | | /** |
2157 | | * fu_struct_genesys_ts_vendor_support_get_reserved1: (skip): |
2158 | | **/ |
2159 | | gchar * |
2160 | | fu_struct_genesys_ts_vendor_support_get_reserved1(const FuStructGenesysTsVendorSupport *st) |
2161 | 0 | { |
2162 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2163 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 2, 8, NULL); |
2164 | 0 | } |
2165 | | /** |
2166 | | * fu_struct_genesys_ts_vendor_support_get_codesign_check: (skip): |
2167 | | **/ |
2168 | | FuGenesysVsCodesignCheck |
2169 | | fu_struct_genesys_ts_vendor_support_get_codesign_check(const FuStructGenesysTsVendorSupport *st) |
2170 | 0 | { |
2171 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2172 | 0 | return st->buf->data[10]; |
2173 | 0 | } |
2174 | | /** |
2175 | | * fu_struct_genesys_ts_vendor_support_get_reserved2: (skip): |
2176 | | **/ |
2177 | | gchar * |
2178 | | fu_struct_genesys_ts_vendor_support_get_reserved2(const FuStructGenesysTsVendorSupport *st) |
2179 | 0 | { |
2180 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2181 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 11, 4, NULL); |
2182 | 0 | } |
2183 | | /** |
2184 | | * fu_struct_genesys_ts_vendor_support_get_hid_isp: (skip): |
2185 | | **/ |
2186 | | FuGenesysVsHidIsp |
2187 | | fu_struct_genesys_ts_vendor_support_get_hid_isp(const FuStructGenesysTsVendorSupport *st) |
2188 | 0 | { |
2189 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2190 | 0 | return st->buf->data[15]; |
2191 | 0 | } |
2192 | | /** |
2193 | | * fu_struct_genesys_ts_vendor_support_get_reserved3: (skip): |
2194 | | **/ |
2195 | | gchar * |
2196 | | fu_struct_genesys_ts_vendor_support_get_reserved3(const FuStructGenesysTsVendorSupport *st) |
2197 | 0 | { |
2198 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2199 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 16, 15, NULL); |
2200 | 0 | } |
2201 | | |
2202 | | /* setters */ |
2203 | | /** |
2204 | | * fu_struct_genesys_ts_vendor_support_set_version: (skip): |
2205 | | **/ |
2206 | | gboolean |
2207 | | fu_struct_genesys_ts_vendor_support_set_version(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error) |
2208 | 0 | { |
2209 | 0 | gsize len; |
2210 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2211 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2212 | 0 | if (value == NULL) { |
2213 | 0 | memset(st->buf->data + 0, 0x0, 2); |
2214 | 0 | return TRUE; |
2215 | 0 | } |
2216 | 0 | len = strlen(value); |
2217 | 0 | if (len > 2) { |
2218 | 0 | g_set_error(error, |
2219 | 0 | FWUPD_ERROR, |
2220 | 0 | FWUPD_ERROR_INVALID_DATA, |
2221 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.version (0x%x bytes)", |
2222 | 0 | value, (guint) len, (guint) 2); |
2223 | 0 | return FALSE; |
2224 | 0 | } |
2225 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 0, (const guint8 *)value, len, 0x0, len, error); |
2226 | 0 | } |
2227 | | /** |
2228 | | * fu_struct_genesys_ts_vendor_support_set_reserved1: (skip): |
2229 | | **/ |
2230 | | gboolean |
2231 | | fu_struct_genesys_ts_vendor_support_set_reserved1(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error) |
2232 | 0 | { |
2233 | 0 | gsize len; |
2234 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2235 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2236 | 0 | if (value == NULL) { |
2237 | 0 | memset(st->buf->data + 2, 0x0, 8); |
2238 | 0 | return TRUE; |
2239 | 0 | } |
2240 | 0 | len = strlen(value); |
2241 | 0 | if (len > 8) { |
2242 | 0 | g_set_error(error, |
2243 | 0 | FWUPD_ERROR, |
2244 | 0 | FWUPD_ERROR_INVALID_DATA, |
2245 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved1 (0x%x bytes)", |
2246 | 0 | value, (guint) len, (guint) 8); |
2247 | 0 | return FALSE; |
2248 | 0 | } |
2249 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 2, (const guint8 *)value, len, 0x0, len, error); |
2250 | 0 | } |
2251 | | /** |
2252 | | * fu_struct_genesys_ts_vendor_support_set_codesign_check: (skip): |
2253 | | **/ |
2254 | | void |
2255 | | fu_struct_genesys_ts_vendor_support_set_codesign_check(FuStructGenesysTsVendorSupport *st, FuGenesysVsCodesignCheck value) |
2256 | 0 | { |
2257 | 0 | g_return_if_fail(st != NULL); |
2258 | 0 | st->buf->data[10] = value; |
2259 | 0 | } |
2260 | | /** |
2261 | | * fu_struct_genesys_ts_vendor_support_set_reserved2: (skip): |
2262 | | **/ |
2263 | | gboolean |
2264 | | fu_struct_genesys_ts_vendor_support_set_reserved2(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error) |
2265 | 0 | { |
2266 | 0 | gsize len; |
2267 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2268 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2269 | 0 | if (value == NULL) { |
2270 | 0 | memset(st->buf->data + 11, 0x0, 4); |
2271 | 0 | return TRUE; |
2272 | 0 | } |
2273 | 0 | len = strlen(value); |
2274 | 0 | if (len > 4) { |
2275 | 0 | g_set_error(error, |
2276 | 0 | FWUPD_ERROR, |
2277 | 0 | FWUPD_ERROR_INVALID_DATA, |
2278 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved2 (0x%x bytes)", |
2279 | 0 | value, (guint) len, (guint) 4); |
2280 | 0 | return FALSE; |
2281 | 0 | } |
2282 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 11, (const guint8 *)value, len, 0x0, len, error); |
2283 | 0 | } |
2284 | | /** |
2285 | | * fu_struct_genesys_ts_vendor_support_set_hid_isp: (skip): |
2286 | | **/ |
2287 | | void |
2288 | | fu_struct_genesys_ts_vendor_support_set_hid_isp(FuStructGenesysTsVendorSupport *st, FuGenesysVsHidIsp value) |
2289 | 0 | { |
2290 | 0 | g_return_if_fail(st != NULL); |
2291 | 0 | st->buf->data[15] = value; |
2292 | 0 | } |
2293 | | /** |
2294 | | * fu_struct_genesys_ts_vendor_support_set_reserved3: (skip): |
2295 | | **/ |
2296 | | gboolean |
2297 | | fu_struct_genesys_ts_vendor_support_set_reserved3(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error) |
2298 | 0 | { |
2299 | 0 | gsize len; |
2300 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2301 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2302 | 0 | if (value == NULL) { |
2303 | 0 | memset(st->buf->data + 16, 0x0, 15); |
2304 | 0 | return TRUE; |
2305 | 0 | } |
2306 | 0 | len = strlen(value); |
2307 | 0 | if (len > 15) { |
2308 | 0 | g_set_error(error, |
2309 | 0 | FWUPD_ERROR, |
2310 | 0 | FWUPD_ERROR_INVALID_DATA, |
2311 | 0 | "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved3 (0x%x bytes)", |
2312 | 0 | value, (guint) len, (guint) 15); |
2313 | 0 | return FALSE; |
2314 | 0 | } |
2315 | 0 | return fu_memcpy_safe(st->buf->data, st->buf->len, 16, (const guint8 *)value, len, 0x0, len, error); |
2316 | 0 | } |
2317 | | /** |
2318 | | * fu_struct_genesys_ts_vendor_support_new: (skip): |
2319 | | **/ |
2320 | | FuStructGenesysTsVendorSupport * |
2321 | | fu_struct_genesys_ts_vendor_support_new(void) |
2322 | 0 | { |
2323 | 0 | FuStructGenesysTsVendorSupport *st = fu_struct_genesys_ts_vendor_support_new_internal(); |
2324 | 0 | st->buf = g_byte_array_sized_new(31); |
2325 | 0 | fu_byte_array_set_size(st->buf, 31, 0x0); |
2326 | 0 | return st; |
2327 | 0 | } |
2328 | | /** |
2329 | | * fu_struct_genesys_ts_vendor_support_to_string: (skip): |
2330 | | **/ |
2331 | | static gchar * |
2332 | | fu_struct_genesys_ts_vendor_support_to_string(const FuStructGenesysTsVendorSupport *st) |
2333 | 0 | { |
2334 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsVendorSupport:\n"); |
2335 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2336 | 0 | { |
2337 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_version(st); |
2338 | 0 | if (tmp != NULL) |
2339 | 0 | g_string_append_printf(str, " version: %s\n", tmp); |
2340 | 0 | } |
2341 | 0 | { |
2342 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved1(st); |
2343 | 0 | if (tmp != NULL) |
2344 | 0 | g_string_append_printf(str, " reserved1: %s\n", tmp); |
2345 | 0 | } |
2346 | 0 | { |
2347 | 0 | const gchar *tmp = fu_genesys_vs_codesign_check_to_string(fu_struct_genesys_ts_vendor_support_get_codesign_check(st)); |
2348 | 0 | if (tmp != NULL) { |
2349 | 0 | g_string_append_printf(str, " codesign_check: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_vendor_support_get_codesign_check(st), tmp); |
2350 | 0 | } else { |
2351 | 0 | g_string_append_printf(str, " codesign_check: 0x%x\n", (guint) fu_struct_genesys_ts_vendor_support_get_codesign_check(st)); |
2352 | 0 | } |
2353 | 0 | } |
2354 | 0 | { |
2355 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved2(st); |
2356 | 0 | if (tmp != NULL) |
2357 | 0 | g_string_append_printf(str, " reserved2: %s\n", tmp); |
2358 | 0 | } |
2359 | 0 | { |
2360 | 0 | const gchar *tmp = fu_genesys_vs_hid_isp_to_string(fu_struct_genesys_ts_vendor_support_get_hid_isp(st)); |
2361 | 0 | if (tmp != NULL) { |
2362 | 0 | g_string_append_printf(str, " hid_isp: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_vendor_support_get_hid_isp(st), tmp); |
2363 | 0 | } else { |
2364 | 0 | g_string_append_printf(str, " hid_isp: 0x%x\n", (guint) fu_struct_genesys_ts_vendor_support_get_hid_isp(st)); |
2365 | 0 | } |
2366 | 0 | } |
2367 | 0 | { |
2368 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved3(st); |
2369 | 0 | if (tmp != NULL) |
2370 | 0 | g_string_append_printf(str, " reserved3: %s\n", tmp); |
2371 | 0 | } |
2372 | 0 | if (str->len > 0) |
2373 | 0 | g_string_set_size(str, str->len - 1); |
2374 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
2375 | 0 | } |
2376 | | static gboolean |
2377 | | fu_struct_genesys_ts_vendor_support_validate_internal(FuStructGenesysTsVendorSupport *st, GError **error) |
2378 | 0 | { |
2379 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2380 | 0 | return TRUE; |
2381 | 0 | } |
2382 | | static gboolean |
2383 | | fu_struct_genesys_ts_vendor_support_parse_internal(FuStructGenesysTsVendorSupport *st, GError **error) |
2384 | 0 | { |
2385 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
2386 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_vendor_support_to_string(st); |
2387 | 0 | g_debug("%s", str); |
2388 | 0 | } |
2389 | 0 | if (!fu_struct_genesys_ts_vendor_support_validate_internal(st, error)) |
2390 | 0 | return FALSE; |
2391 | 0 | return TRUE; |
2392 | 0 | } |
2393 | | |
2394 | | /** |
2395 | | * fu_struct_genesys_ts_vendor_support_parse: (skip): |
2396 | | **/ |
2397 | | FuStructGenesysTsVendorSupport * |
2398 | | fu_struct_genesys_ts_vendor_support_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
2399 | 0 | { |
2400 | 0 | g_autoptr(FuStructGenesysTsVendorSupport) st = fu_struct_genesys_ts_vendor_support_new_internal(); |
2401 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
2402 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
2403 | 0 | if (!fu_memchk_read(bufsz, offset, 31, error)) { |
2404 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsVendorSupport: "); |
2405 | 0 | return NULL; |
2406 | 0 | } |
2407 | 0 | st->buf = g_byte_array_new(); |
2408 | 0 | g_byte_array_append(st->buf, buf + offset, 31); |
2409 | 0 | if (!fu_struct_genesys_ts_vendor_support_parse_internal(st, error)) |
2410 | 0 | return NULL; |
2411 | 0 | return g_steal_pointer(&st); |
2412 | 0 | } |
2413 | | /** |
2414 | | * fu_struct_genesys_ts_brand_project_ref: (skip): |
2415 | | **/ |
2416 | | FuStructGenesysTsBrandProject * |
2417 | | fu_struct_genesys_ts_brand_project_ref(FuStructGenesysTsBrandProject *st) |
2418 | 0 | { |
2419 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2420 | 0 | st->refcount++; |
2421 | 0 | return st; |
2422 | 0 | } |
2423 | | /** |
2424 | | * fu_struct_genesys_ts_brand_project_unref: (skip): |
2425 | | **/ |
2426 | | void |
2427 | | fu_struct_genesys_ts_brand_project_unref(FuStructGenesysTsBrandProject *st) |
2428 | 0 | { |
2429 | 0 | g_return_if_fail(st != NULL); |
2430 | 0 | if (st->refcount == 0) { |
2431 | 0 | g_critical("FuStructGenesysTsBrandProject refcount already zero"); |
2432 | 0 | return; |
2433 | 0 | } |
2434 | 0 | if (--st->refcount > 0) |
2435 | 0 | return; |
2436 | 0 | if (st->buf != NULL) |
2437 | 0 | g_byte_array_unref(st->buf); |
2438 | 0 | g_free(st); |
2439 | 0 | } |
2440 | | /** |
2441 | | * fu_struct_genesys_ts_brand_project_new_internal: (skip): |
2442 | | **/ |
2443 | | static FuStructGenesysTsBrandProject * |
2444 | | fu_struct_genesys_ts_brand_project_new_internal(void) |
2445 | 0 | { |
2446 | 0 | FuStructGenesysTsBrandProject *st = g_new0(FuStructGenesysTsBrandProject, 1); |
2447 | 0 | st->refcount = 1; |
2448 | 0 | return st; |
2449 | 0 | } |
2450 | | |
2451 | | /* getters */ |
2452 | | /** |
2453 | | * fu_struct_genesys_ts_brand_project_get_project: (skip): |
2454 | | **/ |
2455 | | gchar * |
2456 | | fu_struct_genesys_ts_brand_project_get_project(const FuStructGenesysTsBrandProject *st) |
2457 | 0 | { |
2458 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2459 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 0, 15, NULL); |
2460 | 0 | } |
2461 | | |
2462 | | /* setters */ |
2463 | | /** |
2464 | | * fu_struct_genesys_ts_brand_project_to_string: (skip): |
2465 | | **/ |
2466 | | static gchar * |
2467 | | fu_struct_genesys_ts_brand_project_to_string(const FuStructGenesysTsBrandProject *st) |
2468 | 0 | { |
2469 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysTsBrandProject:\n"); |
2470 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2471 | 0 | { |
2472 | 0 | g_autofree gchar *tmp = fu_struct_genesys_ts_brand_project_get_project(st); |
2473 | 0 | if (tmp != NULL) |
2474 | 0 | g_string_append_printf(str, " project: %s\n", tmp); |
2475 | 0 | } |
2476 | 0 | if (str->len > 0) |
2477 | 0 | g_string_set_size(str, str->len - 1); |
2478 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
2479 | 0 | } |
2480 | | static gboolean |
2481 | | fu_struct_genesys_ts_brand_project_validate_internal(FuStructGenesysTsBrandProject *st, GError **error) |
2482 | 0 | { |
2483 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2484 | 0 | return TRUE; |
2485 | 0 | } |
2486 | | static gboolean |
2487 | | fu_struct_genesys_ts_brand_project_parse_internal(FuStructGenesysTsBrandProject *st, GError **error) |
2488 | 0 | { |
2489 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
2490 | 0 | g_autofree gchar *str = fu_struct_genesys_ts_brand_project_to_string(st); |
2491 | 0 | g_debug("%s", str); |
2492 | 0 | } |
2493 | 0 | if (!fu_struct_genesys_ts_brand_project_validate_internal(st, error)) |
2494 | 0 | return FALSE; |
2495 | 0 | return TRUE; |
2496 | 0 | } |
2497 | | |
2498 | | /** |
2499 | | * fu_struct_genesys_ts_brand_project_parse: (skip): |
2500 | | **/ |
2501 | | FuStructGenesysTsBrandProject * |
2502 | | fu_struct_genesys_ts_brand_project_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
2503 | 0 | { |
2504 | 0 | g_autoptr(FuStructGenesysTsBrandProject) st = fu_struct_genesys_ts_brand_project_new_internal(); |
2505 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
2506 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
2507 | 0 | if (!fu_memchk_read(bufsz, offset, 15, error)) { |
2508 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysTsBrandProject: "); |
2509 | 0 | return NULL; |
2510 | 0 | } |
2511 | 0 | st->buf = g_byte_array_new(); |
2512 | 0 | g_byte_array_append(st->buf, buf + offset, 15); |
2513 | 0 | if (!fu_struct_genesys_ts_brand_project_parse_internal(st, error)) |
2514 | 0 | return NULL; |
2515 | 0 | return g_steal_pointer(&st); |
2516 | 0 | } |
2517 | | /** |
2518 | | * fu_struct_genesys_fw_codesign_info_rsa_ref: (skip): |
2519 | | **/ |
2520 | | FuStructGenesysFwCodesignInfoRsa * |
2521 | | fu_struct_genesys_fw_codesign_info_rsa_ref(FuStructGenesysFwCodesignInfoRsa *st) |
2522 | 0 | { |
2523 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2524 | 0 | st->refcount++; |
2525 | 0 | return st; |
2526 | 0 | } |
2527 | | /** |
2528 | | * fu_struct_genesys_fw_codesign_info_rsa_unref: (skip): |
2529 | | **/ |
2530 | | void |
2531 | | fu_struct_genesys_fw_codesign_info_rsa_unref(FuStructGenesysFwCodesignInfoRsa *st) |
2532 | 213 | { |
2533 | 213 | g_return_if_fail(st != NULL); |
2534 | 213 | if (st->refcount == 0) { |
2535 | 0 | g_critical("FuStructGenesysFwCodesignInfoRsa refcount already zero"); |
2536 | 0 | return; |
2537 | 0 | } |
2538 | 213 | if (--st->refcount > 0) |
2539 | 0 | return; |
2540 | 213 | if (st->buf != NULL) |
2541 | 213 | g_byte_array_unref(st->buf); |
2542 | 213 | g_free(st); |
2543 | 213 | } |
2544 | | /** |
2545 | | * fu_struct_genesys_fw_codesign_info_rsa_new_internal: (skip): |
2546 | | **/ |
2547 | | static FuStructGenesysFwCodesignInfoRsa * |
2548 | | fu_struct_genesys_fw_codesign_info_rsa_new_internal(void) |
2549 | 213 | { |
2550 | 213 | FuStructGenesysFwCodesignInfoRsa *st = g_new0(FuStructGenesysFwCodesignInfoRsa, 1); |
2551 | 213 | st->refcount = 1; |
2552 | 213 | return st; |
2553 | 213 | } |
2554 | | |
2555 | | /* getters */ |
2556 | | /** |
2557 | | * fu_struct_genesys_fw_codesign_info_rsa_get_tag_n: (skip): |
2558 | | **/ |
2559 | | static guint32 |
2560 | | fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(const FuStructGenesysFwCodesignInfoRsa *st) |
2561 | 328 | { |
2562 | 328 | g_return_val_if_fail(st != NULL, 0x0); |
2563 | 328 | return fu_memread_uint32(st->buf->data + 0, G_BIG_ENDIAN); |
2564 | 328 | } |
2565 | | /** |
2566 | | * fu_struct_genesys_fw_codesign_info_rsa_get_text_n: (skip): |
2567 | | **/ |
2568 | | gchar * |
2569 | | fu_struct_genesys_fw_codesign_info_rsa_get_text_n(const FuStructGenesysFwCodesignInfoRsa *st) |
2570 | 0 | { |
2571 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2572 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 512, NULL); |
2573 | 0 | } |
2574 | | /** |
2575 | | * fu_struct_genesys_fw_codesign_info_rsa_get_end_n: (skip): |
2576 | | **/ |
2577 | | static guint16 |
2578 | | fu_struct_genesys_fw_codesign_info_rsa_get_end_n(const FuStructGenesysFwCodesignInfoRsa *st) |
2579 | 123 | { |
2580 | 123 | g_return_val_if_fail(st != NULL, 0x0); |
2581 | 123 | return fu_memread_uint16(st->buf->data + 516, G_BIG_ENDIAN); |
2582 | 123 | } |
2583 | | /** |
2584 | | * fu_struct_genesys_fw_codesign_info_rsa_get_tag_e: (skip): |
2585 | | **/ |
2586 | | static guint32 |
2587 | | fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(const FuStructGenesysFwCodesignInfoRsa *st) |
2588 | 123 | { |
2589 | 123 | g_return_val_if_fail(st != NULL, 0x0); |
2590 | 123 | return fu_memread_uint32(st->buf->data + 518, G_BIG_ENDIAN); |
2591 | 123 | } |
2592 | | /** |
2593 | | * fu_struct_genesys_fw_codesign_info_rsa_get_text_e: (skip): |
2594 | | **/ |
2595 | | gchar * |
2596 | | fu_struct_genesys_fw_codesign_info_rsa_get_text_e(const FuStructGenesysFwCodesignInfoRsa *st) |
2597 | 0 | { |
2598 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2599 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 522, 6, NULL); |
2600 | 0 | } |
2601 | | /** |
2602 | | * fu_struct_genesys_fw_codesign_info_rsa_get_end_e: (skip): |
2603 | | **/ |
2604 | | static guint16 |
2605 | | fu_struct_genesys_fw_codesign_info_rsa_get_end_e(const FuStructGenesysFwCodesignInfoRsa *st) |
2606 | 43 | { |
2607 | 43 | g_return_val_if_fail(st != NULL, 0x0); |
2608 | 43 | return fu_memread_uint16(st->buf->data + 528, G_BIG_ENDIAN); |
2609 | 43 | } |
2610 | | /** |
2611 | | * fu_struct_genesys_fw_codesign_info_rsa_get_signature: (skip): |
2612 | | **/ |
2613 | | const guint8 * |
2614 | | fu_struct_genesys_fw_codesign_info_rsa_get_signature(const FuStructGenesysFwCodesignInfoRsa *st, gsize *bufsz) |
2615 | 0 | { |
2616 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2617 | 0 | if (bufsz != NULL) |
2618 | 0 | *bufsz = 256; |
2619 | 0 | return st->buf->data + 530; |
2620 | 0 | } |
2621 | | |
2622 | | /* setters */ |
2623 | | /** |
2624 | | * fu_struct_genesys_fw_codesign_info_rsa_to_string: (skip): |
2625 | | **/ |
2626 | | static gchar * |
2627 | | fu_struct_genesys_fw_codesign_info_rsa_to_string(const FuStructGenesysFwCodesignInfoRsa *st) |
2628 | 0 | { |
2629 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysFwCodesignInfoRsa:\n"); |
2630 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2631 | 0 | g_string_append_printf(str, " tag_n: 0x%x\n", |
2632 | 0 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(st)); |
2633 | 0 | { |
2634 | 0 | g_autofree gchar *tmp = fu_struct_genesys_fw_codesign_info_rsa_get_text_n(st); |
2635 | 0 | if (tmp != NULL) |
2636 | 0 | g_string_append_printf(str, " text_n: %s\n", tmp); |
2637 | 0 | } |
2638 | 0 | g_string_append_printf(str, " end_n: 0x%x\n", |
2639 | 0 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_end_n(st)); |
2640 | 0 | g_string_append_printf(str, " tag_e: 0x%x\n", |
2641 | 0 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(st)); |
2642 | 0 | { |
2643 | 0 | g_autofree gchar *tmp = fu_struct_genesys_fw_codesign_info_rsa_get_text_e(st); |
2644 | 0 | if (tmp != NULL) |
2645 | 0 | g_string_append_printf(str, " text_e: %s\n", tmp); |
2646 | 0 | } |
2647 | 0 | g_string_append_printf(str, " end_e: 0x%x\n", |
2648 | 0 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_end_e(st)); |
2649 | 0 | { |
2650 | 0 | gsize bufsz = 0; |
2651 | 0 | const guint8 *buf = fu_struct_genesys_fw_codesign_info_rsa_get_signature(st, &bufsz); |
2652 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
2653 | 0 | for (gsize i = 0; i < bufsz; i++) |
2654 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
2655 | 0 | g_string_append_printf(str, " signature: 0x%s\n", tmp->str); |
2656 | 0 | } |
2657 | 0 | if (str->len > 0) |
2658 | 0 | g_string_set_size(str, str->len - 1); |
2659 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
2660 | 0 | } |
2661 | | static gboolean |
2662 | | fu_struct_genesys_fw_codesign_info_rsa_validate_internal(FuStructGenesysFwCodesignInfoRsa *st, GError **error) |
2663 | 213 | { |
2664 | 213 | g_return_val_if_fail(st != NULL, FALSE); |
2665 | 213 | if (fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(st) != 0x4E203D20) { |
2666 | 115 | g_set_error(error, |
2667 | 115 | FWUPD_ERROR, |
2668 | 115 | FWUPD_ERROR_INVALID_DATA, |
2669 | 115 | "constant FuStructGenesysFwCodesignInfoRsa.tag_n was not valid, " |
2670 | 115 | "expected 0x%x and got 0x%x", |
2671 | 115 | (guint) 0x4E203D20, |
2672 | 115 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(st)); |
2673 | 115 | return FALSE; |
2674 | 115 | } |
2675 | 98 | if (fu_struct_genesys_fw_codesign_info_rsa_get_end_n(st) != 0x0D0A) { |
2676 | 25 | g_set_error(error, |
2677 | 25 | FWUPD_ERROR, |
2678 | 25 | FWUPD_ERROR_INVALID_DATA, |
2679 | 25 | "constant FuStructGenesysFwCodesignInfoRsa.end_n was not valid, " |
2680 | 25 | "expected 0x%x and got 0x%x", |
2681 | 25 | (guint) 0x0D0A, |
2682 | 25 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_end_n(st)); |
2683 | 25 | return FALSE; |
2684 | 25 | } |
2685 | 73 | if (fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(st) != 0x45203D20) { |
2686 | 50 | g_set_error(error, |
2687 | 50 | FWUPD_ERROR, |
2688 | 50 | FWUPD_ERROR_INVALID_DATA, |
2689 | 50 | "constant FuStructGenesysFwCodesignInfoRsa.tag_e was not valid, " |
2690 | 50 | "expected 0x%x and got 0x%x", |
2691 | 50 | (guint) 0x45203D20, |
2692 | 50 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(st)); |
2693 | 50 | return FALSE; |
2694 | 50 | } |
2695 | 23 | if (fu_struct_genesys_fw_codesign_info_rsa_get_end_e(st) != 0x0D0A) { |
2696 | 20 | g_set_error(error, |
2697 | 20 | FWUPD_ERROR, |
2698 | 20 | FWUPD_ERROR_INVALID_DATA, |
2699 | 20 | "constant FuStructGenesysFwCodesignInfoRsa.end_e was not valid, " |
2700 | 20 | "expected 0x%x and got 0x%x", |
2701 | 20 | (guint) 0x0D0A, |
2702 | 20 | (guint) fu_struct_genesys_fw_codesign_info_rsa_get_end_e(st)); |
2703 | 20 | return FALSE; |
2704 | 20 | } |
2705 | 3 | return TRUE; |
2706 | 23 | } |
2707 | | /** |
2708 | | * fu_struct_genesys_fw_codesign_info_rsa_validate_stream: (skip): |
2709 | | **/ |
2710 | | gboolean |
2711 | | fu_struct_genesys_fw_codesign_info_rsa_validate_stream(GInputStream *stream, gsize offset, GError **error) |
2712 | 213 | { |
2713 | 213 | g_autoptr(FuStructGenesysFwCodesignInfoRsa) st = fu_struct_genesys_fw_codesign_info_rsa_new_internal(); |
2714 | 213 | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
2715 | 213 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2716 | 213 | st->buf = fu_input_stream_read_byte_array(stream, offset, 786, NULL, error); |
2717 | 213 | if (st->buf == NULL) { |
2718 | 0 | g_prefix_error(error, "FuStructGenesysFwCodesignInfoRsa failed read of 0x%x: ", (guint) 786); |
2719 | 0 | return FALSE; |
2720 | 0 | } |
2721 | 213 | if (st->buf->len != 786) { |
2722 | 0 | g_set_error(error, |
2723 | 0 | FWUPD_ERROR, |
2724 | 0 | FWUPD_ERROR_INVALID_DATA, |
2725 | 0 | "FuStructGenesysFwCodesignInfoRsa requested 0x%x and got 0x%x", |
2726 | 0 | (guint) 786, |
2727 | 0 | (guint) st->buf->len); |
2728 | 0 | return FALSE; |
2729 | 0 | } |
2730 | 213 | return fu_struct_genesys_fw_codesign_info_rsa_validate_internal(st, error); |
2731 | 213 | } |
2732 | | static gboolean |
2733 | | fu_struct_genesys_fw_codesign_info_rsa_parse_internal(FuStructGenesysFwCodesignInfoRsa *st, GError **error) |
2734 | 0 | { |
2735 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
2736 | 0 | g_autofree gchar *str = fu_struct_genesys_fw_codesign_info_rsa_to_string(st); |
2737 | 0 | g_debug("%s", str); |
2738 | 0 | } |
2739 | 0 | if (!fu_struct_genesys_fw_codesign_info_rsa_validate_internal(st, error)) |
2740 | 0 | return FALSE; |
2741 | 0 | return TRUE; |
2742 | 0 | } |
2743 | | /** |
2744 | | * fu_struct_genesys_fw_codesign_info_rsa_parse_stream: (skip): |
2745 | | **/ |
2746 | | FuStructGenesysFwCodesignInfoRsa * |
2747 | | fu_struct_genesys_fw_codesign_info_rsa_parse_stream(GInputStream *stream, gsize offset, GError **error) |
2748 | 0 | { |
2749 | 0 | g_autoptr(FuStructGenesysFwCodesignInfoRsa) st = fu_struct_genesys_fw_codesign_info_rsa_new_internal(); |
2750 | 0 | st->buf = fu_input_stream_read_byte_array(stream, offset, 786, NULL, error); |
2751 | 0 | if (st->buf == NULL) { |
2752 | 0 | g_prefix_error(error, "FuStructGenesysFwCodesignInfoRsa failed read of 0x%x: ", (guint) 786); |
2753 | 0 | return NULL; |
2754 | 0 | } |
2755 | 0 | if (st->buf->len != 786) { |
2756 | 0 | g_set_error(error, |
2757 | 0 | FWUPD_ERROR, |
2758 | 0 | FWUPD_ERROR_INVALID_DATA, |
2759 | 0 | "FuStructGenesysFwCodesignInfoRsa requested 0x%x and got 0x%x", |
2760 | 0 | (guint) 786, |
2761 | 0 | (guint) st->buf->len); |
2762 | 0 | return NULL; |
2763 | 0 | } |
2764 | 0 | if (!fu_struct_genesys_fw_codesign_info_rsa_parse_internal(st, error)) |
2765 | 0 | return NULL; |
2766 | 0 | return g_steal_pointer(&st); |
2767 | 0 | } |
2768 | | /** |
2769 | | * fu_struct_genesys_fw_rsa_public_key_text_ref: (skip): |
2770 | | **/ |
2771 | | FuStructGenesysFwRsaPublicKeyText * |
2772 | | fu_struct_genesys_fw_rsa_public_key_text_ref(FuStructGenesysFwRsaPublicKeyText *st) |
2773 | 0 | { |
2774 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2775 | 0 | st->refcount++; |
2776 | 0 | return st; |
2777 | 0 | } |
2778 | | /** |
2779 | | * fu_struct_genesys_fw_rsa_public_key_text_unref: (skip): |
2780 | | **/ |
2781 | | void |
2782 | | fu_struct_genesys_fw_rsa_public_key_text_unref(FuStructGenesysFwRsaPublicKeyText *st) |
2783 | 0 | { |
2784 | 0 | g_return_if_fail(st != NULL); |
2785 | 0 | if (st->refcount == 0) { |
2786 | 0 | g_critical("FuStructGenesysFwRsaPublicKeyText refcount already zero"); |
2787 | 0 | return; |
2788 | 0 | } |
2789 | 0 | if (--st->refcount > 0) |
2790 | 0 | return; |
2791 | 0 | if (st->buf != NULL) |
2792 | 0 | g_byte_array_unref(st->buf); |
2793 | 0 | g_free(st); |
2794 | 0 | } |
2795 | | /** |
2796 | | * fu_struct_genesys_fw_rsa_public_key_text_new_internal: (skip): |
2797 | | **/ |
2798 | | static FuStructGenesysFwRsaPublicKeyText * |
2799 | | fu_struct_genesys_fw_rsa_public_key_text_new_internal(void) |
2800 | 0 | { |
2801 | 0 | FuStructGenesysFwRsaPublicKeyText *st = g_new0(FuStructGenesysFwRsaPublicKeyText, 1); |
2802 | 0 | st->refcount = 1; |
2803 | 0 | return st; |
2804 | 0 | } |
2805 | | |
2806 | | /* getters */ |
2807 | | /** |
2808 | | * fu_struct_genesys_fw_rsa_public_key_text_get_tag_n: (skip): |
2809 | | **/ |
2810 | | static guint32 |
2811 | | fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(const FuStructGenesysFwRsaPublicKeyText *st) |
2812 | 0 | { |
2813 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2814 | 0 | return fu_memread_uint32(st->buf->data + 0, G_BIG_ENDIAN); |
2815 | 0 | } |
2816 | | /** |
2817 | | * fu_struct_genesys_fw_rsa_public_key_text_get_text_n: (skip): |
2818 | | **/ |
2819 | | gchar * |
2820 | | fu_struct_genesys_fw_rsa_public_key_text_get_text_n(const FuStructGenesysFwRsaPublicKeyText *st) |
2821 | 0 | { |
2822 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2823 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 4, 512, NULL); |
2824 | 0 | } |
2825 | | /** |
2826 | | * fu_struct_genesys_fw_rsa_public_key_text_get_end_n: (skip): |
2827 | | **/ |
2828 | | static guint16 |
2829 | | fu_struct_genesys_fw_rsa_public_key_text_get_end_n(const FuStructGenesysFwRsaPublicKeyText *st) |
2830 | 0 | { |
2831 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2832 | 0 | return fu_memread_uint16(st->buf->data + 516, G_BIG_ENDIAN); |
2833 | 0 | } |
2834 | | /** |
2835 | | * fu_struct_genesys_fw_rsa_public_key_text_get_tag_e: (skip): |
2836 | | **/ |
2837 | | static guint32 |
2838 | | fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(const FuStructGenesysFwRsaPublicKeyText *st) |
2839 | 0 | { |
2840 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2841 | 0 | return fu_memread_uint32(st->buf->data + 518, G_BIG_ENDIAN); |
2842 | 0 | } |
2843 | | /** |
2844 | | * fu_struct_genesys_fw_rsa_public_key_text_get_text_e: (skip): |
2845 | | **/ |
2846 | | gchar * |
2847 | | fu_struct_genesys_fw_rsa_public_key_text_get_text_e(const FuStructGenesysFwRsaPublicKeyText *st) |
2848 | 0 | { |
2849 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2850 | 0 | return fu_memstrsafe(st->buf->data, st->buf->len, 522, 6, NULL); |
2851 | 0 | } |
2852 | | /** |
2853 | | * fu_struct_genesys_fw_rsa_public_key_text_get_end_e: (skip): |
2854 | | **/ |
2855 | | static guint16 |
2856 | | fu_struct_genesys_fw_rsa_public_key_text_get_end_e(const FuStructGenesysFwRsaPublicKeyText *st) |
2857 | 0 | { |
2858 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
2859 | 0 | return fu_memread_uint16(st->buf->data + 528, G_BIG_ENDIAN); |
2860 | 0 | } |
2861 | | |
2862 | | /* setters */ |
2863 | | /** |
2864 | | * fu_struct_genesys_fw_rsa_public_key_text_to_string: (skip): |
2865 | | **/ |
2866 | | static gchar * |
2867 | | fu_struct_genesys_fw_rsa_public_key_text_to_string(const FuStructGenesysFwRsaPublicKeyText *st) |
2868 | 0 | { |
2869 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysFwRsaPublicKeyText:\n"); |
2870 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2871 | 0 | g_string_append_printf(str, " tag_n: 0x%x\n", |
2872 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(st)); |
2873 | 0 | { |
2874 | 0 | g_autofree gchar *tmp = fu_struct_genesys_fw_rsa_public_key_text_get_text_n(st); |
2875 | 0 | if (tmp != NULL) |
2876 | 0 | g_string_append_printf(str, " text_n: %s\n", tmp); |
2877 | 0 | } |
2878 | 0 | g_string_append_printf(str, " end_n: 0x%x\n", |
2879 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_end_n(st)); |
2880 | 0 | g_string_append_printf(str, " tag_e: 0x%x\n", |
2881 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(st)); |
2882 | 0 | { |
2883 | 0 | g_autofree gchar *tmp = fu_struct_genesys_fw_rsa_public_key_text_get_text_e(st); |
2884 | 0 | if (tmp != NULL) |
2885 | 0 | g_string_append_printf(str, " text_e: %s\n", tmp); |
2886 | 0 | } |
2887 | 0 | g_string_append_printf(str, " end_e: 0x%x\n", |
2888 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_end_e(st)); |
2889 | 0 | if (str->len > 0) |
2890 | 0 | g_string_set_size(str, str->len - 1); |
2891 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
2892 | 0 | } |
2893 | | static gboolean |
2894 | | fu_struct_genesys_fw_rsa_public_key_text_validate_internal(FuStructGenesysFwRsaPublicKeyText *st, GError **error) |
2895 | 0 | { |
2896 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
2897 | 0 | if (fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(st) != 0x4E203D20) { |
2898 | 0 | g_set_error(error, |
2899 | 0 | FWUPD_ERROR, |
2900 | 0 | FWUPD_ERROR_INVALID_DATA, |
2901 | 0 | "constant FuStructGenesysFwRsaPublicKeyText.tag_n was not valid, " |
2902 | 0 | "expected 0x%x and got 0x%x", |
2903 | 0 | (guint) 0x4E203D20, |
2904 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(st)); |
2905 | 0 | return FALSE; |
2906 | 0 | } |
2907 | 0 | if (fu_struct_genesys_fw_rsa_public_key_text_get_end_n(st) != 0x0D0A) { |
2908 | 0 | g_set_error(error, |
2909 | 0 | FWUPD_ERROR, |
2910 | 0 | FWUPD_ERROR_INVALID_DATA, |
2911 | 0 | "constant FuStructGenesysFwRsaPublicKeyText.end_n was not valid, " |
2912 | 0 | "expected 0x%x and got 0x%x", |
2913 | 0 | (guint) 0x0D0A, |
2914 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_end_n(st)); |
2915 | 0 | return FALSE; |
2916 | 0 | } |
2917 | 0 | if (fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(st) != 0x45203D20) { |
2918 | 0 | g_set_error(error, |
2919 | 0 | FWUPD_ERROR, |
2920 | 0 | FWUPD_ERROR_INVALID_DATA, |
2921 | 0 | "constant FuStructGenesysFwRsaPublicKeyText.tag_e was not valid, " |
2922 | 0 | "expected 0x%x and got 0x%x", |
2923 | 0 | (guint) 0x45203D20, |
2924 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(st)); |
2925 | 0 | return FALSE; |
2926 | 0 | } |
2927 | 0 | if (fu_struct_genesys_fw_rsa_public_key_text_get_end_e(st) != 0x0D0A) { |
2928 | 0 | g_set_error(error, |
2929 | 0 | FWUPD_ERROR, |
2930 | 0 | FWUPD_ERROR_INVALID_DATA, |
2931 | 0 | "constant FuStructGenesysFwRsaPublicKeyText.end_e was not valid, " |
2932 | 0 | "expected 0x%x and got 0x%x", |
2933 | 0 | (guint) 0x0D0A, |
2934 | 0 | (guint) fu_struct_genesys_fw_rsa_public_key_text_get_end_e(st)); |
2935 | 0 | return FALSE; |
2936 | 0 | } |
2937 | 0 | return TRUE; |
2938 | 0 | } |
2939 | | /** |
2940 | | * fu_struct_genesys_fw_rsa_public_key_text_validate: (skip): |
2941 | | **/ |
2942 | | gboolean |
2943 | | fu_struct_genesys_fw_rsa_public_key_text_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
2944 | 0 | { |
2945 | 0 | GByteArray st_buf = {.data = (guint8 *) buf + offset, .len = bufsz - offset, }; |
2946 | 0 | FuStructGenesysFwRsaPublicKeyText st_tmp = {.buf = &st_buf }; |
2947 | 0 | g_return_val_if_fail(buf != NULL, FALSE); |
2948 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
2949 | 0 | if (!fu_memchk_read(bufsz, offset, 530, error)) { |
2950 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwRsaPublicKeyText: "); |
2951 | 0 | return FALSE; |
2952 | 0 | } |
2953 | 0 | if (!fu_struct_genesys_fw_rsa_public_key_text_validate_internal(&st_tmp, error)) |
2954 | 0 | return FALSE; |
2955 | 0 | return TRUE; |
2956 | 0 | } |
2957 | | static gboolean |
2958 | | fu_struct_genesys_fw_rsa_public_key_text_parse_internal(FuStructGenesysFwRsaPublicKeyText *st, GError **error) |
2959 | 0 | { |
2960 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
2961 | 0 | g_autofree gchar *str = fu_struct_genesys_fw_rsa_public_key_text_to_string(st); |
2962 | 0 | g_debug("%s", str); |
2963 | 0 | } |
2964 | 0 | if (!fu_struct_genesys_fw_rsa_public_key_text_validate_internal(st, error)) |
2965 | 0 | return FALSE; |
2966 | 0 | return TRUE; |
2967 | 0 | } |
2968 | | |
2969 | | /** |
2970 | | * fu_struct_genesys_fw_rsa_public_key_text_parse: (skip): |
2971 | | **/ |
2972 | | FuStructGenesysFwRsaPublicKeyText * |
2973 | | fu_struct_genesys_fw_rsa_public_key_text_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
2974 | 0 | { |
2975 | 0 | g_autoptr(FuStructGenesysFwRsaPublicKeyText) st = fu_struct_genesys_fw_rsa_public_key_text_new_internal(); |
2976 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
2977 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
2978 | 0 | if (!fu_memchk_read(bufsz, offset, 530, error)) { |
2979 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwRsaPublicKeyText: "); |
2980 | 0 | return NULL; |
2981 | 0 | } |
2982 | 0 | st->buf = g_byte_array_new(); |
2983 | 0 | g_byte_array_append(st->buf, buf + offset, 530); |
2984 | 0 | if (!fu_struct_genesys_fw_rsa_public_key_text_parse_internal(st, error)) |
2985 | 0 | return NULL; |
2986 | 0 | return g_steal_pointer(&st); |
2987 | 0 | } |
2988 | | /** |
2989 | | * fu_struct_genesys_fw_codesign_info_ecdsa_ref: (skip): |
2990 | | **/ |
2991 | | FuStructGenesysFwCodesignInfoEcdsa * |
2992 | | fu_struct_genesys_fw_codesign_info_ecdsa_ref(FuStructGenesysFwCodesignInfoEcdsa *st) |
2993 | 0 | { |
2994 | 0 | g_return_val_if_fail(st != NULL, NULL); |
2995 | 0 | st->refcount++; |
2996 | 0 | return st; |
2997 | 0 | } |
2998 | | /** |
2999 | | * fu_struct_genesys_fw_codesign_info_ecdsa_unref: (skip): |
3000 | | **/ |
3001 | | void |
3002 | | fu_struct_genesys_fw_codesign_info_ecdsa_unref(FuStructGenesysFwCodesignInfoEcdsa *st) |
3003 | 35 | { |
3004 | 35 | g_return_if_fail(st != NULL); |
3005 | 35 | if (st->refcount == 0) { |
3006 | 0 | g_critical("FuStructGenesysFwCodesignInfoEcdsa refcount already zero"); |
3007 | 0 | return; |
3008 | 0 | } |
3009 | 35 | if (--st->refcount > 0) |
3010 | 0 | return; |
3011 | 35 | if (st->buf != NULL) |
3012 | 35 | g_byte_array_unref(st->buf); |
3013 | 35 | g_free(st); |
3014 | 35 | } |
3015 | | /** |
3016 | | * fu_struct_genesys_fw_codesign_info_ecdsa_new_internal: (skip): |
3017 | | **/ |
3018 | | static FuStructGenesysFwCodesignInfoEcdsa * |
3019 | | fu_struct_genesys_fw_codesign_info_ecdsa_new_internal(void) |
3020 | 35 | { |
3021 | 35 | FuStructGenesysFwCodesignInfoEcdsa *st = g_new0(FuStructGenesysFwCodesignInfoEcdsa, 1); |
3022 | 35 | st->refcount = 1; |
3023 | 35 | return st; |
3024 | 35 | } |
3025 | | |
3026 | | /* getters */ |
3027 | | /** |
3028 | | * fu_struct_genesys_fw_codesign_info_ecdsa_get_hash: (skip): |
3029 | | **/ |
3030 | | const guint8 * |
3031 | | fu_struct_genesys_fw_codesign_info_ecdsa_get_hash(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz) |
3032 | 0 | { |
3033 | 0 | g_return_val_if_fail(st != NULL, NULL); |
3034 | 0 | if (bufsz != NULL) |
3035 | 0 | *bufsz = 32; |
3036 | 0 | return st->buf->data + 0; |
3037 | 0 | } |
3038 | | /** |
3039 | | * fu_struct_genesys_fw_codesign_info_ecdsa_get_key: (skip): |
3040 | | **/ |
3041 | | const guint8 * |
3042 | | fu_struct_genesys_fw_codesign_info_ecdsa_get_key(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz) |
3043 | 0 | { |
3044 | 0 | g_return_val_if_fail(st != NULL, NULL); |
3045 | 0 | if (bufsz != NULL) |
3046 | 0 | *bufsz = 64; |
3047 | 0 | return st->buf->data + 32; |
3048 | 0 | } |
3049 | | /** |
3050 | | * fu_struct_genesys_fw_codesign_info_ecdsa_get_signature: (skip): |
3051 | | **/ |
3052 | | const guint8 * |
3053 | | fu_struct_genesys_fw_codesign_info_ecdsa_get_signature(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz) |
3054 | 0 | { |
3055 | 0 | g_return_val_if_fail(st != NULL, NULL); |
3056 | 0 | if (bufsz != NULL) |
3057 | 0 | *bufsz = 64; |
3058 | 0 | return st->buf->data + 96; |
3059 | 0 | } |
3060 | | |
3061 | | /* setters */ |
3062 | | /** |
3063 | | * fu_struct_genesys_fw_codesign_info_ecdsa_to_string: (skip): |
3064 | | **/ |
3065 | | static gchar * |
3066 | | fu_struct_genesys_fw_codesign_info_ecdsa_to_string(const FuStructGenesysFwCodesignInfoEcdsa *st) |
3067 | 0 | { |
3068 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysFwCodesignInfoEcdsa:\n"); |
3069 | 0 | g_return_val_if_fail(st != NULL, NULL); |
3070 | 0 | { |
3071 | 0 | gsize bufsz = 0; |
3072 | 0 | const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_hash(st, &bufsz); |
3073 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
3074 | 0 | for (gsize i = 0; i < bufsz; i++) |
3075 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
3076 | 0 | g_string_append_printf(str, " hash: 0x%s\n", tmp->str); |
3077 | 0 | } |
3078 | 0 | { |
3079 | 0 | gsize bufsz = 0; |
3080 | 0 | const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_key(st, &bufsz); |
3081 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
3082 | 0 | for (gsize i = 0; i < bufsz; i++) |
3083 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
3084 | 0 | g_string_append_printf(str, " key: 0x%s\n", tmp->str); |
3085 | 0 | } |
3086 | 0 | { |
3087 | 0 | gsize bufsz = 0; |
3088 | 0 | const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_signature(st, &bufsz); |
3089 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
3090 | 0 | for (gsize i = 0; i < bufsz; i++) |
3091 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
3092 | 0 | g_string_append_printf(str, " signature: 0x%s\n", tmp->str); |
3093 | 0 | } |
3094 | 0 | if (str->len > 0) |
3095 | 0 | g_string_set_size(str, str->len - 1); |
3096 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
3097 | 0 | } |
3098 | | static gboolean |
3099 | | fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(FuStructGenesysFwCodesignInfoEcdsa *st, GError **error) |
3100 | 35 | { |
3101 | 35 | g_return_val_if_fail(st != NULL, FALSE); |
3102 | 35 | return TRUE; |
3103 | 35 | } |
3104 | | /** |
3105 | | * fu_struct_genesys_fw_codesign_info_ecdsa_validate: (skip): |
3106 | | **/ |
3107 | | gboolean |
3108 | | fu_struct_genesys_fw_codesign_info_ecdsa_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
3109 | 0 | { |
3110 | 0 | GByteArray st_buf = {.data = (guint8 *) buf + offset, .len = bufsz - offset, }; |
3111 | 0 | FuStructGenesysFwCodesignInfoEcdsa st_tmp = {.buf = &st_buf }; |
3112 | 0 | g_return_val_if_fail(buf != NULL, FALSE); |
3113 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
3114 | 0 | if (!fu_memchk_read(bufsz, offset, 160, error)) { |
3115 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwCodesignInfoEcdsa: "); |
3116 | 0 | return FALSE; |
3117 | 0 | } |
3118 | 0 | if (!fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(&st_tmp, error)) |
3119 | 0 | return FALSE; |
3120 | 0 | return TRUE; |
3121 | 0 | } |
3122 | | /** |
3123 | | * fu_struct_genesys_fw_codesign_info_ecdsa_validate_stream: (skip): |
3124 | | **/ |
3125 | | gboolean |
3126 | | fu_struct_genesys_fw_codesign_info_ecdsa_validate_stream(GInputStream *stream, gsize offset, GError **error) |
3127 | 35 | { |
3128 | 35 | g_autoptr(FuStructGenesysFwCodesignInfoEcdsa) st = fu_struct_genesys_fw_codesign_info_ecdsa_new_internal(); |
3129 | 35 | g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE); |
3130 | 35 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
3131 | 35 | st->buf = fu_input_stream_read_byte_array(stream, offset, 160, NULL, error); |
3132 | 35 | if (st->buf == NULL) { |
3133 | 0 | g_prefix_error(error, "FuStructGenesysFwCodesignInfoEcdsa failed read of 0x%x: ", (guint) 160); |
3134 | 0 | return FALSE; |
3135 | 0 | } |
3136 | 35 | if (st->buf->len != 160) { |
3137 | 0 | g_set_error(error, |
3138 | 0 | FWUPD_ERROR, |
3139 | 0 | FWUPD_ERROR_INVALID_DATA, |
3140 | 0 | "FuStructGenesysFwCodesignInfoEcdsa requested 0x%x and got 0x%x", |
3141 | 0 | (guint) 160, |
3142 | 0 | (guint) st->buf->len); |
3143 | 0 | return FALSE; |
3144 | 0 | } |
3145 | 35 | return fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(st, error); |
3146 | 35 | } |
3147 | | static gboolean |
3148 | | fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(FuStructGenesysFwCodesignInfoEcdsa *st, GError **error) |
3149 | 0 | { |
3150 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
3151 | 0 | g_autofree gchar *str = fu_struct_genesys_fw_codesign_info_ecdsa_to_string(st); |
3152 | 0 | g_debug("%s", str); |
3153 | 0 | } |
3154 | 0 | if (!fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(st, error)) |
3155 | 0 | return FALSE; |
3156 | 0 | return TRUE; |
3157 | 0 | } |
3158 | | |
3159 | | /** |
3160 | | * fu_struct_genesys_fw_codesign_info_ecdsa_parse: (skip): |
3161 | | **/ |
3162 | | FuStructGenesysFwCodesignInfoEcdsa * |
3163 | | fu_struct_genesys_fw_codesign_info_ecdsa_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
3164 | 0 | { |
3165 | 0 | g_autoptr(FuStructGenesysFwCodesignInfoEcdsa) st = fu_struct_genesys_fw_codesign_info_ecdsa_new_internal(); |
3166 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
3167 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
3168 | 0 | if (!fu_memchk_read(bufsz, offset, 160, error)) { |
3169 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwCodesignInfoEcdsa: "); |
3170 | 0 | return NULL; |
3171 | 0 | } |
3172 | 0 | st->buf = g_byte_array_new(); |
3173 | 0 | g_byte_array_append(st->buf, buf + offset, 160); |
3174 | 0 | if (!fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(st, error)) |
3175 | 0 | return NULL; |
3176 | 0 | return g_steal_pointer(&st); |
3177 | 0 | } |
3178 | | /** |
3179 | | * fu_struct_genesys_fw_codesign_info_ecdsa_parse_stream: (skip): |
3180 | | **/ |
3181 | | FuStructGenesysFwCodesignInfoEcdsa * |
3182 | | fu_struct_genesys_fw_codesign_info_ecdsa_parse_stream(GInputStream *stream, gsize offset, GError **error) |
3183 | 0 | { |
3184 | 0 | g_autoptr(FuStructGenesysFwCodesignInfoEcdsa) st = fu_struct_genesys_fw_codesign_info_ecdsa_new_internal(); |
3185 | 0 | st->buf = fu_input_stream_read_byte_array(stream, offset, 160, NULL, error); |
3186 | 0 | if (st->buf == NULL) { |
3187 | 0 | g_prefix_error(error, "FuStructGenesysFwCodesignInfoEcdsa failed read of 0x%x: ", (guint) 160); |
3188 | 0 | return NULL; |
3189 | 0 | } |
3190 | 0 | if (st->buf->len != 160) { |
3191 | 0 | g_set_error(error, |
3192 | 0 | FWUPD_ERROR, |
3193 | 0 | FWUPD_ERROR_INVALID_DATA, |
3194 | 0 | "FuStructGenesysFwCodesignInfoEcdsa requested 0x%x and got 0x%x", |
3195 | 0 | (guint) 160, |
3196 | 0 | (guint) st->buf->len); |
3197 | 0 | return NULL; |
3198 | 0 | } |
3199 | 0 | if (!fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(st, error)) |
3200 | 0 | return NULL; |
3201 | 0 | return g_steal_pointer(&st); |
3202 | 0 | } |
3203 | | /** |
3204 | | * fu_struct_genesys_fw_ecdsa_public_key_ref: (skip): |
3205 | | **/ |
3206 | | FuStructGenesysFwEcdsaPublicKey * |
3207 | | fu_struct_genesys_fw_ecdsa_public_key_ref(FuStructGenesysFwEcdsaPublicKey *st) |
3208 | 0 | { |
3209 | 0 | g_return_val_if_fail(st != NULL, NULL); |
3210 | 0 | st->refcount++; |
3211 | 0 | return st; |
3212 | 0 | } |
3213 | | /** |
3214 | | * fu_struct_genesys_fw_ecdsa_public_key_unref: (skip): |
3215 | | **/ |
3216 | | void |
3217 | | fu_struct_genesys_fw_ecdsa_public_key_unref(FuStructGenesysFwEcdsaPublicKey *st) |
3218 | 0 | { |
3219 | 0 | g_return_if_fail(st != NULL); |
3220 | 0 | if (st->refcount == 0) { |
3221 | 0 | g_critical("FuStructGenesysFwEcdsaPublicKey refcount already zero"); |
3222 | 0 | return; |
3223 | 0 | } |
3224 | 0 | if (--st->refcount > 0) |
3225 | 0 | return; |
3226 | 0 | if (st->buf != NULL) |
3227 | 0 | g_byte_array_unref(st->buf); |
3228 | 0 | g_free(st); |
3229 | 0 | } |
3230 | | /** |
3231 | | * fu_struct_genesys_fw_ecdsa_public_key_new_internal: (skip): |
3232 | | **/ |
3233 | | static FuStructGenesysFwEcdsaPublicKey * |
3234 | | fu_struct_genesys_fw_ecdsa_public_key_new_internal(void) |
3235 | 0 | { |
3236 | 0 | FuStructGenesysFwEcdsaPublicKey *st = g_new0(FuStructGenesysFwEcdsaPublicKey, 1); |
3237 | 0 | st->refcount = 1; |
3238 | 0 | return st; |
3239 | 0 | } |
3240 | | |
3241 | | /* getters */ |
3242 | | /** |
3243 | | * fu_struct_genesys_fw_ecdsa_public_key_get_key: (skip): |
3244 | | **/ |
3245 | | const guint8 * |
3246 | | fu_struct_genesys_fw_ecdsa_public_key_get_key(const FuStructGenesysFwEcdsaPublicKey *st, gsize *bufsz) |
3247 | 0 | { |
3248 | 0 | g_return_val_if_fail(st != NULL, NULL); |
3249 | 0 | if (bufsz != NULL) |
3250 | 0 | *bufsz = 64; |
3251 | 0 | return st->buf->data + 0; |
3252 | 0 | } |
3253 | | |
3254 | | /* setters */ |
3255 | | /** |
3256 | | * fu_struct_genesys_fw_ecdsa_public_key_to_string: (skip): |
3257 | | **/ |
3258 | | static gchar * |
3259 | | fu_struct_genesys_fw_ecdsa_public_key_to_string(const FuStructGenesysFwEcdsaPublicKey *st) |
3260 | 0 | { |
3261 | 0 | g_autoptr(GString) str = g_string_new("FuStructGenesysFwEcdsaPublicKey:\n"); |
3262 | 0 | g_return_val_if_fail(st != NULL, NULL); |
3263 | 0 | { |
3264 | 0 | gsize bufsz = 0; |
3265 | 0 | const guint8 *buf = fu_struct_genesys_fw_ecdsa_public_key_get_key(st, &bufsz); |
3266 | 0 | g_autoptr(GString) tmp = g_string_new(NULL); |
3267 | 0 | for (gsize i = 0; i < bufsz; i++) |
3268 | 0 | g_string_append_printf(tmp, "%02X", buf[i]); |
3269 | 0 | g_string_append_printf(str, " key: 0x%s\n", tmp->str); |
3270 | 0 | } |
3271 | 0 | if (str->len > 0) |
3272 | 0 | g_string_set_size(str, str->len - 1); |
3273 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
3274 | 0 | } |
3275 | | static gboolean |
3276 | | fu_struct_genesys_fw_ecdsa_public_key_validate_internal(FuStructGenesysFwEcdsaPublicKey *st, GError **error) |
3277 | 0 | { |
3278 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
3279 | 0 | return TRUE; |
3280 | 0 | } |
3281 | | /** |
3282 | | * fu_struct_genesys_fw_ecdsa_public_key_validate: (skip): |
3283 | | **/ |
3284 | | gboolean |
3285 | | fu_struct_genesys_fw_ecdsa_public_key_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
3286 | 0 | { |
3287 | 0 | GByteArray st_buf = {.data = (guint8 *) buf + offset, .len = bufsz - offset, }; |
3288 | 0 | FuStructGenesysFwEcdsaPublicKey st_tmp = {.buf = &st_buf }; |
3289 | 0 | g_return_val_if_fail(buf != NULL, FALSE); |
3290 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, FALSE); |
3291 | 0 | if (!fu_memchk_read(bufsz, offset, 64, error)) { |
3292 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwEcdsaPublicKey: "); |
3293 | 0 | return FALSE; |
3294 | 0 | } |
3295 | 0 | if (!fu_struct_genesys_fw_ecdsa_public_key_validate_internal(&st_tmp, error)) |
3296 | 0 | return FALSE; |
3297 | 0 | return TRUE; |
3298 | 0 | } |
3299 | | static gboolean |
3300 | | fu_struct_genesys_fw_ecdsa_public_key_parse_internal(FuStructGenesysFwEcdsaPublicKey *st, GError **error) |
3301 | 0 | { |
3302 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
3303 | 0 | g_autofree gchar *str = fu_struct_genesys_fw_ecdsa_public_key_to_string(st); |
3304 | 0 | g_debug("%s", str); |
3305 | 0 | } |
3306 | 0 | if (!fu_struct_genesys_fw_ecdsa_public_key_validate_internal(st, error)) |
3307 | 0 | return FALSE; |
3308 | 0 | return TRUE; |
3309 | 0 | } |
3310 | | |
3311 | | /** |
3312 | | * fu_struct_genesys_fw_ecdsa_public_key_parse: (skip): |
3313 | | **/ |
3314 | | FuStructGenesysFwEcdsaPublicKey * |
3315 | | fu_struct_genesys_fw_ecdsa_public_key_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error) |
3316 | 0 | { |
3317 | 0 | g_autoptr(FuStructGenesysFwEcdsaPublicKey) st = fu_struct_genesys_fw_ecdsa_public_key_new_internal(); |
3318 | 0 | g_return_val_if_fail(buf != NULL, NULL); |
3319 | 0 | g_return_val_if_fail(error == NULL || *error == NULL, NULL); |
3320 | 0 | if (!fu_memchk_read(bufsz, offset, 64, error)) { |
3321 | 0 | g_prefix_error_literal(error, "invalid struct FuStructGenesysFwEcdsaPublicKey: "); |
3322 | 0 | return NULL; |
3323 | 0 | } |
3324 | 0 | st->buf = g_byte_array_new(); |
3325 | 0 | g_byte_array_append(st->buf, buf + offset, 64); |
3326 | 0 | if (!fu_struct_genesys_fw_ecdsa_public_key_parse_internal(st, error)) |
3327 | 0 | return NULL; |
3328 | 0 | return g_steal_pointer(&st); |
3329 | 0 | } |