Coverage Report

Created: 2026-06-30 06:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/plmn_range.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "plmn_range.h"
6
7
OpenAPI_plmn_range_t *OpenAPI_plmn_range_create(
8
    char *start,
9
    char *end,
10
    char *pattern
11
)
12
0
{
13
0
    OpenAPI_plmn_range_t *plmn_range_local_var = ogs_malloc(sizeof(OpenAPI_plmn_range_t));
14
0
    ogs_assert(plmn_range_local_var);
15
16
0
    plmn_range_local_var->start = start;
17
0
    plmn_range_local_var->end = end;
18
0
    plmn_range_local_var->pattern = pattern;
19
20
0
    return plmn_range_local_var;
21
0
}
22
23
void OpenAPI_plmn_range_free(OpenAPI_plmn_range_t *plmn_range)
24
0
{
25
0
    OpenAPI_lnode_t *node = NULL;
26
27
0
    if (NULL == plmn_range) {
28
0
        return;
29
0
    }
30
0
    if (plmn_range->start) {
31
0
        ogs_free(plmn_range->start);
32
0
        plmn_range->start = NULL;
33
0
    }
34
0
    if (plmn_range->end) {
35
0
        ogs_free(plmn_range->end);
36
0
        plmn_range->end = NULL;
37
0
    }
38
0
    if (plmn_range->pattern) {
39
0
        ogs_free(plmn_range->pattern);
40
0
        plmn_range->pattern = NULL;
41
0
    }
42
0
    ogs_free(plmn_range);
43
0
}
44
45
cJSON *OpenAPI_plmn_range_convertToJSON(OpenAPI_plmn_range_t *plmn_range)
46
0
{
47
0
    cJSON *item = NULL;
48
0
    OpenAPI_lnode_t *node = NULL;
49
50
0
    if (plmn_range == NULL) {
51
0
        ogs_error("OpenAPI_plmn_range_convertToJSON() failed [PlmnRange]");
52
0
        return NULL;
53
0
    }
54
55
0
    item = cJSON_CreateObject();
56
0
    if (plmn_range->start) {
57
0
    if (cJSON_AddStringToObject(item, "start", plmn_range->start) == NULL) {
58
0
        ogs_error("OpenAPI_plmn_range_convertToJSON() failed [start]");
59
0
        goto end;
60
0
    }
61
0
    }
62
63
0
    if (plmn_range->end) {
64
0
    if (cJSON_AddStringToObject(item, "end", plmn_range->end) == NULL) {
65
0
        ogs_error("OpenAPI_plmn_range_convertToJSON() failed [end]");
66
0
        goto end;
67
0
    }
68
0
    }
69
70
0
    if (plmn_range->pattern) {
71
0
    if (cJSON_AddStringToObject(item, "pattern", plmn_range->pattern) == NULL) {
72
0
        ogs_error("OpenAPI_plmn_range_convertToJSON() failed [pattern]");
73
0
        goto end;
74
0
    }
75
0
    }
76
77
0
end:
78
0
    return item;
79
0
}
80
81
OpenAPI_plmn_range_t *OpenAPI_plmn_range_parseFromJSON(cJSON *plmn_rangeJSON)
82
0
{
83
0
    OpenAPI_plmn_range_t *plmn_range_local_var = NULL;
84
0
    OpenAPI_lnode_t *node = NULL;
85
0
    cJSON *start = NULL;
86
0
    cJSON *end = NULL;
87
0
    cJSON *pattern = NULL;
88
0
    start = cJSON_GetObjectItemCaseSensitive(plmn_rangeJSON, "start");
89
0
    if (start) {
90
0
    if (!cJSON_IsString(start) && !cJSON_IsNull(start)) {
91
0
        ogs_error("OpenAPI_plmn_range_parseFromJSON() failed [start]");
92
0
        goto end;
93
0
    }
94
0
    }
95
96
0
    end = cJSON_GetObjectItemCaseSensitive(plmn_rangeJSON, "end");
97
0
    if (end) {
98
0
    if (!cJSON_IsString(end) && !cJSON_IsNull(end)) {
99
0
        ogs_error("OpenAPI_plmn_range_parseFromJSON() failed [end]");
100
0
        goto end;
101
0
    }
102
0
    }
103
104
0
    pattern = cJSON_GetObjectItemCaseSensitive(plmn_rangeJSON, "pattern");
105
0
    if (pattern) {
106
0
    if (!cJSON_IsString(pattern) && !cJSON_IsNull(pattern)) {
107
0
        ogs_error("OpenAPI_plmn_range_parseFromJSON() failed [pattern]");
108
0
        goto end;
109
0
    }
110
0
    }
111
112
0
    plmn_range_local_var = OpenAPI_plmn_range_create (
113
0
        start && !cJSON_IsNull(start) ? ogs_strdup(start->valuestring) : NULL,
114
0
        end && !cJSON_IsNull(end) ? ogs_strdup(end->valuestring) : NULL,
115
0
        pattern && !cJSON_IsNull(pattern) ? ogs_strdup(pattern->valuestring) : NULL
116
0
    );
117
118
0
    return plmn_range_local_var;
119
0
end:
120
0
    return NULL;
121
0
}
122
123
OpenAPI_plmn_range_t *OpenAPI_plmn_range_copy(OpenAPI_plmn_range_t *dst, OpenAPI_plmn_range_t *src)
124
0
{
125
0
    cJSON *item = NULL;
126
0
    char *content = NULL;
127
128
0
    ogs_assert(src);
129
0
    item = OpenAPI_plmn_range_convertToJSON(src);
130
0
    if (!item) {
131
0
        ogs_error("OpenAPI_plmn_range_convertToJSON() failed");
132
0
        return NULL;
133
0
    }
134
135
0
    content = cJSON_Print(item);
136
0
    cJSON_Delete(item);
137
138
0
    if (!content) {
139
0
        ogs_error("cJSON_Print() failed");
140
0
        return NULL;
141
0
    }
142
143
0
    item = cJSON_Parse(content);
144
0
    ogs_free(content);
145
0
    if (!item) {
146
0
        ogs_error("cJSON_Parse() failed");
147
0
        return NULL;
148
0
    }
149
150
0
    OpenAPI_plmn_range_free(dst);
151
0
    dst = OpenAPI_plmn_range_parseFromJSON(item);
152
0
    cJSON_Delete(item);
153
154
0
    return dst;
155
0
}
156