summaryrefslogtreecommitdiff
path: root/src/lib/evil/evil_pwd.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-09-11 16:13:11 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-09-11 16:13:11 +0000
commitcd69ef4c8a66e7155967a8b661a014856979cf31 (patch)
tree4a351ae4a4ca91abf29c85254b85ea8da71f74b0 /src/lib/evil/evil_pwd.c
parent59a9dfd11860888a35e96dfe51af63cea5cecfe1 (diff)
downloadefl-cd69ef4c8a66e7155967a8b661a014856979cf31.tar.gz
merge: add evil files
SVN revision: 76464
Diffstat (limited to 'src/lib/evil/evil_pwd.c')
-rw-r--r--src/lib/evil/evil_pwd.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/lib/evil/evil_pwd.c b/src/lib/evil/evil_pwd.c
new file mode 100644
index 0000000000..0830b5b26a
--- /dev/null
+++ b/src/lib/evil/evil_pwd.c
@@ -0,0 +1,65 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <windows.h>
+#include <security.h>
+
+#include "Evil.h"
+#include "pwd.h"
+
+
+static struct passwd pw;
+
+struct passwd *
+getpwuid (uid_t uid)
+{
+ static char user_name[PATH_MAX];
+ TCHAR name[PATH_MAX];
+ ULONG length;
+ BOOLEAN res;
+#ifdef UNICODE
+ char *a_name;
+# endif /* UNICODE */
+
+ length = PATH_MAX;
+#ifdef _WIN32_WINNT
+ res = GetUserNameEx(NameDisplay, name, &length);
+#else
+ res = GetUserNameEx(NameWindowsCeLocal, name, &length);
+#endif
+#ifdef UNICODE
+ if (res)
+ {
+ a_name = evil_wchar_to_char(name);
+ if (a_name)
+ {
+ int l;
+
+ l = strlen(a_name);
+ if (l >= PATH_MAX)
+ l = PATH_MAX;
+ memcpy(user_name, a_name, l);
+ user_name[l] = '\0';
+ free(a_name);
+ }
+ else
+ res = 0;
+ }
+#endif /* UNICODE */
+ pw.pw_name = (res ? user_name : NULL);
+ pw.pw_passwd = NULL;
+ pw.pw_uid = uid;
+ pw.pw_gid = 0;
+ pw.pw_change = 0;
+ pw.pw_class = NULL;
+ pw.pw_gecos = (res ? user_name : NULL);
+ pw.pw_dir = (char *)evil_homedir_get();
+ pw.pw_shell = getenv("SHELL");
+ if (!pw.pw_shell)
+ pw.pw_shell = "sh";
+ pw.pw_expire = 0;
+ pw.pw_fields = 0;
+
+ return &pw;
+}