Coverage Report

Created: 2026-06-15 06:54

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
25.3k
{
151
25.3k
    if (val == FU_GENESYS_FW_TYPE_HUB)
152
792
        return "hub";
153
24.5k
    if (val == FU_GENESYS_FW_TYPE_DEV_BRIDGE)
154
14.1k
        return "dev-bridge";
155
10.3k
    if (val == FU_GENESYS_FW_TYPE_PD)
156
10.3k
        return "pd";
157
44
    if (val == FU_GENESYS_FW_TYPE_CODESIGN)
158
44
        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
922
{
181
922
    g_return_if_fail(st != NULL);
182
922
    if (st->refcount == 0) {
183
0
        g_critical("FuStructGenesysFirmwareHdr refcount already zero");
184
0
        return;
185
0
    }
186
922
    if (--st->refcount > 0)
187
0
        return;
188
922
    if (st->buf != NULL)
189
922
        g_byte_array_unref(st->buf);
190
922
    g_free(st);
191
922
}
192
/**
193
 * fu_struct_genesys_firmware_hdr_new_internal: (skip):
194
 **/
195
static FuStructGenesysFirmwareHdr *
196
fu_struct_genesys_firmware_hdr_new_internal(void)
197
922
{
198
922
    FuStructGenesysFirmwareHdr *st = g_new0(FuStructGenesysFirmwareHdr, 1);
199
922
    st->refcount = 1;
200
922
    return st;
201
922
}
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
45
{
210
45
    g_return_val_if_fail(st != NULL, NULL);
211
45
    return fu_memstrsafe(st->buf->data, st->buf->len, 252, 4, NULL);
212
45
}
213
214
/* setters */
215
static gboolean
216
fu_struct_genesys_firmware_hdr_validate_internal(FuStructGenesysFirmwareHdr *st, GError **error)
217
893
{
218
893
    g_return_val_if_fail(st != NULL, FALSE);
219
893
    if (strncmp((const gchar *) (st->buf->data + 252), "XROM", 4) != 0) {
220
45
        g_autofree gchar *str = fu_struct_genesys_firmware_hdr_get_magic(st);
221
45
        g_set_error(error,
222
45
                    FWUPD_ERROR,
223
45
                    FWUPD_ERROR_INVALID_DATA,
224
45
                    "constant FuStructGenesysFirmwareHdr.magic was not valid, "
225
45
                    "expected 'XROM' and got '%s'",
226
45
                    str);
227
45
        return FALSE;
228
45
    }
229
848
    return TRUE;
230
893
}
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
922
{
237
922
    g_autoptr(FuStructGenesysFirmwareHdr) st = fu_struct_genesys_firmware_hdr_new_internal();
238
922
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
239
922
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
240
922
    st->buf = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error);
241
922
    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
922
    if (st->buf->len != 256) {
246
29
        g_set_error(error,
247
29
                    FWUPD_ERROR,
248
29
                    FWUPD_ERROR_INVALID_DATA,
249
29
                    "FuStructGenesysFirmwareHdr requested 0x%x and got 0x%x",
250
29
                    (guint) 256,
251
29
                    (guint) st->buf->len);
252
29
        return FALSE;
253
29
    }
254
893
    return fu_struct_genesys_firmware_hdr_validate_internal(st, error);
255
922
}
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
24.9k
{
272
24.9k
    g_return_if_fail(st != NULL);
273
24.9k
    if (st->refcount == 0) {
274
0
        g_critical("FuStructGenesysDevFirmwareHdr refcount already zero");
275
0
        return;
276
0
    }
277
24.9k
    if (--st->refcount > 0)
278
0
        return;
279
24.9k
    if (st->buf != NULL)
280
24.9k
        g_byte_array_unref(st->buf);
281
24.9k
    g_free(st);
282
24.9k
}
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
24.9k
{
289
24.9k
    FuStructGenesysDevFirmwareHdr *st = g_new0(FuStructGenesysDevFirmwareHdr, 1);
290
24.9k
    st->refcount = 1;
291
24.9k
    return st;
292
24.9k
}
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
10.5k
{
301
10.5k
    g_return_val_if_fail(st != NULL, NULL);
302
10.5k
    return fu_memstrsafe(st->buf->data, st->buf->len, 252, 4, NULL);
303
10.5k
}
304
305
/* setters */
306
static gboolean
307
fu_struct_genesys_dev_firmware_hdr_validate_internal(FuStructGenesysDevFirmwareHdr *st, GError **error)
308
24.7k
{
309
24.7k
    g_return_val_if_fail(st != NULL, FALSE);
310
24.7k
    if (strncmp((const gchar *) (st->buf->data + 252), "HOST", 4) != 0) {
311
10.5k
        g_autofree gchar *str = fu_struct_genesys_dev_firmware_hdr_get_magic(st);
312
10.5k
        g_set_error(error,
313
10.5k
                    FWUPD_ERROR,
314
10.5k
                    FWUPD_ERROR_INVALID_DATA,
315
10.5k
                    "constant FuStructGenesysDevFirmwareHdr.magic was not valid, "
316
10.5k
                    "expected 'HOST' and got '%s'",
317
10.5k
                    str);
318
10.5k
        return FALSE;
319
10.5k
    }
320
14.1k
    return TRUE;
321
24.7k
}
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
24.9k
{
328
24.9k
    g_autoptr(FuStructGenesysDevFirmwareHdr) st = fu_struct_genesys_dev_firmware_hdr_new_internal();
329
24.9k
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
330
24.9k
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
331
24.9k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error);
332
24.9k
    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
24.9k
    if (st->buf->len != 256) {
337
169
        g_set_error(error,
338
169
                    FWUPD_ERROR,
339
169
                    FWUPD_ERROR_INVALID_DATA,
340
169
                    "FuStructGenesysDevFirmwareHdr requested 0x%x and got 0x%x",
341
169
                    (guint) 256,
342
169
                    (guint) st->buf->len);
343
169
        return FALSE;
344
169
    }
345
24.7k
    return fu_struct_genesys_dev_firmware_hdr_validate_internal(st, error);
346
24.9k
}
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
10.8k
{
363
10.8k
    g_return_if_fail(st != NULL);
364
10.8k
    if (st->refcount == 0) {
365
0
        g_critical("FuStructGenesysPdFirmwareHdr refcount already zero");
366
0
        return;
367
0
    }
368
10.8k
    if (--st->refcount > 0)
369
0
        return;
370
10.8k
    if (st->buf != NULL)
371
10.8k
        g_byte_array_unref(st->buf);
372
10.8k
    g_free(st);
373
10.8k
}
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
10.8k
{
380
10.8k
    FuStructGenesysPdFirmwareHdr *st = g_new0(FuStructGenesysPdFirmwareHdr, 1);
381
10.8k
    st->refcount = 1;
382
10.8k
    return st;
383
10.8k
}
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
309
{
392
309
    g_return_val_if_fail(st != NULL, NULL);
393
309
    return fu_memstrsafe(st->buf->data, st->buf->len, 252, 4, NULL);
394
309
}
395
396
/* setters */
397
static gboolean
398
fu_struct_genesys_pd_firmware_hdr_validate_internal(FuStructGenesysPdFirmwareHdr *st, GError **error)
399
10.6k
{
400
10.6k
    g_return_val_if_fail(st != NULL, FALSE);
401
10.6k
    if (strncmp((const gchar *) (st->buf->data + 252), "PRDY", 4) != 0) {
402
309
        g_autofree gchar *str = fu_struct_genesys_pd_firmware_hdr_get_magic(st);
403
309
        g_set_error(error,
404
309
                    FWUPD_ERROR,
405
309
                    FWUPD_ERROR_INVALID_DATA,
406
309
                    "constant FuStructGenesysPdFirmwareHdr.magic was not valid, "
407
309
                    "expected 'PRDY' and got '%s'",
408
309
                    str);
409
309
        return FALSE;
410
309
    }
411
10.3k
    return TRUE;
412
10.6k
}
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
10.8k
{
419
10.8k
    g_autoptr(FuStructGenesysPdFirmwareHdr) st = fu_struct_genesys_pd_firmware_hdr_new_internal();
420
10.8k
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
421
10.8k
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
422
10.8k
    st->buf = fu_input_stream_read_byte_array(stream, offset, 256, NULL, error);
423
10.8k
    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
10.8k
    if (st->buf->len != 256) {
428
169
        g_set_error(error,
429
169
                    FWUPD_ERROR,
430
169
                    FWUPD_ERROR_INVALID_DATA,
431
169
                    "FuStructGenesysPdFirmwareHdr requested 0x%x and got 0x%x",
432
169
                    (guint) 256,
433
169
                    (guint) st->buf->len);
434
169
        return FALSE;
435
169
    }
436
10.6k
    return fu_struct_genesys_pd_firmware_hdr_validate_internal(st, error);
437
10.8k
}
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
792
{
454
792
    g_return_if_fail(st != NULL);
455
792
    if (st->refcount == 0) {
456
0
        g_critical("FuStructGenesysTsStatic refcount already zero");
457
0
        return;
458
0
    }
459
792
    if (--st->refcount > 0)
460
0
        return;
461
792
    if (st->buf != NULL)
462
792
        g_byte_array_unref(st->buf);
463
792
    g_free(st);
464
792
}
465
/**
466
 * fu_struct_genesys_ts_static_new_internal: (skip):
467
 **/
468
static FuStructGenesysTsStatic *
469
fu_struct_genesys_ts_static_new_internal(void)
470
792
{
471
792
    FuStructGenesysTsStatic *st = g_new0(FuStructGenesysTsStatic, 1);
472
792
    st->refcount = 1;
473
792
    return st;
474
792
}
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_parse_internal(FuStructGenesysTsStatic *st, GError **error)
872
773
{
873
773
    if (g_log_get_debug_enabled()) {
874
0
        g_autofree gchar *str = fu_struct_genesys_ts_static_to_string(st);
875
0
        g_debug("%s", str);
876
0
    }
877
773
    return TRUE;
878
773
}
879
880
/**
881
 * fu_struct_genesys_ts_static_parse: (skip):
882
 **/
883
FuStructGenesysTsStatic *
884
fu_struct_genesys_ts_static_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
885
0
{
886
0
    g_autoptr(FuStructGenesysTsStatic) st = fu_struct_genesys_ts_static_new_internal();
887
0
    g_return_val_if_fail(buf != NULL, NULL);
888
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
889
0
    if (!fu_memchk_read(bufsz, offset, 31, error)) {
890
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysTsStatic: ");
891
0
        return NULL;
892
0
    }
893
0
    st->buf = g_byte_array_new();
894
0
    g_byte_array_append(st->buf, buf + offset, 31);
895
0
    if (!fu_struct_genesys_ts_static_parse_internal(st, error))
896
0
        return NULL;
897
0
    return g_steal_pointer(&st);
898
0
}
899
/**
900
 * fu_struct_genesys_ts_static_parse_stream: (skip):
901
 **/
902
FuStructGenesysTsStatic *
903
fu_struct_genesys_ts_static_parse_stream(GInputStream *stream, gsize offset, GError **error)
904
792
{
905
792
    g_autoptr(FuStructGenesysTsStatic) st = fu_struct_genesys_ts_static_new_internal();
906
792
    st->buf = fu_input_stream_read_byte_array(stream, offset, 31, NULL, error);
907
792
    if (st->buf == NULL) {
908
0
        g_prefix_error(error, "FuStructGenesysTsStatic failed read of 0x%x: ", (guint) 31);
909
0
        return NULL;
910
0
    }
911
792
    if (st->buf->len != 31) {
912
19
        g_set_error(error,
913
19
                    FWUPD_ERROR,
914
19
                    FWUPD_ERROR_INVALID_DATA,
915
19
                    "FuStructGenesysTsStatic requested 0x%x and got 0x%x",
916
19
                    (guint) 31,
917
19
                    (guint) st->buf->len);
918
19
        return NULL;
919
19
    }
920
773
    if (!fu_struct_genesys_ts_static_parse_internal(st, error))
921
0
        return NULL;
922
773
    return g_steal_pointer(&st);
923
773
}
924
/**
925
 * fu_struct_genesys_ts_dynamic_gl3523_ref: (skip):
926
 **/
927
FuStructGenesysTsDynamicGl3523 *
928
fu_struct_genesys_ts_dynamic_gl3523_ref(FuStructGenesysTsDynamicGl3523 *st)
929
0
{
930
0
    g_return_val_if_fail(st != NULL, NULL);
931
0
    st->refcount++;
932
0
    return st;
933
0
}
934
/**
935
 * fu_struct_genesys_ts_dynamic_gl3523_unref: (skip):
936
 **/
937
void
938
fu_struct_genesys_ts_dynamic_gl3523_unref(FuStructGenesysTsDynamicGl3523 *st)
939
0
{
940
0
    g_return_if_fail(st != NULL);
941
0
    if (st->refcount == 0) {
942
0
        g_critical("FuStructGenesysTsDynamicGl3523 refcount already zero");
943
0
        return;
944
0
    }
945
0
    if (--st->refcount > 0)
946
0
        return;
947
0
    if (st->buf != NULL)
948
0
        g_byte_array_unref(st->buf);
949
0
    g_free(st);
950
0
}
951
/**
952
 * fu_struct_genesys_ts_dynamic_gl3523_new_internal: (skip):
953
 **/
954
static FuStructGenesysTsDynamicGl3523 *
955
fu_struct_genesys_ts_dynamic_gl3523_new_internal(void)
956
0
{
957
0
    FuStructGenesysTsDynamicGl3523 *st = g_new0(FuStructGenesysTsDynamicGl3523, 1);
958
0
    st->refcount = 1;
959
0
    return st;
960
0
}
961
962
/* getters */
963
/**
964
 * fu_struct_genesys_ts_dynamic_gl3523_get_running_mode: (skip):
965
 **/
966
gchar *
967
fu_struct_genesys_ts_dynamic_gl3523_get_running_mode(const FuStructGenesysTsDynamicGl3523 *st)
968
0
{
969
0
    g_return_val_if_fail(st != NULL, NULL);
970
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL);
971
0
}
972
/**
973
 * fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number: (skip):
974
 **/
975
gchar *
976
fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number(const FuStructGenesysTsDynamicGl3523 *st)
977
0
{
978
0
    g_return_val_if_fail(st != NULL, NULL);
979
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL);
980
0
}
981
/**
982
 * fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number: (skip):
983
 **/
984
gchar *
985
fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number(const FuStructGenesysTsDynamicGl3523 *st)
986
0
{
987
0
    g_return_val_if_fail(st != NULL, NULL);
988
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL);
989
0
}
990
/**
991
 * fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status: (skip):
992
 **/
993
gchar *
994
fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status(const FuStructGenesysTsDynamicGl3523 *st)
995
0
{
996
0
    g_return_val_if_fail(st != NULL, NULL);
997
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL);
998
0
}
999
/**
1000
 * fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status: (skip):
1001
 **/
