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