Coverage Report

Created: 2026-10-16 06:49

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