Coverage Report

Created: 2026-02-26 06:27

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