mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-02 13:20:08 +00:00
104 lines
2.8 KiB
C
104 lines
2.8 KiB
C
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include "preferred_search.h"
|
|
|
|
OpenAPI_preferred_search_t *OpenAPI_preferred_search_create(
|
|
int preferred_tai_match_ind
|
|
)
|
|
{
|
|
OpenAPI_preferred_search_t *preferred_search_local_var = OpenAPI_malloc(sizeof(OpenAPI_preferred_search_t));
|
|
if (!preferred_search_local_var) {
|
|
return NULL;
|
|
}
|
|
preferred_search_local_var->preferred_tai_match_ind = preferred_tai_match_ind;
|
|
|
|
return preferred_search_local_var;
|
|
}
|
|
|
|
void OpenAPI_preferred_search_free(OpenAPI_preferred_search_t *preferred_search)
|
|
{
|
|
if (NULL == preferred_search) {
|
|
return;
|
|
}
|
|
OpenAPI_lnode_t *node;
|
|
ogs_free(preferred_search);
|
|
}
|
|
|
|
cJSON *OpenAPI_preferred_search_convertToJSON(OpenAPI_preferred_search_t *preferred_search)
|
|
{
|
|
cJSON *item = NULL;
|
|
|
|
if (preferred_search == NULL) {
|
|
ogs_error("OpenAPI_preferred_search_convertToJSON() failed [PreferredSearch]");
|
|
return NULL;
|
|
}
|
|
|
|
item = cJSON_CreateObject();
|
|
if (preferred_search->preferred_tai_match_ind) {
|
|
if (cJSON_AddBoolToObject(item, "preferredTaiMatchInd", preferred_search->preferred_tai_match_ind) == NULL) {
|
|
ogs_error("OpenAPI_preferred_search_convertToJSON() failed [preferred_tai_match_ind]");
|
|
goto end;
|
|
}
|
|
}
|
|
|
|
end:
|
|
return item;
|
|
}
|
|
|
|
OpenAPI_preferred_search_t *OpenAPI_preferred_search_parseFromJSON(cJSON *preferred_searchJSON)
|
|
{
|
|
OpenAPI_preferred_search_t *preferred_search_local_var = NULL;
|
|
cJSON *preferred_tai_match_ind = cJSON_GetObjectItemCaseSensitive(preferred_searchJSON, "preferredTaiMatchInd");
|
|
|
|
if (preferred_tai_match_ind) {
|
|
if (!cJSON_IsBool(preferred_tai_match_ind)) {
|
|
ogs_error("OpenAPI_preferred_search_parseFromJSON() failed [preferred_tai_match_ind]");
|
|
goto end;
|
|
}
|
|
}
|
|
|
|
preferred_search_local_var = OpenAPI_preferred_search_create (
|
|
preferred_tai_match_ind ? preferred_tai_match_ind->valueint : 0
|
|
);
|
|
|
|
return preferred_search_local_var;
|
|
end:
|
|
return NULL;
|
|
}
|
|
|
|
OpenAPI_preferred_search_t *OpenAPI_preferred_search_copy(OpenAPI_preferred_search_t *dst, OpenAPI_preferred_search_t *src)
|
|
{
|
|
cJSON *item = NULL;
|
|
char *content = NULL;
|
|
|
|
ogs_assert(src);
|
|
item = OpenAPI_preferred_search_convertToJSON(src);
|
|
if (!item) {
|
|
ogs_error("OpenAPI_preferred_search_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_preferred_search_free(dst);
|
|
dst = OpenAPI_preferred_search_parseFromJSON(item);
|
|
cJSON_Delete(item);
|
|
|
|
return dst;
|
|
}
|
|
|