open5gs/lib/sbi/openapi/model/ulcl_bp_information.c

106 lines
2.8 KiB
C
Raw Normal View History

2020-06-17 05:22:28 +00:00
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "ulcl_bp_information.h"
OpenAPI_ulcl_bp_information_t *OpenAPI_ulcl_bp_information_create(
char *ulcl_bp_upf_id
)
2020-06-17 05:22:28 +00:00
{
OpenAPI_ulcl_bp_information_t *ulcl_bp_information_local_var = OpenAPI_malloc(sizeof(OpenAPI_ulcl_bp_information_t));
if (!ulcl_bp_information_local_var) {
return NULL;
}
ulcl_bp_information_local_var->ulcl_bp_upf_id = ulcl_bp_upf_id;
return ulcl_bp_information_local_var;
}
void OpenAPI_ulcl_bp_information_free(OpenAPI_ulcl_bp_information_t *ulcl_bp_information)
{
if (NULL == ulcl_bp_information) {
return;
}
OpenAPI_lnode_t *node;
ogs_free(ulcl_bp_information->ulcl_bp_upf_id);
ogs_free(ulcl_bp_information);
}
cJSON *OpenAPI_ulcl_bp_information_convertToJSON(OpenAPI_ulcl_bp_information_t *ulcl_bp_information)
{
cJSON *item = NULL;
if (ulcl_bp_information == NULL) {
ogs_error("OpenAPI_ulcl_bp_information_convertToJSON() failed [UlclBpInformation]");
return NULL;
}
item = cJSON_CreateObject();
if (ulcl_bp_information->ulcl_bp_upf_id) {
if (cJSON_AddStringToObject(item, "ulclBpUpfId", ulcl_bp_information->ulcl_bp_upf_id) == NULL) {
ogs_error("OpenAPI_ulcl_bp_information_convertToJSON() failed [ulcl_bp_upf_id]");
goto end;
}
2020-06-17 05:22:28 +00:00
}
end:
return item;
}
OpenAPI_ulcl_bp_information_t *OpenAPI_ulcl_bp_information_parseFromJSON(cJSON *ulcl_bp_informationJSON)
{
OpenAPI_ulcl_bp_information_t *ulcl_bp_information_local_var = NULL;
cJSON *ulcl_bp_upf_id = cJSON_GetObjectItemCaseSensitive(ulcl_bp_informationJSON, "ulclBpUpfId");
if (ulcl_bp_upf_id) {
if (!cJSON_IsString(ulcl_bp_upf_id)) {
ogs_error("OpenAPI_ulcl_bp_information_parseFromJSON() failed [ulcl_bp_upf_id]");
goto end;
2020-06-17 05:22:28 +00:00
}
}
2020-06-17 05:22:28 +00:00
ulcl_bp_information_local_var = OpenAPI_ulcl_bp_information_create (
2021-06-06 13:35:46 +00:00
ulcl_bp_upf_id ? ogs_strdup_or_assert(ulcl_bp_upf_id->valuestring) : NULL
);
2020-06-17 05:22:28 +00:00
return ulcl_bp_information_local_var;
end:
return NULL;
}
OpenAPI_ulcl_bp_information_t *OpenAPI_ulcl_bp_information_copy(OpenAPI_ulcl_bp_information_t *dst, OpenAPI_ulcl_bp_information_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_ulcl_bp_information_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_ulcl_bp_information_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_ulcl_bp_information_free(dst);
dst = OpenAPI_ulcl_bp_information_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}