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