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