1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
#ifndef __EVIL_H__
#define __EVIL_H__
/**
* @file Evil.h
* @brief The file that provides miscellaneous functions ported from Unix.
*/
/**
* @page evil_main Evil
* @author Vincent Torri
* @date 2008 (created)
*
* @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
*
* The Evil library is an evil library that ports some evil Unix
* 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.
*
* These functions are intended to be used in the Enlightenment
* Foundation Libraries only and can be compiled only on Windows,
* 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.
*
* @section evil_main_ack Acknowledgments
*
* 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).
*
* @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
*
* After you understood what Evil is and installed it in your system
* you should proceed understanding the programming interface.
*
* Recommended reading:
*
* @li @ref Evil_Mman
* @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
*/
/**
* @cond LOCAL
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <limits.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>
#ifdef _MSC_VER
# include <io.h>
# 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 */
typedef DWORD pid_t;
typedef unsigned short mode_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef signed int int32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
typedef SSIZE_T ssize_t;
# define strdup(s) _strdup(s)
# define unlink(filename) _unlink(filename)
# define fileno(f) _fileno(f)
# define fdopen(fd,m) _fdopen((fd),(m))
# define access(p,m) _access((p),(m))
# define hypot(x,y) _hypot((x),(y))
# define tzset _tzset
#endif /* _MSC_VER */
typedef unsigned long uid_t;
typedef unsigned long gid_t;
#include "evil_macro.h"
#include "evil_fcntl.h"
#include "evil_inet.h"
#include "evil_langinfo.h"
#include "evil_main.h"
#include "evil_stdlib.h"
#include "evil_stdio.h"
#include "evil_string.h"
#include "evil_time.h"
#include "evil_unistd.h"
#include "evil_util.h"
#include "evil_macro_pop.h"
#if (defined(_WIN32) && !defined(_UWIN) && !defined(__CYGWIN__))
# if defined(_MSC_VER) || defined(__MINGW32__)
#ifndef S_ISDIR
# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#endif
#ifndef S_ISREG
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
#endif
# define S_ISLNK(m) 0
#define S_IRUSR _S_IRUSR
#ifndef S_IRGRP
# define S_IRGRP S_IRUSR
#endif
#ifndef S_IROTH
# define S_IROTH S_IRUSR
#endif
#define S_IWUSR _S_IWUSR
#ifndef S_IWGRP
# define S_IWGRP S_IWUSR
#endif
#ifndef S_IWOTH
# define S_IWOTH S_IWUSR
#endif
#define S_IXUSR _S_IXUSR
#ifndef S_IXGRP
# define S_IXGRP S_IXUSR
#endif
#ifndef S_IXOTH
# define S_IXOTH S_IXUSR
#endif
#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
#ifndef S_IRWXG
# define S_IRWXG _S_IRWXU
#endif
#ifndef S_IRWXO
# define S_IRWXO _S_IRWXU
#endif
# define _S_IXUSR _S_IEXEC
# define _S_IWUSR _S_IWRITE
# define _S_IRUSR _S_IREAD
/*
# 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))
*/
# endif
#endif
#define sigsetjmp(Env, Save) setjmp(Env)
#undef EAPI
#define EAPI
#ifdef __cplusplus
}
#endif
/**
* @endcond
*/
#endif /* __EVIL_H__ */
|