* AUTHORS:

mention Tor's contribution
	* configure.ac:
	mention m4 directory, check errno header file,
	add conditionnal when mingw32ce is used, minor
	formatting
	* m4/efl_doxygen.m4:
	fix comments
	* src/lib/Makefile.am:
	include fnmatch files only when mingw32ce is used
	* src/lib/evil_fcntl.c:
	define correctly _get_osfhandle on mingw32ce
	* src/lib/evil_pwd.c:
	fix getpwuid() when cegcc or mingw32ce are used
	* src/lib/evil_stdlib.c:
	fix mkstemp() on all Windows platform, guard errno stuff
	* src/lib/evil_stdlib.h:
	template -> __template because 'template ' is a c++ keyword.
	* src/lib/evil_unistd.c:
	guard errno stuff
	* src/lib/evil_fnmatch.c:
	* src/lib/evil_fnmatch_list_of_states.c:
	* src/lib/evil_fnmatch_private.h:
	* src/lib/fnmatch.h:
	added files
	* win32/common/fnmatch.c:
	* win32/common/fnmatch.h:
	* win32/common/fnmatch_list_of_states.c:
	* win32/common/fnmatch_private.h:
	removed files



SVN revision: 36555
This commit is contained in:
Vincent Torri 2008-10-09 21:56:31 +00:00
parent 82e185693f
commit 85ffa791af
15 changed files with 281 additions and 129 deletions

View File

@ -1,4 +1,4 @@
Main Authors:
Vincent Torri <vtorri at univ-evry dot fr>
Tor Lillqvist <tml at iki dot fi>
Tor Lillqvist <tml at iki dot fi> (pipe function)
ashikase

View File

@ -1,3 +1,46 @@
2008-10-09 Vincent Torri <doursse at users dot sf dot net>
* AUTHORS:
mention Tor's contribution
* configure.ac:
mention m4 directory, check errno header file,
add conditionnal when mingw32ce is used, minor
formatting
* m4/efl_doxygen.m4:
fix comments
* src/lib/Makefile.am:
include fnmatch files only when mingw32ce is used
* src/lib/evil_fcntl.c:
define correctly _get_osfhandle on mingw32ce
* src/lib/evil_pwd.c:
fix getpwuid() when cegcc or mingw32ce are used
* src/lib/evil_stdlib.c:
fix mkstemp() on all Windows platform, guard errno stuff
* src/lib/evil_stdlib.h:
template -> __template because 'template ' is a c++ keyword.
* src/lib/evil_unistd.c:
guard errno stuff
* src/lib/evil_fnmatch.c:
* src/lib/evil_fnmatch_list_of_states.c:
* src/lib/evil_fnmatch_private.h:
* src/lib/fnmatch.h:
added files
* win32/common/fnmatch.c:
* win32/common/fnmatch.h:
* win32/common/fnmatch_list_of_states.c:
* win32/common/fnmatch_private.h:
removed files
2008-10-05 Vincent Torri <doursse at users dot sf dot net>
* m4:

View File

@ -2,6 +2,7 @@
AC_INIT([evil], [0.0.1], [enlightenment-devel@lists.sourceforge.net])
AC_PREREQ([2.52])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_HOST
@ -36,10 +37,10 @@ case "$host_os" in
mingw | mingw32 | mingw32msvc)
win32_libs="-lole32 -luuid -lws2_32"
;;
cegcc)
cegcc*)
win32_libs="-lws2"
;;
mingw32ce)
mingw32ce*)
win32_libs="-lws2"
;;
esac
@ -49,6 +50,7 @@ EFL_CHECK_MPATROL([have_mpatrol="yes"], [have_mpatrol="no"])
### Checks for header files
AC_CHECK_HEADERS_ONCE([errno.h])
### Checks for programs
@ -73,13 +75,16 @@ AC_C_CONST
AC_C___ATTRIBUTE__
win32_cflags=""
have_wince="no"
have_mingw32ce="no"
case "$host_os" in
cegcc)
cegcc*)
have_wince="yes"
win32_cflags="-mwin32"
;;
mingw32ce)
mingw32ce*)
have_wince="yes"
have_mingw32ce="yes"
;;
*)
have_wince="no"
@ -92,6 +97,7 @@ if test "x${have_wince}" = "xyes" ; then
fi
AM_CONDITIONAL(EVIL_HAVE_WINCE, test "x${have_wince}" = "xyes")
AM_CONDITIONAL(EVIL_HAVE_MINGW32CE, test "x${have_mingw32ce}" = "xyes")
### Checks for linker characteristics

