summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1997-12-24 03:10:55 +0000
committerGurusamy Sarathy <gsar@cpan.org>1997-12-24 03:10:55 +0000
commite34ffe5a86599b66240875a414d90fdf19ed7649 (patch)
treef840c3693d649a60e5589dc8b7809073d7b99685 /win32
parent26618a56da4122343158bd70acec552d2e6da993 (diff)
downloadperl-e34ffe5a86599b66240875a414d90fdf19ed7649.tar.gz
[win32] support getlogin()
p4raw-id: //depot/win32/perl@386
Diffstat (limited to 'win32')
-rw-r--r--win32/config.bc2
-rw-r--r--win32/config.gc2
-rw-r--r--win32/config.vc2
-rw-r--r--win32/config_H.bc2
-rw-r--r--win32/config_H.gc2
-rw-r--r--win32/config_H.vc2
-rw-r--r--win32/win32.c18
-rw-r--r--win32/win32.h26
8 files changed, 36 insertions, 20 deletions
diff --git a/win32/config.bc b/win32/config.bc
index c5340214b8..97cee6a476 100644
--- a/win32/config.bc
+++ b/win32/config.bc
@@ -131,7 +131,7 @@ d_getgrps='undef'
d_setgrps='undef'
d_gethent='undef'
d_gethname='undef'
-d_getlogin='undef'
+d_getlogin='define'
d_getpgrp2='undef'
d_getpgrp='undef'
d_getpgid='undef'
diff --git a/win32/config.gc b/win32/config.gc
index c9b0b2ab09..3c9acbeda6 100644
--- a/win32/config.gc
+++ b/win32/config.gc
@@ -131,7 +131,7 @@ d_getgrps='undef'
d_setgrps='undef'
d_gethent='undef'
d_gethname='undef'
-d_getlogin='undef'
+d_getlogin='define'
d_getpgrp2='undef'
d_getpgrp='undef'
d_getpgid='undef'
diff --git a/win32/config.vc b/win32/config.vc
index 3e7f9aa523..09573225fb 100644
--- a/win32/config.vc
+++ b/win32/config.vc
@@ -131,7 +131,7 @@ d_getgrps='undef'
d_setgrps='undef'
d_gethent='undef'
d_gethname='undef'
-d_getlogin='undef'
+d_getlogin='define'
d_getpgrp2='undef'
d_getpgrp='undef'
d_getpgid='undef'
diff --git a/win32/config_H.bc b/win32/config_H.bc
index cea8b4e9c3..846d81d1e4 100644
--- a/win32/config_H.bc
+++ b/win32/config_H.bc
@@ -352,7 +352,7 @@
* This symbol, if defined, indicates that the getlogin routine is
* available to get the login name.
*/
-/*#define HAS_GETLOGIN /**/
+#define HAS_GETLOGIN /**/
/* HAS_GETPGRP2:
* This symbol, if defined, indicates that the getpgrp2() (as in DG/UX)
diff --git a/win32/config_H.gc b/win32/config_H.gc
index 012d2e0062..35737e7ca0 100644
--- a/win32/config_H.gc
+++ b/win32/config_H.gc
@@ -352,7 +352,7 @@
* This symbol, if defined, indicates that the getlogin routine is
* available to get the login name.
*/
-/*#define HAS_GETLOGIN /**/
+#define HAS_GETLOGIN /**/
/* HAS_GETPGRP2:
* This symbol, if defined, indicates that the getpgrp2() (as in DG/UX)
diff --git a/win32/config_H.vc b/win32/config_H.vc
index 87ecab8221..72caabb9f9 100644
--- a/win32/config_H.vc
+++ b/win32/config_H.vc
@@ -352,7 +352,7 @@
* This symbol, if defined, indicates that the getlogin routine is
* available to get the login name.
*/
-/*#define HAS_GETLOGIN /**/
+#define HAS_GETLOGIN /**/
/* HAS_GETPGRP2:
* This symbol, if defined, indicates that the getpgrp2() (as in DG/UX)
diff --git a/win32/win32.c b/win32/win32.c
index 1de1bb870f..bdfb3e2984 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -58,15 +58,18 @@ HANDLE PerlDllHandle = INVALID_HANDLE_VALUE;
#ifdef USE_THREADS
# ifdef USE_DECLSPEC_THREAD
__declspec(thread) char strerror_buffer[512];
+__declspec(thread) char getlogin_buffer[128];
# ifdef HAVE_DES_FCRYPT
__declspec(thread) char crypt_buffer[30];
# endif
# else
# define strerror_buffer (thr->i.Wstrerror_buffer)
+# define getlogin_buffer (thr->i.Wgetlogin_buffer)
# define crypt_buffer (thr->i.Wcrypt_buffer)
# endif
#else
char strerror_buffer[512];
+char getlogin_buffer[128];
# ifdef HAVE_DES_FCRYPT
char crypt_buffer[30];
# endif
@@ -573,6 +576,17 @@ setgid(gid_t agid)
return (agid == ROOT_GID ? 0 : -1);
}
+char *
+getlogin(void)
+{
+ dTHR;
+ char *buf = getlogin_buffer;
+ DWORD size = sizeof(getlogin_buffer);
+ if (GetUserName(buf,&size))
+ return buf;
+ return (char*)NULL;
+}
+
/*
* pretended kill
*/
@@ -1524,8 +1538,8 @@ static
XS(w32_LoginName)
{
dXSARGS;
- char name[256];
- DWORD size = sizeof(name);
+ char *name = getlogin_buffer;
+ DWORD size = sizeof(getlogin_buffer);
if (GetUserName(name,&size)) {
/* size includes NULL */
ST(0) = sv_2mortal(newSVpv(name,size-1));
diff --git a/win32/win32.h b/win32/win32.h
index 7534ec5f31..1b1f64adac 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -149,6 +149,7 @@ extern int setuid(uid_t uid);
extern int setgid(gid_t gid);
extern int kill(int pid, int sig);
extern void *sbrk(int need);
+extern char * getlogin(void);
#undef Stat
#define Stat win32_stat
@@ -205,18 +206,19 @@ EXT void win32_strip_return(struct sv *sv);
*/
#ifdef USE_THREADS
-#ifndef USE_DECLSPEC_THREAD
-#define HAVE_THREAD_INTERN
-
-struct thread_intern
-{
- char Wstrerror_buffer[512];
- struct servent Wservent;
-#ifdef HAVE_DES_FCRYPT
- char Wcrypt_buffer[30];
-#endif
+# ifndef USE_DECLSPEC_THREAD
+# define HAVE_THREAD_INTERN
+
+struct thread_intern {
+ /* XXX can probably use one buffer instead of several */
+ char Wstrerror_buffer[512];
+ struct servent Wservent;
+ char Wgetlogin_buffer[128];
+# ifdef HAVE_DES_FCRYPT
+ char Wcrypt_buffer[30];
+# endif
};
-#endif
-#endif
+# endif /* !USE_DECLSPEC_THREAD */
+#endif /* USE_THREADS */
#endif /* _INC_WIN32_PERL5 */