ZNY_Pakistan/Anjiehui7_ZNY/User/cert.h

59 lines
1.3 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef USER_CERT_PRESENT
#define USER_CERT_PRESENT
#include "type.h"
extern const char *ca_cert;
extern const char *client_cert;
extern const char *client_key;
extern const char *http_header_fmt;
extern const char *json_data;
// 以下为JSON打包函数
char *JSON_data();
void json_initialize();
void json_finish();
void json_new_object();
void json_end_object();
void json_new_array(char *key);
void json_end_array();
void json_new_intValue(char *key, int val);
void json_new_doubleValue(char *key, double val);
void json_new_stringValue(char *key, char *val);
void json_new_boolValue(char *key, uint32_t val);
// 以内为JSON解析函数只解析最简单的记录无数组和嵌套数据类型只支持字符型、整型和浮点型
#define JSON_FIELD_COUNT (25)
#define JSON_NAME_LENGTH (19)
#define JSON_VAL_LENGTH (29)
#define JSON_TYPE_NULL (0)
#define JSON_TYPE_INTEGER (1)
#define JSON_TYPE_FLOAT (2)
#define JSON_TYPE_STRING (3)
#pragma pack(push, 1)
typedef struct
{
char name[JSON_NAME_LENGTH + 1]; // \0
int type;
union
{
char val[JSON_VAL_LENGTH + 2 + 1]; // \"\"\0
char s[JSON_VAL_LENGTH + 1]; // \0
struct
{
long i;
float f;
};
};
} JSON_field;
#pragma pack(pop)
extern JSON_field JSON_Record[JSON_FIELD_COUNT];
int JSON_Parse_Record(char **src);
#endif