mirror of
https://github.com/open5gs/open5gs.git
synced 2025-11-09 00:16:51 +00:00
72 lines
1.9 KiB
C
72 lines
1.9 KiB
C
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include "links_value_schema.h"
|
|
|
|
OpenAPI_links_value_schema_t *OpenAPI_links_value_schema_create(
|
|
char *href
|
|
)
|
|
{
|
|
OpenAPI_links_value_schema_t *links_value_schema_local_var = OpenAPI_malloc(sizeof(OpenAPI_links_value_schema_t));
|
|
if (!links_value_schema_local_var) {
|
|
return NULL;
|
|
}
|
|
links_value_schema_local_var->href = href;
|
|
|
|
return links_value_schema_local_var;
|
|
}
|
|
|
|
void OpenAPI_links_value_schema_free(OpenAPI_links_value_schema_t *links_value_schema)
|
|
{
|
|
if (NULL == links_value_schema) {
|
|
return;
|
|
}
|
|
OpenAPI_lnode_t *node;
|
|
ogs_free(links_value_schema->href);
|
|
ogs_free(links_value_schema);
|
|
}
|
|
|
|
cJSON *OpenAPI_links_value_schema_convertToJSON(OpenAPI_links_value_schema_t *links_value_schema)
|
|
{
|
|
cJSON *item = NULL;
|
|
|
|
if (links_value_schema == NULL) {
|
|
ogs_error("OpenAPI_links_value_schema_convertToJSON() failed [LinksValueSchema]");
|
|
return NULL;
|
|
}
|
|
|
|
item = cJSON_CreateObject();
|
|
if (links_value_schema->href) {
|
|
if (cJSON_AddStringToObject(item, "href", links_value_schema->href) == NULL) {
|
|
ogs_error("OpenAPI_links_value_schema_convertToJSON() failed [href]");
|
|
goto end;
|
|
}
|
|
}
|
|
|
|
end:
|
|
return item;
|
|
}
|
|
|
|
OpenAPI_links_value_schema_t *OpenAPI_links_value_schema_parseFromJSON(cJSON *links_value_schemaJSON)
|
|
{
|
|
OpenAPI_links_value_schema_t *links_value_schema_local_var = NULL;
|
|
cJSON *href = cJSON_GetObjectItemCaseSensitive(links_value_schemaJSON, "href");
|
|
|
|
if (href) {
|
|
if (!cJSON_IsString(href)) {
|
|
ogs_error("OpenAPI_links_value_schema_parseFromJSON() failed [href]");
|
|
goto end;
|
|
}
|
|
}
|
|
|
|
links_value_schema_local_var = OpenAPI_links_value_schema_create (
|
|
href ? ogs_strdup(href->valuestring) : NULL
|
|
);
|
|
|
|
return links_value_schema_local_var;
|
|
end:
|
|
return NULL;
|
|
}
|
|
|