/src/open5gs/lib/sbi/openapi/model/presence_info.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "presence_info.h" |
6 | | |
7 | | OpenAPI_presence_info_t *OpenAPI_presence_info_create( |
8 | | char *pra_id, |
9 | | char *additional_pra_id, |
10 | | OpenAPI_presence_state_e presence_state, |
11 | | OpenAPI_list_t *tracking_area_list, |
12 | | OpenAPI_list_t *ecgi_list, |
13 | | OpenAPI_list_t *ncgi_list, |
14 | | OpenAPI_list_t *global_ran_node_id_list, |
15 | | OpenAPI_list_t *globale_nb_id_list |
16 | | ) |
17 | 0 | { |
18 | 0 | OpenAPI_presence_info_t *presence_info_local_var = ogs_malloc(sizeof(OpenAPI_presence_info_t)); |
19 | 0 | ogs_assert(presence_info_local_var); |
20 | | |
21 | 0 | presence_info_local_var->pra_id = pra_id; |
22 | 0 | presence_info_local_var->additional_pra_id = additional_pra_id; |
23 | 0 | presence_info_local_var->presence_state = presence_state; |
24 | 0 | presence_info_local_var->tracking_area_list = tracking_area_list; |
25 | 0 | presence_info_local_var->ecgi_list = ecgi_list; |
26 | 0 | presence_info_local_var->ncgi_list = ncgi_list; |
27 | 0 | presence_info_local_var->global_ran_node_id_list = global_ran_node_id_list; |
28 | 0 | presence_info_local_var->globale_nb_id_list = globale_nb_id_list; |
29 | |
|
30 | 0 | return presence_info_local_var; |
31 | 0 | } |
32 | | |
33 | | void OpenAPI_presence_info_free(OpenAPI_presence_info_t *presence_info) |
34 | 0 | { |
35 | 0 | OpenAPI_lnode_t *node = NULL; |
36 | |
|
37 | 0 | if (NULL == presence_info) { |
38 | 0 | return; |
39 | 0 | } |
40 | 0 | if (presence_info->pra_id) { |
41 | 0 | ogs_free(presence_info->pra_id); |
42 | 0 | presence_info->pra_id = NULL; |
43 | 0 | } |
44 | 0 | if (presence_info->additional_pra_id) { |
45 | 0 | ogs_free(presence_info->additional_pra_id); |
46 | 0 | presence_info->additional_pra_id = NULL; |
47 | 0 | } |
48 | 0 | if (presence_info->tracking_area_list) { |
49 | 0 | OpenAPI_list_for_each(presence_info->tracking_area_list, node) { |
50 | 0 | OpenAPI_tai_free(node->data); |
51 | 0 | } |
52 | 0 | OpenAPI_list_free(presence_info->tracking_area_list); |
53 | 0 | presence_info->tracking_area_list = NULL; |
54 | 0 | } |
55 | 0 | if (presence_info->ecgi_list) { |
56 | 0 | OpenAPI_list_for_each(presence_info->ecgi_list, node) { |
57 | 0 | OpenAPI_ecgi_free(node->data); |
58 | 0 | } |
59 | 0 | OpenAPI_list_free(presence_info->ecgi_list); |
60 | 0 | presence_info->ecgi_list = NULL; |
61 | 0 | } |
62 | 0 | if (presence_info->ncgi_list) { |
63 | 0 | OpenAPI_list_for_each(presence_info->ncgi_list, node) { |
64 | 0 | OpenAPI_ncgi_free(node->data); |
65 | 0 | } |
66 | 0 | OpenAPI_list_free(presence_info->ncgi_list); |
67 | 0 | presence_info->ncgi_list = NULL; |
68 | 0 | } |
69 | 0 | if (presence_info->global_ran_node_id_list) { |
70 | 0 | OpenAPI_list_for_each(presence_info->global_ran_node_id_list, node) { |
71 | 0 | OpenAPI_global_ran_node_id_free(node->data); |
72 | 0 | } |
73 | 0 | OpenAPI_list_free(presence_info->global_ran_node_id_list); |
74 | 0 | presence_info->global_ran_node_id_list = NULL; |
75 | 0 | } |
76 | 0 | if (presence_info->globale_nb_id_list) { |
77 | 0 | OpenAPI_list_for_each(presence_info->globale_nb_id_list, node) { |
78 | 0 | OpenAPI_global_ran_node_id_free(node->data); |
79 | 0 | } |
80 | 0 | OpenAPI_list_free(presence_info->globale_nb_id_list); |
81 | 0 | presence_info->globale_nb_id_list = NULL; |
82 | 0 | } |
83 | 0 | ogs_free(presence_info); |
84 | 0 | } |
85 | | |
86 | | cJSON *OpenAPI_presence_info_convertToJSON(OpenAPI_presence_info_t *presence_info) |
87 | 0 | { |
88 | 0 | cJSON *item = NULL; |
89 | 0 | OpenAPI_lnode_t *node = NULL; |
90 | |
|
91 | 0 | if (presence_info == NULL) { |
92 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [PresenceInfo]"); |
93 | 0 | return NULL; |
94 | 0 | } |
95 | | |
96 | 0 | item = cJSON_CreateObject(); |
97 | 0 | if (presence_info->pra_id) { |
98 | 0 | if (cJSON_AddStringToObject(item, "praId", presence_info->pra_id) == NULL) { |
99 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [pra_id]"); |
100 | 0 | goto end; |
101 | 0 | } |
102 | 0 | } |
103 | | |
104 | 0 | if (presence_info->additional_pra_id) { |
105 | 0 | if (cJSON_AddStringToObject(item, "additionalPraId", presence_info->additional_pra_id) == NULL) { |
106 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [additional_pra_id]"); |
107 | 0 | goto end; |
108 | 0 | } |
109 | 0 | } |
110 | | |
111 | 0 | if (presence_info->presence_state != OpenAPI_presence_state_NULL) { |
112 | 0 | if (cJSON_AddStringToObject(item, "presenceState", OpenAPI_presence_state_ToString(presence_info->presence_state)) == NULL) { |
113 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [presence_state]"); |
114 | 0 | goto end; |
115 | 0 | } |
116 | 0 | } |
117 | | |
118 | 0 | if (presence_info->tracking_area_list) { |
119 | 0 | cJSON *tracking_area_listList = cJSON_AddArrayToObject(item, "trackingAreaList"); |
120 | 0 | if (tracking_area_listList == NULL) { |
121 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [tracking_area_list]"); |
122 | 0 | goto end; |
123 | 0 | } |
124 | 0 | OpenAPI_list_for_each(presence_info->tracking_area_list, node) { |
125 | 0 | cJSON *itemLocal = OpenAPI_tai_convertToJSON(node->data); |
126 | 0 | if (itemLocal == NULL) { |
127 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [tracking_area_list]"); |
128 | 0 | goto end; |
129 | 0 | } |
130 | 0 | cJSON_AddItemToArray(tracking_area_listList, itemLocal); |
131 | 0 | } |
132 | 0 | } |
133 | | |
134 | 0 | if (presence_info->ecgi_list) { |
135 | 0 | cJSON *ecgi_listList = cJSON_AddArrayToObject(item, "ecgiList"); |
136 | 0 | if (ecgi_listList == NULL) { |
137 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [ecgi_list]"); |
138 | 0 | goto end; |
139 | 0 | } |
140 | 0 | OpenAPI_list_for_each(presence_info->ecgi_list, node) { |
141 | 0 | cJSON *itemLocal = OpenAPI_ecgi_convertToJSON(node->data); |
142 | 0 | if (itemLocal == NULL) { |
143 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [ecgi_list]"); |
144 | 0 | goto end; |
145 | 0 | } |
146 | 0 | cJSON_AddItemToArray(ecgi_listList, itemLocal); |
147 | 0 | } |
148 | 0 | } |
149 | | |
150 | 0 | if (presence_info->ncgi_list) { |
151 | 0 | cJSON *ncgi_listList = cJSON_AddArrayToObject(item, "ncgiList"); |
152 | 0 | if (ncgi_listList == NULL) { |
153 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [ncgi_list]"); |
154 | 0 | goto end; |
155 | 0 | } |
156 | 0 | OpenAPI_list_for_each(presence_info->ncgi_list, node) { |
157 | 0 | cJSON *itemLocal = OpenAPI_ncgi_convertToJSON(node->data); |
158 | 0 | if (itemLocal == NULL) { |
159 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [ncgi_list]"); |
160 | 0 | goto end; |
161 | 0 | } |
162 | 0 | cJSON_AddItemToArray(ncgi_listList, itemLocal); |
163 | 0 | } |
164 | 0 | } |
165 | | |
166 | 0 | if (presence_info->global_ran_node_id_list) { |
167 | 0 | cJSON *global_ran_node_id_listList = cJSON_AddArrayToObject(item, "globalRanNodeIdList"); |
168 | 0 | if (global_ran_node_id_listList == NULL) { |
169 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [global_ran_node_id_list]"); |
170 | 0 | goto end; |
171 | 0 | } |
172 | 0 | OpenAPI_list_for_each(presence_info->global_ran_node_id_list, node) { |
173 | 0 | cJSON *itemLocal = OpenAPI_global_ran_node_id_convertToJSON(node->data); |
174 | 0 | if (itemLocal == NULL) { |
175 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [global_ran_node_id_list]"); |
176 | 0 | goto end; |
177 | 0 | } |
178 | 0 | cJSON_AddItemToArray(global_ran_node_id_listList, itemLocal); |
179 | 0 | } |
180 | 0 | } |
181 | | |
182 | 0 | if (presence_info->globale_nb_id_list) { |
183 | 0 | cJSON *globale_nb_id_listList = cJSON_AddArrayToObject(item, "globaleNbIdList"); |
184 | 0 | if (globale_nb_id_listList == NULL) { |
185 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [globale_nb_id_list]"); |
186 | 0 | goto end; |
187 | 0 | } |
188 | 0 | OpenAPI_list_for_each(presence_info->globale_nb_id_list, node) { |
189 | 0 | cJSON *itemLocal = OpenAPI_global_ran_node_id_convertToJSON(node->data); |
190 | 0 | if (itemLocal == NULL) { |
191 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed [globale_nb_id_list]"); |
192 | 0 | goto end; |
193 | 0 | } |
194 | 0 | cJSON_AddItemToArray(globale_nb_id_listList, itemLocal); |
195 | 0 | } |
196 | 0 | } |
197 | | |
198 | 0 | end: |
199 | 0 | return item; |
200 | 0 | } |
201 | | |
202 | | OpenAPI_presence_info_t *OpenAPI_presence_info_parseFromJSON(cJSON *presence_infoJSON) |
203 | 0 | { |
204 | 0 | OpenAPI_presence_info_t *presence_info_local_var = NULL; |
205 | 0 | OpenAPI_lnode_t *node = NULL; |
206 | 0 | cJSON *pra_id = NULL; |
207 | 0 | cJSON *additional_pra_id = NULL; |
208 | 0 | cJSON *presence_state = NULL; |
209 | 0 | OpenAPI_presence_state_e presence_stateVariable = 0; |
210 | 0 | cJSON *tracking_area_list = NULL; |
211 | 0 | OpenAPI_list_t *tracking_area_listList = NULL; |
212 | 0 | cJSON *ecgi_list = NULL; |
213 | 0 | OpenAPI_list_t *ecgi_listList = NULL; |
214 | 0 | cJSON *ncgi_list = NULL; |
215 | 0 | OpenAPI_list_t *ncgi_listList = NULL; |
216 | 0 | cJSON *global_ran_node_id_list = NULL; |
217 | 0 | OpenAPI_list_t *global_ran_node_id_listList = NULL; |
218 | 0 | cJSON *globale_nb_id_list = NULL; |
219 | 0 | OpenAPI_list_t *globale_nb_id_listList = NULL; |
220 | 0 | pra_id = cJSON_GetObjectItemCaseSensitive(presence_infoJSON, "praId"); |
221 | 0 | if (pra_id) { |
222 | 0 | if (!cJSON_IsString(pra_id) && !cJSON_IsNull(pra_id)) { |
223 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [pra_id]"); |
224 | 0 | goto end; |
225 | 0 | } |
226 | 0 | } |
227 | | |
228 | 0 | additional_pra_id = cJSON_GetObjectItemCaseSensitive(presence_infoJSON, "additionalPraId"); |
229 | 0 | if (additional_pra_id) { |
230 | 0 | if (!cJSON_IsString(additional_pra_id) && !cJSON_IsNull(additional_pra_id)) { |
231 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [additional_pra_id]"); |
232 | 0 | goto end; |
233 | 0 | } |
234 | 0 | } |
235 | | |
236 | 0 | presence_state = cJSON_GetObjectItemCaseSensitive(presence_infoJSON, "presenceState"); |
237 | 0 | if (presence_state) { |
238 | 0 | if (!cJSON_IsString(presence_state)) { |
239 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [presence_state]"); |
240 | 0 | goto end; |
241 | 0 | } |
242 | 0 | presence_stateVariable = OpenAPI_presence_state_FromString(presence_state->valuestring); |
243 | 0 | } |
244 | | |
245 | 0 | tracking_area_list = cJSON_GetObjectItemCaseSensitive(presence_infoJSON, "trackingAreaList"); |
246 | 0 | if (tracking_area_list) { |
247 | 0 | cJSON *tracking_area_list_local = NULL; |
248 | 0 | if (!cJSON_IsArray(tracking_area_list)) { |
249 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [tracking_area_list]"); |
250 | 0 | goto end; |
251 | 0 | } |
252 | | |
253 | 0 | tracking_area_listList = OpenAPI_list_create(); |
254 | |
|
255 | 0 | cJSON_ArrayForEach(tracking_area_list_local, tracking_area_list) { |
256 | 0 | if (!cJSON_IsObject(tracking_area_list_local)) { |
257 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [tracking_area_list]"); |
258 | 0 | goto end; |
259 | 0 | } |
260 | 0 | OpenAPI_tai_t *tracking_area_listItem = OpenAPI_tai_parseFromJSON(tracking_area_list_local); |
261 | 0 | if (!tracking_area_listItem) { |
262 | 0 | ogs_error("No tracking_area_listItem"); |
263 | 0 | goto end; |
264 | 0 | } |
265 | 0 | OpenAPI_list_add(tracking_area_listList, tracking_area_listItem); |
266 | 0 | } |
267 | 0 | } |
268 | | |
269 | 0 | ecgi_list = cJSON_GetObjectItemCaseSensitive(presence_infoJSON, "ecgiList"); |
270 | 0 | if (ecgi_list) { |
271 | 0 | cJSON *ecgi_list_local = NULL; |
272 | 0 | if (!cJSON_IsArray(ecgi_list)) { |
273 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [ecgi_list]"); |
274 | 0 | goto end; |
275 | 0 | } |
276 | | |
277 | 0 | ecgi_listList = OpenAPI_list_create(); |
278 | |
|
279 | 0 | cJSON_ArrayForEach(ecgi_list_local, ecgi_list) { |
280 | 0 | if (!cJSON_IsObject(ecgi_list_local)) { |
281 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [ecgi_list]"); |
282 | 0 | goto end; |
283 | 0 | } |
284 | 0 | OpenAPI_ecgi_t *ecgi_listItem = OpenAPI_ecgi_parseFromJSON(ecgi_list_local); |
285 | 0 | if (!ecgi_listItem) { |
286 | 0 | ogs_error("No ecgi_listItem"); |
287 | 0 | goto end; |
288 | 0 | } |
289 | 0 | OpenAPI_list_add(ecgi_listList, ecgi_listItem); |
290 | 0 | } |
291 | 0 | } |
292 | | |
293 | 0 | ncgi_list = cJSON_GetObjectItemCaseSensitive(presence_infoJSON, "ncgiList"); |
294 | 0 | if (ncgi_list) { |
295 | 0 | cJSON *ncgi_list_local = NULL; |
296 | 0 | if (!cJSON_IsArray(ncgi_list)) { |
297 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [ncgi_list]"); |
298 | 0 | goto end; |
299 | 0 | } |
300 | | |
301 | 0 | ncgi_listList = OpenAPI_list_create(); |
302 | |
|
303 | 0 | cJSON_ArrayForEach(ncgi_list_local, ncgi_list) { |
304 | 0 | if (!cJSON_IsObject(ncgi_list_local)) { |
305 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [ncgi_list]"); |
306 | 0 | goto end; |
307 | 0 | } |
308 | 0 | OpenAPI_ncgi_t *ncgi_listItem = OpenAPI_ncgi_parseFromJSON(ncgi_list_local); |
309 | 0 | if (!ncgi_listItem) { |
310 | 0 | ogs_error("No ncgi_listItem"); |
311 | 0 | goto end; |
312 | 0 | } |
313 | 0 | OpenAPI_list_add(ncgi_listList, ncgi_listItem); |
314 | 0 | } |
315 | 0 | } |
316 | | |
317 | 0 | global_ran_node_id_list = cJSON_GetObjectItemCaseSensitive(presence_infoJSON, "globalRanNodeIdList"); |
318 | 0 | if (global_ran_node_id_list) { |
319 | 0 | cJSON *global_ran_node_id_list_local = NULL; |
320 | 0 | if (!cJSON_IsArray(global_ran_node_id_list)) { |
321 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [global_ran_node_id_list]"); |
322 | 0 | goto end; |
323 | 0 | } |
324 | | |
325 | 0 | global_ran_node_id_listList = OpenAPI_list_create(); |
326 | |
|
327 | 0 | cJSON_ArrayForEach(global_ran_node_id_list_local, global_ran_node_id_list) { |
328 | 0 | if (!cJSON_IsObject(global_ran_node_id_list_local)) { |
329 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [global_ran_node_id_list]"); |
330 | 0 | goto end; |
331 | 0 | } |
332 | 0 | OpenAPI_global_ran_node_id_t *global_ran_node_id_listItem = OpenAPI_global_ran_node_id_parseFromJSON(global_ran_node_id_list_local); |
333 | 0 | if (!global_ran_node_id_listItem) { |
334 | 0 | ogs_error("No global_ran_node_id_listItem"); |
335 | 0 | goto end; |
336 | 0 | } |
337 | 0 | OpenAPI_list_add(global_ran_node_id_listList, global_ran_node_id_listItem); |
338 | 0 | } |
339 | 0 | } |
340 | | |
341 | 0 | globale_nb_id_list = cJSON_GetObjectItemCaseSensitive(presence_infoJSON, "globaleNbIdList"); |
342 | 0 | if (globale_nb_id_list) { |
343 | 0 | cJSON *globale_nb_id_list_local = NULL; |
344 | 0 | if (!cJSON_IsArray(globale_nb_id_list)) { |
345 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [globale_nb_id_list]"); |
346 | 0 | goto end; |
347 | 0 | } |
348 | | |
349 | 0 | globale_nb_id_listList = OpenAPI_list_create(); |
350 | |
|
351 | 0 | cJSON_ArrayForEach(globale_nb_id_list_local, globale_nb_id_list) { |
352 | 0 | if (!cJSON_IsObject(globale_nb_id_list_local)) { |
353 | 0 | ogs_error("OpenAPI_presence_info_parseFromJSON() failed [globale_nb_id_list]"); |
354 | 0 | goto end; |
355 | 0 | } |
356 | 0 | OpenAPI_global_ran_node_id_t *globale_nb_id_listItem = OpenAPI_global_ran_node_id_parseFromJSON(globale_nb_id_list_local); |
357 | 0 | if (!globale_nb_id_listItem) { |
358 | 0 | ogs_error("No globale_nb_id_listItem"); |
359 | 0 | goto end; |
360 | 0 | } |
361 | 0 | OpenAPI_list_add(globale_nb_id_listList, globale_nb_id_listItem); |
362 | 0 | } |
363 | 0 | } |
364 | | |
365 | 0 | presence_info_local_var = OpenAPI_presence_info_create ( |
366 | 0 | pra_id && !cJSON_IsNull(pra_id) ? ogs_strdup(pra_id->valuestring) : NULL, |
367 | 0 | additional_pra_id && !cJSON_IsNull(additional_pra_id) ? ogs_strdup(additional_pra_id->valuestring) : NULL, |
368 | 0 | presence_state ? presence_stateVariable : 0, |
369 | 0 | tracking_area_list ? tracking_area_listList : NULL, |
370 | 0 | ecgi_list ? ecgi_listList : NULL, |
371 | 0 | ncgi_list ? ncgi_listList : NULL, |
372 | 0 | global_ran_node_id_list ? global_ran_node_id_listList : NULL, |
373 | 0 | globale_nb_id_list ? globale_nb_id_listList : NULL |
374 | 0 | ); |
375 | |
|
376 | 0 | return presence_info_local_var; |
377 | 0 | end: |
378 | 0 | if (tracking_area_listList) { |
379 | 0 | OpenAPI_list_for_each(tracking_area_listList, node) { |
380 | 0 | OpenAPI_tai_free(node->data); |
381 | 0 | } |
382 | 0 | OpenAPI_list_free(tracking_area_listList); |
383 | 0 | tracking_area_listList = NULL; |
384 | 0 | } |
385 | 0 | if (ecgi_listList) { |
386 | 0 | OpenAPI_list_for_each(ecgi_listList, node) { |
387 | 0 | OpenAPI_ecgi_free(node->data); |
388 | 0 | } |
389 | 0 | OpenAPI_list_free(ecgi_listList); |
390 | 0 | ecgi_listList = NULL; |
391 | 0 | } |
392 | 0 | if (ncgi_listList) { |
393 | 0 | OpenAPI_list_for_each(ncgi_listList, node) { |
394 | 0 | OpenAPI_ncgi_free(node->data); |
395 | 0 | } |
396 | 0 | OpenAPI_list_free(ncgi_listList); |
397 | 0 | ncgi_listList = NULL; |
398 | 0 | } |
399 | 0 | if (global_ran_node_id_listList) { |
400 | 0 | OpenAPI_list_for_each(global_ran_node_id_listList, node) { |
401 | 0 | OpenAPI_global_ran_node_id_free(node->data); |
402 | 0 | } |
403 | 0 | OpenAPI_list_free(global_ran_node_id_listList); |
404 | 0 | global_ran_node_id_listList = NULL; |
405 | 0 | } |
406 | 0 | if (globale_nb_id_listList) { |
407 | 0 | OpenAPI_list_for_each(globale_nb_id_listList, node) { |
408 | 0 | OpenAPI_global_ran_node_id_free(node->data); |
409 | 0 | } |
410 | 0 | OpenAPI_list_free(globale_nb_id_listList); |
411 | 0 | globale_nb_id_listList = NULL; |
412 | 0 | } |
413 | 0 | return NULL; |
414 | 0 | } |
415 | | |
416 | | OpenAPI_presence_info_t *OpenAPI_presence_info_copy(OpenAPI_presence_info_t *dst, OpenAPI_presence_info_t *src) |
417 | 0 | { |
418 | 0 | cJSON *item = NULL; |
419 | 0 | char *content = NULL; |
420 | |
|
421 | 0 | ogs_assert(src); |
422 | 0 | item = OpenAPI_presence_info_convertToJSON(src); |
423 | 0 | if (!item) { |
424 | 0 | ogs_error("OpenAPI_presence_info_convertToJSON() failed"); |
425 | 0 | return NULL; |
426 | 0 | } |
427 | | |
428 | 0 | content = cJSON_Print(item); |
429 | 0 | cJSON_Delete(item); |
430 | |
|
431 | 0 | if (!content) { |
432 | 0 | ogs_error("cJSON_Print() failed"); |
433 | 0 | return NULL; |
434 | 0 | } |
435 | | |
436 | 0 | item = cJSON_Parse(content); |
437 | 0 | ogs_free(content); |
438 | 0 | if (!item) { |
439 | 0 | ogs_error("cJSON_Parse() failed"); |
440 | 0 | return NULL; |
441 | 0 | } |
442 | | |
443 | 0 | OpenAPI_presence_info_free(dst); |
444 | 0 | dst = OpenAPI_presence_info_parseFromJSON(item); |
445 | 0 | cJSON_Delete(item); |
446 | |
|
447 | 0 | return dst; |
448 | 0 | } |
449 | | |