Coverage Report

Created: 2026-07-14 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/location_area.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "location_area.h"
6
7
OpenAPI_location_area_t *OpenAPI_location_area_create(
8
    OpenAPI_list_t *geographic_areas,
9
    OpenAPI_list_t *civic_addresses,
10
    OpenAPI_network_area_info_1_t *nw_area_info,
11
    OpenAPI_umt_time_t *umt_time
12
)
13
0
{
14
0
    OpenAPI_location_area_t *location_area_local_var = ogs_malloc(sizeof(OpenAPI_location_area_t));
15
0
    ogs_assert(location_area_local_var);
16
17
0
    location_area_local_var->geographic_areas = geographic_areas;
18
0
    location_area_local_var->civic_addresses = civic_addresses;
19
0
    location_area_local_var->nw_area_info = nw_area_info;
20
0
    location_area_local_var->umt_time = umt_time;
21
22
0
    return location_area_local_var;
23
0
}
24
25
void OpenAPI_location_area_free(OpenAPI_location_area_t *location_area)
26
0
{
27
0
    OpenAPI_lnode_t *node = NULL;
28
29
0
    if (NULL == location_area) {
30
0
        return;
31
0
    }
32
0
    if (location_area->geographic_areas) {
33
0
        OpenAPI_list_for_each(location_area->geographic_areas, node) {
34
0
            OpenAPI_geographic_area_free(node->data);
35
0
        }
36
0
        OpenAPI_list_free(location_area->geographic_areas);
37
0
        location_area->geographic_areas = NULL;
38
0
    }
39
0
    if (location_area->civic_addresses) {
40
0
        OpenAPI_list_for_each(location_area->civic_addresses, node) {
41
0
            OpenAPI_civic_address_free(node->data);
42
0
        }
43
0
        OpenAPI_list_free(location_area->civic_addresses);
44
0
        location_area->civic_addresses = NULL;
45
0
    }
46
0
    if (location_area->nw_area_info) {
47
0
        OpenAPI_network_area_info_1_free(location_area->nw_area_info);
48
0
        location_area->nw_area_info = NULL;
49
0
    }
50
0
    if (location_area->umt_time) {
51
0
        OpenAPI_umt_time_free(location_area->umt_time);
52
0
        location_area->umt_time = NULL;
53
0
    }
54
0
    ogs_free(location_area);
55
0
}
56
57
cJSON *OpenAPI_location_area_convertToJSON(OpenAPI_location_area_t *location_area)
58
0
{
59
0
    cJSON *item = NULL;
60
0
    OpenAPI_lnode_t *node = NULL;
61
62
0
    if (location_area == NULL) {
63
0
        ogs_error("OpenAPI_location_area_convertToJSON() failed [LocationArea]");
64
0
        return NULL;
65
0
    }
66
67
0
    item = cJSON_CreateObject();
68
0
    if (location_area->geographic_areas) {
69
0
    cJSON *geographic_areasList = cJSON_AddArrayToObject(item, "geographicAreas");
70
0
    if (geographic_areasList == NULL) {
71
0
        ogs_error("OpenAPI_location_area_convertToJSON() failed [geographic_areas]");
72
0
        goto end;
73
0
    }
74
0
    OpenAPI_list_for_each(location_area->geographic_areas, node) {
75
0
        cJSON *itemLocal = OpenAPI_geographic_area_convertToJSON(node->data);
76
0
        if (itemLocal == NULL) {
77
0
            ogs_error("OpenAPI_location_area_convertToJSON() failed [geographic_areas]");
78
0
            goto end;
79
0
        }
80
0
        cJSON_AddItemToArray(geographic_areasList, itemLocal);
81
0
    }
82
0
    }
83
84
0
    if (location_area->civic_addresses) {
85
0
    cJSON *civic_addressesList = cJSON_AddArrayToObject(item, "civicAddresses");
86
0
    if (civic_addressesList == NULL) {
87
0
        ogs_error("OpenAPI_location_area_convertToJSON() failed [civic_addresses]");
88
0
        goto end;
89
0
    }
90
0
    OpenAPI_list_for_each(location_area->civic_addresses, node) {
91
0
        cJSON *itemLocal = OpenAPI_civic_address_convertToJSON(node->data);
92
0
        if (itemLocal == NULL) {
93
0
            ogs_error("OpenAPI_location_area_convertToJSON() failed [civic_addresses]");
94
0
            goto end;
95
0
        }
96
0
        cJSON_AddItemToArray(civic_addressesList, itemLocal);
97
0
    }
98
0
    }
99
100
0
    if (location_area->nw_area_info) {
101
0
    cJSON *nw_area_info_local_JSON = OpenAPI_network_area_info_1_convertToJSON(location_area->nw_area_info);
102
0
    if (nw_area_info_local_JSON == NULL) {
103
0
        ogs_error("OpenAPI_location_area_convertToJSON() failed [nw_area_info]");
104
0
        goto end;
105
0
    }
106
0
    cJSON_AddItemToObject(item, "nwAreaInfo", nw_area_info_local_JSON);
107
0
    if (item->child == NULL) {
108
0
        ogs_error("OpenAPI_location_area_convertToJSON() failed [nw_area_info]");
109
0
        goto end;
110
0
    }
111
0
    }
112
113
0
    if (location_area->umt_time) {
114
0
    cJSON *umt_time_local_JSON = OpenAPI_umt_time_convertToJSON(location_area->umt_time);
115
0
    if (umt_time_local_JSON == NULL) {
116
0
        ogs_error("OpenAPI_location_area_convertToJSON() failed [umt_time]");
117
0
        goto end;
118
0
    }
119
0
    cJSON_AddItemToObject(item, "umtTime", umt_time_local_JSON);
120
0
    if (item->child == NULL) {
121
0
        ogs_error("OpenAPI_location_area_convertToJSON() failed [umt_time]");
122
0
        goto end;
123
0
    }
124
0
    }
125
126
0
end:
127
0
    return item;
128
0
}
129
130
OpenAPI_location_area_t *OpenAPI_location_area_parseFromJSON(cJSON *location_areaJSON)
131
0
{
132
0
    OpenAPI_location_area_t *location_area_local_var = NULL;
133
0
    OpenAPI_lnode_t *node = NULL;
134
0
    cJSON *geographic_areas = NULL;
135
0
    OpenAPI_list_t *geographic_areasList = NULL;
136
0
    cJSON *civic_addresses = NULL;
137
0
    OpenAPI_list_t *civic_addressesList = NULL;
138
0
    cJSON *nw_area_info = NULL;
139
0
    OpenAPI_network_area_info_1_t *nw_area_info_local_nonprim = NULL;
140
0
    cJSON *umt_time = NULL;
141
0
    OpenAPI_umt_time_t *umt_time_local_nonprim = NULL;
142
0
    geographic_areas = cJSON_GetObjectItemCaseSensitive(location_areaJSON, "geographicAreas");
143
0
    if (geographic_areas) {
144
0
        cJSON *geographic_areas_local = NULL;
145
0
        if (!cJSON_IsArray(geographic_areas)) {
146
0
            ogs_error("OpenAPI_location_area_parseFromJSON() failed [geographic_areas]");
147
0
            goto end;
148
0
        }
149
150
0
        geographic_areasList = OpenAPI_list_create();
151
152
0
        cJSON_ArrayForEach(geographic_areas_local, geographic_areas) {
153
0
            if (!cJSON_IsObject(geographic_areas_local)) {
154
0
                ogs_error("OpenAPI_location_area_parseFromJSON() failed [geographic_areas]");
155
0
                goto end;
156
0
            }
157
0
            OpenAPI_geographic_area_t *geographic_areasItem = OpenAPI_geographic_area_parseFromJSON(geographic_areas_local);
158
0
            if (!geographic_areasItem) {
159
0
                ogs_error("No geographic_areasItem");
160
0
                goto end;
161
0
            }
162
0
            OpenAPI_list_add(geographic_areasList, geographic_areasItem);
163
0
        }
164
0
    }
165
166
0
    civic_addresses = cJSON_GetObjectItemCaseSensitive(location_areaJSON, "civicAddresses");
167
0
    if (civic_addresses) {
168
0
        cJSON *civic_addresses_local = NULL;
169
0
        if (!cJSON_IsArray(civic_addresses)) {
170
0
            ogs_error("OpenAPI_location_area_parseFromJSON() failed [civic_addresses]");
171
0
            goto end;
172
0
        }
173
174
0
        civic_addressesList = OpenAPI_list_create();
175
176
0
        cJSON_ArrayForEach(civic_addresses_local, civic_addresses) {
177
0
            if (!cJSON_IsObject(civic_addresses_local)) {
178
0
                ogs_error("OpenAPI_location_area_parseFromJSON() failed [civic_addresses]");
179
0
                goto end;
180
0
            }
181
0
            OpenAPI_civic_address_t *civic_addressesItem = OpenAPI_civic_address_parseFromJSON(civic_addresses_local);
182
0
            if (!civic_addressesItem) {
183
0
                ogs_error("No civic_addressesItem");
184
0
                goto end;
185
0
            }
186
0
            OpenAPI_list_add(civic_addressesList, civic_addressesItem);
187
0
        }
188
0
    }
189
190
0
    nw_area_info = cJSON_GetObjectItemCaseSensitive(location_areaJSON, "nwAreaInfo");
191
0
    if (nw_area_info) {
192
0
    nw_area_info_local_nonprim = OpenAPI_network_area_info_1_parseFromJSON(nw_area_info);
193
0
    if (!nw_area_info_local_nonprim) {
194
0
        ogs_error("OpenAPI_network_area_info_1_parseFromJSON failed [nw_area_info]");
195
0
        goto end;
196
0
    }
197
0
    }
198
199
0
    umt_time = cJSON_GetObjectItemCaseSensitive(location_areaJSON, "umtTime");
200
0
    if (umt_time) {
201
0
    umt_time_local_nonprim = OpenAPI_umt_time_parseFromJSON(umt_time);
202
0
    if (!umt_time_local_nonprim) {
203
0
        ogs_error("OpenAPI_umt_time_parseFromJSON failed [umt_time]");
204
0
        goto end;
205
0
    }
206
0
    }
207
208
0
    location_area_local_var = OpenAPI_location_area_create (
209
0
        geographic_areas ? geographic_areasList : NULL,
210
0
        civic_addresses ? civic_addressesList : NULL,
211
0
        nw_area_info ? nw_area_info_local_nonprim : NULL,
212
0
        umt_time ? umt_time_local_nonprim : NULL
213
0
    );
214
215
0
    return location_area_local_var;
216
0
end:
217
0
    if (geographic_areasList) {
218
0
        OpenAPI_list_for_each(geographic_areasList, node) {
219
0
            OpenAPI_geographic_area_free(node->data);
220
0
        }
221
0
        OpenAPI_list_free(geographic_areasList);
222
0
        geographic_areasList = NULL;
223
0
    }
224
0
    if (civic_addressesList) {
225
0
        OpenAPI_list_for_each(civic_addressesList, node) {
226
0
            OpenAPI_civic_address_free(node->data);
227
0
        }
228
0
        OpenAPI_list_free(civic_addressesList);
229
0
        civic_addressesList = NULL;
230
0
    }
231
0
    if (nw_area_info_local_nonprim) {
232
0
        OpenAPI_network_area_info_1_free(nw_area_info_local_nonprim);
233
0
        nw_area_info_local_nonprim = NULL;
234
0
    }
235
0
    if (umt_time_local_nonprim) {
236
0
        OpenAPI_umt_time_free(umt_time_local_nonprim);
237
0
        umt_time_local_nonprim = NULL;
238
0
    }
239
0
    return NULL;
240
0
}
241
242
OpenAPI_location_area_t *OpenAPI_location_area_copy(OpenAPI_location_area_t *dst, OpenAPI_location_area_t *src)
243
0
{
244
0
    cJSON *item = NULL;
245
0
    char *content = NULL;
246
247
0
    ogs_assert(src);
248
0
    item = OpenAPI_location_area_convertToJSON(src);
249
0
    if (!item) {
250
0
        ogs_error("OpenAPI_location_area_convertToJSON() failed");
251
0
        return NULL;
252
0
    }
253
254
0
    content = cJSON_Print(item);
255
0
    cJSON_Delete(item);
256
257
0
    if (!content) {
258
0
        ogs_error("cJSON_Print() failed");
259
0
        return NULL;
260
0
    }
261
262
0
    item = cJSON_Parse(content);
263
0
    ogs_free(content);
264
0
    if (!item) {
265
0
        ogs_error("cJSON_Parse() failed");
266
0
        return NULL;
267
0
    }
268
269
0
    OpenAPI_location_area_free(dst);
270
0
    dst = OpenAPI_location_area_parseFromJSON(item);
271
0
    cJSON_Delete(item);
272
273
0
    return dst;
274
0
}
275