Coverage Report

Created: 2025-11-24 06:59

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