forked from enlightenment/efl
Fix open, add getcwd, lstat, setenv, unsetenv and evil_homedir_get and fix typo in doc
SVN revision: 34718
This commit is contained in:
parent
4b4c616e37
commit
d8e6039ece
|
@ -1,3 +1,11 @@
|
|||
2008-06-01 Vincent Torri <doursse at users dot sf dot net>
|
||||
|
||||
* src/lib/Evil.h:
|
||||
* src/lib/evil.c:
|
||||
add open with several arguments
|
||||
add getcwd, lstat, setenv, unsetenv and evil_homedir_get.
|
||||
typo in doc
|
||||
|
||||
2008-06-01 Vincent Torri <doursse at users dot sf dot net>
|
||||
|
||||
* src/lib/dlfcn/dlfcn.c:
|
||||
|
|
|
@ -319,12 +319,14 @@ EAPI int pipe(int *fds);
|
|||
# define S_IWOTH S_IWUSR
|
||||
# define S_IXGRP S_IXUSR
|
||||
# define S_IXOTH S_IXUSR
|
||||
# define open(path,flag,mode) _open((path),(flag),(mode))
|
||||
# define open(path,...) _open((path),__VA_ARGS__)
|
||||
# define close(fd) _close(fd)
|
||||
# define read(fd,buffer,count) _read((fd),(buffer),(count))
|
||||
# define write(fd,buffer,count) _write((fd),(buffer),(count))
|
||||
# define unlink(filename) _unlink((filename))
|
||||
# define mkdir(p,m) _mkdir(p)
|
||||
# define getcwd(b,s) _getcwd((b),(s))
|
||||
# define lstat(f,s) _stat((f),(s))
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
@ -361,7 +363,7 @@ EAPI char *realpath(const char *file_name, char *resolved_name);
|
|||
* @return 1 on success, 0 otherwise.
|
||||
*
|
||||
* Initiates the use of Windows sockets. If the function succeeds,
|
||||
* it returns 1, otherwise it return 0.
|
||||
* it returns 1, otherwise it returns 0.
|
||||
*
|
||||
* Conformity: Non applicable.
|
||||
*
|
||||
|
@ -386,13 +388,55 @@ EAPI int evil_sockets_init(void);
|
|||
*/
|
||||
EAPI void evil_sockets_shutdown(void);
|
||||
|
||||
/**
|
||||
* @brief Create, modify, or remove environment variables.
|
||||
*
|
||||
* @param name The name of the environment variable.
|
||||
* @param value The value of the environment variable to set.
|
||||
* @return 0 on success, -1 otherwise.
|
||||
*
|
||||
* Add the new environment variable @p name or modify its value if it
|
||||
* exists, and set it to @p value. Environment variables define the
|
||||
* environment in which a process executes. If @p value is @c NULL, the
|
||||
* variable is removed (unset) and that call is equivalent to unsetenv().
|
||||
* If the function succeeds, it returns 0, otherwise it returns -1.
|
||||
*
|
||||
* Conformity: Non applicable.
|
||||
*
|
||||
* Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
|
||||
* Windows XP.
|
||||
*
|
||||
* @ingroup Evil
|
||||
*/
|
||||
EAPI int setenv(const char *name, const char *value);
|
||||
|
||||
/**
|
||||
* @brief Remove environment variables.
|
||||
*
|
||||
* @param name The name of the environment variable.
|
||||
* @return 0 on success, -1 otherwise.
|
||||
*
|
||||
* Remove the new environment variable @p name if it exists. That
|
||||
* function is equivalent to setenv() with its second parameter to
|
||||
* @c NULL. If the function succeeds, it returns 0, otherwise it
|
||||
* returns -1.
|
||||
*
|
||||
* Conformity: Non applicable.
|
||||
*
|
||||
* Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
|
||||
* Windows XP.
|
||||
*
|
||||
* @ingroup Evil
|
||||
*/
|
||||
EAPI int unsetenv(const char *name);
|
||||
|
||||
/**
|
||||
* @brief Return a dir to store temporary files.
|
||||
*
|
||||
* @return The directory to store temporary files.
|
||||
*
|
||||
* Return a directory to store temporary files. The function gets
|
||||
* the value of the followig environment variables, and in that order:
|
||||
* the value of the following environment variables, and in that order:
|
||||
* - TMP
|
||||
* - TEMP
|
||||
* - USERPROFILE
|
||||
|
@ -407,9 +451,30 @@ EAPI void evil_sockets_shutdown(void);
|
|||
*
|
||||
* @ingroup Evil
|
||||
*/
|
||||
|
||||
EAPI const char *evil_tmpdir_get(void);
|
||||
|
||||
/**
|
||||
* @brief Return a dir to store personal files.
|
||||
*
|
||||
* @return The directory to store personal files.
|
||||
*
|
||||
* Return a directory to store personal files. The function gets
|
||||
* the value of the following environment variables, and in that order:
|
||||
* - HOME
|
||||
* - USERPROFILE
|
||||
* - WINDIR
|
||||
* and returns its value if it exists. If none exists, the function
|
||||
* returns "C:\".
|
||||
*
|
||||
* Conformity: Non applicable.
|
||||
*
|
||||
* Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
|
||||
* Windows XP.
|
||||
*
|
||||
* @ingroup Evil
|
||||
*/
|
||||
EAPI const char *evil_homedir_get(void);
|
||||
|
||||
/**
|
||||
* @brief Get the current directory.
|
||||
*
|
||||
|
|
|
@ -388,6 +388,38 @@ evil_sockets_shutdown(void)
|
|||
WSACleanup();
|
||||
}
|
||||
|
||||
int
|
||||
setenv(const char *name, const char *value)
|
||||
{
|
||||
char *str;
|
||||
int length;
|
||||
int res;
|
||||
|
||||
length = strlen(name) + strlen(value) + 2;
|
||||
str = (char *)malloc(length);
|
||||
sprintf(str, "%s=%s", name, value);
|
||||
res = _putenv(str);
|
||||
free(str);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int
|
||||
unsetenv(const char *name)
|
||||
{
|
||||
char *str;
|
||||
int length;
|
||||
int res;
|
||||
|
||||
length = strlen(name) + 2;
|
||||
str = (char *)malloc(length);
|
||||
sprintf(str, "%s=", name);
|
||||
res = _putenv(str);
|
||||
free(str);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
const char *
|
||||
evil_tmpdir_get(void)
|
||||
{
|
||||
|
@ -402,6 +434,19 @@ evil_tmpdir_get(void)
|
|||
return tmpdir;
|
||||
}
|
||||
|
||||
const char *
|
||||
evil_homedir_get(void)
|
||||
{
|
||||
char *homedir;
|
||||
|
||||
homedir = getenv("HOME");
|
||||
if (!homedir) homedir = getenv("USERPROFILE");
|
||||
if (!homedir) homedir = getenv("WINDIR");
|
||||
if (!homedir) homedir="C:\\";
|
||||
|
||||
return homedir;
|
||||
}
|
||||
|
||||
char *
|
||||
evil_getcwd(char *buffer, size_t size)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue