Coverage Report

Created: 2026-10-16 06:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open5gs/lib/sbi/openapi/model/roaming_restrictions.c
Line
Count
Source
1
2
#include <stdlib.h>
3
#include <string.h>
4
#include <stdio.h>
5
#include "roaming_restrictions.h"
6
7
OpenAPI_roaming_restrictions_t *OpenAPI_roaming_restrictions_create(
8
    bool is_access_allowed,
9
    int access_allowed
10
)
11
1
{
12
1
    OpenAPI_roaming_restrictions_t *roaming_restrictions_local_var = ogs_malloc(sizeof(OpenAPI_roaming_restrictions_t));
13
1
    ogs_assert(roaming_restrictions_local_var);
14
15
1
    roaming_restrictions_local_var->is_access_allowed = is_access_allowed;
16
1
    roaming_restrictions_local_var->access_allowed = access_allowed;
17
18
1
    return roaming_restrictions_local_var;
19
1
}
20
21
void OpenAPI_roaming_restrictions_free(OpenAPI_roaming_restrictions_t *roaming_restrictions)
22
1
{
23
1
    OpenAPI_lnode_t *node = NULL;
24
25
1
    if (NULL == roaming_restrictions) {
26
0
        return;
27
0
    }
28
1
    ogs_free(roaming_restrictions);
29
1
}
30
31
cJSON *OpenAPI_roaming_restrictions_convertToJSON(OpenAPI_roaming_restrictions_t *roaming_restrictions)
32
0
{
33
0
    cJSON *item = NULL;
34
0
    OpenAPI_lnode_t *node = NULL;
35
36
0
    if (roaming_restrictions == NULL) {
37
0
        ogs_error("OpenAPI_roaming_restrictions_convertToJSON() failed [RoamingRestrictions]");
38
0
        return NULL;
39
0
    }
40
41
0
    item = cJSON_CreateObject();
42
0
    if (roaming_restrictions->is_access_allowed) {
43
0
    if (cJSON_AddBoolToObject(item, "accessAllowed", roaming_restrictions->access_allowed) == NULL) {
44
0
        ogs_error("OpenAPI_roaming_restrictions_convertToJSON() failed [access_allowed]");
45
0
        goto end;
46
0
    }
47
0
    }
48
49
0
end:
50
0
    return item;
51
0
}
52
53
OpenAPI_roaming_restrictions_t *OpenAPI_roaming_restrictions_parseFromJSON(cJSON *roaming_restrictionsJSON)
54
1
{
55
1
    OpenAPI_roaming_restrictions_t *roaming_restrictions_local_var = NULL;
56
1
    OpenAPI_lnode_t *node = NULL;
57
1
    cJSON *access_allowed = NULL;
58
1
    access_allowed = cJSON_GetObjectItemCaseSensitive(roaming_restrictionsJSON, "accessAllowed");
59
1
    if (access_allowed) {
60
0
    if (!cJSON_IsBool(access_allowed)) {
61
0
        ogs_error("OpenAPI_roaming_restrictions_parseFromJSON() failed [access_allowed]");
62
0
        goto end;
63
0
    }
64
0
    }
65
66
1
    roaming_restrictions_local_var = OpenAPI_roaming_restrictions_create (
67
1
        access_allowed ? true : false,
68
1
        access_allowed ? access_allowed->valueint : 0
69
1
    );
70
71
1
    return roaming_restrictions_local_var;
72
0
end:
73
0
    return NULL;
74
1
}
75
76
OpenAPI_roaming_restrictions_t *OpenAPI_roaming_restrictions_copy(OpenAPI_roaming_restrictions_t *dst, OpenAPI_roaming_restrictions_t *src)
77
0
{
78
0
    cJSON *item = NULL;
79
0
    char *content = NULL;
80
81
0
    ogs_assert(src);
82
0
    item = OpenAPI_roaming_restrictions_convertToJSON(src);
83
0
    if (!item) {
84
0
        ogs_error("OpenAPI_roaming_restrictions_convertToJSON() failed");
85
0
        return NULL;
86
0
    }
87
88
0
    content = cJSON_Print(item);
89
0
    cJSON_Delete(item);
90
91
0
    if (!content) {
92
0
        ogs_error("cJSON_Print() failed");
93
0
        return NULL;
94
0
    }
95
96
0
    item = cJSON_Parse(content);
97
0
    ogs_free(content);
98
0
    if (!item) {
99
0
        ogs_error("cJSON_Parse() failed");
100
0
        return NULL;
101
0
    }
102
103
0
    OpenAPI_roaming_restrictions_free(dst);
104
0
    dst = OpenAPI_roaming_restrictions_parseFromJSON(item);
105
0
    cJSON_Delete(item);
106
107
0
    return dst;
108
0
}
109