#if defined(__unix__) || defined(__APPLE__)
#define bool _bool
#include <utime.h>
+#if !defined(__pnacl__)
#include <dlfcn.h>
+#endif
#if defined(__APPLE__)
#include <mach-o/dyld.h>
#endif
#undef bool
#endif
-#if defined(__WIN32__)
+#if defined(__WIN32__) && !defined(__EMSCRIPTEN__)
#define WIN32_LEAN_AND_MEAN
#define UNICODE
#include <windows.h>
#define MAX_FILENAME 274
#define MAX_EXTENSION 17
-#if defined(__WIN32__)
+#if defined(__MINGW32__) && !defined(_W64) && __GNUC__ < 4
+__declspec(dllexport) int isblank(int c) { return c == '\t' || c == ' '; }
+#endif
+
+#if defined(__WIN32__) && !defined(__EMSCRIPTEN__)
intptr_t stdinHandle, stdoutHandle;
int osfStdin, osfStdout;
FILE * fStdIn, * fStdOut;
#endif
FILE *eC_stdin(void) {
-#if defined(__WIN32__)
+#if defined(__WIN32__) && !defined(__EMSCRIPTEN__)
if(!fStdIn)
{
stdinHandle = (intptr_t)GetStdHandle(STD_INPUT_HANDLE);
void * __ecereNameSpace__ecere__com__eSystem_New0(unsigned int size);
void * __ecereNameSpace__ecere__com__eSystem_Renew(void * memory, unsigned int size);
void * __ecereNameSpace__ecere__com__eSystem_Renew0(void * memory, unsigned int size);
-unsigned short * __ecereNameSpace__ecere__sys__UTF8toUTF16(char * source, int * wordCount);
-unsigned short * __ecereNameSpace__ecere__sys__UTF8toUTF16Buffer(char * source, uint16 * dest, int max);
+unsigned short * __ecereNameSpace__ecere__sys__UTF8toUTF16(const char * source, int * wordCount);
+unsigned short * __ecereNameSpace__ecere__sys__UTF8toUTF16Buffer(const char * source, uint16 * dest, int max);
char * __ecereNameSpace__ecere__sys__UTF16toUTF8(uint16 * source);
-char * __ecereNameSpace__ecere__sys__UTF16toUTF8Buffer(uint16 * source, byte * dest, int max);
+char * __ecereNameSpace__ecere__sys__UTF16toUTF8Buffer(uint16 * source, char * dest, int max);
#define eSystem_Delete __ecereNameSpace__ecere__com__eSystem_Delete
#define eSystem_New0 __ecereNameSpace__ecere__com__eSystem_New0
#define forArgsPassing 2
int __ecereNameSpace__ecere__sys__Tokenize(char * string, int maxTokens, char* tokens[], int esc);
-char * __ecereNameSpace__ecere__sys__RSearchString(char * buffer, char * subStr, int maxLen, bool matchCase, bool matchWord);
-char * __ecereNameSpace__ecere__sys__GetLastDirectory(char * string, char * output);
-char * __ecereNameSpace__ecere__sys__PathCat(char * string, char * addedPath);
-char * __ecereNameSpace__ecere__sys__GetExtension(char * string, char * output);
+char * __ecereNameSpace__ecere__sys__RSearchString(const char * buffer, const char * subStr, int maxLen, bool matchCase, bool matchWord);
+char * __ecereNameSpace__ecere__sys__GetLastDirectory(const char * string, char * output);
+char * __ecereNameSpace__ecere__sys__PathCat(char * string, const char * addedPath);
+char * __ecereNameSpace__ecere__sys__GetExtension(const char * string, char * output);
#define Tokenize __ecereNameSpace__ecere__sys__Tokenize
#define RSearchString __ecereNameSpace__ecere__sys__RSearchString
typedef enum { unknown, win32, tux, apple } Platform;
-#if defined(__WIN32__)
+#if defined(__WIN32__) && !defined(__EMSCRIPTEN__)
Platform runtimePlatform = win32;
#elif defined(__APPLE__)
Platform runtimePlatform = apple;
#endif
-bool Instance_LocateModule(char * name, char * fileName)
+bool Instance_LocateModule(const char * name, char * fileName)
{
-#if defined(__WIN32__)
+#if defined(__WIN32__) && !defined(__EMSCRIPTEN__)
HMODULE hModule = null;
if(name && name[0])
{
{
uint16 _wfileName[MAX_LOCATION];
GetModuleFileNameW(hModule, _wfileName, MAX_LOCATION);
- UTF16toUTF8Buffer(_wfileName, (byte *)fileName, MAX_LOCATION);
+ UTF16toUTF8Buffer(_wfileName, fileName, MAX_LOCATION);
return true;
}
}
{
uint16 _wfileName[MAX_LOCATION];
GetModuleFileNameW(null, _wfileName, MAX_LOCATION);
- UTF16toUTF8Buffer(_wfileName, (byte *)fileName, MAX_LOCATION);
+ UTF16toUTF8Buffer(_wfileName, fileName, MAX_LOCATION);
return true;
}
#elif defined(__APPLE__)
}
#elif defined(__unix__)
//File f = FileOpen("/proc/self/maps", read);
- FILE * f;
+ FILE * f = null;
char exeName[MAX_FILENAME];
exeName[0] = 0;
#if defined(__linux__)
}
fclose(f);
}
-#if !defined(ECERE_NOFILE) && !defined(__linux__)
+#if !defined(ECERE_NOFILE) && !defined(__linux__) && !defined(__EMSCRIPTEN__) && !defined(__pnacl__)
if(name && name[0])
{
// Couldn't locate libraries with /proc/curmap/map, attempt with ldd
return false;
}
-void Instance_COM_Initialize(int argc, char ** argv, char ** parsedCommand, int * argcPtr, char *** argvPtr)
+void Instance_COM_Initialize(int argc, char ** argv, char ** parsedCommand, int * argcPtr, const char *** argvPtr)
{
-#if !defined(__WIN32__) && !defined(ECERE_BOOTSTRAP)
+#if !defined(__WIN32__) && !defined(__EMSCRIPTEN__) && !defined(ECERE_BOOTSTRAP) && !defined(__pnacl__)
// Disable stdout buffering on Unix
setvbuf(stdout, null, _IONBF, 0);
#endif
-#if defined(__WIN32__)
+#if defined(__WIN32__) && !defined(__EMSCRIPTEN__)
*parsedCommand = UTF16toUTF8(GetCommandLineW());
*argvPtr = eSystem_New0(sizeof(char *) * 512);
*argcPtr = Tokenize(*parsedCommand, 512,(void*)(char **)(*argvPtr), forArgsPassing);
#else
*argcPtr = argc;
- *argvPtr = argv;
+ *argvPtr = (const char **)argv;
#endif
#if defined(__unix__)
if(!__thisModule && argv)
{
- getcwd(exeLocation, MAX_LOCATION);
+ if(!getcwd(exeLocation, MAX_LOCATION))
+ exeLocation[0] = 0;
PathCat(exeLocation, argv[0]);
}
#endif
*Load = null;
*Unload = null;
-#if defined(__WIN32__)
+#if defined(__WIN32__) && !defined(__EMSCRIPTEN__)
strcpy(fileName, name);
GetExtension(fileName, extension);
if(!extension[0])
strcat(fileName, ".so");
#endif
+#if !defined(__EMSCRIPTEN__) && !defined(__pnacl__)
library = dlopen(fileName, RTLD_LAZY);
+#endif
while(!library && attempts < sizeof(paths)/sizeof(paths[0]))
{
if(paths[attempts])
#else
strcat(fileName, ".so");
#endif
+#if !defined(__EMSCRIPTEN__) && !defined(__pnacl__)
library = dlopen(fileName, RTLD_LAZY);
+#endif
}
if(library)
{
*Load = dlsym(library, "__ecereDll_Load");
*Unload = dlsym(library, "__ecereDll_Unload");
+#if !defined(__EMSCRIPTEN__) && !defined(__pnacl__)
if(!*Load)
dlclose(library);
+#endif
}
#elif defined(__APPLE__)
if(libLocation || strchr(name, '/'))
void Instance_Module_Free(void * library)
{
-#if defined(__WIN32__)
+#if defined(__WIN32__) && !defined(__EMSCRIPTEN__)
if(library)
FreeLibrary(library);
-#elif defined(__unix__) || defined(__APPLE__)
+#elif (defined(__unix__) || defined(__APPLE__)) && !defined(__EMSCRIPTEN__) && !defined(__pnacl__)
if(library)
dlclose(library);
#endif