Coverage Report

Created: 2026-11-12 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/condition_data.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "condition_data.h"
6
7
OpenAPI_condition_data_t *OpenAPI_condition_data_create(
8
    char *cond_id,
9
    bool is_activation_time_null,
10
    char *activation_time,
11
    bool is_deactivation_time_null,
12
    char *deactivation_time,
13
    OpenAPI_access_type_e access_type,
14
    OpenAPI_rat_type_e rat_type
15
)
16
1.29k
{
17
1.29k
    OpenAPI_condition_data_t *condition_data_local_var = ogs_malloc(sizeof(OpenAPI_condition_data_t));
18
1.29k
    ogs_assert(condition_data_local_var);
19
20
1.29k
    condition_data_local_var->cond_id = cond_id;
21
1.29k
    condition_data_local_var->is_activation_time_null = is_activation_time_null;
22
1.29k
    condition_data_local_var->activation_time = activation_time;
23
1.29k
    condition_data_local_var->is_deactivation_time_null = is_deactivation_time_null;
24
1.29k
    condition_data_local_var->deactivation_time = deactivation_time;
25
1.29k
    condition_data_local_var->access_type = access_type;
26
1.29k
    condition_data_local_var->rat_type = rat_type;
27
28
1.29k
    return condition_data_local_var;
29
1.29k
}
30
31
void OpenAPI_condition_data_free(OpenAPI_condition_data_t *condition_data)
32
4.10k
{
33
4.10k
    OpenAPI_lnode_t *node = NULL;
34
35
4.10k
    if (NULL == condition_data) {
36
2.80k
        return;
37
2.80k
    }
38
1.29k
    if (condition_data->cond_id) {
39
1.29k
        ogs_free(condition_data->cond_id);
40
1.29k
        condition_data->cond_id = NULL;
41
1.29k
    }
42
1.29k
    if (condition_data->activation_time) {
43
66
        ogs_free(condition_data->activation_time);
44
66
        condition_data->activation_time = NULL;
45
66
    }
46
1.29k
    if (condition_data->deactivation_time) {
47
66
        ogs_free(condition_data->deactivation_time);
48
66
        condition_data->deactivation_time = NULL;
49
66
    }
50
1.29k
    ogs_free(condition_data);
51
1.29k
}
52
53
cJSON *OpenAPI_condition_data_convertToJSON(OpenAPI_condition_data_t *condition_data)
54
0
{
55
0
    cJSON *item = NULL;
56
0
    OpenAPI_lnode_t *node = NULL;
57
58
0
    if (condition_data == NULL) {
59
0
        ogs_error("OpenAPI_condition_data_convertToJSON() failed [ConditionData]");
60
0
        return NULL;
61
0
    }
62
63
0
    item = cJSON_CreateObject();
64
0
    if (!condition_data->cond_id) {
65
0
        ogs_error("OpenAPI_condition_data_convertToJSON() failed [cond_id]");
66
0
        return NULL;
67
0
    }
68
0
    if (cJSON_AddStringToObject(item, "condId", condition_data->cond_id) == NULL) {
69
0
        ogs_error("OpenAPI_condition_data_convertToJSON() failed [cond_id]");
70
0
        goto end;
71
0
    }
72
73
0
    if (condition_data->activation_time) {
74
0
    if (cJSON_AddStringToObject(item, "activationTime", condition_data->activation_time) == NULL) {
75
0
        ogs_error("OpenAPI_condition_data_convertToJSON() failed [activation_time]");
76
0
        goto end;
77
0
    }
78
0
    } else if (condition_data->is_activation_time_null) {
79
0
        if (cJSON_AddNullToObject(item, "activationTime") == NULL) {
80
0
            ogs_error("OpenAPI_condition_data_convertToJSON() failed [activation_time]");
81
0
            goto end;
82
0
        }
83
0
    }
84
85
0
    if (condition_data->deactivation_time) {
86
0
    if (cJSON_AddStringToObject(item, "deactivationTime", condition_data->deactivation_time) == NULL) {
87
0
        ogs_error("OpenAPI_condition_data_convertToJSON() failed [deactivation_time]");
88
0
        goto end;
89
0
    }
90
0
    } else if (condition_data->is_deactivation_time_null) {
91
0
        if (cJSON_AddNullToObject(item, "deactivationTime") == NULL) {
92
0
            ogs_error("OpenAPI_condition_data_convertToJSON() failed [deactivation_time]");
93
0
            goto end;
94
0
        }
95
0
    }
96
97
0
    if (condition_data->access_type != OpenAPI_access_type_NULL) {
98
0
    if (cJSON_AddStringToObject(item, "accessType", OpenAPI_access_type_ToString(condition_data->access_type)) == NULL) {
99
0
        ogs_error("OpenAPI_condition_data_convertToJSON() failed [access_type]");
100
0
        goto end;
101
0
    }
102
0
    }
103
104
0
    if (condition_data->rat_type != OpenAPI_rat_type_NULL) {
105
0
    if (cJSON_AddStringToObject(item, "ratType", OpenAPI_rat_type_ToString(condition_data->rat_type)) == NULL) {
106
0
        ogs_error("OpenAPI_condition_data_convertToJSON() failed [rat_type]");
107
0
        goto end;
108
0
    }
109
0
    }
110
111
0
end:
112
0
    return item;
113
0
}
114
115
OpenAPI_condition_data_t *OpenAPI_condition_data_parseFromJSON(cJSON *condition_dataJSON)
116
3.58k
{
117
3.58k
    OpenAPI_condition_data_t *condition_data_local_var = NULL;
118
3.58k
    OpenAPI_lnode_t *node = NULL;
119
3.58k
    cJSON *cond_id = NULL;
120
3.58k
    cJSON *activation_time = NULL;
121
3.58k
    cJSON *deactivation_time = NULL;
122
3.58k
    cJSON *access_type = NULL;
123
3.58k
    OpenAPI_access_type_e access_typeVariable = 0;
124
3.58k
    cJSON *rat_type = NULL;
125
3.58k
    OpenAPI_rat_type_e rat_typeVariable = 0;
126
3.58k
    cond_id = cJSON_GetObjectItemCaseSensitive(condition_dataJSON, "condId");
127
3.58k
    if (!cond_id) {
128
1.39k
        ogs_error("OpenAPI_condition_data_parseFromJSON() failed [cond_id]");
129
1.39k
        goto end;
130
1.39k
    }
131
2.18k
    if (!cJSON_IsString(cond_id)) {
132
196
        ogs_error("OpenAPI_condition_data_parseFromJSON() failed [cond_id]");
133
196
        goto end;
134
196
    }
135
136
1.99k
    activation_time = cJSON_GetObjectItemCaseSensitive(condition_dataJSON, "activationTime");
137
1.99k
    if (activation_time) {
138
326
    if (!cJSON_IsNull(activation_time)) {
139
132
    if (!cJSON_IsString(activation_time) && !cJSON_IsNull(activation_time)) {
140
66
        ogs_error("OpenAPI_condition_data_parseFromJSON() failed [activation_time]");
141
66
        goto end;
142
66
    }
143
132
    }
144
326
    }
145
146
1.92k
    deactivation_time = cJSON_GetObjectItemCaseSensitive(condition_dataJSON, "deactivationTime");
147
1.92k
    if (deactivation_time) {
148
326
    if (!cJSON_IsNull(deactivation_time)) {
149
260
    if (!cJSON_IsString(deactivation_time) && !cJSON_IsNull(deactivation_time)) {
150
194
        ogs_error("OpenAPI_condition_data_parseFromJSON() failed [deactivation_time]");
151
194
        goto end;
152
194
    }
153
260
    }
154
326
    }
155
156
1.73k
    access_type = cJSON_GetObjectItemCaseSensitive(condition_dataJSON, "accessType");
157
1.73k
    if (access_type) {
158
375
    if (!cJSON_IsString(access_type)) {
159
309
        ogs_error("OpenAPI_condition_data_parseFromJSON() failed [access_type]");
160
309
        goto end;
161
309
    }
162
66
    access_typeVariable = OpenAPI_access_type_FromString(access_type->valuestring);
163
66
    }
164
165
1.42k
    rat_type = cJSON_GetObjectItemCaseSensitive(condition_dataJSON, "ratType");
166
1.42k
    if (rat_type) {
167
397
    if (!cJSON_IsString(rat_type)) {
168
130
        ogs_error("OpenAPI_condition_data_parseFromJSON() failed [rat_type]");
169
130
        goto end;
170
130
    }
171
267
    rat_typeVariable = OpenAPI_rat_type_FromString(rat_type->valuestring);
172
267
    }
173
174
1.29k
    condition_data_local_var = OpenAPI_condition_data_create (
175
1.29k
        ogs_strdup(cond_id->valuestring),
176
1.29k
        activation_time && cJSON_IsNull(activation_time) ? true : false,
177
1.29k
        activation_time && !cJSON_IsNull(activation_time) ? ogs_strdup(activation_time->valuestring) : NULL,
178
1.29k
        deactivation_time && cJSON_IsNull(deactivation_time) ? true : false,
179
1.29k
        deactivation_time && !cJSON_IsNull(deactivation_time) ? ogs_strdup(deactivation_time->valuestring) : NULL,
180
1.29k
        access_type ? access_typeVariable : 0,
181
1.29k
        rat_type ? rat_typeVariable : 0
182
1.29k
    );
183
184
1.29k
    return condition_data_local_var;
185
2.28k
end:
186
2.28k
    return NULL;
187
1.42k
}
188
189
OpenAPI_condition_data_t *OpenAPI_condition_data_copy(OpenAPI_condition_data_t *dst, OpenAPI_condition_data_t *src)
190
0
{
191
0
    cJSON *item = NULL;
192
0
    char *content = NULL;
193
194
0
    ogs_assert(src);
195
0
    item = OpenAPI_condition_data_convertToJSON(src);
196
0
    if (!item) {
197
0
        ogs_error("OpenAPI_condition_data_convertToJSON() failed");
198
0
        return NULL;
199
0
    }
200
201
0
    content = cJSON_Print(item);
202
0
    cJSON_Delete(item);
203
204
0
    if (!content) {
205
0
        ogs_error("cJSON_Print() failed");
206
0
        return NULL;
207
0
    }
208
209
0
    item = cJSON_Parse(content);
210
0
    ogs_free(content);
211
0
    if (!item) {
212
0
        ogs_error("cJSON_Parse() failed");
213
0
        return NULL;
214
0
    }
215
216
0
    OpenAPI_condition_data_free(dst);
217
0
    dst = OpenAPI_condition_data_parseFromJSON(item);
218
0
    cJSON_Delete(item);
219
220
0
    return dst;
221
0
}
222