|
50 | 50 | }} syscall_default = {{NULL, -1, false, false, NULL, -1, 0, false, NULL, -1, 0, false, NULL, -1, 0, false, NULL, -1, 0, false, NULL, -1, 0, false, NULL, -1, 0, false, NULL, NULL}}; |
51 | 51 |
|
52 | 52 | typedef struct conf_syscall conf_syscall; |
| 53 | +const int calls_size = {CALLLEN}; |
| 54 | +conf_syscall calls[{CALLLEN}]; |
| 55 | +int finishInit = 0; |
53 | 56 |
|
54 | | -conf_syscall * |
55 | | -get_calls() {{ |
| 57 | +void get_calls() {{ |
56 | 58 | {PYSTRUCTBUILD} |
57 | | -return {FIRSTVARNAME}; |
| 59 | +finishInit = 1; |
58 | 60 | }}; |
59 | 61 | """ |
60 | 62 |
|
|
67 | 69 | "set_arg_long": '{varname}->{argname}_long = {arg};\n', |
68 | 70 | "set_arg_matchtype": '{varname}->{argname}_matchtype = {matchtype};\n', |
69 | 71 | "set_arg_isfdesc": '{varname}->{argname}_fdesc = {isfdesc};\n', |
70 | | - "set_next": "{varname}->next = {nextcall};\n", |
71 | | - "set_prev": "{varname}->prev = {prevcall};\n", |
| 72 | + "set_array": "calls[{num}] = *{varname};\n", |
72 | 73 | } |
73 | 74 |
|
74 | 75 |
|
@@ -205,39 +206,15 @@ def build_c_code(self) -> str: |
205 | 206 | i = i - 1 |
206 | 207 | c_structs = c_structs + "\n" |
207 | 208 |
|
208 | | - linked_list_setup: str = "" |
209 | | - if len(self.syscalls) == 1: |
210 | | - linked_list_setup = linked_list_setup + structbuild_template["set_next"].format(varname="call1", nextcall="NULL") |
211 | | - linked_list_setup = linked_list_setup + structbuild_template["set_prev"].format(varname="call1", prevcall="NULL") |
212 | | - else: |
213 | | - for i in range(1, len(self.syscalls) + 1): |
214 | | - if i == 1: |
215 | | - linked_list_setup = linked_list_setup + structbuild_template[ |
216 | | - "set_next" |
217 | | - ].format(varname="call" + str(i), nextcall="call" + str(i + 1)) |
218 | | - linked_list_setup = linked_list_setup + structbuild_template[ |
219 | | - "set_prev" |
220 | | - ].format(varname="call" + str(i), prevcall="NULL") |
221 | | - elif i == len(self.syscalls): |
222 | | - linked_list_setup = linked_list_setup + structbuild_template[ |
223 | | - "set_prev" |
224 | | - ].format(varname="call" + str(i), prevcall="call" + str(i - 1)) |
225 | | - linked_list_setup = linked_list_setup + structbuild_template[ |
226 | | - "set_next" |
227 | | - ].format(varname="call" + str(i), nextcall="NULL") |
228 | | - else: |
229 | | - linked_list_setup = linked_list_setup + structbuild_template[ |
230 | | - "set_prev" |
231 | | - ].format(varname="call" + str(i), prevcall="call" + str(i - 1)) |
232 | | - linked_list_setup = linked_list_setup + structbuild_template[ |
233 | | - "set_next" |
234 | | - ].format(varname="call" + str(i), nextcall="call" + str(i + 1)) |
235 | | - |
236 | | - c_structs = c_structs + linked_list_setup |
| 209 | + call_arr_setup: str = "" |
| 210 | + for i in range(0, len(self.syscalls)): |
| 211 | + call_arr_setup = call_arr_setup + structbuild_template["set_array"].format(num=str(i), varname="call"+str(i+1)) |
| 212 | + |
| 213 | + c_structs = c_structs + call_arr_setup |
237 | 214 | c_code = header_template.format( |
238 | 215 | PYLOGFILE=self.log_file, |
239 | 216 | PYSTRUCTBUILD=c_structs, |
240 | | - FIRSTVARNAME="call1", |
| 217 | + CALLLEN=len(self.syscalls), |
241 | 218 | ) |
242 | 219 | return c_code |
243 | 220 |
|
|
0 commit comments