/src/open5gs/lib/sbi/openapi/model/geo_location.c
Line | Count | Source |
1 | | |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdio.h> |
5 | | #include "geo_location.h" |
6 | | |
7 | | OpenAPI_geo_location_t *OpenAPI_geo_location_create( |
8 | | char *value |
9 | | ) |
10 | 0 | { |
11 | 0 | OpenAPI_geo_location_t *geo_location_local_var = ogs_malloc(sizeof(OpenAPI_geo_location_t)); |
12 | 0 | ogs_assert(geo_location_local_var); |
13 | | |
14 | 0 | geo_location_local_var->value = value; |
15 | |
|
16 | 0 | return geo_location_local_var; |
17 | 0 | } |
18 | | |
19 | | void OpenAPI_geo_location_free(OpenAPI_geo_location_t *geo_location) |
20 | 0 | { |
21 | 0 | OpenAPI_lnode_t *node = NULL; |
22 | |
|
23 | 0 | if (NULL == geo_location) { |
24 | 0 | return; |
25 | 0 | } |
26 | 0 | if (geo_location->value) { |
27 | 0 | ogs_free(geo_location->value); |
28 | 0 | geo_location->value = NULL; |
29 | 0 | } |
30 | 0 | ogs_free(geo_location); |
31 | 0 | } |
32 | | |
33 | | cJSON *OpenAPI_geo_location_convertToJSON(OpenAPI_geo_location_t *geo_location) |
34 | 0 | { |
35 | 0 | cJSON *item = NULL; |
36 | 0 | OpenAPI_lnode_t *node = NULL; |
37 | |
|
38 | 0 | if (geo_location == NULL) { |
39 | 0 | ogs_error("OpenAPI_geo_location_convertToJSON() failed [GeoLocation]"); |
40 | 0 | return NULL; |
41 | 0 | } |
42 | | |
43 | 0 | item = cJSON_CreateObject(); |
44 | 0 | end: |
45 | 0 | return item; |
46 | 0 | } |
47 | | |
48 | | OpenAPI_geo_location_t *OpenAPI_geo_location_parseFromJSON(cJSON *geo_locationJSON) |
49 | 0 | { |
50 | 0 | OpenAPI_geo_location_t *geo_location_local_var = NULL; |
51 | 0 | OpenAPI_lnode_t *node = NULL; |
52 | 0 | geo_location_local_var = OpenAPI_geo_location_create ( |
53 | 0 | NULL |
54 | 0 | ); |
55 | |
|
56 | 0 | return geo_location_local_var; |
57 | 0 | end: |
58 | 0 | return NULL; |
59 | 0 | } |
60 | | |
61 | | OpenAPI_geo_location_t *OpenAPI_geo_location_copy(OpenAPI_geo_location_t *dst, OpenAPI_geo_location_t *src) |
62 | 0 | { |
63 | 0 | cJSON *item = NULL; |
64 | 0 | char *content = NULL; |
65 | |
|
66 | 0 | ogs_assert(src); |
67 | 0 | item = OpenAPI_geo_location_convertToJSON(src); |
68 | 0 | if (!item) { |
69 | 0 | ogs_error("OpenAPI_geo_location_convertToJSON() failed"); |
70 | 0 | return NULL; |
71 | 0 | } |
72 | | |
73 | 0 | content = cJSON_Print(item); |
74 | 0 | cJSON_Delete(item); |
75 | |
|
76 | 0 | if (!content) { |
77 | 0 | ogs_error("cJSON_Print() failed"); |
78 | 0 | return NULL; |
79 | 0 | } |
80 | | |
81 | 0 | item = cJSON_Parse(content); |
82 | 0 | ogs_free(content); |
83 | 0 | if (!item) { |
84 | 0 | ogs_error("cJSON_Parse() failed"); |
85 | 0 | return NULL; |
86 | 0 | } |
87 | | |
88 | 0 | OpenAPI_geo_location_free(dst); |
89 | 0 | dst = OpenAPI_geo_location_parseFromJSON(item); |
90 | 0 | cJSON_Delete(item); |
91 | |
|
92 | 0 | return dst; |
93 | 0 | } |
94 | | |