1002
gchar *
1003
fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status(const FuStructGenesysTsDynamicGl3523 *st)
1004
0
{
1005
0
    g_return_val_if_fail(st != NULL, NULL);
1006
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL);
1007
0
}
1008
/**
1009
 * fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status: (skip):
1010
 **/
1011
gchar *
1012
fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status(const FuStructGenesysTsDynamicGl3523 *st)
1013
0
{
1014
0
    g_return_val_if_fail(st != NULL, NULL);
1015
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL);
1016
0
}
1017
/**
1018
 * fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status: (skip):
1019
 **/
1020
gchar *
1021
fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status(const FuStructGenesysTsDynamicGl3523 *st)
1022
0
{
1023
0
    g_return_val_if_fail(st != NULL, NULL);
1024
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL);
1025
0
}
1026
/**
1027
 * fu_struct_genesys_ts_dynamic_gl3523_get_charging: (skip):
1028
 **/
1029
gchar *
1030
fu_struct_genesys_ts_dynamic_gl3523_get_charging(const FuStructGenesysTsDynamicGl3523 *st)
1031
0
{
1032
0
    g_return_val_if_fail(st != NULL, NULL);
1033
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL);
1034
0
}
1035
/**
1036
 * fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status: (skip):
1037
 **/
1038
gchar *
1039
fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3523 *st)
1040
0
{
1041
0
    g_return_val_if_fail(st != NULL, NULL);
1042
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL);
1043
0
}
1044
/**
1045
 * fu_struct_genesys_ts_dynamic_gl3523_get_bonding: (skip):
1046
 **/
1047
gchar *
1048
fu_struct_genesys_ts_dynamic_gl3523_get_bonding(const FuStructGenesysTsDynamicGl3523 *st)
1049
0
{
1050
0
    g_return_val_if_fail(st != NULL, NULL);
1051
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 9, 1, NULL);
1052
0
}
1053
1054
/* setters */
1055
/**
1056
 * fu_struct_genesys_ts_dynamic_gl3523_to_string: (skip):
1057
 **/
1058
static gchar *
1059
fu_struct_genesys_ts_dynamic_gl3523_to_string(const FuStructGenesysTsDynamicGl3523 *st)
1060
0
{
1061
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3523:\n");
1062
0
    g_return_val_if_fail(st != NULL, NULL);
1063
0
    {
1064
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_running_mode(st);
1065
0
        if (tmp != NULL)
1066
0
            g_string_append_printf(str, "  running_mode: %s\n", tmp);
1067
0
    }
1068
0
    {
1069
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ss_port_number(st);
1070
0
        if (tmp != NULL)
1071
0
            g_string_append_printf(str, "  ss_port_number: %s\n", tmp);
1072
0
    }
1073
0
    {
1074
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_hs_port_number(st);
1075
0
        if (tmp != NULL)
1076
0
            g_string_append_printf(str, "  hs_port_number: %s\n", tmp);
1077
0
    }
1078
0
    {
1079
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ss_connection_status(st);
1080
0
        if (tmp != NULL)
1081
0
            g_string_append_printf(str, "  ss_connection_status: %s\n", tmp);
1082
0
    }
1083
0
    {
1084
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_hs_connection_status(st);
1085
0
        if (tmp != NULL)
1086
0
            g_string_append_printf(str, "  hs_connection_status: %s\n", tmp);
1087
0
    }
1088
0
    {
1089
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_fs_connection_status(st);
1090
0
        if (tmp != NULL)
1091
0
            g_string_append_printf(str, "  fs_connection_status: %s\n", tmp);
1092
0
    }
1093
0
    {
1094
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_ls_connection_status(st);
1095
0
        if (tmp != NULL)
1096
0
            g_string_append_printf(str, "  ls_connection_status: %s\n", tmp);
1097
0
    }
1098
0
    {
1099
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_charging(st);
1100
0
        if (tmp != NULL)
1101
0
            g_string_append_printf(str, "  charging: %s\n", tmp);
1102
0
    }
1103
0
    {
1104
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_non_removable_port_status(st);
1105
0
        if (tmp != NULL)
1106
0
            g_string_append_printf(str, "  non_removable_port_status: %s\n", tmp);
1107
0
    }
1108
0
    {
1109
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3523_get_bonding(st);
1110
0
        if (tmp != NULL)
1111
0
            g_string_append_printf(str, "  bonding: %s\n", tmp);
1112
0
    }
1113
0
    if (str->len > 0)
1114
0
        g_string_set_size(str, str->len - 1);
1115
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1116
0
}
1117
static gboolean
1118
fu_struct_genesys_ts_dynamic_gl3523_parse_internal(FuStructGenesysTsDynamicGl3523 *st, GError **error)
1119
0
{
1120
0
    if (g_log_get_debug_enabled()) {
1121
0
        g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3523_to_string(st);
1122
0
        g_debug("%s", str);
1123
0
    }
1124
0
    return TRUE;
1125
0
}
1126
1127
/**
1128
 * fu_struct_genesys_ts_dynamic_gl3523_parse: (skip):
1129
 **/
1130
FuStructGenesysTsDynamicGl3523 *
1131
fu_struct_genesys_ts_dynamic_gl3523_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
1132
0
{
1133
0
    g_autoptr(FuStructGenesysTsDynamicGl3523) st = fu_struct_genesys_ts_dynamic_gl3523_new_internal();
1134
0
    g_return_val_if_fail(buf != NULL, NULL);
1135
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
1136
0
    if (!fu_memchk_read(bufsz, offset, 10, error)) {
1137
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl3523: ");
1138
0
        return NULL;
1139
0
    }
1140
0
    st->buf = g_byte_array_new();
1141
0
    g_byte_array_append(st->buf, buf + offset, 10);
1142
0
    if (!fu_struct_genesys_ts_dynamic_gl3523_parse_internal(st, error))
1143
0
        return NULL;
1144
0
    return g_steal_pointer(&st);
1145
0
}
1146
/**
1147
 * fu_struct_genesys_ts_dynamic_gl3590_ref: (skip):
1148
 **/
1149
FuStructGenesysTsDynamicGl3590 *
1150
fu_struct_genesys_ts_dynamic_gl3590_ref(FuStructGenesysTsDynamicGl3590 *st)
1151
0
{
1152
0
    g_return_val_if_fail(st != NULL, NULL);
1153
0
    st->refcount++;
1154
0
    return st;
1155
0
}
1156
/**
1157
 * fu_struct_genesys_ts_dynamic_gl3590_unref: (skip):
1158
 **/
1159
void
1160
fu_struct_genesys_ts_dynamic_gl3590_unref(FuStructGenesysTsDynamicGl3590 *st)
1161
0
{
1162
0
    g_return_if_fail(st != NULL);
1163
0
    if (st->refcount == 0) {
1164
0
        g_critical("FuStructGenesysTsDynamicGl3590 refcount already zero");
1165
0
        return;
1166
0
    }
1167
0
    if (--st->refcount > 0)
1168
0
        return;
1169
0
    if (st->buf != NULL)
1170
0
        g_byte_array_unref(st->buf);
1171
0
    g_free(st);
1172
0
}
1173
/**
1174
 * fu_struct_genesys_ts_dynamic_gl3590_new_internal: (skip):
1175
 **/
1176
static FuStructGenesysTsDynamicGl3590 *
1177
fu_struct_genesys_ts_dynamic_gl3590_new_internal(void)
1178
0
{
1179
0
    FuStructGenesysTsDynamicGl3590 *st = g_new0(FuStructGenesysTsDynamicGl3590, 1);
1180
0
    st->refcount = 1;
1181
0
    return st;
1182
0
}
1183
1184
/* getters */
1185
/**
1186
 * fu_struct_genesys_ts_dynamic_gl3590_get_running_mode: (skip):
1187
 **/
1188
gchar *
1189
fu_struct_genesys_ts_dynamic_gl3590_get_running_mode(const FuStructGenesysTsDynamicGl3590 *st)
1190
0
{
1191
0
    g_return_val_if_fail(st != NULL, NULL);
1192
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL);
1193
0
}
1194
/**
1195
 * fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number: (skip):
1196
 **/
1197
gchar *
1198
fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number(const FuStructGenesysTsDynamicGl3590 *st)
1199
0
{
1200
0
    g_return_val_if_fail(st != NULL, NULL);
1201
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL);
1202
0
}
1203
/**
1204
 * fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number: (skip):
1205
 **/
1206
gchar *
1207
fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number(const FuStructGenesysTsDynamicGl3590 *st)
1208
0
{
1209
0
    g_return_val_if_fail(st != NULL, NULL);
1210
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL);
1211
0
}
1212
/**
1213
 * fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status: (skip):
1214
 **/
1215
gchar *
1216
fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status(const FuStructGenesysTsDynamicGl3590 *st)
1217
0
{
1218
0
    g_return_val_if_fail(st != NULL, NULL);
1219
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL);
1220
0
}
1221
/**
1222
 * fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status: (skip):
1223
 **/
1224
gchar *
1225
fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status(const FuStructGenesysTsDynamicGl3590 *st)
1226
0
{
1227
0
    g_return_val_if_fail(st != NULL, NULL);
1228
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL);
1229
0
}
1230
/**
1231
 * fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status: (skip):
1232
 **/
1233
gchar *
1234
fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status(const FuStructGenesysTsDynamicGl3590 *st)
1235
0
{
1236
0
    g_return_val_if_fail(st != NULL, NULL);
1237
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL);
1238
0
}
1239
/**
1240
 * fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status: (skip):
1241
 **/
1242
gchar *
1243
fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status(const FuStructGenesysTsDynamicGl3590 *st)
1244
0
{
1245
0
    g_return_val_if_fail(st != NULL, NULL);
1246
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL);
1247
0
}
1248
/**
1249
 * fu_struct_genesys_ts_dynamic_gl3590_get_charging: (skip):
1250
 **/
1251
gchar *
1252
fu_struct_genesys_ts_dynamic_gl3590_get_charging(const FuStructGenesysTsDynamicGl3590 *st)
1253
0
{
1254
0
    g_return_val_if_fail(st != NULL, NULL);
1255
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL);
1256
0
}
1257
/**
1258
 * fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status: (skip):
1259
 **/
1260
gchar *
1261
fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3590 *st)
1262
0
{
1263
0
    g_return_val_if_fail(st != NULL, NULL);
1264
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL);
1265
0
}
1266
/**
1267
 * fu_struct_genesys_ts_dynamic_gl3590_get_bonding: (skip):
1268
 **/
1269
guint8
1270
fu_struct_genesys_ts_dynamic_gl3590_get_bonding(const FuStructGenesysTsDynamicGl3590 *st)
1271
0
{
1272
0
    g_return_val_if_fail(st != NULL, 0x0);
1273
0
    return st->buf->data[9];
1274
0
}
1275
1276
/* setters */
1277
/**
1278
 * fu_struct_genesys_ts_dynamic_gl3590_to_string: (skip):
1279
 **/
1280
static gchar *
1281
fu_struct_genesys_ts_dynamic_gl3590_to_string(const FuStructGenesysTsDynamicGl3590 *st)
1282
0
{
1283
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3590:\n");
1284
0
    g_return_val_if_fail(st != NULL, NULL);
1285
0
    {
1286
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_running_mode(st);
1287
0
        if (tmp != NULL)
1288
0
            g_string_append_printf(str, "  running_mode: %s\n", tmp);
1289
0
    }
1290
0
    {
1291
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ss_port_number(st);
1292
0
        if (tmp != NULL)
1293
0
            g_string_append_printf(str, "  ss_port_number: %s\n", tmp);
1294
0
    }
1295
0
    {
1296
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_hs_port_number(st);
1297
0
        if (tmp != NULL)
1298
0
            g_string_append_printf(str, "  hs_port_number: %s\n", tmp);
1299
0
    }
1300
0
    {
1301
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ss_connection_status(st);
1302
0
        if (tmp != NULL)
1303
0
            g_string_append_printf(str, "  ss_connection_status: %s\n", tmp);
1304
0
    }
1305
0
    {
1306
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_hs_connection_status(st);
1307
0
        if (tmp != NULL)
1308
0
            g_string_append_printf(str, "  hs_connection_status: %s\n", tmp);
1309
0
    }
1310
0
    {
1311
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_fs_connection_status(st);
1312
0
        if (tmp != NULL)
1313
0
            g_string_append_printf(str, "  fs_connection_status: %s\n", tmp);
1314
0
    }
1315
0
    {
1316
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_ls_connection_status(st);
1317
0
        if (tmp != NULL)
1318
0
            g_string_append_printf(str, "  ls_connection_status: %s\n", tmp);
1319
0
    }
1320
0
    {
1321
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_charging(st);
1322
0
        if (tmp != NULL)
1323
0
            g_string_append_printf(str, "  charging: %s\n", tmp);
1324
0
    }
1325
0
    {
1326
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3590_get_non_removable_port_status(st);
1327
0
        if (tmp != NULL)
1328
0
            g_string_append_printf(str, "  non_removable_port_status: %s\n", tmp);
1329
0
    }
1330
0
    g_string_append_printf(str, "  bonding: 0x%x\n",
1331
0
                           (guint) fu_struct_genesys_ts_dynamic_gl3590_get_bonding(st));
1332
0
    if (str->len > 0)
1333
0
        g_string_set_size(str, str->len - 1);
1334
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1335
0
}
1336
static gboolean
1337
fu_struct_genesys_ts_dynamic_gl3590_parse_internal(FuStructGenesysTsDynamicGl3590 *st, GError **error)
1338
0
{
1339
0
    if (g_log_get_debug_enabled()) {
1340
0
        g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3590_to_string(st);
1341
0
        g_debug("%s", str);
1342
0
    }
1343
0
    return TRUE;
1344
0
}
1345
1346
/**
1347
 * fu_struct_genesys_ts_dynamic_gl3590_parse: (skip):
1348
 **/
1349
FuStructGenesysTsDynamicGl3590 *
1350
fu_struct_genesys_ts_dynamic_gl3590_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
1351
0
{
1352
0
    g_autoptr(FuStructGenesysTsDynamicGl3590) st = fu_struct_genesys_ts_dynamic_gl3590_new_internal();
1353
0
    g_return_val_if_fail(buf != NULL, NULL);
1354
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
1355
0
    if (!fu_memchk_read(bufsz, offset, 10, error)) {
1356
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl3590: ");
1357
0
        return NULL;
1358
0
    }
1359
0
    st->buf = g_byte_array_new();
1360
0
    g_byte_array_append(st->buf, buf + offset, 10);
1361
0
    if (!fu_struct_genesys_ts_dynamic_gl3590_parse_internal(st, error))
1362
0
        return NULL;
1363
0
    return g_steal_pointer(&st);
1364
0
}
1365
/**
1366
 * fu_struct_genesys_ts_dynamic_gl359030_ref: (skip):
1367
 **/
