summaryrefslogtreecommitdiff
path: root/plugins/Db3x_mmap/dbintf.h
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-21 18:25:03 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-21 18:25:03 +0000
commitc2df6e7bbf6efdb36f751379c154623191864a1f (patch)
tree5c48d94f0072a91e137838bee6b04b9623bdad25 /plugins/Db3x_mmap/dbintf.h
parentf8d3f34a53fbd10eab110b77d3260c38ee5e0f01 (diff)
Dbx_mmap_SA ready
git-svn-id: http://svn.miranda-ng.org/main/trunk@1094 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/dbintf.h')
-rw-r--r--plugins/Db3x_mmap/dbintf.h141
1 files changed, 135 insertions, 6 deletions
diff --git a/plugins/Db3x_mmap/dbintf.h b/plugins/Db3x_mmap/dbintf.h
index ac5a1c25b5..4dff427516 100644
--- a/plugins/Db3x_mmap/dbintf.h
+++ b/plugins/Db3x_mmap/dbintf.h
@@ -23,12 +23,139 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_db_int.h>
+/* tree diagram
+
+DBHeader
+ |-->end of file (plain offset)
+ |-->first contact (DBContact)
+ | |-->next contact (DBContact)
+ | | \--> ...
+ | |-->first settings (DBContactSettings)
+ | | |-->next settings (DBContactSettings)
+ | | | \--> ...
+ | | \-->module name (DBModuleName)
+ | \-->first/last/firstunread event
+ |-->user contact (DBContact)
+ | |-->next contact = NULL
+ | |-->first settings as above
+ | \-->first/last/firstunread event as above
+ \-->first module name (DBModuleName)
+ \-->next module name (DBModuleName)
+ \--> ...
+*/
+
+#define DB_THIS_VERSION 0x00000700u
+#define DB_SETTINGS_RESIZE_GRANULARITY 128
+
+struct DBSignature {
+ char name[15];
+ BYTE eof;
+};
+
struct ModuleName
{
char *name;
DWORD ofs;
};
+#include <pshpack1.h>
+struct DBHeader {
+ BYTE signature[16]; // 'Miranda ICQ DB',0,26
+ DWORD version; //as 4 bytes, ie 1.2.3.10 = 0x0102030a
+ //this version is 0x00000700
+ DWORD ofsFileEnd; //offset of the end of the database - place to write
+ //new structures
+ DWORD slackSpace; //a counter of the number of bytes that have been
+ //wasted so far due to deleting structures and/or
+ //re-making them at the end. We should compact when
+ //this gets above a threshold
+ DWORD contactCount; //number of contacts in the chain,excluding the user
+ DWORD ofsFirstContact; //offset to first DBContact in the chain
+ DWORD ofsUser; //offset to DBContact representing the user
+ DWORD ofsFirstModuleName; //offset to first struct DBModuleName in the chain
+};
+
+#define DBCONTACT_SIGNATURE 0x43DECADEu
+
+struct DBContact
+{
+ DWORD signature;
+ DWORD ofsNext; //offset to the next contact in the chain. zero if
+ //this is the 'user' contact or the last contact
+ //in the chain
+ DWORD ofsFirstSettings; //offset to the first DBContactSettings in the
+ //chain for this contact.
+ DWORD eventCount; //number of events in the chain for this contact
+ DWORD ofsFirstEvent,ofsLastEvent; //offsets to the first and last DBEvent in
+ //the chain for this contact
+ DWORD ofsFirstUnreadEvent; //offset to the first (chronological) unread event
+ //in the chain, 0 if all are read
+ DWORD timestampFirstUnread; //timestamp of the event at ofsFirstUnreadEvent
+};
+
+#define DBMODULENAME_SIGNATURE 0x4DDECADEu
+struct DBModuleName
+{
+ DWORD signature;
+ DWORD ofsNext; //offset to the next module name in the chain
+ BYTE cbName; //number of characters in this module name
+ char name[1]; //name, no nul terminator
+};
+
+#define DBCONTACTSETTINGS_SIGNATURE 0x53DECADEu
+struct DBContactSettings
+{
+ DWORD signature;
+ DWORD ofsNext; //offset to the next contactsettings in the chain
+ DWORD ofsModuleName; //offset to the DBModuleName of the owner of these
+ //settings
+ DWORD cbBlob; //size of the blob in bytes. May be larger than the
+ //actual size for reducing the number of moves
+ //required using granularity in resizing
+ BYTE blob[1]; //the blob. a back-to-back sequence of DBSetting
+ //structs, the last has cbName = 0
+};
+
+#define DBEVENT_SIGNATURE 0x45DECADEu
+struct DBEvent
+{
+ DWORD signature;
+ DWORD ofsPrev,ofsNext; //offset to the previous and next events in the
+ //chain. Chain is sorted chronologically
+ DWORD ofsModuleName; //offset to a DBModuleName struct of the name of
+ //the owner of this event
+ DWORD timestamp; //seconds since 00:00:00 01/01/1970
+ DWORD flags; //see m_database.h, db/event/add
+ WORD eventType; //module-defined event type
+ DWORD cbBlob; //number of bytes in the blob
+ BYTE blob[1]; //the blob. module-defined formatting
+};
+
+#include <poppack.h>
+
+struct DBCachedGlobalValue
+{
+ char* name;
+ DBVARIANT value;
+};
+
+struct DBCachedContactValue
+{
+ char* name;
+ DBVARIANT value;
+ DBCachedContactValue* next;
+};
+
+struct DBCachedContactValueList
+{
+ HANDLE hContact;
+ HANDLE hNext;
+ DBCachedContactValue* first;
+ DBCachedContactValue* last;
+};
+
+#define MAXCACHEDREADSIZE 65536
+
struct CDdxMmap : public MIDatabase, public MZeroedObject
{
CDdxMmap(const TCHAR* tszFileName);
@@ -39,7 +166,6 @@ struct CDdxMmap : public MIDatabase, public MZeroedObject
int CreateDbHeaders();
int CheckDbHeaders();
void DatabaseCorruption(TCHAR *text);
-
protected:
STDMETHODIMP_(void) SetCacheSafetyMode(BOOL);
@@ -75,7 +201,13 @@ protected:
STDMETHODIMP_(BOOL) SetSettingResident(BOOL bIsResident, const char *pszSettingName);
STDMETHODIMP_(BOOL) EnumResidentSettings(DBMODULEENUMPROC pFunc, void *pParam);
-private:
+protected:
+ virtual void EncodeCopyMemory(void *dst, void *src, size_t size);
+ virtual void DecodeCopyMemory(void *dst, void *src, size_t size);
+ virtual void EncodeDBWrite(DWORD ofs, void *src, int size);
+ virtual void DecodeDBWrite(DWORD ofs, void *src, int size);
+
+protected:
TCHAR* m_tszProfileName;
HANDLE m_hDbFile;
DBHeader m_dbHeader;
@@ -88,8 +220,7 @@ public:
UINT_PTR m_flushBuffersTimerId;
DWORD m_flushFailTick;
PBYTE m_pDbCache;
-
-private:
+protected:
PBYTE m_pNull;
HANDLE m_hMap;
DWORD m_dwFileSize;
@@ -156,5 +287,3 @@ private:
DWORD GetModuleNameOfs(const char *szName);
char *GetModuleNameByOfs(DWORD ofs);
};
-
-extern LIST<CDdxMmap> g_Dbs;