mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-05 07:08:11 +00:00
Added NRF
This commit is contained in:
parent
46f20cc979
commit
d0673e3066
397 changed files with 85455 additions and 209 deletions
71
lib/sbi/openapi/model/link.c
Normal file
71
lib/sbi/openapi/model/link.c
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "link.h"
|
||||
|
||||
OpenAPI_link_t *OpenAPI_link_create(
|
||||
char *href
|
||||
)
|
||||
{
|
||||
OpenAPI_link_t *link_local_var = OpenAPI_malloc(sizeof(OpenAPI_link_t));
|
||||
if (!link_local_var) {
|
||||
return NULL;
|
||||
}
|
||||
link_local_var->href = href;
|
||||
|
||||
return link_local_var;
|
||||
}
|
||||
|
||||
void OpenAPI_link_free(OpenAPI_link_t *link)
|
||||
{
|
||||
if (NULL == link) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(link->href);
|
||||
ogs_free(link);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_link_convertToJSON(OpenAPI_link_t *link)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
|
||||
if (link == NULL) {
|
||||
ogs_error("OpenAPI_link_convertToJSON() failed [Link]");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (link->href) {
|
||||
if (cJSON_AddStringToObject(item, "href", link->href) == NULL) {
|
||||
ogs_error("OpenAPI_link_convertToJSON() failed [href]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
return item;
|
||||
}
|
||||
|
||||
OpenAPI_link_t *OpenAPI_link_parseFromJSON(cJSON *linkJSON)
|
||||
{
|
||||
OpenAPI_link_t *link_local_var = NULL;
|
||||
cJSON *href = cJSON_GetObjectItemCaseSensitive(linkJSON, "href");
|
||||
|
||||
if (href) {
|
||||
if (!cJSON_IsString(href)) {
|
||||
ogs_error("OpenAPI_link_parseFromJSON() failed [href]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
link_local_var = OpenAPI_link_create (
|
||||
href ? ogs_strdup(href->valuestring) : NULL
|
||||
);
|
||||
|
||||
return link_local_var;
|
||||
end:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue