/src/open5gs/lib/sbi/openapi/model/easdf_info.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "easdf_info.h" |
6 | | |
7 | | OpenAPI_easdf_info_t *OpenAPI_easdf_info_create( |
8 | | OpenAPI_list_t *s_nssai_easdf_info_list, |
9 | | OpenAPI_list_t *easdf_n6_ip_address_list, |
10 | | OpenAPI_list_t *upf_n6_ip_address_list, |
11 | | OpenAPI_list_t* n6_tunnel_info_list, |
12 | | OpenAPI_list_t *dns_security_protocols |
13 | | ) |
14 | 2.92k | { |
15 | 2.92k | OpenAPI_easdf_info_t *easdf_info_local_var = ogs_malloc(sizeof(OpenAPI_easdf_info_t)); |
16 | 2.92k | ogs_assert(easdf_info_local_var); |
17 | | |
18 | 2.92k | easdf_info_local_var->s_nssai_easdf_info_list = s_nssai_easdf_info_list; |
19 | 2.92k | easdf_info_local_var->easdf_n6_ip_address_list = easdf_n6_ip_address_list; |
20 | 2.92k | easdf_info_local_var->upf_n6_ip_address_list = upf_n6_ip_address_list; |
21 | 2.92k | easdf_info_local_var->n6_tunnel_info_list = n6_tunnel_info_list; |
22 | 2.92k | easdf_info_local_var->dns_security_protocols = dns_security_protocols; |
23 | | |
24 | 2.92k | return easdf_info_local_var; |
25 | 2.92k | } |
26 | | |
27 | | void OpenAPI_easdf_info_free(OpenAPI_easdf_info_t *easdf_info) |
28 | 5.05k | { |
29 | 5.05k | OpenAPI_lnode_t *node = NULL; |
30 | | |
31 | 5.05k | if (NULL == easdf_info) { |
32 | 2.12k | return; |
33 | 2.12k | } |
34 | 2.92k | if (easdf_info->s_nssai_easdf_info_list) { |
35 | 3 | OpenAPI_list_for_each(easdf_info->s_nssai_easdf_info_list, node) { |
36 | 0 | OpenAPI_snssai_easdf_info_item_free(node->data); |
37 | 0 | } |
38 | 3 | OpenAPI_list_free(easdf_info->s_nssai_easdf_info_list); |
39 | 3 | easdf_info->s_nssai_easdf_info_list = NULL; |
40 | 3 | } |
41 | 2.92k | if (easdf_info->easdf_n6_ip_address_list) { |
42 | 44 | OpenAPI_list_for_each(easdf_info->easdf_n6_ip_address_list, node) { |
43 | 44 | OpenAPI_ip_addr_free(node->data); |
44 | 44 | } |
45 | 8 | OpenAPI_list_free(easdf_info->easdf_n6_ip_address_list); |
46 | 8 | easdf_info->easdf_n6_ip_address_list = NULL; |
47 | 8 | } |
48 | 2.92k | if (easdf_info->upf_n6_ip_address_list) { |
49 | 361 | OpenAPI_list_for_each(easdf_info->upf_n6_ip_address_list, node) { |
50 | 361 | OpenAPI_ip_addr_free(node->data); |
51 | 361 | } |
52 | 292 | OpenAPI_list_free(easdf_info->upf_n6_ip_address_list); |
53 | 292 | easdf_info->upf_n6_ip_address_list = NULL; |
54 | 292 | } |
55 | 2.92k | if (easdf_info->n6_tunnel_info_list) { |
56 | 482 | OpenAPI_list_for_each(easdf_info->n6_tunnel_info_list, node) { |
57 | 482 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
58 | 482 | ogs_free(localKeyValue->key); |
59 | 482 | OpenAPI_interface_upf_info_item_free(localKeyValue->value); |
60 | 482 | OpenAPI_map_free(localKeyValue); |
61 | 482 | } |
62 | 312 | OpenAPI_list_free(easdf_info->n6_tunnel_info_list); |
63 | 312 | easdf_info->n6_tunnel_info_list = NULL; |
64 | 312 | } |
65 | 2.92k | if (easdf_info->dns_security_protocols) { |
66 | 0 | OpenAPI_list_free(easdf_info->dns_security_protocols); |
67 | 0 | easdf_info->dns_security_protocols = NULL; |
68 | 0 | } |
69 | 2.92k | ogs_free(easdf_info); |
70 | 2.92k | } |
71 | | |
72 | | cJSON *OpenAPI_easdf_info_convertToJSON(OpenAPI_easdf_info_t *easdf_info) |
73 | 0 | { |
74 | 0 | cJSON *item = NULL; |
75 | 0 | OpenAPI_lnode_t *node = NULL; |
76 | |
|
77 | 0 | if (easdf_info == NULL) { |
78 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [EasdfInfo]"); |
79 | 0 | return NULL; |
80 | 0 | } |
81 | | |
82 | 0 | item = cJSON_CreateObject(); |
83 | 0 | if (easdf_info->s_nssai_easdf_info_list) { |
84 | 0 | cJSON *s_nssai_easdf_info_listList = cJSON_AddArrayToObject(item, "sNssaiEasdfInfoList"); |
85 | 0 | if (s_nssai_easdf_info_listList == NULL) { |
86 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [s_nssai_easdf_info_list]"); |
87 | 0 | goto end; |
88 | 0 | } |
89 | 0 | OpenAPI_list_for_each(easdf_info->s_nssai_easdf_info_list, node) { |
90 | 0 | cJSON *itemLocal = OpenAPI_snssai_easdf_info_item_convertToJSON(node->data); |
91 | 0 | if (itemLocal == NULL) { |
92 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [s_nssai_easdf_info_list]"); |
93 | 0 | goto end; |
94 | 0 | } |
95 | 0 | cJSON_AddItemToArray(s_nssai_easdf_info_listList, itemLocal); |
96 | 0 | } |
97 | 0 | } |
98 | | |
99 | 0 | if (easdf_info->easdf_n6_ip_address_list) { |
100 | 0 | cJSON *easdf_n6_ip_address_listList = cJSON_AddArrayToObject(item, "easdfN6IpAddressList"); |
101 | 0 | if (easdf_n6_ip_address_listList == NULL) { |
102 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [easdf_n6_ip_address_list]"); |
103 | 0 | goto end; |
104 | 0 | } |
105 | 0 | OpenAPI_list_for_each(easdf_info->easdf_n6_ip_address_list, node) { |
106 | 0 | cJSON *itemLocal = OpenAPI_ip_addr_convertToJSON(node->data); |
107 | 0 | if (itemLocal == NULL) { |
108 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [easdf_n6_ip_address_list]"); |
109 | 0 | goto end; |
110 | 0 | } |
111 | 0 | cJSON_AddItemToArray(easdf_n6_ip_address_listList, itemLocal); |
112 | 0 | } |
113 | 0 | } |
114 | | |
115 | 0 | if (easdf_info->upf_n6_ip_address_list) { |
116 | 0 | cJSON *upf_n6_ip_address_listList = cJSON_AddArrayToObject(item, "upfN6IpAddressList"); |
117 | 0 | if (upf_n6_ip_address_listList == NULL) { |
118 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [upf_n6_ip_address_list]"); |
119 | 0 | goto end; |
120 | 0 | } |
121 | 0 | OpenAPI_list_for_each(easdf_info->upf_n6_ip_address_list, node) { |
122 | 0 | cJSON *itemLocal = OpenAPI_ip_addr_convertToJSON(node->data); |
123 | 0 | if (itemLocal == NULL) { |
124 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [upf_n6_ip_address_list]"); |
125 | 0 | goto end; |
126 | 0 | } |
127 | 0 | cJSON_AddItemToArray(upf_n6_ip_address_listList, itemLocal); |
128 | 0 | } |
129 | 0 | } |
130 | | |
131 | 0 | if (easdf_info->n6_tunnel_info_list) { |
132 | 0 | cJSON *n6_tunnel_info_list = cJSON_AddObjectToObject(item, "n6TunnelInfoList"); |
133 | 0 | if (n6_tunnel_info_list == NULL) { |
134 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [n6_tunnel_info_list]"); |
135 | 0 | goto end; |
136 | 0 | } |
137 | 0 | cJSON *localMapObject = n6_tunnel_info_list; |
138 | 0 | if (easdf_info->n6_tunnel_info_list) { |
139 | 0 | OpenAPI_list_for_each(easdf_info->n6_tunnel_info_list, node) { |
140 | 0 | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
141 | 0 | if (localKeyValue == NULL) { |
142 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [n6_tunnel_info_list]"); |
143 | 0 | goto end; |
144 | 0 | } |
145 | 0 | if (localKeyValue->key == NULL) { |
146 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [n6_tunnel_info_list]"); |
147 | 0 | goto end; |
148 | 0 | } |
149 | 0 | cJSON *itemLocal = localKeyValue->value ? |
150 | 0 | OpenAPI_interface_upf_info_item_convertToJSON(localKeyValue->value) : |
151 | 0 | cJSON_CreateNull(); |
152 | 0 | if (itemLocal == NULL) { |
153 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [inner]"); |
154 | 0 | goto end; |
155 | 0 | } |
156 | 0 | cJSON_AddItemToObject(localMapObject, localKeyValue->key, itemLocal); |
157 | 0 | } |
158 | 0 | } |
159 | 0 | } |
160 | | |
161 | 0 | if (easdf_info->dns_security_protocols != OpenAPI_dns_security_protocol_NULL) { |
162 | 0 | cJSON *dns_security_protocolsList = cJSON_AddArrayToObject(item, "dnsSecurityProtocols"); |
163 | 0 | if (dns_security_protocolsList == NULL) { |
164 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [dns_security_protocols]"); |
165 | 0 | goto end; |
166 | 0 | } |
167 | 0 | OpenAPI_list_for_each(easdf_info->dns_security_protocols, node) { |
168 | 0 | if (cJSON_AddStringToObject(dns_security_protocolsList, "", OpenAPI_dns_security_protocol_ToString((intptr_t)node->data)) == NULL) { |
169 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed [dns_security_protocols]"); |
170 | 0 | goto end; |
171 | 0 | } |
172 | 0 | } |
173 | 0 | } |
174 | | |
175 | 0 | end: |
176 | 0 | return item; |
177 | 0 | } |
178 | | |
179 | | OpenAPI_easdf_info_t *OpenAPI_easdf_info_parseFromJSON(cJSON *easdf_infoJSON) |
180 | 4.72k | { |
181 | 4.72k | OpenAPI_easdf_info_t *easdf_info_local_var = NULL; |
182 | 4.72k | OpenAPI_lnode_t *node = NULL; |
183 | 4.72k | cJSON *s_nssai_easdf_info_list = NULL; |
184 | 4.72k | OpenAPI_list_t *s_nssai_easdf_info_listList = NULL; |
185 | 4.72k | cJSON *easdf_n6_ip_address_list = NULL; |
186 | 4.72k | OpenAPI_list_t *easdf_n6_ip_address_listList = NULL; |
187 | 4.72k | cJSON *upf_n6_ip_address_list = NULL; |
188 | 4.72k | OpenAPI_list_t *upf_n6_ip_address_listList = NULL; |
189 | 4.72k | cJSON *n6_tunnel_info_list = NULL; |
190 | 4.72k | OpenAPI_list_t *n6_tunnel_info_listList = NULL; |
191 | 4.72k | cJSON *dns_security_protocols = NULL; |
192 | 4.72k | OpenAPI_list_t *dns_security_protocolsList = NULL; |
193 | 4.72k | s_nssai_easdf_info_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "sNssaiEasdfInfoList"); |
194 | 4.72k | if (s_nssai_easdf_info_list) { |
195 | 105 | cJSON *s_nssai_easdf_info_list_local = NULL; |
196 | 105 | if (!cJSON_IsArray(s_nssai_easdf_info_list)) { |
197 | 70 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [s_nssai_easdf_info_list]"); |
198 | 70 | goto end; |
199 | 70 | } |
200 | | |
201 | 35 | s_nssai_easdf_info_listList = OpenAPI_list_create(); |
202 | | |
203 | 35 | cJSON_ArrayForEach(s_nssai_easdf_info_list_local, s_nssai_easdf_info_list) { |
204 | 32 | if (!cJSON_IsObject(s_nssai_easdf_info_list_local)) { |
205 | 10 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [s_nssai_easdf_info_list]"); |
206 | 10 | goto end; |
207 | 10 | } |
208 | 22 | OpenAPI_snssai_easdf_info_item_t *s_nssai_easdf_info_listItem = OpenAPI_snssai_easdf_info_item_parseFromJSON(s_nssai_easdf_info_list_local); |
209 | 22 | if (!s_nssai_easdf_info_listItem) { |
210 | 22 | ogs_error("No s_nssai_easdf_info_listItem"); |
211 | 22 | goto end; |
212 | 22 | } |
213 | 0 | OpenAPI_list_add(s_nssai_easdf_info_listList, s_nssai_easdf_info_listItem); |
214 | 0 | } |
215 | 35 | } |
216 | | |
217 | 4.62k | easdf_n6_ip_address_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "easdfN6IpAddressList"); |
218 | 4.62k | if (easdf_n6_ip_address_list) { |
219 | 143 | cJSON *easdf_n6_ip_address_list_local = NULL; |
220 | 143 | if (!cJSON_IsArray(easdf_n6_ip_address_list)) { |
221 | 47 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [easdf_n6_ip_address_list]"); |
222 | 47 | goto end; |
223 | 47 | } |
224 | | |
225 | 96 | easdf_n6_ip_address_listList = OpenAPI_list_create(); |
226 | | |
227 | 328 | cJSON_ArrayForEach(easdf_n6_ip_address_list_local, easdf_n6_ip_address_list) { |
228 | 328 | if (!cJSON_IsObject(easdf_n6_ip_address_list_local)) { |
229 | 88 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [easdf_n6_ip_address_list]"); |
230 | 88 | goto end; |
231 | 88 | } |
232 | 240 | OpenAPI_ip_addr_t *easdf_n6_ip_address_listItem = OpenAPI_ip_addr_parseFromJSON(easdf_n6_ip_address_list_local); |
233 | 240 | if (!easdf_n6_ip_address_listItem) { |
234 | 0 | ogs_error("No easdf_n6_ip_address_listItem"); |
235 | 0 | goto end; |
236 | 0 | } |
237 | 240 | OpenAPI_list_add(easdf_n6_ip_address_listList, easdf_n6_ip_address_listItem); |
238 | 240 | } |
239 | 96 | } |
240 | | |
241 | 4.48k | upf_n6_ip_address_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "upfN6IpAddressList"); |
242 | 4.48k | if (upf_n6_ip_address_list) { |
243 | 1.50k | cJSON *upf_n6_ip_address_list_local = NULL; |
244 | 1.50k | if (!cJSON_IsArray(upf_n6_ip_address_list)) { |
245 | 199 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [upf_n6_ip_address_list]"); |
246 | 199 | goto end; |
247 | 199 | } |
248 | | |
249 | 1.31k | upf_n6_ip_address_listList = OpenAPI_list_create(); |
250 | | |
251 | 2.13k | cJSON_ArrayForEach(upf_n6_ip_address_list_local, upf_n6_ip_address_list) { |
252 | 2.13k | if (!cJSON_IsObject(upf_n6_ip_address_list_local)) { |
253 | 996 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [upf_n6_ip_address_list]"); |
254 | 996 | goto end; |
255 | 996 | } |
256 | 1.13k | OpenAPI_ip_addr_t *upf_n6_ip_address_listItem = OpenAPI_ip_addr_parseFromJSON(upf_n6_ip_address_list_local); |
257 | 1.13k | if (!upf_n6_ip_address_listItem) { |
258 | 22 | ogs_error("No upf_n6_ip_address_listItem"); |
259 | 22 | goto end; |
260 | 22 | } |
261 | 1.11k | OpenAPI_list_add(upf_n6_ip_address_listList, upf_n6_ip_address_listItem); |
262 | 1.11k | } |
263 | 1.31k | } |
264 | | |
265 | 3.26k | n6_tunnel_info_list = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "n6TunnelInfoList"); |
266 | 3.26k | if (n6_tunnel_info_list) { |
267 | 590 | cJSON *n6_tunnel_info_list_local_map = NULL; |
268 | 590 | if (!cJSON_IsObject(n6_tunnel_info_list) && !cJSON_IsNull(n6_tunnel_info_list)) { |
269 | 24 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [n6_tunnel_info_list]"); |
270 | 24 | goto end; |
271 | 24 | } |
272 | 566 | if (cJSON_IsObject(n6_tunnel_info_list)) { |
273 | 548 | n6_tunnel_info_listList = OpenAPI_list_create(); |
274 | 548 | OpenAPI_map_t *localMapKeyPair = NULL; |
275 | 1.72k | cJSON_ArrayForEach(n6_tunnel_info_list_local_map, n6_tunnel_info_list) { |
276 | 1.72k | cJSON *localMapObject = n6_tunnel_info_list_local_map; |
277 | 1.72k | if (cJSON_IsObject(localMapObject)) { |
278 | 1.20k | localMapKeyPair = OpenAPI_map_create( |
279 | 1.20k | ogs_strdup(localMapObject->string), OpenAPI_interface_upf_info_item_parseFromJSON(localMapObject)); |
280 | 1.20k | } else if (cJSON_IsNull(localMapObject)) { |
281 | 292 | localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), NULL); |
282 | 292 | } else { |
283 | 236 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [inner]"); |
284 | 236 | goto end; |
285 | 236 | } |
286 | 1.49k | if (localMapKeyPair == NULL) { |
287 | 0 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [n6_tunnel_info_list]"); |
288 | 0 | goto end; |
289 | 0 | } |
290 | 1.49k | OpenAPI_list_add(n6_tunnel_info_listList, localMapKeyPair); |
291 | 1.49k | } |
292 | 548 | } |
293 | 566 | } |
294 | | |
295 | 3.00k | dns_security_protocols = cJSON_GetObjectItemCaseSensitive(easdf_infoJSON, "dnsSecurityProtocols"); |
296 | 3.00k | if (dns_security_protocols) { |
297 | 86 | cJSON *dns_security_protocols_local = NULL; |
298 | 86 | if (!cJSON_IsArray(dns_security_protocols)) { |
299 | 68 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [dns_security_protocols]"); |
300 | 68 | goto end; |
301 | 68 | } |
302 | | |
303 | 18 | dns_security_protocolsList = OpenAPI_list_create(); |
304 | | |
305 | 18 | cJSON_ArrayForEach(dns_security_protocols_local, dns_security_protocols) { |
306 | 18 | OpenAPI_dns_security_protocol_e localEnum = OpenAPI_dns_security_protocol_NULL; |
307 | 18 | if (!cJSON_IsString(dns_security_protocols_local)) { |
308 | 18 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed [dns_security_protocols]"); |
309 | 18 | goto end; |
310 | 18 | } |
311 | 0 | localEnum = OpenAPI_dns_security_protocol_FromString(dns_security_protocols_local->valuestring); |
312 | 0 | if (!localEnum) { |
313 | 0 | ogs_info("Enum value \"%s\" for field \"dns_security_protocols\" is not supported. Ignoring it ...", |
314 | 0 | dns_security_protocols_local->valuestring); |
315 | 0 | } else { |
316 | 0 | OpenAPI_list_add(dns_security_protocolsList, (void *)localEnum); |
317 | 0 | } |
318 | 0 | } |
319 | 0 | if (dns_security_protocolsList->count == 0) { |
320 | 0 | ogs_error("OpenAPI_easdf_info_parseFromJSON() failed: Expected dns_security_protocolsList to not be empty (after ignoring unsupported enum values)."); |
321 | 0 | goto end; |
322 | 0 | } |
323 | 0 | } |
324 | | |
325 | 2.92k | easdf_info_local_var = OpenAPI_easdf_info_create ( |
326 | 2.92k | s_nssai_easdf_info_list ? s_nssai_easdf_info_listList : NULL, |
327 | 2.92k | easdf_n6_ip_address_list ? easdf_n6_ip_address_listList : NULL, |
328 | 2.92k | upf_n6_ip_address_list ? upf_n6_ip_address_listList : NULL, |
329 | 2.92k | n6_tunnel_info_list ? n6_tunnel_info_listList : NULL, |
330 | 2.92k | dns_security_protocols ? dns_security_protocolsList : NULL |
331 | 2.92k | ); |
332 | | |
333 | 2.92k | return easdf_info_local_var; |
334 | 1.80k | end: |
335 | 1.80k | if (s_nssai_easdf_info_listList) { |
336 | 32 | OpenAPI_list_for_each(s_nssai_easdf_info_listList, node) { |
337 | 0 | OpenAPI_snssai_easdf_info_item_free(node->data); |
338 | 0 | } |
339 | 32 | OpenAPI_list_free(s_nssai_easdf_info_listList); |
340 | 32 | s_nssai_easdf_info_listList = NULL; |
341 | 32 | } |
342 | 1.80k | if (easdf_n6_ip_address_listList) { |
343 | 196 | OpenAPI_list_for_each(easdf_n6_ip_address_listList, node) { |
344 | 196 | OpenAPI_ip_addr_free(node->data); |
345 | 196 | } |
346 | 88 | OpenAPI_list_free(easdf_n6_ip_address_listList); |
347 | 88 | easdf_n6_ip_address_listList = NULL; |
348 | 88 | } |
349 | 1.80k | if (upf_n6_ip_address_listList) { |
350 | 1.01k | OpenAPI_list_for_each(upf_n6_ip_address_listList, node) { |
351 | 752 | OpenAPI_ip_addr_free(node->data); |
352 | 752 | } |
353 | 1.01k | OpenAPI_list_free(upf_n6_ip_address_listList); |
354 | 1.01k | upf_n6_ip_address_listList = NULL; |
355 | 1.01k | } |
356 | 1.80k | if (n6_tunnel_info_listList) { |
357 | 1.01k | OpenAPI_list_for_each(n6_tunnel_info_listList, node) { |
358 | 1.01k | OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data; |
359 | 1.01k | ogs_free(localKeyValue->key); |
360 | 1.01k | OpenAPI_interface_upf_info_item_free(localKeyValue->value); |
361 | 1.01k | OpenAPI_map_free(localKeyValue); |
362 | 1.01k | } |
363 | 236 | OpenAPI_list_free(n6_tunnel_info_listList); |
364 | 236 | n6_tunnel_info_listList = NULL; |
365 | 236 | } |
366 | 1.80k | if (dns_security_protocolsList) { |
367 | 18 | OpenAPI_list_free(dns_security_protocolsList); |
368 | 18 | dns_security_protocolsList = NULL; |
369 | 18 | } |
370 | 1.80k | return NULL; |
371 | 3.00k | } |
372 | | |
373 | | OpenAPI_easdf_info_t *OpenAPI_easdf_info_copy(OpenAPI_easdf_info_t *dst, OpenAPI_easdf_info_t *src) |
374 | 0 | { |
375 | 0 | cJSON *item = NULL; |
376 | 0 | char *content = NULL; |
377 | |
|
378 | 0 | ogs_assert(src); |
379 | 0 | item = OpenAPI_easdf_info_convertToJSON(src); |
380 | 0 | if (!item) { |
381 | 0 | ogs_error("OpenAPI_easdf_info_convertToJSON() failed"); |
382 | 0 | return NULL; |
383 | 0 | } |
384 | | |
385 | 0 | content = cJSON_Print(item); |
386 | 0 | cJSON_Delete(item); |
387 | |
|
388 | 0 | if (!content) { |
389 | 0 | ogs_error("cJSON_Print() failed"); |
390 | 0 | return NULL; |
391 | 0 | } |
392 | | |
393 | 0 | item = cJSON_Parse(content); |
394 | 0 | ogs_free(content); |
395 | 0 | if (!item) { |
396 | 0 | ogs_error("cJSON_Parse() failed"); |
397 | 0 | return NULL; |
398 | 0 | } |
399 | | |
400 | 0 | OpenAPI_easdf_info_free(dst); |
401 | 0 | dst = OpenAPI_easdf_info_parseFromJSON(item); |
402 | 0 | cJSON_Delete(item); |
403 | |
|
404 | 0 | return dst; |
405 | 0 | } |
406 | | |