2020-03-18 17:24:33 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include "v1_container_state_waiting.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
static v1_container_state_waiting_t *v1_container_state_waiting_create_internal(
|
2020-03-18 17:24:33 +08:00
|
|
|
char *message,
|
|
|
|
|
char *reason
|
|
|
|
|
) {
|
|
|
|
|
v1_container_state_waiting_t *v1_container_state_waiting_local_var = malloc(sizeof(v1_container_state_waiting_t));
|
|
|
|
|
if (!v1_container_state_waiting_local_var) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
v1_container_state_waiting_local_var->message = message;
|
|
|
|
|
v1_container_state_waiting_local_var->reason = reason;
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
v1_container_state_waiting_local_var->_library_owned = 1;
|
2020-03-18 17:24:33 +08:00
|
|
|
return v1_container_state_waiting_local_var;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
__attribute__((deprecated)) v1_container_state_waiting_t *v1_container_state_waiting_create(
|
|
|
|
|
char *message,
|
|
|
|
|
char *reason
|
|
|
|
|
) {
|
|
|
|
|
return v1_container_state_waiting_create_internal (
|
|
|
|
|
message,
|
|
|
|
|
reason
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
|
|
|
|
|
void v1_container_state_waiting_free(v1_container_state_waiting_t *v1_container_state_waiting) {
|
|
|
|
|
if(NULL == v1_container_state_waiting){
|
|
|
|
|
return ;
|
|
|
|
|
}
|
2025-02-11 19:36:46 +00:00
|
|
|
if(v1_container_state_waiting->_library_owned != 1){
|
|
|
|
|
fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "v1_container_state_waiting_free");
|
|
|
|
|
return ;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
listEntry_t *listEntry;
|
2021-01-05 15:42:34 +08:00
|
|
|
if (v1_container_state_waiting->message) {
|
|
|
|
|
free(v1_container_state_waiting->message);
|
|
|
|
|
v1_container_state_waiting->message = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (v1_container_state_waiting->reason) {
|
|
|
|
|
free(v1_container_state_waiting->reason);
|
|
|
|
|
v1_container_state_waiting->reason = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
free(v1_container_state_waiting);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cJSON *v1_container_state_waiting_convertToJSON(v1_container_state_waiting_t *v1_container_state_waiting) {
|
|
|
|
|
cJSON *item = cJSON_CreateObject();
|
|
|
|
|
|
|
|
|
|
// v1_container_state_waiting->message
|
2022-04-18 09:29:02 +08:00
|
|
|
if(v1_container_state_waiting->message) {
|
2020-03-18 17:24:33 +08:00
|
|
|
if(cJSON_AddStringToObject(item, "message", v1_container_state_waiting->message) == NULL) {
|
|
|
|
|
goto fail; //String
|
|
|
|
|
}
|
2022-04-18 09:29:02 +08:00
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// v1_container_state_waiting->reason
|
2022-04-18 09:29:02 +08:00
|
|
|
if(v1_container_state_waiting->reason) {
|
2020-03-18 17:24:33 +08:00
|
|
|
if(cJSON_AddStringToObject(item, "reason", v1_container_state_waiting->reason) == NULL) {
|
|
|
|
|
goto fail; //String
|
|
|
|
|
}
|
2022-04-18 09:29:02 +08:00
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
fail:
|
|
|
|
|
if (item) {
|
|
|
|
|
cJSON_Delete(item);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
v1_container_state_waiting_t *v1_container_state_waiting_parseFromJSON(cJSON *v1_container_state_waitingJSON){
|
|
|
|
|
|
|
|
|
|
v1_container_state_waiting_t *v1_container_state_waiting_local_var = NULL;
|
|
|
|
|
|
|
|
|
|
// v1_container_state_waiting->message
|
|
|
|
|
cJSON *message = cJSON_GetObjectItemCaseSensitive(v1_container_state_waitingJSON, "message");
|
2025-02-11 19:36:46 +00:00
|
|
|
if (cJSON_IsNull(message)) {
|
|
|
|
|
message = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
if (message) {
|
2022-12-29 10:58:47 +08:00
|
|
|
if(!cJSON_IsString(message) && !cJSON_IsNull(message))
|
2020-03-18 17:24:33 +08:00
|
|
|
{
|
|
|
|
|
goto end; //String
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// v1_container_state_waiting->reason
|
|
|
|
|
cJSON *reason = cJSON_GetObjectItemCaseSensitive(v1_container_state_waitingJSON, "reason");
|
2025-02-11 19:36:46 +00:00
|
|
|
if (cJSON_IsNull(reason)) {
|
|
|
|
|
reason = NULL;
|
|
|
|
|
}
|
2020-03-18 17:24:33 +08:00
|
|
|
if (reason) {
|
2022-12-29 10:58:47 +08:00
|
|
|
if(!cJSON_IsString(reason) && !cJSON_IsNull(reason))
|
2020-03-18 17:24:33 +08:00
|
|
|
{
|
|
|
|
|
goto end; //String
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
v1_container_state_waiting_local_var = v1_container_state_waiting_create_internal (
|
2022-12-29 10:58:47 +08:00
|
|
|
message && !cJSON_IsNull(message) ? strdup(message->valuestring) : NULL,
|
|
|
|
|
reason && !cJSON_IsNull(reason) ? strdup(reason->valuestring) : NULL
|
2020-03-18 17:24:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return v1_container_state_waiting_local_var;
|
|
|
|
|
end:
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
}
|