1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Wed May 22 01:48:54 1996 Ulrich Drepper <drepper@cygnus.com>

* stdlib/strtol.c [!QUAD] (ULONG_MAX, LONG_MAX): Define these
	macros if they are not available.
	(WEAKNAME): New macro to declare argument as weak.
	Define function with __ prefix and add normal name as weak alias.

	* sysdeps/posix/euidaccess.c (S_IROTH, S_IWOTH, S_IXOTH): Defines
	these macros if not already available based on R_OK, W_OK, and
	X_OK.

Tue May 21 18:48:46 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>

	* misc/sys/syslog.h (__need___va_list): Define this instead of
	__need_va_list before including <stdarg.h>.

	* Makerules (o-iterator): Use $(object-suffixes-left) instead
	of $(object-suffixes) to produce repetitions; this is used for other
	lists than just that one.
	[versioned]: Use $(o-iterator) properly.

	* sysdeps/unix/sysv/linux/Implies: Include `gnu'.
	* sysdeps/mach/hurd/Implies: Likewise.

Sat May 18 02:57:46 1996  Ulrich Drepper  <drepper@cygnus.com>

	* login/Makefile: New file.  This directory contains functions
	for user administration.
	* Makefile (subdirs): Add login.

	* misc/Makefile (headers): Remove utmp.h.  Now in login/utmp.h.
	(extra-libs, libutil-routines): Ditto.
	* misc/login.c, misc/login_tty.c, misc/logout.c, misc/logwtmp.c,
	misc/utmp.h: Moved to misc/.
	* login/login.c, login/login_tty.c, login/logout.c,
        login/logwtmp.c, login/utmp.h: Moved to here from misc/.

	* login/utmp.h: Split file.  Definitions of data structures
	and constants are now in the system dependent utmpbits.h file.

	* login/setutent_r.c, login/setutent.c, login/endutent_r.c,
	login/endutent.c, login/getutent_r.c, login/getutent.c,
	login/getutid_r.c, login/getutid.c, login/getutline_r.c,
	login/getutline.c, login/pututline_r.c, login/pututline.c:
	New files.  Routines to handle utmp-style files.

	* sysdeps/gnu/utmpbits.h: New file.  Contains GNU/Linux
	specific definitions of utmp data structures and constants.

	* sysdeps/unix/sysv/utmpbits.h: Renamed from sysdeps/unix/sysv/utmp.h.

	* sysdeps/generic/utmpbits.h: New file.  Generic (BSDish) version of
	definitions of utmp data structures and constants.

Fri May 17 00:01:31 1996  Ulrich Drepper  <drepper@cygnus.com>

	* locale/C-monetary.c: Default value for mon_decimal_point should be
        '.'.

	* stdio-common/printf.h: Remove Linux libc compatibility stuff.
	Add `extra' flag.  Currently used in __printf_fp.

	* stdio-common/printf_fp.c (__guess_grouping): Renamed from
        `guess_grouping' and extend visibility to extern.  This function
        is now used in `strfmon'.
	(__printf_fp): Recognize new bit flag in info struct.  This
	triggers to use the grouping information and decimal point from
	the LC_MONETARY category instead of the LC_NUMERIC category.

	* stdio-common/vfprintf.c (process_arg): Correct major bug.  In
	`complicated' loop we must not use the varargs because the args
	are already available in the ARGS_VALUE array.

	* stdlib/Makefile (headers): Add monetary.h.
	(routines): Add strfmon.
	* stdlib/monetary.h: New file.  Header for strfmon function.
	* stdlib/strfmon.c: New file.  Implement strfmon function to print
	monetary amounts according to current locale's rules.

	* sysdeps/unix/sysv/linux/i386/sys/vm86.h: The kernel header is
	now (>= Linux-1.3.100) called <asm/vm86.h>.
This commit is contained in:
Roland McGrath
1996-05-22 02:11:55 +00:00
parent 1b82a4a8ca
commit b8fe19fa80
43 changed files with 1751 additions and 242 deletions

View File

@ -1,3 +1,85 @@
Wed May 22 01:48:54 1996 Ulrich Drepper <drepper@cygnus.com>
* stdlib/strtol.c [!QUAD] (ULONG_MAX, LONG_MAX): Define these
macros if they are not available.
(WEAKNAME): New macro to declare argument as weak.
Define function with __ prefix and add normal name as weak alias.
* sysdeps/posix/euidaccess.c (S_IROTH, S_IWOTH, S_IXOTH): Defines
these macros if not already available based on R_OK, W_OK, and
X_OK.
Tue May 21 18:48:46 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* misc/sys/syslog.h (__need___va_list): Define this instead of
__need_va_list before including <stdarg.h>.
* Makerules (o-iterator): Use $(object-suffixes-left) instead
of $(object-suffixes) to produce repetitions; this is used for other
lists than just that one.
[versioned]: Use $(o-iterator) properly.
* sysdeps/unix/sysv/linux/Implies: Include `gnu'.
* sysdeps/mach/hurd/Implies: Likewise.
Sat May 18 02:57:46 1996 Ulrich Drepper <drepper@cygnus.com>
* login/Makefile: New file. This directory contains functions
for user administration.
* Makefile (subdirs): Add login.
* misc/Makefile (headers): Remove utmp.h. Now in login/utmp.h.
(extra-libs, libutil-routines): Ditto.
* misc/login.c, misc/login_tty.c, misc/logout.c, misc/logwtmp.c,
misc/utmp.h: Moved to misc/.
* login/login.c, login/login_tty.c, login/logout.c,
login/logwtmp.c, login/utmp.h: Moved to here from misc/.
* login/utmp.h: Split file. Definitions of data structures
and constants are now in the system dependent utmpbits.h file.
* login/setutent_r.c, login/setutent.c, login/endutent_r.c,
login/endutent.c, login/getutent_r.c, login/getutent.c,
login/getutid_r.c, login/getutid.c, login/getutline_r.c,
login/getutline.c, login/pututline_r.c, login/pututline.c:
New files. Routines to handle utmp-style files.
* sysdeps/gnu/utmpbits.h: New file. Contains GNU/Linux
specific definitions of utmp data structures and constants.
* sysdeps/unix/sysv/utmpbits.h: Renamed from sysdeps/unix/sysv/utmp.h.
* sysdeps/generic/utmpbits.h: New file. Generic (BSDish) version of
definitions of utmp data structures and constants.
Fri May 17 00:01:31 1996 Ulrich Drepper <drepper@cygnus.com>
* locale/C-monetary.c: Default value for mon_decimal_point should be
'.'.
* stdio-common/printf.h: Remove Linux libc compatibility stuff.
Add `extra' flag. Currently used in __printf_fp.
* stdio-common/printf_fp.c (__guess_grouping): Renamed from
`guess_grouping' and extend visibility to extern. This function
is now used in `strfmon'.
(__printf_fp): Recognize new bit flag in info struct. This
triggers to use the grouping information and decimal point from
the LC_MONETARY category instead of the LC_NUMERIC category.
* stdio-common/vfprintf.c (process_arg): Correct major bug. In
`complicated' loop we must not use the varargs because the args
are already available in the ARGS_VALUE array.
* stdlib/Makefile (headers): Add monetary.h.
(routines): Add strfmon.
* stdlib/monetary.h: New file. Header for strfmon function.
* stdlib/strfmon.c: New file. Implement strfmon function to print
monetary amounts according to current locale's rules.
* sysdeps/unix/sysv/linux/i386/sys/vm86.h: The kernel header is
now (>= Linux-1.3.100) called <asm/vm86.h>.
Thu May 16 00:31:44 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> Thu May 16 00:31:44 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* Makerules [versioned]: Make symlinks in the build directory, because * Makerules [versioned]: Make symlinks in the build directory, because

View File

