Coverage Report

Created: 2026-09-28 06:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/steering_mode.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "steering_mode.h"
6
7
OpenAPI_steering_mode_t *OpenAPI_steering_mode_create(
8
    OpenAPI_steer_mode_value_e steer_mode_value,
9
    OpenAPI_access_type_e active,
10
    OpenAPI_access_type_e standby,
11
    bool is__3g_load,
12
    int _3g_load,
13
    OpenAPI_access_type_e prio_acc,
14
    bool is_thres_value_null,
15
    OpenAPI_threshold_value_t *thres_value,
16
    OpenAPI_steer_mode_indicator_e steer_mode_ind,
17
    OpenAPI_access_type_e primary
18
)
19
0
{
20
0
    OpenAPI_steering_mode_t *steering_mode_local_var = ogs_malloc(sizeof(OpenAPI_steering_mode_t));
21
0
    ogs_assert(steering_mode_local_var);
22
23
0
    steering_mode_local_var->steer_mode_value = steer_mode_value;
24
0
    steering_mode_local_var->active = active;
25
0
    steering_mode_local_var->standby = standby;
26
0
    steering_mode_local_var->is__3g_load = is__3g_load;
27
0
    steering_mode_local_var->_3g_load = _3g_load;
28
0
    steering_mode_local_var->prio_acc = prio_acc;
29
0
    steering_mode_local_var->is_thres_value_null = is_thres_value_null;
30
0
    steering_mode_local_var->thres_value = thres_value;
31
0
    steering_mode_local_var->steer_mode_ind = steer_mode_ind;
32
0
    steering_mode_local_var->primary = primary;
33
34
0
    return steering_mode_local_var;
35
0
}
36
37
void OpenAPI_steering_mode_free(OpenAPI_steering_mode_t *steering_mode)
38
0
{
39
0
    OpenAPI_lnode_t *node = NULL;
40
41
0
    if (NULL == steering_mode) {
42
0
        return;
43
0
    }
44
0
    if (steering_mode->thres_value) {
45
0
        OpenAPI_threshold_value_free(steering_mode->thres_value);
46
0
        steering_mode->thres_value = NULL;
47
0
    }
48
0
    ogs_free(steering_mode);
49
0
}
50
51
cJSON *OpenAPI_steering_mode_convertToJSON(OpenAPI_steering_mode_t *steering_mode)
52
0
{
53
0
    cJSON *item = NULL;
54
0
    OpenAPI_lnode_t *node = NULL;
55
56
0
    if (steering_mode == NULL) {
57
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed [SteeringMode]");
58
0
        return NULL;
59
0
    }
60
61
0
    item = cJSON_CreateObject();
62
0
    if (steering_mode->steer_mode_value == OpenAPI_steer_mode_value_NULL) {
63
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed [steer_mode_value]");
64
0
        return NULL;
65
0
    }
66
0
    if (cJSON_AddStringToObject(item, "steerModeValue", OpenAPI_steer_mode_value_ToString(steering_mode->steer_mode_value)) == NULL) {
67
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed [steer_mode_value]");
68
0
        goto end;
69
0
    }
70
71
0
    if (steering_mode->active != OpenAPI_access_type_NULL) {
72
0
    if (cJSON_AddStringToObject(item, "active", OpenAPI_access_type_ToString(steering_mode->active)) == NULL) {
73
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed [active]");
74
0
        goto end;
75
0
    }
76
0
    }
77
78
0
    if (steering_mode->standby != OpenAPI_access_type_NULL) {
79
0
    if (cJSON_AddStringToObject(item, "standby", OpenAPI_access_type_ToString(steering_mode->standby)) == NULL) {
80
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed [standby]");
81
0
        goto end;
82
0
    }
83
0
    }
84
85
0
    if (steering_mode->is__3g_load) {
86
0
    if (cJSON_AddNumberToObject(item, "3gLoad", steering_mode->_3g_load) == NULL) {
87
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed [_3g_load]");
88
0
        goto end;
89
0
    }
90
0
    }
91
92
0
    if (steering_mode->prio_acc != OpenAPI_access_type_NULL) {
93
0
    if (cJSON_AddStringToObject(item, "prioAcc", OpenAPI_access_type_ToString(steering_mode->prio_acc)) == NULL) {
94
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed [prio_acc]");
95
0
        goto end;
96
0
    }
97
0
    }
98
99
0
    if (steering_mode->thres_value) {
100
0
    cJSON *thres_value_local_JSON = OpenAPI_threshold_value_convertToJSON(steering_mode->thres_value);
101
0
    if (thres_value_local_JSON == NULL) {
102
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed [thres_value]");
103
0
        goto end;
104
0
    }
105
0
    cJSON_AddItemToObject(item, "thresValue", thres_value_local_JSON);
106
0
    if (item->child == NULL) {
107
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed [thres_value]");
108
0
        goto end;
109
0
    }
110
0
    } else if (steering_mode->is_thres_value_null) {
111
0
        if (cJSON_AddNullToObject(item, "thresValue") == NULL) {
112
0
            ogs_error("OpenAPI_steering_mode_convertToJSON() failed [thres_value]");
113
0
            goto end;
114
0
        }
115
0
    }
116
117
0
    if (steering_mode->steer_mode_ind != OpenAPI_steer_mode_indicator_NULL) {
118
0
    if (cJSON_AddStringToObject(item, "steerModeInd", OpenAPI_steer_mode_indicator_ToString(steering_mode->steer_mode_ind)) == NULL) {
119
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed [steer_mode_ind]");
120
0
        goto end;
121
0
    }
122
0
    }
123
124
0
    if (steering_mode->primary != OpenAPI_access_type_NULL) {
125
0
    if (cJSON_AddStringToObject(item, "primary", OpenAPI_access_type_ToString(steering_mode->primary)) == NULL) {
126
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed [primary]");
127
0
        goto end;
128
0
    }
129
0
    }
130
131
0
end:
132
0
    return item;
133
0
}
134
135
OpenAPI_steering_mode_t *OpenAPI_steering_mode_parseFromJSON(cJSON *steering_modeJSON)
136
0
{
137
0
    OpenAPI_steering_mode_t *steering_mode_local_var = NULL;
138
0
    OpenAPI_lnode_t *node = NULL;
139
0
    cJSON *steer_mode_value = NULL;
140
0
    OpenAPI_steer_mode_value_e steer_mode_valueVariable = 0;
141
0
    cJSON *active = NULL;
142
0
    OpenAPI_access_type_e activeVariable = 0;
143
0
    cJSON *standby = NULL;
144
0
    OpenAPI_access_type_e standbyVariable = 0;
145
0
    cJSON *_3g_load = NULL;
146
0
    cJSON *prio_acc = NULL;
147
0
    OpenAPI_access_type_e prio_accVariable = 0;
148
0
    cJSON *thres_value = NULL;
149
0
    OpenAPI_threshold_value_t *thres_value_local_nonprim = NULL;
150
0
    cJSON *steer_mode_ind = NULL;
151
0
    OpenAPI_steer_mode_indicator_e steer_mode_indVariable = 0;
152
0
    cJSON *primary = NULL;
153
0
    OpenAPI_access_type_e primaryVariable = 0;
154
0
    steer_mode_value = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "steerModeValue");
