Coverage Report

Created: 2026-12-01 06:28

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