@ -53,7 +53,7 @@ endif
# These are the subdirectories containing the library source. # These are the subdirectories containing the library source.
subdirs = csu assert ctype db locale intl catgets math setjmp signal stdlib \ subdirs = csu assert ctype db locale intl catgets math setjmp signal stdlib \
stdio-common $(stdio) malloc string wcsmbs time dirent grp pwd\ stdio-common $(stdio) malloc string wcsmbs time dirent grp pwd\
posix io termios resource misc socket sysvipc gmon gnulib \ posix io termios resource misc login socket sysvipc gmon gnulib \
wctype $(wildcard crypt) manual $(sysdep-subdirs) elf po wctype $(wildcard crypt) manual $(sysdep-subdirs) elf po
export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63. export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63.

1
config.sub vendored
View File

@ -307,6 +307,7 @@ case $basic_machine in
basic_machine=m68k-hp basic_machine=m68k-hp
os=-hpux os=-hpux
;; ;;
hp9k2[0-9][0-9] | hp9k31[0-9])
basic_machine=m68000-hp basic_machine=m68000-hp
;; ;;
hp9k3[2-9][0-9]) hp9k3[2-9][0-9])

View File

@ -27,7 +27,7 @@ const struct locale_data _nl_C_LC_MONETARY =
{ {
{ string: "" }, { string: "" },
{ string: "" }, { string: "" },
{ string: "" }, { string: "." },
{ string: "" }, { string: "" },
{ string: "\177" }, { string: "\177" },
{ string: "" }, { string: "" },

38
login/Makefile Normal file
View File

@ -0,0 +1,38 @@
# Copyright (C) 1996 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
# The GNU C Library 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
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public
# License along with the GNU C Library; see the file COPYING.LIB. If
# not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Sub-makefile for login portion of the library.
#
subdir := login
headers := utmp.h utmpbits.h
routines := setutent endutent getutent getutid getutline pututline \
setutent_r endutent_r getutent_r getutid_r getutline_r \
pututline_r
# Build the -lutil library with these extra functions.
extra-libs := libutil
libutil-routines:= login login_tty logout logwtmp pty
include ../Rules
override CFLAGS += -D_THREAD_SAFE

31
login/endutent.c Normal file
View File

@ -0,0 +1,31 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <utmp.h>
/* The global data defined in setutent.c. */
extern struct utmp_data __utmp_data;
void
endutent (void)
{
endutent_r (&__utmp_data);
}

32
login/endutent_r.c Normal file
View File

@ -0,0 +1,32 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <unistd.h>
#include <utmp.h>
void
endutent_r (struct utmp_data *utmp_data)
{
if (utmp_data->ut_fd != -1)
{
close (utmp_data->ut_fd);
utmp_data->ut_fd = -1;
}
}

36
login/getutent.c Normal file
View File

@ -0,0 +1,36 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <utmp.h>
/* The global data defined in setutent.c. */
extern struct utmp_data __utmp_data;
struct utmp *
getutent (void)
{
struct utmp *result;
if (getutent_r (&result, &__utmp_data) < 0)
return NULL;
return result;
}

50
login/getutent_r.c Normal file
View File

@ -0,0 +1,50 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <unistd.h>
#include <utmp.h>
int
getutent_r (struct utmp **utmp, struct utmp_data *utmp_data)
{
/* Open utmp file if not already done. */
if (utmp_data->ut_fd == -1)
{
setutent_r (utmp_data);
if (utmp_data->ut_fd == -1)
return -1;
}
/* Position file correctly. */
if (lseek (utmp_data->ut_fd, utmp_data->loc_utmp, SEEK_SET) == -1)
return -1;
/* Read the next entry. */
if (read (utmp_data->ut_fd, &utmp_data->ubuf, sizeof (struct utmp))
!= sizeof (struct utmp))
return -1;
/* Update position pointer. */
utmp_data->loc_utmp += sizeof (struct utmp);
*utmp = &utmp_data->ubuf;
return 0;
}

36
login/getutid.c Normal file
View File

@ -0,0 +1,36 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <utmp.h>
/* The global data defined in setutent.c. */
extern struct utmp_data __utmp_data;
struct utmp *
getutid (const struct utmp *id)
{
struct utmp *result;
if (getutid_r (id, &result, &__utmp_data) < 0)
return NULL;
return (struct utmp *) result;
}

61
login/getutid_r.c Normal file
View File

@ -0,0 +1,61 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <errno.h>
#include <unistd.h>
#include <utmp.h>
/* For implementing this function we don't use the getutent_r function
because we can avoid the reposition on every new entry this way. */
int
getutid_r (const struct utmp *id, struct utmp **utmp,
struct utmp_data *utmp_data)
{
/* Open utmp file if not already done. */
if (utmp_data->ut_fd == -1)
{
setutent_r (utmp_data);
if (utmp_data->ut_fd == -1)
return -1;
}
/* Position file correctly. */
if (lseek (utmp_data->ut_fd, utmp_data->loc_utmp, SEEK_SET) == -1)
return -1;
do
{
/* Read the next entry. */
if (read (utmp_data->ut_fd, &utmp_data->ubuf, sizeof (struct utmp))
!= sizeof (struct utmp))
{
errno = ESRCH;
return -1;
}
/* Update position pointer. */
utmp_data->loc_utmp += sizeof (struct utmp);
}
while (id->ut_type != utmp_data->ubuf.ut_type);
*utmp = &utmp_data->ubuf;
return 0;
}

36
login/getutline.c Normal file
View File

@ -0,0 +1,36 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <utmp.h>
/* The global data defined in setutent.c. */
extern struct utmp_data __utmp_data;
struct utmp *
getutline (const struct utmp *line)
{
struct utmp *result;
if (getutline_r (line, &result, &__utmp_data) < 0)
return NULL;
return (struct utmp *) result;
}

61
login/getutline_r.c Normal file
View File

@ -0,0 +1,61 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <errno.h>
#include <unistd.h>
#include <utmp.h>
/* For implementing this function we don't use the getutent_r function
because we can avoid the reposition on every new entry this way. */
int
getutline_r (const struct utmp *line, struct utmp **utmp,
struct utmp_data *utmp_data)
{
/* Open utmp file if not already done. */
if (utmp_data->ut_fd == -1)
{
setutent_r (utmp_data);
if (utmp_data->ut_fd == -1)
return -1;
}
/* Position file correctly. */
if (lseek (utmp_data->ut_fd, utmp_data->loc_utmp, SEEK_SET) == -1)
return -1;
do
{
/* Read the next entry. */
if (read (utmp_data->ut_fd, &utmp_data->ubuf, sizeof (struct utmp))
!= sizeof (struct utmp))
{
errno = ESRCH;
return -1;
}
/* Update position pointer. */
utmp_data->loc_utmp += sizeof (struct utmp);
}
while (line->ut_line != utmp_data->ubuf.ut_line);
*utmp = &utmp_data->ubuf;
return 0;
}

34
login/pututline.c Normal file
View File

@ -0,0 +1,34 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <utmp.h>
/* The global data defined in setutent.c. */
extern struct utmp_data __utmp_data;
struct utmp *
pututline (const struct utmp *utmp)
{
if (pututline_r (utmp, &__utmp_data) < 0)
return NULL;
return (struct utmp *) utmp;
}

89
login/pututline_r.c Normal file
View File

@ -0,0 +1,89 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <alloca.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <utmp.h>
#include <sys/file.h>
int
pututline_r (const struct utmp *utmp_ptr, struct utmp_data *utmp_data)
{
/* Open utmp file if not already done. */
if (utmp_data->ut_fd == -1)
{
setutent_r (utmp_data);
if (utmp_data->ut_fd == -1)
return -1;
}
/* Seek position to write. */
if (utmp_data->ubuf.ut_type != utmp_ptr->ut_type)
{
/* We must not overwrite the data in UTMP_DATA. */
struct utmp_data *data_tmp = alloca (sizeof (utmp_data));
struct utmp *dummy;
memcpy (data_tmp, utmp_data, sizeof (utmp_data));
utmp_data = data_tmp;
if (getutid_r (utmp_ptr, &dummy, utmp_data) < 0)
{
if (errno != ESRCH)
return -1;
utmp_data->loc_utmp = lseek (utmp_data->ut_fd, 0, SEEK_END);
if (utmp_data->loc_utmp == -1)
return -1;
}
}
/* Position file correctly. */
if (utmp_data->loc_utmp > 0
&& lseek (utmp_data->ut_fd, utmp_data->loc_utmp - sizeof (struct utmp),
SEEK_SET) < 0)
return -1;
/* XXX An alternative solution would be to call an SUID root program
which write the new value. */
/* Try to lock the file. */
if (flock (utmp_data->ut_fd, LOCK_EX | LOCK_NB) < 0 && errno != ENOSYS)
{
/* Oh, oh. The file is already locked. Wait a bit and try again. */
sleep (1);
/* This time we ignore the error. */
(void) flock (utmp_data->ut_fd, LOCK_EX | LOCK_NB);
}
/* Write the new data. */
if (write (utmp_data->ut_fd, &utmp_data->ubuf, sizeof (struct utmp))
!= sizeof (struct utmp))
return -1;
/* And unlock the file. */
(void) flock (utmp_data->ut_fd, LOCK_UN);
return 0;
}

31
login/setutent.c Normal file
View File

@ -0,0 +1,31 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <utmp.h>
/* Global variable with values for non-reentrent functions. If must
be initialized so that field `ut_fd' is set to -1. */
struct utmp_data __utmp_data = { ut_fd: -1 };
void
setutent (void)
{
setutent_r (&__utmp_data);
}

72
login/setutent_r.c Normal file
View File

@ -0,0 +1,72 @@
/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <utmp.h>
/* This is the default name. */
static const char default_utmp_name[] = _PATH_UTMP;
/* Current file name. */
static const char *utmp_file_name = (const char *) default_utmp_name;
void
setutent_r (struct utmp_data *utmp_data)
{
/* Before the UTMP_DATA is used before the first time the UT_FD
field must be set to -1. */
if (utmp_data->ut_fd == -1)
{
utmp_data->ut_fd = open (utmp_file_name, O_RDWR);
if (utmp_data->ut_fd == -1)
{
/* Hhm, read-write access did not work. Try read-only. */
utmp_data->ut_fd = open (utmp_file_name, O_RDONLY);
if (utmp_data->ut_fd == -1)
{
perror (_("while opening UTMP file"));
return;
}
}
}
/* Remember we are at beginning of file. */
utmp_data->loc_utmp = 0;
utmp_data->ubuf.ut_type = -1;
}
int
utmpname (const char *file)
{
char *fname = strdup (file);
if (fname == NULL)
return 0;
if (utmp_file_name != default_utmp_name)
free ((void *) utmp_file_name);
utmp_file_name = fname;
return 1;
}

96
login/utmp.h Normal file
View File

@ -0,0 +1,96 @@
/* Copyright (C) 1993, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _UTMP_H_
#define _UTMP_H_ 1
#include <features.h>
#include <sys/types.h>
/* Get system dependent values and data structures. */
#include <utmpbits.h>
/* Write the given entry into utmp and wtmp. */
extern void login __P ((__const struct utmp *));
/* Write the utmp entry to say the user on UT_LINE has logged out. */
extern int logout __P ((__const char *ut_line));
/* Append to wtmp an entry for the current time and the given info. */
extern void logwtmp __P ((__const char *ut_line, __const char *ut_name,
__const char *ut_host));
/* Change name of the examine utmp file. */
extern int utmpname __P ((__const char *__file));
/* Read next entry from a utmp-like file. */
extern struct utmp *getutent __P ((void));
/* Rest the input stream to the beginning of the file. */
extern void setutent __P ((void));
/* Close the current open file. */
extern void endutent __P ((void));
/* Search forward from the current point in the utmp file until the
next entry with a ut_type matching ID->ut_type. */
extern struct utmp *getutid __P ((__const struct utmp *__id));
/* Search forward from the current point in the utmp file until the
next entry with a ut_line matching LINE->ut_line. */
extern struct utmp *getutline __P ((__const struct utmp *__line));
/* Write out entry pointed to by UTMP_PTR into the utmp file. */
extern struct utmp *pututline __P ((__const struct utmp *__utmp_ptr));
#if defined(_REENTRANT) || defined(_THREAD_SAFE)
/* Define the data structure needed for the reentrent version. */
struct utmp_data
{
int ut_fd;
off_t loc_utmp;
struct utmp ubuf;
};
/* Reentrent versions of the file for handling utmp files. */
extern int getutent_r __P ((struct utmp **__utmp,
struct utmp_data *__utmp_data));
extern void setutent_r __P ((struct utmp_data *__utmp_data));
extern void endutent_r __P ((struct utmp_data *__utmp_data));
extern int getutid_r __P ((__const struct utmp *__id, struct utmp **__utmp,
struct utmp_data *__utmp_data));
extern int getutline_r __P ((__const struct utmp *__line, struct utmp **__utmp,
struct utmp_data *__utmp_data));
extern int pututline_r __P ((__const struct utmp *__utmp_ptr,
struct utmp_data *__utmp_data));
#endif /* _REENTRENT || _THREAD_SAFE */
__END_DECLS
#endif /* utmp.h */

View File

@ -499,9 +499,11 @@ There is an example at the end of this section.
@comment ANSI @comment ANSI
@deftypefun {unsigned long int} strtoul (const char *@var{string}, char **@var{tailptr}, int @var{base}) @deftypefun {unsigned long int} strtoul (const char *@var{string}, char **@var{tailptr}, int @var{base})
The @code{strtoul} (``string-to-unsigned-long'') function is like The @code{strtoul} (``string-to-unsigned-long'') function is like
@code{strtol} except that it returns its value with type @code{unsigned @code{strtol} except it deals with unsigned numbers, and returns its
long int}. The value returned in case of overflow is @code{ULONG_MAX} value with type @code{unsigned long int}. No @samp{+} or @samp{-} sign
(@pxref{Range of Type}). may appear before the number, but the syntax is otherwise the same as
described above for @code{strtol}. The value returned in case of
overflow is @code{ULONG_MAX} (@pxref{Range of Type}).
@end deftypefun @end deftypefun
@comment stdlib.h @comment stdlib.h

View File

@ -835,6 +835,14 @@ that might not be supported in all implementations, and this is the kind
of error you get if you request them and they are not supported. of error you get if you request them and they are not supported.
@end deftypevr @end deftypevr
@comment errno.h
@comment ISO C: Invalid or incomplete multibyte or wide character
@deftypevr Macro int EILSEQ
@comment errno 106 @c DO NOT REMOVE
While decoding a multibyte character the function came along an invalid
or an incomplete sequence of bytes or the given wide character is invalid.
@end deftypevr
@comment errno.h @comment errno.h
@comment GNU: Inappropriate operation for background process @comment GNU: Inappropriate operation for background process
@deftypevr Macro int EBACKGROUND @deftypevr Macro int EBACKGROUND
@ -1012,4 +1020,3 @@ open_sesame (char *name)
return stream; return stream;
@} @}
@end smallexample @end smallexample

