Coverage Report

Created: 2026-09-27 06:19

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