/work/fu-sbatlevel-section-struct.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* auto-generated, do not modify */ |
2 | | #include "config.h" |
3 | | |
4 | | #include "fu-sbatlevel-section-struct.h" |
5 | | #include "fu-byte-array.h" |
6 | | #include "fu-mem-private.h" |
7 | | #include "fu-string.h" |
8 | | |
9 | | #ifdef G_LOG_DOMAIN |
10 | | #undef G_LOG_DOMAIN |
11 | | #endif |
12 | 0 | #define G_LOG_DOMAIN "FuStruct" |
13 | | /* getters */ |
14 | | /** |
15 | | * fu_struct_sbat_level_section_header_get_version: (skip): |
16 | | **/ |
17 | | static guint32 |
18 | | fu_struct_sbat_level_section_header_get_version(const FuStructSbatLevelSectionHeader *st) |
19 | 0 | { |
20 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
21 | 0 | return fu_memread_uint32(st->data + 0, G_LITTLE_ENDIAN); |
22 | 0 | } |
23 | | /** |
24 | | * fu_struct_sbat_level_section_header_get_previous: (skip): |
25 | | **/ |
26 | | guint32 |
27 | | fu_struct_sbat_level_section_header_get_previous(const FuStructSbatLevelSectionHeader *st) |
28 | 0 | { |
29 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
30 | 0 | return fu_memread_uint32(st->data + 4, G_LITTLE_ENDIAN); |
31 | 0 | } |
32 | | /** |
33 | | * fu_struct_sbat_level_section_header_get_latest: (skip): |
34 | | **/ |
35 | | guint32 |
36 | | fu_struct_sbat_level_section_header_get_latest(const FuStructSbatLevelSectionHeader *st) |
37 | 0 | { |
38 | 0 | g_return_val_if_fail(st != NULL, 0x0); |
39 | 0 | return fu_memread_uint32(st->data + 8, G_LITTLE_ENDIAN); |
40 | 0 | } |
41 | | |
42 | | /* setters */ |
43 | | /** |
44 | | * fu_struct_sbat_level_section_header_set_version: (skip): |
45 | | **/ |
46 | | static void |
47 | | fu_struct_sbat_level_section_header_set_version(FuStructSbatLevelSectionHeader *st, guint32 value) |
48 | 0 | { |
49 | 0 | g_return_if_fail(st != NULL); |
50 | 0 | fu_memwrite_uint32(st->data + 0, value, G_LITTLE_ENDIAN); |
51 | 0 | } |
52 | | /** |
53 | | * fu_struct_sbat_level_section_header_set_previous: (skip): |
54 | | **/ |
55 | | void |
56 | | fu_struct_sbat_level_section_header_set_previous(FuStructSbatLevelSectionHeader *st, guint32 value) |
57 | 0 | { |
58 | 0 | g_return_if_fail(st != NULL); |
59 | 0 | fu_memwrite_uint32(st->data + 4, value, G_LITTLE_ENDIAN); |
60 | 0 | } |
61 | | /** |
62 | | * fu_struct_sbat_level_section_header_set_latest: (skip): |
63 | | **/ |
64 | | void |
65 | | fu_struct_sbat_level_section_header_set_latest(FuStructSbatLevelSectionHeader *st, guint32 value) |
66 | 0 | { |
67 | 0 | g_return_if_fail(st != NULL); |
68 | 0 | fu_memwrite_uint32(st->data + 8, value, G_LITTLE_ENDIAN); |
69 | 0 | } |
70 | | /** |
71 | | * fu_struct_sbat_level_section_header_new: (skip): |
72 | | **/ |
73 | | FuStructSbatLevelSectionHeader * |
74 | | fu_struct_sbat_level_section_header_new(void) |
75 | 0 | { |
76 | 0 | FuStructSbatLevelSectionHeader *st = g_byte_array_sized_new(12); |
77 | 0 | fu_byte_array_set_size(st, 12, 0x0); |
78 | 0 | fu_struct_sbat_level_section_header_set_version(st, 0x0); |
79 | 0 | return st; |
80 | 0 | } |
81 | | /** |
82 | | * fu_struct_sbat_level_section_header_to_string: (skip): |
83 | | **/ |
84 | | static gchar * |
85 | | fu_struct_sbat_level_section_header_to_string(const FuStructSbatLevelSectionHeader *st) |
86 | 0 | { |
87 | 0 | g_autoptr(GString) str = g_string_new("FuStructSbatLevelSectionHeader:\n"); |
88 | 0 | g_return_val_if_fail(st != NULL, NULL); |
89 | 0 | g_string_append_printf(str, " previous: 0x%x\n", |
90 | 0 | (guint) fu_struct_sbat_level_section_header_get_previous(st)); |
91 | 0 | g_string_append_printf(str, " latest: 0x%x\n", |
92 | 0 | (guint) fu_struct_sbat_level_section_header_get_latest(st)); |
93 | 0 | if (str->len > 0) |
94 | 0 | g_string_set_size(str, str->len - 1); |
95 | 0 | return g_string_free(g_steal_pointer(&str), FALSE); |
96 | 0 | } |
97 | | static gboolean |
98 | | fu_struct_sbat_level_section_header_validate_internal(FuStructSbatLevelSectionHeader *st, GError **error) |
99 | 0 | { |
100 | 0 | g_return_val_if_fail(st != NULL, FALSE); |
101 | 0 | if (fu_struct_sbat_level_section_header_get_version(st) != 0x0) { |
102 | 0 | g_set_error_literal(error, |
103 | 0 | FWUPD_ERROR, |
104 | 0 | FWUPD_ERROR_INVALID_DATA, |
105 | 0 | "constant FuStructSbatLevelSectionHeader.version was not valid"); |
106 | 0 | return FALSE; |
107 | 0 | } |
108 | 0 | return TRUE; |
109 | 0 | } |
110 | | static gboolean |
111 | | fu_struct_sbat_level_section_header_parse_internal(FuStructSbatLevelSectionHeader *st, GError **error) |
112 | 0 | { |
113 | 0 | if (!fu_struct_sbat_level_section_header_validate_internal(st, error)) |
114 | 0 | return FALSE; |
115 | 0 | if (g_getenv("FWUPD_VERBOSE") != NULL) { |
116 | 0 | g_autofree gchar *str = fu_struct_sbat_level_section_header_to_string(st); |
117 | 0 | g_debug("%s", str); |
118 | 0 | } |
119 | 0 | return TRUE; |
120 | 0 | } |
121 | | /** |
122 | | * fu_struct_sbat_level_section_header_parse_stream: (skip): |
123 | | **/ |
124 | | FuStructSbatLevelSectionHeader * |
125 | | fu_struct_sbat_level_section_header_parse_stream(GInputStream *stream, gsize offset, GError **error) |
126 | 0 | { |
127 | 0 | g_autoptr(GByteArray) st = NULL; |
128 | 0 | st = fu_input_stream_read_byte_array(stream, offset, 12, NULL, error); |
129 | 0 | if (st == NULL) { |
130 | 0 | g_prefix_error(error, "FuStructSbatLevelSectionHeader failed read of 0x%x: ", (guint) 12); |
131 | 0 | return NULL; |
132 | 0 | } |
133 | 0 | if (st->len != 12) { |
134 | 0 | g_set_error(error, |
135 | 0 | FWUPD_ERROR, |
136 | 0 | FWUPD_ERROR_INVALID_DATA, |
137 | 0 | "FuStructSbatLevelSectionHeader requested 0x%x and got 0x%x", |
138 | 0 | (guint) 12, |
139 | 0 | (guint) st->len); |
140 | 0 | return NULL; |
141 | 0 | } |
142 | 0 | if (!fu_struct_sbat_level_section_header_parse_internal(st, error)) |
143 | 0 | return NULL; |
144 | 0 | return g_steal_pointer(&st); |
145 | 0 | } |