Coverage Report

Created: 2026-09-27 06:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/bw_requirement.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "bw_requirement.h"
6
7
OpenAPI_bw_requirement_t *OpenAPI_bw_requirement_create(
8
    char *app_id,
9
    char *mar_bw_dl,
10
    char *mar_bw_ul,
11
    char *mir_bw_dl,
12
    char *mir_bw_ul
13
)
14
0
{
15
0
    OpenAPI_bw_requirement_t *bw_requirement_local_var = ogs_malloc(sizeof(OpenAPI_bw_requirement_t));
16
0
    ogs_assert(bw_requirement_local_var);
17
18
0
    bw_requirement_local_var->app_id = app_id;
19
0
    bw_requirement_local_var->mar_bw_dl = mar_bw_dl;
20
0
    bw_requirement_local_var->mar_bw_ul = mar_bw_ul;
21
0
    bw_requirement_local_var->mir_bw_dl = mir_bw_dl;
22
0
    bw_requirement_local_var->mir_bw_ul = mir_bw_ul;
23
24
0
    return bw_requirement_local_var;
25
0
}
26
27
void OpenAPI_bw_requirement_free(OpenAPI_bw_requirement_t *bw_requirement)
28
0
{
29
0
    OpenAPI_lnode_t *node = NULL;
30
31
0
    if (NULL == bw_requirement) {
32
0
        return;
33
0
    }
34
0
    if (bw_requirement->app_id) {
35
0
        ogs_free(bw_requirement->app_id);
36
0
        bw_requirement->app_id = NULL;
37
0
    }
38
0
    if (bw_requirement->mar_bw_dl) {
39
0
        ogs_free(bw_requirement->mar_bw_dl);
40
0
        bw_requirement->mar_bw_dl = NULL;
41
0
    }
42
0
    if (bw_requirement->mar_bw_ul) {
43
0
        ogs_free(bw_requirement->mar_bw_ul);
44
0
        bw_requirement->mar_bw_ul = NULL;
45
0
    }
46
0
    if (bw_requirement->mir_bw_dl) {
47
0
        ogs_free(bw_requirement->mir_bw_dl);
48
0
        bw_requirement->mir_bw_dl = NULL;
49
0
    }
50
0
    if (bw_requirement->mir_bw_ul) {
51
0
        ogs_free(bw_requirement->mir_bw_ul);
52
0
        bw_requirement->mir_bw_ul = NULL;
53
0
    }
54
0
    ogs_free(bw_requirement);
55
0
}
56
57
cJSON *OpenAPI_bw_requirement_convertToJSON(OpenAPI_bw_requirement_t *bw_requirement)
58
0
{
59
0
    cJSON *item = NULL;
60
0
    OpenAPI_lnode_t *node = NULL;
61
62
0
    if (bw_requirement == NULL) {
63
0
        ogs_error("OpenAPI_bw_requirement_convertToJSON() failed [BwRequirement]");
64
0
        return NULL;
65
0
    }
66
67
0
    item = cJSON_CreateObject();
68
0
    if (!bw_requirement->app_id) {
69
0
        ogs_error("OpenAPI_bw_requirement_convertToJSON() failed [app_id]");
70
0
        return NULL;
71
0
    }
72
0
    if (cJSON_AddStringToObject(item, "appId", bw_requirement->app_id) == NULL) {
73
0
        ogs_error("OpenAPI_bw_requirement_convertToJSON() failed [app_id]");
74
0
        goto end;
75
0
    }
76
77
0
    if (bw_requirement->mar_bw_dl) {
78
0
    if (cJSON_AddStringToObject(item, "marBwDl", bw_requirement->mar_bw_dl) == NULL) {
79
0
        ogs_error("OpenAPI_bw_requirement_convertToJSON() failed [mar_bw_dl]");
80
0
        goto end;
81
0
    }
82
0
    }
83
84
0
    if (bw_requirement->mar_bw_ul) {
85
0
    if (cJSON_AddStringToObject(item, "marBwUl", bw_requirement->mar_bw_ul) == NULL) {
86
0
        ogs_error("OpenAPI_bw_requirement_convertToJSON() failed [mar_bw_ul]");
87
0
        goto end;
88
0
    }
89
0
    }
90
91
0
    if (bw_requirement->mir_bw_dl) {
92
0
    if (cJSON_AddStringToObject(item, "mirBwDl", bw_requirement->mir_bw_dl) == NULL) {
93
0
        ogs_error("OpenAPI_bw_requirement_convertToJSON() failed [mir_bw_dl]");
94
0
        goto end;
95
0
    }
96
0
    }
97
98
0
    if (bw_requirement->mir_bw_ul) {
99
0
    if (cJSON_AddStringToObject(item, "mirBwUl", bw_requirement->mir_bw_ul) == NULL) {
100
0
        ogs_error("OpenAPI_bw_requirement_convertToJSON() failed [mir_bw_ul]");
101
0
        goto end;
102
0
    }
103
0
    }
104
105
0
end:
106
0
    return item;
107
0
}
108
109
OpenAPI_bw_requirement_t *OpenAPI_bw_requirement_parseFromJSON(cJSON *bw_requirementJSON)
110
0
{
111
0
    OpenAPI_bw_requirement_t *bw_requirement_local_var = NULL;
112
0
    OpenAPI_lnode_t *node = NULL;
113
0
    cJSON *app_id = NULL;
114
0
    cJSON *mar_bw_dl = NULL;
115
0
    cJSON *mar_bw_ul = NULL;
116
0
    cJSON *mir_bw_dl = NULL;
117
0
    cJSON *mir_bw_ul = NULL;
118
0
    app_id = cJSON_GetObjectItemCaseSensitive(bw_requirementJSON, "appId");
119
0
    if (!app_id) {
120
0
        ogs_error("OpenAPI_bw_requirement_parseFromJSON() failed [app_id]");
121
0
        goto end;
122
0
    }
123
0
    if (!cJSON_IsString(app_id)) {
124
0
        ogs_error("OpenAPI_bw_requirement_parseFromJSON() failed [app_id]");
125
0
        goto end;
126
0
    }
127
128
0
    mar_bw_dl = cJSON_GetObjectItemCaseSensitive(bw_requirementJSON, "marBwDl");
129
0
    if (mar_bw_dl) {
130
0
    if (!cJSON_IsString(mar_bw_dl) && !cJSON_IsNull(mar_bw_dl)) {
131
0
        ogs_error("OpenAPI_bw_requirement_parseFromJSON() failed [mar_bw_dl]");
132
0
        goto end;
133
0
    }
134
0
    }
135
136
0
    mar_bw_ul = cJSON_GetObjectItemCaseSensitive(bw_requirementJSON, "marBwUl");
137
0
    if (mar_bw_ul) {
138
0
    if (!cJSON_IsString(mar_bw_ul) && !cJSON_IsNull(mar_bw_ul)) {
139
0
        ogs_error("OpenAPI_bw_requirement_parseFromJSON() failed [mar_bw_ul]");
140
0
        goto end;
141
0
    }
142
0
    }
143
144
0
    mir_bw_dl = cJSON_GetObjectItemCaseSensitive(bw_requirementJSON, "mirBwDl");
145
0
    if (mir_bw_dl) {
146
0
    if (!cJSON_IsString(mir_bw_dl) && !cJSON_IsNull(mir_bw_dl)) {
147
0
        ogs_error("OpenAPI_bw_requirement_parseFromJSON() failed [mir_bw_dl]");
148
0
        goto end;
149
0
    }
150
0
    }
151
152
0
    mir_bw_ul = cJSON_GetObjectItemCaseSensitive(bw_requirementJSON, "mirBwUl");
153
0
    if (mir_bw_ul) {
154
0
    if (!cJSON_IsString(mir_bw_ul) && !cJSON_IsNull(mir_bw_ul)) {
155
0
        ogs_error("OpenAPI_bw_requirement_parseFromJSON() failed [mir_bw_ul]");
156
0
        goto end;
157
0
    }
158
0
    }
159
160
0
    bw_requirement_local_var = OpenAPI_bw_requirement_create (
161
0
        ogs_strdup(app_id->valuestring),
162
0
        mar_bw_dl && !cJSON_IsNull(mar_bw_dl) ? ogs_strdup(mar_bw_dl->valuestring) : NULL,
163
0
        mar_bw_ul && !cJSON_IsNull(mar_bw_ul) ? ogs_strdup(mar_bw_ul->valuestring) : NULL,
164
0
        mir_bw_dl && !cJSON_IsNull(mir_bw_dl) ? ogs_strdup(mir_bw_dl->valuestring) : NULL,
165
0
        mir_bw_ul && !cJSON_IsNull(mir_bw_ul) ? ogs_strdup(mir_bw_ul->valuestring) : NULL
166
0
    );
167
168
0
    return bw_requirement_local_var;
169
0
end:
170
0
    return NULL;
171
0
}
172
173
OpenAPI_bw_requirement_t *OpenAPI_bw_requirement_copy(OpenAPI_bw_requirement_t *dst, OpenAPI_bw_requirement_t *src)
174
0
{
175
0
    cJSON *item = NULL;
176
0
    char *content = NULL;
177
178
0
    ogs_assert(src);
179
0
    item = OpenAPI_bw_requirement_convertToJSON(src);
180
0
    if (!item) {
181
0
        ogs_error("OpenAPI_bw_requirement_convertToJSON() failed");
182
0
        return NULL;
183
0
    }
184
185
0
    content = cJSON_Print(item);
186
0
    cJSON_Delete(item);
187
188
0
    if (!content) {
189
0
        ogs_error("cJSON_Print() failed");
190
0
        return NULL;
191
0
    }
192
193
0
    item = cJSON_Parse(content);
194
0
    ogs_free(content);
195
0
    if (!item) {
196
0
        ogs_error("cJSON_Parse() failed");
197
0
        return NULL;
198
0
    }
199
200
0
    OpenAPI_bw_requirement_free(dst);
201
0
    dst = OpenAPI_bw_requirement_parseFromJSON(item);
202
0
    cJSON_Delete(item);
203
204
0
    return dst;
205
0
}
206