diff options
author | Andy Wingo <wingo@pobox.com> | 2013-03-09 23:09:36 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-03-09 23:09:44 +0100 |
commit | b7548cd2dc4ead3c0ad3d2fb5c9fc43d54e6ce8d (patch) | |
tree | 587386260ecbead2e681389849d354e1db0318aa /lib | |
parent | 6ab4de612510b7c8668f0b50388258392f25b157 (diff) | |
download | guile-b7548cd2dc4ead3c0ad3d2fb5c9fc43d54e6ce8d.tar.gz |
add getlogin from gnulib
* lib/Makefile.am:
* lib/getlogin.c:
* m4/getlogin.m4:
* m4/gnulib-cache.m4: Add getlogin module.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile.am | 11 | ||||
-rw-r--r-- | lib/getlogin.c | 41 |
2 files changed, 51 insertions, 1 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index a0d857aa0..701cd1296 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil clock-time close connect dirfd duplocale environ extensions flock floor fpieee frexp fstat full-read full-write func gendocs getaddrinfo getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen localcharset locale log1p maintainer-makefile malloc-gnu malloca nl_langinfo nproc open pipe-posix pipe2 putenv recv recvfrom regex rename select send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat times trunc verify vsnprintf warnings wchar +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil clock-time close connect dirfd duplocale environ extensions flock floor fpieee frexp fstat full-read full-write func gendocs getaddrinfo getlogin getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen localcharset locale log1p maintainer-makefile malloc-gnu malloca nl_langinfo nproc open pipe-posix pipe2 putenv recv recvfrom regex rename select send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat times trunc verify vsnprintf warnings wchar AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects @@ -577,6 +577,15 @@ EXTRA_libgnu_la_SOURCES += gai_strerror.c getaddrinfo.c ## end gnulib module getaddrinfo +## begin gnulib module getlogin + + +EXTRA_DIST += getlogin.c + +EXTRA_libgnu_la_SOURCES += getlogin.c + +## end gnulib module getlogin + ## begin gnulib module getpeername diff --git a/lib/getlogin.c b/lib/getlogin.c new file mode 100644 index 000000000..ebe7c3366 --- /dev/null +++ b/lib/getlogin.c @@ -0,0 +1,41 @@ +/* Provide a working getlogin for systems which lack it. + + Copyright (C) 2010-2013 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible, 2010. */ + +#include <config.h> + +/* Specification. */ +#include <unistd.h> + +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# define WIN32_LEAN_AND_MEAN +# include <windows.h> +#endif + +char * +getlogin (void) +{ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + static char login_name[1024]; + DWORD sz = sizeof (login_name); + + if (GetUserName (login_name, &sz)) + return login_name; +#endif + return NULL; +} |