diff --git a/dlls/nvault/amxxapi.cpp b/dlls/nvault/amxxapi.cpp new file mode 100755 index 00000000..3a8ec0b2 --- /dev/null +++ b/dlls/nvault/amxxapi.cpp @@ -0,0 +1,51 @@ +#include "amxxapi.h" + +CVector Vaults; + +static cell nvault_open(AMX *amx, cell *params) +{ + int len, id=-1; + char *name = MF_GetAmxString(amx, params[1], 0, &len); + char *file = MF_BuildPathname("%s/nvault/%s", LOCALINFO("amxx_datadir"), name); + for (size_t i=0; iGetFileName(), file) == 0) { + return i; + } + } + Vault *v = new Vault(file); + if (id != -1) + { + Vaults[id] = v; + } else { + Vaults.push_back(v); + id = (int)Vaults.size()-1; + } + + return id; +} + +static cell nvault_get(AMX *amx, cell *params) +{ + unsigned int id = params[1]; + if (id > Vaults.size() || !Vaults.at(i)) + { + MF_LogError(amx, AMX_ERR_NATIVE, "Invalid vault id: %d\n", id); + return 0; + } + + +} + +void OnAmxxAttach() +{ + //create the dir if it doesn't exist +#ifdef __linux__ + mkdir(MF_BuildPathname("%s/nvault", LOCALINFO("amxx_datadir")), 0700); +#else + mkdir(MF_BuildPathname("%s/nvault", LOCALINFO("amxx_datadir")); +#endif +} diff --git a/dlls/nvault/amxxapi.h b/dlls/nvault/amxxapi.h new file mode 100755 index 00000000..d9682186 --- /dev/null +++ b/dlls/nvault/amxxapi.h @@ -0,0 +1,13 @@ +#ifndef _INCLUDE_AMXXAPI_H +#define _INCLUDE_AMXXAPI_H + +#include "sdk/CVector.h" +#include "hash.h" +#include "nvault.h" +#include "journal.h" +#include "sdk/amxxmodule.h" + +AMX_NATIVE_INFO nVault_natives[]; + +#endif //_INCLUDE_AMXXAPI_H + diff --git a/dlls/nvault/nvault.cpp b/dlls/nvault/nvault.cpp index 3886bcb3..a4ceee29 100755 --- a/dlls/nvault/nvault.cpp +++ b/dlls/nvault/nvault.cpp @@ -15,6 +15,11 @@ Vault::~Vault() } } +const char *Vault::GetFileName() +{ + return m_File.c_str(); +} + void Vault::Clear() { if (m_Vault) diff --git a/dlls/nvault/nvault.h b/dlls/nvault/nvault.h index b76e0fae..316dfac2 100755 --- a/dlls/nvault/nvault.h +++ b/dlls/nvault/nvault.h @@ -46,6 +46,7 @@ public: bool KeyExists(const char *key); void Clear(); void EraseKey(const char *key); + const char *GetFileName(); private: void _WriteHeaders(FILE *fp, uint32_t hashes); private: diff --git a/dlls/nvault/nvault.inc b/dlls/nvault/nvault.inc new file mode 100755 index 00000000..fd8d97fa --- /dev/null +++ b/dlls/nvault/nvault.inc @@ -0,0 +1,37 @@ +/* nVault + * + * A binary (hash table) vault with journaling. + * (C)2005 David "BAILOPAN" Anderson + */ + +#if defined _nvault_included + #endinput +#endif +#define _nvault_included + +/* Opens a vault and returns an id to it + * The vault name is appended with ".nvt" and stored in + * datadir/vault. + */ +native vault_open(const name[]); + +/* Reads from a vault. + * No extra params - gets as an int + * One extra param - Float byref + * Two extra params - gets as a string + */ +native nvault_get(id, const name[], ...); + +/* Reads a data from given key. + * If len is set to zero then get_vaultdata +* returns value as an number. */ +native get_vaultdata(const key[], data[] = "", len = 0); + +/* Sets a data under given key. */ +native set_vaultdata(const key[], const data[] = "" ); + +/* Removes a key from vault.*/ +native remove_vaultdata(const key[]); + +/* Checks if a key exists in the vault.*/ +native vaultdata_exists(const key[]); \ No newline at end of file diff --git a/dlls/nvault/nvault.vcproj b/dlls/nvault/nvault.vcproj index 50b8d18e..5ce7a63b 100755 --- a/dlls/nvault/nvault.vcproj +++ b/dlls/nvault/nvault.vcproj @@ -21,17 +21,19 @@ Optimization="0" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;NVAULT_EXPORTS" MinimalRebuild="TRUE" + ExceptionHandling="FALSE" BasicRuntimeChecks="3" - RuntimeLibrary="1" + RuntimeLibrary="5" + StructMemberAlignment="3" UsePrecompiledHeader="0" WarningLevel="3" - Detect64BitPortabilityProblems="TRUE" + Detect64BitPortabilityProblems="FALSE" DebugInformationFormat="4"/> + + + + + + + diff --git a/dlls/nvault/sdk/moduleconfig.h b/dlls/nvault/sdk/moduleconfig.h index 14d7189c..9171757b 100755 --- a/dlls/nvault/sdk/moduleconfig.h +++ b/dlls/nvault/sdk/moduleconfig.h @@ -27,7 +27,7 @@ //#define FN_AMXX_QUERY OnAmxxQuery // AMXX attach // Do native functions init here (MF_AddNatives) -// #define FN_AMXX_ATTACH OnAmxxAttach +#define FN_AMXX_ATTACH OnAmxxAttach // AMXX detach //#define FN_AMXX_DETACH OnAmxxDetach // All plugins loaded