View File

@ -10,10 +10,10 @@
@set xref-automatic-section-title @set xref-automatic-section-title
@smallbook @smallbook
@c I've already told people the printed edition will be 0.06 @c sold 0.06/1.09, print run out 21may96
@set EDITION 0.06 @set EDITION 0.07 DRAFT
@set VERSION 1.09 Beta @set VERSION 1.09 Beta
@set UPDATED 23 December 1994 @set UPDATED 21 May 1996
@set ISBN 1-882114-53-1 @set ISBN 1-882114-53-1
@ifinfo @ifinfo
@ -22,7 +22,7 @@ This file documents the GNU C library.
This is Edition @value{EDITION}, last updated @value{UPDATED}, This is Edition @value{EDITION}, last updated @value{UPDATED},
of @cite{The GNU C Library Reference Manual}, for Version @value{VERSION}. of @cite{The GNU C Library Reference Manual}, for Version @value{VERSION}.
Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. Copyright (C) 1993, '94, '95, '96 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice this manual provided the copyright notice and this permission notice
@ -66,11 +66,11 @@ Foundation.
@center for version @value{VERSION} @center for version @value{VERSION}
@page @page
@vskip 0pt plus 1filll @vskip 0pt plus 1filll
Copyright @copyright{} 1993, 1994, 1995 Free Software Foundation, Inc. Copyright @copyright{} 1993, '94, '95, '96 Free Software Foundation, Inc.
@sp 2 @sp 2
Published by the Free Software Foundation @* Published by the Free Software Foundation @*
675 Massachusetts Avenue @* 59 Temple Place -- Suite 330, @*
Cambridge, MA 02139 USA @* Boston, MA 02111-1307 USA @*
Printed copies are available for $50 each. @* Printed copies are available for $50 each. @*
ISBN @value{ISBN} @* ISBN @value{ISBN} @*

