forked from enlightenment/efl
add autogen.sh in archive distribution * configure.ac: remove useless defines first support of mingw32msvc compiler * src/lib/Evil.h: move some macro definitions * src/lib/Makefile.am: add evil_(fcntl/langinfo).(c/h) and install pwd.h * src/lib/dlfcn/dlfcn.h: remove useless ifdef * src/lib/evil.c: comment all code for now. It will be deleted later * src/lib/evil_fcntl.c: * src/lib/evil_fcntl.h: * src/lib/evil_langinfo.c: * src/lib/evil_langinfo.h: move fcntl and langinfo related code to their own files * src/lib/evil_mman.c: remove useless inclusion * src/lib/evil_pwd.c: pw var is not needed with cegcc * src/lib/evil_stdlib.c: fix bugs, formatting * src/lib/evil_unistd.c: add missing declarations and fix header files * src/lib/evil_unistd.h: move pid_t typedef to Evil.h * src/lib/evil_util.c: additional include and fix a bug in output * src/lib/pwd.h: use EAPI from Evil.h, define struct passwd when not using cegcc * src/lib/sys/mman.h: use EAPI from Evil.h * win32/common/fnmatch.c: * win32/common/fnmatch.h: * win32/common/fnmatch_list_of_states.c: * win32/vs8/evil.sln: fix and cleanup with vc++ compilation Based on patch by Dmitriy Mazovka SVN revision: 35993devs/devilhorns/wayland_egl
parent
bae73a2b60
commit
a7f00b51bc
23 changed files with 469 additions and 366 deletions
@ -0,0 +1,82 @@ |
||||
|
||||
#include <stdio.h> |
||||
|
||||
#ifndef __CEGCC__ |
||||
# include <sys/locking.h> |
||||
#endif /* __CEGCC__ */ |
||||
|
||||
#ifdef HAVE_CONFIG_H |
||||
# include "config.h" |
||||
#endif /* HAVE_CONFIG_H */ |
||||
|
||||
#include "Evil.h" |
||||
|
||||
|
||||
/*
|
||||
* port of fcntl function |
||||
* |
||||
*/ |
||||
|
||||
#ifndef __CEGCC__ |
||||
|
||||
int fcntl(int fd, int cmd, ...) |
||||
{ |
||||
va_list va; |
||||
HANDLE h; |
||||
int res = -1; |
||||
|
||||
va_start (va, cmd); |
||||
|
||||
h = (HANDLE)_get_osfhandle(fd); |
||||
if (h == INVALID_HANDLE_VALUE) |
||||
return -1; |
||||
|
||||
if (cmd == F_SETFD) |
||||
{ |
||||
long flag; |
||||
|
||||
flag = va_arg(va, long); |
||||
if (flag == FD_CLOEXEC) |
||||
{ |
||||
if (SetHandleInformation(h, HANDLE_FLAG_INHERIT, 0)) |
||||
res = 0; |
||||
} |
||||
} |
||||
else if ((cmd == F_SETLK) || (cmd == F_SETLKW)) |
||||
{ |
||||
struct flock fl; |
||||
off_t length = 0; |
||||
long pos; |
||||
|
||||
fl = va_arg(va, struct flock); |
||||
|
||||
if (fl.l_len == 0) |
||||
{ |
||||
length = _lseek(fd, 0L, SEEK_END); |
||||
if (length != -1L) |
||||
res = 0; |
||||
} |
||||
fl.l_len = length - fl.l_start - 1; |
||||
|
||||
pos = _lseek(fd, fl.l_start, fl.l_whence); |
||||
if (pos != -1L) |
||||
res = 0; |
||||
|
||||
if ((fl.l_type == F_RDLCK) || (fl.l_type == F_WRLCK)) |
||||
{ |
||||
if (cmd == F_SETLK) |
||||
res = _locking(fd, _LK_NBLCK, fl.l_len); /* if cannot be locked, we return immediatly */ |
||||
else /* F_SETLKW */ |
||||
res = _locking(fd, _LK_LOCK, fl.l_len); /* otherwise, we try several times */ |
||||
} |
||||
|
||||
if (fl.l_type == F_UNLCK) |
||||
res = _locking(fd, _LK_UNLCK, fl.l_len); |
||||
} |
||||
|
||||
va_end(va); |
||||
|
||||
return res; |
||||
} |
||||
|
||||
#endif /* ! __CEGCC__ */ |
@ -0,0 +1,106 @@ |
||||
#ifndef __EVIL_FCNTL_H__ |
||||
#define __EVIL_FCNTL_H__ |
||||
|
||||
|
||||
#ifndef __CEGCC__ |
||||
|
||||
# include <sys/types.h> |
||||
|
||||
/**
|
||||
* @def FD_CLOEXEC |
||||
* Specifies that the file descriptor should be closed when an exec() |
||||
* function is invoked. |
||||
*/ |
||||
# define FD_CLOEXEC 1 |
||||
|
||||
/**
|
||||
* @def F_SETFD |
||||
* Specifies that fcntl() should set the file descriptor flags |
||||
* associated with the filedes argument. |
||||
*/ |
||||
|
||||
/**
|
||||
* @def F_SETLK |
||||
* Specifies that fcntl() should set or clear a file segment lock |
||||
* according to the lock description pointed to by the third argument. |
||||
*/ |
||||
|
||||
/**
|
||||
* @def F_SETLKW |
||||
* Equivalent to F_SETLK except that if a shared or exclusive lock |
||||
* is blocked by other locks, the thread shall wait until the request |
||||
* can be satisfied. |
||||
*/ |
||||
|
||||
# define F_SETFD 2 |
||||
# define F_SETLK 6 |
||||
# define F_SETLKW 7 |
||||
|
||||
/**
|
||||
* @def F_RDLCK |
||||
* Read (or shared) lock |
||||
*/ |
||||
|
||||
/**
|
||||
* @def F_WRLCK |
||||
* Write (or exclusive) lock |
||||
*/ |
||||
|
||||
/**
|
||||
* @def F_UNLCK |
||||
* Remove lock |
||||
*/ |
||||
|
||||
# ifndef F_RDLCK |
||||
# define F_RDLCK 0 |
||||
# define F_WRLCK 1 |
||||
# define F_UNLCK 2 |
||||
# endif /* ! F_RDLCK */ |
||||
|
||||
/**
|
||||
* @struct flock |
||||
* @brief A structure that control the lock of a file descriptor. |
||||
*/ |
||||
struct flock |
||||
{ |
||||
short int l_type; /**< lock type: read, write, ... */ |
||||
short int l_whence; /**< type of l_start */ |
||||
off_t l_start; /**< starting offset */ |
||||
off_t l_len; /**< 0 means end of the file */ |
||||
pid_t l_pid; /**< lock owner */ |
||||
}; |
||||
|
||||
|
||||
/**
|
||||
* @brief Provide control over file descriptors. |
||||
* |
||||
* @param fd The file descriptor. |
||||
* @param cmd The type of control. |
||||
* @return 0 on success, -1 otherwise. |
||||
* |
||||
* Performs one of various miscellaneous operations on @p fd. |
||||
* The operation in question is determined by @p cmd: |
||||
* |
||||
* - F_SETFD: Set the close-on-exec flag to the value specified |
||||
* by the argument after command (only the least significant |
||||
* bit is used). |
||||
* - F_SETLK and F_SETLKW: used to manage discretionary file locks. |
||||
* The third argument must be a pointer to a struct flock (that |
||||
* may be overwritten by this call). |
||||
* |
||||
* This function returns 0 on success, -1 otherwise. |
||||
* |
||||
* Conformity: None. |
||||
* |
||||
* Supported OS: Windows Vista, Windows XP or Windows 2000 |
||||
* Professional. |
||||
* |
||||
* @ingroup Evil |
||||
*/ |
||||
EAPI int fcntl(int fd, int cmd, ...); |
||||
|
||||
|
||||
#endif /* ! __CEGCC__ */ |
||||
|
||||
|
||||
#endif /* __EVIL_FCNTL_H__ */ |
@ -0,0 +1,50 @@ |
||||
|
||||
#ifdef HAVE_CONFIG_H |
||||
# include "config.h" |
||||
#endif /* HAVE_CONFIG_H */ |
||||
|
||||
#include "Evil.h" |
||||
|
||||
|
||||
#ifndef __CEGCC__ |
||||
|
||||
static char * |
||||
replace(char *prev, char *value) |
||||
{ |
||||
if (value == NULL) |
||||
return prev; |
||||
|
||||
if (prev) |
||||
free (prev); |
||||
return strdup (value); |
||||
} |
||||
|
||||
char * |
||||
nl_langinfo(nl_item index) |
||||
{ |
||||
static char *result = NULL; |
||||
static char *nothing = ""; |
||||
|
||||
switch (index) |
||||
{ |
||||
case CODESET: |
||||
{ |
||||
char *p; |
||||
result = replace(result, setlocale(LC_CTYPE, NULL)); |
||||
if ((p = strrchr(result, '.' )) == NULL) |
||||
return nothing; |
||||
|
||||
if ((++p - result) > 2) |
||||
strcpy(result, "cp"); |
||||
else |
||||
*result = '\0'; |
||||
strcat(result, p); |
||||
|
||||
return result; |
||||
} |
||||
} |
||||
|
||||
return nothing; |
||||
} |
||||
|
||||
#endif /* ! __CEGCC__ */ |
@ -0,0 +1,39 @@ |
||||
#ifndef __EVIL_LANGINFO_H__ |
||||
#define __EVIL_LANGINFO_H__ |
||||
|
||||
|
||||
#ifndef __CEGCC__ |
||||
|
||||
#include <locale.h> |
||||
|
||||
|
||||
typedef int nl_item; |
||||
|
||||
#define __NL_ITEM( CATEGORY, INDEX ) ((CATEGORY << 16) | INDEX) |
||||
#define __NL_ITEM_CATEGORY( ITEM ) (ITEM >> 16) |
||||
#define __NL_ITEM_INDEX( ITEM ) (ITEM & 0xffff) |
||||
|
||||
enum { |
||||
/*
|
||||
* LC_CTYPE category... |
||||
* Character set classification items. |
||||
*/ |
||||
_NL_CTYPE_CODESET = __NL_ITEM( LC_CTYPE, 0 ), |
||||
|
||||
/*
|
||||
* Dummy entry, to terminate the list. |
||||
*/ |
||||
_NL_ITEM_CLASSIFICATION_END |
||||
}; |
||||
|
||||
/*
|
||||
* Define the public aliases for the enumerated classification indices... |
||||
*/ |
||||
# define CODESET _NL_CTYPE_CODESET |
||||
|
||||
EAPI char *nl_langinfo(nl_item index); |
||||
|
||||
#endif /* ! __CEGCC__ */ |
||||
|
||||
|
||||
#endif /*__EVIL_LANGINFO_H__ */ |
Loading…
Reference in new issue