155
0
    if (!steer_mode_value) {
156
0
        ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [steer_mode_value]");
157
0
        goto end;
158
0
    }
159
0
    if (!cJSON_IsString(steer_mode_value)) {
160
0
        ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [steer_mode_value]");
161
0
        goto end;
162
0
    }
163
0
    steer_mode_valueVariable = OpenAPI_steer_mode_value_FromString(steer_mode_value->valuestring);
164
165
0
    active = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "active");
166
0
    if (active) {
167
0
    if (!cJSON_IsString(active)) {
168
0
        ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [active]");
169
0
        goto end;
170
0
    }
171
0
    activeVariable = OpenAPI_access_type_FromString(active->valuestring);
172
0
    }
173
174
0
    standby = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "standby");
175
0
    if (standby) {
176
0
    if (!cJSON_IsString(standby)) {
177
0
        ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [standby]");
178
0
        goto end;
179
0
    }
180
0
    standbyVariable = OpenAPI_access_type_FromString(standby->valuestring);
181
0
    }
182
183
0
    _3g_load = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "3gLoad");
184
0
    if (_3g_load) {
185
0
    if (!cJSON_IsNumber(_3g_load)) {
186
0
        ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [_3g_load]");
187
0
        goto end;
188
0
    }
189
0
    }
190
191
0
    prio_acc = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "prioAcc");