1368
FuStructGenesysTsDynamicGl359030 *
1369
fu_struct_genesys_ts_dynamic_gl359030_ref(FuStructGenesysTsDynamicGl359030 *st)
1370
0
{
1371
0
    g_return_val_if_fail(st != NULL, NULL);
1372
0
    st->refcount++;
1373
0
    return st;
1374
0
}
1375
/**
1376
 * fu_struct_genesys_ts_dynamic_gl359030_unref: (skip):
1377
 **/
1378
void
1379
fu_struct_genesys_ts_dynamic_gl359030_unref(FuStructGenesysTsDynamicGl359030 *st)
1380
0
{
1381
0
    g_return_if_fail(st != NULL);
1382
0
    if (st->refcount == 0) {
1383
0
        g_critical("FuStructGenesysTsDynamicGl359030 refcount already zero");
1384
0
        return;
1385
0
    }
1386
0
    if (--st->refcount > 0)
1387
0
        return;
1388
0
    if (st->buf != NULL)
1389
0
        g_byte_array_unref(st->buf);
1390
0
    g_free(st);
1391
0
}
1392
/**
1393
 * fu_struct_genesys_ts_dynamic_gl359030_new_internal: (skip):
1394
 **/
1395
static FuStructGenesysTsDynamicGl359030 *
1396
fu_struct_genesys_ts_dynamic_gl359030_new_internal(void)
1397
0
{
1398
0
    FuStructGenesysTsDynamicGl359030 *st = g_new0(FuStructGenesysTsDynamicGl359030, 1);
1399
0
    st->refcount = 1;
1400
0
    return st;
1401
0
}
1402
1403
/* getters */
1404
/**
1405
 * fu_struct_genesys_ts_dynamic_gl359030_get_running_mode: (skip):
1406
 **/
1407
gchar *
1408
fu_struct_genesys_ts_dynamic_gl359030_get_running_mode(const FuStructGenesysTsDynamicGl359030 *st)
1409
0
{
1410
0
    g_return_val_if_fail(st != NULL, NULL);
1411
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL);
1412
0
}
1413
/**
1414
 * fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number: (skip):
1415
 **/
1416
gchar *
1417
fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number(const FuStructGenesysTsDynamicGl359030 *st)
1418
0
{
1419
0
    g_return_val_if_fail(st != NULL, NULL);
1420
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL);
1421
0
}
1422
/**
1423
 * fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number: (skip):
1424
 **/
1425
gchar *
1426
fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number(const FuStructGenesysTsDynamicGl359030 *st)
1427
0
{
1428
0
    g_return_val_if_fail(st != NULL, NULL);
1429
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL);
1430
0
}
1431
/**
1432
 * fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status: (skip):
1433
 **/
1434
gchar *
1435
fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status(const FuStructGenesysTsDynamicGl359030 *st)
1436
0
{
1437
0
    g_return_val_if_fail(st != NULL, NULL);
1438
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL);
1439
0
}
1440
/**
1441
 * fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status: (skip):
1442
 **/
1443
gchar *
1444
fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status(const FuStructGenesysTsDynamicGl359030 *st)
1445
0
{
1446
0
    g_return_val_if_fail(st != NULL, NULL);
1447
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL);
1448
0
}
1449
/**
1450
 * fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status: (skip):
1451
 **/
1452
gchar *
1453
fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status(const FuStructGenesysTsDynamicGl359030 *st)
1454
0
{
1455
0
    g_return_val_if_fail(st != NULL, NULL);
1456
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL);
1457
0
}
1458
/**
1459
 * fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status: (skip):
1460
 **/
1461
gchar *
1462
fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status(const FuStructGenesysTsDynamicGl359030 *st)
1463
0
{
1464
0
    g_return_val_if_fail(st != NULL, NULL);
1465
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL);
1466
0
}
1467
/**
1468
 * fu_struct_genesys_ts_dynamic_gl359030_get_charging: (skip):
1469
 **/
1470
gchar *
1471
fu_struct_genesys_ts_dynamic_gl359030_get_charging(const FuStructGenesysTsDynamicGl359030 *st)
1472
0
{
1473
0
    g_return_val_if_fail(st != NULL, NULL);
1474
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL);
1475
0
}
1476
/**
1477
 * fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status: (skip):
1478
 **/
1479
gchar *
1480
fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status(const FuStructGenesysTsDynamicGl359030 *st)
1481
0
{
1482
0
    g_return_val_if_fail(st != NULL, NULL);
1483
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL);
1484
0
}
1485
/**
1486
 * fu_struct_genesys_ts_dynamic_gl359030_get_bonding: (skip):
1487
 **/
1488
guint8
1489
fu_struct_genesys_ts_dynamic_gl359030_get_bonding(const FuStructGenesysTsDynamicGl359030 *st)
1490
0
{
1491
0
    g_return_val_if_fail(st != NULL, 0x0);
1492
0
    return st->buf->data[9];
1493
0
}
1494
/**
1495
 * fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status: (skip):
1496
 **/
1497
FuGenesysFwStatus
1498
fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(const FuStructGenesysTsDynamicGl359030 *st)
1499
0
{
1500
0
    g_return_val_if_fail(st != NULL, 0x0);
1501
0
    return st->buf->data[10];
1502
0
}
1503
/**
1504
 * fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status: (skip):
1505
 **/
1506
FuGenesysFwStatus
1507
fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(const FuStructGenesysTsDynamicGl359030 *st)
1508
0
{
1509
0
    g_return_val_if_fail(st != NULL, 0x0);
1510
0
    return st->buf->data[11];
1511
0
}
1512
/**
1513
 * fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version: (skip):
1514
 **/
1515
guint16
1516
fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version(const FuStructGenesysTsDynamicGl359030 *st)
1517
0
{
1518
0
    g_return_val_if_fail(st != NULL, 0x0);
1519
0
    return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN);
1520
0
}
1521
1522
/* setters */
1523
/**
1524
 * fu_struct_genesys_ts_dynamic_gl359030_to_string: (skip):
1525
 **/
1526
static gchar *
1527
fu_struct_genesys_ts_dynamic_gl359030_to_string(const FuStructGenesysTsDynamicGl359030 *st)
1528
0
{
1529
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl359030:\n");
1530
0
    g_return_val_if_fail(st != NULL, NULL);
1531
0
    {
1532
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_running_mode(st);
1533
0
        if (tmp != NULL)
1534
0
            g_string_append_printf(str, "  running_mode: %s\n", tmp);
1535
0
    }
1536
0
    {
1537
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ss_port_number(st);
1538
0
        if (tmp != NULL)
1539
0
            g_string_append_printf(str, "  ss_port_number: %s\n", tmp);
1540
0
    }
1541
0
    {
1542
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_hs_port_number(st);
1543
0
        if (tmp != NULL)
1544
0
            g_string_append_printf(str, "  hs_port_number: %s\n", tmp);
1545
0
    }
1546
0
    {
1547
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ss_connection_status(st);
1548
0
        if (tmp != NULL)
1549
0
            g_string_append_printf(str, "  ss_connection_status: %s\n", tmp);
1550
0
    }
1551
0
    {
1552
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_hs_connection_status(st);
1553
0
        if (tmp != NULL)
1554
0
            g_string_append_printf(str, "  hs_connection_status: %s\n", tmp);
1555
0
    }
1556
0
    {
1557
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_fs_connection_status(st);
1558
0
        if (tmp != NULL)
1559
0
            g_string_append_printf(str, "  fs_connection_status: %s\n", tmp);
1560
0
    }
1561
0
    {
1562
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_ls_connection_status(st);
1563
0
        if (tmp != NULL)
1564
0
            g_string_append_printf(str, "  ls_connection_status: %s\n", tmp);
1565
0
    }
1566
0
    {
1567
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_charging(st);
1568
0
        if (tmp != NULL)
1569
0
            g_string_append_printf(str, "  charging: %s\n", tmp);
1570
0
    }
1571
0
    {
1572
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl359030_get_non_removable_port_status(st);
1573
0
        if (tmp != NULL)
1574
0
            g_string_append_printf(str, "  non_removable_port_status: %s\n", tmp);
1575
0
    }
1576
0
    g_string_append_printf(str, "  bonding: 0x%x\n",
1577
0
                           (guint) fu_struct_genesys_ts_dynamic_gl359030_get_bonding(st));
1578
0
    {
1579
0
        const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(st));
1580
0
        if (tmp != NULL) {
1581
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);
1582
0
        } else {
1583
0
            g_string_append_printf(str, "  hub_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_hub_fw_status(st));
1584
0
        }
1585
0
    }
1586
0
    {
1587
0
        const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(st));
1588
0
        if (tmp != NULL) {
1589
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);
1590
0
        } else {
1591
0
            g_string_append_printf(str, "  dev_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_status(st));
1592
0
        }
1593
0
    }
1594
0
    g_string_append_printf(str, "  dev_fw_version: 0x%x\n",
1595
0
                           (guint) fu_struct_genesys_ts_dynamic_gl359030_get_dev_fw_version(st));
1596
0
    if (str->len > 0)
1597
0
        g_string_set_size(str, str->len - 1);
1598
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1599
0
}
1600
static gboolean
1601
fu_struct_genesys_ts_dynamic_gl359030_parse_internal(FuStructGenesysTsDynamicGl359030 *st, GError **error)
1602
0
{
1603
0
    if (g_log_get_debug_enabled()) {
1604
0
        g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl359030_to_string(st);
1605
0
        g_debug("%s", str);
1606
0
    }
1607
0
    return TRUE;
1608
0
}
1609
1610
/**
1611
 * fu_struct_genesys_ts_dynamic_gl359030_parse: (skip):
1612
 **/
1613
FuStructGenesysTsDynamicGl359030 *
1614
fu_struct_genesys_ts_dynamic_gl359030_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
1615
0
{
1616
0
    g_autoptr(FuStructGenesysTsDynamicGl359030) st = fu_struct_genesys_ts_dynamic_gl359030_new_internal();
1617
0
    g_return_val_if_fail(buf != NULL, NULL);
1618
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
1619
0
    if (!fu_memchk_read(bufsz, offset, 14, error)) {
1620
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl359030: ");
1621
0
        return NULL;
1622
0
    }
1623
0
    st->buf = g_byte_array_new();
1624
0
    g_byte_array_append(st->buf, buf + offset, 14);
1625
0
    if (!fu_struct_genesys_ts_dynamic_gl359030_parse_internal(st, error))
1626
0
        return NULL;
1627
0
    return g_steal_pointer(&st);
1628
0
}
1629
/**
1630
 * fu_struct_genesys_ts_dynamic_gl3525_ref: (skip):
1631
 **/
1632
FuStructGenesysTsDynamicGl3525 *
1633
fu_struct_genesys_ts_dynamic_gl3525_ref(FuStructGenesysTsDynamicGl3525 *st)
1634
0
{
1635
0
    g_return_val_if_fail(st != NULL, NULL);
1636
0
    st->refcount++;
1637
0
    return st;
1638
0
}
1639
/**
1640
 * fu_struct_genesys_ts_dynamic_gl3525_unref: (skip):
1641
 **/
1642
void
1643
fu_struct_genesys_ts_dynamic_gl3525_unref(FuStructGenesysTsDynamicGl3525 *st)
1644
0
{
1645
0
    g_return_if_fail(st != NULL);
1646
0
    if (st->refcount == 0) {
1647
0
        g_critical("FuStructGenesysTsDynamicGl3525 refcount already zero");
1648
0
        return;
1649
0
    }
1650
0
    if (--st->refcount > 0)
1651
0
        return;
1652
0
    if (st->buf != NULL)
1653
0
        g_byte_array_unref(st->buf);
1654
0
    g_free(st);
1655
0
}
1656
/**
1657
 * fu_struct_genesys_ts_dynamic_gl3525_new_internal: (skip):
1658
 **/
1659
static FuStructGenesysTsDynamicGl3525 *
1660
fu_struct_genesys_ts_dynamic_gl3525_new_internal(void)
1661
0
{
1662
0
    FuStructGenesysTsDynamicGl3525 *st = g_new0(FuStructGenesysTsDynamicGl3525, 1);
1663
0
    st->refcount = 1;
1664
0
    return st;
1665
0
}
1666
1667
/* getters */
1668
/**
1669
 * fu_struct_genesys_ts_dynamic_gl3525_get_running_mode: (skip):
1670
 **/
1671
gchar *
1672
fu_struct_genesys_ts_dynamic_gl3525_get_running_mode(const FuStructGenesysTsDynamicGl3525 *st)
1673
0
{
1674
0
    g_return_val_if_fail(st != NULL, NULL);
1675
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 0, 1, NULL);
1676
0
}
1677
/**
1678
 * fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number: (skip):
1679
 **/
1680
gchar *
1681
fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number(const FuStructGenesysTsDynamicGl3525 *st)
1682
0
{
1683
0
    g_return_val_if_fail(st != NULL, NULL);
1684
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 1, 1, NULL);
1685
0
}
1686
/**
1687
 * fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number: (skip):
1688
 **/
1689
gchar *
1690
fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number(const FuStructGenesysTsDynamicGl3525 *st)
1691
0
{
1692
0
    g_return_val_if_fail(st != NULL, NULL);
1693
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 2, 1, NULL);
1694
0
}
1695
/**
1696
 * fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status: (skip):
1697
 **/
1698
gchar *
1699
fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status(const FuStructGenesysTsDynamicGl3525 *st)
1700
0
{
1701
0
    g_return_val_if_fail(st != NULL, NULL);
1702
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 3, 1, NULL);
1703
0
}
1704
/**
1705
 * fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status: (skip):
1706
 **/
1707
gchar *
1708
fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status(const FuStructGenesysTsDynamicGl3525 *st)
1709
0
{
1710
0
    g_return_val_if_fail(st != NULL, NULL);
1711
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 4, 1, NULL);
1712
0
}
1713
/**
1714
 * fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status: (skip):
1715
 **/
1716
gchar *
1717
fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status(const FuStructGenesysTsDynamicGl3525 *st)
1718
0
{
1719
0
    g_return_val_if_fail(st != NULL, NULL);
1720
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 5, 1, NULL);
1721
0
}
1722
/**
1723
 * fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status: (skip):
1724
 **/
1725
gchar *
1726
fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status(const FuStructGenesysTsDynamicGl3525 *st)
1727
0
{
1728
0
    g_return_val_if_fail(st != NULL, NULL);
1729
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 6, 1, NULL);
1730
0
}
1731
/**
1732
 * fu_struct_genesys_ts_dynamic_gl3525_get_charging: (skip):
1733
 **/
1734
gchar *
1735
fu_struct_genesys_ts_dynamic_gl3525_get_charging(const FuStructGenesysTsDynamicGl3525 *st)
1736
0
{
1737
0
    g_return_val_if_fail(st != NULL, NULL);
1738
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 7, 1, NULL);
1739
0
}
1740
/**
1741
 * fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status: (skip):
1742
 **/
