diff options
Diffstat (limited to 'plugins/Db3x/src/database.cpp')
-rw-r--r-- | plugins/Db3x/src/database.cpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/plugins/Db3x/src/database.cpp b/plugins/Db3x/src/database.cpp index 0172bde5b2..a9054bb591 100644 --- a/plugins/Db3x/src/database.cpp +++ b/plugins/Db3x/src/database.cpp @@ -31,8 +31,6 @@ void UninitSettings(void); int InitContacts(void);
void UninitContacts(void);
int InitEvents(void);
-void UninitEvents(void);
-int InitCrypt(void);
int InitModuleNames(void);
void UninitModuleNames(void);
int InitCache(void);
@@ -40,10 +38,10 @@ void UninitCache(void); int InitIni(void);
void UninitIni(void);
-HANDLE hDbFile=INVALID_HANDLE_VALUE;
+HANDLE hDbFile = INVALID_HANDLE_VALUE;
CRITICAL_SECTION csDbAccess;
struct DBHeader dbHeader;
-char szDbPath[MAX_PATH];
+TCHAR szDbPath[MAX_PATH];
static void UnloadDatabase(void)
{
@@ -54,8 +52,8 @@ DWORD CreateNewSpace(int bytes) {
DWORD ofsNew;
- ofsNew=dbHeader.ofsFileEnd;
- dbHeader.ofsFileEnd+=bytes;
+ ofsNew = dbHeader.ofsFileEnd;
+ dbHeader.ofsFileEnd += bytes;
DBWrite(0,&dbHeader,sizeof(dbHeader));
log2("newspace %d@%08x",bytes,ofsNew);
return ofsNew;
@@ -65,9 +63,9 @@ void DeleteSpace(DWORD ofs,int bytes) {
PBYTE buf;
log2("deletespace %d@%08x",bytes,ofs);
- dbHeader.slackSpace+=bytes;
+ dbHeader.slackSpace += bytes;
DBWrite(0,&dbHeader,sizeof(dbHeader));
- buf=(PBYTE)mir_alloc(bytes);
+ buf = (PBYTE)mir_alloc(bytes);
memset(buf,0,bytes);
DBWrite(ofs,buf,bytes);
mir_free(buf);
@@ -75,8 +73,6 @@ void DeleteSpace(DWORD ofs,int bytes) void UnloadDatabaseModule(void)
{
- //UninitIni();
- UninitEvents();
UninitSettings();
UninitContacts();
UninitModuleNames();
@@ -90,8 +86,8 @@ int LoadDatabaseModule(void) InitializeCriticalSection(&csDbAccess);
log0("DB logging running");
{
- DWORD dummy=0;
- hDbFile=CreateFileA(szDbPath,GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL);
+ DWORD dummy = 0;
+ hDbFile = CreateFile(szDbPath,GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL);
if ( hDbFile == INVALID_HANDLE_VALUE ) {
return 1;
}
@@ -100,17 +96,16 @@ int LoadDatabaseModule(void) 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 (ParseCommandLine()) return 1;
+ if (InitCache()) return 1;
+ if (InitModuleNames()) return 1;
+ if (InitContacts()) return 1;
+ if (InitSettings()) return 1;
+ if (InitEvents()) return 1;
return 0;
}
-static DWORD DatabaseCorrupted=0;
+static DWORD DatabaseCorrupted = 0;
void __cdecl dbpanic(void *arg)
{
@@ -121,10 +116,10 @@ void __cdecl dbpanic(void *arg) void DatabaseCorruption(void)
{
- int kill=0;
+ int kill = 0;
EnterCriticalSection(&csDbAccess);
- if (DatabaseCorrupted==0) {
+ if (DatabaseCorrupted == 0) {
DatabaseCorrupted++;
kill++;
} else {
@@ -151,7 +146,7 @@ void DBLog(const char *file,int line,const char *fmt,...) va_start(vararg,fmt);
mir_vsnprintf(str,sizeof(str),fmt,vararg);
va_end(vararg);
- fp=fopen("c:\\mirandadatabase.log.txt","at");
+ fp = fopen("c:\\mirandadatabase.log.txt","at");
fprintf(fp,"%u: %s %d: %s\n",GetTickCount(),file,line,str);
fclose(fp);
}
|