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