1743
gchar *
1744
fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status(const FuStructGenesysTsDynamicGl3525 *st)
1745
0
{
1746
0
    g_return_val_if_fail(st != NULL, NULL);
1747
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 8, 1, NULL);
1748
0
}
1749
/**
1750
 * fu_struct_genesys_ts_dynamic_gl3525_get_bonding: (skip):
1751
 **/
1752
guint8
1753
fu_struct_genesys_ts_dynamic_gl3525_get_bonding(const FuStructGenesysTsDynamicGl3525 *st)
1754
0
{
1755
0
    g_return_val_if_fail(st != NULL, 0x0);
1756
0
    return st->buf->data[9];
1757
0
}
1758
/**
1759
 * fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status: (skip):
1760
 **/
1761
FuGenesysFwStatus
1762
fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(const FuStructGenesysTsDynamicGl3525 *st)
1763
0
{
1764
0
    g_return_val_if_fail(st != NULL, 0x0);
1765
0
    return st->buf->data[10];
1766
0
}
1767
/**
1768
 * fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status: (skip):
1769
 **/
1770
FuGenesysFwStatus
1771
fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(const FuStructGenesysTsDynamicGl3525 *st)
1772
0
{
1773
0
    g_return_val_if_fail(st != NULL, 0x0);
1774
0
    return st->buf->data[11];
1775
0
}
1776
/**
1777
 * fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version: (skip):
1778
 **/
1779
guint16
1780
fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version(const FuStructGenesysTsDynamicGl3525 *st)
1781
0
{
1782
0
    g_return_val_if_fail(st != NULL, 0x0);
1783
0
    return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN);
1784
0
}
1785
/**
1786
 * fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status: (skip):
1787
 **/
1788
FuGenesysFwStatus
1789
fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(const FuStructGenesysTsDynamicGl3525 *st)
1790
0
{
1791
0
    g_return_val_if_fail(st != NULL, 0x0);
1792
0
    return st->buf->data[14];
1793
0
}
1794
/**
1795
 * fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version: (skip):
1796
 **/
1797
guint16
1798
fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version(const FuStructGenesysTsDynamicGl3525 *st)
1799
0
{
1800
0
    g_return_val_if_fail(st != NULL, 0x0);
1801
0
    return fu_memread_uint16(st->buf->data + 15, G_LITTLE_ENDIAN);
1802
0
}
1803
1804
/* setters */
1805
/**
1806
 * fu_struct_genesys_ts_dynamic_gl3525_to_string: (skip):
1807
 **/
1808
static gchar *
1809
fu_struct_genesys_ts_dynamic_gl3525_to_string(const FuStructGenesysTsDynamicGl3525 *st)
1810
0
{
1811
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsDynamicGl3525:\n");
1812
0
    g_return_val_if_fail(st != NULL, NULL);
1813
0
    {
1814
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_running_mode(st);
1815
0
        if (tmp != NULL)
1816
0
            g_string_append_printf(str, "  running_mode: %s\n", tmp);
1817
0
    }
1818
0
    {
1819
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ss_port_number(st);
1820
0
        if (tmp != NULL)
1821
0
            g_string_append_printf(str, "  ss_port_number: %s\n", tmp);
1822
0
    }
1823
0
    {
1824
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_hs_port_number(st);
1825
0
        if (tmp != NULL)
1826
0
            g_string_append_printf(str, "  hs_port_number: %s\n", tmp);
1827
0
    }
1828
0
    {
1829
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ss_connection_status(st);
1830
0
        if (tmp != NULL)
1831
0
            g_string_append_printf(str, "  ss_connection_status: %s\n", tmp);
1832
0
    }
1833
0
    {
1834
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_hs_connection_status(st);
1835
0
        if (tmp != NULL)
1836
0
            g_string_append_printf(str, "  hs_connection_status: %s\n", tmp);
1837
0
    }
1838
0
    {
1839
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_fs_connection_status(st);
1840
0
        if (tmp != NULL)
1841
0
            g_string_append_printf(str, "  fs_connection_status: %s\n", tmp);
1842
0
    }
1843
0
    {
1844
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_ls_connection_status(st);
1845
0
        if (tmp != NULL)
1846
0
            g_string_append_printf(str, "  ls_connection_status: %s\n", tmp);
1847
0
    }
1848
0
    {
1849
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_charging(st);
1850
0
        if (tmp != NULL)
1851
0
            g_string_append_printf(str, "  charging: %s\n", tmp);
1852
0
    }
1853
0
    {
1854
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_dynamic_gl3525_get_non_removable_port_status(st);
1855
0
        if (tmp != NULL)
1856
0
            g_string_append_printf(str, "  non_removable_port_status: %s\n", tmp);
1857
0
    }
1858
0
    g_string_append_printf(str, "  bonding: 0x%x\n",
1859
0
                           (guint) fu_struct_genesys_ts_dynamic_gl3525_get_bonding(st));
1860
0
    {
1861
0
        const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(st));
1862
0
        if (tmp != NULL) {
1863
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);
1864
0
        } else {
1865
0
            g_string_append_printf(str, "  hub_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_hub_fw_status(st));
1866
0
        }
1867
0
    }
1868
0
    {
1869
0
        const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(st));
1870
0
        if (tmp != NULL) {
1871
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);
1872
0
        } else {
1873
0
            g_string_append_printf(str, "  pd_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_status(st));
1874
0
        }
1875
0
    }
1876
0
    g_string_append_printf(str, "  pd_fw_version: 0x%x\n",
1877
0
                           (guint) fu_struct_genesys_ts_dynamic_gl3525_get_pd_fw_version(st));
1878
0
    {
1879
0
        const gchar *tmp = fu_genesys_fw_status_to_string(fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(st));
1880
0
        if (tmp != NULL) {
1881
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);
1882
0
        } else {
1883
0
            g_string_append_printf(str, "  dev_fw_status: 0x%x\n", (guint) fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_status(st));
1884
0
        }
1885
0
    }
1886
0
    g_string_append_printf(str, "  dev_fw_version: 0x%x\n",
1887
0
                           (guint) fu_struct_genesys_ts_dynamic_gl3525_get_dev_fw_version(st));
1888
0
    if (str->len > 0)
1889
0
        g_string_set_size(str, str->len - 1);
1890
0
    return g_string_free(g_steal_pointer(&str), FALSE);
1891
0
}
1892
static gboolean
1893
fu_struct_genesys_ts_dynamic_gl3525_parse_internal(FuStructGenesysTsDynamicGl3525 *st, GError **error)
1894
0
{
1895
0
    if (g_log_get_debug_enabled()) {
1896
0
        g_autofree gchar *str = fu_struct_genesys_ts_dynamic_gl3525_to_string(st);
1897
0
        g_debug("%s", str);
1898
0
    }
1899
0
    return TRUE;
1900
0
}
1901
1902
/**
1903
 * fu_struct_genesys_ts_dynamic_gl3525_parse: (skip):
1904
 **/
1905
FuStructGenesysTsDynamicGl3525 *
1906
fu_struct_genesys_ts_dynamic_gl3525_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
1907
0
{
1908
0
    g_autoptr(FuStructGenesysTsDynamicGl3525) st = fu_struct_genesys_ts_dynamic_gl3525_new_internal();
1909
0
    g_return_val_if_fail(buf != NULL, NULL);
1910
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
1911
0
    if (!fu_memchk_read(bufsz, offset, 17, error)) {
1912
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysTsDynamicGl3525: ");
1913
0
        return NULL;
1914
0
    }
1915
0
    st->buf = g_byte_array_new();
1916
0
    g_byte_array_append(st->buf, buf + offset, 17);
1917
0
    if (!fu_struct_genesys_ts_dynamic_gl3525_parse_internal(st, error))
1918
0
        return NULL;
1919
0
    return g_steal_pointer(&st);
1920
0
}
1921
/**
1922
 * fu_struct_genesys_ts_firmware_info_ref: (skip):
1923
 **/
1924
FuStructGenesysTsFirmwareInfo *
1925
fu_struct_genesys_ts_firmware_info_ref(FuStructGenesysTsFirmwareInfo *st)
1926
0
{
1927
0
    g_return_val_if_fail(st != NULL, NULL);
1928
0
    st->refcount++;
1929
0
    return st;
1930
0
}
1931
/**
1932
 * fu_struct_genesys_ts_firmware_info_unref: (skip):
1933
 **/
1934
void
1935
fu_struct_genesys_ts_firmware_info_unref(FuStructGenesysTsFirmwareInfo *st)
1936
0
{
1937
0
    g_return_if_fail(st != NULL);
1938
0
    if (st->refcount == 0) {
1939
0
        g_critical("FuStructGenesysTsFirmwareInfo refcount already zero");
1940
0
        return;
1941
0
    }
1942
0
    if (--st->refcount > 0)
1943
0
        return;
1944
0
    if (st->buf != NULL)
1945
0
        g_byte_array_unref(st->buf);
1946
0
    g_free(st);
1947
0
}
1948
/**
1949
 * fu_struct_genesys_ts_firmware_info_new_internal: (skip):
1950
 **/
1951
static FuStructGenesysTsFirmwareInfo *
1952
fu_struct_genesys_ts_firmware_info_new_internal(void)
1953
0
{
1954
0
    FuStructGenesysTsFirmwareInfo *st = g_new0(FuStructGenesysTsFirmwareInfo, 1);
1955
0
    st->refcount = 1;
1956
0
    return st;
1957
0
}
1958
1959
/* getters */
1960
/**
1961
 * fu_struct_genesys_ts_firmware_info_get_tool_version: (skip):
1962
 **/
1963
const guint8 *
1964
fu_struct_genesys_ts_firmware_info_get_tool_version(const FuStructGenesysTsFirmwareInfo *st, gsize *bufsz)
1965
0
{
1966
0
    g_return_val_if_fail(st != NULL, NULL);
1967
0
    if (bufsz != NULL)
1968
0
        *bufsz = 6;
1969
0
    return st->buf->data + 0;
1970
0
}
1971
/**
1972
 * fu_struct_genesys_ts_firmware_info_get_address_mode: (skip):
1973
 **/
1974
guint8
1975
fu_struct_genesys_ts_firmware_info_get_address_mode(const FuStructGenesysTsFirmwareInfo *st)
1976
0
{
1977
0
    g_return_val_if_fail(st != NULL, 0x0);
1978
0
    return st->buf->data[6];
1979
0
}
1980
/**
1981
 * fu_struct_genesys_ts_firmware_info_get_build_fw_time: (skip):
1982
 **/
1983
gchar *
1984
fu_struct_genesys_ts_firmware_info_get_build_fw_time(const FuStructGenesysTsFirmwareInfo *st)
1985
0
{
1986
0
    g_return_val_if_fail(st != NULL, NULL);
1987
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 7, 12, NULL);
1988
0
}
1989
/**
1990
 * fu_struct_genesys_ts_firmware_info_get_update_fw_time: (skip):
1991
 **/
1992
gchar *
1993
fu_struct_genesys_ts_firmware_info_get_update_fw_time(const FuStructGenesysTsFirmwareInfo *st)
1994
0
{
1995
0
    g_return_val_if_fail(st != NULL, NULL);
1996
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 19, 12, NULL);
1997
0
}
1998
1999
/* setters */
2000
/**
2001
 * fu_struct_genesys_ts_firmware_info_to_string: (skip):
2002
 **/
2003
static gchar *
2004
fu_struct_genesys_ts_firmware_info_to_string(const FuStructGenesysTsFirmwareInfo *st)
2005
0
{
2006
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsFirmwareInfo:\n");
2007
0
    g_return_val_if_fail(st != NULL, NULL);
2008
0
    {
2009
0
        gsize bufsz = 0;
2010
0
        const guint8 *buf = fu_struct_genesys_ts_firmware_info_get_tool_version(st, &bufsz);
2011
0
        g_autoptr(GString) tmp = g_string_new(NULL);
2012
0
        for (gsize i = 0; i < bufsz; i++)
2013
0
            g_string_append_printf(tmp, "%02X", buf[i]);
2014
0
        g_string_append_printf(str, "  tool_version: 0x%s\n", tmp->str);
2015
0
    }
2016
0
    g_string_append_printf(str, "  address_mode: 0x%x\n",
2017
0
                           (guint) fu_struct_genesys_ts_firmware_info_get_address_mode(st));
2018
0
    {
2019
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_firmware_info_get_build_fw_time(st);
2020
0
        if (tmp != NULL)
2021
0
            g_string_append_printf(str, "  build_fw_time: %s\n", tmp);
2022
0
    }
2023
0
    {
2024
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_firmware_info_get_update_fw_time(st);
2025
0
        if (tmp != NULL)
2026
0
            g_string_append_printf(str, "  update_fw_time: %s\n", tmp);
2027
0
    }
2028
0
    if (str->len > 0)
2029
0
        g_string_set_size(str, str->len - 1);
2030
0
    return g_string_free(g_steal_pointer(&str), FALSE);
2031
0
}
2032
static gboolean
2033
fu_struct_genesys_ts_firmware_info_parse_internal(FuStructGenesysTsFirmwareInfo *st, GError **error)
2034
0
{
2035
0
    if (g_log_get_debug_enabled()) {
2036
0
        g_autofree gchar *str = fu_struct_genesys_ts_firmware_info_to_string(st);
2037
0
        g_debug("%s", str);
2038
0
    }
2039
0
    return TRUE;
2040
0
}
2041
2042
/**
2043
 * fu_struct_genesys_ts_firmware_info_parse: (skip):
2044
 **/
2045
FuStructGenesysTsFirmwareInfo *
2046
fu_struct_genesys_ts_firmware_info_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
2047
0
{
2048
0
    g_autoptr(FuStructGenesysTsFirmwareInfo) st = fu_struct_genesys_ts_firmware_info_new_internal();
2049
0
    g_return_val_if_fail(buf != NULL, NULL);
2050
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
2051
0
    if (!fu_memchk_read(bufsz, offset, 31, error)) {
2052
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysTsFirmwareInfo: ");
2053
0
        return NULL;
2054
0
    }
2055
0
    st->buf = g_byte_array_new();
2056
0
    g_byte_array_append(st->buf, buf + offset, 31);
2057
0
    if (!fu_struct_genesys_ts_firmware_info_parse_internal(st, error))
2058
0
        return NULL;
2059
0
    return g_steal_pointer(&st);
2060
0
}
2061
/**
2062
 * fu_struct_genesys_ts_vendor_support_ref: (skip):
2063
 **/
2064
FuStructGenesysTsVendorSupport *
2065
fu_struct_genesys_ts_vendor_support_ref(FuStructGenesysTsVendorSupport *st)
2066
0
{
2067
0
    g_return_val_if_fail(st != NULL, NULL);
2068
0
    st->refcount++;
2069
0
    return st;
2070
0
}
2071
/**
2072
 * fu_struct_genesys_ts_vendor_support_unref: (skip):
2073
 **/
