/src/open5gs/lib/sbi/openapi/model/release_data.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "release_data.h" |
6 | | |
7 | | OpenAPI_release_data_t *OpenAPI_release_data_create( |
8 | | OpenAPI_cause_e cause, |
9 | | OpenAPI_ng_ap_cause_t *ng_ap_cause, |
10 | | bool is__5g_mm_cause_value, |
11 | | int _5g_mm_cause_value, |
12 | | OpenAPI_user_location_t *ue_location, |
13 | | char *ue_time_zone, |
14 | | OpenAPI_user_location_t *add_ue_location, |
15 | | OpenAPI_list_t *secondary_rat_usage_report, |
16 | | OpenAPI_list_t *secondary_rat_usage_info, |
17 | | OpenAPI_n4_information_t *n4_info, |
18 | | OpenAPI_n4_information_t *n4_info_ext1, |
19 | | OpenAPI_n4_information_t *n4_info_ext2 |
20 | | ) |
21 | 0 | { |
22 | 0 | OpenAPI_release_data_t *release_data_local_var = ogs_malloc(sizeof(OpenAPI_release_data_t)); |
23 | 0 | ogs_assert(release_data_local_var); |
24 | | |
25 | 0 | release_data_local_var->cause = cause; |
26 | 0 | release_data_local_var->ng_ap_cause = ng_ap_cause; |
27 | 0 | release_data_local_var->is__5g_mm_cause_value = is__5g_mm_cause_value; |
28 | 0 | release_data_local_var->_5g_mm_cause_value = _5g_mm_cause_value; |
29 | 0 | release_data_local_var->ue_location = ue_location; |
30 | 0 | release_data_local_var->ue_time_zone = ue_time_zone; |
31 | 0 | release_data_local_var->add_ue_location = add_ue_location; |
32 | 0 | release_data_local_var->secondary_rat_usage_report = secondary_rat_usage_report; |
33 | 0 | release_data_local_var->secondary_rat_usage_info = secondary_rat_usage_info; |
34 | 0 | release_data_local_var->n4_info = n4_info; |
35 | 0 | release_data_local_var->n4_info_ext1 = n4_info_ext1; |
36 | 0 | release_data_local_var->n4_info_ext2 = n4_info_ext2; |
37 | |
|
38 | 0 | return release_data_local_var; |
39 | 0 | } |
40 | | |
41 | | void OpenAPI_release_data_free(OpenAPI_release_data_t *release_data) |
42 | 0 | { |
43 | 0 | OpenAPI_lnode_t *node = NULL; |
44 | |
|
45 | 0 | if (NULL == release_data) { |
46 | 0 | return; |
47 | 0 | } |
48 | 0 | if (release_data->ng_ap_cause) { |
49 | 0 | OpenAPI_ng_ap_cause_free(release_data->ng_ap_cause); |
50 | 0 | release_data->ng_ap_cause = NULL; |
51 | 0 | } |
52 | 0 | if (release_data->ue_location) { |
53 | 0 | OpenAPI_user_location_free(release_data->ue_location); |
54 | 0 | release_data->ue_location = NULL; |
55 | 0 | } |
56 | 0 | if (release_data->ue_time_zone) { |
57 | 0 | ogs_free(release_data->ue_time_zone); |
58 | 0 | release_data->ue_time_zone = NULL; |
59 | 0 | } |
60 | 0 | if (release_data->add_ue_location) { |
61 | 0 | OpenAPI_user_location_free(release_data->add_ue_location); |
62 | 0 | release_data->add_ue_location = NULL; |
63 | 0 | } |
64 | 0 | if (release_data->secondary_rat_usage_report) { |
65 | 0 | OpenAPI_list_for_each(release_data->secondary_rat_usage_report, node) { |
66 | 0 | OpenAPI_secondary_rat_usage_report_free(node->data); |
67 | 0 | } |
68 | 0 | OpenAPI_list_free(release_data->secondary_rat_usage_report); |
69 | 0 | release_data->secondary_rat_usage_report = NULL; |
70 | 0 | } |
71 | 0 | if (release_data->secondary_rat_usage_info) { |
72 | 0 | OpenAPI_list_for_each(release_data->secondary_rat_usage_info, node) { |
73 | 0 | OpenAPI_secondary_rat_usage_info_free(node->data); |
74 | 0 | } |
75 | 0 | OpenAPI_list_free(release_data->secondary_rat_usage_info); |
76 | 0 | release_data->secondary_rat_usage_info = NULL; |
77 | 0 | } |
78 | 0 | if (release_data->n4_info) { |
79 | 0 | OpenAPI_n4_information_free(release_data->n4_info); |
80 | 0 | release_data->n4_info = NULL; |
81 | 0 | } |
82 | 0 | if (release_data->n4_info_ext1) { |
83 | 0 | OpenAPI_n4_information_free(release_data->n4_info_ext1); |
84 | 0 | release_data->n4_info_ext1 = NULL; |
85 | 0 | } |
86 | 0 | if (release_data->n4_info_ext2) { |
87 | 0 | OpenAPI_n4_information_free(release_data->n4_info_ext2); |
88 | 0 | release_data->n4_info_ext2 = NULL; |
89 | 0 | } |
90 | 0 | ogs_free(release_data); |
91 | 0 | } |
92 | | |
93 | | cJSON *OpenAPI_release_data_convertToJSON(OpenAPI_release_data_t *release_data) |
94 | 0 | { |
95 | 0 | cJSON *item = NULL; |
96 | 0 | OpenAPI_lnode_t *node = NULL; |
97 | |
|
98 | 0 | if (release_data == NULL) { |
99 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [ReleaseData]"); |
100 | 0 | return NULL; |
101 | 0 | } |
102 | | |
103 | 0 | item = cJSON_CreateObject(); |
104 | 0 | if (release_data->cause != OpenAPI_cause_NULL) { |
105 | 0 | if (cJSON_AddStringToObject(item, "cause", OpenAPI_cause_ToString(release_data->cause)) == NULL) { |
106 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [cause]"); |
107 | 0 | goto end; |
108 | 0 | } |
109 | 0 | } |
110 | | |
111 | 0 | if (release_data->ng_ap_cause) { |
112 | 0 | cJSON *ng_ap_cause_local_JSON = OpenAPI_ng_ap_cause_convertToJSON(release_data->ng_ap_cause); |
113 | 0 | if (ng_ap_cause_local_JSON == NULL) { |
114 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [ng_ap_cause]"); |
115 | 0 | goto end; |
116 | 0 | } |
117 | 0 | cJSON_AddItemToObject(item, "ngApCause", ng_ap_cause_local_JSON); |
118 | 0 | if (item->child == NULL) { |
119 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [ng_ap_cause]"); |
120 | 0 | goto end; |
121 | 0 | } |
122 | 0 | } |
123 | | |
124 | 0 | if (release_data->is__5g_mm_cause_value) { |
125 | 0 | if (cJSON_AddNumberToObject(item, "5gMmCauseValue", release_data->_5g_mm_cause_value) == NULL) { |
126 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [_5g_mm_cause_value]"); |
127 | 0 | goto end; |
128 | 0 | } |
129 | 0 | } |
130 | | |
131 | 0 | if (release_data->ue_location) { |
132 | 0 | cJSON *ue_location_local_JSON = OpenAPI_user_location_convertToJSON(release_data->ue_location); |
133 | 0 | if (ue_location_local_JSON == NULL) { |
134 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [ue_location]"); |
135 | 0 | goto end; |
136 | 0 | } |
137 | 0 | cJSON_AddItemToObject(item, "ueLocation", ue_location_local_JSON); |
138 | 0 | if (item->child == NULL) { |
139 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [ue_location]"); |
140 | 0 | goto end; |
141 | 0 | } |
142 | 0 | } |
143 | | |
144 | 0 | if (release_data->ue_time_zone) { |
145 | 0 | if (cJSON_AddStringToObject(item, "ueTimeZone", release_data->ue_time_zone) == NULL) { |
146 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [ue_time_zone]"); |
147 | 0 | goto end; |
148 | 0 | } |
149 | 0 | } |
150 | | |
151 | 0 | if (release_data->add_ue_location) { |
152 | 0 | cJSON *add_ue_location_local_JSON = OpenAPI_user_location_convertToJSON(release_data->add_ue_location); |
153 | 0 | if (add_ue_location_local_JSON == NULL) { |
154 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [add_ue_location]"); |
155 | 0 | goto end; |
156 | 0 | } |
157 | 0 | cJSON_AddItemToObject(item, "addUeLocation", add_ue_location_local_JSON); |
158 | 0 | if (item->child == NULL) { |
159 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [add_ue_location]"); |
160 | 0 | goto end; |
161 | 0 | } |
162 | 0 | } |
163 | | |
164 | 0 | if (release_data->secondary_rat_usage_report) { |
165 | 0 | cJSON *secondary_rat_usage_reportList = cJSON_AddArrayToObject(item, "secondaryRatUsageReport"); |
166 | 0 | if (secondary_rat_usage_reportList == NULL) { |
167 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [secondary_rat_usage_report]"); |
168 | 0 | goto end; |
169 | 0 | } |
170 | 0 | OpenAPI_list_for_each(release_data->secondary_rat_usage_report, node) { |
171 | 0 | cJSON *itemLocal = OpenAPI_secondary_rat_usage_report_convertToJSON(node->data); |
172 | 0 | if (itemLocal == NULL) { |
173 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [secondary_rat_usage_report]"); |
174 | 0 | goto end; |
175 | 0 | } |
176 | 0 | cJSON_AddItemToArray(secondary_rat_usage_reportList, itemLocal); |
177 | 0 | } |
178 | 0 | } |
179 | | |
180 | 0 | if (release_data->secondary_rat_usage_info) { |
181 | 0 | cJSON *secondary_rat_usage_infoList = cJSON_AddArrayToObject(item, "secondaryRatUsageInfo"); |
182 | 0 | if (secondary_rat_usage_infoList == NULL) { |
183 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [secondary_rat_usage_info]"); |
184 | 0 | goto end; |
185 | 0 | } |
186 | 0 | OpenAPI_list_for_each(release_data->secondary_rat_usage_info, node) { |
187 | 0 | cJSON *itemLocal = OpenAPI_secondary_rat_usage_info_convertToJSON(node->data); |
188 | 0 | if (itemLocal == NULL) { |
189 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [secondary_rat_usage_info]"); |
190 | 0 | goto end; |
191 | 0 | } |
192 | 0 | cJSON_AddItemToArray(secondary_rat_usage_infoList, itemLocal); |
193 | 0 | } |
194 | 0 | } |
195 | | |
196 | 0 | if (release_data->n4_info) { |
197 | 0 | cJSON *n4_info_local_JSON = OpenAPI_n4_information_convertToJSON(release_data->n4_info); |
198 | 0 | if (n4_info_local_JSON == NULL) { |
199 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [n4_info]"); |
200 | 0 | goto end; |
201 | 0 | } |
202 | 0 | cJSON_AddItemToObject(item, "n4Info", n4_info_local_JSON); |
203 | 0 | if (item->child == NULL) { |
204 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [n4_info]"); |
205 | 0 | goto end; |
206 | 0 | } |
207 | 0 | } |
208 | | |
209 | 0 | if (release_data->n4_info_ext1) { |
210 | 0 | cJSON *n4_info_ext1_local_JSON = OpenAPI_n4_information_convertToJSON(release_data->n4_info_ext1); |
211 | 0 | if (n4_info_ext1_local_JSON == NULL) { |
212 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [n4_info_ext1]"); |
213 | 0 | goto end; |
214 | 0 | } |
215 | 0 | cJSON_AddItemToObject(item, "n4InfoExt1", n4_info_ext1_local_JSON); |
216 | 0 | if (item->child == NULL) { |
217 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [n4_info_ext1]"); |
218 | 0 | goto end; |
219 | 0 | } |
220 | 0 | } |
221 | | |
222 | 0 | if (release_data->n4_info_ext2) { |
223 | 0 | cJSON *n4_info_ext2_local_JSON = OpenAPI_n4_information_convertToJSON(release_data->n4_info_ext2); |
224 | 0 | if (n4_info_ext2_local_JSON == NULL) { |
225 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [n4_info_ext2]"); |
226 | 0 | goto end; |
227 | 0 | } |
228 | 0 | cJSON_AddItemToObject(item, "n4InfoExt2", n4_info_ext2_local_JSON); |
229 | 0 | if (item->child == NULL) { |
230 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed [n4_info_ext2]"); |
231 | 0 | goto end; |
232 | 0 | } |
233 | 0 | } |
234 | | |
235 | 0 | end: |
236 | 0 | return item; |
237 | 0 | } |
238 | | |
239 | | OpenAPI_release_data_t *OpenAPI_release_data_parseFromJSON(cJSON *release_dataJSON) |
240 | 0 | { |
241 | 0 | OpenAPI_release_data_t *release_data_local_var = NULL; |
242 | 0 | OpenAPI_lnode_t *node = NULL; |
243 | 0 | cJSON *cause = NULL; |
244 | 0 | OpenAPI_cause_e causeVariable = 0; |
245 | 0 | cJSON *ng_ap_cause = NULL; |
246 | 0 | OpenAPI_ng_ap_cause_t *ng_ap_cause_local_nonprim = NULL; |
247 | 0 | cJSON *_5g_mm_cause_value = NULL; |
248 | 0 | cJSON *ue_location = NULL; |
249 | 0 | OpenAPI_user_location_t *ue_location_local_nonprim = NULL; |
250 | 0 | cJSON *ue_time_zone = NULL; |
251 | 0 | cJSON *add_ue_location = NULL; |
252 | 0 | OpenAPI_user_location_t *add_ue_location_local_nonprim = NULL; |
253 | 0 | cJSON *secondary_rat_usage_report = NULL; |
254 | 0 | OpenAPI_list_t *secondary_rat_usage_reportList = NULL; |
255 | 0 | cJSON *secondary_rat_usage_info = NULL; |
256 | 0 | OpenAPI_list_t *secondary_rat_usage_infoList = NULL; |
257 | 0 | cJSON *n4_info = NULL; |
258 | 0 | OpenAPI_n4_information_t *n4_info_local_nonprim = NULL; |
259 | 0 | cJSON *n4_info_ext1 = NULL; |
260 | 0 | OpenAPI_n4_information_t *n4_info_ext1_local_nonprim = NULL; |
261 | 0 | cJSON *n4_info_ext2 = NULL; |
262 | 0 | OpenAPI_n4_information_t *n4_info_ext2_local_nonprim = NULL; |
263 | 0 | cause = cJSON_GetObjectItemCaseSensitive(release_dataJSON, "cause"); |
264 | 0 | if (cause) { |
265 | 0 | if (!cJSON_IsString(cause)) { |
266 | 0 | ogs_error("OpenAPI_release_data_parseFromJSON() failed [cause]"); |
267 | 0 | goto end; |
268 | 0 | } |
269 | 0 | causeVariable = OpenAPI_cause_FromString(cause->valuestring); |
270 | 0 | } |
271 | | |
272 | 0 | ng_ap_cause = cJSON_GetObjectItemCaseSensitive(release_dataJSON, "ngApCause"); |
273 | 0 | if (ng_ap_cause) { |
274 | 0 | ng_ap_cause_local_nonprim = OpenAPI_ng_ap_cause_parseFromJSON(ng_ap_cause); |
275 | 0 | if (!ng_ap_cause_local_nonprim) { |
276 | 0 | ogs_error("OpenAPI_ng_ap_cause_parseFromJSON failed [ng_ap_cause]"); |
277 | 0 | goto end; |
278 | 0 | } |
279 | 0 | } |
280 | | |
281 | 0 | _5g_mm_cause_value = cJSON_GetObjectItemCaseSensitive(release_dataJSON, "5gMmCauseValue"); |
282 | 0 | if (_5g_mm_cause_value) { |
283 | 0 | if (!cJSON_IsNumber(_5g_mm_cause_value)) { |
284 | 0 | ogs_error("OpenAPI_release_data_parseFromJSON() failed [_5g_mm_cause_value]"); |
285 | 0 | goto end; |
286 | 0 | } |
287 | 0 | } |
288 | | |
289 | 0 | ue_location = cJSON_GetObjectItemCaseSensitive(release_dataJSON, "ueLocation"); |
290 | 0 | if (ue_location) { |
291 | 0 | ue_location_local_nonprim = OpenAPI_user_location_parseFromJSON(ue_location); |
292 | 0 | if (!ue_location_local_nonprim) { |
293 | 0 | ogs_error("OpenAPI_user_location_parseFromJSON failed [ue_location]"); |
294 | 0 | goto end; |
295 | 0 | } |
296 | 0 | } |
297 | | |
298 | 0 | ue_time_zone = cJSON_GetObjectItemCaseSensitive(release_dataJSON, "ueTimeZone"); |
299 | 0 | if (ue_time_zone) { |
300 | 0 | if (!cJSON_IsString(ue_time_zone) && !cJSON_IsNull(ue_time_zone)) { |
301 | 0 | ogs_error("OpenAPI_release_data_parseFromJSON() failed [ue_time_zone]"); |
302 | 0 | goto end; |
303 | 0 | } |
304 | 0 | } |
305 | | |
306 | 0 | add_ue_location = cJSON_GetObjectItemCaseSensitive(release_dataJSON, "addUeLocation"); |
307 | 0 | if (add_ue_location) { |
308 | 0 | add_ue_location_local_nonprim = OpenAPI_user_location_parseFromJSON(add_ue_location); |
309 | 0 | if (!add_ue_location_local_nonprim) { |
310 | 0 | ogs_error("OpenAPI_user_location_parseFromJSON failed [add_ue_location]"); |
311 | 0 | goto end; |
312 | 0 | } |
313 | 0 | } |
314 | | |
315 | 0 | secondary_rat_usage_report = cJSON_GetObjectItemCaseSensitive(release_dataJSON, "secondaryRatUsageReport"); |
316 | 0 | if (secondary_rat_usage_report) { |
317 | 0 | cJSON *secondary_rat_usage_report_local = NULL; |
318 | 0 | if (!cJSON_IsArray(secondary_rat_usage_report)) { |
319 | 0 | ogs_error("OpenAPI_release_data_parseFromJSON() failed [secondary_rat_usage_report]"); |
320 | 0 | goto end; |
321 | 0 | } |
322 | | |
323 | 0 | secondary_rat_usage_reportList = OpenAPI_list_create(); |
324 | |
|
325 | 0 | cJSON_ArrayForEach(secondary_rat_usage_report_local, secondary_rat_usage_report) { |
326 | 0 | if (!cJSON_IsObject(secondary_rat_usage_report_local)) { |
327 | 0 | ogs_error("OpenAPI_release_data_parseFromJSON() failed [secondary_rat_usage_report]"); |
328 | 0 | goto end; |
329 | 0 | } |
330 | 0 | OpenAPI_secondary_rat_usage_report_t *secondary_rat_usage_reportItem = OpenAPI_secondary_rat_usage_report_parseFromJSON(secondary_rat_usage_report_local); |
331 | 0 | if (!secondary_rat_usage_reportItem) { |
332 | 0 | ogs_error("No secondary_rat_usage_reportItem"); |
333 | 0 | goto end; |
334 | 0 | } |
335 | 0 | OpenAPI_list_add(secondary_rat_usage_reportList, secondary_rat_usage_reportItem); |
336 | 0 | } |
337 | 0 | } |
338 | | |
339 | 0 | secondary_rat_usage_info = cJSON_GetObjectItemCaseSensitive(release_dataJSON, "secondaryRatUsageInfo"); |
340 | 0 | if (secondary_rat_usage_info) { |
341 | 0 | cJSON *secondary_rat_usage_info_local = NULL; |
342 | 0 | if (!cJSON_IsArray(secondary_rat_usage_info)) { |
343 | 0 | ogs_error("OpenAPI_release_data_parseFromJSON() failed [secondary_rat_usage_info]"); |
344 | 0 | goto end; |
345 | 0 | } |
346 | | |
347 | 0 | secondary_rat_usage_infoList = OpenAPI_list_create(); |
348 | |
|
349 | 0 | cJSON_ArrayForEach(secondary_rat_usage_info_local, secondary_rat_usage_info) { |
350 | 0 | if (!cJSON_IsObject(secondary_rat_usage_info_local)) { |
351 | 0 | ogs_error("OpenAPI_release_data_parseFromJSON() failed [secondary_rat_usage_info]"); |
352 | 0 | goto end; |
353 | 0 | } |
354 | 0 | OpenAPI_secondary_rat_usage_info_t *secondary_rat_usage_infoItem = OpenAPI_secondary_rat_usage_info_parseFromJSON(secondary_rat_usage_info_local); |
355 | 0 | if (!secondary_rat_usage_infoItem) { |
356 | 0 | ogs_error("No secondary_rat_usage_infoItem"); |
357 | 0 | goto end; |
358 | 0 | } |
359 | 0 | OpenAPI_list_add(secondary_rat_usage_infoList, secondary_rat_usage_infoItem); |
360 | 0 | } |
361 | 0 | } |
362 | | |
363 | 0 | n4_info = cJSON_GetObjectItemCaseSensitive(release_dataJSON, "n4Info"); |
364 | 0 | if (n4_info) { |
365 | 0 | n4_info_local_nonprim = OpenAPI_n4_information_parseFromJSON(n4_info); |
366 | 0 | if (!n4_info_local_nonprim) { |
367 | 0 | ogs_error("OpenAPI_n4_information_parseFromJSON failed [n4_info]"); |
368 | 0 | goto end; |
369 | 0 | } |
370 | 0 | } |
371 | | |
372 | 0 | n4_info_ext1 = cJSON_GetObjectItemCaseSensitive(release_dataJSON, "n4InfoExt1"); |
373 | 0 | if (n4_info_ext1) { |
374 | 0 | n4_info_ext1_local_nonprim = OpenAPI_n4_information_parseFromJSON(n4_info_ext1); |
375 | 0 | if (!n4_info_ext1_local_nonprim) { |
376 | 0 | ogs_error("OpenAPI_n4_information_parseFromJSON failed [n4_info_ext1]"); |
377 | 0 | goto end; |
378 | 0 | } |
379 | 0 | } |
380 | | |
381 | 0 | n4_info_ext2 = cJSON_GetObjectItemCaseSensitive(release_dataJSON, "n4InfoExt2"); |
382 | 0 | if (n4_info_ext2) { |
383 | 0 | n4_info_ext2_local_nonprim = OpenAPI_n4_information_parseFromJSON(n4_info_ext2); |
384 | 0 | if (!n4_info_ext2_local_nonprim) { |
385 | 0 | ogs_error("OpenAPI_n4_information_parseFromJSON failed [n4_info_ext2]"); |
386 | 0 | goto end; |
387 | 0 | } |
388 | 0 | } |
389 | | |
390 | 0 | release_data_local_var = OpenAPI_release_data_create ( |
391 | 0 | cause ? causeVariable : 0, |
392 | 0 | ng_ap_cause ? ng_ap_cause_local_nonprim : NULL, |
393 | 0 | _5g_mm_cause_value ? true : false, |
394 | 0 | _5g_mm_cause_value ? _5g_mm_cause_value->valuedouble : 0, |
395 | 0 | ue_location ? ue_location_local_nonprim : NULL, |
396 | 0 | ue_time_zone && !cJSON_IsNull(ue_time_zone) ? ogs_strdup(ue_time_zone->valuestring) : NULL, |
397 | 0 | add_ue_location ? add_ue_location_local_nonprim : NULL, |
398 | 0 | secondary_rat_usage_report ? secondary_rat_usage_reportList : NULL, |
399 | 0 | secondary_rat_usage_info ? secondary_rat_usage_infoList : NULL, |
400 | 0 | n4_info ? n4_info_local_nonprim : NULL, |
401 | 0 | n4_info_ext1 ? n4_info_ext1_local_nonprim : NULL, |
402 | 0 | n4_info_ext2 ? n4_info_ext2_local_nonprim : NULL |
403 | 0 | ); |
404 | |
|
405 | 0 | return release_data_local_var; |
406 | 0 | end: |
407 | 0 | if (ng_ap_cause_local_nonprim) { |
408 | 0 | OpenAPI_ng_ap_cause_free(ng_ap_cause_local_nonprim); |
409 | 0 | ng_ap_cause_local_nonprim = NULL; |
410 | 0 | } |
411 | 0 | if (ue_location_local_nonprim) { |
412 | 0 | OpenAPI_user_location_free(ue_location_local_nonprim); |
413 | 0 | ue_location_local_nonprim = NULL; |
414 | 0 | } |
415 | 0 | if (add_ue_location_local_nonprim) { |
416 | 0 | OpenAPI_user_location_free(add_ue_location_local_nonprim); |
417 | 0 | add_ue_location_local_nonprim = NULL; |
418 | 0 | } |
419 | 0 | if (secondary_rat_usage_reportList) { |
420 | 0 | OpenAPI_list_for_each(secondary_rat_usage_reportList, node) { |
421 | 0 | OpenAPI_secondary_rat_usage_report_free(node->data); |
422 | 0 | } |
423 | 0 | OpenAPI_list_free(secondary_rat_usage_reportList); |
424 | 0 | secondary_rat_usage_reportList = NULL; |
425 | 0 | } |
426 | 0 | if (secondary_rat_usage_infoList) { |
427 | 0 | OpenAPI_list_for_each(secondary_rat_usage_infoList, node) { |
428 | 0 | OpenAPI_secondary_rat_usage_info_free(node->data); |
429 | 0 | } |
430 | 0 | OpenAPI_list_free(secondary_rat_usage_infoList); |
431 | 0 | secondary_rat_usage_infoList = NULL; |
432 | 0 | } |
433 | 0 | if (n4_info_local_nonprim) { |
434 | 0 | OpenAPI_n4_information_free(n4_info_local_nonprim); |
435 | 0 | n4_info_local_nonprim = NULL; |
436 | 0 | } |
437 | 0 | if (n4_info_ext1_local_nonprim) { |
438 | 0 | OpenAPI_n4_information_free(n4_info_ext1_local_nonprim); |
439 | 0 | n4_info_ext1_local_nonprim = NULL; |
440 | 0 | } |
441 | 0 | if (n4_info_ext2_local_nonprim) { |
442 | 0 | OpenAPI_n4_information_free(n4_info_ext2_local_nonprim); |
443 | 0 | n4_info_ext2_local_nonprim = NULL; |
444 | 0 | } |
445 | 0 | return NULL; |
446 | 0 | } |
447 | | |
448 | | OpenAPI_release_data_t *OpenAPI_release_data_copy(OpenAPI_release_data_t *dst, OpenAPI_release_data_t *src) |
449 | 0 | { |
450 | 0 | cJSON *item = NULL; |
451 | 0 | char *content = NULL; |
452 | |
|
453 | 0 | ogs_assert(src); |
454 | 0 | item = OpenAPI_release_data_convertToJSON(src); |
455 | 0 | if (!item) { |
456 | 0 | ogs_error("OpenAPI_release_data_convertToJSON() failed"); |
457 | 0 | return NULL; |
458 | 0 | } |
459 | | |
460 | 0 | content = cJSON_Print(item); |
461 | 0 | cJSON_Delete(item); |
462 | |
|
463 | 0 | if (!content) { |
464 | 0 | ogs_error("cJSON_Print() failed"); |
465 | 0 | return NULL; |
466 | 0 | } |
467 | | |
468 | 0 | item = cJSON_Parse(content); |
469 | 0 | ogs_free(content); |
470 | 0 | if (!item) { |
471 | 0 | ogs_error("cJSON_Parse() failed"); |
472 | 0 | return NULL; |
473 | 0 | } |
474 | | |
475 | 0 | OpenAPI_release_data_free(dst); |
476 | 0 | dst = OpenAPI_release_data_parseFromJSON(item); |
477 | 0 | cJSON_Delete(item); |
478 | |
|
479 | 0 | return dst; |
480 | 0 | } |
481 | | |