View File

@ -25,8 +25,8 @@ subdir := misc
headers := sys/uio.h iovec.h sys/ioctl.h sys/ptrace.h ioctls.h sys/file.h\ headers := sys/uio.h iovec.h sys/ioctl.h sys/ptrace.h ioctls.h sys/file.h\
a.out.h nlist.h stab.h stab.def sgtty.h sys/dir.h sys/cdefs.h \ a.out.h nlist.h stab.h stab.def sgtty.h sys/dir.h sys/cdefs.h \
ttyent.h syscall.h syslog.h sys/syslog.h paths.h sys/reboot.h \ ttyent.h syscall.h syslog.h sys/syslog.h paths.h sys/reboot.h \
sys/mman.h sys/param.h fstab.h mntent.h search.h utmp.h \ sys/mman.h sys/param.h fstab.h mntent.h search.h err.h error.h\
err.h error.h sys/queue.h sysexits.h sys/queue.h sysexits.h
routines := brk sbrk sstk ioctl \ routines := brk sbrk sstk ioctl \
readv writev \ readv writev \
@ -60,10 +60,6 @@ install-lib := libbsd-compat.a libg.a
non-lib.a := libbsd-compat.a non-lib.a := libbsd-compat.a
gpl2lgpl := error.c error.h gpl2lgpl := error.c error.h
# Build the -lutil library with these extra functions.
extra-libs := libutil
libutil-routines:= login login_tty logout logwtmp pty
include ../Rules include ../Rules

View File

@ -1,82 +0,0 @@
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)utmp.h 8.2 (Berkeley) 1/21/94
*/
#ifndef _UTMP_H_
#define _UTMP_H_
#include <sys/cdefs.h>
#define _PATH_UTMP "/var/run/utmp"
#define _PATH_WTMP "/var/log/wtmp"
#define _PATH_LASTLOG "/var/log/lastlog"
#define UT_NAMESIZE 8
#define UT_LINESIZE 8
#define UT_HOSTSIZE 16
__BEGIN_DECLS
struct lastlog {
time_t ll_time;
char ll_line[UT_LINESIZE];
char ll_host[UT_HOSTSIZE];
};
struct utmp {
char ut_line[UT_LINESIZE];
char ut_name[UT_NAMESIZE];
char ut_host[UT_HOSTSIZE];
long ut_time;
};
/* Write the given entry into utmp and wtmp. */
extern void login __P ((const struct utmp *));
/* Write the utmp entry to say the user on UT_LINE has logged out. */
extern int logout __P ((const char *ut_line));
/* Append to wtmp an entry for the current time and the given info. */
extern void logwtmp __P ((const char *ut_line, const char *ut_name,
const char *ut_host));
__END_DECLS
#endif /* !_UTMP_H_ */

View File