2074
void
2075
fu_struct_genesys_ts_vendor_support_unref(FuStructGenesysTsVendorSupport *st)
2076
0
{
2077
0
    g_return_if_fail(st != NULL);
2078
0
    if (st->refcount == 0) {
2079
0
        g_critical("FuStructGenesysTsVendorSupport refcount already zero");
2080
0
        return;
2081
0
    }
2082
0
    if (--st->refcount > 0)
2083
0
        return;
2084
0
    if (st->buf != NULL)
2085
0
        g_byte_array_unref(st->buf);
2086
0
    g_free(st);
2087
0
}
2088
/**
2089
 * fu_struct_genesys_ts_vendor_support_new_internal: (skip):
2090
 **/
2091
static FuStructGenesysTsVendorSupport *
2092
fu_struct_genesys_ts_vendor_support_new_internal(void)
2093
0
{
2094
0
    FuStructGenesysTsVendorSupport *st = g_new0(FuStructGenesysTsVendorSupport, 1);
2095
0
    st->refcount = 1;
2096
0
    return st;
2097
0
}
2098
2099
/* getters */
2100
/**
2101
 * fu_struct_genesys_ts_vendor_support_get_version: (skip):
2102
 **/
2103
gchar *
2104
fu_struct_genesys_ts_vendor_support_get_version(const FuStructGenesysTsVendorSupport *st)
2105
0
{
2106
0
    g_return_val_if_fail(st != NULL, NULL);
2107
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 0, 2, NULL);
2108
0
}
2109
/**
2110
 * fu_struct_genesys_ts_vendor_support_get_reserved1: (skip):
2111
 **/
2112
gchar *
2113
fu_struct_genesys_ts_vendor_support_get_reserved1(const FuStructGenesysTsVendorSupport *st)
2114
0
{
2115
0
    g_return_val_if_fail(st != NULL, NULL);
2116
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 2, 8, NULL);
2117
0
}
2118
/**
2119
 * fu_struct_genesys_ts_vendor_support_get_codesign_check: (skip):
2120
 **/
2121
FuGenesysVsCodesignCheck
2122
fu_struct_genesys_ts_vendor_support_get_codesign_check(const FuStructGenesysTsVendorSupport *st)
2123
0
{
2124
0
    g_return_val_if_fail(st != NULL, 0x0);
2125
0
    return st->buf->data[10];
2126
0
}
2127
/**
2128
 * fu_struct_genesys_ts_vendor_support_get_reserved2: (skip):
2129
 **/
2130
gchar *
2131
fu_struct_genesys_ts_vendor_support_get_reserved2(const FuStructGenesysTsVendorSupport *st)
2132
0
{
2133
0
    g_return_val_if_fail(st != NULL, NULL);
2134
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 11, 4, NULL);
2135
0
}
2136
/**
2137
 * fu_struct_genesys_ts_vendor_support_get_hid_isp: (skip):
2138
 **/
2139
FuGenesysVsHidIsp
2140
fu_struct_genesys_ts_vendor_support_get_hid_isp(const FuStructGenesysTsVendorSupport *st)
2141
0
{
2142
0
    g_return_val_if_fail(st != NULL, 0x0);
2143
0
    return st->buf->data[15];
2144
0
}
2145
/**
2146
 * fu_struct_genesys_ts_vendor_support_get_reserved3: (skip):
2147
 **/
2148
gchar *
2149
fu_struct_genesys_ts_vendor_support_get_reserved3(const FuStructGenesysTsVendorSupport *st)
2150
0
{
2151
0
    g_return_val_if_fail(st != NULL, NULL);
2152
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 16, 15, NULL);
2153
0
}
2154
2155
/* setters */
2156
/**
2157
 * fu_struct_genesys_ts_vendor_support_set_version: (skip):
2158
 **/
2159
gboolean
2160
fu_struct_genesys_ts_vendor_support_set_version(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error)
2161
0
{
2162
0
    gsize len;
2163
0
    g_return_val_if_fail(st != NULL, FALSE);
2164
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
2165
0
    if (value == NULL) {
2166
0
        memset(st->buf->data + 0, 0x0, 2);
2167
0
        return TRUE;
2168
0
    }
2169
0
    len = strlen(value);
2170
0
    if (len > 2) {
2171
0
        g_set_error(error,
2172
0
                    FWUPD_ERROR,
2173
0
                    FWUPD_ERROR_INVALID_DATA,
2174
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.version (0x%x bytes)",
2175
0
                    value, (guint) len, (guint) 2);
2176
0
        return FALSE;
2177
0
    }
2178
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 0, (const guint8 *)value, len, 0x0, len, error);
2179
0
}
2180
/**
2181
 * fu_struct_genesys_ts_vendor_support_set_reserved1: (skip):
2182
 **/
2183
gboolean
2184
fu_struct_genesys_ts_vendor_support_set_reserved1(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error)
2185
0
{
2186
0
    gsize len;
2187
0
    g_return_val_if_fail(st != NULL, FALSE);
2188
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
2189
0
    if (value == NULL) {
2190
0
        memset(st->buf->data + 2, 0x0, 8);
2191
0
        return TRUE;
2192
0
    }
2193
0
    len = strlen(value);
2194
0
    if (len > 8) {
2195
0
        g_set_error(error,
2196
0
                    FWUPD_ERROR,
2197
0
                    FWUPD_ERROR_INVALID_DATA,
2198
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved1 (0x%x bytes)",
2199
0
                    value, (guint) len, (guint) 8);
2200
0
        return FALSE;
2201
0
    }
2202
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 2, (const guint8 *)value, len, 0x0, len, error);
2203
0
}
2204
/**
2205
 * fu_struct_genesys_ts_vendor_support_set_codesign_check: (skip):
2206
 **/
2207
void
2208
fu_struct_genesys_ts_vendor_support_set_codesign_check(FuStructGenesysTsVendorSupport *st, FuGenesysVsCodesignCheck value)
2209
0
{
2210
0
    g_return_if_fail(st != NULL);
2211
0
    st->buf->data[10] = value;
2212
0
}
2213
/**
2214
 * fu_struct_genesys_ts_vendor_support_set_reserved2: (skip):
2215
 **/
2216
gboolean
2217
fu_struct_genesys_ts_vendor_support_set_reserved2(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error)
2218
0
{
2219
0
    gsize len;
2220
0
    g_return_val_if_fail(st != NULL, FALSE);
2221
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
2222
0
    if (value == NULL) {
2223
0
        memset(st->buf->data + 11, 0x0, 4);
2224
0
        return TRUE;
2225
0
    }
2226
0
    len = strlen(value);
2227
0
    if (len > 4) {
2228
0
        g_set_error(error,
2229
0
                    FWUPD_ERROR,
2230
0
                    FWUPD_ERROR_INVALID_DATA,
2231
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved2 (0x%x bytes)",
2232
0
                    value, (guint) len, (guint) 4);
2233
0
        return FALSE;
2234
0
    }
2235
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 11, (const guint8 *)value, len, 0x0, len, error);
2236
0
}
2237
/**
2238
 * fu_struct_genesys_ts_vendor_support_set_hid_isp: (skip):
2239
 **/
2240
void
2241
fu_struct_genesys_ts_vendor_support_set_hid_isp(FuStructGenesysTsVendorSupport *st, FuGenesysVsHidIsp value)
2242
0
{
2243
0
    g_return_if_fail(st != NULL);
2244
0
    st->buf->data[15] = value;
2245
0
}
2246
/**
2247
 * fu_struct_genesys_ts_vendor_support_set_reserved3: (skip):
2248
 **/
2249
gboolean
2250
fu_struct_genesys_ts_vendor_support_set_reserved3(FuStructGenesysTsVendorSupport *st, const gchar *value, GError **error)
2251
0
{
2252
0
    gsize len;
2253
0
    g_return_val_if_fail(st != NULL, FALSE);
2254
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
2255
0
    if (value == NULL) {
2256
0
        memset(st->buf->data + 16, 0x0, 15);
2257
0
        return TRUE;
2258
0
    }
2259
0
    len = strlen(value);
2260
0
    if (len > 15) {
2261
0
        g_set_error(error,
2262
0
                    FWUPD_ERROR,
2263
0
                    FWUPD_ERROR_INVALID_DATA,
2264
0
                    "string '%s' (0x%x bytes) does not fit in FuStructGenesysTsVendorSupport.reserved3 (0x%x bytes)",
2265
0
                    value, (guint) len, (guint) 15);
2266
0
        return FALSE;
2267
0
    }
2268
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 16, (const guint8 *)value, len, 0x0, len, error);
2269
0
}
2270
/**
2271
 * fu_struct_genesys_ts_vendor_support_new: (skip):
2272
 **/
2273
FuStructGenesysTsVendorSupport *
2274
fu_struct_genesys_ts_vendor_support_new(void)
2275
0
{
2276
0
    FuStructGenesysTsVendorSupport *st = fu_struct_genesys_ts_vendor_support_new_internal();
2277
0
    st->buf = g_byte_array_sized_new(31);
2278
0
    fu_byte_array_set_size(st->buf, 31, 0x0);
2279
0
    return st;
2280
0
}
2281
/**
2282
 * fu_struct_genesys_ts_vendor_support_to_string: (skip):
2283
 **/
2284
static gchar *
2285
fu_struct_genesys_ts_vendor_support_to_string(const FuStructGenesysTsVendorSupport *st)
2286
0
{
2287
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsVendorSupport:\n");
2288
0
    g_return_val_if_fail(st != NULL, NULL);
2289
0
    {
2290
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_version(st);
2291
0
        if (tmp != NULL)
2292
0
            g_string_append_printf(str, "  version: %s\n", tmp);
2293
0
    }
2294
0
    {
2295
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved1(st);
2296
0
        if (tmp != NULL)
2297
0
            g_string_append_printf(str, "  reserved1: %s\n", tmp);
2298
0
    }
2299
0
    {
2300
0
        const gchar *tmp = fu_genesys_vs_codesign_check_to_string(fu_struct_genesys_ts_vendor_support_get_codesign_check(st));
2301
0
        if (tmp != NULL) {
2302
0
            g_string_append_printf(str, "  codesign_check: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_vendor_support_get_codesign_check(st), tmp);
2303
0
        } else {
2304
0
            g_string_append_printf(str, "  codesign_check: 0x%x\n", (guint) fu_struct_genesys_ts_vendor_support_get_codesign_check(st));
2305
0
        }
2306
0
    }
2307
0
    {
2308
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved2(st);
2309
0
        if (tmp != NULL)
2310
0
            g_string_append_printf(str, "  reserved2: %s\n", tmp);
2311
0
    }
2312
0
    {
2313
0
        const gchar *tmp = fu_genesys_vs_hid_isp_to_string(fu_struct_genesys_ts_vendor_support_get_hid_isp(st));
2314
0
        if (tmp != NULL) {
2315
0
            g_string_append_printf(str, "  hid_isp: 0x%x [%s]\n", (guint) fu_struct_genesys_ts_vendor_support_get_hid_isp(st), tmp);
2316
0
        } else {
2317
0
            g_string_append_printf(str, "  hid_isp: 0x%x\n", (guint) fu_struct_genesys_ts_vendor_support_get_hid_isp(st));
2318
0
        }
2319
0
    }
2320
0
    {
2321
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_vendor_support_get_reserved3(st);
2322
0
        if (tmp != NULL)
2323
0
            g_string_append_printf(str, "  reserved3: %s\n", tmp);
2324
0
    }
2325
0
    if (str->len > 0)
2326
0
        g_string_set_size(str, str->len - 1);
2327
0
    return g_string_free(g_steal_pointer(&str), FALSE);
2328
0
}
2329
static gboolean
2330
fu_struct_genesys_ts_vendor_support_parse_internal(FuStructGenesysTsVendorSupport *st, GError **error)
2331
0
{
2332
0
    if (g_log_get_debug_enabled()) {
2333
0
        g_autofree gchar *str = fu_struct_genesys_ts_vendor_support_to_string(st);
2334
0
        g_debug("%s", str);
2335
0
    }
2336
0
    return TRUE;
2337
0
}
2338
2339
/**
2340
 * fu_struct_genesys_ts_vendor_support_parse: (skip):
2341
 **/
2342
FuStructGenesysTsVendorSupport *
2343
fu_struct_genesys_ts_vendor_support_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
2344
0
{
2345
0
    g_autoptr(FuStructGenesysTsVendorSupport) st = fu_struct_genesys_ts_vendor_support_new_internal();
2346
0
    g_return_val_if_fail(buf != NULL, NULL);
2347
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
2348
0
    if (!fu_memchk_read(bufsz, offset, 31, error)) {
2349
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysTsVendorSupport: ");
2350
0
        return NULL;
2351
0
    }
2352
0
    st->buf = g_byte_array_new();
2353
0
    g_byte_array_append(st->buf, buf + offset, 31);
2354
0
    if (!fu_struct_genesys_ts_vendor_support_parse_internal(st, error))
2355
0
        return NULL;
2356
0
    return g_steal_pointer(&st);
2357
0
}
2358
/**
2359
 * fu_struct_genesys_ts_brand_project_ref: (skip):
2360
 **/
2361
FuStructGenesysTsBrandProject *
2362
fu_struct_genesys_ts_brand_project_ref(FuStructGenesysTsBrandProject *st)
2363
0
{
2364
0
    g_return_val_if_fail(st != NULL, NULL);
2365
0
    st->refcount++;
2366
0
    return st;
2367
0
}
2368
/**
2369
 * fu_struct_genesys_ts_brand_project_unref: (skip):
2370
 **/
2371
void
2372
fu_struct_genesys_ts_brand_project_unref(FuStructGenesysTsBrandProject *st)
2373
0
{
2374
0
    g_return_if_fail(st != NULL);
2375
0
    if (st->refcount == 0) {
2376
0
        g_critical("FuStructGenesysTsBrandProject refcount already zero");
2377
0
        return;
2378
0
    }
2379
0
    if (--st->refcount > 0)
2380
0
        return;
2381
0
    if (st->buf != NULL)
2382
0
        g_byte_array_unref(st->buf);
2383
0
    g_free(st);
2384
0
}
2385
/**
2386
 * fu_struct_genesys_ts_brand_project_new_internal: (skip):
2387
 **/
2388
static FuStructGenesysTsBrandProject *
2389
fu_struct_genesys_ts_brand_project_new_internal(void)
2390
0
{
2391
0
    FuStructGenesysTsBrandProject *st = g_new0(FuStructGenesysTsBrandProject, 1);
2392
0
    st->refcount = 1;
2393
0
    return st;
2394
0
}
2395
2396
/* getters */
2397
/**
2398
 * fu_struct_genesys_ts_brand_project_get_project: (skip):
2399
 **/
2400
gchar *
2401
fu_struct_genesys_ts_brand_project_get_project(const FuStructGenesysTsBrandProject *st)
2402
0
{
2403
0
    g_return_val_if_fail(st != NULL, NULL);
2404
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 0, 15, NULL);
2405
0
}
2406
2407
/* setters */
2408
/**
2409
 * fu_struct_genesys_ts_brand_project_to_string: (skip):
2410
 **/
