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