1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

add getlogin from gnulib

* lib/Makefile.am:
* lib/getlogin.c:
* m4/getlogin.m4:
* m4/gnulib-cache.m4: Add getlogin module.
This commit is contained in:
Andy Wingo 2013-03-09 23:09:36 +01:00
parent 6ab4de6125
commit b7548cd2dc
5 changed files with 75 additions and 2 deletions

View file

@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program. # the same distribution terms as the rest of that program.
# #
# Generated by gnulib-tool. # 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 AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
@ -577,6 +577,15 @@ EXTRA_libgnu_la_SOURCES += gai_strerror.c getaddrinfo.c
## end gnulib module getaddrinfo ## 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 ## begin gnulib module getpeername

41
lib/getlogin.c Normal file
View file

@ -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;
}

14
m4/getlogin.m4 Normal file
View file

@ -0,0 +1,14 @@
# getlogin.m4 serial 3
dnl Copyright (C) 2010-2013 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_GETLOGIN],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
AC_CHECK_FUNCS_ONCE([getlogin])
if test $ac_cv_func_getlogin = no; then
HAVE_GETLOGIN=0
fi
])

View file

@ -27,7 +27,7 @@
# Specification in the form of a command-line invocation: # Specification in the form of a command-line invocation:
# 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 # 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
# Specification in the form of a few gnulib-tool.m4 macro invocations: # Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([gnulib-local]) gl_LOCAL_DIR([gnulib-local])
@ -58,6 +58,7 @@ gl_MODULES([
func func
gendocs gendocs
getaddrinfo getaddrinfo
getlogin
getpeername getpeername
getsockname getsockname
getsockopt getsockopt

View file

@ -87,6 +87,7 @@ AC_DEFUN([gl_EARLY],
# Code from module func: # Code from module func:
# Code from module gendocs: # Code from module gendocs:
# Code from module getaddrinfo: # Code from module getaddrinfo:
# Code from module getlogin:
# Code from module getpeername: # Code from module getpeername:
# Code from module getsockname: # Code from module getsockname:
# Code from module getsockopt: # Code from module getsockopt:
@ -353,6 +354,11 @@ AC_SUBST([LTALLOCA])
AC_LIBOBJ([gai_strerror]) AC_LIBOBJ([gai_strerror])
fi fi
gl_NETDB_MODULE_INDICATOR([getaddrinfo]) gl_NETDB_MODULE_INDICATOR([getaddrinfo])
gl_FUNC_GETLOGIN
if test $HAVE_GETLOGIN = 0; then
AC_LIBOBJ([getlogin])
fi
gl_UNISTD_MODULE_INDICATOR([getlogin])
AC_REQUIRE([gl_HEADER_SYS_SOCKET]) AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then if test "$ac_cv_header_winsock2_h" = yes; then
AC_LIBOBJ([getpeername]) AC_LIBOBJ([getpeername])
@ -944,6 +950,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/full-write.h lib/full-write.h
lib/gai_strerror.c lib/gai_strerror.c
lib/getaddrinfo.c lib/getaddrinfo.c
lib/getlogin.c
lib/getpeername.c lib/getpeername.c
lib/getsockname.c lib/getsockname.c
lib/getsockopt.c lib/getsockopt.c
@ -1131,6 +1138,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/fstat.m4 m4/fstat.m4
m4/func.m4 m4/func.m4
m4/getaddrinfo.m4 m4/getaddrinfo.m4
m4/getlogin.m4
m4/glibc21.m4 m4/glibc21.m4
m4/gnulib-common.m4 m4/gnulib-common.m4
m4/hostent.m4 m4/hostent.m4