forked from enlightenment/efl
* src/bin/Makefile.am:
* src/bin/evil_suite.c: * src/bin/evil_test_dlfcn.c: * src/bin/evil_test_dlfcn.h: * src/bin/evil_test_environment.c: * src/bin/evil_test_environment.h: * src/bin/evil_test_gettimeofday.c: * src/bin/evil_test_gettimeofday.h: * src/bin/evil_test_link.c: * src/bin/evil_test_link.h: * src/bin/evil_test_mkstemp.c: * src/bin/evil_test_mkstemp.h: * src/bin/evil_test_realpath.c: * src/bin/evil_test_realpath.h: various fixes in the test suite. add mkstemp() and realpath tests. * src/lib/evil_dirent.c: fix opendir() when indexation search is not active. formatting. * src/lib/evil_stdlib.c: fir mkstemp() on both platform * src/lib/evil_unistd.c: remove useless error message. SVN revision: 38645
This commit is contained in:
parent
011bc06ecc
commit
7da4e5839d
|
@ -1,3 +1,32 @@
|
||||||
|
2009-01-19 Vincent Torri <doursse at users dot sf dot net>
|
||||||
|
|
||||||
|
* src/bin/Makefile.am:
|
||||||
|
* src/bin/evil_suite.c:
|
||||||
|
* src/bin/evil_test_dlfcn.c:
|
||||||
|
* src/bin/evil_test_dlfcn.h:
|
||||||
|
* src/bin/evil_test_environment.c:
|
||||||
|
* src/bin/evil_test_environment.h:
|
||||||
|
* src/bin/evil_test_gettimeofday.c:
|
||||||
|
* src/bin/evil_test_gettimeofday.h:
|
||||||
|
* src/bin/evil_test_link.c:
|
||||||
|
* src/bin/evil_test_link.h:
|
||||||
|
* src/bin/evil_test_mkstemp.c:
|
||||||
|
* src/bin/evil_test_mkstemp.h:
|
||||||
|
* src/bin/evil_test_realpath.c:
|
||||||
|
* src/bin/evil_test_realpath.h:
|
||||||
|
various fixes in the test suite.
|
||||||
|
add mkstemp() and realpath tests.
|
||||||
|
|
||||||
|
* src/lib/evil_dirent.c:
|
||||||
|
fix opendir() when indexation search is not active.
|
||||||
|
formatting.
|
||||||
|
|
||||||
|
* src/lib/evil_stdlib.c:
|
||||||
|
fir mkstemp() on both platform
|
||||||
|
|
||||||
|
* src/lib/evil_unistd.c:
|
||||||
|
remove useless error message.
|
||||||
|
|
||||||
2009-01-12 Vincent Torri <doursse at users dot sf dot net>
|
2009-01-12 Vincent Torri <doursse at users dot sf dot net>
|
||||||
|
|
||||||
* src/lib/evil_dirent.c:
|
* src/lib/evil_dirent.c:
|
||||||
|
|
|
@ -18,7 +18,9 @@ evil_test_dlfcn.c \
|
||||||
evil_test_environment.c \
|
evil_test_environment.c \
|
||||||
evil_test_gettimeofday.c \
|
evil_test_gettimeofday.c \
|
||||||
evil_test_link.c \
|
evil_test_link.c \
|
||||||
evil_test_memcpy.c
|
evil_test_memcpy.c \
|
||||||
|
evil_test_mkstemp.c \
|
||||||
|
evil_test_realpath.c
|
||||||
|
|
||||||
if EVIL_HAVE_WINCE
|
if EVIL_HAVE_WINCE
|
||||||
|
|
||||||
|
@ -46,4 +48,6 @@ evil_suite.h \
|
||||||
evil_test_dlfcn.h \
|
evil_test_dlfcn.h \
|
||||||
evil_test_environment.h \
|
evil_test_environment.h \
|
||||||
evil_test_link.h \
|
evil_test_link.h \
|
||||||
evil_test_memcpy.h
|
evil_test_memcpy.h \
|
||||||
|
evil_test_mkstemp.h \
|
||||||
|
evil_test_realpath.h
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include "evil_test_gettimeofday.h"
|
#include "evil_test_gettimeofday.h"
|
||||||
#include "evil_test_link.h"
|
#include "evil_test_link.h"
|
||||||
#include "evil_test_memcpy.h"
|
#include "evil_test_memcpy.h"
|
||||||
|
#include "evil_test_mkstemp.h"
|
||||||
|
#include "evil_test_realpath.h"
|
||||||
|
|
||||||
|
|
||||||
typedef int(*function)(suite *s);
|
typedef int(*function)(suite *s);
|
||||||
|
@ -171,10 +173,12 @@ int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
test tests[] = {
|
test tests[] = {
|
||||||
{ "dlfcn ", test_environment },
|
{ "dlfcn ", test_dlfcn },
|
||||||
{ "environment ", test_environment },
|
{ "environment ", test_environment },
|
||||||
{ "gettimeofday", test_gettimeofday },
|
{ "gettimeofday", test_gettimeofday },
|
||||||
{ "link ", test_link },
|
{ "link ", test_link },
|
||||||
|
{ "mkstemp ", test_mkstemp },
|
||||||
|
{ "realpath ", test_realpath },
|
||||||
/* { "memcpy ", test_memcpy }, */
|
/* { "memcpy ", test_memcpy }, */
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
@ -193,7 +197,6 @@ main()
|
||||||
|
|
||||||
for (i = 0; tests[i].name; ++i)
|
for (i = 0; tests[i].name; ++i)
|
||||||
{
|
{
|
||||||
|
|
||||||
suite_test_add(s, tests[i].name, tests[i].fct);
|
suite_test_add(s, tests[i].name, tests[i].fct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
@ -22,7 +21,7 @@ test_dlfcn_test_dlopen()
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!dlclose(handle))
|
if (dlclose(handle))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -53,7 +52,7 @@ test_dlfcn_test_dlsym()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dlclose(handle))
|
if (dlclose(handle))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -64,7 +63,7 @@ test_dlfcn_tests_run(suite *s)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = test_dlfcn_test_dlopen();
|
res = test_dlfcn_test_dlopen();
|
||||||
res &= test_dlfcn_test_dlsym();
|
res &= test_dlfcn_test_dlsym();
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef __EVIL_TEST_DLFCN__
|
#ifndef __EVIL_TEST_DLFCN_H__
|
||||||
#define __EVIL_TEST_DLFCN__
|
#define __EVIL_TEST_DLFCN_H__
|
||||||
|
|
||||||
|
|
||||||
int test_dlfcn(suite *s);
|
int test_dlfcn(suite *s);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __EVIL_TEST_DLFCN__ */
|
#endif /* __EVIL_TEST_DLFCN_H__ */
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <Evil.h>
|
#include <Evil.h>
|
||||||
|
@ -12,24 +9,165 @@
|
||||||
#include "evil_suite.h"
|
#include "evil_suite.h"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_env_tests_run(suite *s)
|
test_env_test_setenv_NULL(void)
|
||||||
{
|
{
|
||||||
char *val;
|
char *val;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = setenv("EVIL_TEST_ENV", "val1", 1);
|
res = setenv("EVIL_TEST_ENV", NULL, 1);
|
||||||
|
if (res < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
val = getenv("EVIL_TEST_ENV");
|
||||||
|
|
||||||
|
return val ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_env_test_setenv_NULL_after_set(void)
|
||||||
|
{
|
||||||
|
char *val;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = setenv("EVIL_TEST_ENV", "val", 1);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
val = getenv("EVIL_TEST_ENV");
|
val = getenv("EVIL_TEST_ENV");
|
||||||
if (!val)
|
if (!val)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (strcmp(val, "val"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
res = setenv("EVIL_TEST_ENV", NULL, 1);
|
||||||
|
if (res < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
val = getenv("EVIL_TEST_ENV");
|
||||||
|
|
||||||
|
return val ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_env_test_getenv_one(void)
|
||||||
|
{
|
||||||
|
char *val;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = setenv("EVIL_TEST_ENV", "val", 1);
|
||||||
|
if (res < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
val = getenv("EVIL_TEST_ENV");
|
||||||
|
if (!val)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (strcmp(val, "val"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_env_test_getenv_two(void)
|
||||||
|
{
|
||||||
|
char *val;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = setenv("EVIL_TEST_ENV1", "val1", 1);
|
||||||
|
if (res < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
res = setenv("EVIL_TEST_ENV2", "val2", 1);
|
||||||
|
if (res < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
val = getenv("EVIL_TEST_ENV1");
|
||||||
|
if (!val)
|
||||||
|
return 0;
|
||||||
|
if (strcmp(val, "val1"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
val = getenv("EVIL_TEST_ENV2");
|
||||||
|
if (!val)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (strcmp(val, "val2"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_env_test_getenv_two_swapped(void)
|
||||||
|
{
|
||||||
|
char *val;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = setenv("EVIL_TEST_ENV1", "val1", 1);
|
||||||
|
if (res < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
res = setenv("EVIL_TEST_ENV2", "val2", 1);
|
||||||
|
if (res < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
val = getenv("EVIL_TEST_ENV2");
|
||||||
|
if (!val)
|
||||||
|
return 0;
|
||||||
|
if (strcmp(val, "val2"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
val = getenv("EVIL_TEST_ENV1");
|
||||||
|
if (!val)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (strcmp(val, "val1"))
|
if (strcmp(val, "val1"))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_env_test_unsetenv(void)
|
||||||
|
{
|
||||||
|
char *val;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = setenv("EVIL_TEST_ENV", "val", 1);
|
||||||
|
if (res < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
val = getenv("EVIL_TEST_ENV");
|
||||||
|
if (!val)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (unsetenv("EVIL_TEST_ENV") != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
val = getenv("EVIL_TEST_ENV");
|
||||||
|
if (val)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_env_tests_run(suite *s)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = test_env_test_setenv_NULL();
|
||||||
|
res &= test_env_test_setenv_NULL_after_set();
|
||||||
|
res &= test_env_test_getenv_one();
|
||||||
|
res &= test_env_test_getenv_two();
|
||||||
|
res &= test_env_test_getenv_two_swapped();
|
||||||
|
res &= test_env_test_unsetenv();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
test_environment(suite *s)
|
test_environment(suite *s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef __EVIL_TEST_ENVIRONMENT__
|
#ifndef __EVIL_TEST_ENVIRONMENT_H__
|
||||||
#define __EVIL_TEST_ENVIRONMENT__
|
#define __EVIL_TEST_ENVIRONMENT_H__
|
||||||
|
|
||||||
|
|
||||||
int test_environment(suite *s);
|
int test_environment(suite *s);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __EVIL_TEST_ENVIRONMENT__ */
|
#endif /* __EVIL_TEST_ENVIRONMENT_H__ */
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
@ -13,7 +10,7 @@
|
||||||
#include "evil_suite.h"
|
#include "evil_suite.h"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_time_tests_run(suite *s)
|
test_time_test_gettimeofday(void)
|
||||||
{
|
{
|
||||||
struct timeval tp1;
|
struct timeval tp1;
|
||||||
struct timeval tp2;
|
struct timeval tp2;
|
||||||
|
@ -34,6 +31,16 @@ test_time_tests_run(suite *s)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_time_tests_run(suite *s)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = test_time_test_gettimeofday();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
test_gettimeofday(suite *s)
|
test_gettimeofday(suite *s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef __EVIL_TEST_GETTIMEOFDAY__
|
#ifndef __EVIL_TEST_GETTIMEOFDAY_H__
|
||||||
#define __EVIL_TEST_GETTIMEOFDAY__
|
#define __EVIL_TEST_GETTIMEOFDAY_H__
|
||||||
|
|
||||||
|
|
||||||
int test_gettimeofday(suite *s);
|
int test_gettimeofday(suite *s);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __EVIL_TEST_GETTIMEOFDAY__ */
|
#endif /* __EVIL_TEST_GETTIMEOFDAY_H__ */
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <Evil.h>
|
#include <Evil.h>
|
||||||
|
@ -144,7 +143,7 @@ test_link_tests_run(suite *s)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = test_link_test_symlink();
|
res = test_link_test_symlink();
|
||||||
res &= test_link_test_readlink();
|
res &= test_link_test_readlink();
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef __EVIL_TEST_LINK__
|
#ifndef __EVIL_TEST_LINK_H__
|
||||||
#define __EVIL_TEST_LINK__
|
#define __EVIL_TEST_LINK_H__
|
||||||
|
|
||||||
|
|
||||||
int test_link(suite *s);
|
int test_link(suite *s);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __EVIL_TEST_LINK__ */
|
#endif /* __EVIL_TEST_LINK_H__ */
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <Evil.h>
|
||||||
|
|
||||||
|
#include "evil_suite.h"
|
||||||
|
|
||||||
|
int test_mkstemp_test(void)
|
||||||
|
{
|
||||||
|
char _template[PATH_MAX];
|
||||||
|
char cwd[PATH_MAX];
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
#ifdef _WIN32_WCE
|
||||||
|
if (!getcwd(cwd, PATH_MAX))
|
||||||
|
return 0;
|
||||||
|
_snprintf(_template, PATH_MAX, "%s\\%s", cwd, "file_XXXXXX");
|
||||||
|
#else
|
||||||
|
_snprintf(_template, PATH_MAX, "%s", "file_XXXXXX");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fd = mkstemp(_template);
|
||||||
|
|
||||||
|
if (fd < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_mkstemp_run(suite *s)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = test_mkstemp_test();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
test_mkstemp(suite *s)
|
||||||
|
{
|
||||||
|
|
||||||
|
return test_mkstemp_run(s);
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef __EVIL_TEST_MKSTEMP_H__
|
||||||
|
#define __EVIL_TEST_MKSTEMP_H__
|
||||||
|
|
||||||
|
|
||||||
|
int test_mkstemp(suite *s);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __EVIL_TEST_MKSTEMP_H__ */
|
|
@ -0,0 +1,42 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <Evil.h>
|
||||||
|
|
||||||
|
#include "evil_suite.h"
|
||||||
|
|
||||||
|
int test_realpath_test(void)
|
||||||
|
{
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
char *filename;
|
||||||
|
char *result;
|
||||||
|
|
||||||
|
filename = "evil_suite.exe";
|
||||||
|
|
||||||
|
if (!(result = realpath(filename, buf)))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
printf ("res : %s\n", buf);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_realpath_run(suite *s)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = test_realpath_test();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
test_realpath(suite *s)
|
||||||
|
{
|
||||||
|
|
||||||
|
return test_realpath_run(s);
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef __EVIL_TEST_REALPATH_H__
|
||||||
|
#define __EVIL_TEST_REALPATH_H__
|
||||||
|
|
||||||
|
|
||||||
|
int test_realpath(suite *s);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __EVIL_TEST_REALPATH_H__ */
|
|
@ -47,9 +47,9 @@ DIR *opendir(char const *name)
|
||||||
wname = evil_char_to_wchar(name);
|
wname = evil_char_to_wchar(name);
|
||||||
if (!wname)
|
if (!wname)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_ERRNO_H
|
# ifdef HAVE_ERRNO_H
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
#endif
|
# endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ DIR *opendir(char const *name)
|
||||||
free(wname);
|
free(wname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* directory */
|
/* directory */
|
||||||
if (attr != FILE_ATTRIBUTE_DIRECTORY)
|
if (!(attr & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_ERRNO_H
|
#ifdef HAVE_ERRNO_H
|
||||||
errno = ENOTDIR;
|
errno = ENOTDIR;
|
||||||
|
@ -77,8 +77,8 @@ DIR *opendir(char const *name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dir = (DIR *)malloc(sizeof(DIR));
|
dir = (DIR *)malloc(sizeof(DIR));
|
||||||
if (!dir)
|
if (!dir)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_ERRNO_H
|
#ifdef HAVE_ERRNO_H
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
|
|
|
@ -176,6 +176,8 @@ setenv(const char *name,
|
||||||
LONG res;
|
LONG res;
|
||||||
DWORD disposition;
|
DWORD disposition;
|
||||||
wchar_t *wname;
|
wchar_t *wname;
|
||||||
|
char *data;
|
||||||
|
DWORD size;
|
||||||
|
|
||||||
if (!name || !*name)
|
if (!name || !*name)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -208,11 +210,31 @@ setenv(const char *name,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
size = strlen(value);
|
||||||
|
data = malloc(sizeof(char) * (size + 1));
|
||||||
|
if (!data)
|
||||||
|
return -1;
|
||||||
|
memcpy((void *)data, value, size);
|
||||||
|
data[size] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size = 0;
|
||||||
|
data = malloc(sizeof(char));
|
||||||
|
if (!data)
|
||||||
|
return -1;
|
||||||
|
data[0] = '\0';
|
||||||
|
}
|
||||||
|
if (!data)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if ((res = RegSetValueEx(key,
|
if ((res = RegSetValueEx(key,
|
||||||
(LPCWSTR)wname,
|
(LPCWSTR)wname,
|
||||||
0, REG_SZ,
|
0, REG_SZ,
|
||||||
(const BYTE *)value,
|
(const BYTE *)data,
|
||||||
strlen(value) + 1)) != ERROR_SUCCESS)
|
size + 1)) != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
free(wname);
|
free(wname);
|
||||||
_evil_error_display(__FUNCTION__, res);
|
_evil_error_display(__FUNCTION__, res);
|
||||||
|
@ -221,6 +243,7 @@ setenv(const char *name,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(data);
|
||||||
free(wname);
|
free(wname);
|
||||||
|
|
||||||
if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
|
if ((res = RegCloseKey (key)) != ERROR_SUCCESS)
|
||||||
|
@ -251,7 +274,7 @@ unsetenv(const char *name)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
mkstemp(char *template)
|
mkstemp(char *__template)
|
||||||
{
|
{
|
||||||
const char lookup[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
const char lookup[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
char *suffix;
|
char *suffix;
|
||||||
|
@ -259,12 +282,12 @@ mkstemp(char *template)
|
||||||
size_t length;
|
size_t length;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!template)
|
if (!__template)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
length = strlen(template);
|
length = strlen(__template);
|
||||||
if ((length < 6) ||
|
if ((length < 6) ||
|
||||||
(strncmp (template + length - 6, "XXXXXX", 6)))
|
(strncmp (__template + length - 6, "XXXXXX", 6)))
|
||||||
{
|
{
|
||||||
#ifdef HAVE_ERRNO_H
|
#ifdef HAVE_ERRNO_H
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
@ -272,7 +295,7 @@ mkstemp(char *template)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
suffix = template + length - 6;
|
suffix = __template + length - 6;
|
||||||
|
|
||||||
val = GetTickCount();
|
val = GetTickCount();
|
||||||
val += GetCurrentProcessId();
|
val += GetCurrentProcessId();
|
||||||
|
@ -298,12 +321,17 @@ mkstemp(char *template)
|
||||||
v /= 62;
|
v /= 62;
|
||||||
|
|
||||||
#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) )
|
#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) )
|
||||||
fd = _open(template, _O_RDWR | _O_BINARY | _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE);
|
fd = _open(__template, _O_RDWR | _O_BINARY | _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE);
|
||||||
#else /* __CEGCC__ || __MINGW32CE__ */
|
#else /* __CEGCC__ || __MINGW32CE__ */
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
wchar_t *wtemplate;
|
||||||
|
|
||||||
f = fopen(template, "rwb");
|
wtemplate = evil_char_to_wchar(__template);
|
||||||
|
if (!wtemplate)
|
||||||
|
return -1;
|
||||||
|
f = _wfopen(wtemplate, L"rwb");
|
||||||
|
free(wtemplate);
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_ERRNO_H
|
#ifdef HAVE_ERRNO_H
|
||||||
|
@ -311,7 +339,7 @@ mkstemp(char *template)
|
||||||
#endif /* HAVE_ERRNO_H */
|
#endif /* HAVE_ERRNO_H */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fd = fileno(f);
|
fd = _fileno(f);
|
||||||
}
|
}
|
||||||
#endif /* __CEGCC__ || __MINGW32CE__ */
|
#endif /* __CEGCC__ || __MINGW32CE__ */
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
|
@ -333,13 +361,27 @@ realpath(const char *file_name, char *resolved_name)
|
||||||
#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) )
|
#if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) )
|
||||||
return _fullpath(resolved_name, file_name, PATH_MAX);
|
return _fullpath(resolved_name, file_name, PATH_MAX);
|
||||||
#else
|
#else
|
||||||
int length;
|
char cwd[PATH_MAX];
|
||||||
|
size_t l1;
|
||||||
|
size_t l2;
|
||||||
|
size_t l;
|
||||||
|
|
||||||
length = strlen(file_name);
|
if (!file_name || !resolved_name)
|
||||||
if ((length + 1) > PATH_MAX)
|
return NULL;
|
||||||
length = PATH_MAX - 1;
|
|
||||||
memcpy(resolved_name, file_name, length);
|
if (!getcwd(cwd, PATH_MAX))
|
||||||
resolved_name[length] = '\0';
|
return NULL;
|
||||||
|
|
||||||
|
l1 = strlen(cwd);
|
||||||
|
l2 = strlen(file_name);
|
||||||
|
l = l1 + l2 + 2;
|
||||||
|
|
||||||
|
if (l > PATH_MAX)
|
||||||
|
l = PATH_MAX - 1;
|
||||||
|
memcpy(resolved_name, cwd, l1);
|
||||||
|
resolved_name[l1] = '\\';
|
||||||
|
memcpy(resolved_name + l1 + 1, file_name, l2);
|
||||||
|
resolved_name[l] = '\0';
|
||||||
|
|
||||||
return resolved_name;
|
return resolved_name;
|
||||||
#endif /* __CEGCC__ || __MINGW32CE__ */
|
#endif /* __CEGCC__ || __MINGW32CE__ */
|
||||||
|
|
|
@ -215,7 +215,6 @@ evil_stat(const char *file_name, struct stat *st)
|
||||||
handle = FindFirstFile(file, &data);
|
handle = FindFirstFile(file, &data);
|
||||||
if (handle == INVALID_HANDLE_VALUE)
|
if (handle == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
_evil_last_error_display(__FUNCTION__);
|
|
||||||
free(file);
|
free(file);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue