2024-03-04 19:37:24 +00:00
|
|
|
#ifndef DB_H
|
|
|
|
#define DB_H
|
|
|
|
|
2024-03-06 02:12:10 +00:00
|
|
|
#define DB_MAGIC 0xdeadbeef
|
|
|
|
#define DB_VER 0x10
|
|
|
|
|
2024-03-04 19:37:24 +00:00
|
|
|
struct db_hash
|
|
|
|
{
|
2024-03-06 02:12:10 +00:00
|
|
|
int key_len;
|
|
|
|
int value_len;
|
|
|
|
char *key;
|
|
|
|
char *value;
|
2024-03-04 19:37:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct db_table
|
|
|
|
{
|
|
|
|
int db_magic;
|
|
|
|
int db_ver;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
struct db_hash *hashes;
|
|
|
|
};
|
|
|
|
|
|
|
|
int write_db(struct db_table *db, char *fname);
|
|
|
|
struct db_table *read_db(char *fname);
|
2024-03-06 02:12:10 +00:00
|
|
|
int db_add_hash(struct db_table *db, char *key, char *value);
|
|
|
|
int db_del_hash(struct db_table *db, char *key);
|
2024-03-04 19:37:24 +00:00
|
|
|
char *get_hash(struct db_table *db, char *key);
|
|
|
|
|
|
|
|
#endif
|