192
0
    if (prio_acc) {
193
0
    if (!cJSON_IsString(prio_acc)) {
194
0
        ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [prio_acc]");
195
0
        goto end;
196
0
    }
197
0
    prio_accVariable = OpenAPI_access_type_FromString(prio_acc->valuestring);
198
0
    }
199
200
0
    thres_value = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "thresValue");
201
0
    if (thres_value) {
202
0
    if (!cJSON_IsNull(thres_value)) {
203
0
    thres_value_local_nonprim = OpenAPI_threshold_value_parseFromJSON(thres_value);
204
0
    if (!thres_value_local_nonprim) {
205
0
        ogs_error("OpenAPI_threshold_value_parseFromJSON failed [thres_value]");
206
0
        goto end;
207
0
    }
208
0
    }
209
0
    }
210
211
0
    steer_mode_ind = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "steerModeInd");
212
0
    if (steer_mode_ind) {
213
0
    if (!cJSON_IsString(steer_mode_ind)) {
214
0
        ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [steer_mode_ind]");
215
0
        goto end;
216
0
    }
217
0
    steer_mode_indVariable = OpenAPI_steer_mode_indicator_FromString(steer_mode_ind->valuestring);
218
0
    }
219
220
0
    primary = cJSON_GetObjectItemCaseSensitive(steering_modeJSON, "primary");
221
0
    if (primary) {
222
0
    if (!cJSON_IsString(primary)) {
223
0
        ogs_error("OpenAPI_steering_mode_parseFromJSON() failed [primary]");
224
0
        goto end;
225
0
    }
226
0
    primaryVariable = OpenAPI_access_type_FromString(primary->valuestring);
227
0
    }
228
229
0
    steering_mode_local_var = OpenAPI_steering_mode_create (
230
0
        steer_mode_valueVariable,
231
0
        active ? activeVariable : 0,
232
0
        standby ? standbyVariable : 0,
233
0
        _3g_load ? true : false,
234
0
        _3g_load ? _3g_load->valuedouble : 0,
235
0
        prio_acc ? prio_accVariable : 0,
236
0
        thres_value && cJSON_IsNull(thres_value) ? true : false,
237
0
        thres_value ? thres_value_local_nonprim : NULL,
238
0
        steer_mode_ind ? steer_mode_indVariable : 0,
239
0
        primary ? primaryVariable : 0
240
0
    );
241
242
0
    return steering_mode_local_var;
243
0
end:
244
0
    if (thres_value_local_nonprim) {
245
0
        OpenAPI_threshold_value_free(thres_value_local_nonprim);
246
0
        thres_value_local_nonprim = NULL;
247
0
    }
248
0
    return NULL;
249
0
}
250
251
OpenAPI_steering_mode_t *OpenAPI_steering_mode_copy(OpenAPI_steering_mode_t *dst, OpenAPI_steering_mode_t *src)
252
0
{
253
0
    cJSON *item = NULL;
254
0
    char *content = NULL;
255
256
0
    ogs_assert(src);
257
0
    item = OpenAPI_steering_mode_convertToJSON(src);
258
0
    if (!item) {
259
0
        ogs_error("OpenAPI_steering_mode_convertToJSON() failed");
260
0
        return NULL;
261
0
    }
262
263
0
    content = cJSON_Print(item);
264
0
    cJSON_Delete(item);
265
266
0
    if (!content) {
267
0
        ogs_error("cJSON_Print() failed");
268
0
        return NULL;
269
0
    }
270
271
0
    item = cJSON_Parse(content);
272
0
    ogs_free(content);
273
0
    if (!item) {
274
0
        ogs_error("cJSON_Parse() failed");
275
0
        return NULL;
276
0
    }
277
278
0
    OpenAPI_steering_mode_free(dst);
279
0
    dst = OpenAPI_steering_mode_parseFromJSON(item);
280
0
    cJSON_Delete(item);
281
282
0
    return dst;
283
0
}
284