2411
static gchar *
2412
fu_struct_genesys_ts_brand_project_to_string(const FuStructGenesysTsBrandProject *st)
2413
0
{
2414
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysTsBrandProject:\n");
2415
0
    g_return_val_if_fail(st != NULL, NULL);
2416
0
    {
2417
0
        g_autofree gchar *tmp = fu_struct_genesys_ts_brand_project_get_project(st);
2418
0
        if (tmp != NULL)
2419
0
            g_string_append_printf(str, "  project: %s\n", tmp);
2420
0
    }
2421
0
    if (str->len > 0)
2422
0
        g_string_set_size(str, str->len - 1);
2423
0
    return g_string_free(g_steal_pointer(&str), FALSE);
2424
0
}
2425
static gboolean
2426
fu_struct_genesys_ts_brand_project_parse_internal(FuStructGenesysTsBrandProject *st, GError **error)
2427
0
{
2428
0
    if (g_log_get_debug_enabled()) {
2429
0
        g_autofree gchar *str = fu_struct_genesys_ts_brand_project_to_string(st);
2430
0
        g_debug("%s", str);
2431
0
    }
2432
0
    return TRUE;
2433
0
}
2434
2435
/**
2436
 * fu_struct_genesys_ts_brand_project_parse: (skip):
2437
 **/
2438
FuStructGenesysTsBrandProject *
2439
fu_struct_genesys_ts_brand_project_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
2440
0
{
2441
0
    g_autoptr(FuStructGenesysTsBrandProject) st = fu_struct_genesys_ts_brand_project_new_internal();
2442
0
    g_return_val_if_fail(buf != NULL, NULL);
2443
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
2444
0
    if (!fu_memchk_read(bufsz, offset, 15, error)) {
2445
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysTsBrandProject: ");
2446
0
        return NULL;
2447
0
    }
2448
0
    st->buf = g_byte_array_new();
2449
0
    g_byte_array_append(st->buf, buf + offset, 15);
2450
0
    if (!fu_struct_genesys_ts_brand_project_parse_internal(st, error))
2451
0
        return NULL;
2452
0
    return g_steal_pointer(&st);
2453
0
}
2454
/**
2455
 * fu_struct_genesys_fw_codesign_info_rsa_ref: (skip):
2456
 **/
2457
FuStructGenesysFwCodesignInfoRsa *
2458
fu_struct_genesys_fw_codesign_info_rsa_ref(FuStructGenesysFwCodesignInfoRsa *st)
2459
0
{
2460
0
    g_return_val_if_fail(st != NULL, NULL);
2461
0
    st->refcount++;
2462
0
    return st;
2463
0
}
2464
/**
2465
 * fu_struct_genesys_fw_codesign_info_rsa_unref: (skip):
2466
 **/
2467
void
2468
fu_struct_genesys_fw_codesign_info_rsa_unref(FuStructGenesysFwCodesignInfoRsa *st)
2469
182
{
2470
182
    g_return_if_fail(st != NULL);
2471
182
    if (st->refcount == 0) {
2472
0
        g_critical("FuStructGenesysFwCodesignInfoRsa refcount already zero");
2473
0
        return;
2474
0
    }
2475
182
    if (--st->refcount > 0)
2476
0
        return;
2477
182
    if (st->buf != NULL)
2478
182
        g_byte_array_unref(st->buf);
2479
182
    g_free(st);
2480
182
}
2481
/**
2482
 * fu_struct_genesys_fw_codesign_info_rsa_new_internal: (skip):
2483
 **/
2484
static FuStructGenesysFwCodesignInfoRsa *
2485
fu_struct_genesys_fw_codesign_info_rsa_new_internal(void)
2486
182
{
2487
182
    FuStructGenesysFwCodesignInfoRsa *st = g_new0(FuStructGenesysFwCodesignInfoRsa, 1);
2488
182
    st->refcount = 1;
2489
182
    return st;
2490
182
}
2491
2492
/* getters */
2493
/**
2494
 * fu_struct_genesys_fw_codesign_info_rsa_get_tag_n: (skip):
2495
 **/
2496
static guint32
2497
fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(const FuStructGenesysFwCodesignInfoRsa *st)
2498
275
{
2499
275
    g_return_val_if_fail(st != NULL, 0x0);
2500
275
    return fu_memread_uint32(st->buf->data + 0, G_BIG_ENDIAN);
2501
275
}
2502
/**
2503
 * fu_struct_genesys_fw_codesign_info_rsa_get_text_n: (skip):
2504
 **/
2505
gchar *
2506
fu_struct_genesys_fw_codesign_info_rsa_get_text_n(const FuStructGenesysFwCodesignInfoRsa *st)
2507
0
{
2508
0
    g_return_val_if_fail(st != NULL, NULL);
2509
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 4, 512, NULL);
2510
0
}
2511
/**
2512
 * fu_struct_genesys_fw_codesign_info_rsa_get_end_n: (skip):
2513
 **/
2514
static guint16
2515
fu_struct_genesys_fw_codesign_info_rsa_get_end_n(const FuStructGenesysFwCodesignInfoRsa *st)
2516
111
{
2517
111
    g_return_val_if_fail(st != NULL, 0x0);
2518
111
    return fu_memread_uint16(st->buf->data + 516, G_BIG_ENDIAN);
2519
111
}
2520
/**
2521
 * fu_struct_genesys_fw_codesign_info_rsa_get_tag_e: (skip):
2522
 **/
2523
static guint32
2524
fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(const FuStructGenesysFwCodesignInfoRsa *st)
2525
113
{
2526
113
    g_return_val_if_fail(st != NULL, 0x0);
2527
113
    return fu_memread_uint32(st->buf->data + 518, G_BIG_ENDIAN);
2528
113
}
2529
/**
2530
 * fu_struct_genesys_fw_codesign_info_rsa_get_text_e: (skip):
2531
 **/
2532
gchar *
2533
fu_struct_genesys_fw_codesign_info_rsa_get_text_e(const FuStructGenesysFwCodesignInfoRsa *st)
2534
0
{
2535
0
    g_return_val_if_fail(st != NULL, NULL);
2536
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 522, 6, NULL);
2537
0
}
2538
/**
2539
 * fu_struct_genesys_fw_codesign_info_rsa_get_end_e: (skip):
2540
 **/
2541
static guint16
2542
fu_struct_genesys_fw_codesign_info_rsa_get_end_e(const FuStructGenesysFwCodesignInfoRsa *st)
2543
41
{
2544
41
    g_return_val_if_fail(st != NULL, 0x0);
2545
41
    return fu_memread_uint16(st->buf->data + 528, G_BIG_ENDIAN);
2546
41
}
2547
/**
2548
 * fu_struct_genesys_fw_codesign_info_rsa_get_signature: (skip):
2549
 **/
2550
const guint8 *
2551
fu_struct_genesys_fw_codesign_info_rsa_get_signature(const FuStructGenesysFwCodesignInfoRsa *st, gsize *bufsz)
2552
0
{
2553
0
    g_return_val_if_fail(st != NULL, NULL);
2554
0
    if (bufsz != NULL)
2555
0
        *bufsz = 256;
2556
0
    return st->buf->data + 530;
2557
0
}
2558
2559
/* setters */
2560
/**
2561
 * fu_struct_genesys_fw_codesign_info_rsa_to_string: (skip):
2562
 **/
2563
static gchar *
2564
fu_struct_genesys_fw_codesign_info_rsa_to_string(const FuStructGenesysFwCodesignInfoRsa *st)
2565
0
{
2566
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysFwCodesignInfoRsa:\n");
2567
0
    g_return_val_if_fail(st != NULL, NULL);
2568
0
    g_string_append_printf(str, "  tag_n: 0x%x\n",
2569
0
                           (guint) fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(st));
2570
0
    {
2571
0
        g_autofree gchar *tmp = fu_struct_genesys_fw_codesign_info_rsa_get_text_n(st);
2572
0
        if (tmp != NULL)
2573
0
            g_string_append_printf(str, "  text_n: %s\n", tmp);
2574
0
    }
2575
0
    g_string_append_printf(str, "  end_n: 0x%x\n",
2576
0
                           (guint) fu_struct_genesys_fw_codesign_info_rsa_get_end_n(st));
2577
0
    g_string_append_printf(str, "  tag_e: 0x%x\n",
2578
0
                           (guint) fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(st));
2579
0
    {
2580
0
        g_autofree gchar *tmp = fu_struct_genesys_fw_codesign_info_rsa_get_text_e(st);
2581
0
        if (tmp != NULL)
2582
0
            g_string_append_printf(str, "  text_e: %s\n", tmp);
2583
0
    }
2584
0
    g_string_append_printf(str, "  end_e: 0x%x\n",
2585
0
                           (guint) fu_struct_genesys_fw_codesign_info_rsa_get_end_e(st));
2586
0
    {
2587
0
        gsize bufsz = 0;
2588
0
        const guint8 *buf = fu_struct_genesys_fw_codesign_info_rsa_get_signature(st, &bufsz);
2589
0
        g_autoptr(GString) tmp = g_string_new(NULL);
2590
0
        for (gsize i = 0; i < bufsz; i++)
2591
0
            g_string_append_printf(tmp, "%02X", buf[i]);
2592
0
        g_string_append_printf(str, "  signature: 0x%s\n", tmp->str);
2593
0
    }
2594
0
    if (str->len > 0)
2595
0
        g_string_set_size(str, str->len - 1);
2596
0
    return g_string_free(g_steal_pointer(&str), FALSE);
2597
0
}
2598
static gboolean
2599
fu_struct_genesys_fw_codesign_info_rsa_validate_internal(FuStructGenesysFwCodesignInfoRsa *st, GError **error)
2600
182
{
2601
182
    g_return_val_if_fail(st != NULL, FALSE);
2602
182
    if (fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(st) != 0x4E203D20) {
2603
93
        g_set_error(error,
2604
93
                    FWUPD_ERROR,
2605
93
                    FWUPD_ERROR_INVALID_DATA,
2606
93
                    "constant FuStructGenesysFwCodesignInfoRsa.tag_n was not valid, "
2607
93
                    "expected 0x%x and got 0x%x",
2608
93
                    (guint) 0x4E203D20,
2609
93
                    (guint) fu_struct_genesys_fw_codesign_info_rsa_get_tag_n(st));
2610
93
        return FALSE;
2611
93
    }
2612
89
    if (fu_struct_genesys_fw_codesign_info_rsa_get_end_n(st) != 0x0D0A) {
2613
22
        g_set_error(error,
2614
22
                    FWUPD_ERROR,
2615
22
                    FWUPD_ERROR_INVALID_DATA,
2616
22
                    "constant FuStructGenesysFwCodesignInfoRsa.end_n was not valid, "
2617
22
                    "expected 0x%x and got 0x%x",
2618
22
                    (guint) 0x0D0A,
2619
22
                    (guint) fu_struct_genesys_fw_codesign_info_rsa_get_end_n(st));
2620
22
        return FALSE;
2621
22
    }
2622
67
    if (fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(st) != 0x45203D20) {
2623
46
        g_set_error(error,
2624
46
                    FWUPD_ERROR,
2625
46
                    FWUPD_ERROR_INVALID_DATA,
2626
46
                    "constant FuStructGenesysFwCodesignInfoRsa.tag_e was not valid, "
2627
46
                    "expected 0x%x and got 0x%x",
2628
46
                    (guint) 0x45203D20,
2629
46
                    (guint) fu_struct_genesys_fw_codesign_info_rsa_get_tag_e(st));
2630
46
        return FALSE;
2631
46
    }
2632
21
    if (fu_struct_genesys_fw_codesign_info_rsa_get_end_e(st) != 0x0D0A) {
2633
20
        g_set_error(error,
2634
20
                    FWUPD_ERROR,
2635
20
                    FWUPD_ERROR_INVALID_DATA,
2636
20
                    "constant FuStructGenesysFwCodesignInfoRsa.end_e was not valid, "
2637
20
                    "expected 0x%x and got 0x%x",
2638
20
                    (guint) 0x0D0A,
2639
20
                    (guint) fu_struct_genesys_fw_codesign_info_rsa_get_end_e(st));
2640
20
        return FALSE;
2641
20
    }
2642
1
    return TRUE;
2643
21
}
2644
/**
2645
 * fu_struct_genesys_fw_codesign_info_rsa_validate_stream: (skip):
2646
 **/
2647
gboolean
2648
fu_struct_genesys_fw_codesign_info_rsa_validate_stream(GInputStream *stream, gsize offset, GError **error)
2649
182
{
2650
182
    g_autoptr(FuStructGenesysFwCodesignInfoRsa) st = fu_struct_genesys_fw_codesign_info_rsa_new_internal();
2651
182
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
2652
182
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
2653
182
    st->buf = fu_input_stream_read_byte_array(stream, offset, 786, NULL, error);
2654
182
    if (st->buf == NULL) {
2655
0
        g_prefix_error(error, "FuStructGenesysFwCodesignInfoRsa failed read of 0x%x: ", (guint) 786);
2656
0
        return FALSE;
2657
0
    }
2658
182
    if (st->buf->len != 786) {
2659
0
        g_set_error(error,
2660
0
                    FWUPD_ERROR,
2661
0
                    FWUPD_ERROR_INVALID_DATA,
2662
0
                    "FuStructGenesysFwCodesignInfoRsa requested 0x%x and got 0x%x",
2663
0
                    (guint) 786,
2664
0
                    (guint) st->buf->len);
2665
0
        return FALSE;
2666
0
    }
2667
182
    return fu_struct_genesys_fw_codesign_info_rsa_validate_internal(st, error);
2668
182
}
2669
static gboolean
2670
fu_struct_genesys_fw_codesign_info_rsa_parse_internal(FuStructGenesysFwCodesignInfoRsa *st, GError **error)
2671
0
{
2672
0
    if (g_log_get_debug_enabled()) {
2673
0
        g_autofree gchar *str = fu_struct_genesys_fw_codesign_info_rsa_to_string(st);
2674
0
        g_debug("%s", str);
2675
0
    }
2676
0
    if (!fu_struct_genesys_fw_codesign_info_rsa_validate_internal(st, error))
2677
0
        return FALSE;
2678
0
    return TRUE;
2679
0
}
2680
/**
2681
 * fu_struct_genesys_fw_codesign_info_rsa_parse_stream: (skip):
2682
 **/
