reviewed by: <delete if not using a buddy>

patch by: <delete if not someone else's patch>
	* src/lib/Evil.h:
	* src/lib/Makefile.am:
	* src/lib/evil_private.h:
	* src/lib/evil_stdio.c:
	* src/lib/evil_stdio.h:
	* src/lib/evil_stdlib.c:
	* src/lib/evil_unistd.c:
	* src/lib/evil_util.c:



SVN revision: 37046
This commit is contained in:
Vincent Torri 2008-10-24 07:32:08 +00:00
parent 71f14d8463
commit de07e9bad9
9 changed files with 98 additions and 30 deletions

View File

@ -1,3 +1,22 @@
2008-10-24 Vincent Torri <doursse at users dot sf dot net>
* src/lib/Makefile.am:
* src/lib/evil_util.c:
* src/lib/evil_private.h:
move _evil_stdlib_error_display() from evil_stdlib.c
to evil_util.c and rename it to _evil_error_display()
* src/lib/evil_stdlib.c:
* src/lib/evil_unistd.c:
use _evil_error_display()
* src/lib/Evil.h:
overload fopen for mingw32ce
* src/lib/evil_stdio.c:
* src/lib/evil_stdio.h:
add evil_open to overload fopen (for mingw32ce
2008-10-22 Vincent Torri <doursse at users dot sf dot net>
* configure.ac:

View File

@ -149,6 +149,10 @@ typedef unsigned long gid_t;
#define pipe(fd) evil_pipe(fd)
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
# define fopen(path, mode) evil_fopen(path, mode)
#endif /* _WIN32_WCE && ! __CEGCC__ */
#ifdef __cplusplus
}

View File

@ -43,4 +43,4 @@ libevil_la_CFLAGS = @win32_cflags@
libevil_la_LIBADD = @win32_libs@ $(EFL_MPATROL_LIBS)
libevil_la_LDFLAGS = -no-undefined -Wl,--enable-auto-import -version-info @version_info@
EXTRA_DIST = evil_fnmatch_private.h
EXTRA_DIST = evil_private.h evil_fnmatch_private.h

View File

@ -0,0 +1,8 @@
#ifndef __EVIL_PRIVATE_H__
#define __EVIL_PRIVATE_H__
void _evil_error_display(LONG res);
#endif /* __EVIL_PRIVATE_H__ */

View File

@ -4,9 +4,10 @@
#endif /* HAVE_CONFIG_H */
#include "Evil.h"
#undef fopen
#ifdef __MINGW32CE__
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
/*
* Error related functions
@ -23,9 +24,42 @@ void perror (const char *s)
*
*/
FILE *evil_fopen(const char *path, const char *mode)
{
FILE *f;
char *filename;
if (*path != '\\')
{
char buf[PATH_MAX];
int l1;
int l2;
if (!evil_getcwd(buf, PATH_MAX))
return NULL;
l1 = strlen(buf);
l2 = strlen(path);
filename = (char *)malloc(l1 + 1 + l2 + 1);
memcpy(filename, buf, l1);
filename[l1] = '\\';
memcpy(filename + l1 + 1, path, l2);
filename[l1 + 1 + l2] = '\0';
}
else
filename = (char *)path;
f = fopen(filename, mode);
if (*path != '\\')
free(filename);
return f;
}
void rewind(FILE *stream)
{
fseek(stream, 0, SEEK_SET);
}
#endif /* __MINGW32CE__ */
#endif /* _WIN32_WCE && ! __CEGCC__ */

View File

@ -2,7 +2,7 @@
#define __EVIL_STDIO_H__
#ifdef __MINGW32CE__
#if defined (_WIN32_WCE) && ! defined (__CEGCC__)
#include <stdio.h>
@ -19,9 +19,11 @@ EAPI void perror (const char *s);
*
*/
EAPI FILE *evil_fopen(const char *path, const char *mode);
EAPI void rewind(FILE *stream);
#endif /* __MINGW32CE__ */
#endif /* _WIN32_WCE && ! __CEGCC__ */
#endif /* __EVIL_STDIO_H__ */

View File

@ -16,19 +16,7 @@
#undef WIN32_LEAN_AND_MEAN
#include "Evil.h"
/*** Local ***/
static void
_evil_stdlib_error_display(const char *fct,
LONG res)
{
char *error;
error = evil_format_message(res);
fprintf(stderr, "[Evil] [%s] ERROR: %s\n", fct, error);
free(error);
}
#include "evil_private.h"
/*
* Environment variable related functions
@ -61,7 +49,7 @@ getenv(const char *name)
0, 0,
&key)) != ERROR_SUCCESS)
{
_evil_stdlib_error_display("getenv", res);
_evil_error_display(res);
return NULL;
}
@ -69,7 +57,7 @@ getenv(const char *name)
if (!wname)
{
if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
_evil_stdlib_error_display("getenv", res);
_evil_error_display(res);
return NULL;
}
@ -78,9 +66,8 @@ getenv(const char *name)
(LPBYTE)&_evil_stdlib_getenv_buffer,
&size)) != ERROR_SUCCESS)
{
_evil_stdlib_error_display("getenv", res);
if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
_evil_stdlib_error_display("getenv", res);
_evil_error_display(res);
free(wname);
return NULL;
}
@ -89,7 +76,7 @@ getenv(const char *name)
if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
{
_evil_stdlib_error_display("getenv", res);
_evil_error_display(res);
return NULL;
}
@ -206,7 +193,7 @@ setenv(const char *name,
&key,
&disposition)) != ERROR_SUCCESS)
{
_evil_stdlib_error_display("setenv", res);
_evil_error_display(res);
return -1;
}
@ -218,7 +205,7 @@ setenv(const char *name,
if (!wname)
{
if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
_evil_stdlib_error_display("setenv", res);
_evil_error_display(res);
return -1;
}
@ -229,9 +216,9 @@ setenv(const char *name,
strlen(value) + 1)) != ERROR_SUCCESS)
{
free(wname);
_evil_stdlib_error_display("setenv", res);
_evil_error_display(res);
if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
_evil_stdlib_error_display("setenv", res);
_evil_error_display(res);
return -1;
}
@ -239,7 +226,7 @@ setenv(const char *name,
if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
{
_evil_stdlib_error_display("setenv", res);
_evil_error_display(res);
return -1;
}

View File

@ -18,6 +18,7 @@
#endif
#include "Evil.h"
#include "evil_private.h"
/*
* Process identifer related functions
@ -251,7 +252,7 @@ evil_getcwd(char *buffer, size_t size)
wchar_t wpath[PATH_MAX];
char *cpath;
char *delim;
int ret = 0;
DWORD ret = 0;
if (size <= 0)
return NULL;
@ -259,7 +260,10 @@ evil_getcwd(char *buffer, size_t size)
ret = GetModuleFileName(GetModuleHandle(NULL), (LPWSTR)&wpath, PATH_MAX);
if (!ret)
return NULL;
{
_evil_error_display(ret);
return NULL;
}
cpath = evil_wchar_to_char(wpath);
if (!cpath)

View File

@ -92,6 +92,16 @@ evil_format_message(long err)
return disp;
}
void
_evil_error_display(LONG res)
{
char *error;
error = evil_format_message(res);
fprintf(stderr, "[Evil] [%s] ERROR: %s\n", __FUNCTION__, error);
free(error);
}
char *
evil_last_error_get(void)
{