1 #include "RecordedArg.h"
5 RecordedArg * RecordedArg_new(SetupRecordedArg SetupRecord)
26 static FreeArg Destroy_uint8;
27 static FreeArg Destroy_uint16;
28 static FreeArg Destroy_uint32;
29 static FreeArg Destroy_GString;
30 static FreeArg Destroy_p_uint8;
31 static FreeArg Destroy_p_GString;
32 static PrintArgToString Print_uint8;
33 static PrintArgToString Print_uint16;
34 static PrintArgToString Print_uint32;
35 static PrintArgToString Print_GString;
36 static PrintArgToString Print_p_uint8;
37 static PrintArgToString Print_p_GString;
38 static DoArgsMatch Match_uint8;
39 static DoArgsMatch Match_uint16;
40 static DoArgsMatch Match_uint32;
41 static DoArgsMatch Match_GString;
42 static DoArgsMatch Match_p_uint8;
43 static DoArgsMatch Match_p_GString;
44 static CheckArg_t CheckArg_uint8;
45 static CheckArg_t CheckArg_uint16;
46 static CheckArg_t CheckArg_uint32;
47 static CheckArg_t CheckArg_GString;
48 static CheckArg_t CheckArg_p_uint8;
49 static CheckArg_t CheckArg_p_GString;
50 static CheckValArgPointsTo_t CheckValArgPointsTo_p_uint8;
58 self->pArg = malloc(
sizeof(uint8_t));
59 self->Destroy = Destroy_uint8;
60 self->Print = Print_uint8;
61 self->Match = Match_uint8;
62 self->CheckArg = CheckArg_uint8;
66 self->pArg = malloc(
sizeof(uint16_t));
67 self->Destroy = Destroy_uint16;
68 self->Print = Print_uint16;
69 self->Match = Match_uint16;
70 self->CheckArg = CheckArg_uint16;
74 self->pArg = malloc(
sizeof(uint32_t));
75 self->Destroy = Destroy_uint32;
76 self->Print = Print_uint32;
77 self->Match = Match_uint32;
78 self->CheckArg = CheckArg_uint32;
82 self->pArg = malloc(
sizeof(GString));
83 self->Destroy = Destroy_GString;
84 self->Print = Print_GString;
85 self->Match = Match_GString;
86 self->CheckArg = CheckArg_GString;
90 self->pArg = malloc(
sizeof(uint8_t *));
91 self->Destroy = Destroy_p_uint8;
92 self->Print = Print_p_uint8;
93 self->Match = Match_p_uint8;
94 self->CheckArg = CheckArg_p_uint8;
95 self->CheckValArgPointsTo = CheckValArgPointsTo_p_uint8;
99 self->pArg = malloc(
sizeof(GString *));
100 self->Destroy = Destroy_p_GString;
101 self->Print = Print_p_GString;
102 self->Match = Match_p_GString;
103 self->CheckArg = CheckArg_p_GString;
110 free((uint8_t *)self->pArg);
114 free((uint16_t *)self->pArg);
118 free((uint32_t *)self->pArg);
122 g_string_free((GString *)self->pArg,
true);
126 free((uint8_t **)self->pArg);
130 free((GString **)self->pArg);
134 static void Print_uint8(GString *
string,
RecordedArg *
self)
136 g_string_printf(
string,
"(uint8_t)%#04x", *(uint8_t *)self->pArg);
138 static void Print_uint16(GString *
string,
RecordedArg *
self)
140 g_string_printf(
string,
"(uint16_t)%#06x", *(uint16_t *)self->pArg);
143 static void Print_uint32(GString *
string,
RecordedArg *
self)
145 g_string_printf(
string,
"(uint32_t)%#06x", *(uint32_t *)self->pArg);
148 static void Print_GString(GString *
string,
RecordedArg *
self)
150 g_string_printf(
string,
"(GString)%s", ((GString *)self->pArg)->str);
152 static void Print_p_uint8(GString *
string,
RecordedArg *
self)
159 g_string_printf(
string,
"(uint8_t)%#04x", **(uint8_t **)self->pArg);
164 static void Print_p_GString(GString *
string,
RecordedArg *
self)
166 g_string_printf(
string,
"(GString *)%s", (*((GString **)self->pArg))->str);
172 static bool CheckArg_uint8(
RecordedArg *argk,
void const * arg)
174 return *((uint8_t *)argk->pArg) == *((uint8_t *)arg);
177 static bool CheckArg_uint16(
RecordedArg *argk,
void const * arg)
179 return *((uint16_t *)argk->pArg) == *((uint16_t *)arg);
182 static bool CheckArg_uint32(
RecordedArg *argk,
void const * arg)
184 return *((uint32_t *)argk->pArg) == *((uint32_t *)arg);
187 static bool CheckArg_GString(
RecordedArg *argk,
void const * arg)
189 int strings_do_not_match = g_strcmp0(
190 ((GString *)argk->pArg)->str,
191 ((GString *)arg)->str
193 return strings_do_not_match ? false :
true;
196 static bool CheckArg_p_uint8(
RecordedArg *argk,
void const * arg)
198 return *((uint8_t **)argk->pArg) == *((uint8_t **)arg);
201 static bool CheckValArgPointsTo_p_uint8(
RecordedArg *argk,
void const * arg)
203 return **((uint8_t **)argk->pArg) == **((uint8_t **)arg);
206 static bool CheckArg_p_GString(
RecordedArg *argk,
void const * arg)
209 int strings_do_not_match = g_strcmp0(
210 (*((GString **)argk->pArg))->str,
211 (*((GString **)arg))->str
213 return strings_do_not_match ? false :
true;
227 return *((uint8_t *)arg1->pArg) == *((uint8_t *)arg2->pArg);
231 return *((uint16_t *)arg1->pArg) == *((uint16_t *)arg2->pArg);
235 return *((uint32_t *)arg1->pArg) == *((uint32_t *)arg2->pArg);
239 int strings_do_not_match = g_strcmp0(
240 ((GString *)arg1->pArg)->str,
241 ((GString *)arg2->pArg)->str
243 return strings_do_not_match ? false :
true;
250 return *((uint8_t **)arg1->pArg) == *((uint8_t **)arg2->pArg);
260 int strings_do_not_match = g_strcmp0(
261 (*((GString **)arg1->pArg))->str,
262 (*((GString **)arg2->pArg))->str);
263 return strings_do_not_match ? false :
true;