2683
FuStructGenesysFwCodesignInfoRsa *
2684
fu_struct_genesys_fw_codesign_info_rsa_parse_stream(GInputStream *stream, gsize offset, GError **error)
2685
0
{
2686
0
    g_autoptr(FuStructGenesysFwCodesignInfoRsa) st = fu_struct_genesys_fw_codesign_info_rsa_new_internal();
2687
0
    st->buf = fu_input_stream_read_byte_array(stream, offset, 786, NULL, error);
2688
0
    if (st->buf == NULL) {
2689
0
        g_prefix_error(error, "FuStructGenesysFwCodesignInfoRsa failed read of 0x%x: ", (guint) 786);
2690
0
        return NULL;
2691
0
    }
2692
0
    if (st->buf->len != 786) {
2693
0
        g_set_error(error,
2694
0
                    FWUPD_ERROR,
2695
0
                    FWUPD_ERROR_INVALID_DATA,
2696
0
                    "FuStructGenesysFwCodesignInfoRsa requested 0x%x and got 0x%x",
2697
0
                    (guint) 786,
2698
0
                    (guint) st->buf->len);
2699
0
        return NULL;
2700
0
    }
2701
0
    if (!fu_struct_genesys_fw_codesign_info_rsa_parse_internal(st, error))
2702
0
        return NULL;
2703
0
    return g_steal_pointer(&st);
2704
0
}
2705
/**
2706
 * fu_struct_genesys_fw_rsa_public_key_text_ref: (skip):
2707
 **/
2708
FuStructGenesysFwRsaPublicKeyText *
2709
fu_struct_genesys_fw_rsa_public_key_text_ref(FuStructGenesysFwRsaPublicKeyText *st)
2710
0
{
2711
0
    g_return_val_if_fail(st != NULL, NULL);
2712
0
    st->refcount++;
2713
0
    return st;
2714
0
}
2715
/**
2716
 * fu_struct_genesys_fw_rsa_public_key_text_unref: (skip):
2717
 **/
2718
void
2719
fu_struct_genesys_fw_rsa_public_key_text_unref(FuStructGenesysFwRsaPublicKeyText *st)
2720
0
{
2721
0
    g_return_if_fail(st != NULL);
2722
0
    if (st->refcount == 0) {
2723
0
        g_critical("FuStructGenesysFwRsaPublicKeyText refcount already zero");
2724
0
        return;
2725
0
    }
2726
0
    if (--st->refcount > 0)
2727
0
        return;
2728
0
    if (st->buf != NULL)
2729
0
        g_byte_array_unref(st->buf);
2730
0
    g_free(st);
2731
0
}
2732
/**
2733
 * fu_struct_genesys_fw_rsa_public_key_text_new_internal: (skip):
2734
 **/
2735
static FuStructGenesysFwRsaPublicKeyText *
2736
fu_struct_genesys_fw_rsa_public_key_text_new_internal(void)
2737
0
{
2738
0
    FuStructGenesysFwRsaPublicKeyText *st = g_new0(FuStructGenesysFwRsaPublicKeyText, 1);
2739
0
    st->refcount = 1;
2740
0
    return st;
2741
0
}
2742
2743
/* getters */
2744
/**
2745
 * fu_struct_genesys_fw_rsa_public_key_text_get_tag_n: (skip):
2746
 **/
2747
static guint32
2748
fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(const FuStructGenesysFwRsaPublicKeyText *st)
2749
0
{
2750
0
    g_return_val_if_fail(st != NULL, 0x0);
2751
0
    return fu_memread_uint32(st->buf->data + 0, G_BIG_ENDIAN);
2752
0
}
2753
/**
2754
 * fu_struct_genesys_fw_rsa_public_key_text_get_text_n: (skip):
2755
 **/
2756
gchar *
2757
fu_struct_genesys_fw_rsa_public_key_text_get_text_n(const FuStructGenesysFwRsaPublicKeyText *st)
2758
0
{
2759
0
    g_return_val_if_fail(st != NULL, NULL);
2760
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 4, 512, NULL);
2761
0
}
2762
/**
2763
 * fu_struct_genesys_fw_rsa_public_key_text_get_end_n: (skip):
2764
 **/
2765
static guint16
2766
fu_struct_genesys_fw_rsa_public_key_text_get_end_n(const FuStructGenesysFwRsaPublicKeyText *st)
2767
0
{
2768
0
    g_return_val_if_fail(st != NULL, 0x0);
2769
0
    return fu_memread_uint16(st->buf->data + 516, G_BIG_ENDIAN);
2770
0
}
2771
/**
2772
 * fu_struct_genesys_fw_rsa_public_key_text_get_tag_e: (skip):
2773
 **/
2774
static guint32
2775
fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(const FuStructGenesysFwRsaPublicKeyText *st)
2776
0
{
2777
0
    g_return_val_if_fail(st != NULL, 0x0);
2778
0
    return fu_memread_uint32(st->buf->data + 518, G_BIG_ENDIAN);
2779
0
}
2780
/**
2781
 * fu_struct_genesys_fw_rsa_public_key_text_get_text_e: (skip):
2782
 **/
2783
gchar *
2784
fu_struct_genesys_fw_rsa_public_key_text_get_text_e(const FuStructGenesysFwRsaPublicKeyText *st)
2785
0
{
2786
0
    g_return_val_if_fail(st != NULL, NULL);
2787
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 522, 6, NULL);
2788
0
}
2789
/**
2790
 * fu_struct_genesys_fw_rsa_public_key_text_get_end_e: (skip):
2791
 **/
2792
static guint16
2793
fu_struct_genesys_fw_rsa_public_key_text_get_end_e(const FuStructGenesysFwRsaPublicKeyText *st)
2794
0
{
2795
0
    g_return_val_if_fail(st != NULL, 0x0);
2796
0
    return fu_memread_uint16(st->buf->data + 528, G_BIG_ENDIAN);
2797
0
}
2798
2799
/* setters */
2800
/**
2801
 * fu_struct_genesys_fw_rsa_public_key_text_to_string: (skip):
2802
 **/
2803
static gchar *
2804
fu_struct_genesys_fw_rsa_public_key_text_to_string(const FuStructGenesysFwRsaPublicKeyText *st)
2805
0
{
2806
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysFwRsaPublicKeyText:\n");
2807
0
    g_return_val_if_fail(st != NULL, NULL);
2808
0
    g_string_append_printf(str, "  tag_n: 0x%x\n",
2809
0
                           (guint) fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(st));
2810
0
    {
2811
0
        g_autofree gchar *tmp = fu_struct_genesys_fw_rsa_public_key_text_get_text_n(st);
2812
0
        if (tmp != NULL)
2813
0
            g_string_append_printf(str, "  text_n: %s\n", tmp);
2814
0
    }
2815
0
    g_string_append_printf(str, "  end_n: 0x%x\n",
2816
0
                           (guint) fu_struct_genesys_fw_rsa_public_key_text_get_end_n(st));
2817
0
    g_string_append_printf(str, "  tag_e: 0x%x\n",
2818
0
                           (guint) fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(st));
2819
0
    {
2820
0
        g_autofree gchar *tmp = fu_struct_genesys_fw_rsa_public_key_text_get_text_e(st);
2821
0
        if (tmp != NULL)
2822
0
            g_string_append_printf(str, "  text_e: %s\n", tmp);
2823
0
    }
2824
0
    g_string_append_printf(str, "  end_e: 0x%x\n",
2825
0
                           (guint) fu_struct_genesys_fw_rsa_public_key_text_get_end_e(st));
2826
0
    if (str->len > 0)
2827
0
        g_string_set_size(str, str->len - 1);
2828
0
    return g_string_free(g_steal_pointer(&str), FALSE);
2829
0
}
2830
static gboolean
2831
fu_struct_genesys_fw_rsa_public_key_text_validate_internal(FuStructGenesysFwRsaPublicKeyText *st, GError **error)
2832
0
{
2833
0
    g_return_val_if_fail(st != NULL, FALSE);
2834
0
    if (fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(st) != 0x4E203D20) {
2835
0
        g_set_error(error,
2836
0
                    FWUPD_ERROR,
2837
0
                    FWUPD_ERROR_INVALID_DATA,
2838
0
                    "constant FuStructGenesysFwRsaPublicKeyText.tag_n was not valid, "
2839
0
                    "expected 0x%x and got 0x%x",
2840
0
                    (guint) 0x4E203D20,
2841
0
                    (guint) fu_struct_genesys_fw_rsa_public_key_text_get_tag_n(st));
2842
0
        return FALSE;
2843
0
    }
2844
0
    if (fu_struct_genesys_fw_rsa_public_key_text_get_end_n(st) != 0x0D0A) {
2845
0
        g_set_error(error,
2846
0
                    FWUPD_ERROR,
2847
0
                    FWUPD_ERROR_INVALID_DATA,
2848
0
                    "constant FuStructGenesysFwRsaPublicKeyText.end_n was not valid, "
2849
0
                    "expected 0x%x and got 0x%x",
2850
0
                    (guint) 0x0D0A,
2851
0
                    (guint) fu_struct_genesys_fw_rsa_public_key_text_get_end_n(st));
2852
0
        return FALSE;
2853
0
    }
2854
0
    if (fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(st) != 0x45203D20) {
2855
0
        g_set_error(error,
2856
0
                    FWUPD_ERROR,
2857
0
                    FWUPD_ERROR_INVALID_DATA,
2858
0
                    "constant FuStructGenesysFwRsaPublicKeyText.tag_e was not valid, "
2859
0
                    "expected 0x%x and got 0x%x",
2860
0
                    (guint) 0x45203D20,
2861
0
                    (guint) fu_struct_genesys_fw_rsa_public_key_text_get_tag_e(st));
2862
0
        return FALSE;
2863
0
    }
2864
0
    if (fu_struct_genesys_fw_rsa_public_key_text_get_end_e(st) != 0x0D0A) {
2865
0
        g_set_error(error,
2866
0
                    FWUPD_ERROR,
2867
0
                    FWUPD_ERROR_INVALID_DATA,
2868
0
                    "constant FuStructGenesysFwRsaPublicKeyText.end_e was not valid, "
2869
0
                    "expected 0x%x and got 0x%x",
2870
0
                    (guint) 0x0D0A,
2871
0
                    (guint) fu_struct_genesys_fw_rsa_public_key_text_get_end_e(st));
2872
0
        return FALSE;
2873
0
    }
2874
0
    return TRUE;
2875
0
}
2876
/**
2877
 * fu_struct_genesys_fw_rsa_public_key_text_validate: (skip):
2878
 **/
2879
gboolean
2880
fu_struct_genesys_fw_rsa_public_key_text_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
2881
0
{
2882
0
    GByteArray st_buf = {.data = (guint8 *) buf + offset, .len = bufsz - offset, };
2883
0
    FuStructGenesysFwRsaPublicKeyText st_tmp = {.buf = &st_buf };
2884
0
    g_return_val_if_fail(buf != NULL, FALSE);
2885
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
2886
0
    if (!fu_memchk_read(bufsz, offset, 530, error)) {
2887
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysFwRsaPublicKeyText: ");
2888
0
        return FALSE;
2889
0
    }
2890
0
    if (!fu_struct_genesys_fw_rsa_public_key_text_validate_internal(&st_tmp, error))
2891
0
        return FALSE;
2892
0
    return TRUE;
2893
0
}
2894
static gboolean
2895
fu_struct_genesys_fw_rsa_public_key_text_parse_internal(FuStructGenesysFwRsaPublicKeyText *st, GError **error)
2896
0
{
2897
0
    if (g_log_get_debug_enabled()) {
2898
0
        g_autofree gchar *str = fu_struct_genesys_fw_rsa_public_key_text_to_string(st);
2899
0
        g_debug("%s", str);
2900
0
    }
2901
0
    if (!fu_struct_genesys_fw_rsa_public_key_text_validate_internal(st, error))
2902
0
        return FALSE;
2903
0
    return TRUE;
2904
0
}
2905
2906
/**
2907
 * fu_struct_genesys_fw_rsa_public_key_text_parse: (skip):
2908
 **/
2909
FuStructGenesysFwRsaPublicKeyText *
2910
fu_struct_genesys_fw_rsa_public_key_text_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
2911
0
{
2912
0
    g_autoptr(FuStructGenesysFwRsaPublicKeyText) st = fu_struct_genesys_fw_rsa_public_key_text_new_internal();
2913
0
    g_return_val_if_fail(buf != NULL, NULL);
2914
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
2915
0
    if (!fu_memchk_read(bufsz, offset, 530, error)) {
2916
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysFwRsaPublicKeyText: ");
2917
0
        return NULL;
2918
0
    }
2919
0
    st->buf = g_byte_array_new();
2920
0
    g_byte_array_append(st->buf, buf + offset, 530);
2921
0
    if (!fu_struct_genesys_fw_rsa_public_key_text_parse_internal(st, error))
2922
0
        return NULL;
2923
0
    return g_steal_pointer(&st);
2924
0
}
2925
/**
2926
 * fu_struct_genesys_fw_codesign_info_ecdsa_ref: (skip):
2927
 **/
2928
FuStructGenesysFwCodesignInfoEcdsa *
2929
fu_struct_genesys_fw_codesign_info_ecdsa_ref(FuStructGenesysFwCodesignInfoEcdsa *st)
2930
0
{
2931
0
    g_return_val_if_fail(st != NULL, NULL);
2932
0
    st->refcount++;
2933
0
    return st;
2934
0
}
2935
/**
2936
 * fu_struct_genesys_fw_codesign_info_ecdsa_unref: (skip):
2937
 **/
2938
void
2939
fu_struct_genesys_fw_codesign_info_ecdsa_unref(FuStructGenesysFwCodesignInfoEcdsa *st)
2940
43
{
2941
43
    g_return_if_fail(st != NULL);
2942
43
    if (st->refcount == 0) {
2943
0
        g_critical("FuStructGenesysFwCodesignInfoEcdsa refcount already zero");
2944
0
        return;
2945
0
    }
2946
43
    if (--st->refcount > 0)
2947
0
        return;
2948
43
    if (st->buf != NULL)
2949
43
        g_byte_array_unref(st->buf);
2950
43
    g_free(st);
2951
43
}
2952
/**
2953
 * fu_struct_genesys_fw_codesign_info_ecdsa_new_internal: (skip):
2954
 **/
2955
static FuStructGenesysFwCodesignInfoEcdsa *
2956
fu_struct_genesys_fw_codesign_info_ecdsa_new_internal(void)
2957
43
{
2958
43
    FuStructGenesysFwCodesignInfoEcdsa *st = g_new0(FuStructGenesysFwCodesignInfoEcdsa, 1);
2959
43
    st->refcount = 1;
2960
43
    return st;
2961
43
}
2962
2963
/* getters */
2964
/**
2965
 * fu_struct_genesys_fw_codesign_info_ecdsa_get_hash: (skip):
2966
 **/
2967
const guint8 *
2968
fu_struct_genesys_fw_codesign_info_ecdsa_get_hash(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz)
2969
0
{
2970
0
    g_return_val_if_fail(st != NULL, NULL);
2971
0
    if (bufsz != NULL)
2972
0
        *bufsz = 32;
2973
0
    return st->buf->data + 0;
2974
0
}
2975
/**
2976
 * fu_struct_genesys_fw_codesign_info_ecdsa_get_key: (skip):
2977
 **/
