mirror of
https://github.com/fumiama/simple-protobuf.git
synced 2026-06-11 20:20:28 +08:00
优化错误处理
This commit is contained in:
@@ -4,21 +4,27 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct SIMPLE_PB {
|
||||
#define MAX_SIMPLE_PB_STRUCT_LEN (1ull<<20)
|
||||
|
||||
struct simple_pb_t {
|
||||
uint32_t struct_len, real_len;
|
||||
char target[];
|
||||
};
|
||||
typedef struct SIMPLE_PB SIMPLE_PB;
|
||||
typedef struct simple_pb_t simple_pb_t;
|
||||
|
||||
SIMPLE_PB* get_pb(FILE* fp);
|
||||
simple_pb_t* get_pb(FILE* fp);
|
||||
|
||||
// get_pb_len returns 0 on error
|
||||
uint32_t get_pb_len(FILE* fp);
|
||||
|
||||
SIMPLE_PB* read_pb_into(FILE* fp, SIMPLE_PB* spb);
|
||||
simple_pb_t* read_pb_into(FILE* fp, simple_pb_t* spb);
|
||||
|
||||
int set_pb(FILE* fp, const uint32_t* items_len, uint32_t struct_len, const void* target);
|
||||
long set_pb(FILE* fp, const uint32_t* items_len, uint32_t struct_len, const void* target);
|
||||
|
||||
// items_len = align_struct(uint32_t struct_size, uint32_t items_cnt, void* item_addr1, void* item_addr2...)
|
||||
uint32_t* align_struct(uint32_t struct_size, uint32_t items_cnt, ...);
|
||||
|
||||
#endif
|
||||
// items_len = align_struct_into(uint32_t struct_size, uint32_t* items_len, uint32_t items_cnt, void* item_addr1, void* item_addr2...)
|
||||
uint32_t* align_struct_into(uint32_t struct_size, uint32_t* items_len, uint32_t items_cnt, ...);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user