summaryrefslogtreecommitdiff
path: root/legacy/evil
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2008-09-13 21:19:22 +0000
committerVincent Torri <vincent.torri@gmail.com>2008-09-13 21:19:22 +0000
commit146b4a86c6a981c0010c5883f3c55d0ec78c07f5 (patch)
tree3ab5de1416793b6c2416d44551da3818566fcd58 /legacy/evil
parent892ea362f01611c8142712240121a50430c36e52 (diff)
* big rework of evil: put most of functions in evil.c in their own files
* add unit test for memcpy. more will come later SVN revision: 35979
Diffstat (limited to 'legacy/evil')
-rw-r--r--legacy/evil/ChangeLog5
-rw-r--r--legacy/evil/INSTALL23
-rw-r--r--legacy/evil/configure.ac6
-rw-r--r--legacy/evil/src/bin/Makefile.am15
-rw-r--r--legacy/evil/src/bin/memcpy_glibc.S231
-rw-r--r--legacy/evil/src/bin/suite.c191
-rw-r--r--legacy/evil/src/bin/suite.h18
-rw-r--r--legacy/evil/src/bin/test_memcpy.c113
-rw-r--r--legacy/evil/src/bin/test_memcpy.h8
-rw-r--r--legacy/evil/src/lib/Evil.h356
-rw-r--r--legacy/evil/src/lib/Makefile.am16
-rw-r--r--legacy/evil/src/lib/dlfcn/Makefile.am2
-rw-r--r--legacy/evil/src/lib/evil.c522
-rw-r--r--legacy/evil/src/lib/evil_mman.c (renamed from legacy/evil/src/lib/mman/mman.c)2
-rw-r--r--legacy/evil/src/lib/evil_pwd.c42
-rw-r--r--legacy/evil/src/lib/evil_stdlib.c268
-rw-r--r--legacy/evil/src/lib/evil_stdlib.h145
-rw-r--r--legacy/evil/src/lib/evil_unistd.c396
-rw-r--r--legacy/evil/src/lib/evil_unistd.h187
-rw-r--r--legacy/evil/src/lib/evil_util.c137
-rw-r--r--legacy/evil/src/lib/evil_util.h93
-rw-r--r--legacy/evil/src/lib/mman/.cvsignore6
-rw-r--r--legacy/evil/src/lib/mman/Makefile.am12
-rw-r--r--legacy/evil/src/lib/pwd.h (renamed from legacy/evil/src/lib/pwd/pwd.h)0
-rw-r--r--legacy/evil/src/lib/pwd/Makefile.am4
-rw-r--r--legacy/evil/src/lib/sys/mman.h (renamed from legacy/evil/src/lib/mman/sys/mman.h)0
-rw-r--r--legacy/evil/win32/vs8/libevil.vcproj20
27 files changed, 1884 insertions, 934 deletions
diff --git a/legacy/evil/ChangeLog b/legacy/evil/ChangeLog
index d47bbf6f4c..192ad13eec 100644
--- a/legacy/evil/ChangeLog
+++ b/legacy/evil/ChangeLog
@@ -1,3 +1,8 @@
12008-09-13 Vincent Torri <doursse at users dot sf dot net>
2
3 * big rework of evil
4 * addition of a unit test for memcpy
5
12008-07-13 Vincent Torri <doursse at users dot sf dot net> 62008-07-13 Vincent Torri <doursse at users dot sf dot net>
2 7
3 * src/lib/Evil.h: 8 * src/lib/Evil.h:
diff --git a/legacy/evil/INSTALL b/legacy/evil/INSTALL
index 009d903575..d3c5b40a94 100644
--- a/legacy/evil/INSTALL
+++ b/legacy/evil/INSTALL
@@ -235,26 +235,3 @@ an Autoconf bug. Until the bug is fixed you can use this workaround:
235`configure' also accepts some other, not widely useful, options. Run 235`configure' also accepts some other, not widely useful, options. Run
236`configure --help' for more details. 236`configure --help' for more details.
237 237
238================================================================================
239
240NOTE: For compilation with mingw32ce, run configure with the option
241
242--host=arm-wince-mingw32ce
243
244NOTE: For compilation with cegcc, you have to do the following steps:
245
2461) After having run autogen.sh, add in config.sub file:
247
248 cegcc)
249 basic_machine=arm-unknown
250 os=-cegcc
251 ;;
252
253after the mingw32ce case
254
2552) in config.sub, add -cegcc* after -pe*. You should have a line like:
256 | -cygwin* | -pe* | -cegcc* | -psos* | -moss* | -proelf* | -rtems* \
257
2583) run configure with the option
259
260--host=arm-wince-cegcc
diff --git a/legacy/evil/configure.ac b/legacy/evil/configure.ac
index 6a2bd960e1..0418e9a289 100644
--- a/legacy/evil/configure.ac
+++ b/legacy/evil/configure.ac
@@ -10,7 +10,6 @@ dnl otherwise, we set the correct flags
10dnl for each platform. 10dnl for each platform.
11win32_libs="" 11win32_libs=""
12win32_cflags="" 12win32_cflags=""
13lt_enable_auto_import=""
14case "$host_os" in 13case "$host_os" in
15 mingw|mingw32) 14 mingw|mingw32)
16 win32_libs="-lole32 -luuid -lws2_32" 15 win32_libs="-lole32 -luuid -lws2_32"
@@ -18,7 +17,6 @@ case "$host_os" in
18 cegcc) 17 cegcc)
19 win32_cflags="-mwin32" 18 win32_cflags="-mwin32"
20 win32_libs="-lws2" 19 win32_libs="-lws2"
21 lt_enable_auto_import="-Wl,--enable-auto-import"
22 ;; 20 ;;
23 mingw32ce) 21 mingw32ce)
24 win32_libs="-lws2" 22 win32_libs="-lws2"
@@ -29,7 +27,6 @@ case "$host_os" in
29esac 27esac
30AC_SUBST(win32_cflags) 28AC_SUBST(win32_cflags)
31AC_SUBST(win32_libs) 29AC_SUBST(win32_libs)
32AC_SUBST(lt_enable_auto_import)
33 30
34dnl needed for correct definition of EAPI 31dnl needed for correct definition of EAPI
35AC_DEFINE(EFL_EVIL_BUILD, 1, [Define to mention that evil is built]) 32AC_DEFINE(EFL_EVIL_BUILD, 1, [Define to mention that evil is built])
@@ -51,6 +48,7 @@ SNAP=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $4);}'`
51version_info=`expr $VMAJ + $VMIN`":$VMIC:$VMIN" 48version_info=`expr $VMAJ + $VMIN`":$VMIC:$VMIN"
52AC_SUBST(version_info) 49AC_SUBST(version_info)
53 50
51AM_PROG_AS
54AC_LANG(C) 52AC_LANG(C)
55AC_PROG_CPP 53AC_PROG_CPP
56AC_PROG_CC 54AC_PROG_CC
@@ -79,8 +77,6 @@ src/Makefile
79src/bin/Makefile 77src/bin/Makefile
80src/lib/Makefile 78src/lib/Makefile
81src/lib/dlfcn/Makefile 79src/lib/dlfcn/Makefile
82src/lib/mman/Makefile
83src/lib/pwd/Makefile
84]) 80])
85 81
86AC_OUTPUT 82AC_OUTPUT
diff --git a/legacy/evil/src/bin/Makefile.am b/legacy/evil/src/bin/Makefile.am
index eafa679347..4b5c063db3 100644
--- a/legacy/evil/src/bin/Makefile.am
+++ b/legacy/evil/src/bin/Makefile.am
@@ -9,19 +9,26 @@ AM_CPPFLAGS = \
9 9
10AM_CFLAGS = @win32_cflags@ 10AM_CFLAGS = @win32_cflags@
11 11
12bin_PROGRAMS = test_dlfcn test_pipe test_evil 12bin_PROGRAMS = suite test_dlfcn test_pipe test_evil
13
14suite_SOURCES = suite.c test_memcpy.c memcpy_glibc.S
15suite_LDADD = $(top_builddir)/src/lib/libevil.la
16suite_LDFLAGS = -Wl,--enable-auto-import
17suite_DEPENDENCIES = $(top_builddir)/src/lib/libevil.la
13 18
14test_dlfcn_SOURCES = test_dlfcn.c 19test_dlfcn_SOURCES = test_dlfcn.c
15test_dlfcn_LDADD = $(top_builddir)/src/lib/libevil.la $(top_builddir)/src/lib/dlfcn/libdl.la 20test_dlfcn_LDADD = $(top_builddir)/src/lib/libevil.la $(top_builddir)/src/lib/dlfcn/libdl.la
16test_dlfcn_LDFLAGS = @lt_enable_auto_import@ 21test_dlfcn_LDFLAGS = -Wl,--enable-auto-import
17test_dlfcn_DEPENDENCIES = $(top_builddir)/src/lib/libevil.la $(top_builddir)/src/lib/dlfcn/libdl.la 22test_dlfcn_DEPENDENCIES = $(top_builddir)/src/lib/libevil.la $(top_builddir)/src/lib/dlfcn/libdl.la
18 23
19test_pipe_SOURCES = test_pipe.c 24test_pipe_SOURCES = test_pipe.c
20test_pipe_LDADD = $(top_builddir)/src/lib/libevil.la 25test_pipe_LDADD = $(top_builddir)/src/lib/libevil.la
21test_pipe_LDFLAGS = @lt_enable_auto_import@ 26test_pipe_LDFLAGS = -Wl,--enable-auto-import
22test_pipe_DEPENDENCIES = $(top_builddir)/src/lib/libevil.la 27test_pipe_DEPENDENCIES = $(top_builddir)/src/lib/libevil.la
23 28
24test_evil_SOURCES = test_evil.c 29test_evil_SOURCES = test_evil.c
25test_evil_LDADD = $(top_builddir)/src/lib/libevil.la 30test_evil_LDADD = $(top_builddir)/src/lib/libevil.la
26test_evil_LDFLAGS = @lt_enable_auto_import@ 31test_evil_LDFLAGS = -Wl,--enable-auto-import
27test_evil_DEPENDENCIES = $(top_builddir)/src/lib/libevil.la 32test_evil_DEPENDENCIES = $(top_builddir)/src/lib/libevil.la
33
34EXTRA_DIST = suite.h test_memcpy.h \ No newline at end of file
diff --git a/legacy/evil/src/bin/memcpy_glibc.S b/legacy/evil/src/bin/memcpy_glibc.S
new file mode 100644
index 0000000000..ca7fe21a43
--- /dev/null
+++ b/legacy/evil/src/bin/memcpy_glibc.S
@@ -0,0 +1,231 @@
1/* Copyright (C) 2006 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 Contributed by MontaVista Software, Inc. (written by Nicolas Pitre)
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
20
21/* Copyright (C) 2008 Vincent Torri
22 modification of the name and of the entry / end declaration
23 */
24
25/*
26 * Data preload for architectures that support it (ARM V5TE and above)
27 */
28#if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \
29 && !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__) \
30 && !defined (__ARM_ARCH_4T__) && !defined (__ARM_ARCH_5__) \
31 && !defined (__ARM_ARCH_5T__))
32#define PLD(code...) code
33#else
34#define PLD(code...)
35#endif
36
37/*
38 * This can be used to enable code to cacheline align the source pointer.
39 * Experiments on tested architectures (StrongARM and XScale) didn't show
40 * this a worthwhile thing to do. That might be different in the future.
41 */
42//#define CALGN(code...) code
43#define CALGN(code...)
44
45/*
46 * Endian independent macros for shifting bytes within registers.
47 */
48#ifndef __ARMEB__
49#define pull lsr
50#define push lsl
51#else
52#define pull lsl
53#define push lsr
54#endif
55
56 .text
57
58/* Prototype: void *memcpy_glibc(void *dest, const void *src, size_t n); */
59
60 .align
61 .global memcpy_glibc
62 .func memcpy_glibc
63memcpy_glibc:
64
65 stmfd sp!, {r0, r4, lr}
66
67 subs r2, r2, #4
68 blt 8f
69 ands ip, r0, #3
70 PLD( pld [r1, #0] )
71 bne 9f
72 ands ip, r1, #3
73 bne 10f
74
751: subs r2, r2, #(28)
76 stmfd sp!, {r5 - r8}
77 blt 5f
78
79 CALGN( ands ip, r1, #31 )
80 CALGN( rsb r3, ip, #32 )
81 CALGN( sbcnes r4, r3, r2 ) @ C is always set here
82 CALGN( bcs 2f )
83 CALGN( adr r4, 6f )
84 CALGN( subs r2, r2, r3 ) @ C gets set
85 CALGN( add pc, r4, ip )
86
87 PLD( pld [r1, #0] )
882: PLD( subs r2, r2, #96 )
89 PLD( pld [r1, #28] )
90 PLD( blt 4f )
91 PLD( pld [r1, #60] )
92 PLD( pld [r1, #92] )
93
943: PLD( pld [r1, #124] )
954: ldmia r1!, {r3, r4, r5, r6, r7, r8, ip, lr}
96 subs r2, r2, #32
97 stmia r0!, {r3, r4, r5, r6, r7, r8, ip, lr}
98 bge 3b
99 PLD( cmn r2, #96 )
100 PLD( bge 4b )
101
1025: ands ip, r2, #28
103 rsb ip, ip, #32
104 addne pc, pc, ip @ C is always clear here
105 b 7f
1066: nop
107 ldr r3, [r1], #4
108 ldr r4, [r1], #4
109 ldr r5, [r1], #4
110 ldr r6, [r1], #4
111 ldr r7, [r1], #4
112 ldr r8, [r1], #4
113 ldr lr, [r1], #4
114
115 add pc, pc, ip
116 nop
117 nop
118 str r3, [r0], #4
119 str r4, [r0], #4
120 str r5, [r0], #4
121 str r6, [r0], #4
122 str r7, [r0], #4
123 str r8, [r0], #4
124 str lr, [r0], #4
125
126 CALGN( bcs 2b )
127
1287: ldmfd sp!, {r5 - r8}
129
1308: movs r2, r2, lsl #31
131 ldrneb r3, [r1], #1
132 ldrcsb r4, [r1], #1
133 ldrcsb ip, [r1]
134 strneb r3, [r0], #1
135 strcsb r4, [r0], #1
136 strcsb ip, [r0]
137
138 ldmfd sp!, {r0, r4, pc}
139
1409: rsb ip, ip, #4
141 cmp ip, #2
142 ldrgtb r3, [r1], #1
143 ldrgeb r4, [r1], #1
144 ldrb lr, [r1], #1
145 strgtb r3, [r0], #1
146 strgeb r4, [r0], #1
147 subs r2, r2, ip
148 strb lr, [r0], #1
149 blt 8b
150 ands ip, r1, #3
151 beq 1b
152
15310: bic r1, r1, #3
154 cmp ip, #2
155 ldr lr, [r1], #4
156 beq 17f
157 bgt 18f
158
159
160 .macro forward_copy_shift pull push
161
162 subs r2, r2, #28
163 blt 14f
164
165 CALGN( ands ip, r1, #31 )
166 CALGN( rsb ip, ip, #32 )
167 CALGN( sbcnes r4, ip, r2 ) @ C is always set here
168 CALGN( subcc r2, r2, ip )
169 CALGN( bcc 15f )
170
17111: stmfd sp!, {r5 - r9}
172
173 PLD( pld [r1, #0] )
174 PLD( subs r2, r2, #96 )
175 PLD( pld [r1, #28] )
176 PLD( blt 13f )
177 PLD( pld [r1, #60] )
178 PLD( pld [r1, #92] )
179
18012: PLD( pld [r1, #124] )
18113: ldmia r1!, {r4, r5, r6, r7}
182 mov r3, lr, pull #\pull
183 subs r2, r2, #32
184 ldmia r1!, {r8, r9, ip, lr}
185 orr r3, r3, r4, push #\push
186 mov r4, r4, pull #\pull
187 orr r4, r4, r5, push #\push
188 mov r5, r5, pull #\pull
189 orr r5, r5, r6, push #\push
190 mov r6, r6, pull #\pull
191 orr r6, r6, r7, push #\push
192 mov r7, r7, pull #\pull
193 orr r7, r7, r8, push #\push
194 mov r8, r8, pull #\pull
195 orr r8, r8, r9, push #\push
196 mov r9, r9, pull #\pull
197 orr r9, r9, ip, push #\push
198 mov ip, ip, pull #\pull
199 orr ip, ip, lr, push #\push
200 stmia r0!, {r3, r4, r5, r6, r7, r8, r9, ip}
201 bge 12b
202 PLD( cmn r2, #96 )
203 PLD( bge 13b )
204
205 ldmfd sp!, {r5 - r9}
206
20714: ands ip, r2, #28
208 beq 16f
209
21015: mov r3, lr, pull #\pull
211 ldr lr, [r1], #4
212 subs ip, ip, #4
213 orr r3, r3, lr, push #\push
214 str r3, [r0], #4
215 bgt 15b
216 CALGN( cmp r2, #0 )
217 CALGN( bge 11b )
218
21916: sub r1, r1, #(\push / 8)
220 b 8b
221
222 .endm
223
224
225 forward_copy_shift pull=8 push=24
226
22717: forward_copy_shift pull=16 push=16
228
22918: forward_copy_shift pull=24 push=8
230
231.endfunc
diff --git a/legacy/evil/src/bin/suite.c b/legacy/evil/src/bin/suite.c
new file mode 100644
index 0000000000..9a1661db1e
--- /dev/null
+++ b/legacy/evil/src/bin/suite.c
@@ -0,0 +1,191 @@
1#include <stdlib.h>
2#include <stdio.h>
3
4#define WIN32_LEAN_AND_MEAN
5#include <windows.h>
6#undef WIN32_LEAN_AND_MEAN
7
8#include "suite.h"
9#include "test_memcpy.h"
10
11
12typedef void(*function)(void);
13
14struct test
15{
16 const char *name;
17 function fct;
18};
19
20struct list
21{
22 void *data;
23 list *next;
24};
25
26struct suite
27{
28 list *first;
29 list *l;
30};
31
32
33unsigned char *buf1 = NULL;
34unsigned char *buf2 = NULL;
35size_t page_size = 0;
36
37
38suite *
39suite_new(void)
40{
41 suite *s;
42
43 if (!QueryPerformanceFrequency(&freq))
44 return NULL;
45
46 s = (suite *)malloc(sizeof(suite));
47 if (!s) return NULL;
48
49 s->first = NULL;
50 s->l = NULL;
51
52 return s;
53}
54
55void
56suite_del(suite *s)
57{
58 list *l;
59 list *tmp;
60
61 if (!s) return;
62
63 l = s->first;
64 while (l)
65 {
66 tmp = l->next;
67 free(l->data);
68 free(l);
69 l = tmp;
70 }
71
72 free(s);
73}
74
75void
76suite_time_start()
77{
78 QueryPerformanceCounter(&start);
79}
80
81void
82suite_time_stop()
83{
84 QueryPerformanceCounter(&end);
85}
86
87double
88suite_time_get()
89{
90 return (double)(end.QuadPart - start.QuadPart) / (double)freq.QuadPart;
91}
92
93void
94suite_test_add(suite *s, const char *name, function fct)
95{
96 test *t;
97 list *l;
98
99 t = (test *)malloc(sizeof(test));
100 if (!t) return;
101
102 l = (list *)malloc(sizeof(list));
103 if (!l)
104 {
105 free(t);
106 return;
107 }
108
109 t->name = name;
110 t->fct = fct;
111
112 l->data = t;
113 l->next = NULL;
114
115 if (!s->first) s->first = l;
116
117 if (!s->l)
118 s->l = l;
119 else
120 {
121 s->l->next = l;
122 s->l =l;
123 }
124}
125
126void
127suite_run(suite *s)
128{
129 list *l;
130
131 l = s->first;
132 while (l)
133 {
134 test *t;
135
136 t = (test *)l->data;
137 printf("%s test\n", t->name);
138 t->fct();
139 l = l->next;
140 }
141}
142
143int
144main()
145{
146 test tests[] = {
147 { "memcpy", test_memcpy },
148 { NULL, NULL },
149 };
150 suite *s;
151 int i;
152
153 page_size = 2 * getpagesize();
154
155 buf1 = (unsigned char *)malloc(4 * getpagesize());
156 if (!buf1) return EXIT_FAILURE;
157
158 buf2 = (unsigned char *)malloc(4 * getpagesize());
159 if (!buf2)
160 {
161 free(buf1);
162 return EXIT_FAILURE;
163 }
164
165 memset (buf1, 0xa5, page_size);
166 memset (buf2, 0x5a, page_size);
167
168 s = suite_new();
169 if (!s)
170 {
171 free(buf2);
172 free(buf1);
173 return EXIT_FAILURE;
174 }
175
176 for (i = 0; ; ++i)
177 {
178 if (!tests[i].name)
179 break;
180
181 suite_test_add(s, tests[i].name, tests[i].fct);
182 }
183
184 suite_run(s);
185
186 suite_del(s);
187 free(buf2);
188 free(buf1);
189
190 return EXIT_SUCCESS;
191}
diff --git a/legacy/evil/src/bin/suite.h b/legacy/evil/src/bin/suite.h
new file mode 100644
index 0000000000..3cb2f26ea3
--- /dev/null
+++ b/legacy/evil/src/bin/suite.h
@@ -0,0 +1,18 @@
1#ifndef __EVIL_SUITE_H__
2#define __EVIL_SUITE_H__
3
4
5typedef struct test test;
6typedef struct list list;
7typedef struct suite suite;
8
9LARGE_INTEGER freq;
10LARGE_INTEGER start;
11LARGE_INTEGER end;
12
13void suite_time_start();
14void suite_time_stop();
15double suite_time_get();
16
17
18#endif /* __EVIL_SUITE_H__ */
diff --git a/legacy/evil/src/bin/test_memcpy.c b/legacy/evil/src/bin/test_memcpy.c
new file mode 100644
index 0000000000..ea2bcacba0
--- /dev/null
+++ b/legacy/evil/src/bin/test_memcpy.c
@@ -0,0 +1,113 @@
1
2#include <stdlib.h>
3#include <stdio.h>
4#include <sys/time.h>
5
6#define WIN32_LEAN_AND_MEAN
7#include <windows.h>
8#undef WIN32_LEAN_AND_MEAN
9
10#include "suite.h"
11#include "test_memcpy.h"
12
13
14typedef void *(*memcpy_decl)(void *dest, const void *src, size_t n);
15
16void *memcpy_glibc(void *dest, const void *src, size_t n);
17
18
19extern unsigned char *buf1;
20extern unsigned char *buf2;
21extern size_t page_size;
22
23
24static void
25test_memcpy_test_run(memcpy_decl fct, char *dst, const char *src, size_t len)
26{
27 double start;
28 double end;
29 double best;
30 int i;
31
32 best = 1000000000.0;
33
34 for (i = 0; i < 32; ++i)
35 {
36 double time;
37
38 suite_time_start();
39 fct(dst, src, len);
40 suite_time_stop();
41 time = suite_time_get();
42 if (time < best) best = time;
43 }
44
45 printf (" %e", best);
46}
47
48static void
49test_memcpy_tests_run(size_t align1, size_t align2, size_t len)
50{
51 size_t i, j;
52 char *s1, *s2;
53
54 printf ("running test..\n");
55
56/* align1 &= 63; */
57/* if (align1 + len >= page_size) */
58/* return; */
59
60/* align2 &= 63; */
61/* if (align2 + len >= page_size) */
62/* return; */
63
64 s1 = (char *) (buf1 + align1);
65 s2 = (char *) (buf2 + align2);
66
67 for (i = 0, j = 1; i < len; i++, j += 23)
68 s1[i] = j;
69
70 printf ("length: %6d, align %2d/%2d:", (int)len, align1, align2);
71
72 test_memcpy_test_run(memcpy, s2, s1, len);
73 test_memcpy_test_run(memcpy_glibc, s2, s1, len);
74
75 printf ("\n");
76}
77
78void
79test_memcpy(void)
80{
81 size_t i;
82
83/* for (i = 0; i < 18; ++i) */
84/* { */
85/* test_memcpy_tests_run(0, 0, 1 << i); */
86/* test_memcpy_tests_run(i, 0, 1 << i); */
87/* test_memcpy_tests_run(0, i, 1 << i); */
88/* test_memcpy_tests_run(i, i, 1 << i); */
89/* } */
90
91/* for (i = 0; i < 32; ++i) */
92/* { */
93/* test_memcpy_tests_run(0, 0, i); */
94/* test_memcpy_tests_run(i, 0, i); */
95/* test_memcpy_tests_run(0, i, i); */
96/* test_memcpy_tests_run(i, i, i); */
97/* } */
98
99/* for (i = 3; i < 32; ++i) */
100/* { */
101/* if ((i & (i - 1)) == 0) */
102/* continue; */
103/* test_memcpy_tests_run(0, 0, 16 * i); */
104/* test_memcpy_tests_run(i, 0, 16 * i); */
105/* test_memcpy_tests_run(0, i, 16 * i); */
106/* test_memcpy_tests_run(i, i, 16 * i); */
107/* } */
108
109 test_memcpy_tests_run(0, 0, getpagesize ());
110 test_memcpy_tests_run(0, 0, 2 * getpagesize ());
111 test_memcpy_tests_run(0, 0, 4 * getpagesize ());
112 test_memcpy_tests_run(0, 0, 8 * getpagesize ());
113}
diff --git a/legacy/evil/src/bin/test_memcpy.h b/legacy/evil/src/bin/test_memcpy.h
new file mode 100644
index 0000000000..a89f19e978
--- /dev/null
+++ b/legacy/evil/src/bin/test_memcpy.h
@@ -0,0 +1,8 @@
1#ifndef __EVIL_TEST_MEMCPY__
2#define __EVIL_TEST_MEMCPY__
3
4
5void test_memcpy(void);
6
7
8#endif /* __EVIL_TEST_MEMCPY__ */
diff --git a/legacy/evil/src/lib/Evil.h b/legacy/evil/src/lib/Evil.h
index 185031465f..afc2120ead 100644
--- a/legacy/evil/src/lib/Evil.h
+++ b/legacy/evil/src/lib/Evil.h
@@ -74,6 +74,10 @@ extern "C" {
74 74
75#define PATH_MAX MAX_PATH 75#define PATH_MAX MAX_PATH
76 76
77#include "evil_stdlib.h"
78#include "evil_unistd.h"
79#include "evil_util.h"
80
77 81
78#ifndef __CEGCC__ 82#ifndef __CEGCC__
79 83
@@ -132,7 +136,6 @@ extern "C" {
132 136
133#ifdef _MSC_VER 137#ifdef _MSC_VER
134 138
135typedef int pid_t;
136typedef long ssize_t; 139typedef long ssize_t;
137typedef unsigned short mode_t; 140typedef unsigned short mode_t;
138 141
@@ -180,360 +183,9 @@ struct flock
180 */ 183 */
181EAPI int fcntl(int fd, int cmd, ...); 184EAPI int fcntl(int fd, int cmd, ...);
182 185
183/**
184 * @brief Make temporay unique file name.
185 *
186 * @param template Template of the file to create.
187 * @return A file descriptor on success, -1 otherwise.
188 *
189 * Take the given file name @p template and overwrite a portion of it
190 * to create a file name. This file is guaranted not to exist at the
191 * time invocation and is suitable for use by the function.
192 *
193 * The @p template parameter can be any file name with some number of
194 * 'Xs' appended to it, for example @em baseXXXXXX, where @em base is
195 * the part of the new file that you supply and eacg 'X' is a placeholder
196 * for a character supplied by mkstemp(). The trailing 'Xs' are replaced
197 * with a five-digit value; this value is a unique number. Each successful
198 * call to mkstemp() modifes @p template.
199 *
200 * When mkstemp() succeeds, it creates and opens the template file for
201 * reading and writing.
202 *
203 * On success, the function returns the file descriptor of the
204 * temporary file. Otherwise, it returns -1 and errno is set to the
205 * following values:
206 * - EINVAL: @p template has an invalid format.
207 * - EACCESS: Given path is a directory, or file is read-only, but an
208 * open-for-writing operation was attempted.
209 * - EEXISTS: File name already exists.
210 * - EMFILE: No more file descriptors available.
211 * - ENOENT: File or path not found.
212 *
213 * Conformity: Should follow BSD conformity.
214 *
215 * Supported OS: Windows 98, Windows Me, Windows NT, Windows 2000,
216 * Windows XP.
217 *
218 * @ingroup Evil
219 */
220EAPI int mkstemp(char *template);
221
222/**
223 * @brief Return the process identifier of the calling process.
224 *
225 * @return The process ID.
226 *
227 * Return the process identifier of the calling process. Until
228 * the process terminates, the process identifier uniquely
229 * identifies the process throughout the system.
230 *
231 * Conformity: Not appliclable.
232 *
233 * Supported OS: Windows 98, Windows Me, Windows NT, Windows 2000,
234 * Windows XP.
235 *
236 * @ingroup Evil
237 */
238EAPI pid_t getpid(void);
239
240/**
241 * @brief Create a shell link.
242 *
243 * @param oldpath The file name to be linked.
244 * @param newpath The file name to create.
245 * @return 0 on success, -1 otherwise.
246 *
247 * Create a shell link @p newpath to @p oldpath (@p newpath is the
248 * name of the file created, @p oldpath is the string used in
249 * creating the shell link).
250 *
251 * On success, this function returns 0. Otherwise, it returns -1 and
252 * errno may be set to the following value:
253 * - ENOMEM: Not enough memory.
254 *
255 * On Windows, the symbolic links do not exist. Nevertheless
256 * shell links can be created. This function is named like the Unix
257 * function for portability reasons.
258 *
259 * Conformity: None.
260 *
261 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
262 * Windows XP.
263 *
264 * @ingroup Evil
265 */
266EAPI int symlink(const char *oldpath, const char *newpath);
267
268/**
269 * @brief Read value of a shell link.
270 *
271 * @param path The file name to be linked.
272 * @param buf The file name to create.
273 * @param bufsiz The size of the buffer.
274 * @return 0 on success, -1 otherwise.
275 *
276 * Place the content of the shell link @p path in the buffer
277 * @p buf, which has size @p bufzsiz.
278 *
279 * On success, this function returns the count of characters
280 * placed in the buffer. Otherwise, it returns -1 and errno may
281 * be set to the following value:
282 * - ENOMEM: Not enough memory.
283 *
284 * On Windows, the symbolic links do not exist. Nevertheless
285 * shell links can be managed. This function is named like the Unix
286 * function for portability reasons.
287 *
288 * Conformity: None.
289 *
290 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
291 * Windows XP.
292 *
293 * @ingroup Evil
294 */
295EAPI ssize_t readlink(const char *path, char *buf, size_t bufsiz);
296
297/**
298 * @brief Create, modify, or remove environment variables.
299 *
300 * @param name The name of the environment variable.
301 * @param value The value of the environment variable to set.
302 * @return 0 on success, -1 otherwise.
303 *
304 * Add the new environment variable @p name or modify its value if it
305 * exists, and set it to @p value. Environment variables define the
306 * environment in which a process executes. If @p value is @c NULL, the
307 * variable is removed (unset) and that call is equivalent to unsetenv().
308 * If the function succeeds, it returns 0, otherwise it returns -1.
309 *
310 * Conformity: Non applicable.
311 *
312 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
313 * Windows XP.
314 *
315 * @ingroup Evil
316 */
317EAPI int setenv(const char *name, const char *value);
318
319/**
320 * @brief Remove environment variables.
321 *
322 * @param name The name of the environment variable.
323 * @return 0 on success, -1 otherwise.
324 *
325 * Remove the new environment variable @p name if it exists. That
326 * function is equivalent to setenv() with its second parameter to
327 * @c NULL. If the function succeeds, it returns 0, otherwise it
328 * returns -1.
329 *
330 * Conformity: Non applicable.
331 *
332 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
333 * Windows XP.
334 *
335 * @ingroup Evil
336 */
337EAPI int unsetenv(const char *name);
338 186
339#endif /* ! __CEGCC__ */ 187#endif /* ! __CEGCC__ */
340 188
341/**
342 * @brief Return an absolute or full path name for a specified relative path name.
343 *
344 * @param file_name The absolute path name.
345 * @param resolved_name The relative path name.
346 * @return @c NULL on failure, a pointer to the absolute path name otherwise.
347 *
348 * The function expands the relative path name @p file_name to its
349 * fully qualified or absolute path and store it in the buffer pointed
350 * by @p resolved_name. The buffer is at most @c PATH_MAX bytes long.
351 * If @p resolved_name is @c NULL, malloc() is used to allocate a
352 * buffer of sufficient length to hold the path name. In that case, it
353 * is the responsability of the caller to free this buffer with free().
354 *
355 * That function can be used to obtain the absolute path name for
356 * relative paths (relPath) that include "./" or "../" in their names.
357 *
358 * Conformity: None.
359 *
360 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
361 * Windows XP.
362 *
363 * @ingroup Evil
364 */
365EAPI char *realpath(const char *file_name, char *resolved_name);
366
367/**
368 * @brief Initiates the use of Windows sockets.
369 *
370 * @return 1 on success, 0 otherwise.
371 *
372 * Initiates the use of Windows sockets. If the function succeeds,
373 * it returns 1, otherwise it returns 0.
374 *
375 * Conformity: Non applicable.
376 *
377 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
378 * Windows XP.
379 *
380 * @ingroup Evil
381 */
382EAPI int evil_sockets_init(void);
383
384/**
385 * @brief Shutdown the Windows socket system.
386 *
387 * Shutdown the Windows socket system.
388 *
389 * Conformity: Non applicable.
390 *
391 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
392 * Windows XP.
393 *
394 * @ingroup Evil
395 */
396EAPI void evil_sockets_shutdown(void);
397
398/**
399 * @brief Create a pair of sockets.
400 *
401 * @param fds A pointer that contains two sockets.
402 *
403 * Create a pair of sockets that can be use with select().
404 * Hence, evil_sockets_init() must have been caled at least
405 * once before. Contrary to Unix, that functions does not
406 * create a pair of file descriptors.
407 *
408 * Conformity: Not applicable.
409 *
410 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
411 * Windows XP.
412 *
413 * @ingroup Evil
414 */
415EAPI int evil_pipe(int *fds);
416
417/**
418 * @brief Return a dir to store temporary files.
419 *
420 * @return The directory to store temporary files.
421 *
422 * Return a directory to store temporary files. The function gets
423 * the value of the following environment variables, and in that order:
424 * - TMP
425 * - TEMP
426 * - USERPROFILE
427 * - WINDIR
428 * and returns its value if it exists. If none exists, the function
429 * returns "C:\".
430 *
431 * Conformity: Non applicable.
432 *
433 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
434 * Windows XP.
435 *
436 * @ingroup Evil
437 */
438EAPI const char *evil_tmpdir_get(void);
439
440/**
441 * @brief Return a dir to store personal files.
442 *
443 * @return The directory to store personal files.
444 *
445 * Return a directory to store personal files. The function gets
446 * the value of the following environment variables, and in that order:
447 * - HOME
448 * - USERPROFILE
449 * - WINDIR
450 * and returns its value if it exists. If none exists, the function
451 * returns "C:\".
452 *
453 * Conformity: Non applicable.
454 *
455 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
456 * Windows XP.
457 *
458 * @ingroup Evil
459 */
460 EAPI const char *evil_homedir_get(void);
461
462/**
463 * @brief Get the current directory.
464 *
465 * @param buffer Buffer to store the current directory.
466 * @param size Size of the buffer.
467 * @return The current directory.
468 *
469 * On Windows desktop, use the _getcwd function in MSVCRT.
470 *
471 * On Windows CE, get the current directory by extracting the path
472 * from the executable that is running and put the result in @p buffer
473 * of length @p size. If @p size is less or equal than 0, return NULL.
474 * If the current absolute path would require a buffer longer than
475 * @p size elements, NULL is returned. If @p buffer is NULL, a buffer
476 * of length @p size is allocated and is returned. If the allocation
477 * fails, NULL is returned. On success, @p buffer is returned and
478 * contains the current directory. The last '\' is not included.
479 * If @p buffer is NULL, the returned value must be freed if not NULL.
480 *
481 * Specially usefull on WinCE where the current directory functionality
482 * is not supported.
483 *
484 * Conformity: Almost POSIX.1 (no errno set)
485 *
486 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
487 * Windows XP, WinCE.
488 *
489 * @ingroup Evil
490 */
491EAPI char *evil_getcwd(char *buffer, size_t size);
492
493#ifdef UNICODE
494
495/**
496 * @brief Convert a string from char * to wchar_t *.
497 *
498 * @param text The string to convert.
499 * @return The converted string.
500 *
501 * Convert a string from char * to wchar_t * and return it. If the
502 * allocation or conversion fails, NULL is returned. On success, the
503 * returned value must be freed.
504 *
505 * Conformity: Non applicable.
506 *
507 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
508 * Windows XP.
509 *
510 * @ingroup Evil
511 */
512EAPI wchar_t *evil_char_to_wchar(const char *text);
513
514/**
515 * @brief Convert a string from wchar_t * to char *.
516 *
517 * @param text The string to convert.
518 * @return The converted string.
519 *
520 * Convert a string from wchar_t * to char * and return it. If the
521 * allocation or conversion fails, NULL is returned. On success, the
522 * returned value must be freed.
523 *
524 * Conformity: Non applicable.
525 *
526 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
527 * Windows XP.
528 *
529 * @ingroup Evil
530 */
531EAPI char *evil_wchar_to_char(const wchar_t *text);
532
533#endif /* UNICODE */
534
535EAPI char *evil_last_error_get(void);
536
537typedef int nl_item; 189typedef int nl_item;
538 190
539#define __NL_ITEM( CATEGORY, INDEX ) ((CATEGORY << 16) | INDEX) 191#define __NL_ITEM( CATEGORY, INDEX ) ((CATEGORY << 16) | INDEX)
diff --git a/legacy/evil/src/lib/Makefile.am b/legacy/evil/src/lib/Makefile.am
index 4167713437..f66c565821 100644
--- a/legacy/evil/src/lib/Makefile.am
+++ b/legacy/evil/src/lib/Makefile.am
@@ -1,14 +1,22 @@
1 1
2MAINTAINERCLEANFILES = Makefile.in 2MAINTAINERCLEANFILES = Makefile.in
3 3
4SUBDIRS = . dlfcn mman pwd 4SUBDIRS = . dlfcn
5 5
6lib_LTLIBRARIES = libevil.la 6lib_LTLIBRARIES = libevil.la
7 7
8include_HEADERS = Evil.h 8include_HEADERS = Evil.h evil_stdlib.h evil_unistd.h evil_util.h
9libevil_la_SOURCES = evil.c 9nobase_include_HEADERS = sys/mman.h
10
11libevil_la_SOURCES = \
12evil.c \
13evil_mman.c \
14evil_pwd.c \
15evil_stdlib.c \
16evil_unistd.c \
17evil_util.c
10 18
11libevil_la_CFLAGS = @win32_cflags@ 19libevil_la_CFLAGS = @win32_cflags@
12libevil_la_LIBADD = @win32_libs@ 20libevil_la_LIBADD = @win32_libs@
13libevil_la_DEPENDENCIES = $(top_builddir)/config.h 21libevil_la_DEPENDENCIES = $(top_builddir)/config.h
14libevil_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ 22libevil_la_LDFLAGS = -no-undefined -Wl,--enable-auto-import -version-info @version_info@
diff --git a/legacy/evil/src/lib/dlfcn/Makefile.am b/legacy/evil/src/lib/dlfcn/Makefile.am
index b67e47ab58..efff02ca8c 100644
--- a/legacy/evil/src/lib/dlfcn/Makefile.am
+++ b/legacy/evil/src/lib/dlfcn/Makefile.am
@@ -9,4 +9,4 @@ libdl_la_SOURCES = dlfcn.c
9libdl_la_CFLAGS = @win32_cflags@ 9libdl_la_CFLAGS = @win32_cflags@
10libdl_la_LIBADD = $(top_builddir)/src/lib/libevil.la 10libdl_la_LIBADD = $(top_builddir)/src/lib/libevil.la
11libdl_la_DEPENDENCIES = $(top_builddir)/src/lib/libevil.la 11libdl_la_DEPENDENCIES = $(top_builddir)/src/lib/libevil.la
12libdl_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ 12libdl_la_LDFLAGS = -no-undefined -Wl,--enable-auto-import -version-info @version_info@
diff --git a/legacy/evil/src/lib/evil.c b/legacy/evil/src/lib/evil.c
index 947d527c42..fb90e8ef5e 100644
--- a/legacy/evil/src/lib/evil.c
+++ b/legacy/evil/src/lib/evil.c
@@ -36,7 +36,6 @@
36#endif /* HAVE___ATTRIBUTE__ */ 36#endif /* HAVE___ATTRIBUTE__ */
37 37
38#include "Evil.h" 38#include "Evil.h"
39#include "pwd/pwd.h"
40 39
41 40
42static struct passwd pw; 41static struct passwd pw;
@@ -104,529 +103,8 @@ int fcntl(int fd, int cmd, ...)
104 return res; 103 return res;
105} 104}
106 105
107int
108mkstemp(char *template)
109{
110 int fd;
111
112#ifdef __MINGW32__
113 if (!_mktemp(template))
114 return -1;
115
116 fd = _sopen(template, _O_RDWR | _O_BINARY | _O_CREAT | _O_EXCL, _SH_DENYNO, _S_IREAD | _S_IWRITE);
117#else
118 if (_mktemp_s(template, _MAX_PATH) != 0)
119 return -1;
120
121 _sopen_s(&fd, template, _O_RDWR | _O_BINARY | _O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE);
122#endif /* ! __MINGW32__ */
123
124 return fd;
125}
126
127pid_t
128getpid(void)
129{
130 return (pid_t)GetCurrentProcessId();
131}
132
133struct passwd *
134getpwuid (uid_t uid)
135{
136 static char user_name[PATH_MAX];
137 DWORD length;
138 BOOL res;
139
140 length = PATH_MAX;
141 /* get from USERPROFILE for win 98 ? */
142 res = GetUserName(user_name, &length);
143 pw.pw_name = (res ? user_name : NULL);
144 pw.pw_passwd = NULL;
145 pw.pw_uid = uid;
146 pw.pw_gid = 0;
147 pw.pw_change = 0;
148 pw.pw_class = NULL;
149 pw.pw_gecos = (res ? user_name : NULL);
150 pw.pw_dir = (char *)evil_homedir_get();
151 pw.pw_shell = getenv("SHELL");
152 if (pw.pw_shell == NULL)
153 pw.pw_shell = "sh";
154 pw.pw_expire = 0;
155 pw.pw_fields = 0;
156
157 return &pw;
158}
159
160/* REMARK: Windows has no symbolic link. */
161/* Nevertheless, it can create and read .lnk files */
162int
163symlink(const char *oldpath, const char *newpath)
164{
165#ifdef UNICODE
166 wchar_t new_path[MB_CUR_MAX];
167#endif /* UNICODE */
168 IShellLink *pISL;
169 IShellLink **shell_link;
170 IPersistFile *pIPF;
171 IPersistFile **persit_file;
172 HRESULT res;
173
174 res = CoInitialize(NULL);
175 if (FAILED(res))
176 {
177 if (res == E_OUTOFMEMORY)
178 errno = ENOMEM;
179 return -1;
180 }
181
182 /* Hack to cleanly remove a warning */
183 shell_link = &pISL;
184 if (FAILED(CoCreateInstance(&CLSID_ShellLink,
185 NULL,
186 CLSCTX_INPROC_SERVER,
187 &IID_IShellLink,
188 (void **)shell_link)))
189 goto no_instance;
190
191 if (FAILED(pISL->lpVtbl->SetPath(pISL, oldpath)))
192 goto no_setpath;
193
194 /* Hack to cleanly remove a warning */
195 persit_file = &pIPF;
196 if (FAILED(pISL->lpVtbl->QueryInterface(pISL, &IID_IPersistFile, (void **)persit_file)))
197 goto no_queryinterface;
198
199#ifdef UNICODE
200 mbstowcs(new_path, newpath, MB_CUR_MAX);
201 if (FAILED(pIPF->lpVtbl->Save(pIPF, new_path, FALSE)))
202 goto no_save;
203#else
204 if (FAILED(pIPF->lpVtbl->Save(pIPF, newpath, FALSE)))
205 goto no_save;
206#endif /* ! UNICODE */
207
208 pIPF->lpVtbl->Release(pIPF);
209 pISL->lpVtbl->Release(pISL);
210 CoUninitialize();
211
212 return 0;
213
214 no_save:
215 pIPF->lpVtbl->Release(pIPF);
216 no_queryinterface:
217 no_setpath:
218 pISL->lpVtbl->Release(pISL);
219 no_instance:
220 CoUninitialize();
221 return -1;
222}
223
224ssize_t
225readlink(const char *path, char *buf, size_t bufsiz)
226{
227#ifdef UNICODE
228 wchar_t old_path[MB_CUR_MAX];
229#endif /* UNICODE */
230 char new_path[PATH_MAX];
231 IShellLink *pISL;
232 IShellLink **shell_link;
233 IPersistFile *pIPF;
234 IPersistFile **persit_file;
235 unsigned int length;
236 HRESULT res;
237
238 res = CoInitialize(NULL);
239 if (FAILED(res))
240 {
241 if (res == E_OUTOFMEMORY)
242 errno = ENOMEM;
243 return -1;
244 }
245
246 /* Hack to cleanly remove a warning */
247 persit_file = &pIPF;
248 if (FAILED(CoCreateInstance(&CLSID_ShellLink,
249 NULL,
250 CLSCTX_INPROC_SERVER,
251 &IID_IPersistFile,
252 (void **)persit_file)))
253 goto no_instance;
254
255#ifdef UNICODE
256 mbstowcs(old_path, path, MB_CUR_MAX);
257 if (FAILED(pIPF->lpVtbl->Load(pIPF, old_path, STGM_READWRITE)))
258 goto no_load;
259#else
260 if (FAILED(pIPF->lpVtbl->Load(pIPF, path, STGM_READWRITE)))
261 goto no_load;
262#endif /* ! UNICODE */
263
264 shell_link = &pISL;
265 if (FAILED(pIPF->lpVtbl->QueryInterface(pIPF, &IID_IShellLink, (void **)shell_link)))
266 goto no_queryinterface;
267
268 if (FAILED(pISL->lpVtbl->GetPath(pISL, new_path, PATH_MAX, NULL, 0)))
269 goto no_getpath;
270
271 length = strlen(new_path);
272 if (length > bufsiz)
273 length = bufsiz;
274
275 memcpy(buf, new_path, length);
276
277 pISL->lpVtbl->Release(pISL);
278 pIPF->lpVtbl->Release(pIPF);
279 CoUninitialize();
280
281 return length;
282
283 no_getpath:
284 pISL->lpVtbl->Release(pISL);
285 no_queryinterface:
286 no_load:
287 pIPF->lpVtbl->Release(pIPF);
288 no_instance:
289 CoUninitialize();
290 return -1;
291}
292
293int
294setenv(const char *name, const char *value)
295{
296 char *str;
297 int length;
298 int res;
299
300 length = strlen(name) + strlen(value) + 2;
301 str = (char *)malloc(length);
302 sprintf(str, "%s=%s", name, value);
303 res = _putenv(str);
304 free(str);
305
306 return res;
307}
308
309int
310unsetenv(const char *name)
311{
312 char *str;
313 int length;
314 int res;
315
316 length = strlen(name) + 2;
317 str = (char *)malloc(length);
318 sprintf(str, "%s=", name);
319 res = _putenv(str);
320 free(str);
321
322 return res;
323}
324
325#endif /* ! __CEGCC__ */ 106#endif /* ! __CEGCC__ */
326 107
327char *
328realpath(const char *file_name, char *resolved_name)
329{
330#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) )
331 return _fullpath(resolved_name, file_name, PATH_MAX);
332#else
333 int length;
334
335 length = strlen(file_name);
336 if ((length + 1) > PATH_MAX)
337 length = PATH_MAX - 1;
338 memcpy(resolved_name, file_name, length);
339 resolved_name[length] = '\0';
340
341 return resolved_name;
342#endif /* __CEGCC__ || __MINGW32CE__ */
343}
344
345int
346evil_sockets_init(void)
347{
348 WSADATA wsa_data;
349
350 return (WSAStartup(MAKEWORD( 2, 2 ), &wsa_data) == 0) ? 1 : 0;
351}
352
353void
354evil_sockets_shutdown(void)
355{
356 WSACleanup();
357}
358
359/*
360 * The code of the following functions has been kindly offered
361 * by Tor Lillqvist.
362 */
363int
364evil_pipe(int *fds)
365{
366 struct sockaddr_in saddr;
367 struct timeval tv;
368 SOCKET temp;
369 SOCKET socket1 = INVALID_SOCKET;
370 SOCKET socket2 = INVALID_SOCKET;
371 u_long arg;
372 fd_set read_set;
373 fd_set write_set;
374 int len;
375
376 temp = socket (AF_INET, SOCK_STREAM, 0);
377
378 if (temp == INVALID_SOCKET)
379 goto out0;
380
381 arg = 1;
382 if (ioctlsocket (temp, FIONBIO, &arg) == SOCKET_ERROR)
383 goto out0;
384
385 memset (&saddr, 0, sizeof (saddr));
386 saddr.sin_family = AF_INET;
387 saddr.sin_port = 0;
388 saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
389
390 if (bind (temp, (struct sockaddr *)&saddr, sizeof (saddr)))
391 goto out0;
392
393 if (listen (temp, 1) == SOCKET_ERROR)
394 goto out0;
395
396 len = sizeof (saddr);
397 if (getsockname (temp, (struct sockaddr *)&saddr, &len))
398 goto out0;
399
400 socket1 = socket (AF_INET, SOCK_STREAM, 0);
401
402 if (socket1 == INVALID_SOCKET)
403 goto out0;
404
405 arg = 1;
406 if (ioctlsocket (socket1, FIONBIO, &arg) == SOCKET_ERROR)
407 goto out1;
408
409 if ((connect (socket1, (struct sockaddr *)&saddr, len) == SOCKET_ERROR) &&
410 (WSAGetLastError () != WSAEWOULDBLOCK))
411 goto out1;
412
413 FD_ZERO (&read_set);
414 FD_SET (temp, &read_set);
415
416 tv.tv_sec = 0;
417 tv.tv_usec = 0;
418
419 if (select (0, &read_set, NULL, NULL, NULL) == SOCKET_ERROR)
420 goto out1;
421
422 if (!FD_ISSET (temp, &read_set))
423 goto out1;
424
425 socket2 = accept (temp, (struct sockaddr *) &saddr, &len);
426 if (socket2 == INVALID_SOCKET)
427 goto out1;
428
429 FD_ZERO (&write_set);
430 FD_SET (socket1, &write_set);
431
432 tv.tv_sec = 0;
433 tv.tv_usec = 0;
434
435 if (select (0, NULL, &write_set, NULL, NULL) == SOCKET_ERROR)
436 goto out2;
437
438 if (!FD_ISSET (socket1, &write_set))
439 goto out2;
440
441 arg = 0;
442 if (ioctlsocket (socket1, FIONBIO, &arg) == SOCKET_ERROR)
443 goto out2;
444
445 arg = 0;
446 if (ioctlsocket (socket2, FIONBIO, &arg) == SOCKET_ERROR)
447 goto out2;
448
449 fds[0] = socket1;
450 fds[1] = socket2;
451
452 closesocket (temp);
453
454 return 0;
455
456 out2:
457 closesocket (socket2);
458 out1:
459 closesocket (socket1);
460 out0:
461 closesocket (temp);
462
463 fds[0] = INVALID_SOCKET;
464 fds[1] = INVALID_SOCKET;
465
466 return -1;
467}
468
469const char *
470evil_tmpdir_get(void)
471{
472#ifdef _WIN32_WCE
473 return "\\temp";
474#else
475 char *tmpdir;
476
477 tmpdir = getenv("TMP");
478 if (!tmpdir) tmpdir = getenv("TEMP");
479 if (!tmpdir) tmpdir = getenv("USERPROFILE");
480 if (!tmpdir) tmpdir = getenv("WINDIR");
481 if (!tmpdir) tmpdir="C:\\";
482
483 return tmpdir;
484#endif /* ! _WIN32_WCE */
485}
486
487const char *
488evil_homedir_get(void)
489{
490#ifdef _WIN32_WCE
491 return "\\my documents";
492#else
493 char *homedir;
494
495 homedir = getenv("HOME");
496 if (!homedir) homedir = getenv("USERPROFILE");
497 if (!homedir) homedir = getenv("WINDIR");
498 if (!homedir) homedir="C:\\";
499
500 return homedir;
501#endif /* ! _WIN32_WCE */
502}
503
504char *
505evil_getcwd(char *buffer, size_t size)
506{
507#if defined(__CEGCC__) || defined(__MINGW32CE__)
508 wchar_t wpath[PATH_MAX];
509 char *cpath;
510 char *delim;
511 int ret = 0;
512
513 if (size <= 0)
514 return NULL;
515
516 ret = GetModuleFileName(GetModuleHandle(NULL), (LPWSTR)&wpath, PATH_MAX);
517
518 if (!ret)
519 return NULL;
520
521 cpath = evil_wchar_to_char(wpath);
522 if (!cpath)
523 return NULL;
524
525 if (strlen(cpath) >= (size - 1))
526 {
527 free(cpath);
528 return NULL;
529 }
530
531 delim = strrchr(cpath, '\\');
532 if (delim)
533 *delim = '\0';
534
535 if (!buffer)
536 {
537 buffer = (char *)malloc(sizeof(char) * size);
538 if (!buffer)
539 {
540 free(cpath);
541 return NULL;
542 }
543 }
544
545 strcpy(buffer, cpath);
546 free(cpath);
547
548 return buffer;
549#else
550 return _getcwd(buffer, size);
551#endif /* ! __CEGCC__ && ! __MINGW32CE__ */
552}
553
554#ifdef UNICODE
555
556wchar_t *
557evil_char_to_wchar(const char *text)
558{
559 wchar_t *wtext;
560 int wsize;
561
562 wsize = MultiByteToWideChar(CP_ACP, 0, text, strlen(text) + 1, NULL, 0);
563 if ((wsize == 0) ||
564 (wsize > (int)(ULONG_MAX/sizeof(wchar_t))))
565 return NULL;
566
567 wtext = malloc(wsize * sizeof(wchar_t));
568 if (wtext)
569 if (!MultiByteToWideChar(CP_ACP, 0, text, strlen(text) + 1, wtext, wsize))
570 return NULL;
571
572 return wtext;
573}
574
575char *
576evil_wchar_to_char(const wchar_t *text)
577{
578 char * atext;
579 int size;
580 int asize;
581
582 size = wcslen(text) + 1;
583
584 asize = WideCharToMultiByte(CP_ACP, 0, text, size, NULL, 0, NULL, NULL);
585 if (asize == 0)
586 return NULL;
587
588 atext = (char*)malloc((asize + 1) * sizeof(char));
589
590 if (atext)
591 if (!WideCharToMultiByte(CP_ACP, 0, text, size, atext, asize, NULL, NULL))
592 return NULL;
593 atext[asize] = '\0';
594
595 return atext;
596}
597
598#endif /* UNICODE */
599
600char *
601evil_last_error_get(void)
602{
603 char str[PATH_MAX];
604 LPTSTR str1;
605 char *str2;
606 DWORD err;
607
608 err = GetLastError();
609 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
610 NULL,
611 err,
612 0, // Default language
613 (LPTSTR)&str1,
614 0,
615 NULL);
616
617#ifdef UNICODE
618 str2 = evil_wchar_to_char(str1);
619 LocalFree(str1);
620#else
621 str2 = str1;
622#endif /* ! UNICODE */
623
624 snprintf(str, PATH_MAX, "(%ld) %s", err, str2);
625 LocalFree(str2);
626
627 return strdup(str);
628}
629
630static char * 108static char *
631replace(char *prev, char *value) 109replace(char *prev, char *value)
632{ 110{
diff --git a/legacy/evil/src/lib/mman/mman.c b/legacy/evil/src/lib/evil_mman.c
index 6500bd5a7d..b196de435b 100644
--- a/legacy/evil/src/lib/mman/mman.c
+++ b/legacy/evil/src/lib/evil_mman.c
@@ -10,7 +10,7 @@
10# include <io.h> 10# include <io.h>
11#endif /* ! __CEGCC__ */ 11#endif /* ! __CEGCC__ */
12 12
13#include "../Evil.h" 13#include "Evil.h"
14 14
15#ifdef HAVE_CONFIG_H 15#ifdef HAVE_CONFIG_H
16# include "config.h" 16# include "config.h"
diff --git a/legacy/evil/src/lib/evil_pwd.c b/legacy/evil/src/lib/evil_pwd.c
new file mode 100644
index 0000000000..45d7380e60
--- /dev/null
+++ b/legacy/evil/src/lib/evil_pwd.c
@@ -0,0 +1,42 @@
1
2
3#ifdef HAVE_CONFIG_H
4# include "config.h"
5#endif /* HAVE_CONFIG_H */
6
7#include "pwd.h"
8
9
10static struct passwd pw;
11
12
13#ifndef __CEGCC__
14
15struct passwd *
16getpwuid (uid_t uid)
17{
18 static char user_name[PATH_MAX];
19 DWORD length;
20 BOOL res;
21
22 length = PATH_MAX;
23 /* get from USERPROFILE for win 98 ? */
24 res = GetUserName(user_name, &length);
25 pw.pw_name = (res ? user_name : NULL);
26 pw.pw_passwd = NULL;
27 pw.pw_uid = uid;
28 pw.pw_gid = 0;
29 pw.pw_change = 0;
30 pw.pw_class = NULL;
31 pw.pw_gecos = (res ? user_name : NULL);
32 pw.pw_dir = (char *)evil_homedir_get();
33 pw.pw_shell = getenv("SHELL");
34 if (pw.pw_shell == NULL)
35 pw.pw_shell = "sh";
36 pw.pw_expire = 0;
37 pw.pw_fields = 0;
38
39 return &pw;
40}
41
42#endif /* ! __CEGCC__ */
diff --git a/legacy/evil/src/lib/evil_stdlib.c b/legacy/evil/src/lib/evil_stdlib.c
new file mode 100644
index 0000000000..d314938ed8
--- /dev/null
+++ b/legacy/evil/src/lib/evil_stdlib.c
@@ -0,0 +1,268 @@
1
2#include <stdio.h>
3#ifndef __MINGW32CE__
4#include <errno.h>
5#endif /* ! __MINGW32CE__ */
6
7#define WIN32_LEAN_AND_MEAN
8#include <windows.h>
9#undef WIN32_LEAN_AND_MEAN
10
11#ifdef HAVE_CONFIG_H
12# include "config.h"
13#endif /* HAVE_CONFIG_H */
14
15#include "Evil.h"
16
17/*** Local ***/
18
19static void
20_evil_stdlib_error_display(const char *fct,
21 LONG res)
22{
23 char *error;
24
25 error = evil_format_message(res);
26 fprintf(stderr, "[Evil] [%s] ERROR: %ld\n", fct, error);
27 free(error);
28}
29
30/*
31 * Environment variable related functions
32 *
33 * char *getenv (const char *name);
34 * int putenv (const char *string);
35 * int setenv (const char *name, const char *value, int overwrite);
36 * void unsetenv (const char *name);
37 *
38 */
39
40#if defined(__CEGCC__) || defined(__MINGW32CE__)
41
42static char _evil_stdlib_getenv_buffer[PATH_MAX];
43
44char *
45getenv(const char *name)
46{
47 HKEY key;
48 wchar_t *wname;
49 char *buffer;
50 LONG res;
51 DWORD type;
52 DWORD size = PATH_MAX;
53
54 if (!name || !*name)
55 return NULL;
56
57 if ((res = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
58 TEXT("Software\\Efl\\Environment"),
59 0, 0,
60 &key)) != ERROR_SUCCESS)
61 {
62 _evil_stdlib_error_display("getenv", res);
63 return NULL;
64 }
65
66 wname = evil_char_to_wchar(name);
67 if (!wname)
68 {
69 if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
70 _evil_stdlib_error_display("getenv", res);
71 return NULL;
72 }
73
74 if ((res = RegQueryValueEx(key, wname,
75 NULL, &type,
76 (LPBYTE)&buffer,
77 &size)) != ERROR_SUCCESS)
78 {
79 _evil_stdlib_error_display("getenv", res);
80 if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
81 _evil_stdlib_error_display("getenv", res);
82 free(wname);
83 return NULL;
84 }
85
86 free(wname);
87
88 if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
89 {
90 _evil_stdlib_error_display("getenv", res);
91 return NULL;
92 }
93
94 if (buffer[0] == '\0')
95 return NULL;
96 else
97 {
98 return _evil_stdlib_getenv_buffer;
99 }
100}
101
102#endif /* __CEGCC__ || __MINGW32CE__ */
103
104#if ! defined(__CEGCC__)
105
106int
107putenv(const char *string)
108{
109#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) )
110 return _putenv(string);
111#else
112#endif /* __CEGCC__ || __MINGW32CE__ */
113}
114
115#endif /* ! __CEGCC__ */
116
117
118
119int
120setenv(const char *name,
121 const char *value,
122 int overwrite)
123{
124#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) )
125
126 char *old_name;
127 char *str;
128 int length;
129
130 if (!name || !*name)
131 return -1;
132
133 /* if '=' is found, return EINVAL */
134 if (strchr (name, '='))
135 {
136 errno = EINVAL;
137 return -1;
138 }
139
140 /* if name is already set and overwrite is 0, we exit with success */
141 old_name = getenv(name);
142 if (!overwrite && oldname)
143 return 0;
144
145 length = strlen(name) + strlen(value) + 2;
146 str = (char *)malloc(length);
147 if (!str)
148 {
149 errno = ENOMEM;
150 return -1;
151 }
152 if (!value)
153 sprintf(str, "%s=", name);
154 else
155 sprintf(str, "%s=%s", name, value);
156 res = _putenv(str);
157 free(str);
158
159#else /* __CEGCC__ || __MINGW32CE__ */
160
161 HKEY key;
162 LONG res;
163 DWORD disposition;
164
165 if (!name || !*name)
166 return -1;
167
168 /* if '=' is found, return an error */
169 if (strchr (name, '='))
170 return -1;
171
172 if ((res = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
173 TEXT("Software\\Efl\\Environment"),
174 0, NULL,
175 REG_OPTION_VOLATILE,
176 0, NULL,
177 &key,
178 &disposition)) != ERROR_SUCCESS)
179 {
180 _evil_stdlib_error_display("setenv", res);
181 return -1;
182 }
183
184 /* if name is already set and overwrite is 0, we exit with success */
185 if (!overwrite && (disposition == REG_OPENED_EXISTING_KEY))
186 return 0;
187
188 if ((res = RegSetValueEx (key,
189 (LPCWSTR)name,
190 0, REG_SZ,
191 value,
192 strlen(value) + 1)) != ERROR_SUCCESS)
193 {
194 _evil_stdlib_error_display("setenv", res);
195 if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
196 _evil_stdlib_error_display("getenv", res);
197 return -1;
198 }
199
200 if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
201 {
202 _evil_stdlib_error_display("getenv", res);
203 return -1;
204 }
205
206#endif /* __CEGCC__ || __MINGW32CE__ */
207
208 return 0;
209}
210
211#if ! defined(__CEGCC__)
212
213int
214unsetenv(const char *name)
215{
216 setenv(name, NULL, 1);
217}
218
219#endif /* ! __CEGCC__ */
220
221
222/*
223 * Files related functions
224 *
225 */
226
227#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) )
228
229int
230mkstemp(char *template)
231{
232 int fd;
233
234#ifdef __MINGW32__
235 if (!_mktemp(template))
236 return -1;
237
238 fd = _sopen(template, _O_RDWR | _O_BINARY | _O_CREAT | _O_EXCL, _SH_DENYNO, _S_IREAD | _S_IWRITE);
239#else
240 if (_mktemp_s(template, PATH_MAX) != 0)
241 return -1;
242
243 _sopen_s(&fd, template, _O_RDWR | _O_BINARY | _O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE);
244#endif /* ! __MINGW32__ */
245
246 return fd;
247}
248
249#endif /* ! ( __CEGCC__ || __MINGW32CE__ ) */
250
251
252char *
253realpath(const char *file_name, char *resolved_name)
254{
255#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) )
256 return _fullpath(resolved_name, file_name, PATH_MAX);
257#else
258 int length;
259
260 length = strlen(file_name);
261 if ((length + 1) > PATH_MAX)
262 length = PATH_MAX - 1;
263 memcpy(resolved_name, file_name, length);
264 resolved_name[length] = '\0';
265
266 return resolved_name;
267#endif /* __CEGCC__ || __MINGW32CE__ */
268}
diff --git a/legacy/evil/src/lib/evil_stdlib.h b/legacy/evil/src/lib/evil_stdlib.h
new file mode 100644
index 0000000000..387ee6a14d
--- /dev/null
+++ b/legacy/evil/src/lib/evil_stdlib.h
@@ -0,0 +1,145 @@
1#ifndef __EVIL_STDLIB_H__
2#define __EVIL_STDLIB_H__
3
4
5/*
6 * Environment variable related functions
7 *
8 */
9
10#if defined(__CEGCC__) || defined(__MINGW32CE__)
11
12EAPI char *getenv(const char *name);
13
14#endif /* __CEGCC__ || __MINGW32CE__ */
15
16
17#if ! defined(__CEGCC__)
18
19EAPI int putenv(const char *string);
20
21#endif /* ! __CEGCC__ */
22
23/**
24 * @brief Create, modify, or remove environment variables.
25 *
26 * @param name The name of the environment variable.
27 * @param value The value of the environment variable to set.
28 * @return 0 on success, -1 otherwise.
29 *
30 * Add the new environment variable @p name or modify its value if it
31 * exists, and set it to @p value. Environment variables define the
32 * environment in which a process executes. If @p value is @c NULL, the
33 * variable is removed (unset) and that call is equivalent to unsetenv().
34 * If the function succeeds, it returns 0, otherwise it returns -1.
35 *
36 * Conformity: Non applicable.
37 *
38 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
39 * Windows XP.
40 *
41 * @ingroup Evil
42 */
43EAPI int setenv(const char *name,
44 const char *value,
45 int overwrite);
46
47
48#if ! defined(__CEGCC__)
49
50/**
51 * @brief Remove environment variables.
52 *
53 * @param name The name of the environment variable.
54 * @return 0 on success, -1 otherwise.
55 *
56 * Remove the new environment variable @p name if it exists. That
57 * function is equivalent to setenv() with its second parameter to
58 * @c NULL and the third to 1. If the function succeeds, it returns 0,
59 * otherwise it returns -1.
60 *
61 * Conformity: Non applicable.
62 *
63 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
64 * Windows XP.
65 *
66 * @ingroup Evil
67 */
68EAPI int unsetenv(const char *name);
69
70#endif /* ! __CEGCC__ */
71
72
73/*
74 * Files related functions
75 *
76 */
77
78/**
79 * @brief Make temporay unique file name.
80 *
81 * @param template Template of the file to create.
82 * @return A file descriptor on success, -1 otherwise.
83 *
84 * Take the given file name @p template and overwrite a portion of it
85 * to create a file name. This file is guaranted not to exist at the
86 * time invocation and is suitable for use by the function.
87 *
88 * The @p template parameter can be any file name with some number of
89 * 'Xs' appended to it, for example @em baseXXXXXX, where @em base is
90 * the part of the new file that you supply and eacg 'X' is a placeholder
91 * for a character supplied by mkstemp(). The trailing 'Xs' are replaced
92 * with a five-digit value; this value is a unique number. Each successful
93 * call to mkstemp() modifes @p template.
94 *
95 * When mkstemp() succeeds, it creates and opens the template file for
96 * reading and writing.
97 *
98 * On success, the function returns the file descriptor of the
99 * temporary file. Otherwise, it returns -1 and errno is set to the
100 * following values:
101 * - EINVAL: @p template has an invalid format.
102 * - EACCESS: Given path is a directory, or file is read-only, but an
103 * open-for-writing operation was attempted.
104 * - EEXISTS: File name already exists.
105 * - EMFILE: No more file descriptors available.
106 * - ENOENT: File or path not found.
107 *
108 * Conformity: Should follow BSD conformity.
109 *
110 * Supported OS: Windows 98, Windows Me, Windows NT, Windows 2000,
111 * Windows XP.
112 *
113 * @ingroup Evil
114 */
115EAPI int mkstemp(char *template);
116
117/**
118 * @brief Return an absolute or full path name for a specified relative path name.
119 *
120 * @param file_name The absolute path name.
121 * @param resolved_name The relative path name.
122 * @return @c NULL on failure, a pointer to the absolute path name otherwise.
123 *
124 * The function expands the relative path name @p file_name to its
125 * fully qualified or absolute path and store it in the buffer pointed
126 * by @p resolved_name. The buffer is at most @c PATH_MAX bytes long.
127 * If @p resolved_name is @c NULL, malloc() is used to allocate a
128 * buffer of sufficient length to hold the path name. In that case, it
129 * is the responsability of the caller to free this buffer with free().
130 *
131 * That function can be used to obtain the absolute path name for
132 * relative paths (relPath) that include "./" or "../" in their names.
133 *
134 * Conformity: None.
135 *
136 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
137 * Windows XP.
138 *
139 * @ingroup Evil
140 */
141EAPI char *realpath(const char *file_name, char *resolved_name);
142
143
144#endif /* __EVIL_STDLIB_H__ */
145
diff --git a/legacy/evil/src/lib/evil_unistd.c b/legacy/evil/src/lib/evil_unistd.c
new file mode 100644
index 0000000000..54a7999e77
--- /dev/null
+++ b/legacy/evil/src/lib/evil_unistd.c
@@ -0,0 +1,396 @@
1#define WIN32_LEAN_AND_MEAN
2#include <winsock2.h>
3#undef WIN32_LEAN_AND_MEAN
4
5#ifdef HAVE_CONFIG_H
6# include "config.h"
7#endif /* HAVE_CONFIG_H */
8
9#include "Evil.h"
10
11/*
12 * Process identifer related functions
13 *
14 */
15
16pid_t
17getpid(void)
18{
19 return (pid_t)GetCurrentProcessId();
20}
21
22
23/*
24 * Symbolic links and directory related functions
25 *
26 */
27
28/* REMARK: Windows has no symbolic link. */
29/* Nevertheless, it can create and read .lnk files */
30int
31symlink(const char *oldpath, const char *newpath)
32{
33#if defined(__CEGCC__) || defined(__MINGW32CE__)
34 wchar_t *w_oldpath;
35 wchar_t *w_newpath;
36 BOOL res;
37
38 w_oldpath = evil_char_to_wchar(oldpath);
39 if (!w_oldpath)
40 return -1;
41
42 w_newpath = evil_char_to_wchar(newpath);
43 if (!w_newpath)
44 {
45 free(w_oldpath);
46 return -1;
47 }
48
49 res = SHCreateShortcutEx(w_newpath, w_oldpath, NULL, NULL);
50
51 free(w_oldpath);
52 free(w_newpath);
53
54 return res ? 0 : -1;
55#else
56#ifdef UNICODE
57 wchar_t new_path[MB_CUR_MAX];
58#endif /* UNICODE */
59 IShellLink *pISL;
60 IShellLink **shell_link;
61 IPersistFile *pIPF;
62 IPersistFile **persit_file;
63 HRESULT res;
64
65 res = CoInitialize(NULL);
66 if (FAILED(res))
67 {
68 if (res == E_OUTOFMEMORY)
69 errno = ENOMEM;
70 return -1;
71 }
72
73 /* Hack to cleanly remove a warning */
74 shell_link = &pISL;
75 if (FAILED(CoCreateInstance(&CLSID_ShellLink,
76 NULL,
77 CLSCTX_INPROC_SERVER,
78 &IID_IShellLink,
79 (void **)shell_link)))
80 goto no_instance;
81
82 if (FAILED(pISL->lpVtbl->SetPath(pISL, oldpath)))
83 goto no_setpath;
84
85 /* Hack to cleanly remove a warning */
86 persit_file = &pIPF;
87 if (FAILED(pISL->lpVtbl->QueryInterface(pISL, &IID_IPersistFile, (void **)persit_file)))
88 goto no_queryinterface;
89
90#ifdef UNICODE
91 mbstowcs(new_path, newpath, MB_CUR_MAX);
92 if (FAILED(pIPF->lpVtbl->Save(pIPF, new_path, FALSE)))
93 goto no_save;
94#else
95 if (FAILED(pIPF->lpVtbl->Save(pIPF, newpath, FALSE)))
96 goto no_save;
97#endif /* ! UNICODE */
98
99 pIPF->lpVtbl->Release(pIPF);
100 pISL->lpVtbl->Release(pISL);
101 CoUninitialize();
102
103 return 0;
104
105 no_save:
106 pIPF->lpVtbl->Release(pIPF);
107 no_queryinterface:
108 no_setpath:
109 pISL->lpVtbl->Release(pISL);
110 no_instance:
111 CoUninitialize();
112 return -1;
113#endif /* ! __CEGCC__ && ! __MINGW32CE__ */
114}
115
116ssize_t
117readlink(const char *path, char *buf, size_t bufsiz)
118{
119#if defined(__CEGCC__) || defined(__MINGW32CE__)
120 wchar_t *w_path;
121 wchar_t w_newpath[MB_CUR_MAX];
122 char *newpath;
123 size_t length;
124 BOOL res;
125
126 w_path = evil_char_to_wchar(path);
127 if (!w_path)
128 return -1;
129
130 res = SHGetShortcutTarget(w_path, w_newpath, MB_CUR_MAX);
131
132 free(w_path);
133
134 if (!res)
135 return -1;
136
137 newpath = evil_wchar_to_char(w_newpath);
138 if (!newpath)
139 return -1;
140
141 length = strlen(newpath);
142 if (length > bufsiz)
143 length = bufsiz;
144
145 memcpy(buf, newpath, length);
146
147 free(newpath);
148
149 return length;
150#else
151#ifdef UNICODE
152 wchar_t old_path[MB_CUR_MAX];
153#endif /* UNICODE */
154 char new_path[PATH_MAX];
155 IShellLink *pISL;
156 IShellLink **shell_link;
157 IPersistFile *pIPF;
158 IPersistFile **persit_file;
159 unsigned int length;
160 HRESULT res;
161
162 res = CoInitialize(NULL);
163 if (FAILED(res))
164 {
165 if (res == E_OUTOFMEMORY)
166 errno = ENOMEM;
167 return -1;
168 }
169
170 /* Hack to cleanly remove a warning */
171 persit_file = &pIPF;
172 if (FAILED(CoCreateInstance(&CLSID_ShellLink,
173 NULL,
174 CLSCTX_INPROC_SERVER,
175 &IID_IPersistFile,
176 (void **)persit_file)))
177 goto no_instance;
178
179#ifdef UNICODE
180 mbstowcs(old_path, path, MB_CUR_MAX);
181 if (FAILED(pIPF->lpVtbl->Load(pIPF, old_path, STGM_READWRITE)))
182 goto no_load;
183#else
184 if (FAILED(pIPF->lpVtbl->Load(pIPF, path, STGM_READWRITE)))
185 goto no_load;
186#endif /* ! UNICODE */
187
188 shell_link = &pISL;
189 if (FAILED(pIPF->lpVtbl->QueryInterface(pIPF, &IID_IShellLink, (void **)shell_link)))
190 goto no_queryinterface;
191
192 if (FAILED(pISL->lpVtbl->GetPath(pISL, new_path, PATH_MAX, NULL, 0)))
193 goto no_getpath;
194
195 length = strlen(new_path);
196 if (length > bufsiz)
197 length = bufsiz;
198
199 memcpy(buf, new_path, length);
200
201 pISL->lpVtbl->Release(pISL);
202 pIPF->lpVtbl->Release(pIPF);
203 CoUninitialize();
204
205 return length;
206
207 no_getpath:
208 pISL->lpVtbl->Release(pISL);
209 no_queryinterface:
210 no_load:
211 pIPF->lpVtbl->Release(pIPF);
212 no_instance:
213 CoUninitialize();
214 return -1;
215#endif /* ! __CEGCC__ && ! __MINGW32CE__ */
216}
217
218char *
219evil_getcwd(char *buffer, size_t size)
220{
221#if defined(__CEGCC__) || defined(__MINGW32CE__)
222 wchar_t wpath[PATH_MAX];
223 char *cpath;
224 char *delim;
225 int ret = 0;
226
227 if (size <= 0)
228 return NULL;
229
230 ret = GetModuleFileName(GetModuleHandle(NULL), (LPWSTR)&wpath, PATH_MAX);
231
232 if (!ret)
233 return NULL;
234
235 cpath = evil_wchar_to_char(wpath);
236 if (!cpath)
237 return NULL;
238
239 if (strlen(cpath) >= (size - 1))
240 {
241 free(cpath);
242 return NULL;
243 }
244
245 delim = strrchr(cpath, '\\');
246 if (delim)
247 *delim = '\0';
248
249 if (!buffer)
250 {
251 buffer = (char *)malloc(sizeof(char) * size);
252 if (!buffer)
253 {
254 free(cpath);
255 return NULL;
256 }
257 }
258
259 strcpy(buffer, cpath);
260 free(cpath);
261
262 return buffer;
263#else
264 return _getcwd(buffer, size);
265#endif /* ! __CEGCC__ && ! __MINGW32CE__ */
266}
267
268
269/*
270 * Sockets and pipe related functions
271 *
272 */
273
274int
275evil_sockets_init(void)
276{
277 WSADATA wsa_data;
278
279 return (WSAStartup(MAKEWORD( 2, 2 ), &wsa_data) == 0) ? 1 : 0;
280}
281
282void
283evil_sockets_shutdown(void)
284{
285 WSACleanup();
286}
287
288/*
289 * The code of the following functions has been kindly offered
290 * by Tor Lillqvist.
291 */
292int
293evil_pipe(int *fds)
294{
295 struct sockaddr_in saddr;
296 struct timeval tv;
297 SOCKET temp;
298 SOCKET socket1 = INVALID_SOCKET;
299 SOCKET socket2 = INVALID_SOCKET;
300 u_long arg;
301 fd_set read_set;
302 fd_set write_set;
303 int len;
304
305 temp = socket (AF_INET, SOCK_STREAM, 0);
306
307 if (temp == INVALID_SOCKET)
308 goto out0;
309
310 arg = 1;
311 if (ioctlsocket (temp, FIONBIO, &arg) == SOCKET_ERROR)
312 goto out0;
313
314 memset (&saddr, 0, sizeof (saddr));
315 saddr.sin_family = AF_INET;
316 saddr.sin_port = 0;
317 saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
318
319 if (bind (temp, (struct sockaddr *)&saddr, sizeof (saddr)))
320 goto out0;
321
322 if (listen (temp, 1) == SOCKET_ERROR)
323 goto out0;
324
325 len = sizeof (saddr);
326 if (getsockname (temp, (struct sockaddr *)&saddr, &len))
327 goto out0;
328
329 socket1 = socket (AF_INET, SOCK_STREAM, 0);
330
331 if (socket1 == INVALID_SOCKET)
332 goto out0;
333
334 arg = 1;
335 if (ioctlsocket (socket1, FIONBIO, &arg) == SOCKET_ERROR)
336 goto out1;
337
338 if ((connect (socket1, (struct sockaddr *)&saddr, len) == SOCKET_ERROR) &&
339 (WSAGetLastError () != WSAEWOULDBLOCK))
340 goto out1;
341
342 FD_ZERO (&read_set);
343 FD_SET (temp, &read_set);
344
345 tv.tv_sec = 0;
346 tv.tv_usec = 0;
347
348 if (select (0, &read_set, NULL, NULL, NULL) == SOCKET_ERROR)
349 goto out1;
350
351 if (!FD_ISSET (temp, &read_set))
352 goto out1;
353
354 socket2 = accept (temp, (struct sockaddr *) &saddr, &len);
355 if (socket2 == INVALID_SOCKET)
356 goto out1;
357
358 FD_ZERO (&write_set);
359 FD_SET (socket1, &write_set);
360
361 tv.tv_sec = 0;
362 tv.tv_usec = 0;
363
364 if (select (0, NULL, &write_set, NULL, NULL) == SOCKET_ERROR)
365 goto out2;
366
367 if (!FD_ISSET (socket1, &write_set))
368 goto out2;
369
370 arg = 0;
371 if (ioctlsocket (socket1, FIONBIO, &arg) == SOCKET_ERROR)
372 goto out2;
373
374 arg = 0;
375 if (ioctlsocket (socket2, FIONBIO, &arg) == SOCKET_ERROR)
376 goto out2;
377
378 fds[0] = socket1;
379 fds[1] = socket2;
380
381 closesocket (temp);
382
383 return 0;
384
385 out2:
386 closesocket (socket2);
387 out1:
388 closesocket (socket1);
389 out0:
390 closesocket (temp);
391
392 fds[0] = INVALID_SOCKET;
393 fds[1] = INVALID_SOCKET;
394
395 return -1;
396}
diff --git a/legacy/evil/src/lib/evil_unistd.h b/legacy/evil/src/lib/evil_unistd.h
new file mode 100644
index 0000000000..c99d5e246d
--- /dev/null
+++ b/legacy/evil/src/lib/evil_unistd.h
@@ -0,0 +1,187 @@
1#ifndef __EVIL_UNISTD_H__
2#define __EVIL_UNISTD_H__
3
4
5#ifdef _MSC_VER
6
7typedef int pid_t;
8
9#endif /* _MSC_VER */
10
11
12/*
13 * Process identifer related functions
14 *
15 */
16
17
18/**
19 * @brief Return the process identifier of the calling process.
20 *
21 * @return The process ID.
22 *
23 * Return the process identifier of the calling process. Until
24 * the process terminates, the process identifier uniquely
25 * identifies the process throughout the system.
26 *
27 * Conformity: Not appliclable.
28 *
29 * Supported OS: Windows 98, Windows Me, Windows NT, Windows 2000,
30 * Windows XP.
31 *
32 * @ingroup Evil
33 */
34EAPI pid_t getpid(void);
35
36
37/*
38 * Symbolic links and directory related functions
39 *
40 */
41
42/**
43 * @brief Create a shell link.
44 *
45 * @param oldpath The file name to be linked.
46 * @param newpath The file name to create.
47 * @return 0 on success, -1 otherwise.
48 *
49 * Create a shell link @p newpath to @p oldpath (@p newpath is the
50 * name of the file created, @p oldpath is the string used in
51 * creating the shell link).
52 *
53 * On success, this function returns 0. Otherwise, it returns -1 and
54 * errno may be set to the following value:
55 * - ENOMEM: Not enough memory.
56 *
57 * On Windows, the symbolic links do not exist. Nevertheless
58 * shell links can be created. This function is named like the Unix
59 * function for portability reasons.
60 *
61 * Conformity: None.
62 *
63 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
64 * Windows XP.
65 *
66 * @ingroup Evil
67 */
68EAPI int symlink(const char *oldpath, const char *newpath);
69
70/**
71 * @brief Read value of a shell link.
72 *
73 * @param path The file name to be linked.
74 * @param buf The file name to create.
75 * @param bufsiz The size of the buffer.
76 * @return 0 on success, -1 otherwise.
77 *
78 * Place the content of the shell link @p path in the buffer
79 * @p buf, which has size @p bufzsiz.
80 *
81 * On success, this function returns the count of characters
82 * placed in the buffer. Otherwise, it returns -1 and errno may
83 * be set to the following value:
84 * - ENOMEM: Not enough memory.
85 *
86 * On Windows, the symbolic links do not exist. Nevertheless
87 * shell links can be managed. This function is named like the Unix
88 * function for portability reasons.
89 *
90 * Conformity: None.
91 *
92 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
93 * Windows XP.
94 *
95 * @ingroup Evil
96 */
97EAPI ssize_t readlink(const char *path, char *buf, size_t bufsiz);
98
99/**
100 * @brief Get the current directory.
101 *
102 * @param buffer Buffer to store the current directory.
103 * @param size Size of the buffer.
104 * @return The current directory.
105 *
106 * On Windows desktop, use the _getcwd function in MSVCRT.
107 *
108 * On Windows CE, get the current directory by extracting the path
109 * from the executable that is running and put the result in @p buffer
110 * of length @p size. If @p size is less or equal than 0, return NULL.
111 * If the current absolute path would require a buffer longer than
112 * @p size elements, NULL is returned. If @p buffer is NULL, a buffer
113 * of length @p size is allocated and is returned. If the allocation
114 * fails, NULL is returned. On success, @p buffer is returned and
115 * contains the current directory. The last '\' is not included.
116 * If @p buffer is NULL, the returned value must be freed if not NULL.
117 *
118 * Specially usefull on WinCE where the current directory functionality
119 * is not supported.
120 *
121 * Conformity: Almost POSIX.1 (no errno set)
122 *
123 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
124 * Windows XP, WinCE.
125 *
126 * @ingroup Evil
127 */
128EAPI char *evil_getcwd(char *buffer, size_t size);
129
130
131/*
132 * Sockets and pipe related functions
133 *
134 */
135
136/**
137 * @brief Initiates the use of Windows sockets.
138 *
139 * @return 1 on success, 0 otherwise.
140 *
141 * Initiates the use of Windows sockets. If the function succeeds,
142 * it returns 1, otherwise it returns 0.
143 *
144 * Conformity: Non applicable.
145 *
146 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
147 * Windows XP.
148 *
149 * @ingroup Evil
150 */
151EAPI int evil_sockets_init(void);
152
153/**
154 * @brief Shutdown the Windows socket system.
155 *
156 * Shutdown the Windows socket system.
157 *
158 * Conformity: Non applicable.
159 *
160 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
161 * Windows XP.
162 *
163 * @ingroup Evil
164 */
165EAPI void evil_sockets_shutdown(void);
166
167/**
168 * @brief Create a pair of sockets.
169 *
170 * @param fds A pointer that contains two sockets.
171 *
172 * Create a pair of sockets that can be use with select().
173 * Hence, evil_sockets_init() must have been caled at least
174 * once before. Contrary to Unix, that functions does not
175 * create a pair of file descriptors.
176 *
177 * Conformity: Not applicable.
178 *
179 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
180 * Windows XP.
181 *
182 * @ingroup Evil
183 */
184EAPI int evil_pipe(int *fds);
185
186
187#endif /* __EVIL_UNISTD_H__ */
diff --git a/legacy/evil/src/lib/evil_util.c b/legacy/evil/src/lib/evil_util.c
new file mode 100644
index 0000000000..1c53252171
--- /dev/null
+++ b/legacy/evil/src/lib/evil_util.c
@@ -0,0 +1,137 @@
1#include <stdlib.h>
2#include <stdio.h>
3#include <string.h>
4
5#define WIN32_LEAN_AND_MEAN
6#include <windows.h>
7#undef WIN32_LEAN_AND_MEAN
8
9#ifdef HAVE_CONFIG_H
10# include "config.h"
11#endif /* HAVE_CONFIG_H */
12
13#include "Evil.h"
14
15
16wchar_t *
17evil_char_to_wchar(const char *text)
18{
19 wchar_t *wtext;
20 int wsize;
21
22 wsize = MultiByteToWideChar(CP_ACP, 0, text, strlen(text) + 1, NULL, 0);
23 if ((wsize == 0) ||
24 (wsize > (int)(ULONG_MAX / sizeof(wchar_t))))
25 return NULL;
26
27 wtext = malloc(wsize * sizeof(wchar_t));
28 if (wtext)
29 if (!MultiByteToWideChar(CP_ACP, 0, text, strlen(text) + 1, wtext, wsize))
30 return NULL;
31
32 return wtext;
33}
34
35char *
36evil_wchar_to_char(const wchar_t *text)
37{
38 char * atext;
39 int size;
40 int asize;
41
42 size = wcslen(text) + 1;
43
44 asize = WideCharToMultiByte(CP_ACP, 0, text, size, NULL, 0, NULL, NULL);
45 if (asize == 0)
46 return NULL;
47
48 atext = (char*)malloc((asize + 1) * sizeof(char));
49
50 if (atext)
51 if (!WideCharToMultiByte(CP_ACP, 0, text, size, atext, asize, NULL, NULL))
52 return NULL;
53 atext[asize] = '\0';
54
55 return atext;
56}
57
58char *
59evil_format_message(long err)
60{
61 LPTSTR msg;
62 char *str;
63 char *disp;
64
65 if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
66 NULL,
67 err,
68 0, // Default language
69 (LPTSTR)&msg,
70 0,
71 NULL))
72 return NULL;
73
74#ifdef UNICODE
75 str = evil_wchar_to_char(msg);
76#else
77 str = strdup(msg);
78#endif /* UNICODE */
79
80 LocalFree(msg);
81
82 disp = (char *)malloc((strlen(str) + strlen("(00000) ") + 1) * sizeof(char));
83 if (!disp)
84 return NULL;
85
86 snprintf(disp, strlen(str) + strlen("(00000) ") + 1,
87 "(%5d) %s", err, str);
88
89 free(str);
90
91 return disp;
92}
93
94char *
95evil_last_error_get(void)
96{
97 DWORD err;
98
99 err = GetLastError();
100 return evil_format_message(err);
101}
102
103
104const char *
105evil_tmpdir_get(void)
106{
107#ifdef _WIN32_WCE
108 return "\\temp";
109#else
110 char *tmpdir;
111
112 tmpdir = getenv("TMP");
113 if (!tmpdir) tmpdir = getenv("TEMP");
114 if (!tmpdir) tmpdir = getenv("USERPROFILE");
115 if (!tmpdir) tmpdir = getenv("WINDIR");
116 if (!tmpdir) tmpdir="C:\\";
117
118 return tmpdir;
119#endif /* ! _WIN32_WCE */
120}
121
122const char *
123evil_homedir_get(void)
124{
125#ifdef _WIN32_WCE
126 return "\\my documents";
127#else
128 char *homedir;
129
130 homedir = getenv("HOME");
131 if (!homedir) homedir = getenv("USERPROFILE");
132 if (!homedir) homedir = getenv("WINDIR");
133 if (!homedir) homedir="C:\\";
134
135 return homedir;
136#endif /* ! _WIN32_WCE */
137}
diff --git a/legacy/evil/src/lib/evil_util.h b/legacy/evil/src/lib/evil_util.h
new file mode 100644
index 0000000000..eaefdec225
--- /dev/null
+++ b/legacy/evil/src/lib/evil_util.h
@@ -0,0 +1,93 @@
1#ifndef __EVIL_UTIL_H__
2#define __EVIL_UTIL_H__
3
4
5/**
6 * @brief Convert a string from char * to wchar_t *.
7 *
8 * @param text The string to convert.
9 * @return The converted string.
10 *
11 * Convert a string from char * to wchar_t * and return it. If the
12 * allocation or conversion fails, NULL is returned. On success, the
13 * returned value must be freed.
14 *
15 * Conformity: Non applicable.
16 *
17 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
18 * Windows XP.
19 *
20 * @ingroup Evil
21 */
22EAPI wchar_t *evil_char_to_wchar(const char *text);
23
24/**
25 * @brief Convert a string from wchar_t * to char *.
26 *
27 * @param text The string to convert.
28 * @return The converted string.
29 *
30 * Convert a string from wchar_t * to char * and return it. If the
31 * allocation or conversion fails, NULL is returned. On success, the
32 * returned value must be freed.
33 *
34 * Conformity: Non applicable.
35 *
36 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
37 * Windows XP.
38 *
39 * @ingroup Evil
40 */
41EAPI char *evil_wchar_to_char(const wchar_t *text);
42
43EAPI char *evil_format_message(long err);
44
45EAPI char *evil_last_error_get(void);
46
47/**
48 * @brief Return a dir to store temporary files.
49 *
50 * @return The directory to store temporary files.
51 *
52 * Return a directory to store temporary files. The function gets
53 * the value of the following environment variables, and in that order:
54 * - TMP
55 * - TEMP
56 * - USERPROFILE
57 * - WINDIR
58 * and returns its value if it exists. If none exists, the function
59 * returns "C:\".
60 *
61 * Conformity: Non applicable.
62 *
63 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
64 * Windows XP.
65 *
66 * @ingroup Evil
67 */
68EAPI const char *evil_tmpdir_get(void);
69
70/**
71 * @brief Return a dir to store personal files.
72 *
73 * @return The directory to store personal files.
74 *
75 * Return a directory to store personal files. The function gets
76 * the value of the following environment variables, and in that order:
77 * - HOME
78 * - USERPROFILE
79 * - WINDIR
80 * and returns its value if it exists. If none exists, the function
81 * returns "C:\".
82 *
83 * Conformity: Non applicable.
84 *
85 * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
86 * Windows XP.
87 *
88 * @ingroup Evil
89 */
90EAPI const char *evil_homedir_get(void);
91
92
93#endif /* __EVIL_UTIL_H__ */
diff --git a/legacy/evil/src/lib/mman/.cvsignore b/legacy/evil/src/lib/mman/.cvsignore
deleted file mode 100644
index 9730646fdd..0000000000
--- a/legacy/evil/src/lib/mman/.cvsignore
+++ /dev/null
@@ -1,6 +0,0 @@
1.deps
2.libs
3Makefile
4Makefile.in
5*.la
6*.lo
diff --git a/legacy/evil/src/lib/mman/Makefile.am b/legacy/evil/src/lib/mman/Makefile.am
deleted file mode 100644
index 13aade9298..0000000000
--- a/legacy/evil/src/lib/mman/Makefile.am
+++ /dev/null
@@ -1,12 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4lib_LTLIBRARIES = libmman.la
5
6nobase_include_HEADERS = sys/mman.h
7libmman_la_SOURCES = mman.c
8
9libmman_la_CFLAGS = @win32_cflags@
10libmman_la_LIBADD = $(top_builddir)/src/lib/libevil.la
11libmman_la_DEPENDENCIES = $(top_builddir)/config.h $(top_builddir)/src/lib/libevil.la
12libmman_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@
diff --git a/legacy/evil/src/lib/pwd/pwd.h b/legacy/evil/src/lib/pwd.h
index cfd211a83b..cfd211a83b 100644
--- a/legacy/evil/src/lib/pwd/pwd.h
+++ b/legacy/evil/src/lib/pwd.h
diff --git a/legacy/evil/src/lib/pwd/Makefile.am b/legacy/evil/src/lib/pwd/Makefile.am
deleted file mode 100644
index 5837987d02..0000000000
--- a/legacy/evil/src/lib/pwd/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4include_HEADERS = pwd.h
diff --git a/legacy/evil/src/lib/mman/sys/mman.h b/legacy/evil/src/lib/sys/mman.h
index 40c0859dcb..40c0859dcb 100644
--- a/legacy/evil/src/lib/mman/sys/mman.h
+++ b/legacy/evil/src/lib/sys/mman.h
diff --git a/legacy/evil/win32/vs8/libevil.vcproj b/legacy/evil/win32/vs8/libevil.vcproj
index 90eac628be..3268cf1e9e 100644
--- a/legacy/evil/win32/vs8/libevil.vcproj
+++ b/legacy/evil/win32/vs8/libevil.vcproj
@@ -192,6 +192,26 @@
192 RelativePath="..\..\src\lib\evil.c" 192 RelativePath="..\..\src\lib\evil.c"
193 > 193 >
194 </File> 194 </File>
195 <File
196 RelativePath="..\..\src\lib\evil_mman.c"
197 >
198 </File>
199 <File
200 RelativePath="..\..\src\lib\evil_pwd.c"
201 >
202 </File>
203 <File
204 RelativePath="..\..\src\lib\evil_stdlib.c"
205 >
206 </File>
207 <File
208 RelativePath="..\..\src\lib\evil_unistd.c"
209 >
210 </File>
211 <File
212 RelativePath="..\..\src\lib\evil_util.c"
213 >
214 </File>
195 </Filter> 215 </Filter>
196 <Filter 216 <Filter
197 Name="Header Files" 217 Name="Header Files"