2978
const guint8 *
2979
fu_struct_genesys_fw_codesign_info_ecdsa_get_key(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz)
2980
0
{
2981
0
    g_return_val_if_fail(st != NULL, NULL);
2982
0
    if (bufsz != NULL)
2983
0
        *bufsz = 64;
2984
0
    return st->buf->data + 32;
2985
0
}
2986
/**
2987
 * fu_struct_genesys_fw_codesign_info_ecdsa_get_signature: (skip):
2988
 **/
2989
const guint8 *
2990
fu_struct_genesys_fw_codesign_info_ecdsa_get_signature(const FuStructGenesysFwCodesignInfoEcdsa *st, gsize *bufsz)
2991
0
{
2992
0
    g_return_val_if_fail(st != NULL, NULL);
2993
0
    if (bufsz != NULL)
2994
0
        *bufsz = 64;
2995
0
    return st->buf->data + 96;
2996
0
}
2997
2998
/* setters */
2999
/**
3000
 * fu_struct_genesys_fw_codesign_info_ecdsa_to_string: (skip):
3001
 **/
3002
static gchar *
3003
fu_struct_genesys_fw_codesign_info_ecdsa_to_string(const FuStructGenesysFwCodesignInfoEcdsa *st)
3004
0
{
3005
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysFwCodesignInfoEcdsa:\n");
3006
0
    g_return_val_if_fail(st != NULL, NULL);
3007
0
    {
3008
0
        gsize bufsz = 0;
3009
0
        const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_hash(st, &bufsz);
3010
0
        g_autoptr(GString) tmp = g_string_new(NULL);
3011
0
        for (gsize i = 0; i < bufsz; i++)
3012
0
            g_string_append_printf(tmp, "%02X", buf[i]);
3013
0
        g_string_append_printf(str, "  hash: 0x%s\n", tmp->str);
3014
0
    }
3015
0
    {
3016
0
        gsize bufsz = 0;
3017
0
        const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_key(st, &bufsz);
3018
0
        g_autoptr(GString) tmp = g_string_new(NULL);
3019
0
        for (gsize i = 0; i < bufsz; i++)
3020
0
            g_string_append_printf(tmp, "%02X", buf[i]);
3021
0
        g_string_append_printf(str, "  key: 0x%s\n", tmp->str);
3022
0
    }
3023
0
    {
3024
0
        gsize bufsz = 0;
3025
0
        const guint8 *buf = fu_struct_genesys_fw_codesign_info_ecdsa_get_signature(st, &bufsz);
3026
0
        g_autoptr(GString) tmp = g_string_new(NULL);
3027
0
        for (gsize i = 0; i < bufsz; i++)
3028
0
            g_string_append_printf(tmp, "%02X", buf[i]);
3029
0
        g_string_append_printf(str, "  signature: 0x%s\n", tmp->str);
3030
0
    }
3031
0
    if (str->len > 0)
3032
0
        g_string_set_size(str, str->len - 1);
3033
0
    return g_string_free(g_steal_pointer(&str), FALSE);
3034
0
}
3035
static gboolean
3036
fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(FuStructGenesysFwCodesignInfoEcdsa *st, GError **error)
3037
43
{
3038
43
    g_return_val_if_fail(st != NULL, FALSE);
3039
43
    return TRUE;
3040
43
}
3041
/**
3042
 * fu_struct_genesys_fw_codesign_info_ecdsa_validate: (skip):
3043
 **/
3044
gboolean
3045
fu_struct_genesys_fw_codesign_info_ecdsa_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
3046
0
{
3047
0
    GByteArray st_buf = {.data = (guint8 *) buf + offset, .len = bufsz - offset, };
3048
0
    FuStructGenesysFwCodesignInfoEcdsa st_tmp = {.buf = &st_buf };
3049
0
    g_return_val_if_fail(buf != NULL, FALSE);
3050
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
3051
0
    if (!fu_memchk_read(bufsz, offset, 160, error)) {
3052
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysFwCodesignInfoEcdsa: ");
3053
0
        return FALSE;
3054
0
    }
3055
0
    if (!fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(&st_tmp, error))
3056
0
        return FALSE;
3057
0
    return TRUE;
3058
0
}
3059
/**
3060
 * fu_struct_genesys_fw_codesign_info_ecdsa_validate_stream: (skip):
3061
 **/
3062
gboolean
3063
fu_struct_genesys_fw_codesign_info_ecdsa_validate_stream(GInputStream *stream, gsize offset, GError **error)
3064
43
{
3065
43
    g_autoptr(FuStructGenesysFwCodesignInfoEcdsa) st = fu_struct_genesys_fw_codesign_info_ecdsa_new_internal();
3066
43
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
3067
43
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
3068
43
    st->buf = fu_input_stream_read_byte_array(stream, offset, 160, NULL, error);
3069
43
    if (st->buf == NULL) {
3070
0
        g_prefix_error(error, "FuStructGenesysFwCodesignInfoEcdsa failed read of 0x%x: ", (guint) 160);
3071
0
        return FALSE;
3072
0
    }
3073
43
    if (st->buf->len != 160) {
3074
0
        g_set_error(error,
3075
0
                    FWUPD_ERROR,
3076
0
                    FWUPD_ERROR_INVALID_DATA,
3077
0
                    "FuStructGenesysFwCodesignInfoEcdsa requested 0x%x and got 0x%x",
3078
0
                    (guint) 160,
3079
0
                    (guint) st->buf->len);
3080
0
        return FALSE;
3081
0
    }
3082
43
    return fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(st, error);
3083
43
}
3084
static gboolean
3085
fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(FuStructGenesysFwCodesignInfoEcdsa *st, GError **error)
3086
0
{
3087
0
    if (g_log_get_debug_enabled()) {
3088
0
        g_autofree gchar *str = fu_struct_genesys_fw_codesign_info_ecdsa_to_string(st);
3089
0
        g_debug("%s", str);
3090
0
    }
3091
0
    if (!fu_struct_genesys_fw_codesign_info_ecdsa_validate_internal(st, error))
3092
0
        return FALSE;
3093
0
    return TRUE;
3094
0
}
3095
3096
/**
3097
 * fu_struct_genesys_fw_codesign_info_ecdsa_parse: (skip):
3098
 **/
3099
FuStructGenesysFwCodesignInfoEcdsa *
3100
fu_struct_genesys_fw_codesign_info_ecdsa_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
3101
0
{
3102
0
    g_autoptr(FuStructGenesysFwCodesignInfoEcdsa) st = fu_struct_genesys_fw_codesign_info_ecdsa_new_internal();
3103
0
    g_return_val_if_fail(buf != NULL, NULL);
3104
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
3105
0
    if (!fu_memchk_read(bufsz, offset, 160, error)) {
3106
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysFwCodesignInfoEcdsa: ");
3107
0
        return NULL;
3108
0
    }
3109
0
    st->buf = g_byte_array_new();
3110
0
    g_byte_array_append(st->buf, buf + offset, 160);
3111
0
    if (!fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(st, error))
3112
0
        return NULL;
3113
0
    return g_steal_pointer(&st);
3114
0
}
3115
/**
3116
 * fu_struct_genesys_fw_codesign_info_ecdsa_parse_stream: (skip):
3117
 **/
3118
FuStructGenesysFwCodesignInfoEcdsa *
3119
fu_struct_genesys_fw_codesign_info_ecdsa_parse_stream(GInputStream *stream, gsize offset, GError **error)
3120
0
{
3121
0
    g_autoptr(FuStructGenesysFwCodesignInfoEcdsa) st = fu_struct_genesys_fw_codesign_info_ecdsa_new_internal();
3122
0
    st->buf = fu_input_stream_read_byte_array(stream, offset, 160, NULL, error);
3123
0
    if (st->buf == NULL) {
3124
0
        g_prefix_error(error, "FuStructGenesysFwCodesignInfoEcdsa failed read of 0x%x: ", (guint) 160);
3125
0
        return NULL;
3126
0
    }
3127
0
    if (st->buf->len != 160) {
3128
0
        g_set_error(error,
3129
0
                    FWUPD_ERROR,
3130
0
                    FWUPD_ERROR_INVALID_DATA,
3131
0
                    "FuStructGenesysFwCodesignInfoEcdsa requested 0x%x and got 0x%x",
3132
0
                    (guint) 160,
3133
0
                    (guint) st->buf->len);
3134
0
        return NULL;
3135
0
    }
3136
0
    if (!fu_struct_genesys_fw_codesign_info_ecdsa_parse_internal(st, error))
3137
0
        return NULL;
3138
0
    return g_steal_pointer(&st);
3139
0
}
3140
/**
3141
 * fu_struct_genesys_fw_ecdsa_public_key_ref: (skip):
3142
 **/
3143
FuStructGenesysFwEcdsaPublicKey *
3144
fu_struct_genesys_fw_ecdsa_public_key_ref(FuStructGenesysFwEcdsaPublicKey *st)
3145
0
{
3146
0
    g_return_val_if_fail(st != NULL, NULL);
3147
0
    st->refcount++;
3148
0
    return st;
3149
0
}
3150
/**
3151
 * fu_struct_genesys_fw_ecdsa_public_key_unref: (skip):
3152
 **/
3153
void
3154
fu_struct_genesys_fw_ecdsa_public_key_unref(FuStructGenesysFwEcdsaPublicKey *st)
3155
0
{
3156
0
    g_return_if_fail(st != NULL);
3157
0
    if (st->refcount == 0) {
3158
0
        g_critical("FuStructGenesysFwEcdsaPublicKey refcount already zero");
3159
0
        return;
3160
0
    }
3161
0
    if (--st->refcount > 0)
3162
0
        return;
3163
0
    if (st->buf != NULL)
3164
0
        g_byte_array_unref(st->buf);
3165
0
    g_free(st);
3166
0
}
3167
/**
3168
 * fu_struct_genesys_fw_ecdsa_public_key_new_internal: (skip):
3169
 **/
3170
static FuStructGenesysFwEcdsaPublicKey *
3171
fu_struct_genesys_fw_ecdsa_public_key_new_internal(void)
3172
0
{
3173
0
    FuStructGenesysFwEcdsaPublicKey *st = g_new0(FuStructGenesysFwEcdsaPublicKey, 1);
3174
0
    st->refcount = 1;
3175
0
    return st;
3176
0
}
3177
3178
/* getters */
3179
/**
3180
 * fu_struct_genesys_fw_ecdsa_public_key_get_key: (skip):
3181
 **/
3182
const guint8 *
3183
fu_struct_genesys_fw_ecdsa_public_key_get_key(const FuStructGenesysFwEcdsaPublicKey *st, gsize *bufsz)
3184
0
{
3185
0
    g_return_val_if_fail(st != NULL, NULL);
3186
0
    if (bufsz != NULL)
3187
0
        *bufsz = 64;
3188
0
    return st->buf->data + 0;
3189
0
}
3190
3191
/* setters */
3192
/**
3193
 * fu_struct_genesys_fw_ecdsa_public_key_to_string: (skip):
3194
 **/
3195
static gchar *
3196
fu_struct_genesys_fw_ecdsa_public_key_to_string(const FuStructGenesysFwEcdsaPublicKey *st)
3197
0
{
3198
0
    g_autoptr(GString) str = g_string_new("FuStructGenesysFwEcdsaPublicKey:\n");
3199
0
    g_return_val_if_fail(st != NULL, NULL);
3200
0
    {
3201
0
        gsize bufsz = 0;
3202
0
        const guint8 *buf = fu_struct_genesys_fw_ecdsa_public_key_get_key(st, &bufsz);
3203
0
        g_autoptr(GString) tmp = g_string_new(NULL);
3204
0
        for (gsize i = 0; i < bufsz; i++)
3205
0
            g_string_append_printf(tmp, "%02X", buf[i]);
3206
0
        g_string_append_printf(str, "  key: 0x%s\n", tmp->str);
3207
0
    }
3208
0
    if (str->len > 0)
3209
0
        g_string_set_size(str, str->len - 1);
3210
0
    return g_string_free(g_steal_pointer(&str), FALSE);
3211
0
}
3212
static gboolean
3213
fu_struct_genesys_fw_ecdsa_public_key_validate_internal(FuStructGenesysFwEcdsaPublicKey *st, GError **error)
3214
0
{
3215
0
    g_return_val_if_fail(st != NULL, FALSE);
3216
0
    return TRUE;
3217
0
}
3218
/**
3219
 * fu_struct_genesys_fw_ecdsa_public_key_validate: (skip):
3220
 **/
3221
gboolean
3222
fu_struct_genesys_fw_ecdsa_public_key_validate(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
3223
0
{
3224
0
    GByteArray st_buf = {.data = (guint8 *) buf + offset, .len = bufsz - offset, };
3225
0
    FuStructGenesysFwEcdsaPublicKey st_tmp = {.buf = &st_buf };
3226
0
    g_return_val_if_fail(buf != NULL, FALSE);
3227
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
3228
0
    if (!fu_memchk_read(bufsz, offset, 64, error)) {
3229
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysFwEcdsaPublicKey: ");
3230
0
        return FALSE;
3231
0
    }
3232
0
    if (!fu_struct_genesys_fw_ecdsa_public_key_validate_internal(&st_tmp, error))
3233
0
        return FALSE;
3234
0
    return TRUE;
3235
0
}
3236
static gboolean
3237
fu_struct_genesys_fw_ecdsa_public_key_parse_internal(FuStructGenesysFwEcdsaPublicKey *st, GError **error)
3238
0
{
3239
0
    if (g_log_get_debug_enabled()) {
3240
0
        g_autofree gchar *str = fu_struct_genesys_fw_ecdsa_public_key_to_string(st);
3241
0
        g_debug("%s", str);
3242
0
    }
3243
0
    if (!fu_struct_genesys_fw_ecdsa_public_key_validate_internal(st, error))
3244
0
        return FALSE;
3245
0
    return TRUE;
3246
0
}
3247
3248
/**
3249
 * fu_struct_genesys_fw_ecdsa_public_key_parse: (skip):
3250
 **/
3251
FuStructGenesysFwEcdsaPublicKey *
3252
fu_struct_genesys_fw_ecdsa_public_key_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
3253
0
{
3254
0
    g_autoptr(FuStructGenesysFwEcdsaPublicKey) st = fu_struct_genesys_fw_ecdsa_public_key_new_internal();
3255
0
    g_return_val_if_fail(buf != NULL, NULL);
3256
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
3257
0
    if (!fu_memchk_read(bufsz, offset, 64, error)) {
3258
0
        g_prefix_error_literal(error, "invalid struct FuStructGenesysFwEcdsaPublicKey: ");
3259
0
        return NULL;
3260
0
    }
3261
0
    st->buf = g_byte_array_new();
3262
0
    g_byte_array_append(st->buf, buf + offset, 64);
3263
0
    if (!fu_struct_genesys_fw_ecdsa_public_key_parse_internal(st, error))
3264
0
        return NULL;
3265
0
    return g_steal_pointer(&st);
3266
0
}