OpenNSL API Guide and Reference Manual
Macros
rpc_utils.h File Reference
#include <stdint.h>
#include <sys/socket.h>

Go to the source code of this file.

Macros

#define _jsonlog(format, args...)   printf(format, ##args)
 
#define DEF_SERVER   "127.0.0.1"
 
#define EXAMPLE_CONFIG_PORT   7891
 
#define JSON_CHECK_VALUE_AND_CLEANUP(x, y, z)
 
#define JSON_COMPARE_STRINGS_AND_CLEANUP(x, y, z)
 
#define JSON_COMPARE_VALUE_AND_CLEANUP(x, y, z)
 
#define JSON_MAX_NODE_LENGTH   64
 
#define JSON_MAX_NODE_LENGTH   64
 
#define JSON_VALIDATE_JSON_AS_NUMBER(x, y)
 
#define JSON_VALIDATE_JSON_AS_STRING(x, y, z)
 
#define JSON_VALIDATE_JSON_POINTER(x, y, z)
 
#define JSON_VALIDATE_JSON_POINTER_AND_CLEANUP(x, y, z)
 
#define JSON_VALIDATE_POINTER(x, y, z)
 
#define JSON_VALIDATE_POINTER_AND_CLEANUP(x, y, z)
 
#define RPC_MAX_BUFFER_LEN   1023
 

Macro Definition Documentation

#define _jsonlog (   format,
  args... 
)    printf(format, ##args)

Definition at line 39 of file rpc_utils.h.

#define DEF_SERVER   "127.0.0.1"

Definition at line 36 of file rpc_utils.h.

Referenced by main().

#define EXAMPLE_CONFIG_PORT   7891

Definition at line 35 of file rpc_utils.h.

Referenced by main().

#define JSON_CHECK_VALUE_AND_CLEANUP (   x,
  y,
 
)
Value:
do { \
if ( ((x) < (y)) || ( (x) > (z)) ) { \
_jsonlog("The JSON number out of range %d (min %d, max %d) ", (x), (y), (z) ); \
if (root != NULL) { \
cJSON_Delete(root); \
} \
return (-1); \
} \
}while(0)

Definition at line 124 of file rpc_utils.h.

#define JSON_COMPARE_STRINGS_AND_CLEANUP (   x,
  y,
 
)
Value:
do { \
if (strcmp((y), (z)) != 0) { \
_jsonlog("The JSON contains invalid value for %s (actual %s, required %s) ", (x), (y), (z) ); \
if (root != NULL) { \
cJSON_Delete(root); \
} \
return (-1); \
} \
}while(0)

Definition at line 103 of file rpc_utils.h.

Referenced by process_response().

#define JSON_COMPARE_VALUE_AND_CLEANUP (   x,
  y,
 
)
Value:
do { \
if ((y) != (z)) { \
_jsonlog("The JSON contains invalid value for %s (actual %d, required %d) ", (x), (y), (z) ); \
if (root != NULL) { \
cJSON_Delete(root); \
} \
return (-1); \
} \
}while(0)

Definition at line 113 of file rpc_utils.h.

#define JSON_MAX_NODE_LENGTH   64

Definition at line 33 of file rpc_utils.h.

Referenced by process_response().

#define JSON_MAX_NODE_LENGTH   64

Definition at line 33 of file rpc_utils.h.

#define JSON_VALIDATE_JSON_AS_NUMBER (   x,
 
)
Value:
do { \
if ((x)->type != cJSON_Number) { \
_jsonlog("Error parsing JSON, %s not a integer ", (y) ); \
if (root != NULL) { \
cJSON_Delete(root); \
} \
return (-1); \
} \
}while(0)

Definition at line 93 of file rpc_utils.h.

Referenced by process_response().

#define JSON_VALIDATE_JSON_AS_STRING (   x,
  y,
 
)
Value:
do { \
if ((x)->type != cJSON_String) { \
_jsonlog("Error parsing JSON, %s not a string ", (y) ); \
if (root != NULL) { \
cJSON_Delete(root); \
} \
return (z); \
} \
if((x)->valuestring == NULL) { \
_jsonlog("Error parsing JSON, %s not a valid string ", (y) ); \
if (root != NULL) { \
cJSON_Delete(root); \
} \
return (z); \
} \
}while(0)

Definition at line 76 of file rpc_utils.h.

Referenced by process_response().

#define JSON_VALIDATE_JSON_POINTER (   x,
  y,
 
)
Value:
do { \
if ((x) == NULL) { \
_jsonlog("Error parsing JSON %s ", (y) ); \
return (z); \
} \
}while(0)

Definition at line 48 of file rpc_utils.h.

Referenced by process_response().

#define JSON_VALIDATE_JSON_POINTER_AND_CLEANUP (   x,
  y,
 
)
Value:
do { \
if ((x) == NULL) { \
_jsonlog("Error parsing JSON %s ", (y) ); \
if (root != NULL) { \
cJSON_Delete(root); \
} \
return (z); \
} \
}while(0)

Definition at line 65 of file rpc_utils.h.

#define JSON_VALIDATE_POINTER (   x,
  y,
 
)
Value:
do { \
if ((x) == NULL) { \
_jsonlog("Invalid (NULL) value for parameter %s ", (y) ); \
return (z); \
} \
} while(0)

Definition at line 41 of file rpc_utils.h.

#define JSON_VALIDATE_POINTER_AND_CLEANUP (   x,
  y,
 
)
Value:
do { \
if ((x) == NULL) { \
_jsonlog("Invalid (NULL) value for parameter %s ", (y) ); \
if (root != NULL) { \
cJSON_Delete(root); \
} \
return (z); \
} \
} while(0)

Definition at line 55 of file rpc_utils.h.

#define RPC_MAX_BUFFER_LEN   1023

Definition at line 32 of file rpc_utils.h.

Referenced by main().