* src/lib/Evil.h:

declare pid_t, ssize_t and mode_t for vc++ before flock
structure (vc++)
* src/lib/dlfcn/dlfcn.h:
include limits.h for vc++
* src/lib/evil.c: (symlink), (readlink):
use UNICODE instead of checking the OS. Use PATH_MAX instead
of MB_CUR_MAX when needed


SVN revision: 35098
This commit is contained in:
doursse 2008-07-13 17:34:53 +00:00 committed by doursse
parent 04249c53e6
commit 52fbecb588
4 changed files with 42 additions and 7 deletions

View File

@ -1,3 +1,15 @@
2008-07-13 Vincent Torri <doursse at users dot sf dot net>
* src/lib/Evil.h:
declare pid_t, ssize_t and mode_t for vc++ before flock
structure (vc++)
* src/lib/dlfcn/dlfcn.h:
include limits.h for vc++
* src/lib/evil.c: (symlink), (readlink):
use UNICODE instead of checking the OS. Use PATH_MAX instead
of MB_CUR_MAX when needed
2008-07-03 Vincent Torri <doursse at users dot sf dot net>
* src/lib/Evil.h:

View File

@ -130,6 +130,14 @@ extern "C" {
# define F_UNLCK 2
# endif /* ! F_RDLCK */
#ifdef _MSC_VER
typedef int pid_t;
typedef long ssize_t;
typedef unsigned short mode_t;
#endif /* _MSC_VER */
/**
* @struct flock
* @brief A structure that control the lock of a file descriptor.
@ -560,10 +568,6 @@ typedef unsigned long gid_t;
#ifdef _MSC_VER
typedef int pid_t;
typedef long ssize_t;
typedef unsigned short mode_t;
#define F_OK 0 /* Check for file existence */
#define X_OK 1 /* MS access() doesn't check for execute permission. */
#define W_OK 2 /* Check for write permission */

View File

@ -2,6 +2,12 @@
#define __EVIL_DLFCN_H__
#ifdef _MSC_VER
# define _POSIX_
# include <limits.h>
# undef _POSIX_
#endif /* _MSC_VER */
#if defined(__CEGCC__) || defined(__MINGW32CE__)
# include <sys/syslimits.h>
#else

View File

@ -162,7 +162,9 @@ getpwuid (uid_t uid)
int
symlink(const char *oldpath, const char *newpath)
{
#ifdef UNICODE
wchar_t new_path[MB_CUR_MAX];
#endif /* UNICODE */
IShellLink *pISL;
IShellLink **shell_link;
IPersistFile *pIPF;
@ -194,10 +196,14 @@ symlink(const char *oldpath, const char *newpath)
if (FAILED(pISL->lpVtbl->QueryInterface(pISL, &IID_IPersistFile, (void **)persit_file)))
goto no_queryinterface;
/* FIXME: is it for cegcc ??? */
#ifdef UNICODE
mbstowcs(new_path, newpath, MB_CUR_MAX);
if (FAILED(pIPF->lpVtbl->Save(pIPF, new_path, FALSE)))
goto no_save;
#else
if (FAILED(pIPF->lpVtbl->Save(pIPF, newpath, FALSE)))
goto no_save;
#endif /* ! UNICODE */
pIPF->lpVtbl->Release(pIPF);
pISL->lpVtbl->Release(pISL);
@ -218,8 +224,10 @@ symlink(const char *oldpath, const char *newpath)
ssize_t
readlink(const char *path, char *buf, size_t bufsiz)
{
#ifdef UNICODE
wchar_t old_path[MB_CUR_MAX];
char new_path[MB_CUR_MAX];
#endif /* UNICODE */
char new_path[PATH_MAX];
IShellLink *pISL;
IShellLink **shell_link;
IPersistFile *pIPF;
@ -244,15 +252,20 @@ readlink(const char *path, char *buf, size_t bufsiz)
(void **)persit_file)))
goto no_instance;
#ifdef UNICODE
mbstowcs(old_path, path, MB_CUR_MAX);
if (FAILED(pIPF->lpVtbl->Load(pIPF, old_path, STGM_READWRITE)))
goto no_load;
#else
if (FAILED(pIPF->lpVtbl->Load(pIPF, path, STGM_READWRITE)))
goto no_load;
#endif /* ! UNICODE */
shell_link = &pISL;
if (FAILED(pIPF->lpVtbl->QueryInterface(pIPF, &IID_IShellLink, (void **)shell_link)))
goto no_queryinterface;
if (FAILED(pISL->lpVtbl->GetPath(pISL, new_path, MB_CUR_MAX, NULL, 0)))
if (FAILED(pISL->lpVtbl->GetPath(pISL, new_path, PATH_MAX, NULL, 0)))
goto no_getpath;
length = strlen(new_path);