2008-03-01 23:03:37 -08:00
|
|
|
#ifndef __EVIL_H__
|
|
|
|
#define __EVIL_H__
|
2008-02-27 13:01:30 -08:00
|
|
|
|
2012-12-28 10:42:35 -08:00
|
|
|
/**
|
|
|
|
* @file Evil.h
|
|
|
|
* @brief The file that provides miscellaneous functions ported from Unix.
|
|
|
|
*/
|
|
|
|
|
2008-02-27 13:01:30 -08:00
|
|
|
/**
|
2012-12-18 08:12:56 -08:00
|
|
|
* @page evil_main Evil
|
2008-02-29 14:42:14 -08:00
|
|
|
* @author Vincent Torri
|
2012-12-28 15:26:05 -08:00
|
|
|
* @date 2008 (created)
|
2008-02-27 13:01:30 -08:00
|
|
|
*
|
2012-12-28 15:26:05 -08:00
|
|
|
* @section toc Table of Contents
|
|
|
|
*
|
|
|
|
* @li @ref evil_main_intro
|
|
|
|
* @li @ref evil_main_ack
|
|
|
|
* @li @ref evil_main_compiling
|
|
|
|
* @li @ref evil_main_next_steps
|
|
|
|
*
|
|
|
|
* @section evil_main_intro Introduction
|
2008-02-27 13:01:30 -08:00
|
|
|
*
|
|
|
|
* The Evil library is an evil library that ports some evil Unix
|
2011-11-12 14:31:16 -08:00
|
|
|
* functions to the Windows (XP or above, or Mobile) platform. The
|
|
|
|
* evilness is so huge that the most of the functions are not POSIX or
|
|
|
|
* BSD compliant.
|
2008-02-27 13:01:30 -08:00
|
|
|
*
|
|
|
|
* These functions are intended to be used in the Enlightenment
|
2011-12-29 23:06:40 -08:00
|
|
|
* Foundation Libraries only and can be compiled only on Windows,
|
2011-11-12 14:31:16 -08:00
|
|
|
* using MSYS/MinGW on Windows, and cross-compilation on Unix. This
|
|
|
|
* library is minimal in the sense that only the functions needed to
|
|
|
|
* compile the EFL are available. The purpose of this library is NOT
|
|
|
|
* to have a full POSIX emulation et it is NOT a replacement of
|
|
|
|
* cygwin. To compare the size of the DLL themselves, Evil is around
|
|
|
|
* 33 KB and cygwin DLL is around 800 KB.
|
2008-02-27 13:01:30 -08:00
|
|
|
*
|
2012-12-28 15:26:05 -08:00
|
|
|
* @section evil_main_ack Acknowledgments
|
2011-11-12 14:31:16 -08:00
|
|
|
*
|
|
|
|
* This library has receive some from people interested in the EFL or
|
|
|
|
* not. Among them, evil thanks to Lars Munch, Raoul Hecky, Nicolas
|
|
|
|
* Aguirre, Tor Lillqvist, Lance Fetters, Vincent Richomme, Paul
|
|
|
|
* Vixie, Daniel Stenberg, who helped the author of the library in
|
|
|
|
* different fields (code and tests).
|
|
|
|
*
|
2012-12-28 15:26:05 -08:00
|
|
|
* @section evil_main_compiling How to compile
|
|
|
|
*
|
|
|
|
* Evil is a library your application links to. The procedure for
|
|
|
|
* this is very simple. You simply have to compile your application
|
|
|
|
* with the appropriate compiler flags that the @p pkg-config script
|
|
|
|
* outputs. For example:
|
|
|
|
*
|
|
|
|
* Compiling C or C++ files into object files:
|
|
|
|
*
|
|
|
|
* @verbatim
|
|
|
|
gcc -c -o main.o main.c `pkg-config --cflags evil`
|
|
|
|
@endverbatim
|
|
|
|
*
|
|
|
|
* Linking object files into a binary executable:
|
|
|
|
*
|
|
|
|
* @verbatim
|
|
|
|
gcc -o my_application main.o `pkg-config --libs evil`
|
|
|
|
@endverbatim
|
|
|
|
*
|
|
|
|
* See @ref pkgconfig
|
|
|
|
*
|
|
|
|
* @section evil_main_next_steps Next Steps
|
2011-11-12 14:31:16 -08:00
|
|
|
*
|
2012-12-28 15:26:05 -08:00
|
|
|
* After you understood what Evil is and installed it in your system
|
|
|
|
* you should proceed understanding the programming interface.
|
2008-02-27 13:01:30 -08:00
|
|
|
*
|
2012-12-28 15:26:05 -08:00
|
|
|
* Recommended reading:
|
2010-11-06 00:10:12 -07:00
|
|
|
*
|
2012-12-28 15:26:05 -08:00
|
|
|
* @li @ref Evil_Mman
|
|
|
|
* @li @ref Evil_Libgen_Group
|
|
|
|
* @li @ref Evil_Unistd_Group
|
|
|
|
* @li @ref Evil_Dlfcn
|
|
|
|
* @li @ref Evil_Pwd_Group
|
|
|
|
* @li @ref Evil_Stdio_Group
|
|
|
|
* @li @ref Evil_Main_Group
|
|
|
|
* @li @ref Evil_Inet_Group
|
|
|
|
* @li @ref Evil_Dirent_Group
|
|
|
|
* @li @ref Evil_String_Group
|
|
|
|
* @li @ref Evil_Stdlib_Group
|
|
|
|
* @li @ref Evil_Time_Group
|
2008-02-27 13:01:30 -08:00
|
|
|
*/
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @cond LOCAL
|
|
|
|
*/
|
|
|
|
|
2008-06-11 14:34:09 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-03-03 13:12:45 -08:00
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
# define WIN32_LEAN_AND_MEAN
|
|
|
|
#endif
|
2008-06-11 14:34:09 -07:00
|
|
|
#include <windows.h>
|
|
|
|
#undef WIN32_LEAN_AND_MEAN
|
|
|
|
|
2008-02-27 13:01:30 -08:00
|
|
|
#include <stdlib.h>
|
2008-12-09 22:15:03 -08:00
|
|
|
#include <stdio.h>
|
2010-09-14 14:24:25 -07:00
|
|
|
#include <time.h>
|
2008-02-29 14:42:14 -08:00
|
|
|
#include <limits.h>
|
2008-06-11 14:34:09 -07:00
|
|
|
#include <sys/stat.h>
|
2008-06-29 05:09:48 -07:00
|
|
|
#include <fcntl.h>
|
2009-10-24 08:39:59 -07:00
|
|
|
#include <math.h>
|
2012-03-30 09:38:43 -07:00
|
|
|
#include <direct.h>
|
2008-02-27 13:01:30 -08:00
|
|
|
|
2008-09-14 00:07:39 -07:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
2009-12-07 09:23:41 -08:00
|
|
|
# include <io.h>
|
2009-02-19 12:03:58 -08:00
|
|
|
|
2009-12-07 09:23:41 -08:00
|
|
|
# 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 */
|
|
|
|
# define R_OK 4 /* Check for read permission */
|
|
|
|
|
2011-08-26 08:59:42 -07:00
|
|
|
typedef DWORD pid_t;
|
2008-09-14 00:07:39 -07:00
|
|
|
typedef unsigned short mode_t;
|
|
|
|
|
2008-12-27 10:53:56 -08:00
|
|
|
typedef unsigned short uint16_t;
|
|
|
|
typedef unsigned int uint32_t;
|
|
|
|
typedef signed int int32_t;
|
2009-09-16 10:25:28 -07:00
|
|
|
typedef __int64 int64_t;
|
2008-12-27 10:53:56 -08:00
|
|
|
typedef unsigned __int64 uint64_t;
|
2010-03-11 10:49:11 -08:00
|
|
|
typedef SSIZE_T ssize_t;
|
2008-12-27 10:53:56 -08:00
|
|
|
|
2009-12-07 09:23:41 -08:00
|
|
|
# define strdup(s) _strdup(s)
|
|
|
|
# define unlink(filename) _unlink(filename)
|
|
|
|
# define fileno(f) _fileno(f)
|
|
|
|
# define fdopen(fd,m) _fdopen((fd),(m))
|
2009-12-20 04:08:54 -08:00
|
|
|
# define access(p,m) _access((p),(m))
|
2010-04-03 12:06:20 -07:00
|
|
|
# define hypot(x,y) _hypot((x),(y))
|
2010-12-18 09:37:50 -08:00
|
|
|
# define tzset _tzset
|
2009-12-07 09:23:41 -08:00
|
|
|
|
2008-09-14 00:07:39 -07:00
|
|
|
#endif /* _MSC_VER */
|
|
|
|
|
2010-10-29 01:37:25 -07:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
# ifndef offsetof
|
|
|
|
# define offsetof(type, ident) ((size_t)&(((type*)0)->ident))
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2008-06-29 05:09:48 -07:00
|
|
|
typedef unsigned long uid_t;
|
|
|
|
typedef unsigned long gid_t;
|
|
|
|
|
2008-06-11 14:34:09 -07:00
|
|
|
|
2012-02-17 12:48:11 -08:00
|
|
|
#include "evil_macro.h"
|
2008-09-14 23:56:14 -07:00
|
|
|
#include "evil_fcntl.h"
|
2011-05-19 05:00:06 -07:00
|
|
|
#include "evil_inet.h"
|
2008-09-14 23:56:14 -07:00
|
|
|
#include "evil_langinfo.h"
|
2009-12-07 09:23:41 -08:00
|
|
|
#include "evil_libgen.h"
|
2008-11-21 14:57:45 -08:00
|
|
|
#include "evil_main.h"
|
2012-02-17 12:48:11 -08:00
|
|
|
#include "evil_print.h"
|
2008-09-14 23:56:14 -07:00
|
|
|
#include "evil_stdlib.h"
|
2008-10-11 07:35:26 -07:00
|
|
|
#include "evil_stdio.h"
|
|
|
|
#include "evil_string.h"
|
2010-09-14 14:24:25 -07:00
|
|
|
#include "evil_time.h"
|
2008-09-14 23:56:14 -07:00
|
|
|
#include "evil_unistd.h"
|
|
|
|
#include "evil_util.h"
|
2012-02-18 10:11:10 -08:00
|
|
|
#include "evil_macro_pop.h"
|
2012-02-17 12:48:11 -08:00
|
|
|
|
2008-06-11 14:34:09 -07:00
|
|
|
|
2010-02-27 23:57:03 -08:00
|
|
|
#if (defined(_WIN32) && !defined(_UWIN) && !defined(__CYGWIN__))
|
2008-06-10 00:16:53 -07:00
|
|
|
# if defined(_MSC_VER) || defined(__MINGW32__)
|
2009-12-19 03:52:48 -08:00
|
|
|
|
|
|
|
# ifdef S_ISDIR
|
|
|
|
# undef S_ISDIR
|
|
|
|
# endif
|
|
|
|
# ifdef S_ISREG
|
|
|
|
# undef S_ISREG
|
|
|
|
# endif
|
|
|
|
# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
|
|
|
|
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
|
|
|
|
2012-03-30 02:04:26 -07:00
|
|
|
# define S_ISLNK(m) 0
|
|
|
|
|
2009-12-19 03:52:48 -08:00
|
|
|
# define S_IRUSR _S_IRUSR
|
|
|
|
# define S_IWUSR _S_IWUSR
|
|
|
|
# define S_IXUSR _S_IXUSR
|
|
|
|
# define S_IRGRP S_IRUSR
|
|
|
|
# define S_IROTH S_IRUSR
|
|
|
|
# define S_IWGRP S_IWUSR
|
|
|
|
# define S_IWOTH S_IWUSR
|
|
|
|
# define S_IXGRP S_IXUSR
|
|
|
|
# define S_IXOTH S_IXUSR
|
|
|
|
|
|
|
|
# define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
|
|
|
|
# define _S_IXUSR _S_IEXEC
|
|
|
|
# define _S_IWUSR _S_IWRITE
|
|
|
|
# define _S_IRUSR _S_IREAD
|
|
|
|
|
2013-06-24 20:16:36 -07:00
|
|
|
#define S_IRWXO _S_IRWXU
|
|
|
|
#define S_IRWXG _S_IRWXU
|
|
|
|
|
2010-04-03 12:06:20 -07:00
|
|
|
# define mkdir(p,m) _mkdir(p)
|
2010-04-01 13:13:40 -07:00
|
|
|
/*
|
|
|
|
# define close(fd) _close(fd)
|
|
|
|
# define read(fd,buffer,count) _read((fd),(buffer),(count))
|
|
|
|
# define write(fd,buffer,count) _write((fd),(buffer),(count))
|
|
|
|
# define unlink(filename) _unlink((filename))
|
|
|
|
# define lstat(f,s) _stat((f),(s))
|
|
|
|
*/
|
2008-06-10 00:16:53 -07:00
|
|
|
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2008-02-27 13:01:30 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-11-12 14:31:16 -08:00
|
|
|
/**
|
|
|
|
* @endcond
|
|
|
|
*/
|
|
|
|
|
2008-03-01 23:03:37 -08:00
|
|
|
#endif /* __EVIL_H__ */
|