1
0
mirror of https://github.com/fumiama/simple-dict.git synced 2026-06-11 05:30:28 +08:00

优化代码结构

This commit is contained in:
fumiama
2021-12-08 20:21:50 +08:00
parent c8148e1052
commit e3d30a5b74
4 changed files with 88 additions and 95 deletions

18
dict.h
View File

@@ -3,25 +3,25 @@
#include <stdint.h>
#define ITEMSZ 64
#define DICTKEYSZ 64
#define DICTDATSZ 64
struct DICT {
char key[ITEMSZ];
char data[ITEMSZ];
char key[DICTKEYSZ];
char data[DICTDATSZ];
};
typedef struct DICT DICT;
#define DICTSZ sizeof(DICT)
#define LOCK_UN 0x00
#define LOCK_SH 0x01
#define LOCK_EX 0x02
#define DICT_LOCK_UN 0x00
#define DICT_LOCK_SH 0x01
#define DICT_LOCK_EX 0x02
int fill_md5();
uint32_t last_nonnull(char* p, uint32_t max_size);
int init_dict(char* file_path);
FILE *open_dict(uint8_t lock_type, uint32_t index);
void close_dict(uint8_t lock_type, uint32_t index);
int fill_md5();
FILE* get_dict_fp(uint32_t index);
off_t get_dict_size();
int is_md5_equal(uint8_t* digest);
FILE *open_dict(uint8_t lock_type, uint32_t index);
#endif