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/gera_location.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "gera_location.h"
6
7
OpenAPI_gera_location_t *OpenAPI_gera_location_create(
8
    char *location_number,
9
    OpenAPI_cell_global_id_t *cgi,
10
    OpenAPI_service_area_id_t *sai,
11
    OpenAPI_location_area_id_t *lai,
12
    OpenAPI_routing_area_id_t *rai,
13
    char *vlr_number,
14
    char *msc_number,
15
    bool is_age_of_location_information,
16
    int age_of_location_information,
17
    char *ue_location_timestamp,
18
    char *geographical_information,
19
    char *geodetic_information
20
)
21
0
{
22
0
    OpenAPI_gera_location_t *gera_location_local_var = ogs_malloc(sizeof(OpenAPI_gera_location_t));
23
0
    ogs_assert(gera_location_local_var);
24
25
0
    gera_location_local_var->location_number = location_number;
26
0
    gera_location_local_var->cgi = cgi;
27
0
    gera_location_local_var->sai = sai;
28
0
    gera_location_local_var->lai = lai;
29
0
    gera_location_local_var->rai = rai;
30
0
    gera_location_local_var->vlr_number = vlr_number;
31
0
    gera_location_local_var->msc_number = msc_number;
32
0
    gera_location_local_var->is_age_of_location_information = is_age_of_location_information;
33
0
    gera_location_local_var->age_of_location_information = age_of_location_information;
34
0
    gera_location_local_var->ue_location_timestamp = ue_location_timestamp;
35
0
    gera_location_local_var->geographical_information = geographical_information;
36
0
    gera_location_local_var->geodetic_information = geodetic_information;
37
38
0
    return gera_location_local_var;
39
0
}
40
41
void OpenAPI_gera_location_free(OpenAPI_gera_location_t *gera_location)
42
0
{
43
0
    OpenAPI_lnode_t *node = NULL;
44
45
0
    if (NULL == gera_location) {
46
0
        return;
47
0
    }
48
0
    if (gera_location->location_number) {
49
0
        ogs_free(gera_location->location_number);
50
0
        gera_location->location_number = NULL;
51
0
    }
52
0
    if (gera_location->cgi) {
53
0
        OpenAPI_cell_global_id_free(gera_location->cgi);
54
0
        gera_location->cgi = NULL;
55
0
    }
56
0
    if (gera_location->sai) {
57
0
        OpenAPI_service_area_id_free(gera_location->sai);
58
0
        gera_location->sai = NULL;
59
0
    }
60
0
    if (gera_location->lai) {
61
0
        OpenAPI_location_area_id_free(gera_location->lai);
62
0
        gera_location->lai = NULL;
63
0
    }
64
0
    if (gera_location->rai) {
65
0
        OpenAPI_routing_area_id_free(gera_location->rai);
66
0
        gera_location->rai = NULL;
67
0
    }
68
0
    if (gera_location->vlr_number) {
69
0
        ogs_free(gera_location->vlr_number);
70
0
        gera_location->vlr_number = NULL;
71
0
    }
72
0
    if (gera_location->msc_number) {
73
0
        ogs_free(gera_location->msc_number);
74
0
        gera_location->msc_number = NULL;
75
0
    }
76
0
    if (gera_location->ue_location_timestamp) {
77
0
        ogs_free(gera_location->ue_location_timestamp);
78
0
        gera_location->ue_location_timestamp = NULL;
79
0
    }
80
0
    if (gera_location->geographical_information) {
81
0
        ogs_free(gera_location->geographical_information);
82
0
        gera_location->geographical_information = NULL;
83
0
    }
84
0
    if (gera_location->geodetic_information) {
85
0
        ogs_free(gera_location->geodetic_information);
86
0
        gera_location->geodetic_information = NULL;
87
0
    }
88
0
    ogs_free(gera_location);
89
0
}
90
91
cJSON *OpenAPI_gera_location_convertToJSON(OpenAPI_gera_location_t *gera_location)
92
0
{
93
0
    cJSON *item = NULL;
94
0
    OpenAPI_lnode_t *node = NULL;
95
96
0
    if (gera_location == NULL) {
97
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [GeraLocation]");
98
0
        return NULL;
99
0
    }
100
101
0
    item = cJSON_CreateObject();
102
0
    if (gera_location->location_number) {
103
0
    if (cJSON_AddStringToObject(item, "locationNumber", gera_location->location_number) == NULL) {
104
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [location_number]");
105
0
        goto end;
106
0
    }
107
0
    }
108
109
0
    if (gera_location->cgi) {
110
0
    cJSON *cgi_local_JSON = OpenAPI_cell_global_id_convertToJSON(gera_location->cgi);
111
0
    if (cgi_local_JSON == NULL) {
112
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [cgi]");
113
0
        goto end;
114
0
    }
115
0
    cJSON_AddItemToObject(item, "cgi", cgi_local_JSON);
116
0
    if (item->child == NULL) {
117
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [cgi]");
118
0
        goto end;
119
0
    }
120
0
    }
121
122
0
    if (gera_location->sai) {
123
0
    cJSON *sai_local_JSON = OpenAPI_service_area_id_convertToJSON(gera_location->sai);
124
0
    if (sai_local_JSON == NULL) {
125
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [sai]");
126
0
        goto end;
127
0
    }
128
0
    cJSON_AddItemToObject(item, "sai", sai_local_JSON);
129
0
    if (item->child == NULL) {
130
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [sai]");
131
0
        goto end;
132
0
    }
133
0
    }
134
135
0
    if (gera_location->lai) {
136
0
    cJSON *lai_local_JSON = OpenAPI_location_area_id_convertToJSON(gera_location->lai);
137
0
    if (lai_local_JSON == NULL) {
138
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [lai]");
139
0
        goto end;
140
0
    }
141
0
    cJSON_AddItemToObject(item, "lai", lai_local_JSON);
142
0
    if (item->child == NULL) {
143
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [lai]");
144
0
        goto end;
145
0
    }
146
0
    }
147
148
0
    if (gera_location->rai) {
149
0
    cJSON *rai_local_JSON = OpenAPI_routing_area_id_convertToJSON(gera_location->rai);
150
0
    if (rai_local_JSON == NULL) {
151
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [rai]");
152
0
        goto end;
153
0
    }
154
0
    cJSON_AddItemToObject(item, "rai", rai_local_JSON);
155
0
    if (item->child == NULL) {
156
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [rai]");
157
0
        goto end;
158
0
    }
159
0
    }
160
161
0
    if (gera_location->vlr_number) {
162
0
    if (cJSON_AddStringToObject(item, "vlrNumber", gera_location->vlr_number) == NULL) {
163
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [vlr_number]");
164
0
        goto end;
165
0
    }
166
0
    }
167
168
0
    if (gera_location->msc_number) {
169
0
    if (cJSON_AddStringToObject(item, "mscNumber", gera_location->msc_number) == NULL) {
170
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [msc_number]");
171
0
        goto end;
172
0
    }
173
0
    }
174
175
0
    if (gera_location->is_age_of_location_information) {
176
0
    if (cJSON_AddNumberToObject(item, "ageOfLocationInformation", gera_location->age_of_location_information) == NULL) {
177
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [age_of_location_information]");
178
0
        goto end;
179
0
    }
180
0
    }
181
182
0
    if (gera_location->ue_location_timestamp) {
183
0
    if (cJSON_AddStringToObject(item, "ueLocationTimestamp", gera_location->ue_location_timestamp) == NULL) {
184
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [ue_location_timestamp]");
185
0
        goto end;
186
0
    }
187
0
    }
188
189
0
    if (gera_location->geographical_information) {
190
0
    if (cJSON_AddStringToObject(item, "geographicalInformation", gera_location->geographical_information) == NULL) {
191
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [geographical_information]");
192
0
        goto end;
193
0
    }
194
0
    }
195
196
0
    if (gera_location->geodetic_information) {
197
0
    if (cJSON_AddStringToObject(item, "geodeticInformation", gera_location->geodetic_information) == NULL) {
198
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed [geodetic_information]");
199
0
        goto end;
200
0
    }
201
0
    }
202
203
0
end:
204
0
    return item;
205
0
}
206
207
OpenAPI_gera_location_t *OpenAPI_gera_location_parseFromJSON(cJSON *gera_locationJSON)
208
0
{
209
0
    OpenAPI_gera_location_t *gera_location_local_var = NULL;
210
0
    OpenAPI_lnode_t *node = NULL;
211
0
    cJSON *location_number = NULL;
212
0
    cJSON *cgi = NULL;
213
0
    OpenAPI_cell_global_id_t *cgi_local_nonprim = NULL;
214
0
    cJSON *sai = NULL;
215
0
    OpenAPI_service_area_id_t *sai_local_nonprim = NULL;
216
0
    cJSON *lai = NULL;
217
0
    OpenAPI_location_area_id_t *lai_local_nonprim = NULL;
218
0
    cJSON *rai = NULL;
219
0
    OpenAPI_routing_area_id_t *rai_local_nonprim = NULL;
220
0
    cJSON *vlr_number = NULL;
221
0
    cJSON *msc_number = NULL;
222
0
    cJSON *age_of_location_information = NULL;
223
0
    cJSON *ue_location_timestamp = NULL;
224
0
    cJSON *geographical_information = NULL;
225
0
    cJSON *geodetic_information = NULL;
226
0
    location_number = cJSON_GetObjectItemCaseSensitive(gera_locationJSON, "locationNumber");
227
0
    if (location_number) {
228
0
    if (!cJSON_IsString(location_number) && !cJSON_IsNull(location_number)) {
229
0
        ogs_error("OpenAPI_gera_location_parseFromJSON() failed [location_number]");
230
0
        goto end;
231
0
    }
232
0
    }
233
234
0
    cgi = cJSON_GetObjectItemCaseSensitive(gera_locationJSON, "cgi");
235
0
    if (cgi) {
236
0
    cgi_local_nonprim = OpenAPI_cell_global_id_parseFromJSON(cgi);
237
0
    if (!cgi_local_nonprim) {
238
0
        ogs_error("OpenAPI_cell_global_id_parseFromJSON failed [cgi]");
239
0
        goto end;
240
0
    }
241
0
    }
242
243
0
    sai = cJSON_GetObjectItemCaseSensitive(gera_locationJSON, "sai");
244
0
    if (sai) {
245
0
    sai_local_nonprim = OpenAPI_service_area_id_parseFromJSON(sai);
246
0
    if (!sai_local_nonprim) {
247
0
        ogs_error("OpenAPI_service_area_id_parseFromJSON failed [sai]");
248
0
        goto end;
249
0
    }
250
0
    }
251
252
0
    lai = cJSON_GetObjectItemCaseSensitive(gera_locationJSON, "lai");
253
0
    if (lai) {
254
0
    lai_local_nonprim = OpenAPI_location_area_id_parseFromJSON(lai);
255
0
    if (!lai_local_nonprim) {
256
0
        ogs_error("OpenAPI_location_area_id_parseFromJSON failed [lai]");
257
0
        goto end;
258
0
    }
259
0
    }
260
261
0
    rai = cJSON_GetObjectItemCaseSensitive(gera_locationJSON, "rai");
262
0
    if (rai) {
263
0
    rai_local_nonprim = OpenAPI_routing_area_id_parseFromJSON(rai);
264
0
    if (!rai_local_nonprim) {
265
0
        ogs_error("OpenAPI_routing_area_id_parseFromJSON failed [rai]");
266
0
        goto end;
267
0
    }
268
0
    }
269
270
0
    vlr_number = cJSON_GetObjectItemCaseSensitive(gera_locationJSON, "vlrNumber");
271
0
    if (vlr_number) {
272
0
    if (!cJSON_IsString(vlr_number) && !cJSON_IsNull(vlr_number)) {
273
0
        ogs_error("OpenAPI_gera_location_parseFromJSON() failed [vlr_number]");
274
0
        goto end;
275
0
    }
276
0
    }
277
278
0
    msc_number = cJSON_GetObjectItemCaseSensitive(gera_locationJSON, "mscNumber");
279
0
    if (msc_number) {
280
0
    if (!cJSON_IsString(msc_number) && !cJSON_IsNull(msc_number)) {
281
0
        ogs_error("OpenAPI_gera_location_parseFromJSON() failed [msc_number]");
282
0
        goto end;
283
0
    }
284
0
    }
285
286
0
    age_of_location_information = cJSON_GetObjectItemCaseSensitive(gera_locationJSON, "ageOfLocationInformation");
287
0
    if (age_of_location_information) {
288
0
    if (!cJSON_IsNumber(age_of_location_information)) {
289
0
        ogs_error("OpenAPI_gera_location_parseFromJSON() failed [age_of_location_information]");
290
0
        goto end;
291
0
    }
292
0
    }
293
294
0
    ue_location_timestamp = cJSON_GetObjectItemCaseSensitive(gera_locationJSON, "ueLocationTimestamp");
295
0
    if (ue_location_timestamp) {
296
0
    if (!cJSON_IsString(ue_location_timestamp) && !cJSON_IsNull(ue_location_timestamp)) {
297
0
        ogs_error("OpenAPI_gera_location_parseFromJSON() failed [ue_location_timestamp]");
298
0
        goto end;
299
0
    }
300
0
    }
301
302
0
    geographical_information = cJSON_GetObjectItemCaseSensitive(gera_locationJSON, "geographicalInformation");
303
0
    if (geographical_information) {
304
0
    if (!cJSON_IsString(geographical_information) && !cJSON_IsNull(geographical_information)) {
305
0
        ogs_error("OpenAPI_gera_location_parseFromJSON() failed [geographical_information]");
306
0
        goto end;
307
0
    }
308
0
    }
309
310
0
    geodetic_information = cJSON_GetObjectItemCaseSensitive(gera_locationJSON, "geodeticInformation");
311
0
    if (geodetic_information) {
312
0
    if (!cJSON_IsString(geodetic_information) && !cJSON_IsNull(geodetic_information)) {
313
0
        ogs_error("OpenAPI_gera_location_parseFromJSON() failed [geodetic_information]");
314
0
        goto end;
315
0
    }
316
0
    }
317
318
0
    gera_location_local_var = OpenAPI_gera_location_create (
319
0
        location_number && !cJSON_IsNull(location_number) ? ogs_strdup(location_number->valuestring) : NULL,
320
0
        cgi ? cgi_local_nonprim : NULL,
321
0
        sai ? sai_local_nonprim : NULL,
322
0
        lai ? lai_local_nonprim : NULL,
323
0
        rai ? rai_local_nonprim : NULL,
324
0
        vlr_number && !cJSON_IsNull(vlr_number) ? ogs_strdup(vlr_number->valuestring) : NULL,
325
0
        msc_number && !cJSON_IsNull(msc_number) ? ogs_strdup(msc_number->valuestring) : NULL,
326
0
        age_of_location_information ? true : false,
327
0
        age_of_location_information ? age_of_location_information->valuedouble : 0,
328
0
        ue_location_timestamp && !cJSON_IsNull(ue_location_timestamp) ? ogs_strdup(ue_location_timestamp->valuestring) : NULL,
329
0
        geographical_information && !cJSON_IsNull(geographical_information) ? ogs_strdup(geographical_information->valuestring) : NULL,
330
0
        geodetic_information && !cJSON_IsNull(geodetic_information) ? ogs_strdup(geodetic_information->valuestring) : NULL
331
0
    );
332
333
0
    return gera_location_local_var;
334
0
end:
335
0
    if (cgi_local_nonprim) {
336
0
        OpenAPI_cell_global_id_free(cgi_local_nonprim);
337
0
        cgi_local_nonprim = NULL;
338
0
    }
339
0
    if (sai_local_nonprim) {
340
0
        OpenAPI_service_area_id_free(sai_local_nonprim);
341
0
        sai_local_nonprim = NULL;
342
0
    }
343
0
    if (lai_local_nonprim) {
344
0
        OpenAPI_location_area_id_free(lai_local_nonprim);
345
0
        lai_local_nonprim = NULL;
346
0
    }
347
0
    if (rai_local_nonprim) {
348
0
        OpenAPI_routing_area_id_free(rai_local_nonprim);
349
0
        rai_local_nonprim = NULL;
350
0
    }
351
0
    return NULL;
352
0
}
353
354
OpenAPI_gera_location_t *OpenAPI_gera_location_copy(OpenAPI_gera_location_t *dst, OpenAPI_gera_location_t *src)
355
0
{
356
0
    cJSON *item = NULL;
357
0
    char *content = NULL;
358
359
0
    ogs_assert(src);
360
0
    item = OpenAPI_gera_location_convertToJSON(src);
361
0
    if (!item) {
362
0
        ogs_error("OpenAPI_gera_location_convertToJSON() failed");
363
0
        return NULL;
364
0
    }
365
366
0
    content = cJSON_Print(item);
367
0
    cJSON_Delete(item);
368
369
0
    if (!content) {
370
0
        ogs_error("cJSON_Print() failed");
371
0
        return NULL;
372
0
    }
373
374
0
    item = cJSON_Parse(content);
375
0
    ogs_free(content);
376
0
    if (!item) {
377
0
        ogs_error("cJSON_Parse() failed");
378
0
        return NULL;
379
0
    }
380
381
0
    OpenAPI_gera_location_free(dst);
382
0
    dst = OpenAPI_gera_location_parseFromJSON(item);
383
0
    cJSON_Delete(item);
384
385
0
    return dst;
386
0
}
387