added init and deinit functions and windows unicode fixes

ulab-original
jsorg71 17 years ago
parent 668c704a16
commit d5a89b8ce1

@ -56,6 +56,7 @@
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <locale.h>
#include "os_calls.h" #include "os_calls.h"
#include "arch.h" #include "arch.h"
@ -74,6 +75,27 @@ extern char** environ;
#define INADDR_NONE ((unsigned long)-1) #define INADDR_NONE ((unsigned long)-1)
#endif #endif
/*****************************************************************************/
void APP_CC
g_init(void)
{
#if defined(_WIN32)
WSADATA wsadata;
WSAStartup(2, &wsadata);
#endif
setlocale(LC_CTYPE, "");
}
/*****************************************************************************/
void APP_CC
g_deinit(void)
{
#if defined(_WIN32)
WSACleanup();
#endif
}
/*****************************************************************************/ /*****************************************************************************/
/* allocate memory, returns a pointer to it, size bytes are allocated, /* allocate memory, returns a pointer to it, size bytes are allocated,
if zero is non zero, each byte will be set to zero */ if zero is non zero, each byte will be set to zero */
@ -641,7 +663,7 @@ int APP_CC
g_file_open(const char* file_name) g_file_open(const char* file_name)
{ {
#if defined(_WIN32) #if defined(_WIN32)
return (int)CreateFile(file_name, GENERIC_READ | GENERIC_WRITE, return (int)CreateFileA(file_name, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
#else #else
@ -818,7 +840,7 @@ char* APP_CC
g_get_current_dir(char* dirname, int maxlen) g_get_current_dir(char* dirname, int maxlen)
{ {
#if defined(_WIN32) #if defined(_WIN32)
GetCurrentDirectory(maxlen, dirname); GetCurrentDirectoryA(maxlen, dirname);
return 0; return 0;
#else #else
getcwd(dirname, maxlen); getcwd(dirname, maxlen);
@ -832,7 +854,7 @@ int APP_CC
g_set_current_dir(char* dirname) g_set_current_dir(char* dirname)
{ {
#if defined(_WIN32) #if defined(_WIN32)
if (SetCurrentDirectory(dirname)) if (SetCurrentDirectoryA(dirname))
{ {
return 0; return 0;
} }
@ -885,7 +907,7 @@ int APP_CC
g_create_dir(const char* dirname) g_create_dir(const char* dirname)
{ {
#if defined(_WIN32) #if defined(_WIN32)
return CreateDirectory(dirname, 0); // test this return CreateDirectoryA(dirname, 0); // test this
#else #else
return mkdir(dirname, (mode_t)-1) == 0; return mkdir(dirname, (mode_t)-1) == 0;
#endif #endif
@ -897,7 +919,7 @@ int APP_CC
g_remove_dir(const char* dirname) g_remove_dir(const char* dirname)
{ {
#if defined(_WIN32) #if defined(_WIN32)
return RemoveDirectory(dirname); // test this return RemoveDirectoryA(dirname); // test this
#else #else
return rmdir(dirname) == 0; return rmdir(dirname) == 0;
#endif #endif
@ -909,7 +931,7 @@ int APP_CC
g_file_delete(const char* filename) g_file_delete(const char* filename)
{ {
#if defined(_WIN32) #if defined(_WIN32)
return DeleteFile(filename); return DeleteFileA(filename);
#else #else
return unlink(filename) != -1; return unlink(filename) != -1;
#endif #endif
@ -1057,7 +1079,7 @@ long APP_CC
g_load_library(char* in) g_load_library(char* in)
{ {
#if defined(_WIN32) #if defined(_WIN32)
return (long)LoadLibrary(in); return (long)LoadLibraryA(in);
#else #else
return (long)dlopen(in, RTLD_LOCAL | RTLD_LAZY); return (long)dlopen(in, RTLD_LOCAL | RTLD_LAZY);
#endif #endif

@ -27,6 +27,10 @@
#include "arch.h" #include "arch.h"
void APP_CC
g_init(void);
void APP_CC
g_deinit(void);
void* APP_CC void* APP_CC
g_malloc(int size, int zero); g_malloc(int size, int zero);
void APP_CC void APP_CC

Loading…
Cancel
Save