From b8fe19fa809ac786b7d3dbb464cb1b3f887dc69d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 22 May 1996 02:11:55 +0000 Subject: Wed May 22 01:48:54 1996 Ulrich Drepper * 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 * misc/sys/syslog.h (__need___va_list): Define this instead of __need_va_list before including . * 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 * 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 * 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 . --- ChangeLog | 82 ++++++ Makefile | 2 +- config.sub | 1 + locale/C-monetary.c | 2 +- login/Makefile | 38 +++ login/endutent.c | 31 ++ login/endutent_r.c | 32 ++ login/getutent.c | 36 +++ login/getutent_r.c | 50 ++++ login/getutid.c | 36 +++ login/getutid_r.c | 61 ++++ login/getutline.c | 36 +++ login/getutline_r.c | 61 ++++ login/login.c | 63 ++++ login/login_tty.c | 75 +++++ login/logout.c | 72 +++++ login/logwtmp.c | 67 +++++ login/pututline.c | 34 +++ login/pututline_r.c | 89 ++++++ login/setutent.c | 31 ++ login/setutent_r.c | 72 +++++ login/utmp.h | 96 ++++++ manual/arith.texi | 22 +- manual/errno.texi | 25 +- manual/libc.texinfo | 102 +++---- misc/Makefile | 8 +- misc/login.c | 63 ---- misc/login_tty.c | 75 ----- misc/logout.c | 72 ----- misc/logwtmp.c | 67 ----- misc/utmp.h | 82 ------ resolv/gethnamaddr.c | 4 +- stdio-common/printf.h | 5 +- stdio-common/printf_fp.c | 56 +++- stdio-common/vfprintf.c | 105 +++++-- stdlib/Makefile | 6 +- stdlib/monetary.h | 36 +++ stdlib/strfmon.c | 504 ++++++++++++++++++++++++++++++++ stdlib/strtol.c | 29 +- sysdeps/generic/utmpbits.h | 52 ++++ sysdeps/gnu/utmpbits.h | 83 ++++++ sysdeps/mach/hurd/Implies | 3 + sysdeps/posix/euidaccess.c | 10 + sysdeps/unix/sysv/linux/Implies | 4 + sysdeps/unix/sysv/linux/i386/sys/vm86.h | 2 +- sysdeps/unix/sysv/utmp.h | 23 -- sysdeps/unix/sysv/utmpbits.h | 42 +++ 47 files changed, 2028 insertions(+), 519 deletions(-) create mode 100644 login/Makefile create mode 100644 login/endutent.c create mode 100644 login/endutent_r.c create mode 100644 login/getutent.c create mode 100644 login/getutent_r.c create mode 100644 login/getutid.c create mode 100644 login/getutid_r.c create mode 100644 login/getutline.c create mode 100644 login/getutline_r.c create mode 100644 login/login.c create mode 100644 login/login_tty.c create mode 100644 login/logout.c create mode 100644 login/logwtmp.c create mode 100644 login/pututline.c create mode 100644 login/pututline_r.c create mode 100644 login/setutent.c create mode 100644 login/setutent_r.c create mode 100644 login/utmp.h delete mode 100644 misc/login.c delete mode 100644 misc/login_tty.c delete mode 100644 misc/logout.c delete mode 100644 misc/logwtmp.c delete mode 100644 misc/utmp.h create mode 100644 stdlib/monetary.h create mode 100644 stdlib/strfmon.c create mode 100644 sysdeps/generic/utmpbits.h create mode 100644 sysdeps/gnu/utmpbits.h delete mode 100644 sysdeps/unix/sysv/utmp.h create mode 100644 sysdeps/unix/sysv/utmpbits.h diff --git a/ChangeLog b/ChangeLog index d3d8abcaa3..47f8446058 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,85 @@ +Wed May 22 01:48:54 1996 Ulrich Drepper + + * 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 + + * misc/sys/syslog.h (__need___va_list): Define this instead of + __need_va_list before including . + + * 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 + + * 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 + + * 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 . + Thu May 16 00:31:44 1996 Roland McGrath * Makerules [versioned]: Make symlinks in the build directory, because diff --git a/Makefile b/Makefile index ef211a6160..ae32c77001 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ endif # These are the subdirectories containing the library source. subdirs = csu assert ctype db locale intl catgets math setjmp signal stdlib \ 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 export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63. diff --git a/config.sub b/config.sub index 9542fb28ef..27a3689f78 100755 --- a/config.sub +++ b/config.sub @@ -307,6 +307,7 @@ case $basic_machine in basic_machine=m68k-hp os=-hpux ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) diff --git a/locale/C-monetary.c b/locale/C-monetary.c index b661a57493..542e5c30d1 100644 --- a/locale/C-monetary.c +++ b/locale/C-monetary.c @@ -27,7 +27,7 @@ const struct locale_data _nl_C_LC_MONETARY = { { string: "" }, { string: "" }, - { string: "" }, + { string: "." }, { string: "" }, { string: "\177" }, { string: "" }, diff --git a/login/Makefile b/login/Makefile new file mode 100644 index 0000000000..d3e6ac8aa5 --- /dev/null +++ b/login/Makefile @@ -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 diff --git a/login/endutent.c b/login/endutent.c new file mode 100644 index 0000000000..9aed00d7a7 --- /dev/null +++ b/login/endutent.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 + + +/* The global data defined in setutent.c. */ +extern struct utmp_data __utmp_data; + + +void +endutent (void) +{ + endutent_r (&__utmp_data); +} diff --git a/login/endutent_r.c b/login/endutent_r.c new file mode 100644 index 0000000000..b15f57a964 --- /dev/null +++ b/login/endutent_r.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 +#include + + +void +endutent_r (struct utmp_data *utmp_data) +{ + if (utmp_data->ut_fd != -1) + { + close (utmp_data->ut_fd); + utmp_data->ut_fd = -1; + } +} diff --git a/login/getutent.c b/login/getutent.c new file mode 100644 index 0000000000..36411469a0 --- /dev/null +++ b/login/getutent.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 + + +/* 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; +} diff --git a/login/getutent_r.c b/login/getutent_r.c new file mode 100644 index 0000000000..ad8e9eb7c2 --- /dev/null +++ b/login/getutent_r.c @@ -0,0 +1,50 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 +#include + + +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; +} diff --git a/login/getutid.c b/login/getutid.c new file mode 100644 index 0000000000..6b29d38fd0 --- /dev/null +++ b/login/getutid.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 + + +/* 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; +} diff --git a/login/getutid_r.c b/login/getutid_r.c new file mode 100644 index 0000000000..351f96e65e --- /dev/null +++ b/login/getutid_r.c @@ -0,0 +1,61 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 +#include +#include + + +/* 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; +} diff --git a/login/getutline.c b/login/getutline.c new file mode 100644 index 0000000000..23ca6a8107 --- /dev/null +++ b/login/getutline.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 + + +/* 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; +} diff --git a/login/getutline_r.c b/login/getutline_r.c new file mode 100644 index 0000000000..62c8c2fd66 --- /dev/null +++ b/login/getutline_r.c @@ -0,0 +1,61 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 +#include +#include + + +/* 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; +} diff --git a/login/login.c b/login/login.c new file mode 100644 index 0000000000..5b71082c52 --- /dev/null +++ b/login/login.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)login.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#include +#include +#include +#include +#include + +void +login(ut) + const struct utmp *ut; +{ + register int fd; + int tty; + + tty = ttyslot(); + if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY|O_CREAT, 0644)) >= 0) { + (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), L_SET); + (void)write(fd, ut, sizeof(struct utmp)); + (void)close(fd); + } + if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) { + (void)write(fd, ut, sizeof(struct utmp)); + (void)close(fd); + } +} diff --git a/login/login_tty.c b/login/login_tty.c new file mode 100644 index 0000000000..e4e075c6ed --- /dev/null +++ b/login/login_tty.c @@ -0,0 +1,75 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include + +int +login_tty(fd) + int fd; +{ + (void) setsid(); +#ifdef TIOCSCTTY + if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1) + return (-1); +#else + { + /* This might work. */ + char *fdname = ttyname (fd); + int newfd; + if (fdname) + { + if (fd != 0) + (void) close (0); + if (fd != 1) + (void) close (1); + if (fd != 2) + (void) close (2); + newfd = open (fdname, O_RDWR); + (void) close (newfd); + } + } +#endif + (void) dup2(fd, 0); + (void) dup2(fd, 1); + (void) dup2(fd, 2); + if (fd > 2) + (void) close(fd); + return (0); +} diff --git a/login/logout.c b/login/logout.c new file mode 100644 index 0000000000..40ae25456f --- /dev/null +++ b/login/logout.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)logout.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +#include +#include +#include +#include +#include + +typedef struct utmp UTMP; + +int +logout(line) + register const char *line; +{ + register int fd; + UTMP ut; + int rval; + + if ((fd = open(_PATH_UTMP, O_RDWR, 0)) < 0) + return(0); + rval = 0; + while (read(fd, &ut, sizeof(UTMP)) == sizeof(UTMP)) { + if (!ut.ut_name[0] || strncmp(ut.ut_line, line, UT_LINESIZE)) + continue; + bzero(ut.ut_name, UT_NAMESIZE); + bzero(ut.ut_host, UT_HOSTSIZE); + (void)time(&ut.ut_time); + (void)lseek(fd, -(off_t)sizeof(UTMP), L_INCR); + (void)write(fd, &ut, sizeof(UTMP)); + rval = 1; + } + (void)close(fd); + return(rval); +} diff --git a/login/logwtmp.c b/login/logwtmp.c new file mode 100644 index 0000000000..7734ca9624 --- /dev/null +++ b/login/logwtmp.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include + +#include +#include + +void +logwtmp(line, name, host) + const char *line, *name, *host; +{ + struct utmp ut; + struct stat buf; + int fd; + + if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0) + return; + if (fstat(fd, &buf) == 0) { + (void) strncpy(ut.ut_line, line, sizeof(ut.ut_line)); + (void) strncpy(ut.ut_name, name, sizeof(ut.ut_name)); + (void) strncpy(ut.ut_host, host, sizeof(ut.ut_host)); + (void) time(&ut.ut_time); + if (write(fd, (char *)&ut, sizeof(struct utmp)) != + sizeof(struct utmp)) + (void) ftruncate(fd, buf.st_size); + } + (void) close(fd); +} diff --git a/login/pututline.c b/login/pututline.c new file mode 100644 index 0000000000..a704e380fa --- /dev/null +++ b/login/pututline.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 + + +/* 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; +} diff --git a/login/pututline_r.c b/login/pututline_r.c new file mode 100644 index 0000000000..365a37672e --- /dev/null +++ b/login/pututline_r.c @@ -0,0 +1,89 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 +#include +#include +#include +#include +#include +#include + + +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; +} diff --git a/login/setutent.c b/login/setutent.c new file mode 100644 index 0000000000..aab28c0015 --- /dev/null +++ b/login/setutent.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 + +/* 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); +} diff --git a/login/setutent_r.c b/login/setutent_r.c new file mode 100644 index 0000000000..715101d659 --- /dev/null +++ b/login/setutent_r.c @@ -0,0 +1,72 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper , 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 +#include +#include +#include +#include + +/* 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; +} diff --git a/login/utmp.h b/login/utmp.h new file mode 100644 index 0000000000..2ba3da8e0b --- /dev/null +++ b/login/utmp.h @@ -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 + +#include + +/* Get system dependent values and data structures. */ +#include + + +/* 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 */ diff --git a/manual/arith.texi b/manual/arith.texi index a5d2814b1d..b3f646a187 100644 --- a/manual/arith.texi +++ b/manual/arith.texi @@ -446,20 +446,20 @@ These functions are declared in @file{stdlib.h}. @deftypefun {long int} strtol (const char *@var{string}, char **@var{tailptr}, int @var{base}) The @code{strtol} (``string-to-long'') function converts the initial part of @var{string} to a signed integer, which is returned as a value -of type @code{long int}. +of type @code{long int}. This function attempts to decompose @var{string} as follows: @itemize @bullet -@item +@item A (possibly empty) sequence of whitespace characters. Which characters are whitespace is determined by the @code{isspace} function (@pxref{Classification of Characters}). These are discarded. -@item +@item An optional plus or minus sign (@samp{+} or @samp{-}). -@item +@item A nonempty sequence of digits in the radix specified by @var{base}. If @var{base} is zero, decimal radix is assumed unless the series of @@ -471,7 +471,7 @@ Otherwise @var{base} must have a value between @code{2} and @code{35}. If @var{base} is @code{16}, the digits may optionally be preceded by @samp{0x} or @samp{0X}. -@item +@item Any remaining characters in the string. If @var{tailptr} is not a null pointer, @code{strtol} stores a pointer to this tail in @code{*@var{tailptr}}. @@ -499,9 +499,11 @@ There is an example at the end of this section. @comment ANSI @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 -@code{strtol} except that it returns its value with type @code{unsigned -long int}. The value returned in case of overflow is @code{ULONG_MAX} -(@pxref{Range of Type}). +@code{strtol} except it deals with unsigned numbers, and returns its +value with type @code{unsigned long int}. No @samp{+} or @samp{-} sign +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 @comment stdlib.h @@ -568,12 +570,12 @@ These functions are declared in @file{stdlib.h}. @deftypefun double strtod (const char *@var{string}, char **@var{tailptr}) The @code{strtod} (``string-to-double'') function converts the initial part of @var{string} to a floating-point number, which is returned as a -value of type @code{double}. +value of type @code{double}. This function attempts to decompose @var{string} as follows: @itemize @bullet -@item +@item A (possibly empty) sequence of whitespace characters. Which characters are whitespace is determined by the @code{isspace} function (@pxref{Classification of Characters}). These are discarded. diff --git a/manual/errno.texi b/manual/errno.texi index 836fff3bf2..a00ac7859d 100644 --- a/manual/errno.texi +++ b/manual/errno.texi @@ -18,7 +18,7 @@ facility. @menu * Checking for Errors:: How errors are reported by library functions. -* Error Codes:: Error code macros; all of these expand +* Error Codes:: Error code macros; all of these expand into integer constant values. * Error Messages:: Mapping error codes onto error messages. @end menu @@ -492,7 +492,7 @@ A file that isn't a socket was specified when a socket is required. @deftypevr Macro int EMSGSIZE @comment errno 40 @c DO NOT REMOVE The size of a message sent on a socket was larger than the supported -maximum size. +maximum size. @end deftypevr @comment errno.h @@ -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. @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 GNU: Inappropriate operation for background process @deftypevr Macro int EBACKGROUND @@ -920,11 +928,11 @@ This function prints an error message to the stream @code{stderr}; see @ref{Standard Streams}. If you call @code{perror} with a @var{message} that is either a null -pointer or an empty string, @code{perror} just prints the error message +pointer or an empty string, @code{perror} just prints the error message corresponding to @code{errno}, adding a trailing newline. If you supply a non-null @var{message} argument, then @code{perror} -prefixes its output with this string. It adds a colon and a space +prefixes its output with this string. It adds a colon and a space character to separate the @var{message} from the error string corresponding to @code{errno}. @@ -952,7 +960,7 @@ variable @code{program_invocation_name}: @comment errno.h @comment GNU -@deftypevar {char *} program_invocation_name +@deftypevar {char *} program_invocation_name This variable's value is the name that was used to invoke the program running in the current process. It is the same as @code{argv[0]}. Note that this is not necessarily a useful file name; often it contains no @@ -961,7 +969,7 @@ directory names. @xref{Program Arguments}. @comment errno.h @comment GNU -@deftypevar {char *} program_invocation_short_name +@deftypevar {char *} program_invocation_short_name This variable's value is the name that was used to invoke the program running in the current process, with directory names removed. (That is to say, it is the same as @code{program_invocation_name} minus @@ -997,10 +1005,10 @@ functions might overwrite @code{errno} in the meantime. FILE * open_sesame (char *name) -@{ +@{ FILE *stream; - errno = 0; + errno = 0; stream = fopen (name, "r"); if (stream == NULL) @{ @@ -1012,4 +1020,3 @@ open_sesame (char *name) return stream; @} @end smallexample - diff --git a/manual/libc.texinfo b/manual/libc.texinfo index 1ba44c2071..7a8c1c3327 100644 --- a/manual/libc.texinfo +++ b/manual/libc.texinfo @@ -10,10 +10,10 @@ @set xref-automatic-section-title @smallbook -@c I've already told people the printed edition will be 0.06 -@set EDITION 0.06 +@c sold 0.06/1.09, print run out 21may96 +@set EDITION 0.07 DRAFT @set VERSION 1.09 Beta -@set UPDATED 23 December 1994 +@set UPDATED 21 May 1996 @set ISBN 1-882114-53-1 @ifinfo @@ -22,7 +22,7 @@ This file documents the GNU C library. This is Edition @value{EDITION}, last updated @value{UPDATED}, 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 this manual provided the copyright notice and this permission notice @@ -66,11 +66,11 @@ Foundation. @center for version @value{VERSION} @page @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 Published by the Free Software Foundation @* -675 Massachusetts Avenue @* -Cambridge, MA 02139 USA @* +59 Temple Place -- Suite 330, @* +Boston, MA 02111-1307 USA @* Printed copies are available for $50 each. @* ISBN @value{ISBN} @* @@ -145,7 +145,7 @@ of the GNU C Library. Appendices -* Language Features:: C language features provided by the library. +* Language Features:: C language features provided by the library. * Library Summary:: A summary showing the syntax, header file, and derivation of each library feature. @@ -173,10 +173,10 @@ Introduction Standards and Portability * ANSI C:: The American National Standard for the - C programming language. + C programming language. * POSIX:: The IEEE 1003 standards for operating systems. * Berkeley Unix:: BSD and SunOS. -* SVID:: The System V Interface Description. +* SVID:: The System V Interface Description. Using the Library @@ -243,9 +243,9 @@ Obstacks complicated) growing objects. * Status of an Obstack:: Inquiries about the status of an obstack. * Obstacks Data Alignment:: Controlling alignment of objects in obstacks. -* Obstack Chunks:: How obstacks obtain and release chunks. +* Obstack Chunks:: How obstacks obtain and release chunks. Efficiency considerations. -* Summary of Obstacks:: +* Summary of Obstacks:: Automatic Storage with Variable Size @@ -291,7 +291,7 @@ Extended Characters and vice versa. * Length of Char:: how many bytes make up one multibyte char. * Converting One Char:: Converting a string character by character. -* Example of Conversion:: Example showing why converting +* Example of Conversion:: Example showing why converting one character at a time may be useful. * Shift State:: Multibyte codes with "shift characters". @@ -305,7 +305,7 @@ Locales and Internationalization * Standard Locales:: Locale names available on all systems. * Numeric Formatting:: How to format numbers for the chosen locale. -Searching and Sorting +Searching and Sorting * Comparison Functions:: Defining how to compare two objects. Since the sort and search facilities are @@ -345,7 +345,7 @@ File Names I/O on Streams * Streams:: About the data type representing a stream. -* Standard Streams:: Streams to the standard input and output +* Standard Streams:: Streams to the standard input and output devices are created for you. * Opening Streams:: How to create a stream to talk to a file. * Closing Streams:: Close a stream when you are finished with it. @@ -388,10 +388,10 @@ Formatted Output Customizing Printf -* Registering New Conversions:: -* Conversion Specifier Options:: -* Defining the Output Handler:: -* Printf Extension Example:: +* Registering New Conversions:: +* Conversion Specifier Options:: +* Defining the Output Handler:: +* Printf Extension Example:: Formatted Input @@ -412,13 +412,13 @@ Stream Buffering Other Kinds of Streams -* String Streams:: -* Custom Streams:: +* String Streams:: +* Custom Streams:: Programming Your Own Custom Streams -* Streams and Cookies:: -* Hook Functions:: +* Streams and Cookies:: +* Hook Functions:: Low-Level I/O @@ -512,7 +512,7 @@ Internet Domain * Services Database:: Ports may have symbolic names. * Byte Order:: Different hosts may use different byte ordering conventions; you need to - canonicalize host address and port number. + canonicalize host address and port number. * Inet Example:: Putting it all together. Host Addresses @@ -588,9 +588,9 @@ Terminal Modes Special Characters -* Editing Characters:: -* Signal Characters:: -* Start/Stop Characters:: +* Editing Characters:: +* Signal Characters:: +* Start/Stop Characters:: Mathematics @@ -689,12 +689,12 @@ Specifying Signal Actions Defining Signal Handlers -* Handler Returns:: -* Termination in Handler:: -* Longjmp in Handler:: -* Signals in Handler:: -* Nonreentrancy:: -* Atomic Data Access:: +* Handler Returns:: +* Termination in Handler:: +* Longjmp in Handler:: +* Signals in Handler:: +* Nonreentrancy:: +* Atomic Data Access:: Generating Signals @@ -726,7 +726,7 @@ Waiting for a Signal BSD Signal Handling * BSD Handler:: BSD Function to Establish a Handler. -* Blocking in BSD:: BSD Functions for Blocking Signals +* Blocking in BSD:: BSD Functions for Blocking Signals Process Startup and Termination @@ -756,12 +756,12 @@ Program Termination * Normal Termination:: If a program calls @code{exit}, a process terminates normally. -* Exit Status:: The @code{exit status} provides information - about why the process terminated. +* Exit Status:: The @code{exit status} provides information + about why the process terminated. * Cleanups on Exit:: A process can run its own cleanup - functions upon normal termination. + functions upon normal termination. * Aborting a Program:: The @code{abort} function causes - abnormal program termination. + abnormal program termination. * Termination Internals:: What happens when a process terminates. @@ -773,7 +773,7 @@ Child Processes * Creating a Process:: How to fork a child process. * Executing a File:: How to make a child execute another program. * Process Completion:: How to tell when a child process has completed. -* Process Completion Status:: How to interpret the status value +* Process Completion Status:: How to interpret the status value returned from a child process. * BSD Wait Functions:: More functions, for backward compatibility. * Process Creation Example:: A complete example program. @@ -814,11 +814,11 @@ Users and Groups its user and/or group IDs. * How Change Persona:: Restrictions on changing user and group IDs. * Reading Persona:: Examining the process's user and group IDs. -* Setting User ID:: -* Setting Groups:: -* Enable/Disable Setuid:: +* Setting User ID:: +* Setting Groups:: +* Enable/Disable Setuid:: * Setuid Program Example:: Setuid Program Example -* Tips for Setuid:: +* Tips for Setuid:: * Who Logged In:: Getting the name of the user who logged in, or of the real user ID of the current process. @@ -831,15 +831,15 @@ Users and Groups User Database -* User Data Structure:: -* Lookup User:: +* User Data Structure:: +* Lookup User:: * Scanning All Users:: Scanning the List of All Users -* Writing a User Entry:: +* Writing a User Entry:: Group Database -* Group Data Structure:: -* Lookup Group:: +* Group Data Structure:: +* Lookup Group:: * Scanning All Groups:: Scanning the List of All Groups System Information @@ -858,17 +858,17 @@ System Configuration Limits * Sysconf:: Getting specific configuration values of general limits and system options. * Minimums:: Minimum values for general limits. - + * Limits for Files:: Size limitations on individual files. These can vary between file systems or even from file to file. * Options for Files:: Optional features that some files may support. * File Minimums:: Minimum values for file limits. * Pathconf:: Getting the limit values for a particular file. - + * Utility Limits:: Capacity limits of POSIX.2 utility programs. * Utility Minimums:: Minimum allowable values of those limits. - + * String Parameters:: Getting the default search path. Library Facilities that are Part of the C Language diff --git a/misc/Makefile b/misc/Makefile index db08014d78..b36e46f09a 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -25,8 +25,8 @@ subdir := misc 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 \ 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 \ - err.h error.h sys/queue.h sysexits.h + sys/mman.h sys/param.h fstab.h mntent.h search.h err.h error.h\ + sys/queue.h sysexits.h routines := brk sbrk sstk ioctl