summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-02-02 14:14:56 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-02-02 14:14:56 +0000
commitb75d91b2249acd062d80bfccdb66e8d25284ad9c (patch)
tree122eaa0bfe5e069bfaaf082c54598fdfb11f8eea
parentd72729b46f37b9ff953a12ba2926e0b6b71f1142 (diff)
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@106 4f64403b-2f21-0410-a795-97e2b3489a10
-rw-r--r--db3x_autobackups/Makefile53
-rw-r--r--db3x_autobackups/backup.c256
-rw-r--r--db3x_autobackups/commonheaders.c1
-rw-r--r--db3x_autobackups/commonheaders.h61
-rw-r--r--db3x_autobackups/database.c218
-rw-r--r--db3x_autobackups/database.h214
-rw-r--r--db3x_autobackups/db3x.dep56
-rw-r--r--db3x_autobackups/db3x.dsp239
-rw-r--r--db3x_autobackups/db3x.dsw29
-rw-r--r--db3x_autobackups/db3x.mak471
-rw-r--r--db3x_autobackups/db3x.vcproj795
-rw-r--r--db3x_autobackups/db3x_8.sln23
-rw-r--r--db3x_autobackups/db3x_8.vcproj808
-rw-r--r--db3x_autobackups/dbcache.c229
-rw-r--r--db3x_autobackups/dbcontacts.c270
-rw-r--r--db3x_autobackups/dbevents.c440
-rw-r--r--db3x_autobackups/dbheaders.c78
-rw-r--r--db3x_autobackups/dbmodulechain.c132
-rw-r--r--db3x_autobackups/dbsettings.c957
-rw-r--r--db3x_autobackups/dbtime.c163
-rw-r--r--db3x_autobackups/docs/db3x-license.txt340
-rw-r--r--db3x_autobackups/docs/db3x-readme.txt38
-rw-r--r--db3x_autobackups/docs/db3x-translation.txt43
-rw-r--r--db3x_autobackups/encrypt.c67
-rw-r--r--db3x_autobackups/encryption.h23
-rw-r--r--db3x_autobackups/finalcommand.c58
-rw-r--r--db3x_autobackups/icon1.icobin0 -> 318 bytes
-rw-r--r--db3x_autobackups/init.c210
-rw-r--r--db3x_autobackups/options.c384
-rw-r--r--db3x_autobackups/options.h42
-rw-r--r--db3x_autobackups/resource.h51
-rw-r--r--db3x_autobackups/resource.rc248
-rw-r--r--db3x_autobackups/sync.bat4
33 files changed, 7001 insertions, 0 deletions
diff --git a/db3x_autobackups/Makefile b/db3x_autobackups/Makefile
new file mode 100644
index 0000000..5a75630
--- /dev/null
+++ b/db3x_autobackups/Makefile
@@ -0,0 +1,53 @@
+SRC = commonheaders.c \
+ database.c \
+ dbcache.c \
+ dbcontacts.c \
+ dbevents.c \
+ dbheaders.c \
+ dbini.c \
+ dblists.c \
+ dbmodulechain.c \
+ dbsettings.c \
+ dbtime.c \
+ encrypt.c \
+ init.c
+OBJ = $(SRC:.c=.o)
+RES = resource.res
+LIB = -lgdi32 -lversion -lcomctl32 -lcomdlg32 -lole32
+
+CC = gcc
+RC = windres
+RM = rm
+
+# Install location
+ifdef DEBUG
+BIN = ..\..\bin\debug\plugins\dbx_3x.dll
+else
+BIN = ..\..\bin\release\plugins\dbx_3x.dll
+endif
+
+# Defines
+DEFINES = -DWIN32 -D__SEH_NOOP
+ifdef DEBUG
+DEFINES := $(DEFINES) -D_DEBUG
+endif
+
+# Flags
+LFLAGS = -shared
+RCFLAGS = --input-format rc --output-format coff
+ifdef DEBUG
+CFLAGS = -g $(DEFINES) -I../../include
+else
+CFLAGS = -O1 $(DEFINES) -I../../include
+endif
+
+# Targets
+all : $(OBJ) $(RES)
+ $(CC) $(LFLAGS) $(CFLAGS) -o $(BIN) $(OBJ) $(RES) $(LIB) -Wl
+
+$(RES) : $(RES:.res=.rc) $(RES:.res=.h) Makefile
+ $(RC) $(RCFLAGS) -o $(RES) -i $(RES:.res=.rc)
+
+clean :
+ $(RM) -f $(OBJ) $(RES)
+
diff --git a/db3x_autobackups/backup.c b/db3x_autobackups/backup.c
new file mode 100644
index 0000000..8eb26da
--- /dev/null
+++ b/db3x_autobackups/backup.c
@@ -0,0 +1,256 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+#include "database.h"
+#include "options.h"
+
+#define SHOW_PROGRESS_TIME 1000 // show progress window when backup time exceeds this many milliseconds
+
+extern HANDLE hDbFile;
+extern CRITICAL_SECTION csDbAccess;
+extern HINSTANCE g_hInst;
+
+extern Options options;
+
+struct DBHeader dbHeader;
+
+UINT timer_id = 0;
+
+
+BOOL CALLBACK DlgProcProgress(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ {
+ HWND prog = GetDlgItem(hwndDlg, IDC_PROGRESS);
+
+ TranslateDialogDefault( hwndDlg );
+
+ SendMessage(prog, PBM_SETPOS, 0, 0);
+ }
+ break;
+ case WM_COMMAND:
+ if ( HIWORD( wParam ) == BN_CLICKED ) {
+ switch( LOWORD( wParam )) {
+ case IDCANCEL:
+ // in the progress dialog, use the user data to indicate that the user has pressed cancel
+ SetWindowLong(hwndDlg, GWL_USERDATA, (LONG)1);
+ return TRUE;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+int RotateBackups(HWND progress_dialog, DWORD start_time) {
+ char num1[4], num2[4];
+ char backupfilename1[MAX_PATH], backupfilename2[MAX_PATH];
+ int i;
+ HWND prog = GetDlgItem(progress_dialog, IDC_PROGRESS);
+ MSG msg;
+
+ // delete the last file, so that the rest can be rename operations
+ strcpy(backupfilename1, options.folder);
+ strcat(backupfilename1, "\\db_backup");
+ itoa(options.num_backups - 1, num1, 10);
+ strcat(backupfilename1, num1);
+ strcat(backupfilename1, ".dat");
+ DeleteFile(backupfilename1);
+
+ for(i = options.num_backups - 1; i > 0 && GetWindowLong(progress_dialog, GWL_USERDATA) == 0; i--) {
+ strcpy(backupfilename1, options.folder);
+ strcat(backupfilename1, "\\db_backup");
+ itoa(i - 1, num1, 10);
+ strcat(backupfilename1, num1);
+ strcat(backupfilename1, ".dat");
+
+ strcpy(backupfilename2, options.folder);
+ strcat(backupfilename2, "\\db_backup");
+ itoa(i, num2, 10);
+ strcat(backupfilename2, num2);
+ strcat(backupfilename2, ".dat");
+
+ MoveFile(backupfilename1, backupfilename2);
+
+ if(GetTickCount() - start_time >= SHOW_PROGRESS_TIME)
+ ShowWindow(progress_dialog, SW_SHOW);
+
+ while(PeekMessage(&msg, progress_dialog, 0, 0, PM_REMOVE) != 0) {
+ if(!IsDialogMessage(progress_dialog, &msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ SendMessage(prog, PBM_SETPOS, (WPARAM)(int)(100 * (options.num_backups - i) / options.num_backups), 0);
+ UpdateWindow(progress_dialog);
+
+ }
+
+ return 0;
+}
+
+int Backup() {
+ HANDLE hBackupFile;
+ char backup_filename[MAX_PATH];
+ char buff[8192];
+ DWORD bytes_read, bytes_written, file_size, total_bytes_copied = 0;
+ HWND progress_dialog = 0, prog;
+ MSG msg;
+
+ DWORD start_time = GetTickCount();
+
+ // ensure the backup folder exists (either create it or return non-zero signifying error)
+ if(!CreateDirectory(options.folder, 0)) {
+ DWORD err = GetLastError();
+ if(err != ERROR_ALREADY_EXISTS) {
+ return 1;
+ }
+ }
+
+ if(!options.disable_progress) {
+ progress_dialog = CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_COPYPROGRESS), 0, DlgProcProgress);
+ prog = GetDlgItem(progress_dialog, IDC_PROGRESS);
+ SetDlgItemText(progress_dialog, IDC_PROGRESSMESSAGE, Translate("Rotating backup files..."));
+ }
+
+
+ RotateBackups(progress_dialog, start_time);
+
+ strcpy(backup_filename, options.folder);
+ strcat(backup_filename, "\\db_backup0.dat");
+
+ hBackupFile = CreateFile(backup_filename, GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+
+ if(hBackupFile != INVALID_HANDLE_VALUE) {
+ if(!options.disable_progress) {
+ SetDlgItemText(progress_dialog, IDC_PROGRESSMESSAGE, Translate("Copying database file..."));
+ SendMessage(prog, PBM_SETPOS, (WPARAM)(int)(0), 0);
+ UpdateWindow(progress_dialog);
+ }
+
+ EnterCriticalSection(&csDbAccess);
+
+ file_size = GetFileSize(hDbFile, 0);
+
+ if(file_size == 0) {
+ LeaveCriticalSection(&csDbAccess);
+ CloseHandle(hBackupFile);
+ DestroyWindow(progress_dialog);
+ return 1;
+ }
+
+ SetFilePointer(hDbFile, sizeof(dbHeader), 0, FILE_BEGIN);
+
+ if(WriteFile(hBackupFile,&dbHeader,sizeof(dbHeader),&bytes_written,NULL) == TRUE) {
+ total_bytes_copied += bytes_written;
+ if(!options.disable_progress) {
+ SendMessage(prog, PBM_SETPOS, (WPARAM)(int)(100.0 * total_bytes_copied / file_size), 0);
+ UpdateWindow(progress_dialog);
+ }
+ } else {
+ LeaveCriticalSection(&csDbAccess);
+ CloseHandle(hBackupFile);
+ DestroyWindow(progress_dialog);
+ return 1;
+ }
+
+ while(ReadFile(hDbFile, buff, sizeof(buff), &bytes_read, 0) == TRUE && bytes_read > 0
+ && GetWindowLong(progress_dialog, GWL_USERDATA) == 0)
+ {
+ if(!WriteFile(hBackupFile, buff, bytes_read, &bytes_written, 0)) {
+ LeaveCriticalSection(&csDbAccess);
+ CloseHandle(hBackupFile);
+ DestroyWindow(progress_dialog);
+ return 1;
+ }
+ total_bytes_copied += bytes_written;
+
+ if(!options.disable_progress) {
+
+ if(GetTickCount() - start_time >= SHOW_PROGRESS_TIME)
+ ShowWindow(progress_dialog, SW_SHOW);
+
+
+ while(PeekMessage(&msg, progress_dialog, 0, 0, PM_REMOVE) != 0) {
+ if(!IsDialogMessage(progress_dialog, &msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ SendMessage(prog, PBM_SETPOS, (WPARAM)(int)(100.0 * total_bytes_copied / file_size), 0);
+ UpdateWindow(progress_dialog);
+ }
+ }
+ LeaveCriticalSection(&csDbAccess);
+
+ CloseHandle(hBackupFile);
+
+ if(!options.disable_progress && GetWindowLong(progress_dialog, GWL_USERDATA) != 0)
+ DeleteFile(backup_filename);
+ else
+ DBWriteContactSettingDword(0, "db3x", "LastBackupTimestamp", (DWORD)time(0));
+
+ if(!options.disable_progress)
+ DestroyWindow(progress_dialog);
+
+ return 0;
+ }
+
+ DestroyWindow(progress_dialog);
+ return 1;
+}
+
+VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) {
+ time_t t = time(0), diff = t - (time_t)DBGetContactSettingDword(0, "db3x", "LastBackupTimestamp", (DWORD)t);
+ if(diff > (time_t)(options.period * (options.period_type == PT_HOURS ? 60 * 60 : 60 * 60 * 24)))
+ Backup();
+}
+
+int SetBackupTimer(void) {
+
+ if(options.backup_types & BT_PERIODIC) {
+ if(timer_id == 0) {
+ time_t t = time(0), diff = t - (time_t)DBGetContactSettingDword(0, "db3x", "LastBackupTimestamp", (DWORD)t);
+ if(diff > (time_t)(options.period * (options.period_type == PT_HOURS ? 60 * 60 : 60 * 60 * 24)))
+ Backup();
+
+ timer_id = SetTimer(0, 0, 1000 * 60 * 60, TimerProc);
+ }
+ } else {
+ if(timer_id != 0) {
+ KillTimer(0, timer_id);
+ timer_id = 0;
+ }
+ }
+
+
+ return 0;
+}
+
+int BackupService(WPARAM wParam, LPARAM lParam) {
+ return Backup();
+} \ No newline at end of file
diff --git a/db3x_autobackups/commonheaders.c b/db3x_autobackups/commonheaders.c
new file mode 100644
index 0000000..14f99f7
--- /dev/null
+++ b/db3x_autobackups/commonheaders.c
@@ -0,0 +1 @@
+#include "commonheaders.h"
diff --git a/db3x_autobackups/commonheaders.h b/db3x_autobackups/commonheaders.h
new file mode 100644
index 0000000..4d4afad
--- /dev/null
+++ b/db3x_autobackups/commonheaders.h
@@ -0,0 +1,61 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#define _WIN32_WINNT 0x0501
+#include <windows.h>
+
+#ifdef _DEBUG
+# define _ALPHA_BASE_ 1 // defined for CVS builds
+# define _ALPHA_FUSE_ 1 // defined for fuse powered core
+# define _CRTDBG_MAP_ALLOC
+# include <stdlib.h>
+# include <crtdbg.h>
+#endif
+
+#include <malloc.h>
+
+#include <commctrl.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <stddef.h>
+#include <process.h>
+#include <io.h>
+#include <string.h>
+#include <direct.h>
+#include "resource.h"
+#include <newpluginapi.h>
+#include <win2k.h>
+#include <m_system.h>
+#include <m_database.h>
+#include <m_langpack.h>
+
+extern PLUGINLINK *pluginLink;
+
+extern struct LIST_INTERFACE li;
+
+#ifdef __GNUC__
+#define mir_i64(x) (x##LL)
+#else
+#define mir_i64(x) (x##i64)
+#endif
diff --git a/db3x_autobackups/database.c b/db3x_autobackups/database.c
new file mode 100644
index 0000000..2d815dc
--- /dev/null
+++ b/db3x_autobackups/database.c
@@ -0,0 +1,218 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include "commonheaders.h"
+#include "database.h"
+
+int ProfileManager(char *szDbDest,int cbDbDest);
+int ShouldAutoCreate(void);
+int CreateDbHeaders(HANDLE hFile);
+int InitialiseDbHeaders(void);
+int InitSettings(void);
+void UninitSettings(void);
+int InitContacts(void);
+void UninitContacts(void);
+int InitEvents(void);
+void UninitEvents(void);
+int InitCrypt(void);
+int InitTime(void);
+int InitModuleNames(void);
+void UninitModuleNames(void);
+int InitCache(void);
+void UninitCache(void);
+int InitIni(void);
+void UninitIni(void);
+
+int InitOptions(void);
+void UninitOptions(void);
+
+void FinalCommandSetup(void);
+void FinalCommandExecute(void);
+
+HANDLE hDbFile=INVALID_HANDLE_VALUE;
+CRITICAL_SECTION csDbAccess;
+struct DBHeader dbHeader;
+char szDbPath[MAX_PATH];
+
+BOOL bUnloading=FALSE;
+
+static void UnloadDatabase(void)
+{
+ CloseHandle(hDbFile);
+}
+
+DWORD CreateNewSpace(int bytes)
+{
+ DWORD ofsNew;
+
+ ofsNew=dbHeader.ofsFileEnd;
+ dbHeader.ofsFileEnd+=bytes;
+ DBWrite(0,&dbHeader,sizeof(dbHeader));
+ log2("newspace %d@%08x",bytes,ofsNew);
+ return ofsNew;
+}
+
+void DeleteSpace(DWORD ofs,int bytes)
+{
+ PBYTE buf;
+ log2("deletespace %d@%08x",bytes,ofs);
+
+ // reclaim a little space - will result in e.g. multiple db events with the same handle!
+#ifdef DB_RECLAIM
+ if(ofs + bytes == dbHeader.ofsFileEnd) {
+ dbHeader.ofsFileEnd-=bytes;
+ DBWrite(0,&dbHeader,sizeof(dbHeader));
+ // shrink file
+ SetFilePointer(hDbFile, dbHeader.ofsFileEnd, 0, FILE_BEGIN);
+ SetEndOfFile(hDbFile);
+ return;
+ }
+#endif
+
+ dbHeader.slackSpace+=bytes;
+ DBWrite(0,&dbHeader,sizeof(dbHeader));
+ buf=(PBYTE)mir_alloc(bytes);
+ memset(buf,0,bytes);
+ DBWrite(ofs,buf,bytes);
+ mir_free(buf);
+}
+
+void UnloadDatabaseModule(void)
+{
+ bUnloading = TRUE;
+
+ FinalCommandSetup();
+
+ UninitOptions();
+
+ //UninitIni();
+ UninitEvents();
+ UninitSettings();
+ UninitContacts();
+ UninitModuleNames();
+ UninitCache();
+ UnloadDatabase();
+ DeleteCriticalSection(&csDbAccess);
+
+ FinalCommandExecute();
+}
+
+static int GetProfileName(WPARAM wParam, LPARAM lParam)
+{
+ char * p = 0;
+ p = strrchr(szDbPath, '\\');
+ if ( p == 0 ) return 1;
+ p++;
+ strncpy((char*)lParam, p, (size_t) wParam);
+ return 0;
+}
+
+static int GetProfilePath(WPARAM wParam, LPARAM lParam)
+{
+ char * dst = (char*)lParam;
+ char * p = 0;
+ strncpy(dst,szDbPath,wParam);
+ p = strrchr(dst, '\\');
+ if ( p == NULL ) return 1;
+ *p=0;
+ return 0;
+}
+
+int LoadDatabaseModule(void)
+{
+ InitializeCriticalSection(&csDbAccess);
+ log0("DB logging running");
+ {
+ DWORD dummy=0;
+ hDbFile=CreateFile(szDbPath,GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL);
+ if ( hDbFile == INVALID_HANDLE_VALUE ) {
+ return 1;
+ }
+ if ( !ReadFile(hDbFile,&dbHeader,sizeof(dbHeader),&dummy,NULL) ) {
+ CloseHandle(hDbFile);
+ return 1;
+ }
+ }
+ //if(ParseCommandLine()) return 1;
+ if(InitCache()) return 1;
+ if(InitModuleNames()) return 1;
+ if(InitContacts()) return 1;
+ if(InitSettings()) return 1;
+ if(InitEvents()) return 1;
+ if(InitCrypt()) return 1;
+ //if(InitTime()) return 1;
+ //if(InitIni()) return 1;
+ CreateServiceFunction(MS_DB_GETPROFILENAME,GetProfileName);
+ CreateServiceFunction(MS_DB_GETPROFILEPATH,GetProfilePath);
+
+ if(InitOptions()) return 1;
+
+ return 0;
+}
+
+static DWORD DatabaseCorrupted=0;
+
+void __cdecl dbpanic(void *arg)
+{
+
+ MessageBox(0,Translate("Miranda has detected corruption in your database. This corruption maybe fixed by DBTool. Please download it from http://www.miranda-im.org. Miranda will now shutdown."),Translate("Database Panic"),MB_SETFOREGROUND|MB_TOPMOST|MB_APPLMODAL|MB_ICONWARNING|MB_OK);
+ TerminateProcess(GetCurrentProcess(),255);
+ return;
+}
+
+void DatabaseCorruption(void)
+{
+ int kill=0;
+
+ EnterCriticalSection(&csDbAccess);
+ if (DatabaseCorrupted==0) {
+ DatabaseCorrupted++;
+ kill++;
+ } else {
+ /* db is already corrupted, someone else is dealing with it, wait here
+ so that we don't do any more damage */
+ LeaveCriticalSection(&csDbAccess);
+ Sleep(INFINITE);
+ return;
+ }
+ LeaveCriticalSection(&csDbAccess);
+ if (kill) {
+ _beginthread(dbpanic,0,NULL);
+ Sleep(INFINITE);
+ }
+}
+
+#ifdef DBLOGGING
+void DBLog(const char *file,int line,const char *fmt,...)
+{
+ FILE *fp;
+ va_list vararg;
+ char str[1024];
+
+ va_start(vararg,fmt);
+ mir_vsnprintf(str,sizeof(str),fmt,vararg);
+ va_end(vararg);
+ fp=fopen("c:\\mirandadatabase.log.txt","at");
+ fprintf(fp,"%u: %s %d: %s\n",GetTickCount(),file,line,str);
+ fclose(fp);
+}
+#endif
diff --git a/db3x_autobackups/database.h b/db3x_autobackups/database.h
new file mode 100644
index 0000000..3e09949
--- /dev/null
+++ b/db3x_autobackups/database.h
@@ -0,0 +1,214 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+//all offsets are relative to the start of the file
+//offsets are 0 if there is nothing in the chain or this is the last in the
+//chain
+
+/* 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_RESIZE_GRANULARITY 16384
+#define DB_THIS_VERSION 0x00000700u
+#define DB_SETTINGS_RESIZE_GRANULARITY 128
+
+#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 struct DBContact in the chain
+ DWORD ofsUser; //offset to struct 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
+};
+
+/* not a valid structure, content is figured out on the fly
+struct DBSetting {
+ BYTE cbName; //number of bytes in the name of this setting
+ //this =0 marks the end
+ char szName[...]; //setting name, excluding nul
+ BYTE dataType; //type of data. see m_database.h, db/contact/getsetting
+ union { //a load of types of data, length is defined by dataType
+ BYTE bVal; WORD wVal; DWORD dVal;
+ struct {
+ WORD cbString;
+ char szVal[...]; //excludes nul terminator
+ };
+ struct {
+ WORD cbBlob;
+ BYTE blobVal[...];
+ };
+ };
+};
+*/
+
+#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>
+
+typedef struct
+{
+ BYTE bIsResident;
+ char name[1];
+}
+ DBCachedSettingName;
+
+typedef struct
+{
+ char* name;
+ DBVARIANT value;
+}
+ DBCachedGlobalValue;
+
+typedef struct DBCachedContactValue_tag
+{
+ char* name;
+ DBVARIANT value;
+ struct DBCachedContactValue_tag* next;
+}
+ DBCachedContactValue;
+
+typedef struct
+{
+ HANDLE hContact;
+ HANDLE hNext;
+ DBCachedContactValue* first;
+}
+ DBCachedContactValueList;
+
+
+//databasecorruption: called if any signatures are broken. very very fatal
+void DatabaseCorruption(void);
+PBYTE DBRead(DWORD ofs,int bytesRequired,int *bytesAvail); //any preview result could be invalidated by the next call
+void DBWrite(DWORD ofs,PVOID pData,int count);
+void DBFlush(int setting);
+void DBMoveChunk(DWORD ofsDest,DWORD ofsSource,int bytes);
+DWORD CreateNewSpace(int bytes);
+void DeleteSpace(DWORD ofs,int bytes);
+int GetProfileDirectory(char *szPath,int cbPath);
+int GetDefaultProfilePath(char *szPath,int cbPath,int *specified);
+int ShouldShowProfileManager(void);
+int CheckDbHeaders(struct DBHeader * hdr);
+int CreateDbHeaders(HANDLE hFile);
+int LoadDatabaseModule(void);
+void UnloadDatabaseModule(void);
+
+#ifdef _DEBUG
+#define MAXCACHEDREADSIZE 512
+#else
+#define MAXCACHEDREADSIZE 2048 //push it to 1K //technically 4096 would work, but I'm not going to push it
+#endif
+
+#ifdef _DEBUG
+//#define DBLOGGING
+#endif
+#ifdef DBLOGGING
+void DBLog(const char *file,int line,const char *fmt,...);
+#define logg() DBLog(__FILE__,__LINE__,"")
+#define log0(s) DBLog(__FILE__,__LINE__,s)
+#define log1(s,a) DBLog(__FILE__,__LINE__,s,a)
+#define log2(s,a,b) DBLog(__FILE__,__LINE__,s,a,b)
+#define log3(s,a,b,c) DBLog(__FILE__,__LINE__,s,a,b,c)
+#define log4(s,a,b,c,d) DBLog(__FILE__,__LINE__,s,a,b,c,d)
+#else
+#define logg()
+#define log0(s)
+#define log1(s,a)
+#define log2(s,a,b)
+#define log3(s,a,b,c)
+#define log4(s,a,b,c,d)
+#endif
diff --git a/db3x_autobackups/db3x.dep b/db3x_autobackups/db3x.dep
new file mode 100644
index 0000000..20d2e5d
--- /dev/null
+++ b/db3x_autobackups/db3x.dep
@@ -0,0 +1,56 @@
+# Microsoft Developer Studio Generated Dependency File, included by db3x.mak
+
+.\commonheaders.c : \
+ "..\..\include\m_database.h"\
+ "..\..\include\m_langpack.h"\
+ "..\..\include\m_plugins.h"\
+ "..\..\include\m_system.h"\
+ "..\..\include\newpluginapi.h"\
+ "..\..\include\win2k.h"\
+ ".\commonheaders.h"\
+
+
+.\database.c : \
+ "..\..\include\m_plugins.h"\
+ ".\database.h"\
+
+
+.\dbcache.c : \
+ "..\..\include\m_plugins.h"\
+ ".\database.h"\
+
+
+.\dbcontacts.c : \
+ "..\..\include\m_plugins.h"\
+ ".\database.h"\
+
+
+.\dbevents.c : \
+ "..\..\include\m_plugins.h"\
+ ".\database.h"\
+
+
+.\dbheaders.c : \
+ "..\..\include\m_plugins.h"\
+ ".\database.h"\
+
+
+.\dbmodulechain.c : \
+ "..\..\include\m_plugins.h"\
+ ".\database.h"\
+
+
+.\dbsettings.c : \
+ "..\..\include\m_plugins.h"\
+ ".\database.h"\
+
+
+.\encrypt.c : \
+ "..\..\include\m_plugins.h"\
+ ".\database.h"\
+
+
+.\init.c : \
+ "..\..\include\m_plugins.h"\
+ ".\database.h"\
+
diff --git a/db3x_autobackups/db3x.dsp b/db3x_autobackups/db3x.dsp
new file mode 100644
index 0000000..241e039
--- /dev/null
+++ b/db3x_autobackups/db3x.dsp
@@ -0,0 +1,239 @@
+# Microsoft Developer Studio Project File - Name="db3x" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=db3x - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "db3x.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "db3x.mak" CFG="db3x - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "db3x - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "db3x - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""$/Miranda/miranda/plugins/db3x", WKIAAAAA"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Yu"commonheaders.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x5130000" /dll /map /debug /machine:I386 /out:"../../bin/release/plugins/dbx_3x.dll" /IGNORE:4089
+# SUBTRACT LINK32 /pdb:none /incremental:yes
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr /Yu"commonheaders.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /map /debug /machine:I386 /out:"../../bin/debug/plugins/dbx_3x.dll" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none /incremental:no
+
+!ENDIF
+
+# Begin Target
+
+# Name "db3x - Win32 Release"
+# Name "db3x - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\commonheaders.c
+# ADD CPP /Yc"commonheaders.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\database.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+# ADD CPP /Yu"commonheaders.h"
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\dbcache.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+# ADD CPP /Yu"commonheaders.h"
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\dbcontacts.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+# ADD CPP /Yu"commonheaders.h"
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\dbevents.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+# ADD CPP /Yu"commonheaders.h"
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\dbheaders.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+# ADD CPP /Yu"commonheaders.h"
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\dbmodulechain.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+# ADD CPP /Yu"commonheaders.h"
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\dbsettings.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+# ADD CPP /Yu"commonheaders.h"
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\encrypt.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+# ADD CPP /Yu"commonheaders.h"
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\init.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+# ADD CPP /Yu"commonheaders.h"
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\commonheaders.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\database.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\resource.rc
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/db3x_autobackups/db3x.dsw b/db3x_autobackups/db3x.dsw
new file mode 100644
index 0000000..0f90f8d
--- /dev/null
+++ b/db3x_autobackups/db3x.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "db3x"=.\db3x.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/db3x_autobackups/db3x.mak b/db3x_autobackups/db3x.mak
new file mode 100644
index 0000000..faade4a
--- /dev/null
+++ b/db3x_autobackups/db3x.mak
@@ -0,0 +1,471 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on db3x.dsp
+!IF "$(CFG)" == ""
+CFG=db3x - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to db3x - Win32 Debug.
+!ENDIF
+
+!IF "$(CFG)" != "db3x - Win32 Release" && "$(CFG)" != "db3x - Win32 Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "db3x.mak" CFG="db3x - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "db3x - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "db3x - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+!ERROR An invalid configuration is specified.
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE
+NULL=nul
+!ENDIF
+
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+
+ALL : "..\..\bin\release\plugins\dbx_3x.dll"
+
+
+CLEAN :
+ -@erase "$(INTDIR)\commonheaders.obj"
+ -@erase "$(INTDIR)\database.obj"
+ -@erase "$(INTDIR)\db3x.pch"
+ -@erase "$(INTDIR)\dbcache.obj"
+ -@erase "$(INTDIR)\dbcontacts.obj"
+ -@erase "$(INTDIR)\dbevents.obj"
+ -@erase "$(INTDIR)\dbheaders.obj"
+ -@erase "$(INTDIR)\dbmodulechain.obj"
+ -@erase "$(INTDIR)\dbsettings.obj"
+ -@erase "$(INTDIR)\encrypt.obj"
+ -@erase "$(INTDIR)\init.obj"
+ -@erase "$(INTDIR)\resource.res"
+ -@erase "$(INTDIR)\vc60.idb"
+ -@erase "$(INTDIR)\vc60.pdb"
+ -@erase "$(OUTDIR)\dbx_3x.exp"
+ -@erase "$(OUTDIR)\dbx_3x.lib"
+ -@erase "$(OUTDIR)\dbx_3x.map"
+ -@erase "$(OUTDIR)\dbx_3x.pdb"
+ -@erase "..\..\bin\release\plugins\dbx_3x.dll"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
+RSC_PROJ=/l 0x809 /fo"$(INTDIR)\resource.res" /d "NDEBUG"
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\db3x.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x5130000" /dll /incremental:no /pdb:"$(OUTDIR)\dbx_3x.pdb" /map:"$(INTDIR)\dbx_3x.map" /debug /machine:I386 /out:"../../bin/release/plugins/dbx_3x.dll" /implib:"$(OUTDIR)\dbx_3x.lib" /IGNORE:4089
+LINK32_OBJS= \
+ "$(INTDIR)\commonheaders.obj" \
+ "$(INTDIR)\database.obj" \
+ "$(INTDIR)\dbcache.obj" \
+ "$(INTDIR)\dbcontacts.obj" \
+ "$(INTDIR)\dbevents.obj" \
+ "$(INTDIR)\dbheaders.obj" \
+ "$(INTDIR)\dbmodulechain.obj" \
+ "$(INTDIR)\dbsettings.obj" \
+ "$(INTDIR)\encrypt.obj" \
+ "$(INTDIR)\init.obj" \
+ "$(INTDIR)\resource.res"
+
+"..\..\bin\release\plugins\dbx_3x.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+ALL : "..\..\bin\debug\plugins\dbx_3x.dll" "$(OUTDIR)\db3x.bsc"
+
+
+CLEAN :
+ -@erase "$(INTDIR)\commonheaders.obj"
+ -@erase "$(INTDIR)\commonheaders.sbr"
+ -@erase "$(INTDIR)\database.obj"
+ -@erase "$(INTDIR)\database.sbr"
+ -@erase "$(INTDIR)\db3x.pch"
+ -@erase "$(INTDIR)\dbcache.obj"
+ -@erase "$(INTDIR)\dbcache.sbr"
+ -@erase "$(INTDIR)\dbcontacts.obj"
+ -@erase "$(INTDIR)\dbcontacts.sbr"
+ -@erase "$(INTDIR)\dbevents.obj"
+ -@erase "$(INTDIR)\dbevents.sbr"
+ -@erase "$(INTDIR)\dbheaders.obj"
+ -@erase "$(INTDIR)\dbheaders.sbr"
+ -@erase "$(INTDIR)\dbmodulechain.obj"
+ -@erase "$(INTDIR)\dbmodulechain.sbr"
+ -@erase "$(INTDIR)\dbsettings.obj"
+ -@erase "$(INTDIR)\dbsettings.sbr"
+ -@erase "$(INTDIR)\encrypt.obj"
+ -@erase "$(INTDIR)\encrypt.sbr"
+ -@erase "$(INTDIR)\init.obj"
+ -@erase "$(INTDIR)\init.sbr"
+ -@erase "$(INTDIR)\resource.res"
+ -@erase "$(INTDIR)\vc60.idb"
+ -@erase "$(INTDIR)\vc60.pdb"
+ -@erase "$(OUTDIR)\db3x.bsc"
+ -@erase "$(OUTDIR)\dbx_3x.exp"
+ -@erase "$(OUTDIR)\dbx_3x.lib"
+ -@erase "$(OUTDIR)\dbx_3x.map"
+ -@erase "$(OUTDIR)\dbx_3x.pdb"
+ -@erase "..\..\bin\debug\plugins\dbx_3x.dll"
+ -@erase "..\..\bin\debug\plugins\dbx_3x.ilk"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
+RSC_PROJ=/l 0x809 /fo"$(INTDIR)\resource.res" /d "_DEBUG"
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\db3x.bsc"
+BSC32_SBRS= \
+ "$(INTDIR)\commonheaders.sbr" \
+ "$(INTDIR)\database.sbr" \
+ "$(INTDIR)\dbcache.sbr" \
+ "$(INTDIR)\dbcontacts.sbr" \
+ "$(INTDIR)\dbevents.sbr" \
+ "$(INTDIR)\dbheaders.sbr" \
+ "$(INTDIR)\dbmodulechain.sbr" \
+ "$(INTDIR)\dbsettings.sbr" \
+ "$(INTDIR)\encrypt.sbr" \
+ "$(INTDIR)\init.sbr"
+
+"$(OUTDIR)\db3x.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+ $(BSC32) @<<
+ $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\dbx_3x.pdb" /map:"$(INTDIR)\dbx_3x.map" /debug /machine:I386 /out:"../../bin/debug/plugins/dbx_3x.dll" /implib:"$(OUTDIR)\dbx_3x.lib" /pdbtype:sept
+LINK32_OBJS= \
+ "$(INTDIR)\commonheaders.obj" \
+ "$(INTDIR)\database.obj" \
+ "$(INTDIR)\dbcache.obj" \
+ "$(INTDIR)\dbcontacts.obj" \
+ "$(INTDIR)\dbevents.obj" \
+ "$(INTDIR)\dbheaders.obj" \
+ "$(INTDIR)\dbmodulechain.obj" \
+ "$(INTDIR)\dbsettings.obj" \
+ "$(INTDIR)\encrypt.obj" \
+ "$(INTDIR)\init.obj" \
+ "$(INTDIR)\resource.res"
+
+"..\..\bin\debug\plugins\dbx_3x.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF
+
+.c{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.c{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("db3x.dep")
+!INCLUDE "db3x.dep"
+!ELSE
+!MESSAGE Warning: cannot find "db3x.dep"
+!ENDIF
+!ENDIF
+
+
+!IF "$(CFG)" == "db3x - Win32 Release" || "$(CFG)" == "db3x - Win32 Debug"
+SOURCE=.\commonheaders.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+CPP_SWITCHES=/nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fp"$(INTDIR)\db3x.pch" /Yc"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+
+"$(INTDIR)\commonheaders.obj" "$(INTDIR)\db3x.pch" : $(SOURCE) "$(INTDIR)"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\db3x.pch" /Yc"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+
+"$(INTDIR)\commonheaders.obj" "$(INTDIR)\commonheaders.sbr" "$(INTDIR)\db3x.pch" : $(SOURCE) "$(INTDIR)"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF
+
+SOURCE=.\database.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+CPP_SWITCHES=/nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+
+"$(INTDIR)\database.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+
+"$(INTDIR)\database.obj" "$(INTDIR)\database.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF
+
+SOURCE=.\dbcache.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+CPP_SWITCHES=/nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+
+"$(INTDIR)\dbcache.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+
+"$(INTDIR)\dbcache.obj" "$(INTDIR)\dbcache.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF
+
+SOURCE=.\dbcontacts.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+CPP_SWITCHES=/nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+
+"$(INTDIR)\dbcontacts.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+
+"$(INTDIR)\dbcontacts.obj" "$(INTDIR)\dbcontacts.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF
+
+SOURCE=.\dbevents.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+CPP_SWITCHES=/nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+
+"$(INTDIR)\dbevents.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+
+"$(INTDIR)\dbevents.obj" "$(INTDIR)\dbevents.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF
+
+SOURCE=.\dbheaders.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+CPP_SWITCHES=/nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+
+"$(INTDIR)\dbheaders.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+
+"$(INTDIR)\dbheaders.obj" "$(INTDIR)\dbheaders.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF
+
+SOURCE=.\dbmodulechain.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+CPP_SWITCHES=/nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+
+"$(INTDIR)\dbmodulechain.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+
+"$(INTDIR)\dbmodulechain.obj" "$(INTDIR)\dbmodulechain.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF
+
+SOURCE=.\dbsettings.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+CPP_SWITCHES=/nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+
+"$(INTDIR)\dbsettings.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+
+"$(INTDIR)\dbsettings.obj" "$(INTDIR)\dbsettings.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF
+
+SOURCE=.\encrypt.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+CPP_SWITCHES=/nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+
+"$(INTDIR)\encrypt.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+
+"$(INTDIR)\encrypt.obj" "$(INTDIR)\encrypt.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF
+
+SOURCE=.\init.c
+
+!IF "$(CFG)" == "db3x - Win32 Release"
+
+CPP_SWITCHES=/nologo /MD /W3 /Zi /O1 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+
+"$(INTDIR)\init.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ELSEIF "$(CFG)" == "db3x - Win32 Debug"
+
+CPP_SWITCHES=/nologo /MDd /W3 /Gm /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DB3X_EXPORTS" /Fr"$(INTDIR)\\" /Fp"$(INTDIR)\db3x.pch" /Yu"commonheaders.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+
+"$(INTDIR)\init.obj" "$(INTDIR)\init.sbr" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\db3x.pch"
+ $(CPP) @<<
+ $(CPP_SWITCHES) $(SOURCE)
+<<
+
+
+!ENDIF
+
+SOURCE=.\resource.rc
+
+"$(INTDIR)\resource.res" : $(SOURCE) "$(INTDIR)"
+ $(RSC) $(RSC_PROJ) $(SOURCE)
+
+
+
+!ENDIF
+
diff --git a/db3x_autobackups/db3x.vcproj b/db3x_autobackups/db3x.vcproj
new file mode 100644
index 0000000..65bf2b5
--- /dev/null
+++ b/db3x_autobackups/db3x.vcproj
@@ -0,0 +1,795 @@
+<?xml version="1.0" encoding="windows-1251"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="db3x"
+ ProjectGUID="{18ED0397-6E30-4A6B-8FA5-1348E12B6DB8}"
+ SccProjectName="&quot;$/Miranda/miranda/plugins/db3x&quot;, WKIAAAAA"
+ SccAuxPath=""
+ SccLocalPath="."
+ SccProvider="MSSCCI:Microsoft Visual SourceSafe">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)/Plugins"
+ IntermediateDirectory="$(SolutionDir)$(ConfigurationName)/Obj/$(ProjectName)"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DB3X_EXPORTS"
+ ExceptionHandling="FALSE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"
+ BrowseInformation="1"
+ BrowseInformationFile="$(IntDir)/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/dbx_3x.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="TRUE"
+ GenerateDebugInformation="TRUE"
+ ImportLibrary="$(IntDir)/$(TargetName).lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/db3x.tlb"
+ HeaderFileName=""/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="2057"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)/Plugins"
+ IntermediateDirectory="$(SolutionDir)$(ConfigurationName)/Obj/$(ProjectName)"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2"
+ WholeProgramOptimization="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ GlobalOptimizations="TRUE"
+ InlineFunctionExpansion="1"
+ FavorSizeOrSpeed="2"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DB3X_EXPORTS"
+ StringPooling="TRUE"
+ ExceptionHandling="FALSE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"
+ AssemblerOutput="3"
+ BrowseInformationFile="$(IntDir)/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="3"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ IgnoreImportLibrary="TRUE"
+ OutputFile="$(OutDir)/dbx_3x.dll"
+ SuppressStartupBanner="TRUE"
+ GenerateDebugInformation="TRUE"
+ GenerateMapFile="TRUE"
+ MapFileName="$(OutDir)/$(ProjectName).map"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ OptimizeForWindows98="1"
+ BaseAddress="0x5130000"
+ ImportLibrary="$(IntDir)/$(TargetName).lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/db3x.tlb"
+ HeaderFileName=""/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="2057"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Debug Unicode|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)/Plugins"
+ IntermediateDirectory="$(SolutionDir)$(ConfigurationName)/Obj/$(ProjectName)"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DB3X_EXPORTS"
+ ExceptionHandling="FALSE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ BufferSecurityCheck="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"
+ BrowseInformation="1"
+ BrowseInformationFile="$(IntDir)/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ IgnoreImportLibrary="TRUE"
+ OutputFile="$(OutDir)/dbx_3x.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="TRUE"
+ GenerateDebugInformation="TRUE"
+ ImportLibrary="$(IntDir)/$(TargetName).lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/db3x.tlb"
+ HeaderFileName=""/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="2057"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release Unicode|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)/Plugins"
+ IntermediateDirectory="$(SolutionDir)$(ConfigurationName)/Obj/$(ProjectName)"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2"
+ WholeProgramOptimization="FALSE">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ GlobalOptimizations="TRUE"
+ FavorSizeOrSpeed="2"
+ OmitFramePointers="FALSE"
+ OptimizeForProcessor="0"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DB3X_EXPORTS"
+ StringPooling="TRUE"
+ ExceptionHandling="FALSE"
+ RuntimeLibrary="2"
+ BufferSecurityCheck="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"
+ AssemblerOutput="3"
+ BrowseInformationFile="$(IntDir)/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="3"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ IgnoreImportLibrary="TRUE"
+ OutputFile="$(OutDir)/dbx_3x.dll"
+ GenerateDebugInformation="TRUE"
+ GenerateMapFile="TRUE"
+ MapFileName="$(OutDir)/$(ProjectName).map"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ OptimizeForWindows98="1"
+ BaseAddress="0x5130000"
+ ImportLibrary="$(IntDir)/$(TargetName).lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/db3x.tlb"
+ HeaderFileName=""/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="2057"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath="commonheaders.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ UsePrecompiledHeader="1"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="1"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ UsePrecompiledHeader="1"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="1"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="database.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbcache.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbcontacts.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbevents.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbheaders.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbmodulechain.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbsettings.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbtime.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="encrypt.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="init.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ BrowseInformation="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="commonheaders.h"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath="commonheaders.h">
+ </File>
+ <File
+ RelativePath="database.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ <File
+ RelativePath="resource.rc">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/db3x_autobackups/db3x_8.sln b/db3x_autobackups/db3x_8.sln
new file mode 100644
index 0000000..a033a41
--- /dev/null
+++ b/db3x_autobackups/db3x_8.sln
@@ -0,0 +1,23 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "db3x", "db3x_8.vcproj", "{8B778B6A-F5EF-49A4-8437-424832F2B280}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release (RECLAIM)|Win32 = Release (RECLAIM)|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8B778B6A-F5EF-49A4-8437-424832F2B280}.Debug|Win32.ActiveCfg = Release|Win32
+ {8B778B6A-F5EF-49A4-8437-424832F2B280}.Debug|Win32.Build.0 = Release|Win32
+ {8B778B6A-F5EF-49A4-8437-424832F2B280}.Release (RECLAIM)|Win32.ActiveCfg = Release (RECLAIM)|Win32
+ {8B778B6A-F5EF-49A4-8437-424832F2B280}.Release (RECLAIM)|Win32.Build.0 = Release (RECLAIM)|Win32
+ {8B778B6A-F5EF-49A4-8437-424832F2B280}.Release|Win32.ActiveCfg = Release|Win32
+ {8B778B6A-F5EF-49A4-8437-424832F2B280}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/db3x_autobackups/db3x_8.vcproj b/db3x_autobackups/db3x_8.vcproj
new file mode 100644
index 0000000..88639d2
--- /dev/null
+++ b/db3x_autobackups/db3x_8.vcproj
@@ -0,0 +1,808 @@
+<?xml version="1.0" encoding="windows-1251"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="db3x"
+ ProjectGUID="{8B778B6A-F5EF-49A4-8437-424832F2B280}"
+ RootNamespace="db3x"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/db3x.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DB3X_EXPORTS"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ CompileAs="0"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="2057"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../../bin/$(ConfigurationName)/Plugins/dbx_3x.dll"
+ LinkIncremental="0"
+ SuppressStartupBanner="true"
+ GenerateDebugInformation="true"
+ ImportLibrary="$(IntDir)/$(TargetName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/db3x.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ InlineFunctionExpansion="1"
+ FavorSizeOrSpeed="2"
+ OmitFramePointers="true"
+ WholeProgramOptimization="true"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DB3X_EXPORTS"
+ StringPooling="true"
+ ExceptionHandling="0"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ AssemblerOutput="3"
+ BrowseInformationFile="$(IntDir)/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ CompileAs="0"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="2057"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ IgnoreImportLibrary="true"
+ OutputFile="../../bin/$(ConfigurationName)/Plugins/dbx_3x.dll"
+ LinkIncremental="0"
+ SuppressStartupBanner="true"
+ AdditionalManifestDependencies="type=&apos;Win32&apos; name=&apos;Microsoft.Windows.Common-Controls&apos; version=&apos;6.0.0.0&apos; processorArchitecture=&apos;X86&apos; publicKeyToken=&apos;6595b64144ccf1df&apos; language=&apos;*&apos;"
+ GenerateDebugInformation="true"
+ GenerateMapFile="true"
+ MapFileName="$(OutDir)/$(ProjectName).map"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ OptimizeForWindows98="1"
+ BaseAddress="0x5130000"
+ ImportLibrary="$(IntDir)/$(TargetName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release (RECLAIM)|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/db3x.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="3"
+ InlineFunctionExpansion="1"
+ FavorSizeOrSpeed="2"
+ OmitFramePointers="true"
+ WholeProgramOptimization="true"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DB3X_EXPORTS;DB_RECLAIM"
+ StringPooling="true"
+ ExceptionHandling="0"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ AssemblerOutput="3"
+ BrowseInformationFile="$(IntDir)/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ CompileAs="0"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="2057"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ IgnoreImportLibrary="true"
+ OutputFile="../../bin/$(ConfigurationName)/Plugins/dbx_3x_reclaim.dll"
+ LinkIncremental="0"
+ SuppressStartupBanner="true"
+ AdditionalManifestDependencies="type=&apos;Win32&apos; name=&apos;Microsoft.Windows.Common-Controls&apos; version=&apos;6.0.0.0&apos; processorArchitecture=&apos;X86&apos; publicKeyToken=&apos;6595b64144ccf1df&apos; language=&apos;*&apos;"
+ GenerateDebugInformation="true"
+ GenerateMapFile="true"
+ MapFileName="$(OutDir)/$(ProjectName).map"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ OptimizeForWindows98="1"
+ BaseAddress="0x5130000"
+ ImportLibrary="$(IntDir)/$(TargetName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath=".\backup.c"
+ >
+ </File>
+ <File
+ RelativePath="commonheaders.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="1"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release (RECLAIM)|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="1"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="database.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release (RECLAIM)|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbcache.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release (RECLAIM)|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbcontacts.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release (RECLAIM)|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbevents.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release (RECLAIM)|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbheaders.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release (RECLAIM)|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbmodulechain.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release (RECLAIM)|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbsettings.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release (RECLAIM)|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="dbtime.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release (RECLAIM)|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="encrypt.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release (RECLAIM)|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\finalcommand.c"
+ >
+ </File>
+ <File
+ RelativePath="init.c"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ BasicRuntimeChecks="3"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release (RECLAIM)|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;DB3X_EXPORTS;$(NoInherit)"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="commonheaders.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\options.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath="commonheaders.h"
+ >
+ </File>
+ <File
+ RelativePath="database.h"
+ >
+ </File>
+ <File
+ RelativePath=".\options.h"
+ >
+ </File>
+ <File
+ RelativePath=".\resource.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ <File
+ RelativePath="resource.rc"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/db3x_autobackups/dbcache.c b/db3x_autobackups/dbcache.c
new file mode 100644
index 0000000..dd3bc5a
--- /dev/null
+++ b/db3x_autobackups/dbcache.c
@@ -0,0 +1,229 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+#include "database.h"
+
+
+#define CACHESECTIONSIZE 4096
+#define CACHESECTIONCOUNT 32
+
+extern HANDLE hDbFile;
+extern CRITICAL_SECTION csDbAccess;
+
+static BOOL safetyMode=TRUE;
+static PBYTE pDbCache;
+static DWORD lastUseCounter;
+struct DBCacheSectionInfo {
+ DWORD ofsBase;
+ DWORD lastUsed;
+} static cacheSectionInfo[CACHESECTIONCOUNT];
+
+static __inline int FindSectionForOffset(const DWORD ofs)
+{
+ int i;
+ for(i=0;i<CACHESECTIONCOUNT;i++)
+ if(ofs>=cacheSectionInfo[i].ofsBase && ofs<cacheSectionInfo[i].ofsBase+CACHESECTIONSIZE)
+ return i;
+ return -1;
+}
+
+static __inline int FindLRUSection(void)
+{
+ int i,lru=0;
+ DWORD lowestLastUse=cacheSectionInfo[0].lastUsed;
+ for(i=1;i<CACHESECTIONCOUNT;i++) if(cacheSectionInfo[i].lastUsed<lowestLastUse) {lru=i; lowestLastUse=cacheSectionInfo[i].lastUsed;}
+ return lru;
+}
+
+static __inline void LoadSection(const int i,DWORD ofs)
+{
+ cacheSectionInfo[i].ofsBase=ofs-ofs%CACHESECTIONSIZE;
+ log1("readsect %08x",ofs);
+ SetFilePointer(hDbFile,cacheSectionInfo[i].ofsBase,NULL,FILE_BEGIN);
+ ReadFile(hDbFile,pDbCache+i*CACHESECTIONSIZE,CACHESECTIONSIZE,&ofs,NULL);
+}
+
+static __inline void MoveSection(int *sectId,int dest)
+{
+ CopyMemory(pDbCache+dest*CACHESECTIONSIZE,pDbCache+(*sectId)*CACHESECTIONSIZE,CACHESECTIONSIZE);
+ cacheSectionInfo[dest].ofsBase=cacheSectionInfo[*sectId].ofsBase;
+ *sectId=dest;
+}
+
+
+
+//we are assumed to be in a mutex here
+PBYTE DBRead(DWORD ofs,int bytesRequired,int *bytesAvail)
+{
+
+ int part1sect;
+ int part2sect;
+
+
+ part1sect = FindSectionForOffset(ofs);
+ if (ofs%CACHESECTIONSIZE+bytesRequired<CACHESECTIONSIZE) {
+ //only one section required
+ if(part1sect==-1) {
+ part1sect=FindLRUSection();
+ LoadSection(part1sect,ofs);
+ }
+ cacheSectionInfo[part1sect].lastUsed=++lastUseCounter;
+ if(bytesAvail!=NULL) *bytesAvail=cacheSectionInfo[part1sect].ofsBase+CACHESECTIONSIZE-ofs;
+ return pDbCache+part1sect*CACHESECTIONSIZE+(ofs-cacheSectionInfo[part1sect].ofsBase);
+ }
+ //two sections are required
+ part2sect=FindSectionForOffset(ofs+CACHESECTIONSIZE);
+ if(part1sect!=-1) {
+ if(part2sect==-1) { //first part in cache, but not second part
+ if(part1sect==CACHESECTIONCOUNT-1) MoveSection(&part1sect,0);
+ LoadSection(part1sect+1,ofs+CACHESECTIONSIZE);
+ }
+ else if(part2sect!=part1sect+1) { //both parts are in cache, but not already consecutive
+ if(part1sect==CACHESECTIONCOUNT-1) {
+ //first part is at end, move to before second part
+ if(part2sect==0) //second part is at start: need to move both
+ MoveSection(&part2sect,1);
+ MoveSection(&part1sect,part2sect-1);
+ }
+ else //move second part to after first part
+ MoveSection(&part2sect,part1sect+1);
+ }
+ }
+ else {
+ if(part2sect==-1) { //neither section is in cache
+ part1sect=0; part2sect=1;
+ LoadSection(part1sect,ofs); LoadSection(part2sect,ofs+CACHESECTIONSIZE);
+ }
+ else { //part 2 is in cache, but not part 1
+ if(part2sect==0) MoveSection(&part2sect,1);
+ part1sect=part2sect-1;
+ LoadSection(part1sect,ofs);
+ }
+ }
+ //both sections are now consecutive, starting at part1sect
+ cacheSectionInfo[part1sect].lastUsed=++lastUseCounter;
+ cacheSectionInfo[part1sect+1].lastUsed=++lastUseCounter;
+ if(bytesAvail!=NULL) *bytesAvail=cacheSectionInfo[part1sect+1].ofsBase+CACHESECTIONSIZE-ofs;
+ return pDbCache+part1sect*CACHESECTIONSIZE+(ofs-cacheSectionInfo[part1sect].ofsBase);
+}
+
+
+
+//we are assumed to be in a mutex here
+void DBWrite(DWORD ofs,PVOID pData,int bytes)
+{
+ //write direct, and rely on Windows' write caching
+ DWORD bytesWritten;
+ int i;
+
+ log2("write %d@%08x",bytes,ofs);
+ SetFilePointer(hDbFile,ofs,NULL,FILE_BEGIN);
+ if (WriteFile(hDbFile,pData,bytes,&bytesWritten,NULL)==0)
+ {
+ DatabaseCorruption();
+ }
+ logg();
+ //check if any of the cache sections contain this bit
+ for(i=0;i<CACHESECTIONCOUNT;i++) {
+ if(ofs+bytes>=cacheSectionInfo[i].ofsBase && ofs<cacheSectionInfo[i].ofsBase+CACHESECTIONSIZE) {
+ if(ofs<cacheSectionInfo[i].ofsBase) { //don't start at beginning
+ if(ofs+bytes>=cacheSectionInfo[i].ofsBase+CACHESECTIONSIZE) //don't finish at end
+ CopyMemory(pDbCache+i*CACHESECTIONSIZE,(PBYTE)pData+cacheSectionInfo[i].ofsBase-ofs,CACHESECTIONSIZE);
+ else CopyMemory(pDbCache+i*CACHESECTIONSIZE,(PBYTE)pData+cacheSectionInfo[i].ofsBase-ofs,bytes-(cacheSectionInfo[i].ofsBase-ofs));
+ }
+ else { //start at beginning
+ if(ofs+bytes>=cacheSectionInfo[i].ofsBase+CACHESECTIONSIZE) //don't finish at end
+ CopyMemory(pDbCache+i*CACHESECTIONSIZE+ofs-cacheSectionInfo[i].ofsBase,pData,cacheSectionInfo[i].ofsBase+CACHESECTIONSIZE-ofs);
+ else CopyMemory(pDbCache+i*CACHESECTIONSIZE+ofs-cacheSectionInfo[i].ofsBase,pData,bytes);
+ }
+ }
+ }
+}
+
+void DBMoveChunk(DWORD ofsDest,DWORD ofsSource,int bytes)
+{
+ DWORD bytesRead;
+ PBYTE buf;
+
+ log3("move %d %08x->%08x",bytes,ofsSource,ofsDest);
+ buf=(PBYTE)mir_alloc(bytes);
+ SetFilePointer(hDbFile,ofsSource,NULL,FILE_BEGIN);
+ ReadFile(hDbFile,buf,bytes,&bytesRead,NULL);
+ DBWrite(ofsDest,buf,bytes);
+ mir_free(buf);
+ logg();
+}
+
+static int flushBuffersTimerId;
+static VOID CALLBACK DoBufferFlushTimerProc(HWND hwnd,UINT message,UINT idEvent,DWORD dwTime)
+{
+ KillTimer(NULL,flushBuffersTimerId);
+ log0("tflush1");
+ FlushFileBuffers(hDbFile);
+ log0("tflush2");
+}
+
+void DBFlush(int setting)
+{
+ if(!setting) {
+ log0("nflush1");
+ if(safetyMode) FlushFileBuffers(hDbFile);
+ log0("nflush2");
+ return;
+ }
+ KillTimer(NULL,flushBuffersTimerId);
+ flushBuffersTimerId=SetTimer(NULL,flushBuffersTimerId,50,DoBufferFlushTimerProc);
+}
+
+static int CacheSetSafetyMode(WPARAM wParam,LPARAM lParam)
+{
+ EnterCriticalSection(&csDbAccess);
+ safetyMode=wParam;
+ LeaveCriticalSection(&csDbAccess);
+ if(safetyMode) FlushFileBuffers(hDbFile);
+ return 0;
+}
+
+int InitCache(void)
+{
+ int i;
+ DWORD bytesRead;
+
+ CreateServiceFunction(MS_DB_SETSAFETYMODE,CacheSetSafetyMode);
+ pDbCache=(PBYTE)mir_alloc(CACHESECTIONSIZE*CACHESECTIONCOUNT);
+ lastUseCounter=CACHESECTIONCOUNT;
+ for(i=0;i<CACHESECTIONCOUNT;i++) {
+ cacheSectionInfo[i].ofsBase=0;
+ cacheSectionInfo[i].lastUsed=i;
+ SetFilePointer(hDbFile,cacheSectionInfo[i].ofsBase,NULL,FILE_BEGIN);
+ ReadFile(hDbFile,pDbCache+i*CACHESECTIONSIZE,CACHESECTIONSIZE,&bytesRead,NULL);
+ }
+ return 0;
+}
+
+void UninitCache(void)
+{
+ mir_free(pDbCache);
+ KillTimer(NULL,flushBuffersTimerId);
+}
diff --git a/db3x_autobackups/dbcontacts.c b/db3x_autobackups/dbcontacts.c
new file mode 100644
index 0000000..2a8d038
--- /dev/null
+++ b/db3x_autobackups/dbcontacts.c
@@ -0,0 +1,270 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+#include "database.h"
+
+static int GetContactCount(WPARAM wParam,LPARAM lParam);
+static int FindFirstContact(WPARAM wParam,LPARAM lParam);
+static int FindNextContact(WPARAM wParam,LPARAM lParam);
+static int DeleteContact(WPARAM wParam,LPARAM lParam);
+static int AddContact(WPARAM wParam,LPARAM lParam);
+static int IsDbContact(WPARAM wParam,LPARAM lParam);
+
+extern CRITICAL_SECTION csDbAccess;
+extern struct DBHeader dbHeader;
+static HANDLE hContactDeletedEvent,hContactAddedEvent;
+
+extern HANDLE hCacheHeap;
+extern SortedList lContacts;
+
+int InitContacts(void)
+{
+ CreateServiceFunction(MS_DB_CONTACT_GETCOUNT,GetContactCount);
+ CreateServiceFunction(MS_DB_CONTACT_FINDFIRST,FindFirstContact);
+ CreateServiceFunction(MS_DB_CONTACT_FINDNEXT,FindNextContact);
+ CreateServiceFunction(MS_DB_CONTACT_DELETE,DeleteContact);
+ CreateServiceFunction(MS_DB_CONTACT_ADD,AddContact);
+ CreateServiceFunction(MS_DB_CONTACT_IS,IsDbContact);
+ hContactDeletedEvent=CreateHookableEvent(ME_DB_CONTACT_DELETED);
+ hContactAddedEvent=CreateHookableEvent(ME_DB_CONTACT_ADDED);
+ return 0;
+}
+
+void UninitContacts(void)
+{
+}
+
+static int GetContactCount(WPARAM wParam,LPARAM lParam)
+{
+ int ret;
+
+ EnterCriticalSection(&csDbAccess);
+ ret=dbHeader.contactCount;
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
+
+static int FindFirstContact(WPARAM wParam,LPARAM lParam)
+{
+ int ret = 0;
+ EnterCriticalSection(&csDbAccess);
+ ret = (int)(HANDLE)dbHeader.ofsFirstContact;
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
+
+static int FindNextContact(WPARAM wParam,LPARAM lParam)
+{
+ int ret, index;
+ struct DBContact *dbc;
+ DBCachedContactValueList *VL = NULL;
+
+ EnterCriticalSection(&csDbAccess);
+ {
+ DBCachedContactValueList VLtemp;
+ VLtemp.hContact = (HANDLE)wParam;
+ if ( li.List_GetIndex(&lContacts,&VLtemp,&index)) {
+ VL = ( DBCachedContactValueList* )lContacts.items[index];
+ if ( VL->hNext != NULL ) {
+ LeaveCriticalSection(&csDbAccess);
+ return (int)VL->hNext;
+ } } }
+
+ dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
+ if(dbc->signature!=DBCONTACT_SIGNATURE)
+ ret=(int)(HANDLE)NULL;
+ else {
+ if ( VL == NULL ) {
+ VL = (DBCachedContactValueList*)HeapAlloc(hCacheHeap,HEAP_NO_SERIALIZE+HEAP_ZERO_MEMORY,sizeof(DBCachedContactValueList));
+ VL->hContact = (HANDLE)wParam;
+ li.List_Insert(&lContacts,VL,index);
+ }
+ VL->hNext = (HANDLE)dbc->ofsNext;
+ ret=(int)(HANDLE)dbc->ofsNext;
+ }
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
+
+static int DeleteContact(WPARAM wParam,LPARAM lParam)
+{
+ struct DBContact *dbc,*dbcPrev;
+ DWORD ofsThis,ofsNext,ofsFirstEvent;
+ struct DBContactSettings *dbcs;
+ struct DBEvent *dbe;
+ int index;
+
+ if((HANDLE)wParam==NULL) return 1;
+ EnterCriticalSection(&csDbAccess);
+ dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
+ if(dbc->signature!=DBCONTACT_SIGNATURE) {
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ if ( (HANDLE)wParam == (HANDLE)dbHeader.ofsUser ) {
+ LeaveCriticalSection(&csDbAccess);
+ log0("FATAL: del of user chain attempted.");
+ return 1;
+ }
+ log0("del contact");
+ LeaveCriticalSection(&csDbAccess);
+ //call notifier while outside mutex
+ NotifyEventHooks(hContactDeletedEvent,wParam,0);
+ //get back in
+ EnterCriticalSection(&csDbAccess);
+
+ { DBCachedContactValueList VLtemp;
+ VLtemp.hContact = (HANDLE)wParam;
+ if ( li.List_GetIndex(&lContacts,&VLtemp,&index))
+ {
+ DBCachedContactValueList *VL = ( DBCachedContactValueList* )lContacts.items[index];
+ DBCachedContactValue* V = VL->first;
+ while ( V != NULL ) {
+ DBCachedContactValue* V1 = V->next;
+ if ( V->value.type == DBVT_ASCIIZ )
+ HeapFree( hCacheHeap, HEAP_NO_SERIALIZE, V->value.pszVal );
+ HeapFree( hCacheHeap, HEAP_NO_SERIALIZE, V );
+ V = V1;
+ }
+ HeapFree( hCacheHeap, HEAP_NO_SERIALIZE, VL );
+
+ li.List_Remove(&lContacts,index);
+ } }
+
+ dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
+ //delete settings chain
+ ofsThis=dbc->ofsFirstSettings;
+ ofsFirstEvent=dbc->ofsFirstEvent;
+ while(ofsThis) {
+ dbcs=(struct DBContactSettings*)DBRead(ofsThis,sizeof(struct DBContactSettings),NULL);
+ ofsNext=dbcs->ofsNext;
+ DeleteSpace(ofsThis,offsetof(struct DBContactSettings,blob)+dbcs->cbBlob);
+ ofsThis=ofsNext;
+ }
+ //delete event chain
+ ofsThis=ofsFirstEvent;
+ while(ofsThis) {
+ dbe=(struct DBEvent*)DBRead(ofsThis,sizeof(struct DBEvent),NULL);
+ ofsNext=dbe->ofsNext;
+ DeleteSpace(ofsThis,offsetof(struct DBEvent,blob)+dbe->cbBlob);
+ ofsThis=ofsNext;
+ }
+ //find previous contact in chain and change ofsNext
+ dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
+ if(dbHeader.ofsFirstContact==wParam) {
+ dbHeader.ofsFirstContact=dbc->ofsNext;
+ DBWrite(0,&dbHeader,sizeof(dbHeader));
+ }
+ else {
+ ofsNext=dbc->ofsNext;
+ ofsThis=dbHeader.ofsFirstContact;
+ dbcPrev=(struct DBContact*)DBRead(ofsThis,sizeof(struct DBContact),NULL);
+ while(dbcPrev->ofsNext!=wParam) {
+ if(dbcPrev->ofsNext==0) DatabaseCorruption();
+ ofsThis=dbcPrev->ofsNext;
+ dbcPrev=(struct DBContact*)DBRead(ofsThis,sizeof(struct DBContact),NULL);
+ }
+ dbcPrev->ofsNext=ofsNext;
+ DBWrite(ofsThis,dbcPrev,sizeof(struct DBContact));
+ {
+ DBCachedContactValueList VLtemp;
+ VLtemp.hContact = (HANDLE)ofsThis;
+ if ( li.List_GetIndex(&lContacts,&VLtemp,&index))
+ {
+ DBCachedContactValueList *VL = ( DBCachedContactValueList* )lContacts.items[index];
+ VL->hNext = ( HANDLE )ofsNext;
+ } }
+ }
+ //delete contact
+ DeleteSpace(wParam,sizeof(struct DBContact));
+ //decrement contact count
+ dbHeader.contactCount--;
+ DBWrite(0,&dbHeader,sizeof(dbHeader));
+ DBFlush(0);
+ //quit
+ LeaveCriticalSection(&csDbAccess);
+ return 0;
+}
+
+static int AddContact(WPARAM wParam,LPARAM lParam)
+{
+ struct DBContact dbc;
+ DWORD ofsNew;
+
+ log0("add contact");
+ EnterCriticalSection(&csDbAccess);
+ ofsNew=CreateNewSpace(sizeof(struct DBContact));
+ dbc.signature=DBCONTACT_SIGNATURE;
+ dbc.eventCount=0;
+ dbc.ofsFirstEvent=dbc.ofsLastEvent=0;
+ dbc.ofsFirstSettings=0;
+ dbc.ofsNext=dbHeader.ofsFirstContact;
+ dbc.ofsFirstUnreadEvent=0;
+ dbc.timestampFirstUnread=0;
+ dbHeader.ofsFirstContact=ofsNew;
+ dbHeader.contactCount++;
+ DBWrite(ofsNew,&dbc,sizeof(struct DBContact));
+ DBWrite(0,&dbHeader,sizeof(dbHeader));
+ DBFlush(0);
+
+ { int index;
+
+ DBCachedContactValueList *VL = (DBCachedContactValueList*)HeapAlloc(hCacheHeap,HEAP_NO_SERIALIZE+HEAP_ZERO_MEMORY,sizeof(DBCachedContactValueList));
+ VL->hContact = (HANDLE)ofsNew;
+
+ li.List_GetIndex(&lContacts,VL,&index);
+ li.List_Insert(&lContacts,VL,index);
+ }
+
+ LeaveCriticalSection(&csDbAccess);
+ NotifyEventHooks(hContactAddedEvent,(WPARAM)ofsNew,0);
+ return (int)ofsNew;
+}
+
+static int IsDbContact(WPARAM wParam,LPARAM lParam)
+{
+ struct DBContact dbc;
+ DWORD ofsContact=(DWORD)wParam;
+ int ret;
+
+ EnterCriticalSection(&csDbAccess);
+ {
+ int index;
+ DBCachedContactValueList VLtemp,*VL;
+ VLtemp.hContact = (HANDLE)wParam;
+ if ( li.List_GetIndex(&lContacts,&VLtemp,&index))
+ ret = TRUE;
+ else {
+ dbc=*(struct DBContact*)DBRead(ofsContact,sizeof(struct DBContact),NULL);
+ ret=dbc.signature==DBCONTACT_SIGNATURE;
+
+ if (ret) {
+ VL = (DBCachedContactValueList*)HeapAlloc(hCacheHeap,HEAP_NO_SERIALIZE+HEAP_ZERO_MEMORY,sizeof(DBCachedContactValueList));
+ VL->hContact = (HANDLE)wParam;
+ li.List_Insert(&lContacts,VL,index);
+ } } }
+
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
diff --git a/db3x_autobackups/dbevents.c b/db3x_autobackups/dbevents.c
new file mode 100644
index 0000000..e0f7c02
--- /dev/null
+++ b/db3x_autobackups/dbevents.c
@@ -0,0 +1,440 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+#include "database.h"
+
+
+DWORD GetModuleNameOfs(const char *szName);
+char *GetModuleNameByOfs(DWORD ofs);
+
+static int GetEventCount(WPARAM wParam,LPARAM lParam);
+static int AddEvent(WPARAM wParam,LPARAM lParam);
+static int DeleteEvent(WPARAM wParam,LPARAM lParam);
+static int GetBlobSize(WPARAM wParam,LPARAM lParam);
+static int GetEvent(WPARAM wParam,LPARAM lParam);
+static int MarkEventRead(WPARAM wParam,LPARAM lParam);
+static int GetEventContact(WPARAM wParam,LPARAM lParam);
+static int FindFirstEvent(WPARAM wParam,LPARAM lParam);
+static int FindFirstUnreadEvent(WPARAM wParam,LPARAM lParam);
+static int FindLastEvent(WPARAM wParam,LPARAM lParam);
+static int FindNextEvent(WPARAM wParam,LPARAM lParam);
+static int FindPrevEvent(WPARAM wParam,LPARAM lParam);
+
+extern CRITICAL_SECTION csDbAccess;
+extern struct DBHeader dbHeader;
+
+static HANDLE hEventDeletedEvent,hEventAddedEvent,hEventFilterAddedEvent;
+
+int InitEvents(void)
+{
+ CreateServiceFunction(MS_DB_EVENT_GETCOUNT,GetEventCount);
+ CreateServiceFunction(MS_DB_EVENT_ADD,AddEvent);
+ CreateServiceFunction(MS_DB_EVENT_DELETE,DeleteEvent);
+ CreateServiceFunction(MS_DB_EVENT_GETBLOBSIZE,GetBlobSize);
+ CreateServiceFunction(MS_DB_EVENT_GET,GetEvent);
+ CreateServiceFunction(MS_DB_EVENT_MARKREAD,MarkEventRead);
+ CreateServiceFunction(MS_DB_EVENT_GETCONTACT,GetEventContact);
+ CreateServiceFunction(MS_DB_EVENT_FINDFIRST,FindFirstEvent);
+ CreateServiceFunction(MS_DB_EVENT_FINDFIRSTUNREAD,FindFirstUnreadEvent);
+ CreateServiceFunction(MS_DB_EVENT_FINDLAST,FindLastEvent);
+ CreateServiceFunction(MS_DB_EVENT_FINDNEXT,FindNextEvent);
+ CreateServiceFunction(MS_DB_EVENT_FINDPREV,FindPrevEvent);
+ hEventDeletedEvent=CreateHookableEvent(ME_DB_EVENT_DELETED);
+ hEventAddedEvent=CreateHookableEvent(ME_DB_EVENT_ADDED);
+ hEventFilterAddedEvent=CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
+ return 0;
+}
+
+void UninitEvents(void)
+{
+}
+
+static int GetEventCount(WPARAM wParam,LPARAM lParam)
+{
+ int ret;
+ struct DBContact *dbc;
+
+ EnterCriticalSection(&csDbAccess);
+ if(wParam==0) wParam=dbHeader.ofsUser;
+ dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
+ if(dbc->signature!=DBCONTACT_SIGNATURE) ret=-1;
+ else ret=dbc->eventCount;
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
+
+static int AddEvent(WPARAM wParam,LPARAM lParam)
+{
+ DBEVENTINFO *dbei=(DBEVENTINFO*)lParam;
+ struct DBContact dbc;
+ struct DBEvent dbe,*dbeTest;
+ DWORD ofsNew,ofsModuleName,ofsContact,ofsThis;
+
+ if(dbei==NULL||dbei->cbSize!=sizeof(DBEVENTINFO)) return (int)NULL;
+ if(dbei->timestamp==0) return (int)NULL;
+ if (NotifyEventHooks(hEventFilterAddedEvent,wParam,lParam)) {
+ return (int)NULL;
+ }
+ EnterCriticalSection(&csDbAccess);
+ if(wParam==0) ofsContact=dbHeader.ofsUser;
+ else ofsContact=wParam;
+ dbc=*(struct DBContact*)DBRead(ofsContact,sizeof(struct DBContact),NULL);
+ if(dbc.signature!=DBCONTACT_SIGNATURE) {
+ LeaveCriticalSection(&csDbAccess);
+ return (int)NULL;
+ }
+ ofsNew=CreateNewSpace(offsetof(struct DBEvent,blob)+dbei->cbBlob);
+ ofsModuleName=GetModuleNameOfs(dbei->szModule);
+
+ dbe.signature=DBEVENT_SIGNATURE;
+ dbe.ofsModuleName=ofsModuleName;
+ dbe.timestamp=dbei->timestamp;
+ dbe.flags=dbei->flags;
+ dbe.eventType=dbei->eventType;
+ dbe.cbBlob=dbei->cbBlob;
+ //find where to put it - sort by timestamp
+ if(dbc.eventCount==0) {
+ dbe.ofsPrev=wParam;
+ dbe.ofsNext=0;
+ dbe.flags|=DBEF_FIRST;
+ dbc.ofsFirstEvent=dbc.ofsLastEvent=ofsNew;
+ }
+ else {
+ dbeTest=(struct DBEvent*)DBRead(dbc.ofsFirstEvent,sizeof(struct DBEvent),NULL);
+ // Should new event be placed before first event in chain?
+ if (dbei->timestamp < dbeTest->timestamp) {
+ dbe.ofsPrev=wParam;
+ dbe.ofsNext=dbc.ofsFirstEvent;
+ dbe.flags|=DBEF_FIRST;
+ dbc.ofsFirstEvent=ofsNew;
+ dbeTest=(struct DBEvent*)DBRead(dbe.ofsNext,sizeof(struct DBEvent),NULL);
+ dbeTest->flags&=~DBEF_FIRST;
+ dbeTest->ofsPrev=ofsNew;
+ DBWrite(dbe.ofsNext,dbeTest,sizeof(struct DBEvent));
+ }
+ else {
+ // Loop through the chain, starting at the end
+ ofsThis = dbc.ofsLastEvent;
+ dbeTest = (struct DBEvent*)DBRead(ofsThis, sizeof(struct DBEvent), NULL);
+ for(;;) {
+ // If the new event's timesstamp is equal to or greater than the
+ // current dbevent, it will be inserted after. If not, continue
+ // with the previous dbevent in chain.
+ if (dbe.timestamp >= dbeTest->timestamp) {
+ dbe.ofsPrev = ofsThis;
+ dbe.ofsNext = dbeTest->ofsNext;
+ dbeTest->ofsNext = ofsNew;
+ DBWrite(ofsThis, dbeTest, sizeof(struct DBEvent));
+ if (dbe.ofsNext == 0)
+ dbc.ofsLastEvent = ofsNew;
+ else {
+ dbeTest = (struct DBEvent*)DBRead(dbe.ofsNext, sizeof(struct DBEvent), NULL);
+ dbeTest->ofsPrev = ofsNew;
+ DBWrite(dbe.ofsNext, dbeTest, sizeof(struct DBEvent));
+ }
+ break;
+ }
+ ofsThis = dbeTest->ofsPrev;
+ dbeTest = (struct DBEvent*)DBRead(ofsThis, sizeof(struct DBEvent), NULL);
+ }
+ }
+ }
+ dbc.eventCount++;
+ if(!(dbe.flags&(DBEF_READ|DBEF_SENT))) {
+ if(dbe.timestamp<dbc.timestampFirstUnread || dbc.timestampFirstUnread==0) {
+ dbc.timestampFirstUnread=dbe.timestamp;
+ dbc.ofsFirstUnreadEvent=ofsNew;
+ }
+ }
+ DBWrite(ofsContact,&dbc,sizeof(struct DBContact));
+ DBWrite(ofsNew,&dbe,offsetof(struct DBEvent,blob));
+ DBWrite(ofsNew+offsetof(struct DBEvent,blob),dbei->pBlob,dbei->cbBlob);
+ DBFlush(0);
+ LeaveCriticalSection(&csDbAccess);
+ log1("add event @ %08x",ofsNew);
+ NotifyEventHooks(hEventAddedEvent,wParam,(LPARAM)ofsNew);
+ return (int)ofsNew;
+}
+
+static int DeleteEvent(WPARAM wParam,LPARAM lParam)
+{
+ struct DBContact dbc;
+ DWORD ofsContact,ofsThis;
+ struct DBEvent dbe,*dbeNext,*dbePrev;
+
+ EnterCriticalSection(&csDbAccess);
+ if(wParam==0) ofsContact=dbHeader.ofsUser;
+ else ofsContact=wParam;
+ dbc=*(struct DBContact*)DBRead(ofsContact,sizeof(struct DBContact),NULL);
+ dbe=*(struct DBEvent*)DBRead(lParam,sizeof(struct DBEvent),NULL);
+ if(dbc.signature!=DBCONTACT_SIGNATURE || dbe.signature!=DBEVENT_SIGNATURE) {
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ log1("delete event @ %08x",wParam);
+ LeaveCriticalSection(&csDbAccess);
+ //call notifier while outside mutex
+ NotifyEventHooks(hEventDeletedEvent,wParam,lParam);
+ //get back in
+ EnterCriticalSection(&csDbAccess);
+ dbc=*(struct DBContact*)DBRead(ofsContact,sizeof(struct DBContact),NULL);
+ dbe=*(struct DBEvent*)DBRead(lParam,sizeof(struct DBEvent),NULL);
+ //check if this was the first unread, if so, recalc the first unread
+ if(dbc.ofsFirstUnreadEvent==(DWORD)lParam) {
+ dbeNext=&dbe;
+ for(;;) {
+ if(dbeNext->ofsNext==0) {
+ dbc.ofsFirstUnreadEvent=0;
+ dbc.timestampFirstUnread=0;
+ break;
+ }
+ ofsThis=dbeNext->ofsNext;
+ dbeNext=(struct DBEvent*)DBRead(ofsThis,sizeof(struct DBEvent),NULL);
+ if(!(dbeNext->flags&(DBEF_READ|DBEF_SENT))) {
+ dbc.ofsFirstUnreadEvent=ofsThis;
+ dbc.timestampFirstUnread=dbeNext->timestamp;
+ break;
+ }
+ }
+ }
+ //get previous and next events in chain and change offsets
+ if(dbe.flags&DBEF_FIRST) {
+ if(dbe.ofsNext==0) {
+ dbc.ofsFirstEvent=dbc.ofsLastEvent=0;
+ }
+ else {
+ dbeNext=(struct DBEvent*)DBRead(dbe.ofsNext,sizeof(struct DBEvent),NULL);
+ dbeNext->flags|=DBEF_FIRST;
+ dbeNext->ofsPrev=dbe.ofsPrev;
+ DBWrite(dbe.ofsNext,dbeNext,sizeof(struct DBEvent));
+ dbc.ofsFirstEvent=dbe.ofsNext;
+ }
+ }
+ else {
+ if(dbe.ofsNext==0) {
+ dbePrev=(struct DBEvent*)DBRead(dbe.ofsPrev,sizeof(struct DBEvent),NULL);
+ dbePrev->ofsNext=0;
+ DBWrite(dbe.ofsPrev,dbePrev,sizeof(struct DBEvent));
+ dbc.ofsLastEvent=dbe.ofsPrev;
+ }
+ else {
+ dbePrev=(struct DBEvent*)DBRead(dbe.ofsPrev,sizeof(struct DBEvent),NULL);
+ dbePrev->ofsNext=dbe.ofsNext;
+ DBWrite(dbe.ofsPrev,dbePrev,sizeof(struct DBEvent));
+ dbeNext=(struct DBEvent*)DBRead(dbe.ofsNext,sizeof(struct DBEvent),NULL);
+ dbeNext->ofsPrev=dbe.ofsPrev;
+ DBWrite(dbe.ofsNext,dbeNext,sizeof(struct DBEvent));
+ }
+ }
+ //delete event
+ DeleteSpace(lParam,offsetof(struct DBEvent,blob)+dbe.cbBlob);
+ //decrement event count
+ dbc.eventCount--;
+ DBWrite(ofsContact,&dbc,sizeof(struct DBContact));
+ DBFlush(0);
+ //quit
+ LeaveCriticalSection(&csDbAccess);
+ return 0;
+}
+
+static int GetBlobSize(WPARAM wParam,LPARAM lParam)
+{
+ int ret;
+ struct DBEvent *dbe;
+
+ EnterCriticalSection(&csDbAccess);
+ dbe=(struct DBEvent*)DBRead(wParam,sizeof(struct DBEvent),NULL);
+ if(dbe->signature!=DBEVENT_SIGNATURE) ret=-1;
+ else ret=dbe->cbBlob;
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
+
+static int GetEvent(WPARAM wParam,LPARAM lParam)
+{
+ struct DBEvent *dbe;
+ DBEVENTINFO *dbei=(DBEVENTINFO*)lParam;
+ int bytesToCopy,i;
+
+ if(dbei==NULL||dbei->cbSize!=sizeof(DBEVENTINFO)) return 1;
+ EnterCriticalSection(&csDbAccess);
+ dbe=(struct DBEvent*)DBRead(wParam,sizeof(struct DBEvent),NULL);
+ if(dbe->signature!=DBEVENT_SIGNATURE) {
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ dbei->szModule=GetModuleNameByOfs(dbe->ofsModuleName);
+ dbei->timestamp=dbe->timestamp;
+ dbei->flags=dbe->flags;
+ dbei->eventType=dbe->eventType;
+ if(dbei->cbBlob<dbe->cbBlob) bytesToCopy=dbei->cbBlob;
+ else bytesToCopy=dbe->cbBlob;
+ dbei->cbBlob=dbe->cbBlob;
+ if(dbei->pBlob == 0 && bytesToCopy > 0) {
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ for(i=0;;i+=MAXCACHEDREADSIZE) {
+ if(bytesToCopy-i<=MAXCACHEDREADSIZE) {
+ CopyMemory(dbei->pBlob+i,DBRead(wParam+offsetof(struct DBEvent,blob)+i,bytesToCopy-i,NULL),bytesToCopy-i);
+ break;
+ }
+ CopyMemory(dbei->pBlob+i,DBRead(wParam+offsetof(struct DBEvent,blob)+i,MAXCACHEDREADSIZE,NULL),MAXCACHEDREADSIZE);
+ }
+ LeaveCriticalSection(&csDbAccess);
+ return 0;
+}
+
+static int MarkEventRead(WPARAM wParam,LPARAM lParam)
+{
+ int ret;
+ struct DBEvent *dbe;
+ struct DBContact dbc;
+ DWORD ofsThis;
+
+ EnterCriticalSection(&csDbAccess);
+ if(wParam==0) wParam=dbHeader.ofsUser;
+ dbc=*(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
+ dbe=(struct DBEvent*)DBRead(lParam,sizeof(struct DBEvent),NULL);
+ if(dbe->signature!=DBEVENT_SIGNATURE || dbc.signature!=DBCONTACT_SIGNATURE) {
+ LeaveCriticalSection(&csDbAccess);
+ return -1;
+ }
+ if(dbe->flags&DBEF_READ || dbe->flags&DBEF_SENT) {
+ ret=(int)dbe->flags;
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+ }
+ log1("mark read @ %08x",wParam);
+ dbe->flags|=DBEF_READ;
+ DBWrite(lParam,dbe,sizeof(struct DBEvent));
+ ret=(int)dbe->flags;
+ if(dbc.ofsFirstUnreadEvent==(DWORD)lParam) {
+ for(;;) {
+ if(dbe->ofsNext==0) {
+ dbc.ofsFirstUnreadEvent=0;
+ dbc.timestampFirstUnread=0;
+ break;
+ }
+ ofsThis=dbe->ofsNext;
+ dbe=(struct DBEvent*)DBRead(ofsThis,sizeof(struct DBEvent),NULL);
+ if(!(dbe->flags&(DBEF_READ|DBEF_SENT))) {
+ dbc.ofsFirstUnreadEvent=ofsThis;
+ dbc.timestampFirstUnread=dbe->timestamp;
+ break;
+ }
+ }
+ }
+ DBWrite(wParam,&dbc,sizeof(struct DBContact));
+ DBFlush(0);
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
+
+static int GetEventContact(WPARAM wParam,LPARAM lParam)
+{
+ int ret;
+ struct DBEvent *dbe;
+
+ EnterCriticalSection(&csDbAccess);
+ dbe=(struct DBEvent*)DBRead(wParam,sizeof(struct DBEvent),NULL);
+ if(dbe->signature!=DBEVENT_SIGNATURE) {
+ LeaveCriticalSection(&csDbAccess);
+ return -1;
+ }
+ while(!(dbe->flags&DBEF_FIRST))
+ dbe=(struct DBEvent*)DBRead(dbe->ofsPrev,sizeof(struct DBEvent),NULL);
+ ret=(int)(HANDLE)dbe->ofsPrev;
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
+
+static int FindFirstEvent(WPARAM wParam,LPARAM lParam)
+{
+ int ret;
+ struct DBContact *dbc;
+
+ EnterCriticalSection(&csDbAccess);
+ if(wParam==0) wParam=dbHeader.ofsUser;
+ dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
+ if(dbc->signature!=DBCONTACT_SIGNATURE) ret=(int)(HANDLE)NULL;
+ else ret=(int)dbc->ofsFirstEvent;
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
+
+static int FindFirstUnreadEvent(WPARAM wParam,LPARAM lParam)
+{
+ int ret;
+ struct DBContact *dbc;
+
+ EnterCriticalSection(&csDbAccess);
+ if(wParam==0) wParam=dbHeader.ofsUser;
+ dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
+ if(dbc->signature!=DBCONTACT_SIGNATURE) ret=(int)(HANDLE)NULL;
+ else ret=(int)dbc->ofsFirstUnreadEvent;
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
+
+static int FindLastEvent(WPARAM wParam,LPARAM lParam)
+{
+ int ret;
+ struct DBContact *dbc;
+
+ EnterCriticalSection(&csDbAccess);
+ if(wParam==0) wParam=dbHeader.ofsUser;
+ dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
+ if(dbc->signature!=DBCONTACT_SIGNATURE) ret=(int)(HANDLE)NULL;
+ else ret=(int)dbc->ofsLastEvent;
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
+
+static int FindNextEvent(WPARAM wParam,LPARAM lParam)
+{
+ int ret;
+ struct DBEvent *dbe;
+
+ EnterCriticalSection(&csDbAccess);
+ dbe=(struct DBEvent*)DBRead(wParam,sizeof(struct DBEvent),NULL);
+ if(dbe->signature!=DBEVENT_SIGNATURE) ret=(int)(HANDLE)NULL;
+ else ret=(int)(HANDLE)dbe->ofsNext;
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
+
+static int FindPrevEvent(WPARAM wParam,LPARAM lParam)
+{
+ int ret;
+ struct DBEvent *dbe;
+
+ EnterCriticalSection(&csDbAccess);
+ dbe=(struct DBEvent*)DBRead(wParam,sizeof(struct DBEvent),NULL);
+ if(dbe->signature!=DBEVENT_SIGNATURE) ret=(int)(HANDLE)NULL;
+ else if(dbe->flags&DBEF_FIRST) ret=(int)(HANDLE)NULL;
+ else ret=(int)(HANDLE)dbe->ofsPrev;
+ LeaveCriticalSection(&csDbAccess);
+ return ret;
+}
diff --git a/db3x_autobackups/dbheaders.c b/db3x_autobackups/dbheaders.c
new file mode 100644
index 0000000..da7cb6e
--- /dev/null
+++ b/db3x_autobackups/dbheaders.c
@@ -0,0 +1,78 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+#include "database.h"
+
+extern struct DBHeader dbHeader;
+extern HANDLE hDbFile;
+
+struct DBSignature {
+ char name[15];
+ BYTE eof;
+};
+static struct DBSignature dbSignature={"Miranda ICQ DB",0x1A};
+
+//the cache has not been loaded when these functions are used
+
+int CreateDbHeaders(HANDLE hFile)
+{
+ struct DBContact user;
+ DWORD bytesWritten;
+
+ CopyMemory(dbHeader.signature,&dbSignature,sizeof(dbHeader.signature));
+ dbHeader.version=DB_THIS_VERSION;
+ dbHeader.ofsFileEnd=sizeof(struct DBHeader);
+ dbHeader.slackSpace=0;
+ dbHeader.contactCount=0;
+ dbHeader.ofsFirstContact=0;
+ dbHeader.ofsFirstModuleName=0;
+ dbHeader.ofsUser=0;
+ //create user
+ dbHeader.ofsUser=dbHeader.ofsFileEnd;
+ dbHeader.ofsFileEnd+=sizeof(struct DBContact);
+ SetFilePointer(hFile,0,NULL,FILE_BEGIN);
+ WriteFile(hFile,&dbHeader,sizeof(dbHeader),&bytesWritten,NULL);
+ user.signature=DBCONTACT_SIGNATURE;
+ user.ofsNext=0;
+ user.ofsFirstSettings=0;
+ user.eventCount=0;
+ user.ofsFirstEvent=user.ofsLastEvent=0;
+ SetFilePointer(hFile,dbHeader.ofsUser,NULL,FILE_BEGIN);
+ WriteFile(hFile,&user,sizeof(struct DBContact),&bytesWritten,NULL);
+ FlushFileBuffers(hFile);
+ return 0;
+}
+
+int CheckDbHeaders(struct DBHeader * hdr)
+{
+ if(memcmp(hdr->signature,&dbSignature,sizeof(hdr->signature))) return 1;
+ if(hdr->version!=DB_THIS_VERSION) return 2;
+ if(hdr->ofsUser==0) return 3;
+ return 0;
+}
+
+int InitialiseDbHeaders(void)
+{
+ return 0;
+}
diff --git a/db3x_autobackups/dbmodulechain.c b/db3x_autobackups/dbmodulechain.c
new file mode 100644
index 0000000..352a06c
--- /dev/null
+++ b/db3x_autobackups/dbmodulechain.c
@@ -0,0 +1,132 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+#include "database.h"
+
+extern struct DBHeader dbHeader;
+
+static int EnumModuleNames(WPARAM wParam,LPARAM lParam);
+
+struct ModuleName {
+ char *name;
+ DWORD hash;
+ DWORD ofs;
+};
+static struct ModuleName *moduleName;
+static int moduleNameCount;
+
+int InitModuleNames(void)
+{
+ struct DBModuleName *dbmn;
+ DWORD ofsThis,ofsNext;
+ int nameLen;
+
+ moduleNameCount=0;
+ moduleName=NULL;
+ ofsThis=dbHeader.ofsFirstModuleName;
+ dbmn=(struct DBModuleName*)DBRead(ofsThis,sizeof(struct DBModuleName),NULL);
+ while(ofsThis) {
+ if(dbmn->signature!=DBMODULENAME_SIGNATURE) DatabaseCorruption();
+ moduleName=(struct ModuleName*)mir_realloc(moduleName,sizeof(struct ModuleName)*(moduleNameCount+1));
+ moduleName[moduleNameCount].ofs=ofsThis;
+ moduleName[moduleNameCount].hash=dbmn->cbName; //very very simple hash so far
+ moduleName[moduleNameCount].name=(char*)mir_alloc(dbmn->cbName+1);
+ ofsNext=dbmn->ofsNext;
+ nameLen=dbmn->cbName;
+ CopyMemory(moduleName[moduleNameCount].name,DBRead(ofsThis+offsetof(struct DBModuleName,name),nameLen,NULL),nameLen);
+ moduleName[moduleNameCount].name[nameLen]=0;
+ moduleNameCount++;
+ ofsThis=ofsNext;
+ dbmn=(struct DBModuleName*)DBRead(ofsThis,sizeof(struct DBModuleName),NULL);
+ }
+ CreateServiceFunction(MS_DB_MODULES_ENUM,EnumModuleNames);
+ return 0;
+}
+
+void UninitModuleNames(void)
+{
+ int i;
+ for(i=0;i<moduleNameCount;i++) mir_free(moduleName[i].name);
+ if(moduleNameCount) mir_free(moduleName);
+}
+
+static DWORD FindExistingModuleNameOfs(const char *szName,int nameLen)
+{
+ int i;
+ for(i=0;i<moduleNameCount;i++)
+ if(moduleName[i].hash==(DWORD)nameLen && !strcmp(moduleName[i].name,szName)) return moduleName[i].ofs;
+ return 0;
+}
+
+//will create the offset if it needs to
+DWORD GetModuleNameOfs(const char *szName)
+{
+ struct DBModuleName dbmn;
+ int nameLen=strlen(szName);
+ DWORD ofsNew,ofsExisting;
+
+ ofsExisting=FindExistingModuleNameOfs(szName,nameLen);
+ if(ofsExisting) return ofsExisting;
+ //need to create the module name
+ ofsNew=CreateNewSpace(nameLen+offsetof(struct DBModuleName,name));
+ dbmn.signature=DBMODULENAME_SIGNATURE;
+ dbmn.cbName=nameLen;
+ dbmn.ofsNext=dbHeader.ofsFirstModuleName;
+ dbHeader.ofsFirstModuleName=ofsNew;
+ DBWrite(0,&dbHeader,sizeof(dbHeader));
+ DBWrite(ofsNew,&dbmn,offsetof(struct DBModuleName,name));
+ DBWrite(ofsNew+offsetof(struct DBModuleName,name),(PVOID)szName,nameLen);
+ DBFlush(0);
+ //add to cache
+ moduleName=(struct ModuleName*)mir_realloc(moduleName,sizeof(struct ModuleName)*(moduleNameCount+1));
+ moduleName[moduleNameCount].ofs=ofsNew;
+ moduleName[moduleNameCount].hash=nameLen; //very very simple hash so far
+ moduleName[moduleNameCount].name=(char*)mir_alloc(nameLen+1);
+ strcpy(moduleName[moduleNameCount].name,szName);
+ moduleNameCount++;
+ //quit
+ return ofsNew;
+}
+
+//it's OK that this is a bit slow - it's rarely used
+char *GetModuleNameByOfs(DWORD ofs)
+{
+ int i;
+
+ for(i=0;i<moduleNameCount;i++)
+ if(moduleName[i].ofs==ofs) return moduleName[i].name;
+ DatabaseCorruption();
+ return NULL;
+}
+
+static int EnumModuleNames(WPARAM wParam,LPARAM lParam)
+{
+ int i;
+ int ret;
+ for(i=0;i<moduleNameCount;i++) {
+ ret=((DBMODULEENUMPROC)lParam)(moduleName[i].name,moduleName[i].ofs,wParam);
+ if(ret) return ret;
+ }
+ return 0;
+}
diff --git a/db3x_autobackups/dbsettings.c b/db3x_autobackups/dbsettings.c
new file mode 100644
index 0000000..3c40277
--- /dev/null
+++ b/db3x_autobackups/dbsettings.c
@@ -0,0 +1,957 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+
+#include "database.h"
+
+DWORD GetModuleNameOfs(const char *szName);
+
+extern CRITICAL_SECTION csDbAccess;
+extern struct DBHeader dbHeader;
+
+HANDLE hCacheHeap = NULL;
+SortedList lContacts;
+
+static SortedList lSettings, lGlobalSettings;
+static HANDLE hSettingChangeEvent = NULL;
+
+#define SETTINGSGROUPOFSCOUNT 32
+struct SettingsGroupOfsCacheEntry {
+ DWORD ofsContact;
+ DWORD ofsModuleName;
+ DWORD ofsSettingsGroup;
+};
+static struct SettingsGroupOfsCacheEntry settingsGroupOfsCache[SETTINGSGROUPOFSCOUNT];
+static int nextSGOCacheEntry;
+
+//this function caches results
+static DWORD GetSettingsGroupOfsByModuleNameOfs(struct DBContact *dbc,DWORD ofsContact,DWORD ofsModuleName)
+{
+ struct DBContactSettings *dbcs;
+ DWORD ofsThis;
+ int i;
+
+ for(i=0;i<SETTINGSGROUPOFSCOUNT;i++) {
+ if(settingsGroupOfsCache[i].ofsContact==ofsContact && settingsGroupOfsCache[i].ofsModuleName==ofsModuleName)
+ return settingsGroupOfsCache[i].ofsSettingsGroup;
+ }
+ ofsThis=dbc->ofsFirstSettings;
+ while(ofsThis) {
+ dbcs=(struct DBContactSettings*)DBRead(ofsThis,sizeof(struct DBContactSettings),NULL);
+ if(dbcs->signature!=DBCONTACTSETTINGS_SIGNATURE) DatabaseCorruption();
+ if(dbcs->ofsModuleName==ofsModuleName) {
+ settingsGroupOfsCache[nextSGOCacheEntry].ofsContact=ofsContact;
+ settingsGroupOfsCache[nextSGOCacheEntry].ofsModuleName=ofsModuleName;
+ settingsGroupOfsCache[nextSGOCacheEntry].ofsSettingsGroup=ofsThis;
+ if(++nextSGOCacheEntry==SETTINGSGROUPOFSCOUNT) nextSGOCacheEntry=0;
+ return ofsThis;
+ }
+ ofsThis=dbcs->ofsNext;
+ }
+ return 0;
+}
+
+static void InvalidateSettingsGroupOfsCacheEntry(DWORD ofsSettingsGroup)
+{
+ int i;
+
+ for(i=0;i<SETTINGSGROUPOFSCOUNT;i++) {
+ if(settingsGroupOfsCache[i].ofsSettingsGroup==ofsSettingsGroup) {
+ settingsGroupOfsCache[i].ofsContact=0;
+ settingsGroupOfsCache[i].ofsModuleName=0;
+ settingsGroupOfsCache[i].ofsSettingsGroup=0;
+ break;
+} } }
+
+static DWORD __inline GetSettingValueLength(PBYTE pSetting)
+{
+ if(pSetting[0]&DBVTF_VARIABLELENGTH) return 2+*(PWORD)(pSetting+1);
+ return pSetting[0];
+}
+
+static char* InsertCachedSetting( const char* szName, size_t cbNameLen, int index )
+{
+ char* newValue = (char*)HeapAlloc( hCacheHeap, HEAP_NO_SERIALIZE, cbNameLen );
+ *newValue = 0;
+ strcpy(newValue+1,szName+1);
+ li.List_Insert(&lSettings,newValue,index);
+ return newValue;
+}
+
+static char* GetCachedSetting(const char *szModuleName,const char *szSettingName,int settingNameLen)
+{
+ int moduleNameLen = strlen(szModuleName),index;
+ char *szFullName = (char*)alloca(moduleNameLen+settingNameLen+3);
+
+ strcpy(szFullName+1,szModuleName);
+ szFullName[moduleNameLen+1]='/';
+ strcpy(szFullName+moduleNameLen+2,szSettingName);
+
+ if ( li.List_GetIndex(&lSettings, szFullName, &index))
+ return((char*)lSettings.items[index] + 1);
+
+ return InsertCachedSetting( szFullName, moduleNameLen+settingNameLen+3, index )+1;
+}
+
+static void SetCachedVariant( DBVARIANT* s /* new */, DBVARIANT* d /* cached */ )
+{
+ char* szSave = ( d->type == DBVT_UTF8 || d->type == DBVT_ASCIIZ ) ? d->pszVal : NULL;
+
+ memcpy( d, s, sizeof( DBVARIANT ));
+ if (( s->type == DBVT_UTF8 || s->type == DBVT_ASCIIZ ) && s->pszVal != NULL ) {
+ if ( szSave != NULL )
+ d->pszVal = (char*)HeapReAlloc(hCacheHeap,HEAP_NO_SERIALIZE,szSave,strlen(s->pszVal)+1);
+ else
+ d->pszVal = (char*)HeapAlloc(hCacheHeap,HEAP_NO_SERIALIZE,strlen(s->pszVal)+1);
+ strcpy(d->pszVal,s->pszVal);
+ }
+
+ switch( d->type ) {
+ case DBVT_BYTE: log1( "set cached byte: %d", d->bVal ); break;
+ case DBVT_WORD: log1( "set cached word: %d", d->wVal ); break;
+ case DBVT_DWORD: log1( "set cached dword: %d", d->dVal ); break;
+ case DBVT_UTF8:
+ case DBVT_ASCIIZ: log1( "set cached string: '%s'", d->pszVal ); break;
+ default: log1( "set cached crap: %d", d->type ); break;
+} }
+
+static void FreeCachedVariant( DBVARIANT* V )
+{
+ if (( V->type == DBVT_ASCIIZ || V->type == DBVT_UTF8 ) && V->pszVal != NULL )
+ HeapFree(hCacheHeap,HEAP_NO_SERIALIZE,V->pszVal);
+}
+
+static DBVARIANT* GetCachedValuePtr( HANDLE hContact, char* szSetting, int bAllocate )
+{
+ int index;
+
+ if ( hContact == 0 ) {
+ DBCachedGlobalValue Vtemp, *V;
+ Vtemp.name = szSetting;
+ if ( li.List_GetIndex(&lGlobalSettings,&Vtemp,&index)) {
+ V = (DBCachedGlobalValue*)lGlobalSettings.items[index];
+ if ( bAllocate == -1 ) {
+ FreeCachedVariant( &V->value );
+ li.List_Remove(&lGlobalSettings,index);
+ HeapFree(hCacheHeap,HEAP_NO_SERIALIZE,V);
+ return NULL;
+ } }
+ else {
+ if ( bAllocate != 1 )
+ return NULL;
+
+ V = (DBCachedGlobalValue*)HeapAlloc(hCacheHeap,HEAP_NO_SERIALIZE+HEAP_ZERO_MEMORY,sizeof(DBCachedGlobalValue));
+ V->name = szSetting;
+ li.List_Insert(&lGlobalSettings,V,index);
+ }
+
+ return &V->value;
+ }
+ else {
+ DBCachedContactValue *V, *V1;
+ DBCachedContactValueList VLtemp,*VL;
+
+ VLtemp.hContact=hContact;
+ if ( li.List_GetIndex(&lContacts,&VLtemp,&index)) {
+ VL = (DBCachedContactValueList*)lContacts.items[index];
+ }
+ else {
+ if ( bAllocate == -1 )
+ return NULL;
+
+ VL = (DBCachedContactValueList*)HeapAlloc(hCacheHeap,HEAP_NO_SERIALIZE+HEAP_ZERO_MEMORY,sizeof(DBCachedContactValueList));
+ VL->hContact = hContact;
+ li.List_Insert(&lContacts,VL,index);
+ }
+
+ for ( V = VL->first; V != NULL; V = V->next)
+ if (strcmp(V->name,szSetting)==0)
+ break;
+
+ if ( V == NULL )
+ { if ( bAllocate != 1 )
+ return NULL;
+
+ V = HeapAlloc(hCacheHeap,HEAP_NO_SERIALIZE+HEAP_ZERO_MEMORY,sizeof(DBCachedContactValue));
+ V->next = VL->first;
+ VL->first = V;
+ V->name = szSetting;
+ }
+ else if ( bAllocate == -1 ) {
+ FreeCachedVariant(&V->value);
+ if ( VL->first == V )
+ VL->first = V->next;
+ for ( V1=VL->first; V1 != NULL; V1 = V1->next )
+ if ( V1->next == V ) {
+ V1->next = V->next;
+ break;
+ }
+ HeapFree(hCacheHeap,HEAP_NO_SERIALIZE,V);
+ return NULL;
+ }
+
+ return &V->value;
+} }
+
+#define NeedBytes(n) if(bytesRemaining<(n)) pBlob=(PBYTE)DBRead(ofsBlobPtr,(n),&bytesRemaining)
+#define MoveAlong(n) {int x=n; pBlob+=(x); ofsBlobPtr+=(x); bytesRemaining-=(x);}
+#define VLT(n) ((n==DBVT_UTF8)?DBVT_ASCIIZ:n)
+static __inline int GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs,int isStatic)
+{
+ struct DBContact dbc;
+ struct DBContactSettings dbcs;
+ DWORD ofsModuleName,ofsContact,ofsSettingsGroup,ofsBlobPtr;
+ int settingNameLen;
+ int bytesRemaining;
+ PBYTE pBlob;
+ char* szCachedSettingName;
+
+ if ((!dbcgs->szSetting) || (!dbcgs->szModule))
+ return 1;
+ settingNameLen=strlen(dbcgs->szSetting);
+
+ EnterCriticalSection(&csDbAccess);
+
+ log3("get [%08p] %s/%s",hContact,dbcgs->szModule,dbcgs->szSetting);
+
+ szCachedSettingName = GetCachedSetting(dbcgs->szModule,dbcgs->szSetting,settingNameLen);
+ {
+ DBVARIANT* pCachedValue = GetCachedValuePtr( hContact, szCachedSettingName, 0 );
+ if ( pCachedValue != NULL ) {
+ if ( pCachedValue->type == DBVT_ASCIIZ || pCachedValue->type == DBVT_UTF8 ) {
+ int cbOrigLen = dbcgs->pValue->cchVal;
+ char* cbOrigPtr = dbcgs->pValue->pszVal;
+ memcpy( dbcgs->pValue, pCachedValue, sizeof( DBVARIANT ));
+ if ( isStatic ) {
+ int cbLen = 0;
+ if ( pCachedValue->pszVal != NULL )
+ cbLen = strlen( pCachedValue->pszVal );
+
+ cbOrigLen--;
+ dbcgs->pValue->pszVal = cbOrigPtr;
+ if(cbLen<cbOrigLen) cbOrigLen=cbLen;
+ CopyMemory(dbcgs->pValue->pszVal,pCachedValue->pszVal,cbOrigLen);
+ dbcgs->pValue->pszVal[cbOrigLen]=0;
+ dbcgs->pValue->cchVal=cbLen;
+ }
+ else {
+ dbcgs->pValue->pszVal = (char*)mir_alloc(strlen(pCachedValue->pszVal)+1);
+ strcpy(dbcgs->pValue->pszVal,pCachedValue->pszVal);
+ }
+ }
+ else
+ memcpy( dbcgs->pValue, pCachedValue, sizeof( DBVARIANT ));
+
+ switch( dbcgs->pValue->type ) {
+ case DBVT_BYTE: log1( "get cached byte: %d", dbcgs->pValue->bVal ); break;
+ case DBVT_WORD: log1( "get cached word: %d", dbcgs->pValue->wVal ); break;
+ case DBVT_DWORD: log1( "get cached dword: %d", dbcgs->pValue->dVal ); break;
+ case DBVT_UTF8:
+ case DBVT_ASCIIZ: log1( "get cached string: '%s'", dbcgs->pValue->pszVal); break;
+ default: log1( "get cached crap: %d", dbcgs->pValue->type ); break;
+ }
+
+ LeaveCriticalSection(&csDbAccess);
+ return ( pCachedValue->type == DBVT_DELETED ) ? 1 : 0;
+ } }
+
+ ofsModuleName=GetModuleNameOfs(dbcgs->szModule);
+ if(hContact==NULL) ofsContact=dbHeader.ofsUser;
+ else ofsContact=(DWORD)hContact;
+ dbc=*(struct DBContact*)DBRead(ofsContact,sizeof(struct DBContact),NULL);
+ if(dbc.signature!=DBCONTACT_SIGNATURE) {
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ ofsSettingsGroup=GetSettingsGroupOfsByModuleNameOfs(&dbc,ofsContact,ofsModuleName);
+ if(ofsSettingsGroup) {
+ dbcs=*(struct DBContactSettings*)DBRead(ofsSettingsGroup,sizeof(struct DBContactSettings),&bytesRemaining);
+ ofsBlobPtr=ofsSettingsGroup+offsetof(struct DBContactSettings,blob);
+ pBlob=(PBYTE)DBRead(ofsBlobPtr,1,&bytesRemaining);
+ while(pBlob[0]) {
+ NeedBytes(1+settingNameLen);
+ if(pBlob[0]==settingNameLen && !memcmp(pBlob+1,dbcgs->szSetting,settingNameLen)) {
+ MoveAlong(1+settingNameLen);
+ NeedBytes(5);
+ if(isStatic && pBlob[0]&DBVTF_VARIABLELENGTH && VLT(dbcgs->pValue->type) != VLT(pBlob[0])) {
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ dbcgs->pValue->type=pBlob[0];
+ switch(pBlob[0]) {
+ case DBVT_DELETED: { /* this setting is deleted */
+ dbcgs->pValue->type=DBVT_DELETED;
+ LeaveCriticalSection(&csDbAccess);
+ return 2;
+ }
+ case DBVT_BYTE: dbcgs->pValue->bVal=pBlob[1]; break;
+ case DBVT_WORD: dbcgs->pValue->wVal=*(PWORD)(pBlob+1); break;
+ case DBVT_DWORD: dbcgs->pValue->dVal=*(PDWORD)(pBlob+1); break;
+ case DBVT_UTF8:
+ case DBVT_ASCIIZ:
+ NeedBytes(3+*(PWORD)(pBlob+1));
+ if(isStatic) {
+ dbcgs->pValue->cchVal--;
+ if(*(PWORD)(pBlob+1)<dbcgs->pValue->cchVal) dbcgs->pValue->cchVal=*(PWORD)(pBlob+1);
+ CopyMemory(dbcgs->pValue->pszVal,pBlob+3,dbcgs->pValue->cchVal);
+ dbcgs->pValue->pszVal[dbcgs->pValue->cchVal]=0;
+ dbcgs->pValue->cchVal=*(PWORD)(pBlob+1);
+ }
+ else {
+ dbcgs->pValue->pszVal=(char*)mir_alloc(1+*(PWORD)(pBlob+1));
+ CopyMemory(dbcgs->pValue->pszVal,pBlob+3,*(PWORD)(pBlob+1));
+ dbcgs->pValue->pszVal[*(PWORD)(pBlob+1)]=0;
+ }
+ break;
+ case DBVT_BLOB:
+ NeedBytes(3+*(PWORD)(pBlob+1));
+ if(isStatic) {
+ if(*(PWORD)(pBlob+1)<dbcgs->pValue->cpbVal) dbcgs->pValue->cpbVal=*(PWORD)(pBlob+1);
+ CopyMemory(dbcgs->pValue->pbVal,pBlob+3,dbcgs->pValue->cchVal);
+ }
+ else {
+ dbcgs->pValue->pbVal=(char*)mir_alloc(*(PWORD)(pBlob+1));
+ CopyMemory(dbcgs->pValue->pbVal,pBlob+3,*(PWORD)(pBlob+1));
+ }
+ dbcgs->pValue->cpbVal=*(PWORD)(pBlob+1);
+ break;
+ }
+
+ /**** add to cache **********************/
+ if ( dbcgs->pValue->type != DBVT_BLOB )
+ {
+ DBVARIANT* pCachedValue = GetCachedValuePtr( hContact, szCachedSettingName, 1 );
+ if ( pCachedValue != NULL )
+ SetCachedVariant(dbcgs->pValue,pCachedValue);
+ }
+
+ LeaveCriticalSection(&csDbAccess);
+ logg();
+ return 0;
+ }
+ NeedBytes(1);
+ MoveAlong(pBlob[0]+1);
+ NeedBytes(3);
+ MoveAlong(1+GetSettingValueLength(pBlob));
+ NeedBytes(1);
+ } }
+
+ /**** add missing setting to cache **********************/
+ if ( dbcgs->pValue->type != DBVT_BLOB )
+ {
+ DBVARIANT* pCachedValue = GetCachedValuePtr( hContact, szCachedSettingName, 1 );
+ if ( pCachedValue != NULL )
+ pCachedValue->type = DBVT_DELETED;
+ }
+
+ LeaveCriticalSection(&csDbAccess);
+ logg();
+ return 1;
+}
+
+static int GetContactSetting(WPARAM wParam,LPARAM lParam)
+{
+ DBCONTACTGETSETTING* dgs = ( DBCONTACTGETSETTING* )lParam;
+ dgs->pValue->type = 0;
+ if ( GetContactSettingWorker(( HANDLE )wParam, dgs, 0 ))
+ return 1;
+
+ if ( dgs->pValue->type == DBVT_UTF8 ) {
+ mir_utf8decode( dgs->pValue->pszVal, NULL );
+ dgs->pValue->type = DBVT_ASCIIZ;
+ }
+
+ return 0;
+}
+
+static int GetContactSettingStr(WPARAM wParam,LPARAM lParam)
+{
+ DBCONTACTGETSETTING* dgs = (DBCONTACTGETSETTING*)lParam;
+ int iSaveType = dgs->pValue->type;
+
+ if ( GetContactSettingWorker(( HANDLE )wParam, dgs, 0 ))
+ return 1;
+
+ if ( iSaveType == 0 || iSaveType == dgs->pValue->type )
+ return 0;
+
+ if ( dgs->pValue->type != DBVT_ASCIIZ && dgs->pValue->type != DBVT_UTF8 )
+ return 0;
+
+ if ( iSaveType == DBVT_WCHAR ) {
+ if ( dgs->pValue->type != DBVT_UTF8 ) {
+ int len = MultiByteToWideChar( CP_ACP, 0, dgs->pValue->pszVal, -1, NULL, 0 );
+ wchar_t* wszResult = ( wchar_t* )mir_alloc(( len+1 )*sizeof( wchar_t ));
+ if ( wszResult == NULL )
+ return 1;
+
+ MultiByteToWideChar( CP_ACP, 0, dgs->pValue->pszVal, -1, wszResult, len );
+ wszResult[ len ] = 0;
+ mir_free( dgs->pValue->pszVal );
+ dgs->pValue->pwszVal = wszResult;
+ }
+ else {
+ char* savePtr = dgs->pValue->pszVal;
+ mir_utf8decode( dgs->pValue->pszVal, &dgs->pValue->pwszVal );
+ mir_free( savePtr );
+ }
+ }
+ else if ( iSaveType == DBVT_UTF8 ) {
+ char* tmpBuf = mir_utf8encode( dgs->pValue->pszVal );
+ if ( tmpBuf == NULL )
+ return 1;
+
+ mir_free( dgs->pValue->pszVal );
+ dgs->pValue->pszVal = tmpBuf;
+ }
+ else if ( iSaveType == DBVT_ASCIIZ )
+ mir_utf8decode( dgs->pValue->pszVal, NULL );
+
+ dgs->pValue->type = iSaveType;
+ return 0;
+}
+
+static int GetContactSettingStatic(WPARAM wParam,LPARAM lParam)
+{
+ DBCONTACTGETSETTING* dgs = (DBCONTACTGETSETTING*)lParam;
+ if ( GetContactSettingWorker(( HANDLE )wParam, dgs, 1 ))
+ return 1;
+
+ if ( dgs->pValue->type == DBVT_UTF8 ) {
+ mir_utf8decode( dgs->pValue->pszVal, NULL );
+ dgs->pValue->type = DBVT_ASCIIZ;
+ }
+
+ return 0;
+}
+
+static int FreeVariant(WPARAM wParam,LPARAM lParam)
+{
+ DBVARIANT *dbv=(DBVARIANT*)lParam;
+ if ( dbv == 0 ) return 1;
+ switch ( dbv->type ) {
+ case DBVT_ASCIIZ:
+ case DBVT_UTF8:
+ case DBVT_WCHAR:
+ {
+ if ( dbv->pszVal ) mir_free(dbv->pszVal);
+ dbv->pszVal=0;
+ break;
+ }
+ case DBVT_BLOB:
+ {
+ if ( dbv->pbVal ) mir_free(dbv->pbVal);
+ dbv->pbVal=0;
+ break;
+ }
+ }
+ dbv->type=0;
+ return 0;
+}
+
+static int SetSettingResident(WPARAM wParam,LPARAM lParam)
+{
+ char* szSetting;
+ size_t cbSettingNameLen = strlen(( char* )lParam );
+ int idx;
+ char* szTemp = ( char* )alloca( cbSettingNameLen+2 );
+ strcpy( szTemp+1, ( char* )lParam );
+
+ EnterCriticalSection(&csDbAccess);
+ if ( !li.List_GetIndex( &lSettings, szTemp, &idx ))
+ szSetting = InsertCachedSetting( szTemp, cbSettingNameLen+2, idx );
+ else
+ szSetting = lSettings.items[ idx ];
+
+ *szSetting = (char)wParam;
+
+ LeaveCriticalSection(&csDbAccess);
+ return 0;
+}
+
+static int WriteContactSetting(WPARAM wParam,LPARAM lParam)
+{
+ DBCONTACTWRITESETTING *dbcws=(DBCONTACTWRITESETTING*)lParam;
+ struct DBContact dbc;
+ DWORD ofsModuleName;
+ struct DBContactSettings dbcs;
+ PBYTE pBlob;
+ int settingNameLen=0;
+ int moduleNameLen=0;
+ int settingDataLen=0;
+
+ int bytesRequired,bytesRemaining;
+ DWORD ofsContact,ofsSettingsGroup,ofsBlobPtr;
+
+ if (dbcws == NULL)
+ return 1;
+
+ if (dbcws->value.type == DBVT_WCHAR) {
+ if (dbcws->value.pszVal != NULL) {
+ char* val = mir_utf8encodeW(dbcws->value.pwszVal);
+ if ( val == NULL )
+ return 1;
+
+ dbcws->value.pszVal = ( char* )alloca( strlen( val )+1 );
+ strcpy( dbcws->value.pszVal, val );
+ mir_free(val);
+ dbcws->value.type = DBVT_UTF8;
+ }
+ else return 1;
+ }
+
+ if(dbcws->value.type!=DBVT_BYTE && dbcws->value.type!=DBVT_WORD && dbcws->value.type!=DBVT_DWORD && dbcws->value.type!=DBVT_ASCIIZ && dbcws->value.type!=DBVT_UTF8 && dbcws->value.type!=DBVT_BLOB)
+ return 1;
+ if ((!dbcws->szModule) || (!dbcws->szSetting) || ((dbcws->value.type == DBVT_ASCIIZ || dbcws->value.type == DBVT_UTF8 )&& dbcws->value.pszVal == NULL) || (dbcws->value.type == DBVT_BLOB && dbcws->value.pbVal == NULL) )
+ return 1;
+ // the db format can't tolerate more than 255 bytes of space (incl. null) for settings+module name
+ settingNameLen=strlen(dbcws->szSetting);
+ moduleNameLen=strlen(dbcws->szModule);
+ if ( settingNameLen > 0xFE )
+ {
+ #ifdef _DEBUG
+ OutputDebugString("WriteContactSetting() got a > 255 setting name length. \n");
+ #endif
+ return 1;
+ }
+ if ( moduleNameLen > 0xFE )
+ {
+ #ifdef _DEBUG
+ OutputDebugString("WriteContactSetting() got a > 255 module name length. \n");
+ #endif
+ return 1;
+ }
+
+ // the db can not tolerate strings/blobs longer than 0xFFFF since the format writes 2 lengths
+ switch( dbcws->value.type ) {
+ case DBVT_ASCIIZ: case DBVT_BLOB: case DBVT_UTF8:
+ { int len = ( dbcws->value.type != DBVT_BLOB ) ? strlen(dbcws->value.pszVal) : dbcws->value.cpbVal;
+ if ( len >= 0xFFFF ) {
+ #ifdef _DEBUG
+ OutputDebugString("WriteContactSetting() writing huge string/blob, rejecting ( >= 0xFFFF ) \n");
+ #endif
+ return 1;
+ }
+ }
+ }
+
+ EnterCriticalSection(&csDbAccess);
+ {
+ char* szCachedSettingName = GetCachedSetting(dbcws->szModule, dbcws->szSetting, settingNameLen);
+ if ( dbcws->value.type != DBVT_BLOB ) {
+ DBVARIANT* pCachedValue = GetCachedValuePtr((HANDLE)wParam, szCachedSettingName, 1);
+ if ( pCachedValue != NULL ) {
+ BOOL bIsIdentical = FALSE;
+ if ( pCachedValue->type == dbcws->value.type ) {
+ switch(dbcws->value.type) {
+ case DBVT_BYTE: bIsIdentical = pCachedValue->bVal == dbcws->value.bVal; break;
+ case DBVT_WORD: bIsIdentical = pCachedValue->wVal == dbcws->value.wVal; break;
+ case DBVT_DWORD: bIsIdentical = pCachedValue->dVal == dbcws->value.dVal; break;
+ case DBVT_UTF8:
+ case DBVT_ASCIIZ: bIsIdentical = strcmp( pCachedValue->pszVal, dbcws->value.pszVal ) == 0; break;
+ }
+ if ( bIsIdentical ) {
+ LeaveCriticalSection(&csDbAccess);
+ return 0;
+ }
+ }
+ SetCachedVariant(&dbcws->value, pCachedValue);
+ }
+ if ( szCachedSettingName[-1] != 0 ) {
+ LeaveCriticalSection(&csDbAccess);
+ NotifyEventHooks(hSettingChangeEvent,wParam,lParam);
+ return 0;
+ }
+ }
+ else GetCachedValuePtr((HANDLE)wParam, szCachedSettingName, -1);
+ }
+
+ ofsModuleName=GetModuleNameOfs(dbcws->szModule);
+ if(wParam==0) ofsContact=dbHeader.ofsUser;
+ else ofsContact=wParam;
+
+ dbc=*(struct DBContact*)DBRead(ofsContact,sizeof(struct DBContact),NULL);
+ if(dbc.signature!=DBCONTACT_SIGNATURE) {
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ log0("write setting");
+ //make sure the module group exists
+ ofsSettingsGroup=GetSettingsGroupOfsByModuleNameOfs(&dbc,ofsContact,ofsModuleName);
+ if(ofsSettingsGroup==0) { //module group didn't exist - make it
+ if(dbcws->value.type&DBVTF_VARIABLELENGTH) {
+ if(dbcws->value.type==DBVT_ASCIIZ || dbcws->value.type==DBVT_UTF8) bytesRequired=strlen(dbcws->value.pszVal)+2;
+ else if(dbcws->value.type==DBVT_BLOB) bytesRequired=dbcws->value.cpbVal+2;
+ }
+ else bytesRequired=dbcws->value.type;
+ bytesRequired+=2+settingNameLen;
+ bytesRequired+=(DB_SETTINGS_RESIZE_GRANULARITY-(bytesRequired%DB_SETTINGS_RESIZE_GRANULARITY))%DB_SETTINGS_RESIZE_GRANULARITY;
+ ofsSettingsGroup=CreateNewSpace(bytesRequired+offsetof(struct DBContactSettings,blob));
+ dbcs.signature=DBCONTACTSETTINGS_SIGNATURE;
+ dbcs.ofsNext=dbc.ofsFirstSettings;
+ dbcs.ofsModuleName=ofsModuleName;
+ dbcs.cbBlob=bytesRequired;
+ dbcs.blob[0]=0;
+ dbc.ofsFirstSettings=ofsSettingsGroup;
+ DBWrite(ofsContact,&dbc,sizeof(struct DBContact));
+ DBWrite(ofsSettingsGroup,&dbcs,sizeof(struct DBContactSettings));
+ ofsBlobPtr=ofsSettingsGroup+offsetof(struct DBContactSettings,blob);
+ pBlob=(PBYTE)DBRead(ofsBlobPtr,1,&bytesRemaining);
+ }
+ else {
+ dbcs=*(struct DBContactSettings*)DBRead(ofsSettingsGroup,sizeof(struct DBContactSettings),&bytesRemaining);
+ //find if the setting exists
+ ofsBlobPtr=ofsSettingsGroup+offsetof(struct DBContactSettings,blob);
+ pBlob=(PBYTE)DBRead(ofsBlobPtr,1,&bytesRemaining);
+ while(pBlob[0]) {
+ NeedBytes(settingNameLen+1);
+ if(pBlob[0]==settingNameLen && !memcmp(pBlob+1,dbcws->szSetting,settingNameLen))
+ break;
+ NeedBytes(1);
+ MoveAlong(pBlob[0]+1);
+ NeedBytes(3);
+ MoveAlong(1+GetSettingValueLength(pBlob));
+ NeedBytes(1);
+ }
+ if(pBlob[0]) { //setting already existed, and up to end of name is in cache
+ MoveAlong(1+settingNameLen);
+ //if different type or variable length and length is different
+ NeedBytes(3);
+ if(pBlob[0]!=dbcws->value.type || ((pBlob[0]==DBVT_ASCIIZ || pBlob[0]==DBVT_UTF8) && *(PWORD)(pBlob+1)!=strlen(dbcws->value.pszVal)) || (pBlob[0]==DBVT_BLOB && *(PWORD)(pBlob+1)!=dbcws->value.cpbVal)) {
+ //bin it
+ int nameLen,valLen;
+ DWORD ofsSettingToCut;
+ NeedBytes(3);
+ nameLen=1+settingNameLen;
+ valLen=1+GetSettingValueLength(pBlob);
+ ofsSettingToCut=ofsBlobPtr-nameLen;
+ MoveAlong(valLen);
+ NeedBytes(1);
+ while(pBlob[0]) {
+ MoveAlong(pBlob[0]+1);
+ NeedBytes(3);
+ MoveAlong(1+GetSettingValueLength(pBlob));
+ NeedBytes(1);
+ }
+ DBMoveChunk(ofsSettingToCut,ofsSettingToCut+nameLen+valLen,ofsBlobPtr+1-ofsSettingToCut);
+ ofsBlobPtr-=nameLen+valLen;
+ pBlob=(PBYTE)DBRead(ofsBlobPtr,1,&bytesRemaining);
+ }
+ else {
+ //replace existing setting at pBlob
+ MoveAlong(1); //skip data type
+ switch(dbcws->value.type) {
+ case DBVT_BYTE: DBWrite(ofsBlobPtr,&dbcws->value.bVal,1); break;
+ case DBVT_WORD: DBWrite(ofsBlobPtr,&dbcws->value.wVal,2); break;
+ case DBVT_DWORD: DBWrite(ofsBlobPtr,&dbcws->value.dVal,4); break;
+ case DBVT_UTF8:
+ case DBVT_ASCIIZ: DBWrite(ofsBlobPtr+2,dbcws->value.pszVal,strlen(dbcws->value.pszVal)); break;
+ case DBVT_BLOB: DBWrite(ofsBlobPtr+2,dbcws->value.pbVal,dbcws->value.cpbVal); break;
+ }
+ //quit
+ DBFlush(1);
+ LeaveCriticalSection(&csDbAccess);
+ //notify
+ NotifyEventHooks(hSettingChangeEvent,wParam,lParam);
+ return 0;
+ }
+ }
+ }
+ //cannot do a simple replace, add setting to end of list
+ //pBlob already points to end of list
+ //see if it fits
+ if(dbcws->value.type&DBVTF_VARIABLELENGTH) {
+ if(dbcws->value.type==DBVT_ASCIIZ || dbcws->value.type==DBVT_UTF8) bytesRequired=strlen(dbcws->value.pszVal)+2;
+ else if(dbcws->value.type==DBVT_BLOB) bytesRequired=dbcws->value.cpbVal+2;
+ }
+ else bytesRequired=dbcws->value.type;
+ bytesRequired+=2+settingNameLen;
+ bytesRequired+=ofsBlobPtr+1-(ofsSettingsGroup+offsetof(struct DBContactSettings,blob));
+ if((DWORD)bytesRequired>dbcs.cbBlob) {
+ //doesn't fit: move entire group
+ struct DBContactSettings *dbcsPrev;
+ DWORD ofsDbcsPrev,oldSize,ofsNew;
+
+ InvalidateSettingsGroupOfsCacheEntry(ofsSettingsGroup);
+ bytesRequired+=(DB_SETTINGS_RESIZE_GRANULARITY-(bytesRequired%DB_SETTINGS_RESIZE_GRANULARITY))%DB_SETTINGS_RESIZE_GRANULARITY;
+ //find previous group to change its offset
+ ofsDbcsPrev=dbc.ofsFirstSettings;
+ if(ofsDbcsPrev==ofsSettingsGroup) ofsDbcsPrev=0;
+ else {
+ dbcsPrev=(struct DBContactSettings*)DBRead(ofsDbcsPrev,sizeof(struct DBContactSettings),NULL);
+ while(dbcsPrev->ofsNext!=ofsSettingsGroup) {
+ if(dbcsPrev->ofsNext==0) DatabaseCorruption();
+ ofsDbcsPrev=dbcsPrev->ofsNext;
+ dbcsPrev=(struct DBContactSettings*)DBRead(ofsDbcsPrev,sizeof(struct DBContactSettings),NULL);
+ }
+ }
+ //create the new one
+ ofsNew=CreateNewSpace(bytesRequired+offsetof(struct DBContactSettings,blob));
+ //copy across
+ DBMoveChunk(ofsNew,ofsSettingsGroup,bytesRequired+offsetof(struct DBContactSettings,blob));
+ oldSize=dbcs.cbBlob;
+ dbcs.cbBlob=bytesRequired;
+ DBWrite(ofsNew,&dbcs,offsetof(struct DBContactSettings,blob));
+ if(ofsDbcsPrev==0) {
+ dbc.ofsFirstSettings=ofsNew;
+ DBWrite(ofsContact,&dbc,sizeof(struct DBContact));
+ }
+ else {
+ dbcsPrev=(struct DBContactSettings*)DBRead(ofsDbcsPrev,sizeof(struct DBContactSettings),NULL);
+ dbcsPrev->ofsNext=ofsNew;
+ DBWrite(ofsDbcsPrev,dbcsPrev,offsetof(struct DBContactSettings,blob));
+ }
+ DeleteSpace(ofsSettingsGroup,oldSize+offsetof(struct DBContactSettings,blob));
+ ofsBlobPtr+=ofsNew-ofsSettingsGroup;
+ ofsSettingsGroup=ofsNew;
+ pBlob=(PBYTE)DBRead(ofsBlobPtr,1,&bytesRemaining);
+ }
+ //we now have a place to put it and enough space: make it
+ DBWrite(ofsBlobPtr,&settingNameLen,1);
+ DBWrite(ofsBlobPtr+1,(PVOID)dbcws->szSetting,settingNameLen);
+ MoveAlong(1+settingNameLen);
+ DBWrite(ofsBlobPtr,&dbcws->value.type,1);
+ MoveAlong(1);
+ switch(dbcws->value.type) {
+ case DBVT_BYTE: DBWrite(ofsBlobPtr,&dbcws->value.bVal,1); MoveAlong(1); break;
+ case DBVT_WORD: DBWrite(ofsBlobPtr,&dbcws->value.wVal,2); MoveAlong(2); break;
+ case DBVT_DWORD: DBWrite(ofsBlobPtr,&dbcws->value.dVal,4); MoveAlong(4); break;
+ case DBVT_UTF8:
+ case DBVT_ASCIIZ:
+ { int len=strlen(dbcws->value.pszVal);
+ DBWrite(ofsBlobPtr,&len,2);
+ DBWrite(ofsBlobPtr+2,dbcws->value.pszVal,len);
+ MoveAlong(2+len);
+ }
+ break;
+ case DBVT_BLOB:
+ DBWrite(ofsBlobPtr,&dbcws->value.cpbVal,2);
+ DBWrite(ofsBlobPtr+2,dbcws->value.pbVal,dbcws->value.cpbVal);
+ MoveAlong(2+dbcws->value.cpbVal);
+ break;
+ }
+ { BYTE zero=0;
+ DBWrite(ofsBlobPtr,&zero,1);
+ }
+ //quit
+ DBFlush(1);
+ LeaveCriticalSection(&csDbAccess);
+ //notify
+ NotifyEventHooks(hSettingChangeEvent,wParam,lParam);
+ return 0;
+}
+
+static int DeleteContactSetting(WPARAM wParam,LPARAM lParam)
+{
+ DBCONTACTGETSETTING *dbcgs=(DBCONTACTGETSETTING*)lParam;
+ struct DBContact *dbc;
+ DWORD ofsModuleName,ofsSettingsGroup,ofsBlobPtr;
+ struct DBContactSettings dbcs;
+ PBYTE pBlob;
+ int settingNameLen=strlen(dbcgs->szSetting),bytesRemaining;
+ char* szCachedSettingName;
+ WPARAM saveWparam = wParam;
+
+ if ((!dbcgs->szModule) || (!dbcgs->szSetting))
+ return 1;
+
+ EnterCriticalSection(&csDbAccess);
+ ofsModuleName=GetModuleNameOfs(dbcgs->szModule);
+ if(wParam==0) wParam=dbHeader.ofsUser;
+
+ dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
+ if(dbc->signature!=DBCONTACT_SIGNATURE) {
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ //make sure the module group exists
+ ofsSettingsGroup=GetSettingsGroupOfsByModuleNameOfs(dbc,wParam,ofsModuleName);
+ if(ofsSettingsGroup==0) {
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
+ if(dbc->signature!=DBCONTACT_SIGNATURE) {
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ ofsSettingsGroup=GetSettingsGroupOfsByModuleNameOfs(dbc,wParam,ofsModuleName);
+ if(ofsSettingsGroup==0) {
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ dbcs=*(struct DBContactSettings*)DBRead(ofsSettingsGroup,sizeof(struct DBContactSettings),NULL);
+ //find if the setting exists
+ ofsBlobPtr=ofsSettingsGroup+offsetof(struct DBContactSettings,blob);
+ pBlob=(PBYTE)DBRead(ofsBlobPtr,1,&bytesRemaining);
+ while(pBlob[0]) {
+ NeedBytes(settingNameLen+1);
+ if(pBlob[0]==settingNameLen && !memcmp(pBlob+1,dbcgs->szSetting,settingNameLen))
+ break;
+ NeedBytes(1);
+ MoveAlong(pBlob[0]+1);
+ NeedBytes(3);
+ MoveAlong(1+GetSettingValueLength(pBlob));
+ NeedBytes(1);
+ }
+ if(!pBlob[0]) { //setting didn't exist
+ LeaveCriticalSection(&csDbAccess);
+ return 1;
+ }
+ { //bin it
+ int nameLen,valLen;
+ DWORD ofsSettingToCut;
+ MoveAlong(1+settingNameLen);
+ NeedBytes(3);
+ nameLen=1+settingNameLen;
+ valLen=1+GetSettingValueLength(pBlob);
+ ofsSettingToCut=ofsBlobPtr-nameLen;
+ MoveAlong(valLen);
+ NeedBytes(1);
+ while(pBlob[0]) {
+ MoveAlong(pBlob[0]+1);
+ NeedBytes(3);
+ MoveAlong(1+GetSettingValueLength(pBlob));
+ NeedBytes(1);
+ }
+ DBMoveChunk(ofsSettingToCut,ofsSettingToCut+nameLen+valLen,ofsBlobPtr+1-ofsSettingToCut);
+ }
+
+ szCachedSettingName = GetCachedSetting(dbcgs->szModule,dbcgs->szSetting,settingNameLen);
+ GetCachedValuePtr((HANDLE)saveWparam, szCachedSettingName, -1 );
+
+ //quit
+ DBFlush(1);
+ LeaveCriticalSection(&csDbAccess);
+ { //notify
+ DBCONTACTWRITESETTING dbcws;
+ dbcws.szModule=dbcgs->szModule;
+ dbcws.szSetting=dbcgs->szSetting;
+ dbcws.value.type=DBVT_DELETED;
+ NotifyEventHooks(hSettingChangeEvent,saveWparam,(LPARAM)&dbcws);
+ }
+ return 0;
+}
+
+static int EnumContactSettings(WPARAM wParam,LPARAM lParam)
+{
+ DBCONTACTENUMSETTINGS *dbces=(DBCONTACTENUMSETTINGS*)lParam;
+ struct DBContact dbc;
+ struct DBContactSettings dbcs;
+ DWORD ofsModuleName,ofsContact,ofsBlobPtr;
+ int bytesRemaining, result;
+ PBYTE pBlob;
+ char szSetting[256];
+
+ if (!dbces->szModule)
+ return -1;
+
+ EnterCriticalSection(&csDbAccess);
+
+ ofsModuleName=GetModuleNameOfs(dbces->szModule);
+ if(wParam==0) ofsContact=dbHeader.ofsUser;
+ else ofsContact=wParam;
+ dbc=*(struct DBContact*)DBRead(ofsContact,sizeof(struct DBContact),NULL);
+ if(dbc.signature!=DBCONTACT_SIGNATURE) {
+ LeaveCriticalSection(&csDbAccess);
+ return -1;
+ }
+ dbces->ofsSettings=GetSettingsGroupOfsByModuleNameOfs(&dbc,ofsContact,ofsModuleName);
+ if(!dbces->ofsSettings) {
+ LeaveCriticalSection(&csDbAccess);
+ return -1;
+ }
+ dbcs=*(struct DBContactSettings*)DBRead(dbces->ofsSettings,sizeof(struct DBContactSettings),&bytesRemaining);
+ ofsBlobPtr=dbces->ofsSettings+offsetof(struct DBContactSettings,blob);
+ pBlob=(PBYTE)DBRead(ofsBlobPtr,1,&bytesRemaining);
+ if(pBlob[0]==0) {
+ LeaveCriticalSection(&csDbAccess);
+ return -1;
+ }
+ result = 0;
+ while(pBlob[0]) {
+ NeedBytes(1);
+ NeedBytes(1+pBlob[0]);
+ CopyMemory(szSetting,pBlob+1,pBlob[0]); szSetting[pBlob[0]]=0;
+ result = (dbces->pfnEnumProc)(szSetting,dbces->lParam);
+ MoveAlong(1+pBlob[0]);
+ NeedBytes(3);
+ MoveAlong(1+GetSettingValueLength(pBlob));
+ NeedBytes(1);
+ }
+ LeaveCriticalSection(&csDbAccess);
+ return result;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+//
+// Module initialization procedure
+
+static int stringCompare( DBCachedSettingName* p1, DBCachedSettingName* p2 )
+{
+ return strcmp( p1->name, p2->name );
+}
+
+static int stringCompare2( DBCachedGlobalValue* p1, DBCachedGlobalValue* p2 )
+{
+ return strcmp( p1->name, p2->name );
+}
+
+static int handleCompare( void* p1, void* p2 )
+{
+ if ( *( long* )p1 == *( long* )p2 )
+ return 0;
+
+ return *( long* )p1 - *( long* )p2;
+}
+
+int InitSettings(void)
+{
+ CreateServiceFunction(MS_DB_CONTACT_GETSETTING,GetContactSetting);
+ CreateServiceFunction(MS_DB_CONTACT_GETSETTING_STR,GetContactSettingStr);
+ CreateServiceFunction(MS_DB_CONTACT_GETSETTINGSTATIC,GetContactSettingStatic);
+ CreateServiceFunction(MS_DB_CONTACT_FREEVARIANT,FreeVariant);
+ CreateServiceFunction(MS_DB_CONTACT_WRITESETTING,WriteContactSetting);
+ CreateServiceFunction(MS_DB_CONTACT_DELETESETTING,DeleteContactSetting);
+ CreateServiceFunction(MS_DB_CONTACT_ENUMSETTINGS,EnumContactSettings);
+ CreateServiceFunction(MS_DB_SETSETTINGRESIDENT,SetSettingResident);
+ hSettingChangeEvent=CreateHookableEvent(ME_DB_CONTACT_SETTINGCHANGED);
+
+ hCacheHeap=HeapCreate(HEAP_NO_SERIALIZE,0,0);
+ lSettings.sortFunc=stringCompare;
+ lSettings.increment=50;
+ lContacts.sortFunc=handleCompare;
+ lContacts.increment=100;
+ lGlobalSettings.sortFunc=stringCompare2;
+ lGlobalSettings.increment=100;
+ return 0;
+}
+
+void UninitSettings(void)
+{
+ HeapDestroy(hCacheHeap);
+ li.List_Destroy(&lContacts);
+ li.List_Destroy(&lSettings);
+ li.List_Destroy(&lGlobalSettings);
+}
diff --git a/db3x_autobackups/dbtime.c b/db3x_autobackups/dbtime.c
new file mode 100644
index 0000000..e9189b9
--- /dev/null
+++ b/db3x_autobackups/dbtime.c
@@ -0,0 +1,163 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+#include "database.h"
+
+static int daysInMonth[12]={31,28,31,30,31,30,31,31,30,31,30,31};
+static int IsLeapYear(int year)
+{
+ if(year&3) return 0;
+ if(year%100) return 1;
+ if(year%400) return 0;
+ return 1;
+}
+
+static int CompareSystemTimes(SYSTEMTIME *st,SYSTEMTIME *switchDate)
+{
+ FILETIME ft1,ft2;
+
+ if(switchDate->wYear==0) { //strange day-in-month thing
+ SYSTEMTIME tempst;
+
+ //short-circuit if the months aren't the same
+ if(st->wMonth<switchDate->wMonth) return -1;
+ if(st->wMonth>switchDate->wMonth) return 1;
+
+ tempst=*switchDate;
+ tempst.wYear=st->wYear;
+ tempst.wDay=1;
+ SystemTimeToFileTime(&tempst,&ft1);
+ FileTimeToSystemTime(&ft1,&tempst); //gets the day of week of the first of the month
+ tempst.wDay=1+(7+switchDate->wDayOfWeek-tempst.wDayOfWeek)%7;
+ if(switchDate->wDay==5) { //last wDayOfWeek in month
+ if(tempst.wMonth==2) {
+ if(IsLeapYear(tempst.wYear)) daysInMonth[1]=29;
+ else daysInMonth[1]=28;
+ }
+ tempst.wDay+=7*3; //can't be less than 4 of that day in the month
+ if(tempst.wDay+7<=daysInMonth[switchDate->wMonth-1]) tempst.wDay+=7;
+ }
+ else tempst.wDay+=7*(switchDate->wDay-1); //nth of month
+ SystemTimeToFileTime(&tempst,&ft2);
+ }
+ else {
+ switchDate->wYear=st->wYear;
+ SystemTimeToFileTime(switchDate,&ft2);
+ }
+ SystemTimeToFileTime(st,&ft1);
+ return CompareFileTime(&ft1,&ft2);
+}
+
+static int TimestampToLocal(WPARAM wParam,LPARAM lParam)
+{
+ TIME_ZONE_INFORMATION tzInfo;
+ LARGE_INTEGER liFiletime;
+ FILETIME filetime;
+ SYSTEMTIME st;
+
+ GetTimeZoneInformation(&tzInfo);
+ if(tzInfo.StandardDate.wMonth==0) { //no daylight savings time
+ return (int)(wParam-tzInfo.Bias*60);
+ }
+ //this huge number is the difference between 1970 and 1601 in seconds
+ liFiletime.QuadPart=(mir_i64(11644473600)+(__int64)wParam)*10000000;
+ filetime.dwHighDateTime=liFiletime.HighPart;
+ filetime.dwLowDateTime=liFiletime.LowPart;
+ FileTimeToSystemTime(&filetime,&st);
+ if(tzInfo.DaylightDate.wMonth<tzInfo.StandardDate.wMonth) {
+ //northern hemisphere
+ if(CompareSystemTimes(&st,&tzInfo.DaylightDate)<0 ||
+ CompareSystemTimes(&st,&tzInfo.StandardDate)>0) {
+ return (int)(wParam-(tzInfo.Bias+tzInfo.StandardBias)*60);
+ }
+ return (int)(wParam-(tzInfo.Bias+tzInfo.DaylightBias)*60);
+ }
+ else {
+ //southern hemisphere
+ if(CompareSystemTimes(&st,&tzInfo.StandardDate)<0 ||
+ CompareSystemTimes(&st,&tzInfo.DaylightDate)>0) {
+ return (int)(wParam-(tzInfo.Bias+tzInfo.DaylightBias)*60);
+ }
+ return (int)(wParam-(tzInfo.Bias+tzInfo.StandardBias)*60);
+ }
+ return 0;
+}
+
+static int TimestampToString(WPARAM wParam,LPARAM lParam)
+{
+ DBTIMETOSTRING *tts=(DBTIMETOSTRING*)lParam;
+ LARGE_INTEGER liFiletime;
+ FILETIME filetime;
+ SYSTEMTIME st;
+ char dateTimeStr[64];
+ char *pDest,*pFormat;
+ int destCharsLeft,dateTimeStrLen;
+
+ //this huge number is the difference between 1970 and 1601 in seconds
+ liFiletime.QuadPart=(mir_i64(11644473600)+(__int64)(DWORD)TimestampToLocal(wParam,0))*10000000;
+ filetime.dwHighDateTime=liFiletime.HighPart;
+ filetime.dwLowDateTime=liFiletime.LowPart;
+ FileTimeToSystemTime(&filetime,&st);
+ destCharsLeft=tts->cbDest;
+ for(pFormat=tts->szFormat,pDest=tts->szDest;*pFormat;pFormat++) {
+ switch(*pFormat) {
+ case 't':
+ GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,NULL,dateTimeStr,sizeof(dateTimeStr));
+ break;
+ case 's':
+ GetTimeFormat(LOCALE_USER_DEFAULT,0,&st,NULL,dateTimeStr,sizeof(dateTimeStr));
+ break;
+ case 'm':
+ GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOMINUTESORSECONDS,&st,NULL,dateTimeStr,sizeof(dateTimeStr));
+ break;
+ case 'd':
+ GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&st,NULL,dateTimeStr,sizeof(dateTimeStr));
+ break;
+ case 'D':
+ GetDateFormat(LOCALE_USER_DEFAULT,DATE_LONGDATE,&st,NULL,dateTimeStr,sizeof(dateTimeStr));
+ break;
+ default:
+ if(destCharsLeft) {
+ *pDest++=*pFormat;
+ destCharsLeft--;
+ }
+ continue;
+ }
+ dateTimeStrLen=strlen(dateTimeStr);
+ if(destCharsLeft<dateTimeStrLen) dateTimeStrLen=destCharsLeft;
+ CopyMemory(pDest,dateTimeStr,dateTimeStrLen);
+ destCharsLeft-=dateTimeStrLen;
+ pDest+=dateTimeStrLen;
+ }
+ if(destCharsLeft) *pDest=0;
+ else tts->szDest[tts->cbDest-1]=0;
+ return 0;
+}
+
+int InitTime(void)
+{
+ CreateServiceFunction(MS_DB_TIME_TIMESTAMPTOLOCAL,TimestampToLocal);
+ CreateServiceFunction(MS_DB_TIME_TIMESTAMPTOSTRING,TimestampToString);
+ return 0;
+}
diff --git a/db3x_autobackups/docs/db3x-license.txt b/db3x_autobackups/docs/db3x-license.txt
new file mode 100644
index 0000000..7f11610
--- /dev/null
+++ b/db3x_autobackups/docs/db3x-license.txt
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/db3x_autobackups/docs/db3x-readme.txt b/db3x_autobackups/docs/db3x-readme.txt
new file mode 100644
index 0000000..eb5707c
--- /dev/null
+++ b/db3x_autobackups/docs/db3x-readme.txt
@@ -0,0 +1,38 @@
+################################################################
+# Classic Database Driver for Miranda IM
+################################################################
+
+About
+-----
+The Classic Database Driver is used to store all contacts and
+events in Miranda IM.
+
+
+Requirements
+------------
+ - Miranda IM 0.4
+
+
+History
+-------
+0.4.0.0
+ - DB driver separated from core (initial release)
+
+
+Copyright
+---------
+Copyright (C) 2003-2005 Miranda IM Development Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
diff --git a/db3x_autobackups/docs/db3x-translation.txt b/db3x_autobackups/docs/db3x-translation.txt
new file mode 100644
index 0000000..fc265cc
--- /dev/null
+++ b/db3x_autobackups/docs/db3x-translation.txt
@@ -0,0 +1,43 @@
+Miranda Language Pack Version 1
+Locale: 0809
+Authors: Miranda IM Development Team
+Author-email: info@miranda-im.org
+Last-Modified-Using: Miranda IM 0.4
+Plugins-included:
+
+; Generated by lpgen on Wed Apr 6 12:41:12 2005
+; Translations: 27
+
+; database.c
+;[Miranda has detected corruption in your database. This corruption maybe fixed by DBTool. Please download it from http://www.miranda-im.org. Miranda will now shutdown.]
+;[Database Panic]
+
+; dbini.c
+;[Invalid setting type. The first character of every value must be b, w, d, l, s or n.]
+;[Install Database Settings]
+
+; resource.rc
+;[&Allow all further changes to this section]
+;[Yes]
+;[&Yes]
+;[No]
+;[No to all]
+;[&View contents]
+;[&No]
+;[Cancel Import]
+;[&Recycle]
+;[&Delete]
+;[&Move/Rename]
+;[&Leave]
+;[A file containing new database settings has been placed in the Miranda IM directory.]
+;[Do you want to import the settings now?]
+;[Security systems to prevent malicious changes are in place and you will be warned before changes that are not known to be safe.]
+;[Database settings are being imported from]
+;[This file wishes to change the setting]
+;[to the value]
+;[Do you want to allow this change?]
+;[The import has completed from]
+;[What do you want to do with the file now?]
+;[Database Setting Change]
+;[Database Import Complete]
+
diff --git a/db3x_autobackups/encrypt.c b/db3x_autobackups/encrypt.c
new file mode 100644
index 0000000..1382a27
--- /dev/null
+++ b/db3x_autobackups/encrypt.c
@@ -0,0 +1,67 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+#include "database.h"
+
+//VERY VERY VERY BASIC ENCRYPTION FUNCTION
+
+
+void Encrypt(char*msg,BOOL up)
+{
+ int i;
+ int jump;
+ if (up)
+ {
+ jump=5;
+ }
+ else
+ {
+ jump=-5;
+ }
+
+ for (i=0;msg[i];i++)
+ {
+ msg[i]=msg[i]+jump;
+ }
+
+}
+
+static int EncodeString(WPARAM wParam,LPARAM lParam)
+{
+ Encrypt((char*)lParam,TRUE);
+ return 0;
+}
+
+static int DecodeString(WPARAM wParam,LPARAM lParam)
+{
+ Encrypt((char*)lParam,FALSE);
+ return 0;
+}
+
+int InitCrypt(void)
+{
+ CreateServiceFunction(MS_DB_CRYPT_ENCODESTRING,EncodeString);
+ CreateServiceFunction(MS_DB_CRYPT_DECODESTRING,DecodeString);
+ return 0;
+}
diff --git a/db3x_autobackups/encryption.h b/db3x_autobackups/encryption.h
new file mode 100644
index 0000000..73c2d7e
--- /dev/null
+++ b/db3x_autobackups/encryption.h
@@ -0,0 +1,23 @@
+/*
+Miranda ICQ: the free icq client for MS Windows
+Copyright (C) 2000-2 Richard Hughes, Roland Rabien & Tristan Van de Vreede
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#ifndef MODULAR
+#include <windows.h>
+
+void Encrypt(char*msg,BOOL up);
+#endif \ No newline at end of file
diff --git a/db3x_autobackups/finalcommand.c b/db3x_autobackups/finalcommand.c
new file mode 100644
index 0000000..2e8ecbb
--- /dev/null
+++ b/db3x_autobackups/finalcommand.c
@@ -0,0 +1,58 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+
+char exit_command[MAX_PATH],
+ exit_command_dir[MAX_PATH],
+ exit_command_params[MAX_PATH];
+
+BOOL command_valid = FALSE,
+ command_dir_valid = FALSE,
+ command_params_valid = FALSE;
+
+void FinalCommandSetup(void) {
+ DBVARIANT dbv;
+
+ if(!DBGetContactSetting(0, "db3x", "ExitCommand", &dbv) && dbv.type == DBVT_ASCIIZ) {
+ strncpy(exit_command, dbv.pszVal, MAX_PATH);
+ command_valid = TRUE;
+ DBFreeVariant(&dbv);
+
+ if(!DBGetContactSetting(0, "db3x", "ExitCommandParams", &dbv) && dbv.type == DBVT_ASCIIZ) {
+ strncpy(exit_command_params, dbv.pszVal, MAX_PATH);
+ command_params_valid = TRUE;
+ DBFreeVariant(&dbv);
+ }
+ if(!DBGetContactSetting(0, "db3x", "ExitCommandDir", &dbv) && dbv.type == DBVT_ASCIIZ) {
+ strncpy(exit_command_dir, dbv.pszVal, MAX_PATH);
+ command_dir_valid = TRUE;
+ DBFreeVariant(&dbv);
+ }
+ }
+}
+
+void FinalCommandExecute(void) {
+ if(command_valid)
+ ShellExecute(0, 0, exit_command, command_params_valid ? exit_command_params : 0, command_dir_valid ? exit_command_dir : 0, SW_SHOWNORMAL);
+}
diff --git a/db3x_autobackups/icon1.ico b/db3x_autobackups/icon1.ico
new file mode 100644
index 0000000..171f5dd
--- /dev/null
+++ b/db3x_autobackups/icon1.ico
Binary files differ
diff --git a/db3x_autobackups/init.c b/db3x_autobackups/init.c
new file mode 100644
index 0000000..11b0f61
--- /dev/null
+++ b/db3x_autobackups/init.c
@@ -0,0 +1,210 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+#include "database.h"
+#include <m_plugins.h>
+
+struct MM_INTERFACE mmi;
+struct LIST_INTERFACE li;
+struct UTF8_INTERFACE utfi;
+
+extern char szDbPath[MAX_PATH];
+
+HINSTANCE g_hInst=NULL;
+PLUGINLINK *pluginLink;
+
+static int getCapability( int flag )
+{
+ return 0;
+}
+
+// returns 0 if the profile is created, EMKPRF*
+static int makeDatabase(char * profile, int * error)
+{
+ HANDLE hFile=CreateFile(profile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
+ if ( hFile != INVALID_HANDLE_VALUE ) {
+ CreateDbHeaders(hFile);
+ CloseHandle(hFile);
+ return 0;
+ }
+ if ( error != NULL ) *error=EMKPRF_CREATEFAILED;
+ return 1;
+}
+
+// returns 0 if the given profile has a valid header
+static int grokHeader( char * profile, int * error )
+{
+ int rc=1;
+ int chk=0;
+ struct DBHeader hdr;
+ HANDLE hFile = INVALID_HANDLE_VALUE;
+ DWORD dummy=0;
+
+ hFile = CreateFile(profile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+ if ( hFile == INVALID_HANDLE_VALUE ) {
+ if ( error != NULL ) *error=EGROKPRF_CANTREAD;
+ return 1;
+ }
+ // read the header, which can fail (for various reasons)
+ if ( !ReadFile(hFile, &hdr, sizeof(struct DBHeader), &dummy, NULL) ) {
+ if ( error != NULL) *error=EGROKPRF_CANTREAD;
+ CloseHandle(hFile);
+ return 1;
+ }
+ chk=CheckDbHeaders(&hdr);
+ if ( chk == 0 ) {
+ // all the internal tests passed, hurrah
+ rc=0;
+ if ( error != NULL ) *error=0;
+ } else {
+ // didn't pass at all, or some did.
+ switch ( chk ) {
+ case 1:
+ {
+ // "Miranda ICQ DB" wasn't present
+ if ( error != NULL ) *error = EGROKPRF_UNKHEADER;
+ break;
+ }
+ case 2:
+ {
+ // header was present, but version information newer
+ if ( error != NULL ) *error= EGROKPRF_VERNEWER;
+ break;
+ }
+ case 3:
+ {
+ // header/version OK, internal data missing
+ if ( error != NULL ) *error=EGROKPRF_DAMAGED;
+ break;
+ }
+ } // switch
+ } //if
+ CloseHandle(hFile);
+ return rc;
+}
+
+static PLUGININFO pluginInfo = {
+ sizeof(PLUGININFO),
+ "Miranda database - with AutoBackups",
+ PLUGIN_MAKE_VERSION(0,6,0,1),
+ "Provides Miranda database support: global settings, contacts, history, settings per contact.",
+ "Miranda-IM project",
+ "mail@scottellis.com.au",
+ "Copyright 2000-2005 Miranda-IM project",
+ "",
+ 0,
+ DEFMOD_DB
+};
+
+// returns 0 if all the APIs are injected otherwise, 1
+static int LoadDatabase( char * profile, void * plink )
+{
+ PLUGINLINK *link = plink;
+#ifdef _DEBUG
+ _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+#endif
+ // don't need thread notifications
+ strncpy(szDbPath, profile, sizeof(szDbPath));
+
+ // this is like Load()'s pluginLink
+ pluginLink=link;
+
+ // set the memory, lists & UTF8 manager
+ mir_getLI( &li );
+ mir_getMMI( &mmi );
+ mir_getUTFI( &utfi );
+
+ // inject all APIs and hooks into the core
+ return LoadDatabaseModule();
+}
+
+static int UnloadDatabase(int wasLoaded)
+{
+ if ( !wasLoaded) return 0;
+ UnloadDatabaseModule();
+ return 0;
+}
+
+static int getFriendlyName( char * buf, size_t cch, int shortName )
+{
+ strncpy(buf,shortName ? "db3x driver" : "db3x database support",cch);
+ return 0;
+}
+
+
+static DATABASELINK dblink = {
+ sizeof(DATABASELINK),
+ getCapability,
+ getFriendlyName,
+ makeDatabase,
+ grokHeader,
+ LoadDatabase,
+ UnloadDatabase,
+};
+
+/*
+
+static PLUGININFO pluginInfo = {
+ sizeof(PLUGININFO),
+ "Miranda database driver",
+ PLUGIN_MAKE_VERSION(0,6,0,1),
+ "Provides Miranda database support: global settings, contacts, history, settings per contact.",
+ "Miranda-IM project",
+ "ghazan@miranda-im.org",
+ "Copyright 2000-2006 Miranda IM project",
+ "",
+ 0,
+ DEFMOD_DB
+};
+
+*/
+BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID reserved)
+{
+ g_hInst = hInstDLL;
+ return TRUE;
+}
+
+__declspec(dllexport) DATABASELINK* DatabasePluginInfo(void * reserved)
+{
+ return &dblink;
+}
+
+__declspec(dllexport) PLUGININFO * MirandaPluginInfo(DWORD mirandaVersion)
+{
+ if ( mirandaVersion < PLUGIN_MAKE_VERSION(0,6,0,15)) {
+ MessageBox( NULL, _T("The db3x plugin cannot be loaded. It requires Miranda IM 0.6.0.15 or later."), _T("db3x Plugin"), MB_OK|MB_ICONWARNING|MB_SETFOREGROUND|MB_TOPMOST );
+ return NULL;
+ }
+ return &pluginInfo;
+}
+
+int __declspec(dllexport) Load(PLUGINLINK * link)
+{
+ return 1;
+}
+
+int __declspec(dllexport) Unload(void)
+{
+ return 0;
+}
diff --git a/db3x_autobackups/options.c b/db3x_autobackups/options.c
new file mode 100644
index 0000000..9381923
--- /dev/null
+++ b/db3x_autobackups/options.c
@@ -0,0 +1,384 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+#include "../../include/m_utils.h"
+#include "../../include/m_trigger.h"
+#include "../updater/m_updater.h"
+
+#include <shlobj.h>
+
+#include "database.h"
+#include "options.h"
+
+extern HINSTANCE g_hInst;
+Options options;
+
+
+#define SUB_DIR "\\AutoBackups"
+int GetProfileDirectory(char *szPath,int cbPath) {
+ return CallService(MS_DB_GETPROFILEPATH, (WPARAM)cbPath, (LPARAM)szPath);
+}
+
+int Backup(void);
+int BackupService(WPARAM wParam, LPARAM lParam);
+int SetBackupTimer(void);
+
+int LoadOptions(void) {
+ DBVARIANT dbv;
+
+ options.backup_types = (BackupType)DBGetContactSettingByte(0, "db3x", "BackupType", (BYTE)(BT_EXIT | BT_PERIODIC));
+ options.period = (unsigned int)DBGetContactSettingWord(0, "db3x", "Period", 1);
+ options.period_type = (PeriodType)DBGetContactSettingByte(0, "db3x", "PeriodType", (BYTE)PT_DAYS);
+
+ if(!DBGetContactSetting(0, "db3x", "Folder", &dbv) && dbv.type == DBVT_ASCIIZ) {
+ if(strlen(dbv.pszVal) >= 2 && dbv.pszVal[1] == ':') {
+ strncpy(options.folder, dbv.pszVal, MAX_PATH);
+ } else {
+ GetProfileDirectory(options.folder, MAX_PATH);
+ strcat(options.folder, "\\");
+ strcat(options.folder, dbv.pszVal);
+ }
+ DBFreeVariant(&dbv);
+ } else {
+ int len;
+ GetProfileDirectory(options.folder, MAX_PATH);
+ len = strlen(options.folder);
+ strncat(options.folder, SUB_DIR, MAX_PATH - len);
+ }
+
+ options.num_backups = (unsigned int)DBGetContactSettingWord(0, "db3x", "NumBackups", 3);
+
+ options.disable_progress = (BOOL)DBGetContactSettingByte(0, "db3x", "NoProgress", 0);
+
+ SetBackupTimer();
+ return 0;
+}
+
+int SaveOptions(void) {
+ char prof_dir[MAX_PATH];
+ int prof_len, opt_len;
+
+ DBWriteContactSettingByte(0, "db3x", "BackupType", (BYTE)options.backup_types);
+ DBWriteContactSettingWord(0, "db3x", "Period", (WORD)options.period);
+ DBWriteContactSettingByte(0, "db3x", "PeriodType", (BYTE)options.period_type);
+
+ GetProfileDirectory(prof_dir, MAX_PATH);
+ strcat(prof_dir, "\\");
+ prof_len = strlen(prof_dir);
+ opt_len = strlen(options.folder);
+
+ if(opt_len > prof_len && strncmp(options.folder, prof_dir, prof_len) == 0) {
+ DBWriteContactSettingString(0, "db3x", "Folder", (options.folder + prof_len));
+ } else
+ DBWriteContactSettingString(0, "db3x", "Folder", options.folder);
+
+ DBWriteContactSettingWord(0, "db3x", "NumBackups", (WORD)options.num_backups);
+ DBWriteContactSettingByte(0, "db3x", "NoProgress", (BYTE)options.disable_progress);
+
+ SetBackupTimer();
+ return 0;
+}
+
+Options new_options;
+
+int SetDlgState(HWND hwndDlg) {
+ HWND hwndCtrl;
+ char buff[10];
+
+ if(new_options.backup_types == BT_DISABLED) {
+ CheckDlgButton(hwndDlg, IDC_RAD_DISABLED, BST_CHECKED);
+ hwndCtrl = GetDlgItem(hwndDlg, IDC_RAD_DISABLED);
+ EnableWindow(hwndCtrl, FALSE);
+
+ CheckDlgButton(hwndDlg, IDC_RAD_START, BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_RAD_EXIT, BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_RAD_PERIODIC, BST_UNCHECKED);
+ hwndCtrl = GetDlgItem(hwndDlg, IDC_ED_PERIOD);
+ EnableWindow(hwndCtrl, FALSE);
+ hwndCtrl = GetDlgItem(hwndDlg, IDC_RAD_DAYS);
+ EnableWindow(hwndCtrl, FALSE);
+ hwndCtrl = GetDlgItem(hwndDlg, IDC_RAD_HOURS);
+ EnableWindow(hwndCtrl, FALSE);
+ } else {
+ hwndCtrl = GetDlgItem(hwndDlg, IDC_RAD_DISABLED);
+ EnableWindow(hwndCtrl, TRUE);
+ CheckDlgButton(hwndDlg, IDC_RAD_DISABLED, BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_RAD_START, new_options.backup_types & BT_START ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_RAD_EXIT, new_options.backup_types & BT_EXIT ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_RAD_PERIODIC, new_options.backup_types & BT_PERIODIC ? BST_CHECKED : BST_UNCHECKED);
+ hwndCtrl = GetDlgItem(hwndDlg, IDC_ED_PERIOD);
+ EnableWindow(hwndCtrl, new_options.backup_types & BT_PERIODIC);
+ hwndCtrl = GetDlgItem(hwndDlg, IDC_RAD_DAYS);
+ EnableWindow(hwndCtrl, new_options.backup_types & BT_PERIODIC);
+ hwndCtrl = GetDlgItem(hwndDlg, IDC_RAD_HOURS);
+ EnableWindow(hwndCtrl, new_options.backup_types & BT_PERIODIC);
+ }
+
+ SetDlgItemText(hwndDlg, IDC_ED_PERIOD, itoa(new_options.period, buff, 10));
+
+ switch(new_options.period_type) {
+ case PT_DAYS:
+ CheckDlgButton(hwndDlg, IDC_RAD_DAYS, BST_CHECKED);
+ CheckDlgButton(hwndDlg, IDC_RAD_HOURS, BST_UNCHECKED);
+ break;
+ case PT_HOURS:
+ CheckDlgButton(hwndDlg, IDC_RAD_DAYS, BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_RAD_HOURS, BST_CHECKED);
+ break;
+ }
+
+ SetDlgItemText(hwndDlg, IDC_ED_NUMBACKUPS, itoa(new_options.num_backups, buff, 10));
+
+ SetDlgItemText(hwndDlg, IDC_ED_FOLDER, new_options.folder);
+
+ CheckDlgButton(hwndDlg, IDC_CHK_NOPROG, new_options.disable_progress ? BST_CHECKED : BST_UNCHECKED);
+
+ return 0;
+}
+
+BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ char buff[10];
+ char folder_buff[MAX_PATH];
+ BROWSEINFO bi;
+ LPCITEMIDLIST pidl;
+
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault( hwndDlg );
+ memcpy(&new_options, &options, sizeof(Options));
+ SetDlgState(hwndDlg);
+ return TRUE;
+ case WM_COMMAND:
+ if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+ switch( LOWORD( wParam )) {
+ case IDC_ED_PERIOD:
+ case IDC_ED_FOLDER:
+ case IDC_ED_NUMBACKUPS:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ if ( HIWORD( wParam ) == BN_CLICKED ) {
+ switch( LOWORD( wParam )) {
+ case IDC_RAD_DISABLED:
+ if(IsDlgButtonChecked(hwndDlg, IDC_RAD_DISABLED)) {
+ new_options.backup_types = BT_DISABLED;
+ }
+ SetDlgState(hwndDlg);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case IDC_RAD_START:
+ if(IsDlgButtonChecked(hwndDlg, IDC_RAD_START))
+ new_options.backup_types |= BT_START;
+ else
+ new_options.backup_types &= ~BT_START;
+ SetDlgState(hwndDlg);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case IDC_RAD_EXIT:
+ if(IsDlgButtonChecked(hwndDlg, IDC_RAD_EXIT))
+ new_options.backup_types |= BT_EXIT;
+ else
+ new_options.backup_types &= ~BT_EXIT;
+ SetDlgState(hwndDlg);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case IDC_RAD_PERIODIC:
+ if(IsDlgButtonChecked(hwndDlg, IDC_RAD_PERIODIC))
+ new_options.backup_types |= BT_PERIODIC;
+ else
+ new_options.backup_types &= ~BT_PERIODIC;
+ SetDlgState(hwndDlg);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case IDC_RAD_DAYS:
+ new_options.period_type = PT_DAYS;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case IDC_RAD_HOURS:
+ new_options.period_type = PT_HOURS;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_BUT_BROWSE:
+ bi.hwndOwner = hwndDlg;
+ bi.pidlRoot = 0;
+ bi.pszDisplayName = folder_buff;
+ bi.lpszTitle = Translate("Select Backup Folder");
+ bi.ulFlags = 0;
+ bi.lpfn = 0;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ if((pidl = SHBrowseForFolder(&bi)) != 0) {
+ SHGetPathFromIDList(pidl, folder_buff);
+ SetDlgItemText(hwndDlg, IDC_ED_FOLDER, folder_buff);
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+
+ CoTaskMemFree((void *)pidl);
+ }
+ break;
+ case IDC_BUT_NOW:
+ Backup();
+ break;
+ case IDC_CHK_NOPROG:
+ new_options.disable_progress = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOPROG);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ }
+
+ break;
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
+ GetDlgItemText(hwndDlg, IDC_ED_PERIOD, buff, sizeof(buff));
+ new_options.period = atoi(buff);
+ GetDlgItemText(hwndDlg, IDC_ED_NUMBACKUPS, buff, sizeof(buff));
+ new_options.num_backups = atoi(buff);
+ GetDlgItemText(hwndDlg, IDC_ED_FOLDER, folder_buff, MAX_PATH);
+
+ {
+ BOOL folder_ok = TRUE;
+ if(!CreateDirectory(folder_buff, 0)) {
+ DWORD err = GetLastError();
+ if(err != ERROR_ALREADY_EXISTS) {
+ char msg_buff[512];
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, err, 0, msg_buff, 512, 0);
+ MessageBox(0, msg_buff, Translate("Error Creating Backup Folder"), MB_OK | MB_ICONERROR);
+ folder_ok = FALSE;
+ }
+ }
+
+ if(folder_ok) {
+ strncpy(new_options.folder, folder_buff, MAX_PATH);
+ memcpy(&options, &new_options, sizeof(Options));
+ SaveOptions();
+ } else {
+ memcpy(&new_options, &options, sizeof(Options));
+ SetDlgState(hwndDlg);
+ }
+ }
+ return TRUE;
+
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+int OptInit(WPARAM wParam, LPARAM lParam) {
+ OPTIONSDIALOGPAGE odp = {0};
+#define OPTIONPAGE_OLD_SIZE2 60
+ //odp.cbSize = sizeof(odp);
+ odp.cbSize = OPTIONPAGE_OLD_SIZE2;
+ odp.position = -790000000;
+ odp.hInstance = g_hInst;
+ odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS);
+ odp.pszTitle = Translate("Database Backups");
+ odp.pszGroup = Translate("Services");
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.nIDBottomSimpleControl = 0;
+ odp.pfnDlgProc = DlgProcOpts;
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+
+ return 0;
+}
+
+int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
+ CLISTMENUITEM menu;
+
+ HookEvent(ME_OPT_INITIALISE, OptInit);
+
+ ZeroMemory(&menu,sizeof(menu));
+ menu.cbSize=sizeof(menu);
+ menu.flags = CMIM_ALL;
+
+ menu.hIcon=LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_MENU));
+
+ // main menu item
+ menu.pszName = (char *)Translate("Backup Profile");
+ menu.pszService = MS_DB_BACKUP;
+ menu.position = 500100000;
+ CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&menu);
+
+ // register trigger action for triggerplugin
+ if(ServiceExists(MS_TRIGGER_REGISTERACTION)) {
+ // create update action for triggerplugin
+ ACTIONREGISTER ar = {0};
+ ar.cbSize = sizeof(ACTIONREGISTER);
+ ar.pszName = Translate("Backup Database");
+ ar.pszService = MS_DB_BACKUPTRGR;
+
+ CallService(MS_TRIGGER_REGISTERACTION, 0, (LPARAM)&ar);
+ }
+
+
+ return 0;
+}
+
+// can't do this on unload, since other plugins will be have already been unloaded, but their hooks
+// for setting changed event not cleared. the backup on exit function will write to the db, calling those hooks.
+int PreShutdown(WPARAM wParam, LPARAM lParam) {
+ if(options.backup_types & BT_EXIT)
+ Backup();
+
+ return 0;
+}
+
+int BackupServiceTrgr(WPARAM wParam, LPARAM lParam) {
+ if(wParam & ACT_PERFORM) {
+ return CallService(MS_DB_BACKUP, 0, 0);
+ }
+ return 0;
+}
+
+int InitOptions(void) {
+
+ OleInitialize(0);
+
+ CreateServiceFunction(MS_DB_BACKUP, BackupService);
+ CreateServiceFunction(MS_DB_BACKUPTRGR, BackupServiceTrgr);
+
+ // we have to wait for the options module to load!
+ HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
+
+ // but, our stuff has loaded so...
+ LoadOptions();
+
+ if(options.backup_types & BT_START)
+ Backup();
+
+ return 0;
+}
+
+int UninitOptions(void) {
+
+ OleUninitialize();
+
+ return 0;
+}
+
diff --git a/db3x_autobackups/options.h b/db3x_autobackups/options.h
new file mode 100644
index 0000000..5f027bc
--- /dev/null
+++ b/db3x_autobackups/options.h
@@ -0,0 +1,42 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2003 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <m_clist.h>
+#include <m_options.h>
+#include "resource.h"
+
+typedef enum { BT_DISABLED = 0, BT_START = 1, BT_EXIT = 2, BT_PERIODIC = 4} BackupType;
+typedef enum { PT_DAYS, PT_HOURS} PeriodType;
+
+typedef struct Options_tag {
+ int backup_types;
+ unsigned int period;
+ PeriodType period_type;
+ char folder[MAX_PATH];
+ unsigned int num_backups;
+ BOOL disable_progress;
+} Options;
+
+
+#define MS_DB_BACKUP "DB/Backup"
+#define MS_DB_BACKUPTRGR "DB/BackupTrigger"
diff --git a/db3x_autobackups/resource.h b/db3x_autobackups/resource.h
new file mode 100644
index 0000000..3e69e1e
--- /dev/null
+++ b/db3x_autobackups/resource.h
@@ -0,0 +1,51 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by resource.rc
+//
+#define IDC_NOTOALL 3
+#define IDD_INSTALLINI 235
+#define IDD_WARNINICHANGE 236
+#define IDD_INIIMPORTDONE 237
+#define IDD_OPTIONS 238
+#define IDD_COPYPROGRESS 239
+#define IDC_ININAME 1333
+#define IDC_VIEWINI 1334
+#define IDC_SECURITYINFO 1335
+#define IDC_SETTINGNAME 1336
+#define IDC_NEWVALUE 1337
+#define IDC_WARNNOMORE 1338
+#define IDC_DELETE 1339
+#define IDC_RECYCLE 1340
+#define IDC_NEWNAME 1341
+#define IDC_MOVE 1342
+#define IDC_LEAVE 1343
+
+#define IDC_ED_PERIOD 1344
+#define IDC_RAD_DAYS 1345
+#define IDC_RAD_HOURS 1346
+#define IDC_ED_FOLDER 1347
+#define IDC_BUT_BROWSE 1348
+#define IDC_ED_NUMBACKUPS 1349
+#define IDC_BUT_NOW 1350
+#define IDC_CHK_NOPROG 1351
+#define IDC_RAD_DISABLED 1352
+#define IDC_RAD_START 1353
+#define IDC_RAD_EXIT 1354
+#define IDC_RAD_PERIODIC 1355
+
+#define IDC_PROGRESS 1356
+#define IDC_PROGRESSMESSAGE 1357
+
+#define IDI_MENU 240
+
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 273
+#define _APS_NEXT_COMMAND_VALUE 40018
+#define _APS_NEXT_CONTROL_VALUE 1676
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/db3x_autobackups/resource.rc b/db3x_autobackups/resource.rc
new file mode 100644
index 0000000..9d5d1da
--- /dev/null
+++ b/db3x_autobackups/resource.rc
@@ -0,0 +1,248 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include <winres.h>
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_INSTALLINI DIALOGEX 0, 0, 212, 102
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "Install Database Settings"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "Yes",IDOK,26,83,50,14
+ PUSHBUTTON "No",IDCANCEL,81,83,50,14
+ LTEXT "A file containing new database settings has been placed in the Miranda IM directory.",IDC_STATIC,5,5,202,16
+ LTEXT "Do you want to import the settings now?",IDC_STATIC,5,69,202,8
+ PUSHBUTTON "No to all",IDC_NOTOALL,136,83,50,14
+ LTEXT "",IDC_ININAME,5,24,143,16,SS_NOPREFIX | SS_CENTERIMAGE
+ PUSHBUTTON "&View contents",IDC_VIEWINI,149,25,58,14
+ LTEXT "Security systems to prevent malicious changes are in place and you will be warned before changes that are not known to be safe.",IDC_SECURITYINFO,5,43,202,24
+END
+
+IDD_WARNINICHANGE DIALOGEX 0, 0, 187, 113
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "Database Setting Change"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ LTEXT "Database settings are being imported from",IDC_STATIC,5,
+ 5,177,8
+ CONTROL "",IDC_ININAME,"Static",SS_SIMPLE | SS_NOPREFIX |
+ WS_GROUP,5,13,177,8
+ LTEXT "This file wishes to change the setting",IDC_STATIC,5,24,
+ 177,8
+ CONTROL "",IDC_SETTINGNAME,"Static",SS_SIMPLE | SS_NOPREFIX |
+ WS_GROUP,12,33,170,8
+ LTEXT "to the value",IDC_STATIC,5,42,177,8
+ CONTROL "",IDC_NEWVALUE,"Static",SS_SIMPLE | SS_NOPREFIX |
+ WS_GROUP,12,51,170,8
+ LTEXT "",IDC_SECURITYINFO,5,60,177,8
+ LTEXT "Do you want to allow this change?",IDC_STATIC,5,71,177,8
+ CONTROL "&Allow all further changes to this section",IDC_WARNNOMORE,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,80,169,10
+ DEFPUSHBUTTON "&Yes",IDYES,5,94,50,14
+ PUSHBUTTON "&No",IDNO,59,94,50,14
+ PUSHBUTTON "Cancel Import",IDCANCEL,123,94,59,14
+END
+
+IDD_INIIMPORTDONE DIALOGEX 0, 0, 186, 73
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "Database Import Complete"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ LTEXT "The import has completed from",IDC_STATIC,5,5,176,8
+ CONTROL "",IDC_ININAME,"Static",SS_SIMPLE | SS_NOPREFIX |
+ WS_GROUP,5,13,176,8
+ LTEXT "What do you want to do with the file now?",IDC_STATIC,5,
+ 24,176,8
+ PUSHBUTTON "&Recycle",IDC_RECYCLE,5,36,50,14
+ PUSHBUTTON "&Delete",IDC_DELETE,68,36,50,14
+ EDITTEXT IDC_NEWNAME,5,55,117,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Move/Rename",IDC_MOVE,124,54,57,14
+ PUSHBUTTON "&Leave",IDC_LEAVE,131,36,50,14
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_INSTALLINI, DIALOG
+ BEGIN
+ LEFTMARGIN, 5
+ RIGHTMARGIN, 207
+ TOPMARGIN, 5
+ BOTTOMMARGIN, 97
+ END
+
+ IDD_WARNINICHANGE, DIALOG
+ BEGIN
+ LEFTMARGIN, 5
+ RIGHTMARGIN, 182
+ TOPMARGIN, 5
+ BOTTOMMARGIN, 108
+ END
+
+ IDD_INIIMPORTDONE, DIALOG
+ BEGIN
+ LEFTMARGIN, 5
+ RIGHTMARGIN, 181
+ TOPMARGIN, 5
+ BOTTOMMARGIN, 68
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include <winres.h>\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (Australia) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPTIONS DIALOGEX 0, 0, 277, 228
+STYLE DS_SETFONT | WS_POPUP
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+ GROUPBOX "Automatic Backups",IDC_STATIC,7,7,263,214,WS_GROUP
+ RTEXT "Every:",IDC_STATIC,39,97,52,8
+ EDITTEXT IDC_ED_PERIOD,98,93,28,14,ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT
+ GROUPBOX "",IDC_STATIC,143,81,89,36,WS_GROUP
+ CONTROL "Days",IDC_RAD_DAYS,"Button",BS_AUTORADIOBUTTON | WS_GROUP,149,89,70,10
+ CONTROL "Hours",IDC_RAD_HOURS,"Button",BS_AUTORADIOBUTTON,149,103,70,10
+ EDITTEXT IDC_ED_FOLDER,18,163,176,14,ES_AUTOHSCROLL
+ LTEXT "Backup to folder:",IDC_STATIC,30,150,164,8
+ PUSHBUTTON "Browse...",IDC_BUT_BROWSE,200,163,60,14
+ RTEXT "Number of backups to keep:",IDC_STATIC,34,129,132,8
+ EDITTEXT IDC_ED_NUMBACKUPS,175,127,28,14,ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT
+ PUSHBUTTON "Backup NOW",IDC_BUT_NOW,95,199,75,14
+ CONTROL "Disable progress bar",IDC_CHK_NOPROG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,182,184,10
+ CONTROL "Disabled",IDC_RAD_DISABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,22,156,10
+ CONTROL "When Miranda starts",IDC_RAD_START,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,40,156,10
+ CONTROL "When Miranda exits",IDC_RAD_EXIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,58,156,10
+ CONTROL "Periodically:",IDC_RAD_PERIODIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,76,106,10
+END
+
+IDD_COPYPROGRESS DIALOG 0, 0, 254, 148
+STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION
+CAPTION "Backup in Progress"
+FONT 8, "MS Sans Serif"
+BEGIN
+ PUSHBUTTON "Cancel",IDCANCEL,102,97,50,14
+ CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER,46,64,163,14
+ EDITTEXT IDC_PROGRESSMESSAGE,31,37,190,14,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPTIONS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 270
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 221
+ END
+
+ IDD_COPYPROGRESS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 247
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 141
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_MENU ICON "icon1.ico"
+#endif // English (Australia) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
diff --git a/db3x_autobackups/sync.bat b/db3x_autobackups/sync.bat
new file mode 100644
index 0000000..60d3f6b
--- /dev/null
+++ b/db3x_autobackups/sync.bat
@@ -0,0 +1,4 @@
+@echo off
+
+rem *** this is just a dummy file, so that the 'post-build' copied from the project I
+rem *** modified in miranda's svn does not cause an error :) \ No newline at end of file