[sword-cvs] swordreader/src/Dll1/winceSword/src swwinlog.cpp,NONE,1.1 dirent.cpp,1.3,1.4 swordce.cpp,1.2,1.3 unistd.cpp,1.4,1.5

sword@www.crosswire.org sword@www.crosswire.org
Tue, 20 Jan 2004 23:15:35 -0700


Update of /cvs/core/swordreader/src/Dll1/winceSword/src
In directory www:/tmp/cvs-serv16861/src/Dll1/winceSword/src

Modified Files:
	dirent.cpp swordce.cpp unistd.cpp 
Added Files:
	swwinlog.cpp 
Log Message:
no message

--- NEW FILE: swwinlog.cpp ---
#include "swwinlog.h"
#include <stdio.h>
#include <stdarg.h>
#include <swordce.h>
#include <swlog.h>

SWORD_NAMESPACE_START


// can't do this in main app cuz static class exports are not
// really exported???

class __staticsystemwinlog {
public:
	__staticsystemwinlog() {
		delete SWLog::systemlog;
		SWLog::systemlog = new SWWinLog(0);
	}
} _staticsystemwinlog;

// ---------------------------------------------------------


SWWinLog::SWWinLog(HWND iparent) : SWLog() {
	parent = iparent;
}

 
void SWWinLog::LogWarning(char *fmt, ...)
{
	char msg[2048];
	va_list argptr;

	if (logLevel >= 2) {
		va_start(argptr, fmt);
		vsprintf(msg, fmt, argptr);
		va_end(argptr);

		MessageBox(parent, strtowstr(msg), L"Warning", MB_OK);
	}
}


void SWWinLog::LogError(char *fmt, ...)
{
	char msg[2048];
	va_list argptr;

	if (logLevel) {
		va_start(argptr, fmt);
		vsprintf(msg, fmt, argptr);
		va_end(argptr);

		MessageBox(parent, strtowstr(msg), L"Error", MB_OK);
	}
}


void SWWinLog::LogTimedInformation(char *fmt, ...)
{
	char msg[2048];
	va_list argptr;

	if (logLevel >= 4) {
		va_start(argptr, fmt);
		vsprintf(msg, fmt, argptr);
		va_end(argptr);

		MessageBox(parent, strtowstr(msg), L"Information...", MB_OK);

	}
}


void SWWinLog::LogInformation(char *fmt, ...)
{
	char msg[2048];
	va_list argptr;

	if (logLevel >= 3) {
		va_start(argptr, fmt);
		vsprintf(msg, fmt, argptr);
		va_end(argptr);

		MessageBox(parent, strtowstr(msg), L"Information", MB_OK);
	}
}

SWORD_NAMESPACE_END

Index: dirent.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/Dll1/winceSword/src/dirent.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dirent.cpp	18 Jan 2004 07:00:29 -0000	1.3
+++ dirent.cpp	21 Jan 2004 06:15:33 -0000	1.4
@@ -7,7 +7,7 @@
 using sword::SWBuf;
 
 DIR* opendir(const char *pSpec) {
-	DIR *pDir = (DIR*) malloc(sizeof(DIR));
+	DIR *pDir = new DIR;
 	pDir->dirPath = new SWBuf();
 	*(pDir->dirPath) = windizePath(pSpec);
 	*(pDir->dirPath) += "\\*";
@@ -17,14 +17,18 @@
 
 
 void closedir(DIR * pDir) {
+//MessageBox(0,L"closedir",L"STAGE",MB_OK|MB_ICONERROR);
 	FindClose( pDir->hFind );
 	delete pDir->dirPath;
-    free(pDir);
+    delete pDir;
 }
 
 
 struct dirent* readdir(DIR *pDir) {
 	if (pDir->hFind) {
+//MessageBox(0,pDir->wfd.cFileName,L"readdir returning",MB_OK|MB_ICONERROR);
+//strcpy(pDir->de.d_name, "whnu.conf");
+//strcpy(pDir->de.d_name, wstrtostr(L"whnu.conf"));
 		strcpy(pDir->de.d_name, wstrtostr(pDir->wfd.cFileName));
 		if ( !FindNextFile(pDir->hFind, &(pDir->wfd)) )
 			pDir->hFind = NULL;
@@ -37,6 +41,7 @@
 
 
 void rewinddir(DIR* dir) {
+//MessageBox(0,L"rewinddir",L"STAGE",MB_OK|MB_ICONERROR);
 	dir->hFind = FindFirstFile(strtowstr(dir->dirPath->c_str()), &(dir->wfd));
 }
 

Index: swordce.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/Dll1/winceSword/src/swordce.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- swordce.cpp	17 Jan 2004 02:57:42 -0000	1.2
+++ swordce.cpp	21 Jan 2004 06:15:33 -0000	1.3
@@ -1,5 +1,6 @@
 #include <swordce.h>
 #include <swbuf.h>
+#include <windows.h>
 
 using sword::SWBuf;
 // TODO: from the DLL entry point, figure out the path
@@ -27,7 +28,7 @@
   static char *c, *buffer = 0;
   if (buffer)
     delete [] buffer;
-  buffer = c = new char[ strlen((const char*)str2) + 1 ];
+  buffer = c = new char[ wcslen(str2) + 1 ];
   while (*str2)
     *c++ = (char)*str2++;
   *c = 0;
@@ -37,6 +38,7 @@
 
 const char *windizePath(const char *path) {
 	static SWBuf retVal = "";
+	retVal = "";
 	if ((*path != '/') && (*path != '\\'))
 		retVal = getWorkingDirectory();
 	retVal += "/";

Index: unistd.cpp
===================================================================
RCS file: /cvs/core/swordreader/src/Dll1/winceSword/src/unistd.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- unistd.cpp	17 Jan 2004 19:13:14 -0000	1.4
+++ unistd.cpp	21 Jan 2004 06:15:33 -0000	1.5
@@ -11,6 +11,7 @@
 
 
 int close (int fd) {
+//MessageBox(0,L"close",L"STAGE",MB_OK|MB_ICONERROR);
 	if (fd > 0) {
 	  CloseHandle(*(HANDLE *)fd);
 	  delete (HANDLE *)fd;
@@ -21,6 +22,7 @@
 
 
 int open(const char *path, int mode) {
+//MessageBox(0,strtowstr(path),L"open",MB_OK|MB_ICONERROR);
   const char *winPath = windizePath(path);
   DWORD access = 0;
   DWORD create = OPEN_EXISTING;