@ -409,8 +409,8 @@ struct hostent *
gethostbyname(name) gethostbyname(name)
const char *name; const char *name;
{ {
/* Moved #if line to here because declararing HP would lead to a /* Moved #if line to here because declaring HP would lead to a
warining. --drepper@gnu */ warning. --drepper@gnu */
#if defined(AF_INET6) && defined(RES_TRY_INET6) #if defined(AF_INET6) && defined(RES_TRY_INET6)
struct hostent *hp; struct hostent *hp;

View File

@ -34,11 +34,7 @@ struct printf_info
{ {
int prec; /* Precision. */ int prec; /* Precision. */
int width; /* Width. */ int width; /* Width. */
#ifdef THIS_IS_INCOMPATIBLE_WITH_LINUX_LIBC
wchar_t spec; /* Format letter. */ wchar_t spec; /* Format letter. */
#else
char spec; /* Format letter. */
#endif
unsigned int is_long_double:1;/* L flag. */ unsigned int is_long_double:1;/* L flag. */
unsigned int is_short:1; /* h flag. */ unsigned int is_short:1; /* h flag. */
unsigned int is_long:1; /* l flag. */ unsigned int is_long:1; /* l flag. */
@ -47,6 +43,7 @@ struct printf_info
unsigned int left:1; /* - flag. */ unsigned int left:1; /* - flag. */
unsigned int showsign:1; /* + flag. */ unsigned int showsign:1; /* + flag. */
unsigned int group:1; /* ' flag. */ unsigned int group:1; /* ' flag. */
unsigned int extra:1; /* For special use. */
char pad; /* Padding character. */ char pad; /* Padding character. */
}; };

View File

@ -121,10 +121,10 @@ extern mp_size_t __mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
extern mp_size_t __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, extern mp_size_t __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
int *expt, int *is_neg, int *expt, int *is_neg,
long double value); long double value);
extern unsigned int __guess_grouping (unsigned int intdig_max,
static unsigned int guess_grouping (unsigned int intdig_max,
const char *grouping, wchar_t sepchar); const char *grouping, wchar_t sepchar);
static char *group_number (char *buf, char *bufend, unsigned int intdig_no, static char *group_number (char *buf, char *bufend, unsigned int intdig_no,
const char *grouping, wchar_t thousands_sep); const char *grouping, wchar_t thousands_sep);
@ -229,22 +229,51 @@ __printf_fp (FILE *fp,
/* Figure out the decimal point character. */ /* Figure out the decimal point character. */
if (info->extra == 0)
{
if (mbtowc (&decimal, _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT), if (mbtowc (&decimal, _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT),
strlen (_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT))) <= 0) strlen (_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT))) <= 0)
decimal = (wchar_t) *_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT); decimal = (wchar_t) *_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
}
else
{
if (mbtowc (&decimal, _NL_CURRENT (LC_MONETARY, MON_DECIMAL_POINT),
strlen (_NL_CURRENT (LC_MONETARY, MON_DECIMAL_POINT))) <= 0)
decimal = (wchar_t) *_NL_CURRENT (LC_MONETARY, MON_DECIMAL_POINT);
}
if (info->group) if (info->group)
{ {
if (info->extra == 0)
grouping = _NL_CURRENT (LC_NUMERIC, GROUPING); grouping = _NL_CURRENT (LC_NUMERIC, GROUPING);
else
grouping = _NL_CURRENT (LC_MONETARY, MON_GROUPING);
if (*grouping <= 0 || *grouping == CHAR_MAX) if (*grouping <= 0 || *grouping == CHAR_MAX)
grouping = NULL; grouping = NULL;
else else
{ {
/* Figure out the thousands seperator character. */ /* Figure out the thousands seperator character. */
if (mbtowc (&thousands_sep, _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP), if (info->extra == 0)
strlen (_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP))) <= 0) {
thousands_sep = (wchar_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP); if (mbtowc (&thousands_sep, _NL_CURRENT (LC_NUMERIC,
THOUSANDS_SEP),
strlen (_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP)))
<= 0)
thousands_sep = (wchar_t) *_NL_CURRENT (LC_NUMERIC,
THOUSANDS_SEP);
}
else
{
if (mbtowc (&thousands_sep, _NL_CURRENT (LC_MONETARY,
MON_THOUSANDS_SEP),
strlen (_NL_CURRENT (LC_MONETARY,
MON_THOUSANDS_SEP))) <= 0)
thousands_sep = (wchar_t) *_NL_CURRENT (LC_MONETARY,
MON_THOUSANDS_SEP);
}
if (thousands_sep == L'\0') if (thousands_sep == L'\0')
grouping = NULL; grouping = NULL;
} }
@ -726,7 +755,7 @@ __printf_fp (FILE *fp,
if (grouping) if (grouping)
/* Guess the number of groups we will make, and thus how /* Guess the number of groups we will make, and thus how
many spaces we need for separator characters. */ many spaces we need for separator characters. */
chars_needed += guess_grouping (intdig_max, grouping, thousands_sep); chars_needed += __guess_grouping (intdig_max, grouping, thousands_sep);
/* Allocate buffer for output. We need two more because while rounding /* Allocate buffer for output. We need two more because while rounding
it is possible that we need two more characters in front of all the it is possible that we need two more characters in front of all the
@ -933,8 +962,9 @@ __printf_fp (FILE *fp,
/* Return the number of extra grouping characters that will be inserted /* Return the number of extra grouping characters that will be inserted
into a number with INTDIG_MAX integer digits. */ into a number with INTDIG_MAX integer digits. */
static unsigned int unsigned int
guess_grouping (unsigned int intdig_max, const char *grouping, wchar_t sepchar) __guess_grouping (unsigned int intdig_max, const char *grouping,
wchar_t sepchar)
{ {
unsigned int groups; unsigned int groups;
@ -972,7 +1002,7 @@ static char *
group_number (char *buf, char *bufend, unsigned int intdig_no, group_number (char *buf, char *bufend, unsigned int intdig_no,
const char *grouping, wchar_t thousands_sep) const char *grouping, wchar_t thousands_sep)
{ {
unsigned int groups = guess_grouping (intdig_no, grouping, thousands_sep); unsigned int groups = __guess_grouping (intdig_no, grouping, thousands_sep);
char *p; char *p;
if (groups == 0) if (groups == 0)

View File

@ -414,7 +414,10 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
{ \ { \
long long int signed_number; \ long long int signed_number; \
\ \
if (fspec == NULL) \
signed_number = va_arg (ap, long long int); \ signed_number = va_arg (ap, long long int); \
else \
signed_number = args_value[fspec->data_arg].pa_long_long_int; \
\ \
is_negative = signed_number < 0; \ is_negative = signed_number < 0; \
number.longlong = is_negative ? (- signed_number) : signed_number; \ number.longlong = is_negative ? (- signed_number) : signed_number; \
@ -425,10 +428,16 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
{ \ { \
long int signed_number; \ long int signed_number; \
\ \
if (fspec == NULL) \
if (is_long) \ if (is_long) \
signed_number = va_arg (ap, long int); \ signed_number = va_arg (ap, long int); \
else /* `short int' will be promoted to `int'. */ \ else /* `short int' will be promoted to `int'. */ \
signed_number = va_arg (ap, int); \ signed_number = va_arg (ap, int); \
else \
if (is_long) \
signed_number = args_value[fspec->data_arg].pa_long_int; \
else \
signed_number = args_value[fspec->data_arg].pa_int; \
\ \
is_negative = signed_number < 0; \ is_negative = signed_number < 0; \
number.word = is_negative ? (- signed_number) : signed_number; \ number.word = is_negative ? (- signed_number) : signed_number; \
@ -463,7 +472,10 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
\ \
if (is_longlong) \ if (is_longlong) \
{ \ { \
if (fspec == NULL) \
number.longlong = va_arg (ap, unsigned long long int); \ number.longlong = va_arg (ap, unsigned long long int); \
else \
number.longlong = args_value[fspec->data_arg].pa_u_long_long_int; \
\ \
LABEL (longlong_number): \ LABEL (longlong_number): \
if (prec < 0) \ if (prec < 0) \
@ -493,12 +505,21 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
} \ } \
else \ else \
{ \ { \
if (fspec == NULL) \
if (is_long) \ if (is_long) \
number.word = va_arg (ap, unsigned long int); \ number.word = va_arg (ap, unsigned long int); \
else if (!is_short) \ else if (!is_short) \
number.word = va_arg (ap, unsigned int); \ number.word = va_arg (ap, unsigned int); \
else \ else \
number.word = (unsigned short int) va_arg (ap, unsigned int); \ number.word = (unsigned short int) va_arg (ap, unsigned int); \
else \
if (is_long) \
number.word = args_value[fspec->data_arg].pa_u_long_int; \
else if (!is_short) \
number.word = args_value[fspec->data_arg].pa_u_int; \
else \
number.word = (unsigned short int) \
args_value[fspec->data_arg].pa_u_short_int; \
\ \
LABEL (number): \ LABEL (number): \
if (prec < 0) \ if (prec < 0) \
@ -617,13 +638,6 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
const void *ptr; \ const void *ptr; \
int function_done; \ int function_done; \
\ \
if (is_long_double) \
the_arg.pa_long_double = va_arg (ap, long double); \
else \
the_arg.pa_double = va_arg (ap, double); \
\
ptr = (const void *) &the_arg; \
\
if (fspec == NULL) \ if (fspec == NULL) \
{ \ { \
struct printf_info info = { prec: prec, \ struct printf_info info = { prec: prec, \
@ -637,12 +651,23 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
left: left, \ left: left, \
showsign: showsign, \ showsign: showsign, \
group: group, \ group: group, \
pad: pad }; \ pad: pad, \
extra: 0 }; \
\
if (is_long_double) \
the_arg.pa_long_double = va_arg (ap, long double); \
else \
the_arg.pa_double = va_arg (ap, double); \
ptr = (const void *) &the_arg; \
\ \
function_done = __printf_fp (s, &info, &ptr); \ function_done = __printf_fp (s, &info, &ptr); \
} \ } \
else \ else \
{ \
ptr = (const void *) &args_value[fspec->data_arg]; \
\
function_done = __printf_fp (s, &fspec->info, &ptr); \ function_done = __printf_fp (s, &fspec->info, &ptr); \
} \
\ \
if (function_done < 0) \ if (function_done < 0) \
/* Error in print handler. */ \ /* Error in print handler. */ \
@ -657,7 +682,10 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
--width; /* Account for the character itself. */ \ --width; /* Account for the character itself. */ \
if (!left) \ if (!left) \
PAD (' '); \ PAD (' '); \
if (fspec == NULL) \
outchar ((unsigned char) va_arg (ap, int)); /* Promoted. */ \ outchar ((unsigned char) va_arg (ap, int)); /* Promoted. */ \
else \
outchar ((unsigned char) args_value[fspec->data_arg].pa_char); \
if (left) \ if (left) \
PAD (' '); \ PAD (' '); \
break; \ break; \
@ -668,7 +696,10 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
\ \
/* The string argument could in fact be `char *' or `wchar_t *'. \ /* The string argument could in fact be `char *' or `wchar_t *'. \
But this should not make a difference here. */ \ But this should not make a difference here. */ \
if (fspec == NULL) \
string = (char *) va_arg (ap, const char *); \ string = (char *) va_arg (ap, const char *); \
else \
string = (char *) args_value[fspec->data_arg].pa_string; \
\ \
/* Entry point for printing other strings. */ \ /* Entry point for printing other strings. */ \
LABEL (print_string): \ LABEL (print_string): \
@ -738,7 +769,10 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
/* Generic pointer. */ \ /* Generic pointer. */ \
{ \ { \
const void *ptr; \ const void *ptr; \
if (fspec == NULL) \
ptr = va_arg (ap, void *); \ ptr = va_arg (ap, void *); \
else \
ptr = args_value[fspec->data_arg].pa_pointer; \
if (ptr != NULL) \ if (ptr != NULL) \
{ \ { \
/* If the pointer is not NULL, write it as a %#x spec. */ \ /* If the pointer is not NULL, write it as a %#x spec. */ \
@ -765,6 +799,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
\ \
LABEL (form_number): \ LABEL (form_number): \
/* Answer the count of characters written. */ \ /* Answer the count of characters written. */ \
if (fspec == NULL) \
if (is_longlong) \ if (is_longlong) \
*(long long int *) va_arg (ap, void *) = done; \ *(long long int *) va_arg (ap, void *) = done; \
else if (is_long) \ else if (is_long) \
@ -773,6 +808,15 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
*(int *) va_arg (ap, void *) = done; \ *(int *) va_arg (ap, void *) = done; \
else \ else \
*(short int *) va_arg (ap, void *) = done; \ *(short int *) va_arg (ap, void *) = done; \
else \
if (is_longlong) \
*(long long int *) args_value[fspec->data_arg].pa_pointer = done; \
else if (is_long) \
*(long int *) args_value[fspec->data_arg].pa_pointer = done; \
else if (!is_short) \
*(int *) args_value[fspec->data_arg].pa_pointer = done; \
else \
*(short int *) args_value[fspec->data_arg].pa_pointer = done; \
break; \ break; \
\ \
LABEL (form_strerror): \ LABEL (form_strerror): \
@ -827,6 +871,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
STEP0_3_TABLE; STEP0_3_TABLE;
STEP4_TABLE; STEP4_TABLE;
union printf_arg *args_value; /* This is not used here but ... */
int is_negative; /* Flag for negative number. */ int is_negative; /* Flag for negative number. */
union union
{ {

View File

@ -21,7 +21,7 @@
# #
subdir := stdlib subdir := stdlib
headers := stdlib.h alloca.h headers := stdlib.h alloca.h monetary.h
routines := \ routines := \
atof atoi atol \ atof atoi atol \
@ -40,9 +40,9 @@ routines := \
drand48-iter \ drand48-iter \
strtol strtoul strtoq strtouq \ strtol strtoul strtoq strtouq \
strtof strtod strtold \ strtof strtod strtold \
system \ system realpath \
a64l l64a \ a64l l64a \
rpmatch rpmatch strfmon
distribute := exit.h grouping.h distribute := exit.h grouping.h
tests := tst-strtol tst-strtod testmb testrand testsort testdiv tests := tst-strtol tst-strtod testmb testrand testsort testdiv

36
stdlib/monetary.h Normal file
View File

@ -0,0 +1,36 @@
/* Header file for monetary value formatting functions.
Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _MONETARY_H
#define _MONETARY_H 1
#include <features.h>
/* Get needed types. */
#include <sys/types.h>
__BEGIN_DECLS
/* Formating a monetary value according to the current locale. */
extern ssize_t strfmon __P ((char *__s, size_t __maxsize,
__const char *__format, ...));
__END_DECLS
#endif /* monetary.h */

504
stdlib/strfmon.c Normal file
View File

@ -0,0 +1,504 @@
/* strfmon -- formating a monetary value according to the current locale
Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>
and Jochen Hein <Jochen.Hein@informatik.TU-Clausthal.de>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <ctype.h>
#include <errno.h>
#include <langinfo.h>
#include <monetary.h>
#ifdef USE_IN_LIBIO
# include "../libio/libioP.h"
# include "../libio/strfile.h"
#endif
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "../stdio-common/printf.h"
#include "../locale/localeinfo.h"
#define out_char(Ch) \
do { \
if (dest >= s + maxsize - 1) \
{ \
errno = E2BIG; \
va_end (ap); \
return -1; \
} \
*dest++ = (Ch); \
} while (0)
#define out_string(String) \
do { \
const char *_s = (String); \
while (*_s) \
out_char (*_s++); \
} while (0)
#define to_digit(Ch) ((Ch) - '0')
extern int __printf_fp (FILE *, const struct printf_info *,
const void **const);
/* This function determines the number of digit groups in the output.
The definition is in printf_fp.c. */
extern unsigned int __guess_grouping (unsigned int intdig_max,
const char *grouping, wchar_t sepchar);
/* We have to overcome some problems with this implementation. On the
one hand the strfmon() function is specified by in XPG4 and of
course it has to follow this. But on the other hand POSIX.2
specifies some information in the LC_MONETARY category which should
be used, too. Some of the information contradicts the information
which can be specified in format string. */
ssize_t
strfmon (char *s, size_t maxsize, const char *format, ...)
{
#ifdef USE_IN_LIBIO
_IO_strfile f;
#else
FILE f;
#endif
struct printf_info info;
va_list ap; /* Scan through the varargs. */
char *dest; /* Pointer so copy the output. */
const char *fmt; /* Pointer that walks through format. */
va_start (ap, format);
dest = s;
fmt = format;
/* Loop through the format-string. */
while (*fmt != '\0')
{
/* The floating-point value to output. */
union
{
double dbl;
__long_double_t ldbl;
}
fpnum;
int print_curr_symbol;
int left_prec;
int right_prec;
int group;
char pad;
int is_long_double;
int p_sign_posn;
int n_sign_posn;
int sign_posn;
int left;
int is_negative;
int sep_by_space;
int cs_precedes;
char sign_char;
int done;
const char *currency_symbol;
int width;
char *startp;
const void *ptr;
/* Process all character which do not introduce a format
specification. */
if (*fmt != '%')
{
out_char (*fmt++);
continue;
}
/* "%%" means a single '%' character. */
if (fmt[1] == '%')
{
out_char (*++fmt);
++fmt;
continue;
}
/* Defaults for formatting. */
print_curr_symbol = 1; /* Print the currency symbol. */
left_prec = -1; /* No left precision specified. */
right_prec = -1; /* No right precision specified. */
group = 1; /* Print digits grouped. */
pad = ' '; /* Fill character is <SP>. */
is_long_double = 0; /* Double argument by default. */
p_sign_posn = -1; /* This indicates whether the */
n_sign_posn = -1; /* '(' flag is given. */
width = -1; /* No width specified so far. */
left = 0; /* Right justified by default. */
/* Parse group characters. */
while (1)
{
switch (*++fmt)
{
case '=': /* Set fill character. */
pad = *++fmt;
continue;
case '^': /* Don't group digits. */
group = 0;
continue;
case '+': /* Use +/- for sign of number. */
if (n_sign_posn != -1)
{
errno = EINVAL;
va_end (ap);
return -1;
}
if (*_NL_CURRENT (LC_MONETARY, P_SIGN_POSN) == '\0')
p_sign_posn = 1;
else
p_sign_posn = *_NL_CURRENT (LC_MONETARY, P_SIGN_POSN);
if (*_NL_CURRENT (LC_MONETARY, N_SIGN_POSN) == '\0')
n_sign_posn = 1;
else
n_sign_posn = *_NL_CURRENT (LC_MONETARY, N_SIGN_POSN);
continue;
case '(': /* Use ( ) for negative sign. */
if (n_sign_posn != -1)
{
errno = EINVAL;
va_end (ap);
return -1;
}
n_sign_posn = 5; /* This is a else unused value. */
continue;
case '!': /* Don't print the currency symbol. */
print_curr_symbol = 0;
continue;
case '-': /* Print left justified. */
left = 1;
continue;
default:
/* Will stop the loop. */;
}
break;
}
if (isdigit (*fmt))
{
/* Parse field width. */
width = to_digit (*fmt);
while (isdigit (*++fmt))
{
width *= 10;
width += to_digit (*fmt);
}
/* If we don't have enough room for the demanded width we
can stop now and return an error. */
if (dest + width >= s + maxsize)
{
errno = E2BIG;
va_end (ap);
return -1;
}
}
/* Recognize left precision. */
if (*fmt == '#')
{
if (!isdigit (*++fmt))
{
errno = EINVAL;
va_end (ap);
return -1;
}
left_prec = to_digit (*fmt);
while (isdigit (*++fmt))
{
left_prec *= 10;
left_prec += to_digit (*fmt);
}
}
/* Recognize right precision. */
if (*fmt == '.')
{
if (!isdigit (*++fmt))
{
errno = EINVAL;
va_end (ap);
return -1;
}
right_prec = to_digit (*fmt);
while (isdigit (*++fmt))
{
right_prec *= 10;
right_prec += to_digit (*fmt);
}
}
/* Handle modifier. This is an extension. */
if (*fmt == 'L')
{
++fmt;
is_long_double = 1;
}
/* Handle format specifier. */
switch (*fmt++)
{
case 'i': /* Use international currency symbol. */
currency_symbol = _NL_CURRENT (LC_MONETARY, INT_CURR_SYMBOL);
if (right_prec == -1)
if (*_NL_CURRENT (LC_MONETARY, INT_FRAC_DIGITS) == '\177')
right_prec = 2;
else
right_prec = *_NL_CURRENT (LC_MONETARY, INT_FRAC_DIGITS);
break;
case 'n': /* Use national currency symbol. */
currency_symbol = _NL_CURRENT (LC_MONETARY, CURRENCY_SYMBOL);
if (right_prec == -1)
if (*_NL_CURRENT (LC_MONETARY, FRAC_DIGITS) == '\177')
right_prec = 2;
else
right_prec = *_NL_CURRENT (LC_MONETARY, FRAC_DIGITS);
break;
default: /* Any unrecognized format is an error. */
errno = EINVAL;
va_end (ap);
return -1;
}
/* If we have to print the digits grouped determine how many
extra characters this means. */
if (group && left_prec != -1)
left_prec += __guess_grouping (left_prec,
_NL_CURRENT (LC_MONETARY, MON_GROUPING),
*_NL_CURRENT (LC_MONETARY,
MON_THOUSANDS_SEP));
/* Now it's time to get the value. */
if (is_long_double == 1)
{
fpnum.ldbl = va_arg (ap, long double);
is_negative = fpnum.ldbl < 0;
if (is_negative)
fpnum.ldbl = -fpnum.ldbl;
}
else
{
fpnum.dbl = va_arg (ap, double);
is_negative = fpnum.dbl < 0;
if (is_negative)
fpnum.dbl = -fpnum.dbl;
}
/* We now know the sign of the value and can determine the format. */
if (is_negative)
{
sign_char = *_NL_CURRENT (LC_MONETARY, NEGATIVE_SIGN);
/* If the locale does not specify a character for the
negative sign we use a '-'. */
if (sign_char == '\0')
sign_char = '-';
cs_precedes = *_NL_CURRENT (LC_MONETARY, N_CS_PRECEDES);
sep_by_space = *_NL_CURRENT (LC_MONETARY, N_SEP_BY_SPACE);
/* If the '(' flag is not given use the sign position from
the current locale. */
if (n_sign_posn == -1)
sign_posn = *_NL_CURRENT (LC_MONETARY, N_SIGN_POSN);
else
/* This means use parentheses. */
sign_posn = 0;
}
else
{
sign_char = *_NL_CURRENT (LC_MONETARY, POSITIVE_SIGN);
/* If the locale does not specify a character for the
positive sign we use a <SP>. */
if (sign_char == '\0')
sign_char = ' ';
cs_precedes = *_NL_CURRENT (LC_MONETARY, P_CS_PRECEDES);
sep_by_space = *_NL_CURRENT (LC_MONETARY, P_SEP_BY_SPACE);
if (n_sign_posn == -1)
sign_posn = *_NL_CURRENT (LC_MONETARY, P_SIGN_POSN);
else
/* Here we don't set SIGN_POSN to 0 because we don'want to
print <SP> instead of the braces and this is what the
value 5 means. */
sign_posn = 5;
}
/* Set default values for unspecified information. */
if (cs_precedes != 0)
cs_precedes = 1;
if (sep_by_space == 127)
sep_by_space = 0;
if (left_prec == -1)
left_prec = 0;
/* Perhaps we'll someday make these things configurable so
better start using symbolic names now. */
#define left_paren '('
#define right_paren ')'
startp = dest; /* Remember start so we can compute lenght. */
if (sign_posn == 0)
out_char (left_paren);
if (sign_posn == 5) /* This is for positive number and ( flag. */
out_char (' ');
if (cs_precedes)
{
if (sign_posn != 0 && sign_posn != 2 && sign_posn != 4
&& sign_posn != 5)
{
out_char (sign_char);
if (sep_by_space == 2)
out_char (' ');
}
if (print_curr_symbol)
{
out_string (currency_symbol);
if (sign_posn == 4)
{
if (sep_by_space == 2)
out_char (' ');
out_char (sign_char);
}
else
if (sep_by_space == 1)
out_char (' ');
}
}
else
if (sign_posn != 0 && sign_posn != 2 && sign_posn != 3
&& sign_posn != 4 && sign_posn != 5)
out_char (sign_char);
/* Print the number. */
#ifdef USE_IN_LIBIO
_IO_init ((_IO_FILE *) &f, 0);
_IO_JUMPS ((_IO_FILE *) &f) = &_IO_str_jumps;
_IO_str_init_static ((_IO_FILE *) &f, dest, (s + maxsize) - dest, dest);
#else
memset((PTR) &f, 0, sizeof(f));
f.__magic = _IOMAGIC;
f.__mode.__write = 1;
/* The buffer size is one less than MAXLEN
so we have space for the null terminator. */
f.__bufp = f.__buffer = (char *) dest;
f.__bufsize = (s + maxsize) - dest;
f.__put_limit = f.__buffer + f.__bufsize;
f.__get_limit = f.__buffer;
/* After the buffer is full (MAXLEN characters have been written),
any more characters written will go to the bit bucket. */
f.__room_funcs = __default_room_functions;
f.__io_funcs.__write = NULL;
f.__seen = 1;
#endif
/* We clear the last available byte so we can find out whether
the numeric representation is too long. */
s[maxsize - 1] = '\0';
info.prec = right_prec;
info.width = left_prec + (right_prec ? (right_prec + 1) : 0);
info.spec = 'f';
info.is_long_double = is_long_double;
info.is_short = 0;
info.is_long = 0;
info.alt = 0;
info.space = 0;
info.left = left;
info.showsign = 0;
info.group = group;
info.pad = pad;
info.extra = 1; /* This means use values from LC_MONETARY. */
ptr = &fpnum;
done = __printf_fp ((FILE *) &f, &info, &ptr);
if (done < 0)
{
va_end (ap);
return -1;
}
if (s[maxsize - 1] != '\0')
return -1;
dest += done;
if (!cs_precedes)
{
if (sign_posn == 3)
{
if (sep_by_space == 1)
out_char (' ');
out_char (sign_char);
}
if (print_curr_symbol)
{
if (sign_posn == 3 && sep_by_space == 2)
out_char (' ');
out_string (currency_symbol);
}
}
else
if (sign_posn == 2)
{
if (sep_by_space == 2)
out_char (' ');
out_char (sign_char);
}
if (sign_posn == 0)
out_char (right_paren);
if (sign_posn == 5)
out_char (' '); /* This is for positive number and ( flag. */
/* Now test whether the output width is filled. */
if (dest - startp < width)
if (left)
/* We simply have to fill using spaces. */
do
out_char (' ');
while (dest - startp < width);
else
{
int dist = width - (dest - startp);
char *cp;
for (cp = dest - 1; cp >= startp; --cp)
cp[dist] = cp[0];
dest += dist;
do
startp[--dist] = ' ';
while (dist > 0);
}
}
/* Terminate the string. */
out_char ('\0');
va_end (ap);
return dest - s - 1;
}

View File

@ -105,6 +105,13 @@ extern int errno;
# endif # endif
#else #else
# define LONG long # define LONG long
#ifndef ULONG_MAX
# define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
#endif
#ifndef LONG_MAX
# define LONG_MAX ((long int) (ULONG_MAX >> 1))
#endif
#endif #endif
#ifdef USE_WIDE_CHAR #ifdef USE_WIDE_CHAR
@ -128,8 +135,11 @@ extern int errno;
#ifdef __STDC__ #ifdef __STDC__
# define INTERNAL(x) INTERNAL1(x) # define INTERNAL(x) INTERNAL1(x)
# define INTERNAL1(x) __##x##_internal # define INTERNAL1(x) __##x##_internal
# define WEAKNAME(x) WEAKNAME1(x)
# define WEAKNAME1(x) __##x
#else #else
# define INTERNAL(x) __/**/x/**/_internal # define INTERNAL(x) __/**/x/**/_internal
# define WEAKNAME(x) __/**/x
#endif #endif
#ifdef USE_NUMBER_GROUPING #ifdef USE_NUMBER_GROUPING
@ -290,8 +300,10 @@ INTERNAL (strtol) (nptr, endptr, base, group)
#if !UNSIGNED #if !UNSIGNED
/* Check for a value that is within the range of /* Check for a value that is within the range of
`unsigned LONG int', but outside the range of `LONG int'. */ `unsigned LONG int', but outside the range of `LONG int'. */
if (i > (negative ? if (overflow == 0
-(unsigned LONG int) LONG_MIN : (unsigned LONG int) LONG_MAX)) && i > (negative
? -((unsigned LONG int) (LONG_MIN + 1)) + 1
: (unsigned LONG int) LONG_MAX))
overflow = 1; overflow = 1;
#endif #endif
@ -326,8 +338,13 @@ noconv:
/* External user entry point. */ /* External user entry point. */
/* Prototype. */
INT WEAKNAME (strtol) __P ((const STRING_TYPE *nptr, STRING_TYPE **endptr,
int base));
INT INT
strtol (nptr, endptr, base) WEAKNAME (strtol) (nptr, endptr, base)
const STRING_TYPE *nptr; const STRING_TYPE *nptr;
STRING_TYPE **endptr; STRING_TYPE **endptr;
int base; int base;
@ -335,9 +352,9 @@ strtol (nptr, endptr, base)
return INTERNAL (strtol) (nptr, endptr, base, 0); return INTERNAL (strtol) (nptr, endptr, base, 0);
} }
#ifdef weak_symbol #ifdef weak_alias
/* We need this indirection when `strtol' is defined as a macro /* We need this indirection when `strtol' is defined as a macro
for one of the other names. */ for one of the other names. */
#define weak1(x) weak_symbol(x) #define weak1(x, y) weak_alias (x, y)
weak1 (strtol) weak1 (WEAKNAME (strtol), strtol)
#endif #endif

View File

@ -0,0 +1,52 @@
/* The `struct utmp' type, describing entries in the utmp file. Generic/BSDish
Copyright (C) 1993, 1996 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _UTMPBITS_H
#define _UTMPBITS_H 1
#include <features.h>
#include <time.h>
#define _PATH_UTMP "/var/run/utmp"
#define _PATH_WTMP "/var/log/wtmp"
#define _PATH_LASTLOG "/var/log/lastlog"
#define UT_NAMESIZE 8
#define UT_LINESIZE 8
#define UT_HOSTSIZE 16
__BEGIN_DECLS
struct lastlog {
time_t ll_time;
char ll_line[UT_LINESIZE];
char ll_host[UT_HOSTSIZE];
};
struct utmp {
char ut_line[UT_LINESIZE];
char ut_name[UT_NAMESIZE];
char ut_host[UT_HOSTSIZE];
long ut_time;
};
__END_DECLS
#endif /* utmpbits.h */

83
sysdeps/gnu/utmpbits.h Normal file
View File

@ -0,0 +1,83 @@
/* The `struct utmp' type, describing entries in the utmp file. GNU version.
Copyright (C) 1993, 1996 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _UTMPBITS_H
#define _UTMPBITS_H 1
#include <features.h>
#include <sys/time.h>
#include <sys/types.h>
#define _PATH_UTMP "/var/run/utmp"
#define _PATH_WTMP "/var/log/wtmp"
#define _PATH_LASTLOG "/var/log/lastlog"
#define UTMP_FILE _PATH_UTMP
#define WTMP_FILE _PATH_WTMP
#define UTMP_FILENAME UTMP_FILE
#define WTMP_FILENAME WTMP_FILE
#define UT_UNKNOWN 0 /* for ut_type field */
#define RUN_LVL 1
#define BOOT_TIME 2
#define NEW_TIME 3
#define OLD_TIME 4
#define INIT_PROCESS 5
#define LOGIN_PROCESS 6
#define USER_PROCESS 7
#define DEAD_PROCESS 8
#define ut_name ut_user
#define UT_LINESIZE 32
#define UT_NAMESIZE 32
#define UT_HOSTSIZE 256
__BEGIN_DECLS
struct lastlog
{
time_t ll_time;
char ll_line[UT_LINESIZE];
char ll_host[UT_HOSTSIZE];
};
struct utmp
{
short int ut_type; /* Type of login. */
pid_t ut_pid; /* Pid of login process. */
char ut_line[UT_LINESIZE]; /* NUL-terminated devicename of tty. */
char ut_id[4]; /* Inittab id. */
char ut_user[UT_NAMESIZE]; /* Username (not NUL terminated). */
char ut_host[UT_HOSTSIZE]; /* Hostname for remote login. */
int ut_exit; /* Process termination/exit status. */
struct timeval ut_tv; /* Time entry was made. */
long ut_session; /* Session ID, used for windowing. */
int32_t ut_addr; /* Internet address of remote host. */
char pad[32]; /* Reserved for future use. */
};
#define ut_time ut_tv.tv_sec /* Backwards compatibility. */
__END_DECLS
#endif /* !_UTMP_H_ */

View File

@ -1,2 +1,5 @@
# The gnu subdirectory exists for things common to both Linux-based and
# Hurd-based GNU systems.
gnu
# The Hurd provides a rough superset of the functionality of 4.4 BSD. # The Hurd provides a rough superset of the functionality of 4.4 BSD.
unix/bsd/bsd4.4 unix/bsd/bsd4.4

View File

@ -78,6 +78,16 @@ extern int errno;
#define R_OK 4 #define R_OK 4
#endif #endif
#if !defined (S_IROTH) && defined (R_OK)
# define S_IROTH R_OK
#endif
#if !defined (S_IWOTH) && defined (W_OK)
# define S_IWOTH W_OK
#endif
#if !defined (S_IXOTH) && defined (X_OK)
# define S_IXOTH X_OK
#endif
#ifdef _LIBC #ifdef _LIBC

View File

@ -1,3 +1,7 @@
# The gnu subdirectory exists for things common to both Linux-based and
# Hurd-based GNU systems.
gnu
# Linux shares most of the syscalls which are also common to BSD and SVR4. # Linux shares most of the syscalls which are also common to BSD and SVR4.
unix/common unix/common

View File

@ -22,7 +22,7 @@ Boston, MA 02111-1307, USA. */
#include <features.h> #include <features.h>
/* Get constants and data types from kernel header file. */ /* Get constants and data types from kernel header file. */
#include <linux/vm86.h> #include <asm/vm86.h>
__BEGIN_DECLS __BEGIN_DECLS

View File

@ -1,23 +0,0 @@
#ifndef _UTMP_H
#define _UTMP_H 1
#include <time.h>
struct utmp
{
#define ut_name ut_user
char ut_user[8];
char ut_id[4];
char ut_line[12];
short ut_pid;
short ut_type;
struct exit_status
{
short e_termination;
short e_exit;
} ut_exit;
time_t ut_time;
};
#endif /* utmp.h. */

View File

@ -0,0 +1,42 @@
/* The `struct utmp' type, describing entries in the utmp file. System V.
Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#ifndef _UTMPBITS_H
#define _UTMPBITS_H 1
#include <time.h>
struct utmp
{
#define ut_name ut_user
char ut_user[8];
char ut_id[4];
char ut_line[12];
short ut_pid;
short ut_type;
struct exit_status
{
short e_termination;
short e_exit;
} ut_exit;
time_t ut_time;
};
#endif /* utmpbits.h */