Enlightenment CVS committal
Author : doursse
Project : e17
Module : proto/evil
Dir : e17/proto/evil/src/lib
Modified Files:
Evil.h evil.c
Log Message:
Fix open, add getcwd, lstat, setenv, unsetenv and evil_homedir_get and fix typo
in doc
===================================================================
RCS file: /cvs/e/e17/proto/evil/src/lib/Evil.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- Evil.h 11 May 2008 09:32:52 -0000 1.11
+++ Evil.h 1 Jun 2008 17:09:14 -0000 1.12
@@ -319,12 +319,14 @@
# 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 @@
* @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.
*
@@ -387,12 +389,54 @@
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,8 +451,29 @@
*
* @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.
===================================================================
RCS file: /cvs/e/e17/proto/evil/src/lib/evil.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- evil.c 11 May 2008 09:32:52 -0000 1.8
+++ evil.c 1 Jun 2008 17:09:14 -0000 1.9
@@ -388,6 +388,38 @@
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)
{
@@ -400,6 +432,19 @@
if (!tmpdir) tmpdir="C:\\";
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 *
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs