amxmodx/dlls/nvault/nvault.h

58 lines
1.2 KiB
C
Raw Normal View History

2005-04-02 16:04:08 +00:00
#ifndef _INCLUDE_NVAULT_H
#define _INCLUDE_NVAULT_H
#include "sdk/CString.h"
#include "hash.h"
2005-04-03 02:01:42 +00:00
/**
* Vault file format:
* Headers
* uint32_t - nVLT
* uint8_t - sizeof(time_t)
* uint32_t - key size (will be used in future maybe)
* uint32_t - number of hashes stored
* Data
* uint32_t - key hash
* uint32_t - # of keys in this hash
* Data
* uint32_t - Time
* uint8_t - Characters in key
* uint16_t - Characters in value
* char[] - Key
* char[] - Value
*/
#define VAULT_MAGIC 0x6E564C54
class Vault
2005-04-02 16:04:08 +00:00
{
public:
2005-04-03 02:01:42 +00:00
Vault(const char *name);
~Vault();
enum VaultError
2005-04-02 16:04:08 +00:00
{
2005-04-03 02:01:42 +00:00
Vault_Ok=0,
Vault_ReadFail,
Vault_BadMagic,
2005-04-02 16:04:08 +00:00
};
public:
bool WriteToFile();
2005-04-03 02:01:42 +00:00
VaultError ReadFromFile();
2005-04-02 16:04:08 +00:00
public:
void Store(const char *key, const char *value, bool temporary=true);
2005-04-03 02:01:42 +00:00
void Store(const char *key, const char *value, time_t stamp);
2005-04-02 16:04:08 +00:00
size_t Prune(time_t begin, time_t end, bool all=false);
HashTable::htNode *Find(const char *key);
bool KeyExists(const char *key);
void Clear();
2005-04-03 02:01:42 +00:00
void EraseKey(const char *key);
2005-04-03 03:26:35 +00:00
const char *GetFileName();
2005-04-03 02:01:42 +00:00
private:
void _WriteHeaders(FILE *fp, uint32_t hashes);
2005-04-02 16:04:08 +00:00
private:
String m_File;
HashTable *m_Vault;
};
#endif //_INCLUDE_NVAULT_H