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/timestamped_location.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "timestamped_location.h"
6
7
OpenAPI_timestamped_location_t *OpenAPI_timestamped_location_create(
8
    char *ts,
9
    OpenAPI_location_info_t *loc_info,
10
    char *supi,
11
    char *gpsi
12
)
13
0
{
14
0
    OpenAPI_timestamped_location_t *timestamped_location_local_var = ogs_malloc(sizeof(OpenAPI_timestamped_location_t));
15
0
    ogs_assert(timestamped_location_local_var);
16
17
0
    timestamped_location_local_var->ts = ts;
18
0
    timestamped_location_local_var->loc_info = loc_info;
19
0
    timestamped_location_local_var->supi = supi;
20
0
    timestamped_location_local_var->gpsi = gpsi;
21
22
0
    return timestamped_location_local_var;
23
0
}
24
25
void OpenAPI_timestamped_location_free(OpenAPI_timestamped_location_t *timestamped_location)
26
0
{
27
0
    OpenAPI_lnode_t *node = NULL;
28
29
0
    if (NULL == timestamped_location) {
30
0
        return;
31
0
    }
32
0
    if (timestamped_location->ts) {
33
0
        ogs_free(timestamped_location->ts);
34
0
        timestamped_location->ts = NULL;
35
0
    }
36
0
    if (timestamped_location->loc_info) {
37
0
        OpenAPI_location_info_free(timestamped_location->loc_info);
38
0
        timestamped_location->loc_info = NULL;
39
0
    }
40
0
    if (timestamped_location->supi) {
41
0
        ogs_free(timestamped_location->supi);
42
0
        timestamped_location->supi = NULL;
43
0
    }
44
0
    if (timestamped_location->gpsi) {
45
0
        ogs_free(timestamped_location->gpsi);
46
0
        timestamped_location->gpsi = NULL;
47
0
    }
48
0
    ogs_free(timestamped_location);
49
0
}
50
51
cJSON *OpenAPI_timestamped_location_convertToJSON(OpenAPI_timestamped_location_t *timestamped_location)
52
0
{
53
0
    cJSON *item = NULL;
54
0
    OpenAPI_lnode_t *node = NULL;
55
56
0
    if (timestamped_location == NULL) {
57
0
        ogs_error("OpenAPI_timestamped_location_convertToJSON() failed [TimestampedLocation]");
58
0
        return NULL;
59
0
    }
60
61
0
    item = cJSON_CreateObject();
62
0
    if (!timestamped_location->ts) {
63
0
        ogs_error("OpenAPI_timestamped_location_convertToJSON() failed [ts]");
64
0
        return NULL;
65
0
    }
66
0
    if (cJSON_AddStringToObject(item, "ts", timestamped_location->ts) == NULL) {
67
0
        ogs_error("OpenAPI_timestamped_location_convertToJSON() failed [ts]");
68
0
        goto end;
69
0
    }
70
71
0
    if (!timestamped_location->loc_info) {
72
0
        ogs_error("OpenAPI_timestamped_location_convertToJSON() failed [loc_info]");
73
0
        return NULL;
74
0
    }
75
0
    cJSON *loc_info_local_JSON = OpenAPI_location_info_convertToJSON(timestamped_location->loc_info);
76
0
    if (loc_info_local_JSON == NULL) {
77
0
        ogs_error("OpenAPI_timestamped_location_convertToJSON() failed [loc_info]");
78
0
        goto end;
79
0
    }
80
0
    cJSON_AddItemToObject(item, "locInfo", loc_info_local_JSON);
81
0
    if (item->child == NULL) {
82
0
        ogs_error("OpenAPI_timestamped_location_convertToJSON() failed [loc_info]");
83
0
        goto end;
84
0
    }
85
86
0
    if (timestamped_location->supi) {
87
0
    if (cJSON_AddStringToObject(item, "supi", timestamped_location->supi) == NULL) {
88
0
        ogs_error("OpenAPI_timestamped_location_convertToJSON() failed [supi]");
89
0
        goto end;
90
0
    }
91
0
    }
92
93
0
    if (timestamped_location->gpsi) {
94
0
    if (cJSON_AddStringToObject(item, "gpsi", timestamped_location->gpsi) == NULL) {
95
0
        ogs_error("OpenAPI_timestamped_location_convertToJSON() failed [gpsi]");
96
0
        goto end;
97
0
    }
98
0
    }
99
100
0
end:
101
0
    return item;
102
0
}
103
104
OpenAPI_timestamped_location_t *OpenAPI_timestamped_location_parseFromJSON(cJSON *timestamped_locationJSON)
105
0
{
106
0
    OpenAPI_timestamped_location_t *timestamped_location_local_var = NULL;
107
0
    OpenAPI_lnode_t *node = NULL;
108
0
    cJSON *ts = NULL;
109
0
    cJSON *loc_info = NULL;
110
0
    OpenAPI_location_info_t *loc_info_local_nonprim = NULL;
111
0
    cJSON *supi = NULL;
112
0
    cJSON *gpsi = NULL;
113
0
    ts = cJSON_GetObjectItemCaseSensitive(timestamped_locationJSON, "ts");
114
0
    if (!ts) {
115
0
        ogs_error("OpenAPI_timestamped_location_parseFromJSON() failed [ts]");
116
0
        goto end;
117
0
    }
118
0
    if (!cJSON_IsString(ts) && !cJSON_IsNull(ts)) {
119
0
        ogs_error("OpenAPI_timestamped_location_parseFromJSON() failed [ts]");
120
0
        goto end;
121
0
    }
122
123
0
    loc_info = cJSON_GetObjectItemCaseSensitive(timestamped_locationJSON, "locInfo");
124
0
    if (!loc_info) {
125
0
        ogs_error("OpenAPI_timestamped_location_parseFromJSON() failed [loc_info]");
126
0
        goto end;
127
0
    }
128
0
    loc_info_local_nonprim = OpenAPI_location_info_parseFromJSON(loc_info);
129
0
    if (!loc_info_local_nonprim) {
130
0
        ogs_error("OpenAPI_location_info_parseFromJSON failed [loc_info]");
131
0
        goto end;
132
0
    }
133
134
0
    supi = cJSON_GetObjectItemCaseSensitive(timestamped_locationJSON, "supi");
135
0
    if (supi) {
136
0
    if (!cJSON_IsString(supi) && !cJSON_IsNull(supi)) {
137
0
        ogs_error("OpenAPI_timestamped_location_parseFromJSON() failed [supi]");
138
0
        goto end;
139
0
    }
140
0
    }
141
142
0
    gpsi = cJSON_GetObjectItemCaseSensitive(timestamped_locationJSON, "gpsi");
143
0
    if (gpsi) {
144
0
    if (!cJSON_IsString(gpsi) && !cJSON_IsNull(gpsi)) {
145
0
        ogs_error("OpenAPI_timestamped_location_parseFromJSON() failed [gpsi]");
146
0
        goto end;
147
0
    }
148
0
    }
149
150
0
    timestamped_location_local_var = OpenAPI_timestamped_location_create (
151
0
        ogs_strdup(ts->valuestring),
152
0
        loc_info_local_nonprim,
153
0
        supi && !cJSON_IsNull(supi) ? ogs_strdup(supi->valuestring) : NULL,
154
0
        gpsi && !cJSON_IsNull(gpsi) ? ogs_strdup(gpsi->valuestring) : NULL
155
0
    );
156
157
0
    return timestamped_location_local_var;
158
0
end:
159
0
    if (loc_info_local_nonprim) {
160
0
        OpenAPI_location_info_free(loc_info_local_nonprim);
161
0
        loc_info_local_nonprim = NULL;
162
0
    }
163
0
    return NULL;
164
0
}
165
166
OpenAPI_timestamped_location_t *OpenAPI_timestamped_location_copy(OpenAPI_timestamped_location_t *dst, OpenAPI_timestamped_location_t *src)
167
0
{
168
0
    cJSON *item = NULL;
169
0
    char *content = NULL;
170
171
0
    ogs_assert(src);
172
0
    item = OpenAPI_timestamped_location_convertToJSON(src);
173
0
    if (!item) {
174
0
        ogs_error("OpenAPI_timestamped_location_convertToJSON() failed");
175
0
        return NULL;
176
0
    }
177
178
0
    content = cJSON_Print(item);
179
0
    cJSON_Delete(item);
180
181
0
    if (!content) {
182
0
        ogs_error("cJSON_Print() failed");
183
0
        return NULL;
184
0
    }
185
186
0
    item = cJSON_Parse(content);
187
0
    ogs_free(content);
188
0
    if (!item) {
189
0
        ogs_error("cJSON_Parse() failed");
190
0
        return NULL;
191
0
    }
192
193
0
    OpenAPI_timestamped_location_free(dst);
194
0
    dst = OpenAPI_timestamped_location_parseFromJSON(item);
195
0
    cJSON_Delete(item);
196
197
0
    return dst;
198
0
}
199