View File

@ -1,8 +1,12 @@
dnl Configure script for doxygen
dnl Vincent Torri 2008-08-25
dnl
dnl Copyright (C) 2008 Vincent Torri <vtorri at univ-evry dot fr>
dnl That code is public domain and can be freely used or copied.
dnl Macro that check if doxygen is available or not.
dnl EFL_CHECK_DOXYGEN([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for the doxygen program, and define DOXYGEN.
dnl Test for the doxygen program
dnl Defines DOXYGEN
dnl Defines the automake conditionnal EFL_BUILD_DOC
dnl
AC_DEFUN([EFL_CHECK_DOXYGEN],
[

View File

@ -15,6 +15,12 @@ evil_util.h
nobase_include_HEADERS = pwd.h sys/mman.h
if EVIL_HAVE_MINGW32CE
nobase_include_HEADERS += fnmatch.h
endif
libevil_la_SOURCES = \
evil.c \
evil_fcntl.c \
@ -25,7 +31,13 @@ evil_stdlib.c \
evil_unistd.c \
evil_util.c
libevil_la_CPPFLAGS = -DEFL_EVIL_BUILD
if EVIL_HAVE_MINGW32CE
libevil_la_SOURCES += evil_fnmatch.c evil_fnmatch_list_of_states.c
endif
libevil_la_CPPFLAGS = -DEFL_EVIL_BUILD -D_WIN32_WCE=0x0420
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@

View File

@ -12,12 +12,19 @@
#include "Evil.h"
#if defined(__CEGCC__)
# define _get_osfhandle get_osfhandle
# elif defined (__MINGW32CE__)
# define _get_osfhandle(FILEDES) ((HANDLE)FILEDES)
#endif /* ! __CEGCC__ && ! __MINGW32CE__ */
/*
* port of fcntl function
*
*/
#ifndef __CEGCC__
#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) )
int fcntl(int fd, int cmd, ...)
{
@ -79,4 +86,4 @@ int fcntl(int fd, int cmd, ...)
return res;
}
#endif /* ! __CEGCC__ */
#endif /* __CEGCC__ || __MINGW32CE__ */

View File

@ -2,20 +2,20 @@
#include <string.h>
#include "fnmatch.h"
#include "fnmatch_private.h"
#include "evil_fnmatch_private.h"
enum fnmatch_status
{
fnmatch_not_found = 0,
fnmatch_found = 1,
fnmatch_syntax_error = 2
};
{
fnmatch_not_found = 0,
fnmatch_found = 1,
fnmatch_syntax_error = 2
};
static
size_t
fnmatch_match_class_token(enum fnmatch_status *status,
const char *class_token,
char c)
fnmatch_match_class_token(enum fnmatch_status *status,
const char *class_token,
char c)
{
if (! *class_token)
{
@ -55,12 +55,12 @@ fnmatch_complement_class(const char *class_token)
static
size_t
fnmatch_match_class(const char *class,
char c)
fnmatch_match_class(const char *class,
char c)
{
const size_t complement = fnmatch_complement_class(class + 1);
enum fnmatch_status status;
size_t pos;
const size_t complement = fnmatch_complement_class(class + 1);
enum fnmatch_status status;
size_t pos;
if (complement == FNM_SYNTAXERR)
return FNM_SYNTAXERR;
@ -83,7 +83,8 @@ fnmatch_match_class(const char *class,
static
size_t
fnmatch_chrcasecmp(char a, char b)
fnmatch_chrcasecmp(char a,
char b)
{
if ('A' <= a && a <= 'Z')
a += 'a' - 'A';
@ -94,10 +95,10 @@ fnmatch_chrcasecmp(char a, char b)
static
size_t
fnmatch_match_token(const char *token,
char c,
_Bool leading,
int flags)
fnmatch_match_token(const char *token,
char c,
e_bool leading,
int flags)
{
if (*token == '\\' && !(flags & FNM_NOESCAPE))
return token[1] ? (token[1] == c ? 2 : 0) : FNM_SYNTAXERR;
@ -135,37 +136,37 @@ fnmatch_init_states(struct list_of_states *states)
static
size_t
fnmatch_check_finals(const char *pattern,
const struct list_of_states *states)
fnmatch_check_finals(const char *pattern,
const struct list_of_states *states)
{
size_t i, j;
for (i = 0; i < states->size; ++i)
{
_Bool match = 1;
for (i = 0; i < states->size; ++i)
{
e_bool match = 1;
for (j = states->states[i]; pattern[j]; ++j)
if (pattern[j] != '*')
{
match = 0;
break;
}
for (j = states->states[i]; pattern[j]; ++j)
if (pattern[j] != '*')
{
match = 0;
break;
}
if (match)
return 0;
}
return FNM_NOMATCH;
if (match)
return 0;
}
return FNM_NOMATCH;
}
int
fnmatch(const char *pattern,
const char *string,
int flags)
fnmatch(const char *pattern,
const char *string,
int flags)
{
struct list_of_states *states;
struct list_of_states *new_states;
_Bool leading = 1;
char* c;
size_t r;
struct list_of_states *states;
struct list_of_states *new_states;
e_bool leading = 1;
char *c;
size_t r;
assert(pattern);
assert(string);
@ -185,7 +186,7 @@ fnmatch(const char *pattern,
for (i = 0; i < states->size; ++i)
{
const size_t pos = states->states[i];
const size_t pos = states->states[i];
if (! pattern[pos])
{
@ -212,7 +213,7 @@ fnmatch(const char *pattern,
}
}
{
struct list_of_states *tmp = states;
struct list_of_states *tmp = states;
states = new_states;
new_states = tmp;

View File

@ -2,22 +2,23 @@
#include <stdlib.h>
#include <string.h>
#include "fnmatch_private.h"
#include "evil_fnmatch_private.h"
struct list_of_states*
fnmatch_list_of_states_alloc(size_t n, size_t pattern_len)
fnmatch_list_of_states_alloc(size_t n,
size_t pattern_len)
{
struct list_of_states *l;
const size_t reserved = pattern_len + 1;
const size_t states_size = sizeof (*l->states) * reserved;
const size_t has_size = sizeof (*l->has) * reserved;
const size_t reserved = pattern_len + 1;
const size_t states_size = sizeof (*l->states) * reserved;
const size_t has_size = sizeof (*l->has) * reserved;
const size_t states_has_size = states_size + has_size;
const size_t struct_size = sizeof (*l) + states_has_size;
const size_t struct_size = sizeof (*l) + states_has_size;
unsigned char *states;
unsigned char *has;
size_t i;
size_t i;
if (! (l = malloc(n * struct_size)))
return 0;
@ -29,7 +30,7 @@ fnmatch_list_of_states_alloc(size_t n, size_t pattern_len)
{
l[i].reserved = reserved;
l[i].states = (size_t *) states;
l[i].has = (_Bool *) has;
l[i].has = (e_bool *) has;
states += states_has_size;
has += states_has_size;
}
@ -38,7 +39,8 @@ fnmatch_list_of_states_alloc(size_t n, size_t pattern_len)
}
void
fnmatch_list_of_states_free(struct list_of_states *lists, size_t n)
fnmatch_list_of_states_free(struct list_of_states *lists,
size_t n)
{
assert(lists);
@ -47,7 +49,8 @@ fnmatch_list_of_states_free(struct list_of_states *lists, size_t n)
}
void
fnmatch_list_of_states_insert(struct list_of_states *list, size_t state)
fnmatch_list_of_states_insert(struct list_of_states *list,
size_t state)
{
assert(list);
assert(state < list->reserved);

View File

@ -0,0 +1,24 @@
#ifndef __EVIL_FNMATCH_PRIVATE_H__
#define __EVIL_FNMATCH_PRIVATE_H__
typedef int e_bool;
struct list_of_states
{
size_t reserved;
size_t size;
size_t *states;
e_bool *has;
};
struct list_of_states *fnmatch_list_of_states_alloc(size_t n, size_t pattern_len);
void fnmatch_list_of_states_free(struct list_of_states *lists, size_t n);
void fnmatch_list_of_states_insert(struct list_of_states *list, size_t state);
void fnmatch_list_of_states_clear(struct list_of_states *list);
#endif /* __EVIL_FNMATCH_PRIVATE_H__ */

View File

@ -4,6 +4,10 @@
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <windows.h>
#include <security.h>
#include "Evil.h"
#include "pwd.h"
@ -16,12 +20,35 @@ struct passwd *
getpwuid (uid_t uid)
{
static char user_name[PATH_MAX];
DWORD length;
BOOL res;
TCHAR name[PATH_MAX];
ULONG length;
BOOLEAN res;
#ifdef UNICODE
char *a_name;
# endif /* UNICODE */
length = PATH_MAX;
/* get from USERPROFILE for win 98 ? */
res = GetUserName(user_name, &length);
res = GetUserNameEx(NameUnknown, name, &length);
#ifdef UNICODE
if (res)
{
a_name = evil_wchar_to_char(name);
if (a_name)
{
int length;
length = strlen(a_name);
if (length >= PATH_MAX)
length = PATH_MAX;
memcpy(user_name, a_name, length);
user_name[length] = '\0';
free(a_name);
}
else
res = 0;
}
#endif /* UNICODE */
pw.pw_name = (res ? user_name : NULL);
pw.pw_passwd = NULL;
pw.pw_uid = uid;

View File

@ -1,20 +1,20 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdio.h>
#ifndef __CEGCC__
# include <io.h>
#endif /* ! __CEGCC__ */
#ifndef __MINGW32CE__
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif /* ! __MINGW32CE__ */
#endif /* HAVE_ERRNO_H */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include "Evil.h"
/*** Local ***/
@ -137,7 +137,9 @@ setenv(const char *name,
/* if '=' is found, return EINVAL */
if (strchr (name, '='))
{
#ifdef HAVE_ERRNO_H
errno = EINVAL;
#endif /* HAVE_ERRNO_H */
return -1;
}
@ -150,7 +152,9 @@ setenv(const char *name,
str = (char *)malloc(length);
if (!str)
{
#ifdef HAVE_ERRNO_H
errno = ENOMEM;
#endif /* HAVE_ERRNO_H */
return -1;
}
if (!value)
@ -230,23 +234,66 @@ unsetenv(const char *name)
*
*/
#ifndef __CEGCC__
int
mkstemp(char *template)
{
int fd;
const char lookup[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
char *suffix;
DWORD val;
int length;
int i;
if (!_mktemp(template))
return -1;
if (!template)
return 0;
fd = _open(template, _O_RDWR | _O_BINARY | _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE);
length = strlen(template);
if ((length < 6) ||
(strncmp (template + length - 6, "XXXXXX", 6)))
{
#ifdef HAVE_ERRNO_H
errno = EINVAL;
#endif /* HAVE_ERRNO_H */
return -1;
}
return fd;
suffix = template + length - 6;
val = GetTickCount();
val += GetCurrentProcessId();
for (i = 0; i < 32768; i++)
{
DWORD v;
int fd;
v = val;
suffix[0] = lookup[v % 62];
v /= 62;
suffix[1] = lookup[v % 62];
v /= 62;
suffix[2] = lookup[v % 62];
v /= 62;
suffix[3] = lookup[v % 62];
v /= 62;
suffix[4] = lookup[v % 62];
v /= 62;
suffix[5] = lookup[v % 62];
v /= 62;
fd = _open(template, _O_RDWR | _O_BINARY | _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE);
if (fd >= 0)
return fd;
val += 7777;
}
#ifdef HAVE_ERRNO_H
errno = EEXIST;
#endif /* HAVE_ERRNO_H */
return -1;
}
#endif /* ! __CEGCC__ */
char *
realpath(const char *file_name, char *resolved_name)

View File

@ -99,11 +99,7 @@ EAPI int unsetenv(const char *name);
* temporary file. Otherwise, it returns -1 and errno is set to the
* following values:
* - EINVAL: @p template has an invalid format.
* - EACCESS: Given path is a directory, or file is read-only, but an
* open-for-writing operation was attempted.
* - EEXISTS: File name already exists.
* - EMFILE: No more file descriptors available.
* - ENOENT: File or path not found.
*
* Conformity: Should follow BSD conformity.
*
@ -112,7 +108,7 @@ EAPI int unsetenv(const char *name);
*
* @ingroup Evil
*/
EAPI int mkstemp(char *template);
EAPI int mkstemp(char *__template);
/**
* @brief Return an absolute or full path name for a specified relative path name.

View File

@ -1,3 +1,12 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif /* HAVE_ERRNO_H */
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#undef WIN32_LEAN_AND_MEAN
@ -6,13 +15,8 @@
(defined(__MINGW32__) && ! defined(__MINGW32CE__))
# include <shlobj.h>
# include <objidl.h>
# include <errno.h>
#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include "Evil.h"
/*
@ -87,7 +91,9 @@ symlink(const char *oldpath, const char *newpath)
if (FAILED(res))
{
if (res == E_OUTOFMEMORY)
#ifdef HAVE_ERRNO_H
errno = ENOMEM;
#endif /* HAVE_ERRNO_H */
return -1;
}
@ -184,7 +190,9 @@ readlink(const char *path, char *buf, size_t bufsiz)
if (FAILED(res))
{
if (res == E_OUTOFMEMORY)
#ifdef HAVE_ERRNO_H
errno = ENOMEM;
#endif /* HAVE_ERRNO_H */
return -1;
}

View File

@ -1,19 +1,21 @@
#ifndef _FNMATCH_H
#define _FNMATCH_H
#ifdef EVIL_COMMON_API
# undef EVIL_COMMON_API
#endif /* EVIL_COMMON_API */
#ifdef EAPI
# undef EAPI
#endif /* EAPI */
#ifdef _WIN32
# ifdef EFL_EVIL_BUILD
# ifdef DLL_EXPORT
# define EVIL_COMMON_API __declspec(dllexport)
# define EAPI __declspec(dllexport)
# else
# define EVIL_COMMON_API
# define EAPI
# endif /* ! DLL_EXPORT */
# else
# define EVIL_COMMON_API __declspec(dllimport)
# define EAPI __declspec(dllimport)
# endif /* ! EFL_EVIL_BUILD */
#endif /* _WIN32 */
#ifdef __cplusplus
extern "C" {
@ -43,7 +45,7 @@ extern "C" {
/* Match STRING against the filename pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */
EVIL_COMMON_API int fnmatch(const char *__pattern, const char *__string, int __flags);
EAPI int fnmatch(const char *__pattern, const char *__string, int __flags);
#ifdef __cplusplus
}

View File

@ -1,28 +0,0 @@
#ifndef FNMATCH_PRIVATE_H_
# define FNMATCH_PRIVATE_H_
# include <stddef.h>
typedef int _Bool;
struct list_of_states
{
size_t reserved;
size_t size;
size_t *states;
_Bool *has;
};
struct list_of_states*
fnmatch_list_of_states_alloc(size_t n, size_t pattern_len);
void
fnmatch_list_of_states_free(struct list_of_states *lists, size_t n);
void
fnmatch_list_of_states_insert(struct list_of_states *list, size_t state);
void
fnmatch_list_of_states_clear(struct list_of_states *list);
#endif // ! FNMATCH_PRIVATE_H_