From 8f2ece695d8822e9ecc63ecd157e90bf17a6fe65 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 2 Aug 1997 21:00:51 +0000 Subject: Update. 1997-08-02 21:27 Ulrich Drepper * inet/Makefile (headers): Rename netinet/inbits.h to bits/in.h. * inet/netinet/in.h: Include bits/in.h instead of netinet/inbits.h. * sysdeps/generic/netinet/inbits.h: Move to... * sysdeps/generic/bits/in.h: ... here. * sysdeps/unix/sysv/linux/bits/inbits.h: Move to ... * sysdeps/unix/sysv/linux/bits/in.h: ... here. * nis/Makefile (headers): Add bits/nislib.h. * nis/rpcsvc/nislib.h: Moved to .... * nis/bits/nislib.h: ... here. * nis/nss_compat/compat-grp.c: Don't include . * nis/nss_compat/compat-pwd.c: Likewise. * nis/nss_compat/compat-spwd.c: Likewise. * nis/nss_nisplus/nisplus-alias.c: Likewise. * nis/nss_nisplus/nisplus-ethers.c: Likewise. * nis/nss_nisplus/nisplus-grp.c: Likewise. * nis/nss_nisplus/nisplus-hosts.c: Likewise. * nis/nss_nisplus/nisplus-netgrp.c: Likewise. * nis/nss_nisplus/nisplus-ntework.c: Likewise. * nis/nss_nisplus/nisplus-proto.c: Likewise. * nis/nss_nisplus/nisplus-publickey.c: Likewise. * nis/nss_nisplus/nisplus-pwd.c: Likewise. * nis/nss_nisplus/nisplus-rpc.c: Likewise. * nis/nss_nisplus/nisplus-service.c: Likewise. * nis/nss_nisplus/nisplus-spwd.c: Likewise. * nis/rpcsvc/nis.x: Include bits/nislib.h, not rpcsvc/nislib.h. * nis/rpcsvc/nis.h: Likewise. * inet/getnameinfo.c (nrl_domainname): Change return type to const char *. (getnameinfo): Change type of local variable c to const char *. * inet/inet_ntoa.c: Rewrite to use __libc_once for initialization. * stdlib/fmtmsg.c: Likewise. * intl/bindtextdom.c: Update from latest gettext. * intl/dcgettext.c: Likewise. * intl/finddomain.c: Likewise. * intl/l10nflist.c: Likewise. * intl/localealias.c: Likewise. * intl/textdomain.c: Likewise. * login/getutid_r.c: Remove parameter to setutent call. * login/getutline_r.c: Likewise. * posix/wordexp.c: Complete rewrite. Not fully implemented yet, though. Patch by Tim Waugh . * stdio-common/printf_fp.c: Remove relative include paths. * stdio-common/printf_fphex.c: Likewise. * sysdeps/generic/crypt.h: Cleanup. Don't define non standard elements unless __USE_GNU. * sysdeps/generic/vlimit.c: Pretty print. * sysdeps/generic/vtimes.c: Likewise. * sysdeps/i386/elf/bsd-_setjmp.S: New file. Empty dummy file. * sysdeps/i386/elf/bsd-setjmp.S: New file. Empty dummy file. * sysdeps/i386/elf/setjmp.S: New file. Define __setjmp and also weak definitions of setjmp and _setjmp. * sysdeps/i386/fpu/bits/mathinline.h: More patches by John Bowman. * sysdeps/stub/if_index.h: Set errno in all functions and add stub warnings. * sysdeps/stub/libc-lock.h: Add __libc_once. 1997-08-02 01:57 Ulrich Drepper * sysdeps/unix/sysv/linux/ptrace.c: Don't set errno in error case since the __syscall_ptrace call already did this. Reported by Philip Gladstone . 1997-07-29 Andreas Jaeger * sysdeps/unix/sysv/linux/sys/fsuid.h: Change include to . 1997-08-01 23:18 Ulrich Drepper * csu/defs.awk: Fix regexp for end and align. Patch by Klaus Espenlaub . * locale/programs/localedef.c (print_escaped): New function. (show_info): Use print_escaped if strings can control unprintable characters. Patch by Jochen Hein . 1997-08-01 18:45 Thorsten Kukuk * nis/nss_nisplus/nisplus-alias.c: Fix NULL pointer problems * nis/nss_nisplus/nisplus-grp.c: Likewise. 1997-07-31 Andreas Schwab * elf/dl-profile.c (_dl_start_profile): Use _dl_sysdep_error instead of fprintf. 1997-07-31 Andreas Schwab * manual/socket.texi (Host Address Functions): Fix arguments of @deftypefun. 1997-07-31 Andreas Schwab * elf/dl-runtime.c: Avoid warning about profile_fixup being unused. * sysdeps/m68k/dl-machine.h: Add support for shared library profiling. 1997-07-31 Andreas Schwab * md5-crypt/Makefile (extra-objs): Add onlymd5-crypt.o for dependencies. 1997-07-31 Andreas Schwab * Make-dist (subdirs): Distribute both aout and elf. 1997-07-31 23:04 Mark Kettenis * login/utmp-private.h: Remove reset argument from backend setutent. * login/getutent_r.c (__setutent): Allways call the setutent function in the daemon backend. (setutent_unknown): Function removed. (getutent_unknown, pututline_unknown): Call __setutent instead of setutent_unknown. * login/utmp_file.c (setutent_file): Removed reset argument. All callers changed. * login/utmp_daemon.c (setutent_daemon): Removed reset argument. All callers changed. Try to open connection even if a previous connection failed, but first check if the sockets exist in the filesystem. * login/utmp_daemon.c (pututline_daemon): Try to open connection before reporting failure. * login/programs/database.c (open_database): Create compatibility file if it does not already exist. Supply mode argument in open calls to guarantee that created files have the proper protection. * login/programs/utmpd.c (main): Remove files created by a previous `bind' before creating sockets. Suggested by a sun . 1997-07-29 Andreas Jaeger * math/libm-test.c: Remove unneeded function check_int_exec. * BUGS: Correct typos. * gmon/gmon.c: Add alias for monstartup, declare _strerror_internal. 1997-07-30 Andreas Jaeger * manual/socket.texi (Host Address Functions): Reformat inet_ntop entry to confirm with expected behaviour of some scripts. * libc.map: Add functions/variables in global namespace, remove wildcards. 1997-07-29 Andreas Jaeger * resolv/libresolv.map: Add variables and routines used by named, nslookup and other bind utils. * libc.map: Likewise. 1997-07-31 00:35 Philip Blundell * sysdeps/unix/sysv/linux/if_index.c: Rewrite to avoid using /proc filesystem. * inet/test_ifindex.c: New file. * inet/Makefile (tests): Add test_ifindex. 1997-08-01 04:25 Ulrich Drepper * nis/nss_nisplus/nisplus-parser.c: Fix another bug in the parser. Patch by Thorsten Kukuk . * manual/errno.texi: Fix typo. Reported by Erik Talvola . (write_hist): Remove dependency on 32 bit int. --- BUGS | 8 +- ChangeLog | 192 +++- Make-dist | 3 + bits/in.h | 84 ++ config.sub | 5 +- csu/defs.awk | 4 +- elf/dl-profile.c | 15 +- elf/dl-runtime.c | 8 + gmon/gmon.c | 3 + inet/Makefile | 4 +- inet/getnameinfo.c | 4 +- inet/inet_ntoa.c | 74 +- inet/netinet/in.h | 6 +- inet/test_ifindex.c | 59 ++ intl/bindtextdom.c | 7 +- intl/dcgettext.c | 3 +- intl/finddomain.c | 5 +- intl/l10nflist.c | 3 + intl/localealias.c | 3 + intl/textdomain.c | 3 + libc.map | 309 +++++- locale/programs/locale.c | 36 +- login/getutent_r.c | 54 +- login/getutid_r.c | 4 +- login/getutline_r.c | 4 +- login/programs/database.c | 5 +- login/programs/utmpd.c | 5 + login/utmp-private.h | 5 +- login/utmp_daemon.c | 35 +- login/utmp_file.c | 51 +- manual/errno.texi | 2 +- manual/socket.texi | 8 +- math/libm-test.c | 29 - md5-crypt/Makefile | 1 + nis/Makefile | 2 +- nis/nislib/nislib.h | 268 +++++ nis/nss_compat/compat-grp.c | 1 - nis/nss_compat/compat-pwd.c | 1 - nis/nss_compat/compat-spwd.c | 1 - nis/nss_nisplus/nisplus-alias.c | 16 +- nis/nss_nisplus/nisplus-ethers.c | 16 +- nis/nss_nisplus/nisplus-grp.c | 16 +- nis/nss_nisplus/nisplus-hosts.c | 29 +- nis/nss_nisplus/nisplus-netgrp.c | 1 - nis/nss_nisplus/nisplus-network.c | 15 +- nis/nss_nisplus/nisplus-parser.c | 19 +- nis/nss_nisplus/nisplus-proto.c | 9 +- nis/nss_nisplus/nisplus-publickey.c | 1 - nis/nss_nisplus/nisplus-pwd.c | 9 +- nis/nss_nisplus/nisplus-rpc.c | 3 +- nis/nss_nisplus/nisplus-service.c | 3 +- nis/nss_nisplus/nisplus-spwd.c | 1 - nis/rpcsvc/nis.h | 2 +- nis/rpcsvc/nis.x | 60 +- nis/rpcsvc/nislib.h | 268 ----- posix/wordexp.c | 1624 +++++++++++++++++++++++++++--- resolv/libresolv.map | 16 +- stdio-common/printf_fp.c | 10 +- stdio-common/printf_fphex.c | 2 +- stdlib/fmtmsg.c | 185 ++-- sysdeps/generic/bits/in.h | 84 ++ sysdeps/generic/crypt.h | 30 +- sysdeps/generic/netinet/inbits.h | 84 -- sysdeps/generic/vlimit.c | 2 +- sysdeps/generic/vtimes.c | 8 +- sysdeps/gnu/errlist.c | 2 +- sysdeps/i386/elf/bsd-_setjmp.S | 1 + sysdeps/i386/elf/bsd-setjmp.S | 1 + sysdeps/i386/elf/setjmp.S | 72 ++ sysdeps/i386/fpu/bits/mathinline.h | 71 +- sysdeps/m68k/dl-machine.h | 47 +- sysdeps/sparc/dl-machine.h | 4 +- sysdeps/stub/bits/libc-lock.h | 14 + sysdeps/stub/if_index.c | 8 + sysdeps/unix/sysv/linux/bits/in.h | 75 ++ sysdeps/unix/sysv/linux/if_index.c | 217 ++-- sysdeps/unix/sysv/linux/netinet/inbits.h | 75 -- sysdeps/unix/sysv/linux/ptrace.c | 1 - sysdeps/unix/sysv/linux/sys/fsuid.h | 2 +- 79 files changed, 3332 insertions(+), 1085 deletions(-) create mode 100644 bits/in.h create mode 100644 inet/test_ifindex.c create mode 100644 nis/nislib/nislib.h delete mode 100644 nis/rpcsvc/nislib.h create mode 100644 sysdeps/generic/bits/in.h delete mode 100644 sysdeps/generic/netinet/inbits.h create mode 100644 sysdeps/i386/elf/bsd-_setjmp.S create mode 100644 sysdeps/i386/elf/bsd-setjmp.S create mode 100644 sysdeps/i386/elf/setjmp.S create mode 100644 sysdeps/unix/sysv/linux/bits/in.h delete mode 100644 sysdeps/unix/sysv/linux/netinet/inbits.h diff --git a/BUGS b/BUGS index 611f614aa2..a9f2c2cc5b 100644 --- a/BUGS +++ b/BUGS @@ -1,20 +1,20 @@ List of known bugs (certainly very incomplete) ---------------------------------------------- -Time-stamp: <1997-05-21T21:25:40+0200 drepper> +Time-stamp: <1997-08-01T05:37:51+0200 drepper> This following list contains those bugs which I'm aware of. Please make sure that bugs you report are not listed here. If you can fix one of these bugs/limitations I'll certainly be glad to receive a patch. Another source of information about bugs is the problem data base of the -GNU project. There is an easy to use WWW interface is available at +GNU project. There is an easy to use WWW interface available at http://www-gnats.gnu.ai.mit.edu:8080/cgi-bin/wwwgnats.pl I would appreciate it very much if you could verify the problem was not -reported before by looking though the database. To make the information -in this data as useful as possible please report bugs always using the +reported before by looking through the database. To make the information +in this database as useful as possible please report bugs always using the `glibcbug' shell script which gets installed with GNU libc. diff --git a/ChangeLog b/ChangeLog index b57649c6d2..a72ab06702 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,193 @@ +1997-08-02 21:27 Ulrich Drepper + + * inet/Makefile (headers): Rename netinet/inbits.h to bits/in.h. + * inet/netinet/in.h: Include bits/in.h instead of netinet/inbits.h. + * sysdeps/generic/netinet/inbits.h: Move to... + * sysdeps/generic/bits/in.h: ... here. + * sysdeps/unix/sysv/linux/bits/inbits.h: Move to ... + * sysdeps/unix/sysv/linux/bits/in.h: ... here. + + * nis/Makefile (headers): Add bits/nislib.h. + * nis/rpcsvc/nislib.h: Moved to .... + * nis/bits/nislib.h: ... here. + + * nis/nss_compat/compat-grp.c: Don't include . + * nis/nss_compat/compat-pwd.c: Likewise. + * nis/nss_compat/compat-spwd.c: Likewise. + * nis/nss_nisplus/nisplus-alias.c: Likewise. + * nis/nss_nisplus/nisplus-ethers.c: Likewise. + * nis/nss_nisplus/nisplus-grp.c: Likewise. + * nis/nss_nisplus/nisplus-hosts.c: Likewise. + * nis/nss_nisplus/nisplus-netgrp.c: Likewise. + * nis/nss_nisplus/nisplus-ntework.c: Likewise. + * nis/nss_nisplus/nisplus-proto.c: Likewise. + * nis/nss_nisplus/nisplus-publickey.c: Likewise. + * nis/nss_nisplus/nisplus-pwd.c: Likewise. + * nis/nss_nisplus/nisplus-rpc.c: Likewise. + * nis/nss_nisplus/nisplus-service.c: Likewise. + * nis/nss_nisplus/nisplus-spwd.c: Likewise. + + * nis/rpcsvc/nis.x: Include bits/nislib.h, not rpcsvc/nislib.h. + * nis/rpcsvc/nis.h: Likewise. + + * inet/getnameinfo.c (nrl_domainname): Change return type to const + char *. + (getnameinfo): Change type of local variable c to const char *. + + * inet/inet_ntoa.c: Rewrite to use __libc_once for initialization. + * stdlib/fmtmsg.c: Likewise. + + * intl/bindtextdom.c: Update from latest gettext. + * intl/dcgettext.c: Likewise. + * intl/finddomain.c: Likewise. + * intl/l10nflist.c: Likewise. + * intl/localealias.c: Likewise. + * intl/textdomain.c: Likewise. + + * login/getutid_r.c: Remove parameter to setutent call. + * login/getutline_r.c: Likewise. + + * posix/wordexp.c: Complete rewrite. Not fully implemented yet, + though. Patch by Tim Waugh . + + * stdio-common/printf_fp.c: Remove relative include paths. + * stdio-common/printf_fphex.c: Likewise. + + * sysdeps/generic/crypt.h: Cleanup. Don't define non standard + elements unless __USE_GNU. + + * sysdeps/generic/vlimit.c: Pretty print. + * sysdeps/generic/vtimes.c: Likewise. + + * sysdeps/i386/elf/bsd-_setjmp.S: New file. Empty dummy file. + * sysdeps/i386/elf/bsd-setjmp.S: New file. Empty dummy file. + * sysdeps/i386/elf/setjmp.S: New file. Define __setjmp and also + weak definitions of setjmp and _setjmp. + + * sysdeps/i386/fpu/bits/mathinline.h: More patches by John Bowman. + + * sysdeps/stub/if_index.h: Set errno in all functions and add + stub warnings. + + * sysdeps/stub/libc-lock.h: Add __libc_once. + +1997-08-02 01:57 Ulrich Drepper + + * sysdeps/unix/sysv/linux/ptrace.c: Don't set errno in error + case since the __syscall_ptrace call already did this. + Reported by Philip Gladstone . + +1997-07-29 Andreas Jaeger + + * sysdeps/unix/sysv/linux/sys/fsuid.h: Change include + to . + +1997-08-01 23:18 Ulrich Drepper + + * csu/defs.awk: Fix regexp for end and align. + Patch by Klaus Espenlaub . + + * locale/programs/localedef.c (print_escaped): New function. + (show_info): Use print_escaped if strings can control unprintable + characters. + Patch by Jochen Hein . + +1997-08-01 18:45 Thorsten Kukuk + + * nis/nss_nisplus/nisplus-alias.c: Fix NULL pointer problems + * nis/nss_nisplus/nisplus-grp.c: Likewise. + +1997-07-31 Andreas Schwab + + * elf/dl-profile.c (_dl_start_profile): Use _dl_sysdep_error + instead of fprintf. + +1997-07-31 Andreas Schwab + + * manual/socket.texi (Host Address Functions): Fix arguments of + @deftypefun. + +1997-07-31 Andreas Schwab + + * elf/dl-runtime.c: Avoid warning about profile_fixup being + unused. + + * sysdeps/m68k/dl-machine.h: Add support for shared library + profiling. + +1997-07-31 Andreas Schwab + + * md5-crypt/Makefile (extra-objs): Add onlymd5-crypt.o for + dependencies. + +1997-07-31 Andreas Schwab + + * Make-dist (subdirs): Distribute both aout and elf. + +1997-07-31 23:04 Mark Kettenis + + * login/utmp-private.h: Remove reset argument from backend + setutent. + * login/getutent_r.c (__setutent): Allways call the setutent + function in the daemon backend. + (setutent_unknown): Function removed. + (getutent_unknown, pututline_unknown): Call __setutent instead of + setutent_unknown. + * login/utmp_file.c (setutent_file): Removed reset argument. All + callers changed. + * login/utmp_daemon.c (setutent_daemon): Removed reset + argument. All callers changed. Try to open connection even if a + previous connection failed, but first check if the sockets exist + in the filesystem. + + * login/utmp_daemon.c (pututline_daemon): Try to open connection + before reporting failure. + + * login/programs/database.c (open_database): Create compatibility + file if it does not already exist. Supply mode argument in open + calls to guarantee that created files have the proper protection. + + * login/programs/utmpd.c (main): Remove files created by a + previous `bind' before creating sockets. + Suggested by a sun . + +1997-07-29 Andreas Jaeger + + * math/libm-test.c: Remove unneeded function check_int_exec. + + * BUGS: Correct typos. + + * gmon/gmon.c: Add alias for monstartup, declare _strerror_internal. + +1997-07-30 Andreas Jaeger + + * manual/socket.texi (Host Address Functions): Reformat inet_ntop + entry to confirm with expected behaviour of some scripts. + + * libc.map: Add functions/variables in global namespace, + remove wildcards. + +1997-07-29 Andreas Jaeger + + * resolv/libresolv.map: Add variables and routines used by named, + nslookup and other bind utils. + * libc.map: Likewise. + +1997-07-31 00:35 Philip Blundell + + * sysdeps/unix/sysv/linux/if_index.c: Rewrite to avoid using /proc + filesystem. + * inet/test_ifindex.c: New file. + * inet/Makefile (tests): Add test_ifindex. + +1997-08-01 04:25 Ulrich Drepper + + * nis/nss_nisplus/nisplus-parser.c: Fix another bug in the parser. + Patch by Thorsten Kukuk . + + * manual/errno.texi: Fix typo. + Reported by Erik Talvola . + 1997-07-28 23:35 Ulrich Drepper * csu/gmon-start.c (__gmon_start__): Call __monstartup not @@ -9,7 +199,7 @@ * gmon/bb_exit_func.c (__bb_exit_func): Use memcpy instead of bcopy. * gmon/gmon.c (__monstartup): Likewise. - (write_hist): Remove dependency on 32 int. + (write_hist): Remove dependency on 32 bit int. (_mcleanup): Don't call perror, use fprintf. * elf/dl-load.c: Fix handling of current directory in search path. diff --git a/Make-dist b/Make-dist index 9d16242be5..02f7fe4302 100644 --- a/Make-dist +++ b/Make-dist @@ -47,6 +47,9 @@ subdirs := $(filter-out $(add-ons),$(subdirs)) # Make sure both stdio and libio get in, whichever is in use. subdirs += stdio libio +# Make sure both aout and elf get in, whichever is in use. +subdirs += aout elf + sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs))) ifdef sysdep-Subdir-files subdirs := $(sort $(subdirs) \ diff --git a/bits/in.h b/bits/in.h new file mode 100644 index 0000000000..7241bd24c3 --- /dev/null +++ b/bits/in.h @@ -0,0 +1,84 @@ +/* Copyright (C) 1997 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. */ + +/* Generic version. */ + +#ifndef _NETINET_INBITS_H +#define _NETINET_INBITS_H 1 + +/* Link numbers. */ +#define IMPLINK_IP 155 +#define IMPLINK_LOWEXPER 156 +#define IMPLINK_HIGHEXPER 158 + + +/* Options for use with `getsockopt' and `setsockopt' at the IP level. + The first word in the comment at the right is the data type used; + "bool" means a boolean value stored in an `int'. */ +#define IP_OPTIONS 1 /* ip_opts; IP per-packet options. */ +#define IP_HDRINCL 2 /* int; Header is included with data. */ +#define IP_TOS 3 /* int; IP type of service and precedence. */ +#define IP_TTL 4 /* int; IP time to live. */ +#define IP_RECVOPTS 5 /* bool; Receive all IP options w/datagram. */ +#define IP_RECVRETOPTS 6 /* bool; Receive IP options for response. */ +#define IP_RECVDSTADDR 7 /* bool; Receive IP dst addr w/datagram. */ +#define IP_RETOPTS 8 /* ip_opts; Set/get IP per-packet options. */ +#define IP_MULTICAST_IF 9 /* in_addr; set/get IP multicast i/f */ +#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ +#define IP_MULTICAST_LOOP 11 /* i_char; set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ +#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ + +/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS. + The `ip_dst' field is used for the first-hop gateway when using a + source route (this gets put into the header proper). */ +struct ip_opts + { + struct in_addr ip_dst; /* First hop; zero without source route. */ + char ip_opts[40]; /* Actually variable in size. */ + }; + +/* Structure used for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. */ +struct ip_mreq +{ + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* IPV6 socket options. */ +#define IPV6_ADDRFORM 1 +#define IPV6_RXINFO 2 +#define IPV6_RXHOPOPTS 3 +#define IPV6_RXDSTOPTS 4 +#define IPV6_RXSRCRT 5 +#define IPV6_PKTOPTIONS 6 +#define IPV6_CHECKSUM 7 +#define IPV6_HOPLIMIT 8 + +#define IPV6_TXINFO IPV6_RXINFO +#define SCM_SRCINFO IPV6_TXINFO +#define SCM_SRCRT IPV6_RXSRCRT + +#define IPV6_UNICAST_HOPS 16 +#define IPV6_MULTICAST_IF 17 +#define IPV6_MULTICAST_HOPS 18 +#define IPV6_MULTICAST_LOOP 19 +#define IPV6_ADD_MEMBERSHIP 20 +#define IPV6_DROP_MEMBERSHIP 21 + +#endif /* netinet/inbits.h */ diff --git a/config.sub b/config.sub index e3105a7fe5..eb4fca1a84 100755 --- a/config.sub +++ b/config.sub @@ -682,9 +682,12 @@ case $os in -solaris) os=-solaris2 ;; - -unixware* | svr4*) + -svr4*) os=-sysv4 ;; + -unixware*) + os=-sysv4.2uw + ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; diff --git a/csu/defs.awk b/csu/defs.awk index 96f0a1d3cc..ac73e1a3ad 100644 --- a/csu/defs.awk +++ b/csu/defs.awk @@ -1,5 +1,5 @@ -/.end/ { need_end = 1 } -/.align/ { if($2 > max) max = $2; } +/\.end/ { need_end = 1 } +/\.align/ { if($2 > max) max = $2; } END { if(need_end) diff --git a/elf/dl-profile.c b/elf/dl-profile.c index cc25b6105f..805624909b 100644 --- a/elf/dl-profile.c +++ b/elf/dl-profile.c @@ -179,8 +179,9 @@ _dl_start_profile (struct link_map *map, const char *output_dir) cannot_create: errnum = errno; __close (fd); - fprintf (stderr, "%s: cannot create file: %s\n", filename, - _strerror_internal (errnum, buf, sizeof buf)); + _dl_sysdep_error (filename, ": cannot create file: ", + _strerror_internal (errnum, buf, sizeof buf), + "\n", NULL); return; } @@ -192,8 +193,9 @@ _dl_start_profile (struct link_map *map, const char *output_dir) { __close (fd); wrong_format: - fprintf (stderr, "%s: file is no correct profile data file for `%s'\n", - filename, _dl_profile); + _dl_sysdep_error (filename, + ": file is no correct profile data file for `", + _dl_profile, "'\n", NULL); return; } @@ -204,8 +206,9 @@ _dl_start_profile (struct link_map *map, const char *output_dir) char buf[400]; int errnum = errno; __close (fd); - fprintf (stderr, "%s: cannot map file: %s\n", filename, - _strerror_internal (errnum, buf, sizeof buf)); + _dl_sysdep_error (filename, ": cannot map file: ", + _strerror_internal (errnum, buf, sizeof buf), + "\n", NULL); return; } diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c index 1b34026d38..8ee1838df9 100644 --- a/elf/dl-runtime.c +++ b/elf/dl-runtime.c @@ -163,6 +163,14 @@ fixup ( #ifndef PROF +static ElfW(Addr) +profile_fixup ( +#ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS + ELF_MACHINE_RUNTIME_FIXUP_ARGS, +#endif + struct link_map *l, ElfW(Word) reloc_offset, ElfW(Addr) retaddr) + __attribute__ ((unused)); + static ElfW(Addr) profile_fixup ( #ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS diff --git a/gmon/gmon.c b/gmon/gmon.c index 6b7ef81d93..72b36f99c3 100644 --- a/gmon/gmon.c +++ b/gmon/gmon.c @@ -46,6 +46,8 @@ #include #include +extern char *_strerror_internal __P ((int, char *buf, size_t)); + extern int __profile_frequency __P ((void)); struct __bb *__bb_head; /* Head of basic-block list or NULL. */ @@ -162,6 +164,7 @@ __monstartup (lowpc, highpc) __moncontrol(1); } +weak_alias(__monstartup, monstartup) static void diff --git a/inet/Makefile b/inet/Makefile index 0237d0b45d..9a70c316b5 100644 --- a/inet/Makefile +++ b/inet/Makefile @@ -23,7 +23,7 @@ subdir := inet headers := netinet/ether.h netinet/in.h netinet/if_ether.h \ netinet/tcp.h netinet/ip.h $(wildcard arpa/*.h protocols/*.h) \ - aliases.h netinet/ip6.h netinet/icmp6.h netinet/inbits.h + aliases.h netinet/ip6.h netinet/icmp6.h bits/in.h distribute := netgroup.h @@ -46,7 +46,7 @@ routines := htonl htons \ getaliasent_r getaliasent getaliasname getaliasname_r \ in6_addr getnameinfo if_index -tests := htontest +tests := htontest test_ifindex # No warnings about losing BSD code. CFLAGS-rcmd.c = -w diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c index 037578f277..e6f4cbfc94 100644 --- a/inet/getnameinfo.c +++ b/inet/getnameinfo.c @@ -77,7 +77,7 @@ struct hostent *_addr2hostname_hosts (const char *, int, int); #endif /* min */ -static char * +static const char * nrl_domainname (void) { static const char *domain = NULL; @@ -267,7 +267,7 @@ getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host, { if (flags & NI_NOFQDN) { - char *c; + const char *c; if ((c = nrl_domainname ()) && (c = strstr(h->h_name, c)) && (c != h->h_name) && (*(--c) == '.')) { diff --git a/inet/inet_ntoa.c b/inet/inet_ntoa.c index 9e4b2af5b9..5dfec626a0 100644 --- a/inet/inet_ntoa.c +++ b/inet/inet_ntoa.c @@ -26,60 +26,45 @@ /* The interface of this function is completely stupid, it requires a static buffer. We relax this a bit in that we allow at least one buffer for each thread. */ -__libc_lock_define_initialized (static, lock); /* This is the key for the thread specific memory. */ static __libc_key_t key; +/* If nonzero the key allocation failed and we should better use a + static buffer than fail. */ +static char local_buf[18]; +static char *static_buf; + /* Destructor for the thread-specific data. */ +static void init (void); static void free_key_mem (void *mem); char * inet_ntoa (struct in_addr in) { - static char static_buf[18]; - static int initialized = 0; - char *buffer = NULL; + __libc_once_define (once); + char *buffer; unsigned char *bytes; /* If we have not yet initialized the buffer do it now. */ - if (!initialized) - { - /* Make sure there is only one process doing the initialization. */ - __libc_lock_lock (lock); - - if (!initialized) - { - if (__libc_key_create (&key, free_key_mem)) - /* Creating the key failed. This either means we run - have only a single-threaded application or something - really went wrong. In any case use a static buffer - which is better than nothing. */ - buffer = static_buf; - else - /* We have a key. */ - initialized = 1; - } - - __libc_lock_unlock (lock); - } + __libc_once (once, init); + if (static_buf != NULL) + return static_buf; + + /* We don't use the static buffer and so we have a key. Use it to + get the thread-specific buffer. */ + buffer = __libc_getspecific (key); if (buffer == NULL) { - /* We don't use the static buffer and so we have a key. Use it - to get the thread-specific buffer. */ - buffer = __libc_getspecific (key); + /* No buffer allocated so far. */ + buffer = malloc (18); if (buffer == NULL) - { - /* No buffer allocated so far. */ - buffer = malloc (18); - if (buffer == NULL) - /* No more memory available. We use the static buffer. */ - buffer = static_buf; - else - __libc_setspecific (key, buffer); - } + /* No more memory available. We use the static buffer. */ + buffer = local_buf; + else + __libc_setspecific (key, buffer); } bytes = (unsigned char *) ∈ @@ -89,12 +74,21 @@ inet_ntoa (struct in_addr in) } +/* Initialize buffer. */ +static void +init (void) +{ + if (__libc_key_create (&key, free_key_mem)) + /* Creating the key failed. This means something really went + wrong. In any case use a static buffer which is better than + nothing. */ + static_buf = local_buf; +} + + +/* free the thread specific data, this is done if a thread terminates. */ static void free_key_mem (void *mem) { free (mem); - - /* And we must set the data to NULL so that the destructor is not - called again. */ - __libc_setspecific (key, NULL); } diff --git a/inet/netinet/in.h b/inet/netinet/in.h index 9eda281360..faaf7e8a63 100644 --- a/inet/netinet/in.h +++ b/inet/netinet/in.h @@ -140,7 +140,7 @@ struct in_addr #define IN_LOOPBACKNET 127 /* Address to loopback in software to local host. */ #ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK ((unsigned) 0x7f000001) /* Inet address 127.0.0.1. */ +# define INADDR_LOOPBACK ((unsigned) 0x7f000001) /* Inet 127.0.0.1. */ #endif @@ -208,7 +208,7 @@ struct ipv6_mreq }; /* Get system-specific definitions. */ -#include +#include /* Functions to convert between host and network byte order. @@ -272,7 +272,7 @@ extern uint16_t htons __P ((uint16_t __hostshort)); (((uint32_t *) (a))[1] == ((uint32_t *) (b))[2]) && \ (((uint32_t *) (a))[2] == ((uint32_t *) (b))[1]) && \ (((uint32_t *) (a))[3] == ((uint32_t *) (b))[3])) - + /* Bind socket to a privileged IP port. */ extern int bindresvport __P ((int __sockfd, struct sockaddr_in *__sin)); diff --git a/inet/test_ifindex.c b/inet/test_ifindex.c new file mode 100644 index 0000000000..f0a34cf0da --- /dev/null +++ b/inet/test_ifindex.c @@ -0,0 +1,59 @@ +/* Test interface name <-> index conversions. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Philip Blundell . + + 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 + +int +main (void) +{ + int failures = 0; + struct if_nameindex *idx = if_nameindex (), *p; + if (idx == NULL) + { + if (errno != ENOSYS) + { + printf ("Couldn't get any interfaces.\n"); + exit (1); + } + /* The function is simply not implemented. */ + exit (0); + } + + printf ("Idx Name | Idx Name\n"); + + for (p = idx; p->if_index || p->if_name; ++p) + { + char buf[IFNAMSIZ]; + int ni, result; + printf ("%3d %15s | ", p->if_index, p->if_name); + printf ("%3d", ni = if_nametoindex (p->if_name)); + printf ("%15s", if_indextoname (p->if_index, buf)); + result = (ni != p->if_index || (strcmp (buf, p->if_name))); + printf ("%10s", result ? "fail" : "okay"); + printf ("\n"); + failures += result; + } + if_freenameindex (idx); + exit (failures ? 1 : 0); +} diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c index 79195b3780..b8f22b6c5d 100644 --- a/intl/bindtextdom.c +++ b/intl/bindtextdom.c @@ -1,5 +1,5 @@ -/* bindtextdom.c -- implementation of the bindtextdomain(3) function - Copyright (C) 1995, 1997 Free Software Foundation, Inc. +/* Implementation of the bindtextdomain(3) function + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. @@ -37,6 +37,9 @@ void free (); # include #else # include +# ifndef memcpy +# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) +# endif #endif #ifdef _LIBC diff --git a/intl/dcgettext.c b/intl/dcgettext.c index 948d0a730c..152acef9a1 100644 --- a/intl/dcgettext.c +++ b/intl/dcgettext.c @@ -545,7 +545,8 @@ category_to_name (category) } /* Guess value of current locale from value of the environment variables. */ -static const char *guess_category_value (category, categoryname) +static const char * +guess_category_value (category, categoryname) int category; const char *categoryname; { diff --git a/intl/finddomain.c b/intl/finddomain.c index 9b531c4f66..27163a6f66 100644 --- a/intl/finddomain.c +++ b/intl/finddomain.c @@ -1,4 +1,4 @@ -/* finddomain.c -- handle list of needed message catalogs +/* Handle list of needed message catalogs Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. Written by Ulrich Drepper , 1995. @@ -43,6 +43,9 @@ void free (); # include #else # include +# ifndef memcpy +# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) +# endif #endif #if !HAVE_STRCHR && !defined _LIBC # ifndef strchr diff --git a/intl/l10nflist.c b/intl/l10nflist.c index 4f45d3db4e..bda2105ac7 100644 --- a/intl/l10nflist.c +++ b/intl/l10nflist.c @@ -31,6 +31,9 @@ # include #else # include +# ifndef memcpy +# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) +# endif #endif #if !HAVE_STRCHR && !defined _LIBC # ifndef strchr diff --git a/intl/localealias.c b/intl/localealias.c index 420a255601..4547873414 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -62,6 +62,9 @@ void free (); # include #else # include +# ifndef memcpy +# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) +# endif #endif #if !HAVE_STRCHR && !defined _LIBC # ifndef strchr diff --git a/intl/textdomain.c b/intl/textdomain.c index 4775e366b0..bad9d166c0 100644 --- a/intl/textdomain.c +++ b/intl/textdomain.c @@ -31,6 +31,9 @@ # include #else # include +# ifndef memcpy +# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) +# endif #endif #ifdef _LIBC diff --git a/libc.map b/libc.map index c9949448b8..587c71e59a 100644 --- a/libc.map +++ b/libc.map @@ -83,10 +83,313 @@ GLIBC_2.0 { _IO_str_seekoff; _IO_str_pbackfail; _IO_list_all; _IO_file_jumps; _IO_peekc_locked; _rpc_dtablesize; _null_auth; _seterr_reply; + __res_randomid; - # all functions and variables in the normal name space - a*; b*; c*; d*; e*; f*; g*; h*; i*; j*; k*; l*; m*; - n*; o*; p*; q*; r*; s*; t*; u*; v*; w*; x*; y*; z*; + # variables in normal name space + argp_err_exit_status; argp_program_bug_address; argp_program_version; + argp_program_version_hook; + daylight; + environ; + errno; error_message_count; error_one_per_line; error_print_progname; + getdate_err; + h_errlist; h_errno; h_nerr; + in6addr_any; in6addr_loopback; + loc1; loc2; locs; + mallwatch; + obstack_alloc_failed_handler; obstack_exit_failure; + optarg; opterr; optind; optopt; + program_invocation_name; program_invocation_short_name; + re_max_failures; re_syntax_options; rexecoptions; rpc_createerr; + stderr; stdin; stdout; svc_fdset; svcauthdes_stats; + sys_errlist; sys_nerr; sys_sigabbrev; sys_siglist; + timezone; tzname; + + # functions in normal name space + # Please keep them sorted by name! + + # a* + a64l; abort; abs; accept; access; acct; addmntent; addseverity; + adjtime; adjtimex; advance; alarm; alphasort; + + argp_error; argp_failure; argp_fmtstream_free; argp_fmtstream_point; + argp_fmtstream_printf; argp_fmtstream_putc; argp_fmtstream_puts; + argp_fmtstream_set_lmargin; argp_fmtstream_set_rmargin; + argp_fmtstream_set_wmargin; argp_fmtstream_write; argp_help; + argp_make_fmtstream; argp_parse; argp_state_help; argp_usage; + + argz_add; argz_add_sep; argz_append; argz_count; argz_create; + argz_create_sep; argz_delete; argz_extract; argz_insert; argz_next; + argz_replace; argz_stringify; + + asctime; asctime_r; asprintf; atexit; atof; atoi; atol; atoll; + authdes_create; authdes_getucred; authdes_pk_create; authnone_create; + authunix_create; authunix_create_default; + + # b* + basename; bcmp; bcopy; bdflush; bind; bindresvport; + bindtextdomain; brk; bsd_signal; bsearch; btowc; bzero; + + # c* + cachectl; cacheflush; calloc; callrpc; canonicalize_file_name; + catclose; catgets; catopen; + cbc_crypt; cfgetispeed; cfgetospeed; cfmakeraw; cfree; + cfsetispeed; cfsetospeed; cfsetspeed; chdir; chflags; chmod; chown; + chroot; clearenv; clearerr; clearerr_unlocked; + + clnt_broadcast; clnt_create; clnt_pcreateerror; clnt_perrno; + clnt_perror; clnt_spcreateerror; clnt_sperrno; clnt_sperror; + clntraw_create; clnttcp_create; clntudp_bufcreate; clntudp_create; + + clock; clone; close; closedir; closelog; confstr; connect; copysign; + copysignf; copysignl; creat; create_module; ctermid; ctime; ctime_r; + cuserid; + + # d* + daemon; dcgettext; delete_module; des_setparity; dgettext; + difftime; dirfd; dirname; div; dprintf; drand48; drand48_r; dup; dup2; + dysize; + + # e* + ecb_crypt; ecvt; ecvt_r; endaliasent; endfsent; endgrent; endhostent; + endmntent; endnetent; endnetgrent; endprotoent; endpwent; endrpcent; + endservent; endspent; endttyent; endusershell; endutent; endutxent; + envz_add; envz_entry; envz_get; envz_merge; envz_remove; + envz_strip; erand48; erand48_r; err; error; error_at_line; errx; + + ether_aton; ether_aton_r; ether_hostton; ether_line; ether_ntoa; + ether_ntoa_r; ether_ntohost; + + euidaccess; execl; execle; execlp; execv; execve; execvp; exit; + + # f* + fchdir; fchflags; fchmod; fchown; fclose; fcloseall; fcntl; fcvt; + fcvt_r; fdatasync; fdopen; feof; feof_unlocked; ferror; + ferror_unlocked; fexecve; fflush; fflush_unlocked; ffs; fgetc; + fgetgrent; fgetgrent_r; fgetpos; fgetpwent; fgetpwent_r; fgets; + fgetspent; fgetspent_r; fileno; fileno_unlocked; finite; finitef; + finitel; flock; flockfile; fmtmsg; fnmatch; fopen; fopencookie; fork; + fpathconf; fprintf; fputc; fputc_unlocked; fputs; fread; free; + freeaddrinfo; freopen; frexp; frexpf; frexpl; fscanf; fseek; fsetpos; + fstatfs; fsync; ftell; ftime; ftok; ftruncate; ftrylockfile; + fts_children; fts_close; fts_open; fts_read; fts_set; ftw; + funlockfile; fwrite; + + # g* + gai_strerror; gcvt; get_avphys_pages; get_current_dir_name; + get_kernel_syms; get_myaddress; get_nprocs; get_nprocs_conf; + get_phys_pages; getaddrinfo; getaliasbyname; getaliasbyname_r; + getaliasent; getaliasent_r; getc; getc_unlocked; getchar; + getchar_unlocked; getcwd; getdate; getdate_r; getdelim; getdirentries; + getdomainname; getdtablesize; getegid; getenv; geteuid; getfsent; + getfsfile; getfsspec; getgid; getgrent; getgrent_r; getgrgid; + getgrgid_r; getgrnam; getgrnam_r; getgroups; gethostbyaddr; + gethostbyaddr_r; gethostbyname; gethostbyname2; gethostbyname2_r; + gethostbyname_r; gethostent; gethostent_r; gethostid; gethostname; + getitimer; getline; getlogin; getlogin_r; getmntent; getmntent_r; + getnameinfo; getnetbyaddr; getnetbyaddr_r; getnetbyname; + getnetbyname_r; getnetent; getnetent_r; getnetgrent; getnetgrent_r; + getnetname; getopt; getopt_long; getopt_long_only; getpagesize; + getpass; getpeername; getpgid; getpgrp; getpid; getppid; getpriority; + getprotobyname; getprotobyname_r; getprotobynumber; + getprotobynumber_r; getprotoent; getprotoent_r; getpublickey; getpw; + getpwent; getpwent_r; getpwnam; getpwnam_r; getpwuid; getpwuid_r; + getrlimit; getrpcbyname; getrpcbyname_r; getrpcbynumber; + getrpcbynumber_r; getrpcent; getrpcent_r; getrpcport; getrusage; gets; + getsecretkey; getservbyname; getservbyname_r; getservbyport; + getservbyport_r; getservent; getservent_r; getsid; getsockname; + getsockopt; getspent; getspent_r; getspnam; getspnam_r; getsubopt; + gettext; gettimeofday; getttyent; getttynam; getuid; getusershell; + getutent; getutent_r; getutid; getutid_r; getutline; getutline_r; + getutxent; getw; getwd; glob; glob_pattern_p; globfree; gmtime; + gmtime_r; group_member; gsignal; gtty; + + # h* + hasmntopt; hcreate; hcreate_r; hdestroy; hdestroy_r; herror; + host2netname; hsearch; hsearch_r; hstrerror; htonl; htons; + + # i* + if_freenameindex; if_indextoname; if_nameindex; if_nametoindex; index; + inet6_isipv4mapped; inet_addr; inet_aton; inet_lnaof; inet_makeaddr; + inet_netof; inet_network; inet_nsap_addr; inet_nsap_ntoa; inet_ntoa; + inet_ntop; inet_pton; init_module; initgroups; initstate; initstate_r; + innetgr; insque; ioctl; ioperm; iopl; iruserok; + + isalnum; isalpha; isascii; isatty; isblank; iscntrl; isdigit; + isfdtype; isgraph; isinf; isinff; isinfl; islower; isnan; isnanf; + isnanl; isprint; ispunct; isspace; isupper; iswalnum; iswalpha; + iswblank; iswcntrl; iswctype; iswdigit; iswgraph; iswlower; iswprint; + iswpunct; iswspace; iswupper; iswxdigit; isxdigit; + + # j* + jrand48; jrand48_r; + + # k* + key_decryptsession; key_decryptsession_pk; key_encryptsession; + key_encryptsession_pk; key_gendes; key_get_conv; key_secretkey_is_set; + key_setnet; key_setsecret; + + kill; killpg; klogctl; + + # l* + l64a; labs; lchown; lckpwdf; lcong48; lcong48_r; ldexp; ldexpf; + ldexpl; ldiv; lfind; link; listen; llabs; lldiv; llseek; localeconv; + localtime; localtime_r; lockf; longjmp; lrand48; lrand48_r; lsearch; + lseek; + + # m* + madvise; + + mallinfo; malloc; malloc_get_state; malloc_set_state; + malloc_stats; malloc_trim; malloc_usable_size; mallopt; + + mblen; mbrlen; mbrtowc; mbsinit; mbsnrtowcs; mbsrtowcs; mbstowcs; + mbtowc; mcheck; mcount; + + memalign; memccpy; memchr; memcmp; memcpy; memfrob; memmem; + memmove; memset; + + mkdir; mkfifo; mkstemp; mktemp; mktime; mlock; + mlockall; mmap; modf; modff; modfl; moncontrol; monstartup; mount; + mprobe; mprotect; mrand48; mrand48_r; mremap; msgctl; msgget; msgrcv; + msgsnd; msync; mtrace; munlock; munlockall; munmap; muntrace; + + # n* + nanosleep; netname2host; netname2user; nftw; nice; nl_langinfo; + nrand48; nrand48_r; ntohl; ntohs; + + # o* + obstack_free; obstack_printf; obstack_vprintf; on_exit; open; + open_memstream; opendir; openlog; + + # p* + parse_printf_format; passwd2des; pathconf; pause; pclose; perror; + personality; pipe; pmap_getmaps; pmap_getport; pmap_rmtcall; pmap_set; + pmap_unset; poll; popen; printf; printf_size; printf_size_info; + profil; profil_counter; pselect; psignal; + + pthread_attr_destroy; + pthread_attr_getdetachstate; pthread_attr_getinheritsched; + pthread_attr_getschedparam; pthread_attr_getschedpolicy; + pthread_attr_getscope; pthread_attr_init; pthread_attr_setdetachstate; + pthread_attr_setinheritsched; pthread_attr_setschedparam; + pthread_attr_setschedpolicy; pthread_attr_setscope; + pthread_cond_broadcast; pthread_cond_destroy; pthread_cond_init; + pthread_cond_signal; pthread_cond_wait; pthread_condattr_destroy; + pthread_condattr_init; pthread_equal; pthread_exit; + pthread_getschedparam; pthread_mutex_destroy; pthread_mutex_init; + pthread_mutex_lock; pthread_mutex_unlock; + pthread_mutexattr_getkind_np; pthread_mutexattr_setkind_np; + pthread_self; pthread_setcancelstate; pthread_setcanceltype; + pthread_setschedparam; + + ptrace; putc; putc_unlocked; putchar; + putchar_unlocked; putenv; putpwent; puts; putspent; pututline; + pututxline; putw; pvalloc; + + # q* + qecvt; qecvt_r; qfcvt; qfcvt_r; qgcvt; qsort; quotactl; + + # r* + raise; rand; rand_r; random; random_r; rcmd; + + re_comp; re_compile_fastmap; re_compile_pattern; re_exec; re_match; + re_match_2; re_search; re_search_2; re_set_registers; re_set_syntax; + + read; readdir; readdir_r; readlink; readv; realloc; realpath; reboot; + recv; recvfrom; recvmsg; regcomp; regerror; regexec; regfree; + register_printf_function; registerrpc; remove; remque; rename; + res_init; revoke; rewind; rewinddir; rexec; rindex; rmdir; rpmatch; + rresvport; rtime; ruserok; ruserpass; + + # s* + sbrk; scalbn; scalbnf; scalbnl; scandir; scanf; + + sched_get_priority_max; sched_get_priority_min; sched_getparam; + sched_getscheduler; sched_rr_get_interval; sched_setparam; + sched_setscheduler; sched_yield; + + seed48; seed48_r; seekdir; select; + semctl; semget; semop; send; sendmsg; sendto; setaliasent; setbuf; + setbuffer; setdomainname; setegid; setenv; seteuid; setfsent; + setfsgid; setfsuid; setgid; setgrent; setgroups; sethostent; + sethostid; sethostname; setitimer; setjmp; setlinebuf; setlocale; + setlogin; setlogmask; setmntent; setnetent; setnetgrent; setpgid; + setpgrp; setpriority; setprotoent; setpwent; setregid; setreuid; + setrlimit; setrpcent; setservent; setsid; setsockopt; setspent; + setstate; setstate_r; settimeofday; setttyent; setuid; setusershell; + setutent; setutxent; setvbuf; sgetspent; sgetspent_r; shmat; shmctl; + shmdt; shmget; shutdown; + + sigaction; sigaddset; sigaltstack; sigandset; sigblock; sigdelset; + sigemptyset; sigfillset; siggetmask; siginterrupt; sigisemptyset; + sigismember; siglongjmp; signal; sigorset; sigpause; sigpending; + sigprocmask; sigreturn; sigsetmask; sigstack; sigsuspend; sigvec; + sigwait; + + sleep; snprintf; socket; socketpair; sprintf; srand; srand48; + srand48_r; srandom; srandom_r; sscanf; ssignal; sstk; statfs; step; + stime; stpcpy; stpncpy; strcasecmp; strcat; strchr; strcmp; strcoll; + strcpy; strcspn; strdup; strerror; strerror_r; strfmon; strfry; + strftime; strlen; strncasecmp; strncat; strncmp; strncpy; strndup; + strnlen; strpbrk; strptime; strrchr; strsep; strsignal; strspn; + strstr; strtod; strtof; strtok; strtok_r; strtol; strtold; strtoll; + strtoq; strtoul; strtoull; strtouq; strverscmp; strxfrm; stty; + + svc_exit; svc_getreq; svc_getreqset; svc_register; svc_run; + svc_sendreply; svc_unregister; svcerr_auth; svcerr_decode; + svcerr_noproc; svcerr_noprog; svcerr_progvers; svcerr_systemerr; + svcerr_weakauth; svcfd_create; svcraw_create; svctcp_create; + svcudp_bufcreate; svcudp_create; svcudp_enablecache; + + swab; swapoff; swapon; symlink; sync; + syscall; sysconf; sysctl; sysinfo; syslog; + system; + + # t* + tcdrain; tcflow; tcflush; tcgetattr; tcgetpgrp; tcsendbreak; + tcsetattr; tcsetpgrp; tdelete; tdestroy; telldir; tempnam; textdomain; + tfind; time; timegm; timelocal; times; tmpfile; tmpnam; tmpnam_r; + + toascii; tolower; toupper; towctrans; towlower; towupper; + tr_break; truncate; tsearch; ttyname; ttyname_r; ttyslot; twalk; + tzset; + + # u* + ualarm; ulckpwdf; ulimit; umask; umount; uname; ungetc; unlink; + unsetenv; updwtmp; uselib; user2netname; usleep; ustat; utime; utimes; + utmpname; + + # v* + valloc; vasprintf; vdprintf; verr; verrx; versionsort; vfork; + vfprintf; vfscanf; vhangup; vlimit; vm86; vprintf; vscanf; vsnprintf; + vsprintf; vsscanf; vsyslog; vtimes; vwarn; vwarnx; + + # w* + wait; wait3; wait4; waitpid; warn; warnx; + + wcpcpy; wcpncpy; wcrtomb; wcscasecmp; wcscat; wcschr; wcscmp; wcscoll; + wcscpy; wcscspn; wcsdup; wcslen; wcsncasecmp; wcsncat; wcsncmp; + wcsncpy; wcsnrtombs; wcspbrk; wcsrchr; wcsrtombs; wcsspn; wcsstr; + wcstod; wcstof; wcstok; wcstol; wcstold; wcstoll; wcstombs; wcstoq; + wcstoul; wcstoull; wcstouq; wcswcs; wcswidth; wcsxfrm; wctob; wctomb; + wctrans; wctype; wcwidth; + + wmemchr; wmemcmp; wmemcpy; wmemmove; wmemset; write; writev; + + # x* + xdecrypt; xdr_accepted_reply; xdr_array; xdr_authdes_cred; + xdr_authdes_verf; xdr_authunix_parms; xdr_bool; xdr_bytes; + xdr_callhdr; xdr_callmsg; xdr_char; xdr_cryptkeyarg; xdr_cryptkeyarg2; + xdr_cryptkeyres; xdr_des_block; xdr_double; xdr_enum; xdr_float; + xdr_free; xdr_getcredres; xdr_int; xdr_key_netstarg; xdr_key_netstres; + xdr_keybuf; xdr_keystatus; xdr_long; xdr_netnamestr; xdr_netobj; + xdr_opaque; xdr_opaque_auth; xdr_pmap; xdr_pmaplist; xdr_pointer; + xdr_reference; xdr_rejected_reply; xdr_replymsg; xdr_rmtcall_args; + xdr_rmtcallres; xdr_short; xdr_string; xdr_u_char; xdr_u_int; + xdr_u_long; xdr_u_short; xdr_union; xdr_unixcred; xdr_vector; + xdr_void; xdr_wrapstring; xdrmem_create; xdrrec_create; + xdrrec_endofrecord; xdrrec_eof; xdrrec_skiprecord; xdrstdio_create; + xencrypt; xprt_register; xprt_unregister; local: *; diff --git a/locale/programs/locale.c b/locale/programs/locale.c index cf2789c9d9..3292962309 100644 --- a/locale/programs/locale.c +++ b/locale/programs/locale.c @@ -192,7 +192,7 @@ main (int argc, char *argv[]) } /* `m' requests the names of all available charmaps. The names can be - used for the -f argument to localedef(3). */ + used for the -f argument to localedef(1). */ if (do_charmaps != 0) { write_charmaps (); @@ -554,6 +554,25 @@ show_locale_vars (void) } +/* Some of the "string" we print contain non-printable characters. We + encode them here. */ +static void +print_escaped (const char *string) +{ + const unsigned char *ch; + + ch = string; + while ('\0' != *ch) + { + if (isprint (*ch)) + putchar (*ch); + else + printf("<0x%02x>", *ch); + ++ch; + } +} + + /* Show the information request for NAME. */ static void show_info (const char *name) @@ -568,9 +587,11 @@ show_info (const char *name) switch (item->value_type) { case string: - printf ("%s%s%s", show_keyword_name ? "\"" : "", - nl_langinfo (item->item_id) ? : "", - show_keyword_name ? "\"" : ""); + if (show_keyword_name) + putchar ('"'); + print_escaped (nl_langinfo (item->item_id) ? : ""); + if (show_keyword_name) + putchar ('"'); break; case stringarray: { @@ -583,11 +604,14 @@ show_info (const char *name) for (cnt = 0; cnt < item->max - 1; ++cnt) { val = nl_langinfo (item->item_id + cnt); - printf ("%s;", val ? : ""); + if (val != NULL) + print_escaped (val); + putchar (';'); } val = nl_langinfo (item->item_id + cnt); - printf ("%s", val ? : ""); + if (val != NULL) + print_escaped (val); if (show_keyword_name) putchar ('"'); diff --git a/login/getutent_r.c b/login/getutent_r.c index a50e2786fd..ed4c330f73 100644 --- a/login/getutent_r.c +++ b/login/getutent_r.c @@ -29,9 +29,9 @@ /* The various backends we have. */ -static int setutent_unknown (int reset); static int getutent_r_unknown (struct utmp *buffer, struct utmp **result); static struct utmp *pututline_unknown (const struct utmp *data); +static void setutent_unknown (void); static void endutent_unknown (void); /* Initial Jump table. */ @@ -58,7 +58,7 @@ __setutent (void) { __libc_lock_lock (__libc_utmp_lock); - (void) (*__libc_utmp_jump_table->setutent) (1); + (*__libc_utmp_jump_table->setutent) (); __libc_lock_unlock (__libc_utmp_lock); } @@ -66,36 +66,6 @@ weak_alias (__setutent, setutent) weak_alias (__setutent, setutxent) -static int -setutent_unknown (int reset) -{ - /* We have to test whether it is still not decided which backend to use. */ - assert (__libc_utmp_jump_table == &__libc_utmp_unknown_functions); - - /* See whether utmpd is running. */ - if ((*__libc_utmp_daemon_functions.setutent) (reset)) - __libc_utmp_jump_table = &__libc_utmp_daemon_functions; - else - { - /* Use the normal file, but if the current file is _PATH_UTMP or - _PATH_WTMP and the corresponding extended file (with an extra - 'x' added to the pathname) exists, we use the extended file, - because the original file is in a different format. */ - if (strcmp (__libc_utmp_file_name, _PATH_UTMP) == 0 - && __access (_PATH_UTMP "x", F_OK) == 0) - __utmpname (_PATH_UTMP "x"); - else if (strcmp (__libc_utmp_file_name, _PATH_WTMP) == 0 - && __access (_PATH_WTMP "x", F_OK) == 0) - __utmpname (_PATH_WTMP "x"); - - (*__libc_utmp_file_functions.setutent) (reset); - __libc_utmp_jump_table = &__libc_utmp_file_functions; - } - - return 0; -} - - void __endutent (void) { @@ -109,6 +79,20 @@ weak_alias (__endutent, endutent) weak_alias (__endutent, endutxent) +static void +setutent_unknown (void) +{ + /* See whether utmpd is running. */ + if ((*__libc_utmp_daemon_functions.setutent) ()) + __libc_utmp_jump_table = &__libc_utmp_daemon_functions; + else + { + (*__libc_utmp_file_functions.setutent) (); + __libc_utmp_jump_table = &__libc_utmp_file_functions; + } +} + + static void endutent_unknown (void) { @@ -136,7 +120,7 @@ static int getutent_r_unknown (struct utmp *buffer, struct utmp **result) { /* It is not yet initialized. */ - setutent_unknown (0); + __setutent (); return (*__libc_utmp_jump_table->getutent_r) (buffer, result); } @@ -158,12 +142,12 @@ __pututline (const struct utmp *data) weak_alias (__pututline, pututline) weak_alias (__pututline, pututxline) - + static struct utmp * pututline_unknown (const struct utmp *data) { /* It is not yet initialized. */ - setutent_unknown (0); + __setutent (); return (*__libc_utmp_jump_table->pututline) (data); } diff --git a/login/getutid_r.c b/login/getutid_r.c index ee3a39a3bd..90b75b8c01 100644 --- a/login/getutid_r.c +++ b/login/getutid_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper and Paul Janzen , 1996. @@ -55,7 +55,7 @@ __getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result) __libc_lock_lock (__libc_utmp_lock); /* Not yet initialized. */ - if ((*__libc_utmp_jump_table->setutent) (0)) + if ((*__libc_utmp_jump_table->setutent) ()) retval = (*__libc_utmp_jump_table->getutid_r) (id, buffer, result); else *result = NULL; diff --git a/login/getutline_r.c b/login/getutline_r.c index 9b4180fe4a..a1bdc0bc4e 100644 --- a/login/getutline_r.c +++ b/login/getutline_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper and Paul Janzen , 1996. @@ -43,7 +43,7 @@ __getutline_r (const struct utmp *line, struct utmp *buffer, __libc_lock_lock (__libc_utmp_lock); /* Not yet initialized. */ - if ((*__libc_utmp_jump_table->setutent) (0)) + if ((*__libc_utmp_jump_table->setutent) ()) retval = (*__libc_utmp_jump_table->getutline_r) (line, buffer, result); else *result = NULL; diff --git a/login/programs/database.c b/login/programs/database.c index 087ec54d26..00d573f336 100644 --- a/login/programs/database.c +++ b/login/programs/database.c @@ -52,6 +52,7 @@ static int get_mtime (int filedes, time_t *timer); utmp_database * open_database (const char *file, const char *old_file) { + mode_t mode = S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH; utmp_database *database; /* Allocate memory. */ @@ -65,7 +66,7 @@ open_database (const char *file, const char *old_file) memset (database, 0, sizeof (utmp_database)); /* Open database, create it if it doesn't exist already. */ - database->fd = open (file, O_RDWR | O_CREAT); + database->fd = open (file, O_RDWR | O_CREAT, mode); if (database->fd < 0) { error (0, errno, "%s", file); @@ -81,7 +82,7 @@ open_database (const char *file, const char *old_file) if (old_file) { - database->old_fd = open (old_file, O_RDWR); + database->old_fd = open (old_file, O_RDWR|O_CREAT, mode); if (database->old_fd < 0) { error (0, errno, "%s", old_file); diff --git a/login/programs/utmpd.c b/login/programs/utmpd.c index 1469d94ca7..e0648ebb42 100644 --- a/login/programs/utmpd.c +++ b/login/programs/utmpd.c @@ -141,6 +141,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ if (check_pid (_PATH_UTMPDPID)) error (EXIT_FAILURE, 0, _("already running")); + /* Cleanup files created by a previous `bind'. */ + unlink (_PATH_UTMPD_RO); + unlink (_PATH_UTMPD_RW); + /* Open UTMP database. */ utmp_db = open_database (_PATH_UTMP "x", _PATH_UTMP); if (utmp_db == NULL) @@ -248,6 +252,7 @@ make_socket (const char *name) size = (offsetof (struct sockaddr_un, sun_path) + strlen (addr.sun_path)); + if (bind (sock, (struct sockaddr *) &addr, size) < 0) error (EXIT_FAILURE, errno, "%s", name); diff --git a/login/utmp-private.h b/login/utmp-private.h index 87860d5d33..531d058469 100644 --- a/login/utmp-private.h +++ b/login/utmp-private.h @@ -24,11 +24,10 @@ #include -/* The extra `int' argument for each function shows whether locking is - wanted or not. */ +/* The structure describing the functions in a backend. */ struct utfuncs { - int (*setutent) (int); + int (*setutent) (void); int (*getutent_r) (struct utmp *, struct utmp **); int (*getutid_r) (const struct utmp *, struct utmp *, struct utmp **); int (*getutline_r) (const struct utmp *, struct utmp *, struct utmp **); diff --git a/login/utmp_daemon.c b/login/utmp_daemon.c index e0a20e9a9f..5907e06e2d 100644 --- a/login/utmp_daemon.c +++ b/login/utmp_daemon.c @@ -35,7 +35,7 @@ static int daemon_sock = INT_MIN; /* Functions defined here. */ -static int setutent_daemon (int reset); +static int setutent_daemon (void); static int getutent_r_daemon (struct utmp *buffer, struct utmp **result); static int getutid_r_daemon (const struct utmp *line, struct utmp *buffer, struct utmp **result); @@ -74,9 +74,13 @@ static int send_request (int sock, const request_header *request, static int -setutent_daemon (int reset) +setutent_daemon (void) { - if (daemon_sock == INT_MIN) + if (access (_PATH_UTMPD_RW, F_OK) == -1 + && access (_PATH_UTMPD_RO, F_OK) == -1) + return 0; + + if (daemon_sock < 0) { daemon_sock = open_socket (_PATH_UTMPD_RW); if (daemon_sock < 0) @@ -86,18 +90,12 @@ setutent_daemon (int reset) if (daemon_sock < 0) return 0; } - - /* Send request to the daemon. */ - if (do_setutent (daemon_sock) < 0) - return 0; - } - else if (reset) - { - /* Send request to the daemon. */ - if (do_setutent (daemon_sock) < 0) - return 0; } + /* Send request to the daemon. */ + if (do_setutent (daemon_sock) < 0) + return 0; + return 1; } @@ -121,7 +119,7 @@ getutent_r_daemon (struct utmp *buffer, struct utmp **result) { /* Open connection if not already done. */ if (daemon_sock == INT_MIN) - setutent_daemon (1); + setutent_daemon (); if (daemon_sock < 0) { @@ -189,9 +187,9 @@ getutid_r_daemon (const struct utmp *id, struct utmp *buffer, static struct utmp * pututline_daemon (const struct utmp *utmp) { + /* Open connection if not already done. */ if (daemon_sock == INT_MIN) - /* The connection is closed. Open it again. */ - setutent_daemon (0); + setutent_daemon (); if (daemon_sock < 0) /* Something went wrong. */ @@ -217,7 +215,10 @@ updwtmp_daemon (const char *file, const struct utmp *utmp) /* Send request to the daemon. */ if (do_updwtmp (sock, file, utmp) < 0) - return -1; + { + close (sock); + return -1; + } close (sock); return 0; diff --git a/login/utmp_file.c b/login/utmp_file.c index 4e218d8baa..6d6e05b292 100644 --- a/login/utmp_file.c +++ b/login/utmp_file.c @@ -39,7 +39,7 @@ static struct utmp last_entry; /* Functions defined here. */ -static int setutent_file (int reset); +static int setutent_file (void); static int getutent_r_file (struct utmp *buffer, struct utmp **result); static int getutid_r_file (const struct utmp *key, struct utmp *buffer, struct utmp **result); @@ -63,41 +63,40 @@ struct utfuncs __libc_utmp_file_functions = static int -setutent_file (int reset) +setutent_file (void) { - if (file_fd == INT_MIN) + if (file_fd < 0) { - file_fd = open (__libc_utmp_file_name, O_RDWR); + const char *file_name = __libc_utmp_file_name; + + if (strcmp (__libc_utmp_file_name, _PATH_UTMP) == 0 + && __access (_PATH_UTMP "x", F_OK) == 0) + file_name = _PATH_UTMP "x"; + else if (strcmp (__libc_utmp_file_name, _PATH_WTMP) == 0 + && __access (_PATH_WTMP "x", F_OK) == 0) + file_name = _PATH_WTMP "x"; + + file_fd = open (file_name, O_RDWR); if (file_fd == -1) { /* Hhm, read-write access did not work. Try read-only. */ - file_fd = open (__libc_utmp_file_name, O_RDONLY); + file_fd = open (file_name, O_RDONLY); if (file_fd == -1) { perror (_("while opening UTMP file")); return 0; } } - file_offset = 0; - -#if _HAVE_UT_TYPE - 0 - /* Make sure the entry won't match. */ - last_entry.ut_type = -1; -#endif } - else if (reset) - { - lseek (file_fd, 0, SEEK_SET); - /* Remember we are at beginning of file. */ - file_offset = 0; + lseek (file_fd, 0, SEEK_SET); + file_offset = 0; #if _HAVE_UT_TYPE - 0 - /* Make sure the entry won't match. */ - last_entry.ut_type = -1; + /* Make sure the entry won't match. */ + last_entry.ut_type = -1; #endif - } - + return 1; } @@ -120,7 +119,7 @@ getutent_r_file (struct utmp *buffer, struct utmp **result) /* Open utmp file if not already done. */ if (file_fd == INT_MIN) - setutent_file (1); + setutent_file (); if (file_fd == -1 || file_offset == -1l) { @@ -348,14 +347,14 @@ pututline_file (const struct utmp *data) struct utmp *pbuf; int found; - if (file_fd < 0) + /* Open utmp file if not already done. */ + if (file_fd == INT_MIN) + setutent_file (); + + if (file_fd == -1) /* Something went wrong. */ return NULL; - if (file_fd == INT_MIN) - /* The file is closed. Open it again. */ - setutent_file (0); - /* Find the correct place to insert the data. */ if (file_offset > 0 && ( diff --git a/manual/errno.texi b/manual/errno.texi index bba820869e..800b0393c5 100644 --- a/manual/errno.texi +++ b/manual/errno.texi @@ -430,7 +430,7 @@ until some external condition makes it possible to read, write, or connect (whatever the operation). You can use @code{select} to find out when the operation will be possible; @pxref{Waiting for I/O}. -@strong{Portability Note:} In older Unix many systems, this condition +@strong{Portability Note:} In older many Unix systems, this condition was indicated by @code{EWOULDBLOCK}, which was a distinct error code different from @code{EAGAIN}. To make your program portable, you should check for both codes and treat them the same. diff --git a/manual/socket.texi b/manual/socket.texi index 6efc54d1a5..cc39bec452 100644 --- a/manual/socket.texi +++ b/manual/socket.texi @@ -852,7 +852,7 @@ local-address-within-network numbers in host byte order. @comment arpa/inet.h @comment BSD -@deftypefun {int} inet_aton (const char *@var{name}, struct in_addr *@var{addr}) +@deftypefun int inet_aton (const char *@var{name}, struct in_addr *@var{addr}) This function converts the Internet host address @var{name} from the standard numbers-and-dots notation into binary data and stores it in the @code{struct in_addr} that @var{addr} points to. @@ -917,8 +917,7 @@ address @var{addr}. @comment arpa/inet.h @comment IPv6 basic API -@deftypefun int inet_pton (int @var{af}, const char *@var{cp}, void -*@var{buf}) +@deftypefun int inet_pton (int @var{af}, const char *@var{cp}, void *@var{buf}) This function converts an Internet address (either IPv4 or IPv6) from presentation (textual) to network (binary) format. @var{af} should be either @code{AF_INET} or @code{AF_INET6}, as appropriate for the type of @@ -929,8 +928,7 @@ responsibility to make sure the buffer is large enough. @comment arpa/inet.h @comment IPv6 basic API -@deftypefun char *inet_ntop(int @var{af}, const void *@var{cp}, char -*@var{buf}, size_t @var{len}) +@deftypefun {char *} inet_ntop (int @var{af}, const void *@var{cp}, char *@var{buf}, size_t @var{len}) This function converts an Internet address (either IPv4 or IPv6) from network (binary) to presentation (textual) form. @var{af} should be either @code{AF_INET} or @code{AF_INET6}, as appropriate. @var{cp} is a diff --git a/math/libm-test.c b/math/libm-test.c index 2ea0bf83cf..982e051bdd 100644 --- a/math/libm-test.c +++ b/math/libm-test.c @@ -595,35 +595,6 @@ check_int (const char *test_name, int computed, int expected) fpstack_test (test_name); } -static void -check_int_exc (const char *test_name, int computed, int expected, - short exception) -{ - int diff = computed - expected; - int result = diff == 0; - - output_new_test (test_name); - test_exceptions (test_name, exception); - - if (result) - { - output_pass_value (); - } - else - { - output_fail_value (test_name); - if (verbose > 1) - { - printf ("Result:\n"); - printf (" is: %d\n", computed); - printf (" should be: %d\n", expected); - } - noErrors++; - } - - fpstack_test (test_name); -} - /* check that computed and expected values are equal (long int values) diff --git a/md5-crypt/Makefile b/md5-crypt/Makefile index 6e88eb6053..b52e1ef012 100644 --- a/md5-crypt/Makefile +++ b/md5-crypt/Makefile @@ -36,6 +36,7 @@ libcrypt-map := libcrypt.map onlymd5-routines := onlymd5-entry md5-crypt md5 distribute += onlymd5-entry.c +extra-objs := onlymd5-entry.o include ../Makeconfig diff --git a/nis/Makefile b/nis/Makefile index e7dd50c1d9..7c70c9c2a8 100644 --- a/nis/Makefile +++ b/nis/Makefile @@ -21,7 +21,7 @@ # subdir := nis -headers := $(wildcard rpcsvc/*.[hx]) +headers := $(wildcard rpcsvc/*.[hx]) bits/nislib.h distribute := nss-nis.h nss-nisplus.h nis_intern.h Banner \ nisplus-parser.h diff --git a/nis/nislib/nislib.h b/nis/nislib/nislib.h new file mode 100644 index 0000000000..73b3804e85 --- /dev/null +++ b/nis/nislib/nislib.h @@ -0,0 +1,268 @@ +/* Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Thorsten Kukuk , 1997. + + 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 __RPCSVC_NISLIB_H__ +#define __RPCSVC_NISLIB_H__ + +#include + +__BEGIN_DECLS + +typedef const char *const_nis_name; + +/* nis_names: These functions are used to locate and manipulate all NIS+ + * objects except the NIS+ entry objects. + * + * nis_lookup (name, flags) resolves a NIS+ name and returns a copy of + * that object from a NIS+ server. + * const nis_name name: name of the object to be resolved + * u_long flags: logically ORing zero or more flags (FOLLOW_LINKS, + * HARD_LOOKUP, [NO_CACHE], MASTER_ONLY, EXPAND_NAME) + * + * nis_add (name, obj) adds objects to the NIS+ namespace. + * const nis_name name: fully qualified NIS+ name. + * const nis_object *obj: object members zo_name and zo_domain will be + * constructed from name. + * + * nis_remove (name, obj) removes objects from the NIS+ namespace. + * const nis_name name: fully qualified NIS+ name. + * const nis_object *obj: if not NULL, it is assumed to point to a copy + * of the object being removed. In this case, if + * the object on the server does not have the same + * object identifier as the object being passed, + * the operation will fail with the NIS_NOTSAMEOBJ + * error. + * + * nis_modify (name, obj) can change specific attributes of an object + * that already exists in the namespace. + */ +extern nis_result *nis_lookup __P ((const_nis_name name, u_long flags)); +extern nis_result *nis_add __P ((const_nis_name name, const nis_object *obj)); +extern nis_result *nis_remove __P ((const_nis_name name, + const nis_object *obj)); +extern nis_result *nis_modify __P ((const_nis_name name, + const nis_object *obj)); + +/* nis_tables: These functions are used to search and modify NIS+ tables. + * + * nis_list (table_name, flags, callback(table_name, obj, userdata), userdata) + * search a table in the NIS+ namespace. + * const nis_name table_name: indexed name ([xx=yy],table.dir) + * u_long flags: logically ORing one or more flags (FOLLOW_LINKS, + * [FOLLOW_PATH], HARD_LOOKUP, [ALL_RESULTS], [NO_CACHE], + * MASTER_ONLY, EXPAND_NAME, RETURN_RESULT) + * callback(): callback is an optional pointer to a function that will + * process the ENTRY type objects that are returned from the + * search. If this pointer is NULL, then all entries that match + * the search criteria are returned in the nis_result structure, + * otherwise this function will be called once for each + * entry returned. + * void *userdata: passed to callback function along with the returned + * entry object. + * + * nis_add_entry (table_name, obj, flags) will add the NIS+ object to the + * NIS+ table_name. + * const nis_name table_name + * const nis_object *obj + * u_long flags: 0, ADD_OVERWRITE, RETURN_RESULT + * + * nis_modify_entry (name, obj, flags) modifies an object identified by name. + * const nis_name name: object identifier + * const nis_object *obj: should point to an entry with the EN_MODIFIED + * flag set in each column that contains new + * information. + * u_long flags: 0, MOD_SAMEOBJ, RETURN_RESULT + * + * nis_remove_entry (table_name, obj, flags) removes a set of entries + * identified by table_name from the table. + * const nis_name table_name: indexed NIS+ name + * const nis_object *obj: if obj is non-null, it is presumed to point to + * a cached copy of the entry. When the removal is + * attempted, and the object that would be removed + * is not the same as the cached object pointed to + * by object then the operation will fail with an + * NIS_NOTSAMEOBJ error + * u_long flags: 0, REM_MULTIPLE + * + * nis_first_entry (table_name) fetches entries from a table one at a time. + * const nis_name table_name + * + * nis_next_entry (table_name, cookie) retrieves the "next" entry from a + * table specified by table_name. + * const nis_name table_name: + * const netobj *cookie: The value of cookie from the nis_result structure + * form the previous call. + */ +extern nis_result *nis_list __P ((const_nis_name name, u_long flags, + int (*callback)(const_nis_name table_name, + const nis_object *obj, + const void *userdata), + const void *userdata)); +extern nis_result *nis_add_entry __P ((const_nis_name table_name, + const nis_object *obj, u_long flags)); +extern nis_result *nis_modify_entry __P ((const_nis_name name, + const nis_object *obj, + u_long flags)); +extern nis_result *nis_remove_entry __P ((const_nis_name table_name, + const nis_object *obj, + u_long flags)); +extern nis_result *nis_first_entry __P ((const_nis_name table_name)); +extern nis_result *nis_next_entry __P ((const_nis_name table_name, + const netobj *cookie)); +/* +** nis_server +*/ +extern nis_error nis_mkdir __P ((const_nis_name dirname, + const nis_server *machine)); +extern nis_error nis_rmdir __P ((const_nis_name dirname, + const nis_server *machine)); +extern nis_error nis_servstate __P ((const nis_server *machine, + const nis_tag *tags, int numtags, + nis_tag **result)); +extern nis_error nis_stats __P ((const nis_server *machine, + const nis_tag *tags, int numtags, + nis_tag **result)); +extern void nis_freetags __P ((nis_tag *tags, int numtags)); +extern nis_server **nis_getservlist __P ((const_nis_name dirname)); +extern void nis_freeservlist __P ((nis_server **machines)); + +/* +** nis_subr +*/ +extern nis_name nis_leaf_of __P ((const_nis_name name)); +extern nis_name nis_leaf_of_r __P ((const_nis_name name, char *buffer, + size_t buflen)); +extern nis_name nis_name_of __P ((const_nis_name name)); +extern nis_name nis_name_of_r __P ((const_nis_name name, char *buffer, + size_t buflen)); +extern nis_name nis_domain_of __P ((const_nis_name name)); +extern nis_name nis_domain_of_r __P ((const_nis_name name, char *buffer, + size_t buflen)); +extern nis_name *nis_getnames __P ((const_nis_name name)); +extern void nis_freenames __P ((nis_name *namelist)); +extern name_pos nis_dir_cmp __P ((const_nis_name n1, const_nis_name n2)); +extern nis_object *nis_clone_object __P ((const nis_object *src, + nis_object *dest)); +extern void nis_destroy_object __P ((nis_object *obj)); +extern void nis_print_object __P ((const nis_object *obj)); + +/* +** nis_local_names +*/ +extern nis_name nis_local_group __P ((void)); +extern nis_name nis_local_directory __P ((void)); +extern nis_name nis_local_principal __P ((void)); +extern nis_name nis_local_host __P ((void)); + +/* +** nis_error +*/ +extern const char *nis_sperrno __P ((const nis_error status)); +extern void nis_perror __P ((const nis_error status, const char *label)); +extern void nis_lerror __P ((const nis_error status, const char *label)); +extern char *nis_sperror __P ((const nis_error status, const char *label)); +extern char *nis_sperror_r __P ((const nis_error status, const char *label, + char *buffer, size_t buflen)); +/* +** nis_groups +*/ +extern bool_t nis_ismember __P ((const_nis_name principal, + const_nis_name group)); +extern nis_error nis_addmember __P ((const_nis_name member, + const_nis_name group)); +extern nis_error nis_removemember __P ((const_nis_name member, + const_nis_name group)); +extern nis_error nis_creategroup __P ((const_nis_name group, u_long flags)); +extern nis_error nis_destroygroup __P ((const_nis_name group)); +extern void nis_print_group_entry __P ((const_nis_name group)); +extern nis_error nis_verifygroup __P ((const_nis_name group)); + +/* +** nis_ping +*/ +extern void nis_ping __P ((const_nis_name dirname, u_long utime, + const nis_object *dirobj)); +extern nis_result *nis_checkpoint __P ((const_nis_name dirname)); + +/* +** nis_print (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) +*/ +extern void nis_print_result __P ((const nis_result *result)); +extern void nis_print_rights __P ((u_long rights)); +extern void nis_print_directory __P ((const directory_obj *dirobj)); +extern void nis_print_group __P ((const group_obj *grpobj)); +extern void nis_print_table __P ((const table_obj *tblobj)); +extern void nis_print_link __P ((const link_obj *lnkobj)); +extern void nis_print_entry __P ((const entry_obj *enobj)); + +/* +** nis_file (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) +*/ +extern directory_obj *readColdStartFile __P ((void)); +extern bool_t writeColdStartFile __P ((const directory_obj *dirobj)); +extern nis_object *nis_read_obj __P ((const char *obj)); +extern bool_t nis_write_obj __P ((const char *file, const nis_object *obj)); + +/* +** nis_clone - (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) +*/ +extern directory_obj *nis_clone_directory __P ((const directory_obj *src, + directory_obj *dest)); +extern group_obj *nis_clone_group __P ((const group_obj *src, + group_obj *dest)); +extern table_obj *nis_clone_table __P ((const table_obj *src, + table_obj *dest)); +extern entry_obj *nis_clone_entry __P ((const entry_obj *src, + entry_obj *dest)); +extern link_obj *nis_clone_link __P ((const link_obj *src, link_obj *dest)); +extern objdata *nis_clone_objdata __P ((const objdata *src, objdata *dest)); +extern nis_result *nis_clone_result __P ((const nis_result *src, + nis_result *dest)); + +/* nis_free - nis_freeresult */ +extern void nis_freeresult __P ((nis_result *result)); +/* (XXX THE FOLLOWING ARE INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */ +extern void nis_free_attr __P ((nis_attr *attr)); +extern void nis_free_request __P ((ib_request *req)); +extern void nis_free_endpoints __P ((endpoint *ep, unsigned int count)); +extern void nis_free_servers __P ((nis_server *machine, unsigned int count)); +extern void nis_free_directory __P ((directory_obj *dirobj)); +extern void nis_free_group __P ((group_obj *grpobj)); +extern void nis_free_table __P ((table_obj *tblobj)); +extern void nis_free_entry __P ((entry_obj *enobj)); +extern void nis_free_link __P ((link_obj *lnkobj)); +extern void nis_free_object __P ((nis_object *obj)); + +/* (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */ +extern nis_name __nis_default_owner __P ((char *)); +extern nis_name __nis_default_group __P ((char *)); +extern u_long __nis_default_ttl __P ((char *)); +extern u_long __nis_default_access __P ((char *, u_long)); +extern fd_result *__nis_finddirectory __P ((directory_obj *, const_nis_name)); +extern u_long __nis_hash __P ((const void *keyarg, register size_t len)); +extern log_result *__nis_dumplog __P ((nis_server *,nis_name, u_long)); +extern log_result *__nis_dump __P ((nis_server *, nis_name, + int (*)(nis_name, nis_object *, void *))); +/* NIS+ cache locking */ +extern int __nis_lock_cache __P ((void)); +extern int __nis_unlock_cache __P ((void)); + +__END_DECLS + +#endif /* __RPCSVC_NISLIB_H__ */ diff --git a/nis/nss_compat/compat-grp.c b/nis/nss_compat/compat-grp.c index 35ae2f7b02..c0ddbdffdf 100644 --- a/nis/nss_compat/compat-grp.c +++ b/nis/nss_compat/compat-grp.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "nss-nisplus.h" diff --git a/nis/nss_compat/compat-pwd.c b/nis/nss_compat/compat-pwd.c index 6fac0f46c6..681258d2e6 100644 --- a/nis/nss_compat/compat-pwd.c +++ b/nis/nss_compat/compat-pwd.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include "netgroup.h" diff --git a/nis/nss_compat/compat-spwd.c b/nis/nss_compat/compat-spwd.c index a4c6201c2d..431380dac6 100644 --- a/nis/nss_compat/compat-spwd.c +++ b/nis/nss_compat/compat-spwd.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include "netgroup.h" diff --git a/nis/nss_nisplus/nisplus-alias.c b/nis/nss_nisplus/nisplus-alias.c index 0a16b3890f..8d682d785c 100644 --- a/nis/nss_nisplus/nisplus-alias.c +++ b/nis/nss_nisplus/nisplus-alias.c @@ -24,7 +24,6 @@ #include #include #include -#include #include "nss-nisplus.h" @@ -153,6 +152,8 @@ _nss_nisplus_parse_aliasent (nis_result *result, unsigned long entry, static enum nss_status internal_setaliasent (void) { + enum nss_status status; + if (result) nis_freeresult (result); result = NULL; @@ -162,12 +163,13 @@ internal_setaliasent (void) next_entry = 0; result = nis_list(tablename_val, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL); - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) + status = niserr2nss (result->status); + if (status != NSS_STATUS_SUCCESS) { nis_freeresult (result); result = NULL; } - return niserr2nss (result->status); + return status; } enum nss_status @@ -206,7 +208,13 @@ internal_nisplus_getaliasent_r (struct aliasent *alias, int parse_res; if (result == NULL) - internal_setaliasent (); + { + enum nss_status status; + + status = internal_setaliasent (); + if (result == NULL || status != NSS_STATUS_SUCCESS) + return status; + } /* Get the next entry until we found a correct one. */ do diff --git a/nis/nss_nisplus/nisplus-ethers.c b/nis/nss_nisplus/nisplus-ethers.c index d7c3720932..cfdb3dc4e1 100644 --- a/nis/nss_nisplus/nisplus-ethers.c +++ b/nis/nss_nisplus/nisplus-ethers.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include "nss-nisplus.h" @@ -153,7 +152,7 @@ internal_nisplus_getetherent_r (struct etherent *ether, char *buffer, do { nis_result *saved_result; - + if (result == NULL) { saved_result = NULL; @@ -175,7 +174,7 @@ internal_nisplus_getetherent_r (struct etherent *ether, char *buffer, } } - if ((parse_res = _nss_nisplus_parse_etherent (result, ether, buffer, + if ((parse_res = _nss_nisplus_parse_etherent (result, ether, buffer, buflen)) == -1) { nis_freeresult (result); @@ -187,7 +186,7 @@ internal_nisplus_getetherent_r (struct etherent *ether, char *buffer, if (saved_result != NULL) nis_freeresult (saved_result); } - + } while (!parse_res); return NSS_STATUS_SUCCESS; @@ -233,14 +232,14 @@ _nss_nisplus_gethostton_r (const char *name, struct etherent *eth, nis_freeresult (result); return status; } - + if ((parse_res = _nss_nisplus_parse_etherent (result, eth, buffer, buflen)) == -1) { nis_freeresult (result); return NSS_STATUS_TRYAGAIN; } - + if (parse_res) return NSS_STATUS_SUCCESS; } @@ -282,16 +281,15 @@ _nss_nisplus_getntohost_r (const struct ether_addr *addr, return status; } - if ((parse_res = _nss_nisplus_parse_etherent (result, eth, buffer, + if ((parse_res = _nss_nisplus_parse_etherent (result, eth, buffer, buflen)) == -1) { nis_freeresult (result); return NSS_STATUS_TRYAGAIN; } - + if (parse_res) return NSS_STATUS_SUCCESS; } return NSS_STATUS_NOTFOUND; } - diff --git a/nis/nss_nisplus/nisplus-grp.c b/nis/nss_nisplus/nisplus-grp.c index 08e9e040fe..1031d69ac9 100644 --- a/nis/nss_nisplus/nisplus-grp.c +++ b/nis/nss_nisplus/nisplus-grp.c @@ -24,7 +24,6 @@ #include #include #include -#include #include "nss-nisplus.h" #include "nisplus-parser.h" @@ -57,6 +56,8 @@ _nss_create_tablename (void) static enum nss_status internal_setgrent (void) { + enum nss_status status; + if (result) nis_freeresult (result); result = NULL; @@ -67,12 +68,13 @@ internal_setgrent (void) return NSS_STATUS_UNAVAIL; result = nis_list (tablename_val, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL); - if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) + status = niserr2nss (result->status); + if (status != NSS_STATUS_SUCCESS) { nis_freeresult (result); result = NULL; } - return niserr2nss (result->status); + return status; } enum nss_status @@ -109,7 +111,13 @@ internal_nisplus_getgrent_r (struct group *gr, char *buffer, size_t buflen) int parse_res; if (result == NULL) - internal_setgrent (); + { + enum nss_status status; + + status = internal_setgrent (); + if (result == NULL || status != NSS_STATUS_SUCCESS) + return status; + } /* Get the next entry until we found a correct one. */ do diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c index 10f939e341..89a8bf7564 100644 --- a/nis/nss_nisplus/nisplus-hosts.c +++ b/nis/nss_nisplus/nisplus-hosts.c @@ -26,7 +26,6 @@ #include #include #include -#include #include "nss-nisplus.h" @@ -98,7 +97,7 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host, if (NISENTRYLEN (0, 0, result) + 1 > room_left) goto no_more_room; - + p = stpncpy (first_unused, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result)); *p = '\0'; @@ -114,7 +113,7 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host, { if (NISENTRYLEN (i, 1, result) + 2 > room_left) goto no_more_room; - + *p++ = ' '; p = stpncpy (p, NISENTRYVAL (i, 1, result), NISENTRYLEN (i, 1, result)); @@ -131,7 +130,7 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host, host->h_addr_list = (char **) first_unused; if (room_left < 2 * sizeof (char *)) goto no_more_room; - + room_left -= (2 * sizeof (char *)); host->h_addr_list[0] = data; host->h_addr_list[1] = NULL; @@ -242,7 +241,7 @@ internal_nisplus_gethostent_r (struct hostent *host, char *buffer, result = nis_first_entry(tablename_val); if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) { - enum nss_status retval = niserr2nss (result->status); + enum nss_status retval = niserr2nss (result->status); if (retval == NSS_STATUS_TRYAGAIN) { *herrnop = NETDB_INTERNAL; @@ -250,12 +249,12 @@ internal_nisplus_gethostent_r (struct hostent *host, char *buffer, } return retval; } - + } else { nis_result *res2; - + saved_res = result; res2 = nis_next_entry(tablename_val, &result->cookie); result = res2; @@ -273,7 +272,7 @@ internal_nisplus_gethostent_r (struct hostent *host, char *buffer, return retval; } } - + parse_res = _nss_nisplus_parse_hostent (result, AF_INET6, host, buffer, buflen); if (parse_res < 1 && errno != ERANGE) @@ -288,9 +287,9 @@ internal_nisplus_gethostent_r (struct hostent *host, char *buffer, } if (saved_res != NULL) nis_freeresult (saved_res); - + } while (!parse_res); - + return NSS_STATUS_SUCCESS; } @@ -349,10 +348,10 @@ _nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host, else sprintf(buf, "[cname=%s],%s", NISENTRYVAL(0, 0, result), tablename_val); - + nis_freeresult (result); result = nis_list(buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL); - + retval = niserr2nss (result->status); if (retval != NSS_STATUS_SUCCESS) { @@ -369,7 +368,7 @@ _nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host, _nss_nisplus_parse_hostent (result, af, host, buffer, buflen); nis_freeresult (result); - + if (parse_res > 0) return NSS_STATUS_SUCCESS; @@ -435,10 +434,10 @@ _nss_nisplus_gethostbyaddr_r (const char *addr, int addrlen, int type, parse_res = _nss_nisplus_parse_hostent (result, type, host, buffer, buflen); nis_freeresult (result); - + if (parse_res > 0) return NSS_STATUS_SUCCESS; - + *herrnop = NETDB_INTERNAL; if (parse_res == -1) return NSS_STATUS_TRYAGAIN; diff --git a/nis/nss_nisplus/nisplus-netgrp.c b/nis/nss_nisplus/nisplus-netgrp.c index 9c38539de8..967eec898c 100644 --- a/nis/nss_nisplus/nisplus-netgrp.c +++ b/nis/nss_nisplus/nisplus-netgrp.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "nss-nisplus.h" diff --git a/nis/nss_nisplus/nisplus-network.c b/nis/nss_nisplus/nisplus-network.c index 57362dba78..ff71af8573 100644 --- a/nis/nss_nisplus/nisplus-network.c +++ b/nis/nss_nisplus/nisplus-network.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "nss-nisplus.h" @@ -86,7 +85,7 @@ _nss_nisplus_parse_netent (nis_result *result, struct netent *network, { if (NISENTRYLEN (i, 1, result) + 2 > room_left) goto no_more_room; - + *p++ = ' '; p = stpncpy (p, NISENTRYVAL (i, 1, result), NISENTRYLEN (i, 1, result)); @@ -217,7 +216,7 @@ internal_nisplus_getnetent_r (struct netent *network, char *buffer, if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) { int retval; - + retval = niserr2nss (result->status); nis_freeresult (result); result = NULL; @@ -254,15 +253,15 @@ internal_nisplus_getnetent_r (struct netent *network, char *buffer, } } - if ((parse_res = _nss_nisplus_parse_netent (result, network, buffer, + if ((parse_res = _nss_nisplus_parse_netent (result, network, buffer, buflen)) == -1) { *herrnop = NETDB_INTERNAL; return NSS_STATUS_TRYAGAIN; } - + } while (!parse_res); - + return NSS_STATUS_SUCCESS; } @@ -301,7 +300,7 @@ _nss_nisplus_getnetbyname_r (const char *name, struct netent *network, { nis_result *result; char buf[strlen (name) + 255 + tablename_len]; - + /* Search at first in the alias list, and use the correct name for the next search */ sprintf(buf, "[name=%s],%s", name, tablename_val); @@ -390,7 +389,7 @@ _nss_nisplus_getnetbyaddr_r (const unsigned long addr, const int type, if (parse_res > 0) return NSS_STATUS_SUCCESS; - + *herrnop = NETDB_INTERNAL; if (parse_res == -1) return NSS_STATUS_TRYAGAIN; diff --git a/nis/nss_nisplus/nisplus-parser.c b/nis/nss_nisplus/nisplus-parser.c index 3d0ff32e57..db5f487159 100644 --- a/nis/nss_nisplus/nisplus-parser.c +++ b/nis/nss_nisplus/nisplus-parser.c @@ -212,20 +212,23 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry, room_left -= sizeof (char *); gr->gr_mem[count] = line; - while (*line != '\0' && *line != ',' && !isspace(*line)) + while (*line != '\0' && *line != ',' && !isspace (*line)) ++line; - if (line != gr->gr_mem[count]) + if (*line == ',' || isspace (*line)) { - if (*line != '\0') - { - *line = '\0'; + int is = isspace (*line); + + *line = '\0'; + if (is) + while (*line != '\0' && (*line == ',' || isspace (*line))) ++line; - } + else + ++line; ++count; } else - gr->gr_mem[count] = NULL; + gr->gr_mem[count+1] = NULL; } if (room_left < sizeof (char *)) goto no_more_room; @@ -241,7 +244,7 @@ _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp, { char *first_unused = buffer; size_t room_left = buflen; - + if (result == NULL) return 0; diff --git a/nis/nss_nisplus/nisplus-proto.c b/nis/nss_nisplus/nisplus-proto.c index 707a0e5296..ddfce86905 100644 --- a/nis/nss_nisplus/nisplus-proto.c +++ b/nis/nss_nisplus/nisplus-proto.c @@ -24,7 +24,6 @@ #include #include #include -#include #include "nss-nisplus.h" @@ -212,7 +211,7 @@ internal_nisplus_getprotoent_r (struct protoent *proto, char *buffer, else { nis_result *res; - + saved_res = result; res = nis_next_entry (tablename_val, &result->cookie); result = res; @@ -224,7 +223,7 @@ internal_nisplus_getprotoent_r (struct protoent *proto, char *buffer, } } - if ((parse_res = _nss_nisplus_parse_protoent (result, proto, buffer, + if ((parse_res = _nss_nisplus_parse_protoent (result, proto, buffer, buflen)) == -1) { nis_freeresult (result); @@ -346,10 +345,10 @@ _nss_nisplus_getprotobynumber_r (const int number, struct protoent *proto, if (parse_res == -1) return NSS_STATUS_TRYAGAIN; - + if (parse_res) return NSS_STATUS_SUCCESS; - + return NSS_STATUS_NOTFOUND; } } diff --git a/nis/nss_nisplus/nisplus-publickey.c b/nis/nss_nisplus/nisplus-publickey.c index 4c596b8ada..554da95754 100644 --- a/nis/nss_nisplus/nisplus-publickey.c +++ b/nis/nss_nisplus/nisplus-publickey.c @@ -25,7 +25,6 @@ #include #include #include -#include #ifdef HAVE_SECURE_RPC #include extern int xdecrypt (char *, char *); diff --git a/nis/nss_nisplus/nisplus-pwd.c b/nis/nss_nisplus/nisplus-pwd.c index 2c1fb19cab..e358b060e1 100644 --- a/nis/nss_nisplus/nisplus-pwd.c +++ b/nis/nss_nisplus/nisplus-pwd.c @@ -23,7 +23,6 @@ #include #include #include -#include #include "nss-nisplus.h" @@ -97,7 +96,7 @@ internal_nisplus_getpwent_r (struct passwd *pw, char *buffer, size_t buflen) do { nis_result *saved_res; - + if (result == NULL) { saved_res = NULL; @@ -123,7 +122,7 @@ internal_nisplus_getpwent_r (struct passwd *pw, char *buffer, size_t buflen) } } - if ((parse_res = _nss_nisplus_parse_pwent (result, pw, buffer, + if ((parse_res = _nss_nisplus_parse_pwent (result, pw, buffer, buflen)) == -1) { nis_freeresult (result); @@ -192,7 +191,7 @@ _nss_nisplus_getpwnam_r (const char *name, struct passwd *pw, if (parse_res) return NSS_STATUS_SUCCESS; - + return NSS_STATUS_NOTFOUND; } } @@ -227,7 +226,7 @@ _nss_nisplus_getpwuid_r (const uid_t uid, struct passwd *pw, if (parse_res == -1) return NSS_STATUS_TRYAGAIN; - + if (parse_res) return NSS_STATUS_SUCCESS; diff --git a/nis/nss_nisplus/nisplus-rpc.c b/nis/nss_nisplus/nisplus-rpc.c index b70c2ebbca..6682a7502a 100644 --- a/nis/nss_nisplus/nisplus-rpc.c +++ b/nis/nss_nisplus/nisplus-rpc.c @@ -24,7 +24,6 @@ #include #include #include -#include #include "nss-nisplus.h" @@ -225,7 +224,7 @@ internal_nisplus_getrpcent_r (struct rpcent *rpc, char *buffer, } } - if ((parse_res = _nss_nisplus_parse_rpcent (result, rpc, buffer, + if ((parse_res = _nss_nisplus_parse_rpcent (result, rpc, buffer, buflen)) == -1) { nis_freeresult (result); diff --git a/nis/nss_nisplus/nisplus-service.c b/nis/nss_nisplus/nisplus-service.c index 37042d9d13..e8a12145d3 100644 --- a/nis/nss_nisplus/nisplus-service.c +++ b/nis/nss_nisplus/nisplus-service.c @@ -24,7 +24,6 @@ #include #include #include -#include #include "nss-nisplus.h" @@ -205,7 +204,7 @@ internal_nisplus_getservent_r (struct servent *serv, char *buffer, do { nis_result *saved_res; - + if (result == NULL) { saved_res = NULL; diff --git a/nis/nss_nisplus/nisplus-spwd.c b/nis/nss_nisplus/nisplus-spwd.c index c7f1e2a567..507aa4bcad 100644 --- a/nis/nss_nisplus/nisplus-spwd.c +++ b/nis/nss_nisplus/nisplus-spwd.c @@ -23,7 +23,6 @@ #include #include #include -#include #include "nss-nisplus.h" #include "nisplus-parser.h" diff --git a/nis/rpcsvc/nis.h b/nis/rpcsvc/nis.h index b91ce19903..e24c7d05b3 100644 --- a/nis/rpcsvc/nis.h +++ b/nis/rpcsvc/nis.h @@ -767,7 +767,7 @@ typedef enum name_pos name_pos; #endif /* Prototypes, and extern declarations for the NIS library functions. */ -#include +#include #endif /* __NIS_RPCGEN_H */ /* EDIT_START */ diff --git a/nis/rpcsvc/nis.x b/nis/rpcsvc/nis.x index 625ed57f10..e68114c36b 100644 --- a/nis/rpcsvc/nis.x +++ b/nis/rpcsvc/nis.x @@ -28,7 +28,7 @@ % * Mountain View, California 94043 % */ -/* +/* * From 4.1 : @(#)nis.x 1.61 Copyright 1989 Sun Microsystems * * RPC Language Protocol description file for NIS Plus @@ -44,9 +44,9 @@ % * structures used by the NIS service. It includes the file nis_tags.h % * which defines the tag values. This allows the tags to change without % * having to change the nis.x file. -% * +% * % * NOTE : DO NOT EDIT THIS FILE! It is automatically generated when -% * rpcgen is run on the nis.x file. Note that there is a +% * rpcgen is run on the nis.x file. Note that there is a % * simple sed script to remove some unneeded lines. (See the % * Makefile target nis.h) % * @@ -118,11 +118,11 @@ enum nis_error { }; -/* +/* * Structure definitions for the parameters and results of the actual * NIS RPC calls. * - * This is the standard result (in the protocol) of most of the nis + * This is the standard result (in the protocol) of most of the nis * requests. */ @@ -136,11 +136,11 @@ struct nis_result { u_long cticks; /* Client ticks */ }; -/* - * A Name Service request - * This request is used to access the name space, ns_name is the name +/* + * A Name Service request + * This request is used to access the name space, ns_name is the name * of the object within the namespace and the object is it's value, for - * add/modify, a copy of the original for remove. + * add/modify, a copy of the original for remove. */ struct ns_request { @@ -148,7 +148,7 @@ struct ns_request { nis_object ns_object<1>; /* Optional Object (add/remove) */ }; -/* +/* * An information base request * This request includes the NIS name of the table we wish to search, the * search criteria in the form of attribute/value pairs and an optional @@ -168,7 +168,7 @@ struct ib_request { }; /* - * This argument to the PING call notifies the replicas that something in + * This argument to the PING call notifies the replicas that something in * a directory has changed and this is it's timestamp. The replica will use * the timestamp to determine if its resync operation was successful. */ @@ -177,8 +177,8 @@ struct ping_args { u_long stamp; /* timestamp of the transaction */ }; -/* - * These are the type of entries that are stored in the transaction log, +/* + * These are the type of entries that are stored in the transaction log, * note that modifications will appear as two entries, for names, they have * a "OLD" entry followed by a "NEW" entry. For entries in tables, there * is a remove followed by an add. It is done this way so that we can read @@ -196,13 +196,13 @@ enum log_entry_t { MOD_IBASE = 7, /* Entry was modified in information base */ UPD_STAMP = 8 /* Update timestamp (used as fenceposts) */ }; - + /* - * This result is returned from the name service when it is requested to + * This result is returned from the name service when it is requested to * dump logged entries from its transaction log. Information base updates * will have the name of the information base in the le_name field and * a canonical set of attribute/value pairs to fully specify the entry's - * 'name'. + * 'name'. */ struct log_entry { u_long le_time; /* Time in seconds */ @@ -218,7 +218,7 @@ struct log_result { netobj lr_cookie; /* Used by the dump callback */ log_entry lr_entries<>; /* zero or more entries */ }; - + struct cp_result { nis_error cp_status; /* Status of the checkpoint */ u_long cp_zticks; /* Service 'ticks' */ @@ -227,7 +227,7 @@ struct cp_result { /* * This structure defines a generic NIS tag list. The taglist contains - * zero or tags, each of which is a type and a value. (u_long). + * zero or tags, each of which is a type and a value. (u_long). * These are used to report statistics (see tag definitions below) * and to set or reset state variables. */ @@ -254,17 +254,17 @@ struct fd_args { struct fd_result { nis_error status; /* Status returned by function */ nis_name source; /* Source of this answer */ - opaque dir_data<>; /* Directory Data (XDR'ed) */ + opaque dir_data<>; /* Directory Data (XDR'ed) */ opaque signature<>; /* Signature of the source */ }; -/* +/* * What's going on here? Well, it's like this. When the service * is being compiled it wants to have the service definition specific * info included, and when the client is being compiled it wants that * info. This includes the appropriate file which was generated by - * make in the protocols directory (probably /usr/include/rpcsvc). + * make in the protocols directory (probably /usr/include/rpcsvc). */ #ifdef RPC_SVC %#include "nis_svc.h" @@ -296,10 +296,10 @@ program NIS_PROG { /* If fetch and optionally reset statistics */ nis_taglist NIS_STATUS(nis_taglist) = 14; - + /* Dump changes to directory since time in da_time */ log_result NIS_DUMPLOG(dump_args) = 15; - + /* Dump contents of directory named */ log_result NIS_DUMP(dump_args) = 16; @@ -314,16 +314,16 @@ program NIS_PROG { /* Send 'status changed' ping to replicates */ void NIS_PING(ping_args) = 20; - + /* Modify server behaviour (such as debugging) */ nis_taglist NIS_SERVSTATE(nis_taglist) = 21; - + /* Create a Directory */ nis_error NIS_MKDIR(nis_name) = 22; - + /* Remove a Directory */ nis_error NIS_RMDIR(nis_name) = 23; - + /* Update public keys of a directory object */ nis_error NIS_UPDKEYS(nis_name) = 24; } = 3; @@ -423,18 +423,18 @@ program NIS_PROG { %#endif % %/* Prototypes, and extern declarations for the NIS library functions. */ -%#include +%#include %#endif /* __NIS_RPCGEN_H */ %/* EDIT_START */ % %/* % * nis_3.h -% * +% * % * This file contains definitions that are only of interest to the actual % * service daemon and client stubs. Normal users of NIS will not include % * this file. % * -% * NOTE : This include file is automatically created by a combination +% * NOTE : This include file is automatically created by a combination % * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead % * and then remake this file. % */ diff --git a/nis/rpcsvc/nislib.h b/nis/rpcsvc/nislib.h deleted file mode 100644 index 73b3804e85..0000000000 --- a/nis/rpcsvc/nislib.h +++ /dev/null @@ -1,268 +0,0 @@ -/* Copyright (C) 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Thorsten Kukuk , 1997. - - 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 __RPCSVC_NISLIB_H__ -#define __RPCSVC_NISLIB_H__ - -#include - -__BEGIN_DECLS - -typedef const char *const_nis_name; - -/* nis_names: These functions are used to locate and manipulate all NIS+ - * objects except the NIS+ entry objects. - * - * nis_lookup (name, flags) resolves a NIS+ name and returns a copy of - * that object from a NIS+ server. - * const nis_name name: name of the object to be resolved - * u_long flags: logically ORing zero or more flags (FOLLOW_LINKS, - * HARD_LOOKUP, [NO_CACHE], MASTER_ONLY, EXPAND_NAME) - * - * nis_add (name, obj) adds objects to the NIS+ namespace. - * const nis_name name: fully qualified NIS+ name. - * const nis_object *obj: object members zo_name and zo_domain will be - * constructed from name. - * - * nis_remove (name, obj) removes objects from the NIS+ namespace. - * const nis_name name: fully qualified NIS+ name. - * const nis_object *obj: if not NULL, it is assumed to point to a copy - * of the object being removed. In this case, if - * the object on the server does not have the same - * object identifier as the object being passed, - * the operation will fail with the NIS_NOTSAMEOBJ - * error. - * - * nis_modify (name, obj) can change specific attributes of an object - * that already exists in the namespace. - */ -extern nis_result *nis_lookup __P ((const_nis_name name, u_long flags)); -extern nis_result *nis_add __P ((const_nis_name name, const nis_object *obj)); -extern nis_result *nis_remove __P ((const_nis_name name, - const nis_object *obj)); -extern nis_result *nis_modify __P ((const_nis_name name, - const nis_object *obj)); - -/* nis_tables: These functions are used to search and modify NIS+ tables. - * - * nis_list (table_name, flags, callback(table_name, obj, userdata), userdata) - * search a table in the NIS+ namespace. - * const nis_name table_name: indexed name ([xx=yy],table.dir) - * u_long flags: logically ORing one or more flags (FOLLOW_LINKS, - * [FOLLOW_PATH], HARD_LOOKUP, [ALL_RESULTS], [NO_CACHE], - * MASTER_ONLY, EXPAND_NAME, RETURN_RESULT) - * callback(): callback is an optional pointer to a function that will - * process the ENTRY type objects that are returned from the - * search. If this pointer is NULL, then all entries that match - * the search criteria are returned in the nis_result structure, - * otherwise this function will be called once for each - * entry returned. - * void *userdata: passed to callback function along with the returned - * entry object. - * - * nis_add_entry (table_name, obj, flags) will add the NIS+ object to the - * NIS+ table_name. - * const nis_name table_name - * const nis_object *obj - * u_long flags: 0, ADD_OVERWRITE, RETURN_RESULT - * - * nis_modify_entry (name, obj, flags) modifies an object identified by name. - * const nis_name name: object identifier - * const nis_object *obj: should point to an entry with the EN_MODIFIED - * flag set in each column that contains new - * information. - * u_long flags: 0, MOD_SAMEOBJ, RETURN_RESULT - * - * nis_remove_entry (table_name, obj, flags) removes a set of entries - * identified by table_name from the table. - * const nis_name table_name: indexed NIS+ name - * const nis_object *obj: if obj is non-null, it is presumed to point to - * a cached copy of the entry. When the removal is - * attempted, and the object that would be removed - * is not the same as the cached object pointed to - * by object then the operation will fail with an - * NIS_NOTSAMEOBJ error - * u_long flags: 0, REM_MULTIPLE - * - * nis_first_entry (table_name) fetches entries from a table one at a time. - * const nis_name table_name - * - * nis_next_entry (table_name, cookie) retrieves the "next" entry from a - * table specified by table_name. - * const nis_name table_name: - * const netobj *cookie: The value of cookie from the nis_result structure - * form the previous call. - */ -extern nis_result *nis_list __P ((const_nis_name name, u_long flags, - int (*callback)(const_nis_name table_name, - const nis_object *obj, - const void *userdata), - const void *userdata)); -extern nis_result *nis_add_entry __P ((const_nis_name table_name, - const nis_object *obj, u_long flags)); -extern nis_result *nis_modify_entry __P ((const_nis_name name, - const nis_object *obj, - u_long flags)); -extern nis_result *nis_remove_entry __P ((const_nis_name table_name, - const nis_object *obj, - u_long flags)); -extern nis_result *nis_first_entry __P ((const_nis_name table_name)); -extern nis_result *nis_next_entry __P ((const_nis_name table_name, - const netobj *cookie)); -/* -** nis_server -*/ -extern nis_error nis_mkdir __P ((const_nis_name dirname, - const nis_server *machine)); -extern nis_error nis_rmdir __P ((const_nis_name dirname, - const nis_server *machine)); -extern nis_error nis_servstate __P ((const nis_server *machine, - const nis_tag *tags, int numtags, - nis_tag **result)); -extern nis_error nis_stats __P ((const nis_server *machine, - const nis_tag *tags, int numtags, - nis_tag **result)); -extern void nis_freetags __P ((nis_tag *tags, int numtags)); -extern nis_server **nis_getservlist __P ((const_nis_name dirname)); -extern void nis_freeservlist __P ((nis_server **machines)); - -/* -** nis_subr -*/ -extern nis_name nis_leaf_of __P ((const_nis_name name)); -extern nis_name nis_leaf_of_r __P ((const_nis_name name, char *buffer, - size_t buflen)); -extern nis_name nis_name_of __P ((const_nis_name name)); -extern nis_name nis_name_of_r __P ((const_nis_name name, char *buffer, - size_t buflen)); -extern nis_name nis_domain_of __P ((const_nis_name name)); -extern nis_name nis_domain_of_r __P ((const_nis_name name, char *buffer, - size_t buflen)); -extern nis_name *nis_getnames __P ((const_nis_name name)); -extern void nis_freenames __P ((nis_name *namelist)); -extern name_pos nis_dir_cmp __P ((const_nis_name n1, const_nis_name n2)); -extern nis_object *nis_clone_object __P ((const nis_object *src, - nis_object *dest)); -extern void nis_destroy_object __P ((nis_object *obj)); -extern void nis_print_object __P ((const nis_object *obj)); - -/* -** nis_local_names -*/ -extern nis_name nis_local_group __P ((void)); -extern nis_name nis_local_directory __P ((void)); -extern nis_name nis_local_principal __P ((void)); -extern nis_name nis_local_host __P ((void)); - -/* -** nis_error -*/ -extern const char *nis_sperrno __P ((const nis_error status)); -extern void nis_perror __P ((const nis_error status, const char *label)); -extern void nis_lerror __P ((const nis_error status, const char *label)); -extern char *nis_sperror __P ((const nis_error status, const char *label)); -extern char *nis_sperror_r __P ((const nis_error status, const char *label, - char *buffer, size_t buflen)); -/* -** nis_groups -*/ -extern bool_t nis_ismember __P ((const_nis_name principal, - const_nis_name group)); -extern nis_error nis_addmember __P ((const_nis_name member, - const_nis_name group)); -extern nis_error nis_removemember __P ((const_nis_name member, - const_nis_name group)); -extern nis_error nis_creategroup __P ((const_nis_name group, u_long flags)); -extern nis_error nis_destroygroup __P ((const_nis_name group)); -extern void nis_print_group_entry __P ((const_nis_name group)); -extern nis_error nis_verifygroup __P ((const_nis_name group)); - -/* -** nis_ping -*/ -extern void nis_ping __P ((const_nis_name dirname, u_long utime, - const nis_object *dirobj)); -extern nis_result *nis_checkpoint __P ((const_nis_name dirname)); - -/* -** nis_print (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) -*/ -extern void nis_print_result __P ((const nis_result *result)); -extern void nis_print_rights __P ((u_long rights)); -extern void nis_print_directory __P ((const directory_obj *dirobj)); -extern void nis_print_group __P ((const group_obj *grpobj)); -extern void nis_print_table __P ((const table_obj *tblobj)); -extern void nis_print_link __P ((const link_obj *lnkobj)); -extern void nis_print_entry __P ((const entry_obj *enobj)); - -/* -** nis_file (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) -*/ -extern directory_obj *readColdStartFile __P ((void)); -extern bool_t writeColdStartFile __P ((const directory_obj *dirobj)); -extern nis_object *nis_read_obj __P ((const char *obj)); -extern bool_t nis_write_obj __P ((const char *file, const nis_object *obj)); - -/* -** nis_clone - (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) -*/ -extern directory_obj *nis_clone_directory __P ((const directory_obj *src, - directory_obj *dest)); -extern group_obj *nis_clone_group __P ((const group_obj *src, - group_obj *dest)); -extern table_obj *nis_clone_table __P ((const table_obj *src, - table_obj *dest)); -extern entry_obj *nis_clone_entry __P ((const entry_obj *src, - entry_obj *dest)); -extern link_obj *nis_clone_link __P ((const link_obj *src, link_obj *dest)); -extern objdata *nis_clone_objdata __P ((const objdata *src, objdata *dest)); -extern nis_result *nis_clone_result __P ((const nis_result *src, - nis_result *dest)); - -/* nis_free - nis_freeresult */ -extern void nis_freeresult __P ((nis_result *result)); -/* (XXX THE FOLLOWING ARE INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */ -extern void nis_free_attr __P ((nis_attr *attr)); -extern void nis_free_request __P ((ib_request *req)); -extern void nis_free_endpoints __P ((endpoint *ep, unsigned int count)); -extern void nis_free_servers __P ((nis_server *machine, unsigned int count)); -extern void nis_free_directory __P ((directory_obj *dirobj)); -extern void nis_free_group __P ((group_obj *grpobj)); -extern void nis_free_table __P ((table_obj *tblobj)); -extern void nis_free_entry __P ((entry_obj *enobj)); -extern void nis_free_link __P ((link_obj *lnkobj)); -extern void nis_free_object __P ((nis_object *obj)); - -/* (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */ -extern nis_name __nis_default_owner __P ((char *)); -extern nis_name __nis_default_group __P ((char *)); -extern u_long __nis_default_ttl __P ((char *)); -extern u_long __nis_default_access __P ((char *, u_long)); -extern fd_result *__nis_finddirectory __P ((directory_obj *, const_nis_name)); -extern u_long __nis_hash __P ((const void *keyarg, register size_t len)); -extern log_result *__nis_dumplog __P ((nis_server *,nis_name, u_long)); -extern log_result *__nis_dump __P ((nis_server *, nis_name, - int (*)(nis_name, nis_object *, void *))); -/* NIS+ cache locking */ -extern int __nis_lock_cache __P ((void)); -extern int __nis_unlock_cache __P ((void)); - -__END_DECLS - -#endif /* __RPCSVC_NISLIB_H__ */ diff --git a/posix/wordexp.c b/posix/wordexp.c index 52869fe1d3..b204f653b5 100644 --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -1,5 +1,7 @@ -/* Copyright (C) 1992, 1997 Free Software Foundation, Inc. +/* POSIX.2 wordexp implementation. + Copyright (C) 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. + Contributed by Tim Waugh . 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 @@ -16,170 +18,1558 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include #include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -/* We do word expansion with a pipe to the shell. - The shell command `sh [-P] [-u] -w "words ..."' expands words. - If -P, command substitution is an error. - If -u, reference to an undefined variable is an error. - The shell writes on its stdout: - %u\0 Number of words. - %u\0 Number of bytes in all words together (not counting \0s). - word1\0 - word2\0 - ... - wordN\0 +/* + * This is a recursive-descent-style word expansion routine. + */ + +/* Some forward declarations */ +static int +parse_dollars (char **word, size_t *word_length, const char *words, + size_t *offset, int flags, wordexp_t *pwordexp); +static int +parse_backtick (char **word, size_t *word_length, const char *words, + size_t *offset, int flags, wordexp_t *pwordexp); + +static int +eval_expr (char *expr, int *result); + +/* The w_*() unctions manipulate word lists. */ + +static char* +w_extend (char *word, size_t *word_length, size_t by) +{ + /* Extend the allocated size of word by 'by' characters + * (from *word_length). */ + char* newword; + size_t new_length; -#define SHELL_PATH "/bin/sh" -#define SHELL_NAME "sh" + if (word == NULL) + *word_length = 0; + new_length = *word_length + by; + newword = realloc (word, 1 + new_length); + if (newword != NULL) + { + *word_length = new_length; -int -wordexp (string, pwordexp, flags) - const char *string; - wordexp_t *pwordexp; - int flags; + newword[*word_length] = 0; + } + return newword; +} + +static char* +w_addstr (char *word, size_t *word_length, const char *str) +{ + /* Add a string to 'word', allocating room for it. + */ + char* newword; + size_t new_length; + + if (word == NULL) + *word_length = '\0'; + + new_length = *word_length + strlen (str); + newword = realloc (word, 1 + new_length); + if (newword != NULL) + { + strcpy (&newword[*word_length], str); + *word_length = new_length; + } + return newword; +} + +static inline char* +w_addchar (char *word, size_t *word_length, char ch) +{ + /* Add a character to 'word', allocating room for it. + */ + char* newword = w_extend (word, word_length, 1); + + if (newword != NULL) + newword[*word_length - 1] = ch; + return newword; +} + +static int +w_addword (wordexp_t *pwordexp, char *word) +{ + /* Add a word to the wordlist */ + size_t num_p; + + num_p = 2 + pwordexp->we_wordc + pwordexp->we_offs; + pwordexp->we_wordv = realloc (pwordexp->we_wordv, sizeof (char *) * num_p); + if (pwordexp->we_wordv != NULL) + { + pwordexp->we_wordv[pwordexp->we_wordc++] = word; + pwordexp->we_wordv[pwordexp->we_wordc] = NULL; + return 0; + } + + return WRDE_NOSPACE; +} + +/* The parse_*() functions should leave *offset being the offset in 'words' + * to the last character processed. + */ + +static int +parse_backslash (char **word, size_t *word_length, const char *words, + size_t *offset) +{ + /* We are poised _at_ a backslash, not in quotes */ + + switch (words[1 + *offset]) + { + case 0: + /* Backslash is last character of input words */ + return WRDE_SYNTAX; + + case '\n': + ++(*offset); + break; + + default: + *word = w_addchar (*word, word_length, words[1 + *offset]); + if (*word == NULL) + return WRDE_NOSPACE; + + ++(*offset); + break; + } + + return 0; +} + +static int +parse_qtd_backslash (char **word, size_t *word_length, const char *words, + size_t *offset) +{ + /* We are poised _at_ a backslash, inside quotes */ + + switch (words[1 + *offset]) + { + case 0: + /* Backslash is last character of input words */ + return WRDE_SYNTAX; + + case '\n': + ++(*offset); + break; + + case '$': + case '`': + case '"': + case '\\': + *word = w_addchar (*word, word_length, words[1 + *offset]); + if (*word == NULL) + return WRDE_NOSPACE; + + (*offset)++; + break; + + default: + *word = w_extend (*word, word_length, 2); + if (*word == NULL) + return WRDE_NOSPACE; + + (*word)[*word_length - 1] = words[1 + *offset]; + (*word)[*word_length - 2] = words[*offset]; + (*offset)++; + break; + } + + return 0; +} + +static int +parse_tilde (char **word, size_t *word_length, const char *words, + size_t *offset, size_t wordc) +{ + /* We are poised _at_ a tilde */ + int i; + + if (*word_length != 0) + { + if (!((*word)[*word_length - 1] == '=' && wordc == 0)) + { + if (!((*word)[*word_length - 1] == ':' && + strchr(*word, '=') && wordc == 0)) + { + *word = w_addchar (*word, word_length, '~'); + return *word ? 0 : WRDE_NOSPACE; + } + } + } + + for (i = 1 + *offset; words[i]; i++) + { + if (words[i] == ':' || words[i] == '/' || words[i] == ' ' || + words[i] == '\t' || words[i] == 0 ) + break; + + if (words[i] == '\\') + { + *word = w_addchar (*word, word_length, '~'); + return *word ? 0 : WRDE_NOSPACE; + } + } + + if (i == 1 + *offset) + { + /* Tilde appears on its own */ + uid_t uid; + struct passwd pwd, *tpwd; + int buflen = 1000; + char* buffer = __alloca (buflen); + int result; + + uid = getuid (); + + while ((result = __getpwuid_r (uid, pwd, buffer, buflen, &tpwd)) != 0 + && errno == ERANGE) + { + buflen += 1000; + buffer = __alloca (buflen); + } + + if (result == 0 && pwd.pw_dir != NULL) + { + *word = w_addstr (*word, word_length, pwd.pw_dir); + if (*word == NULL) + return WRDE_NOSPACE; + } + else + { + *word = w_addchar (*word, word_length, '~'); + if (*word == NULL) + return WRDE_NOSPACE; + } + } + else + { + /* Look up user name in database to get home directory */ + uid_t uid; + char *user = strndup (&words[1 + *offset], i - *offset); + struct passwd pwd, *tpwd; + int buflen = 1000; + char* buffer = __alloca (buflen); + int result; + + while ((result = __getpwnam_r (uid, pwd, buffer, buflen, &tpwd)) != 0 + && errno == ERANGE) + { + buflen += 1000; + buffer = __alloca (buflen); + } + + if (result == 0 && pwd.pw_dir) + *word = w_addstr (*word, word_length, pwd.pw_dir); + else + { + /* (invalid login name) */ + *word = w_addchar (*word, word_length, '~'); + if (*word != NULL) + *word = w_addstr (*word, word_length, user); + } + + *offset = i - 1; + } + return *word ? 0 : WRDE_NOSPACE; +} + +static int +parse_glob (char **word, size_t *word_length, const char *words, + size_t *offset, int flags, wordexp_t *pwordexp, char *ifs) +{ + /* We are poised just after a '*' or a '{'. */ + int error; + glob_t globbuf; + int match; + char * matching_word; + + for (; words[*offset]; (*offset)++) + switch (words[*offset]) + { + case ' ': + case '\t': + break; + + case '$': + error = parse_dollars (word, word_length, words, offset, flags, + pwordexp); + if (error) + return error; + + continue; + + default: + if (ifs == NULL || strchr (ifs, words[*offset]) == NULL) + { + *word = w_addchar (*word, word_length, words[*offset]); + if (*word == NULL) + return WRDE_NOSPACE; + + continue; + } + + break; + } + + error = glob (*word, GLOB_NOCHECK, NULL, &globbuf); + + if (error != 0) + { + /* We can only run into memory problems. */ + assert (error == GLOB_NOSPACE); + + return WRDE_NOSPACE; + } + + if (ifs && !*ifs) + { + /* No field splitting allowed */ + *word_length = strlen (globbuf.gl_pathv[0]); + *word = realloc (*word, 1 + *word_length); + if (*word == NULL) + goto no_space; + + strcpy (*word, globbuf.gl_pathv[0]); + + for (match = 1; match < globbuf.gl_pathc; ++match) + { + *word = w_addchar (*word, word_length, ' '); + if (*word != NULL) + *word = w_addstr (*word, word_length, globbuf.gl_pathv[match]); + } + + /* Re-parse white space on return */ + globfree (&globbuf); + --(*offset); + return *word ? 0 : WRDE_NOSPACE; + } + + /* here ifs != "" */ + free (*word); + *word = NULL; + *word_length = 0; + + matching_word = malloc (1 + strlen (globbuf.gl_pathv[0])); + if (matching_word == NULL) + goto no_space; + + strcpy (matching_word, globbuf.gl_pathv[0]); + if (w_addword (pwordexp, matching_word) == WRDE_NOSPACE) + goto no_space; + + for (match = 1; match < globbuf.gl_pathc; ++match) + { + matching_word = malloc (1 + strlen (globbuf.gl_pathv[match])); + if (matching_word == NULL) + goto no_space; + + strcpy (matching_word, globbuf.gl_pathv[match]); + if (w_addword (pwordexp, matching_word) == WRDE_NOSPACE) + goto no_space; + } + + globfree (&globbuf); + + /* Re-parse white space on return */ + --(*offset); + return 0; + +no_space: + globfree (&globbuf); + return WRDE_NOSPACE; +} + +static int +parse_squote (char **word, size_t *word_length, const char *words, + size_t *offset) +{ + /* We are poised just after a single quote */ + for (; words[*offset]; ++(*offset)) + { + if (words[*offset] != '\'') + { + *word = w_addchar (*word, word_length, words[*offset]); + if (*word == NULL) + return WRDE_NOSPACE; + } + else return 0; + } + + /* Unterminated string */ + return WRDE_SYNTAX; +} + +/* Functions to evaluate an arithmetic expression */ +static int +eval_expr_val (char **expr, int *result) { + int sgn = +1; + char *digit; + + /* Skip white space */ + for (digit = *expr; digit && *digit && isspace (*digit); ++digit); + + switch (*digit) + { + case '(': + + /* Scan for closing paren */ + for (++digit; **expr && **expr != ')'; ++(*expr)); + + /* Is there one? */ + if (!**expr) + return WRDE_SYNTAX; + + *(*expr)++ = 0; + + if (eval_expr(digit, result)) + return WRDE_SYNTAX; + + return 0; + + case '+': /* Positive value */ + ++digit; + break; + + case '-': /* Negative value */ + ++digit; + sgn = -1; + break; + + default: + if (!isdigit (*digit)) + return WRDE_SYNTAX; + } + + *result = 0; + for (; *digit && isdigit(*digit); ++digit) + *result = (*result * 10) + (*digit - '0'); + + *expr = digit; + *result *= sgn; + return 0; +} + +static int +eval_expr_multdiv (char **expr, int *result) +{ + int arg; + + /* Read a Value */ + if (eval_expr_val (expr, result)) + return WRDE_SYNTAX; + + while (**expr) + { + /* Skip white space */ + for (; *expr && **expr && isspace (**expr); ++(*expr)); + + if (**expr == '*') + { + (*expr)++; + if ((eval_expr_val (expr, &arg)) != 0) + return WRDE_SYNTAX; + + *result *= arg; + } + else if (**expr == '/') + { + (*expr)++; + if ((eval_expr_val (expr, &arg)) != 0) + return WRDE_SYNTAX; + + *result /= arg; + } + else break; + } + + return 0; +} + +static int +eval_expr (char *expr, int *result) +{ + int arg; + + /* Read a Multdiv */ + if ((eval_expr_multdiv (&expr, result)) != 0) + return WRDE_SYNTAX; + + while (*expr) + { + /* Skip white space */ + for (; expr && *expr && isspace (*expr); ++expr); + + if (*expr == '+') + { + expr++; + if ((eval_expr_multdiv (&expr, &arg)) != 0) + return WRDE_SYNTAX; + + *result += arg; + } + else if (*expr == '-') + { + expr++; + if ((eval_expr_multdiv (&expr, &arg)) != 0) + return WRDE_SYNTAX; + + *result -= arg; + } + else break; + } + + return 0; +} + +static int +parse_arith (char **word, size_t *word_length, const char *words, + size_t *offset, int flags, int bracket) +{ + /* We are poised just after "$((" or "$[" */ int error; + int paren_depth = 1; + size_t expr_length = 0; + char *expr = calloc (1, sizeof (char)); /* ??? */ + + if (expr == NULL) + return WRDE_NOSPACE; + + for (; words[*offset]; ++(*offset)) + { + switch (words[*offset]) + { + case '$': + error = parse_dollars (&expr, &expr_length, + words, offset, flags, NULL); + /* The NULL here is to tell parse_dollars not to + * split the fields. + */ + if (error) + { + free (expr); + return error; + } + break; + + case '`': + (*offset)++; + error = parse_backtick (&expr, &expr_length, + words, offset, flags, NULL); + /* The NULL here is to tell parse_backtick not to + * split the fields. + */ + if (error) + { + free (expr); + return error; + } + break; + + case '\\': + error = parse_qtd_backslash (&expr, &expr_length, words, offset); + if (error) + { + free (expr); + return error; + } + /* I think that a backslash within an + * arithmetic expansion is bound to + * cause an error sooner or later anyway though. + */ + break; + + case ')': + if (--paren_depth == 0) + { + char *result; + int numresult = 0; + + if (bracket || words[1 + *offset] != ')') + return WRDE_SYNTAX; + + ++(*offset); + + /* Go - evaluate. */ + if (*expr && + eval_expr (expr, &numresult) != 0) + return WRDE_SYNTAX; + + result = __alloca (100); + __snprintf (result, 100, "%d", numresult); + *word = w_addstr (*word, word_length, result); + free (expr); + return *word ? 0 : WRDE_NOSPACE; + } + expr = w_addchar (expr, &expr_length, words[*offset]); + if (expr == NULL) + return WRDE_NOSPACE; + + break; + + case ']': + if (bracket && paren_depth == 1) + { + char *result; + int numresult = 0; + + /* Go - evaluate. */ + if (*expr && eval_expr (expr, &numresult) != 0) + return WRDE_SYNTAX; + + result = __alloca (100); + __snprintf (result, 100, "%d", numresult); + *word = w_addstr (*word, word_length, result); + free (expr); + return *word ? 0 : WRDE_NOSPACE; + } + + free (expr); + return WRDE_SYNTAX; + + case '\n': + case ';': + case '{': + case '}': + free (expr); + return WRDE_BADCHAR; + + case '(': + ++paren_depth; + default: + expr = w_addchar (expr, &expr_length, words[*offset]); + if (expr == NULL) + return WRDE_NOSPACE; + } + } + + /* Premature end */ + free (expr); + return WRDE_SYNTAX; +} + +/* Function to execute a command and retrieve the results */ +/* pwordexp contains NULL if field-splitting is forbidden */ +static int +exec_comm (char *comm, char **word, size_t *word_length, int flags, + wordexp_t *pwordexp) +{ + int fildes[2]; + int bufsize = 128; + int buflen; + int state = 0; + int i; + char *sh, *buffer; pid_t pid; - int d[2]; - int status; + /* 'state' is: + * 0 until first non-(whitespace-ifs) + * 1 after a non-ifs + * 2 after non-(whitespace-ifs) + */ - FILE *f; - size_t wordc, start, buflen; - char *buf; + /* Don't fork() unless necessary */ + if (!comm || !*comm) + return 0; - /* Create the pipe through which we will communicate to the shell. */ - if (pipe (d) < 0) - return -1; + if (pipe (fildes)) + /* Bad */ + return WRDE_NOSPACE; - pid = fork (); - if (pid < 0) - return -1; + if ((pid = fork ()) < 0) + { + /* Bad */ + return WRDE_NOSPACE; + } if (pid == 0) { - /* Child. Run the shell. */ + /* Child */ + /* Redirect input and output */ + dup2 (fildes[1], 1); - const char *argv[5]; + /* Close stderr if we have to */ + if ((flags & WRDE_SHOWERR) == 0) + close (2); - close (d[STDIN_FILENO]); - dup2 (d[STDOUT_FILENO], STDOUT_FILENO); - if (!(flags & WRDE_SHOWERR)) - close (STDERR_FILENO); + execl (_PATH_BSHELL, _PATH_BSHELL, "-c", comm, NULL); + /* Bad */ + exit (1); + } - i = 0; - argv[i++] = SHELL_NAME; - if (flags & WRDE_NOCMD) - argv[i++] = "-P"; - if (flags & WRDE_UNDEF) - argv[i++] = "-u"; - argv[i++] = "-w"; - argv[i++] = string; - argv[i++] = NULL; + /* Parent */ + + close (fildes[1]); + buffer = __alloca (bufsize); - execv (SHELL_PATH, argv); - _exit (WRDE_NOSPACE); + if (!pwordexp) + { /* Quoted - no field splitting */ + + while (1) + { + if ((buflen = read (fildes[0], buffer, bufsize)) < 1) + { + if (waitpid (pid, NULL, WNOHANG) == 0) + continue; + if ((buflen = read (fildes[0], buffer, bufsize)) < 1) + break; + } + + for (i = 0; i < buflen; ++i) + { + *word = w_addchar (*word, word_length, buffer[i]); + if (*word == NULL) + { + close (fildes[0]); + return WRDE_NOSPACE; + } + } + } + + close (fildes[0]); + return 0; } - /* Parent. */ + /* Not quoted - split fields. + * NB. This isn't done properly yet. + */ + while (1) + { + if ((buflen = read (fildes[0], buffer, bufsize)) < 1) + { + if (waitpid (pid, NULL, WNOHANG) == 0) + continue; + if ((read (fildes[0], buffer, bufsize)) < 1) + break; + } - buf = NULL; - error = WRDE_NOSPACE; + for (i = 0; i < buflen; ++i) + { + /* What if these aren't field separators? FIX */ + if ((buffer[i] == ' ') || (buffer[i] == '\t') || (buffer[i] == '\n')) + { + if (state != 0) + state = 2; + continue; + } - close (d[STDOUT_FILENO]); - f = fdopen (d[STDIN_FILENO]); - if (f == NULL) - goto lose; + if (state == 2) + { + /* End of word */ + if (w_addword (pwordexp, *word) == WRDE_NOSPACE) + { + close (fildes[0]); + return WRDE_NOSPACE; + } - /* Read the number of words and number of bytes from the shell. */ - if (fscanf (f, "%u", &wordc) != 1 || getc (f) != '\0' || - fscanf (f, "%u", &buflen) != 1 || getc (f) != '\0') - goto lose; + *word = NULL; + *word_length = 0; + } - /* Read the words from the shell, and wait for it to return. */ - buflen += wordc; - buf = malloc (buflen); - if (buf == NULL || - fread (buf, buflen, 1, f) != 1 || - waitpid (pid, &status, 0) != pid) - goto lose; + state = 1; + *word = w_addchar (*word, word_length, buffer[i]); + if (*word == NULL) + { + close (fildes[0]); + return WRDE_NOSPACE; + } + } + } - if (WIFEXITED (status)) + close (fildes[0]); + return 0; +} + +static int +parse_comm (char **word, size_t *word_length, const char *words, + size_t *offset, int flags, wordexp_t *pwordexp) +{ + /* We are poised just after "$(" */ + int paren_depth = 1; + int error; + size_t comm_length = 0; + char *comm = calloc (1, sizeof (char)); /* ??? */ + + if (comm == NULL) + return WRDE_NOSPACE; + + for (; words[*offset]; ++(*offset)) { - if (WEXITSTATUS (status) != 0) + switch (words[*offset]) { - error = WEXITSTATUS (status); - goto lose; + case ')': + if (--paren_depth == 0) + { + /* Go -- give script to the shell */ + error = exec_comm (comm, word, word_length, flags, pwordexp); + free (comm); + return error; + } + + /* This is just part of the script */ + comm = w_addchar (comm, &comm_length, words[*offset]); + if (comm == NULL) + return WRDE_NOSPACE; + + break; + + case '(': + paren_depth++; + default: + comm = w_addchar (comm, &comm_length, words[*offset]); + if (comm == NULL) + return WRDE_NOSPACE; + + break; } } - else - goto lose; - /* Pack the structure. */ + /* Premature end */ + free (comm); + return WRDE_SYNTAX; +} - start = 0; - if (flags & WRDE_DOOFFS) - start += pwordexp->we_offs; - if (flags & WRDE_APPEND) - start += pwordexp->we_wordc; - wordc = start + wordc + 1; - - if (flags & WRDE_APPEND) - wordv = (char **) realloc ((void *) pwordexp->we_wordv, - wordc * sizeof (char *)); +static int +parse_param (char **word, size_t *word_length, const char *words, + size_t *offset, int flags, wordexp_t *pwordexp) +{ + /* We are poised just after "$" */ + size_t start = *offset; + size_t env_length = 0; + size_t pat_length = 0; + char *env = calloc (1, sizeof (char)); /* ??? */ + char *pattern = calloc (1, sizeof (char)); /* ??? */ + char *value; + char action = 0; + int prefix = 0; + int suffix = 0; + int colon_seen = 0; + int depth = 0; + int error; + + if ((env == NULL) || (pattern == NULL)) + return WRDE_NOSPACE; + + for (; words[*offset]; ++(*offset)) + { + switch (words[*offset]) + { + case '{': + if (action || prefix || suffix) + { + ++depth; + pattern = w_addchar (pattern, &pat_length, words[*offset]); + if (pattern == NULL) + goto no_space; + + break; + } + + if (*offset == start) + break; + /* Otherwise evaluate */ + /* (and re-parse this character) */ + --(*offset); + goto envsubst; + + case '}': + if (words[start] != '{') + { + --(*offset); + } + + if (action || prefix || suffix) + { + if (--depth) + { + pattern = w_addchar (pattern, &pat_length, words[*offset]); + if (pattern == NULL) + goto no_space; + + break; + } + } + + /* Evaluate */ + goto envsubst; + + case '#': + case '%': + if (words[start] == '{') + { + /* At the start? (ie. 'string length') */ + if (*offset == start + 1) + break; + + /* Separating variable name from prefix pattern? */ + if (words[*offset] == '#') + { + if ((prefix < 2) && (!suffix)) + { + ++prefix; + break; + } + } + else + { + if ((suffix < 2) && (!prefix)) + { + ++suffix; + break; + } + } + + /* Must be part of prefix/suffix pattern. */ + pattern = w_addchar (pattern, &pat_length, words[*offset]); + if (pattern == NULL) + goto no_space; + + break; + } + /* Otherwise evaluate */ + /* (and re-parse this character) */ + --(*offset); + goto envsubst; + + case ':': + if (!*env) + { + free (env); + free (pattern); + return WRDE_SYNTAX; + } + + if (action || prefix || suffix) + { + pattern = w_addchar (pattern, &pat_length, words[*offset]); + if (pattern == NULL) + goto no_space; + + break; + } + + if ((words[1 + *offset] == '-') || (words[1 + *offset] == '=') || + (words[1 + *offset] == '?') || (words[1 + *offset] == '+')) + { + colon_seen = 1; + break; + } + + free (env); + free (pattern); + return WRDE_SYNTAX; + + case '-': + case '=': + case '?': + case '+': + if (!*env) + { + free (env); + free (pattern); + return WRDE_SYNTAX; + } + + if (action || prefix || suffix) + { + pattern = w_addchar (pattern, &pat_length, words[*offset]); + if (pattern == NULL) + { + free (env); + return WRDE_NOSPACE; + } + + break; + } + + action = words[*offset]; + break; + + case '\\': + if (action || prefix || suffix) + { + error = parse_qtd_backslash (word, word_length, words, offset); + if (error == 0) + break; + } + else + { + error = WRDE_SYNTAX; + } + + free (env); + free (pattern); + return error; + + default: + if (action || prefix || suffix) + { + pattern = w_addchar (pattern, &pat_length, words[*offset]); + if (pattern == NULL) + goto no_space; + + break; + } + + if ((words[start] == '{') || isalpha (words[*offset])) + { + env = w_addchar (env, &env_length, words[*offset]); + if (env == NULL) + goto no_space; + + break; + } + + --(*offset); + goto envsubst; + } + } + + /* End of input string */ + --(*offset); + +envsubst: + if (words[start] == '{' && words[*offset] != '}') + { + free (env); + free (pattern); + return WRDE_SYNTAX; + } + + if (!env || !*env) + { + *offset = start - 1; + *word = w_addchar (*word, word_length, '$'); + free (env); + free (pattern); + return *word ? 0 : WRDE_NOSPACE; + } + + value = getenv (env); + + if (action || prefix || suffix) + { + switch (action) + { + case 0: + /* For the time being, pattern is ignored */ + printf ("Pattern: %s\nPrefix: %d\nSuffix: %d\n", pattern, prefix, suffix); + break; + + case '?': + if (value && *value) + break; + + if (!colon_seen && value) + { + /* Substitute NULL */ + free (env); + free (pattern); + return 0; + } + + /* Error - exit */ + fprintf (stderr, "%s: ", env); + + if (*pattern) + { + /* Expand 'pattern' and write it to stderr */ + wordexp_t we; + + error = wordexp (pattern, &we, flags); + + if (error == 0) + { + int i; + + for (i = 0; i < we.we_wordc; ++i) + { + fprintf (stderr, "%s%s", i ? " " : "", we.we_wordv[i]); + } + + fprintf (stderr, "\n"); + error = WRDE_BADVAL; + } + + wordfree (&we); + free (env); + free (pattern); + return error; + } + + fprintf (stderr, "parameter null or not set\n"); + free (env); + free (pattern); + return WRDE_BADVAL; + + default: + printf ("warning: parameter substitution does not yet support \"%s%c\"\n", colon_seen?":":"", action); + } + } + + free (env); + free (pattern); + + if (!value) + { + /* Variable not defined */ + if (flags & WRDE_UNDEF) + return WRDE_SYNTAX; + + return 0; + } + + if (!pwordexp) + /* Quoted - no field split */ + *word = w_addstr (*word, word_length, value); else - wordv = (char **) malloc (wordc * sizeof (char *)); - if (wordv == NULL) - goto lose; + /* Should field-split here - FIX */ + *word = w_addstr (*word, word_length, value); - if (flags & WRDE_DOOFFS) - for (i = 0; i < pwordexp->we_offs; ++i) - wordv[i] = NULL; + return *word ? 0 : WRDE_NOSPACE; + +no_space: + if (env) + free (env); + + if (pattern) + free (pattern); - for (i = start; i < wordc; ++i) + return WRDE_NOSPACE; +} + +static int +parse_dollars (char **word, size_t *word_length, const char *words, + size_t *offset, int flags, wordexp_t *pwordexp) +{ + /* We are poised _at_ "$" */ + switch (words[1 + *offset]) { - pwordexp->we_wordv[i] = buf; - buf = strchr (buf, '\0') + 1; + case '"': + case '\'': + case 0: + *word = w_addchar (*word, word_length, '$'); + return *word ? 0 : WRDE_NOSPACE; + + case '(': + if (words[2 + *offset] == '(') + { + (*offset) += 3; + /* Call parse_arith -- 0 is for "no brackets" */ + return parse_arith (word, word_length, words, offset, flags, 0); + } + + if (flags & WRDE_NOCMD) + return WRDE_CMDSUB; + + (*offset) += 2; + return parse_comm (word, word_length, words, offset, flags, pwordexp); + + case '[': + (*offset) += 2; + /* Call parse_arith -- 1 is for "brackets" */ + return parse_arith (word, word_length, words, offset, flags, 1); + + case '{': + default: + ++(*offset); /* parse_param needs to know if "{" is there */ + return parse_param (word, word_length, words, offset, flags, pwordexp); } - wordv[i] = NULL; +} - if (flags & WRDE_REUSE) +static int +parse_backtick (char **word, size_t *word_length, const char *words, + size_t *offset, int flags, wordexp_t *pwordexp) +{ + /* We are poised just after "`" */ + int error; + size_t comm_length = 0; + char *comm = calloc (1, sizeof (char)); /* ??? */ + int squoting = 0; + + for (; words[*offset]; ++(*offset)) { - free (pwordexp->we_wordv[0]); - if (!(flags & WRDE_APPEND)) - free (pwordexp->we_wordv); + switch (words[*offset]) + { + case '`': + /* Go -- give the script to the shell */ + error = exec_comm (comm, word, word_length, flags, pwordexp); + free (comm); + return error; + + case '\\': + if (squoting) + { + error = parse_qtd_backslash (&comm, &comm_length, words, offset); + + if (error) + { + free (comm); + return error; + } + + break; + } + + ++(*offset); + error = parse_backslash (&comm, &comm_length, words, offset); + + if (error) + { + free (comm); + return error; + } + + break; + + case '\'': + squoting = 1 - squoting; + default: + comm = w_addchar (comm, &comm_length, words[*offset]); + if (comm == NULL) + return WRDE_NOSPACE; + } } - pwordexp->we_wordc = wordc; - pwordexp->we_wordv = wordv; + /* Premature end */ + free (comm); + return WRDE_SYNTAX; +} - return 0; +static int +parse_dquote (char **word, size_t *word_length, const char *words, + size_t *offset, int flags) +{ + /* We are poised just after a double-quote */ + int error; + + for (; words[*offset]; ++(*offset)) + { + switch (words[*offset]) + { + case '"': + return 0; + + case '$': + error = parse_dollars (word, word_length, words, offset, flags, + NULL); + /* The NULL here is to tell parse_dollars not to + * split the fields. + */ + if (error) + return error; - lose: - { - int save; - save = errno; - (void) kill (pid, SIGKILL); - free (buf); - (void) waitpid (pid, (int *) NULL, 0); - errno = save; - return error; - } + break; + + case '`': + if (flags & WRDE_NOCMD) + { + return WRDE_CMDSUB; + } + + ++(*offset); + error = parse_backtick (word, word_length, words, offset, flags, + NULL); + /* The NULL here is to tell parse_backtick not to + * split the fields. + */ + if (error) + return error; + + break; + + case '\\': + error = parse_qtd_backslash (word, word_length, words, offset); + + if (error) + return error; + + break; + + default: + *word = w_addchar (*word, word_length, words[*offset]); + if (*word == NULL) + return WRDE_NOSPACE; + } + } + + /* Unterminated string */ + return WRDE_SYNTAX; } +/* + * wordfree() is to be called after pwordexp is finished with. + */ void -DEFUN(wordexp, (pwordexp), wordexp_t *pwordexp) +wordfree (wordexp_t *pwordexp) { - /* All the other elts point into the first. */ - free (pwordexp->we_wordv[0]); - free (pwordexp->we_wordv); + + /* wordexp can set pwordexp to NULL */ + if (pwordexp && pwordexp->we_wordv) + { + char **wordv = pwordexp->we_wordv; + + for (wordv += pwordexp->we_offs; *wordv; ++wordv) + free (*wordv); + + free (pwordexp->we_wordv); + pwordexp->we_wordv = NULL; + } +} + +/* + * wordexp() + */ + +int +wordexp (const char *words, wordexp_t *pwordexp, int flags) +{ + size_t wordv_offset; + size_t words_offset; + size_t word_length = 0; + int error; + char *word = NULL; + char *ifs; + char ifs_white[4]; + char **old_wordv = pwordexp->we_wordv; + size_t old_wordc = pwordexp->we_wordc; + + if (flags & WRDE_REUSE) + /* Minimal implementation of WRDE_REUSE for now */ + wordfree (pwordexp); + + if (flags & WRDE_DOOFFS) + { + pwordexp->we_wordv = calloc (1 + pwordexp->we_offs, sizeof (char *)); + if (pwordexp->we_wordv == NULL) + return WRDE_NOSPACE; + } + else + { + pwordexp->we_wordv = calloc (1, sizeof (char *)); + if (pwordexp->we_wordv == NULL) + return WRDE_NOSPACE; + + pwordexp->we_offs = 0; + } + + if ((flags & WRDE_APPEND) == 0) + pwordexp->we_wordc = 0; + + wordv_offset = pwordexp->we_offs + pwordexp->we_wordc; + + /* Find out what the field separators are. + * There are two types: whitespace and non-whitespace. + */ + ifs = getenv ("IFS"); + + if (!ifs) + ifs = strcpy (ifs_white, " \t\n"); + else + { + char *ifsch = ifs; + char *whch = ifs_white; + + while (*ifsch != '\0') + if ((*ifsch == ' ') || (*ifsch == '\t') || (*ifsch == '\n')) + { + /* White space IFS. Se first whether it is already in our + collection. */ + char *runp = ifs_white; + + while (runp < whch && *runp != '\0') + ++runp; + + if (runp == whch) + *whch++ = *ifsch; + } + *whch = '\0'; + } + + for (words_offset = 0 ; words[words_offset] ; ++words_offset) + switch (words[words_offset]) + { + case '\n': + case '|': + case '&': + case ';': + case '<': + case '>': + case '(': + case ')': + case '}': + /* Fail */ + wordfree (pwordexp); + pwordexp->we_wordc = 0; + pwordexp->we_wordv = old_wordv; + return WRDE_BADCHAR; + + case '\\': + error = parse_backslash (&word, &word_length, words, &words_offset); + + if (error) + goto do_error; + + break; + + case '$': + error = parse_dollars (&word, &word_length, words, &words_offset, + flags, pwordexp); + + if (error) + goto do_error; + + break; + + case '`': + if (flags & WRDE_NOCMD) + return WRDE_CMDSUB; + + ++words_offset; + error = parse_backtick (&word, &word_length, words, &words_offset, + flags, pwordexp); + + if (error) + goto do_error; + + break; + + case '"': + ++words_offset; + error = parse_dquote (&word, &word_length, words, &words_offset, + flags); + + if (error) + goto do_error; + + break; + + case '\'': + ++words_offset; + error = parse_squote (&word, &word_length, words, &words_offset); + + if (error) + goto do_error; + + break; + + case '~': + error = parse_tilde (&word, &word_length, words, &words_offset, + pwordexp->we_wordc); + + if (error) + goto do_error; + + break; + + case '*': + case '{': + error = parse_glob (&word, &word_length, words, &words_offset, flags, + pwordexp, ifs); + + if (error) + goto do_error; + + break; + + default: + /* Is it a field separator? */ + if (strchr (ifs, words[words_offset]) == NULL) + { + /* "Ordinary" character -- add it to word */ + + word = w_addchar (word, &word_length, words[words_offset]); + if (word == NULL) + { + error = WRDE_NOSPACE; + goto do_error; + } + + break; + } + + /* Field separator */ + if (strchr (ifs_white, words[words_offset])) + { + /* It's a whitespace IFS char. Ignore it at the beginning + of a line and ignore multiple instances. */ + if (!word || !*word) + break; + + if (w_addword (pwordexp, word) == WRDE_NOSPACE) + { + error = WRDE_NOSPACE; + goto do_error; + } + + word = NULL; + word_length = 0; + break; + } + + /* It's a non-whitespace IFS char */ + if (!word) + { + word = calloc (1, sizeof (char)); /* ??? */ + if (word == NULL) + { + error = WRDE_NOSPACE; + goto do_error; + } + } + + if (w_addword (pwordexp, word) == WRDE_NOSPACE) + { + error = WRDE_NOSPACE; + goto do_error; + } + + word = NULL; + word_length = 0; + } + + /* End of string */ + + /* There was a field separator at the end */ + if (!word || !*word) + return 0; + + /* There was no field separator at the end */ + return w_addword (pwordexp, word); + +do_error: + /* Error: + free memory used, set we_wordc and wd_wordv back to what they were. + */ + if (word != NULL) + free (word); + + wordfree (pwordexp); + pwordexp->we_wordv = old_wordv; + pwordexp->we_wordc = old_wordc; + return error; } diff --git a/resolv/libresolv.map b/resolv/libresolv.map index 326264668c..8cb621072a 100644 --- a/resolv/libresolv.map +++ b/resolv/libresolv.map @@ -5,8 +5,20 @@ GLIBC_2.0 { inet_net_ntop; inet_net_pton; inet_neta; res_gethostbyaddr; res_gethostbyname; res_gethostbyname2; res_mkquery; res_query; res_querydomain; res_search; res_send_setqhook; res_send_setrhook; - __res_dnok; __res_hnok; __p_class; __hostalias; __dn_skipname; - __p_type; + # Variables + __p_class_syms; __p_type_syms; + # Private routines shared between libc/net, named, nslookup and others. + __b64_ntop; __b64_pton; + __dn_comp; __dn_count_labels; __dn_skipname; + __fp_nquery; __fp_query; __fp_resstat; __hostalias; + __loc_aton; __loc_ntoa; + __p_cdname; __p_cdnname; __p_class; __p_fqname; __p_fqnname; __p_option; + __p_query; __p_rr; __p_secstodate; __p_time; __p_type; + __putlong; __putshort; + __res_close; __res_dnok; __res_hnok; __res_isourserver; __res_mailok; + __res_nameinquery; __res_ownok; __res_queriesmatch; + __res_send; + __sym_ntop; __sym_ntos; __sym_ston; local: *; diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c index d1004356b4..9240355d31 100644 --- a/stdio-common/printf_fp.c +++ b/stdio-common/printf_fp.c @@ -30,11 +30,11 @@ #include #include #include -#include "../stdlib/gmp.h" -#include "../stdlib/gmp-impl.h" -#include "../stdlib/longlong.h" -#include "../stdlib/fpioconst.h" -#include "../locale/localeinfo.h" +#include +#include +#include +#include +#include #include #include #include diff --git a/stdio-common/printf_fphex.c b/stdio-common/printf_fphex.c index f5a3b49e38..c57396f98b 100644 --- a/stdio-common/printf_fphex.c +++ b/stdio-common/printf_fphex.c @@ -27,7 +27,7 @@ #include #include #include "_itoa.h" -#include "../locale/localeinfo.h" +#include /* #define NDEBUG 1*/ /* Undefine this for debugging assertions. */ #include diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c index cbe4291246..9945ab9400 100644 --- a/stdlib/fmtmsg.c +++ b/stdlib/fmtmsg.c @@ -87,8 +87,11 @@ static const struct severity_info infosev = /* Start of the list. */ static struct severity_info *severity_list = (struct severity_info *) &infosev; +/* Mask of values we will print. */ +static int print; /* Prototypes for local functions. */ +static void init (void); static int internal_addseverity (int severity, const char *string); @@ -96,100 +99,12 @@ int fmtmsg (long int classification, const char *label, int severity, const char *text, const char *action, const char *tag) { - static int print = -1; + __libc_once_define (once); int result = MM_OK; struct severity_info *severity_rec; - if (print == -1) - { - __libc_lock_lock (lock); - - if (print == -1) - { - const char *msgverb_var = getenv ("MSGVERB"); - const char *sevlevel_var = getenv ("SEV_LEVEL"); - - if (msgverb_var != NULL && msgverb_var[0] != '\0') - { - /* Using this extra variable allows us to work without - locking. */ - print = 0; - - do - { - size_t cnt; - - for (cnt = 0; cnt < NKEYWORDS; ++cnt) - if (memcmp (msgverb_var, - keywords[cnt].name, keywords[cnt].len) == 0 - && (msgverb_var[keywords[cnt].len] == ':' - || msgverb_var[keywords[cnt].len] == '\0')) - break; - - if (cnt < NKEYWORDS) - { - print |= 1 << cnt; - - msgverb_var += keywords[cnt].len; - if (msgverb_var[0] == ':') - ++msgverb_var; - } - else - { - /* We found an illegal keyword in the - environment variable. The specifications say - that we print all fields. */ - print = all_mask; - break; - } - } - while (msgverb_var[0] != '\0'); - } - else - print = all_mask; - - - if (sevlevel_var != NULL) - while (sevlevel_var[0] != '\0') - { - const char *end = strchr (sevlevel_var, ':'); - int level; - - if (end == NULL) - end = strchr (sevlevel_var, '\0'); - - /* First field: keyword. This is not used here but it - must be present. */ - while (sevlevel_var < end) - if (*sevlevel_var++ == ',') - break; - - if (sevlevel_var < end) - { - /* Second field: severity level, a number. */ - char *cp; - - level = strtol (sevlevel_var, &cp, 0); - if (cp != sevlevel_var && cp < end && *cp++ == ',' - && level > MM_INFO) - { - const char *new_string; - - new_string = __strndup (cp, end - cp); - - if (new_string != NULL - && (internal_addseverity (level, new_string) - != MM_OK)) - free ((char *) new_string); - } - } - - sevlevel_var = end + (*end == ':' ? 1 : 0); - } - } - - __libc_lock_unlock (lock); - } + /* make sure everything is initialized. */ + __libc_once (once, init); /* Start the real work. First check whether the input is ok. */ if (label != MM_NULLLBL) @@ -268,6 +183,94 @@ fmtmsg (long int classification, const char *label, int severity, } +/* Initialize from environment variable content. */ +static void +init (void) +{ + const char *msgverb_var = getenv ("MSGVERB"); + const char *sevlevel_var = getenv ("SEV_LEVEL"); + + if (msgverb_var != NULL && msgverb_var[0] != '\0') + { + /* Using this extra variable allows us to work without locking. */ + do + { + size_t cnt; + + for (cnt = 0; cnt < NKEYWORDS; ++cnt) + if (memcmp (msgverb_var, + keywords[cnt].name, keywords[cnt].len) == 0 + && (msgverb_var[keywords[cnt].len] == ':' + || msgverb_var[keywords[cnt].len] == '\0')) + break; + + if (cnt < NKEYWORDS) + { + print |= 1 << cnt; + + msgverb_var += keywords[cnt].len; + if (msgverb_var[0] == ':') + ++msgverb_var; + } + else + { + /* We found an illegal keyword in the environment + variable. The specifications say that we print all + fields. */ + print = all_mask; + break; + } + } + while (msgverb_var[0] != '\0'); + } + else + print = all_mask; + + + if (sevlevel_var != NULL) + { + __libc_lock_lock (lock); + + while (sevlevel_var[0] != '\0') + { + const char *end = strchr (sevlevel_var, ':'); + int level; + + if (end == NULL) + end = strchr (sevlevel_var, '\0'); + + /* First field: keyword. This is not used here but it must be + present. */ + while (sevlevel_var < end) + if (*sevlevel_var++ == ',') + break; + + if (sevlevel_var < end) + { + /* Second field: severity level, a number. */ + char *cp; + + level = strtol (sevlevel_var, &cp, 0); + if (cp != sevlevel_var && cp < end && *cp++ == ',' + && level > MM_INFO) + { + const char *new_string; + + new_string = __strndup (cp, end - cp); + + if (new_string != NULL + && (internal_addseverity (level, new_string) + != MM_OK)) + free ((char *) new_string); + } + } + + sevlevel_var = end + (*end == ':' ? 1 : 0); + } + } +} + + /* Add the new entry to the list. */ static int internal_addseverity (int severity, const char *string) diff --git a/sysdeps/generic/bits/in.h b/sysdeps/generic/bits/in.h new file mode 100644 index 0000000000..7241bd24c3 --- /dev/null +++ b/sysdeps/generic/bits/in.h @@ -0,0 +1,84 @@ +/* Copyright (C) 1997 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. */ + +/* Generic version. */ + +#ifndef _NETINET_INBITS_H +#define _NETINET_INBITS_H 1 + +/* Link numbers. */ +#define IMPLINK_IP 155 +#define IMPLINK_LOWEXPER 156 +#define IMPLINK_HIGHEXPER 158 + + +/* Options for use with `getsockopt' and `setsockopt' at the IP level. + The first word in the comment at the right is the data type used; + "bool" means a boolean value stored in an `int'. */ +#define IP_OPTIONS 1 /* ip_opts; IP per-packet options. */ +#define IP_HDRINCL 2 /* int; Header is included with data. */ +#define IP_TOS 3 /* int; IP type of service and precedence. */ +#define IP_TTL 4 /* int; IP time to live. */ +#define IP_RECVOPTS 5 /* bool; Receive all IP options w/datagram. */ +#define IP_RECVRETOPTS 6 /* bool; Receive IP options for response. */ +#define IP_RECVDSTADDR 7 /* bool; Receive IP dst addr w/datagram. */ +#define IP_RETOPTS 8 /* ip_opts; Set/get IP per-packet options. */ +#define IP_MULTICAST_IF 9 /* in_addr; set/get IP multicast i/f */ +#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ +#define IP_MULTICAST_LOOP 11 /* i_char; set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ +#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ + +/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS. + The `ip_dst' field is used for the first-hop gateway when using a + source route (this gets put into the header proper). */ +struct ip_opts + { + struct in_addr ip_dst; /* First hop; zero without source route. */ + char ip_opts[40]; /* Actually variable in size. */ + }; + +/* Structure used for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. */ +struct ip_mreq +{ + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* IPV6 socket options. */ +#define IPV6_ADDRFORM 1 +#define IPV6_RXINFO 2 +#define IPV6_RXHOPOPTS 3 +#define IPV6_RXDSTOPTS 4 +#define IPV6_RXSRCRT 5 +#define IPV6_PKTOPTIONS 6 +#define IPV6_CHECKSUM 7 +#define IPV6_HOPLIMIT 8 + +#define IPV6_TXINFO IPV6_RXINFO +#define SCM_SRCINFO IPV6_TXINFO +#define SCM_SRCRT IPV6_RXSRCRT + +#define IPV6_UNICAST_HOPS 16 +#define IPV6_MULTICAST_IF 17 +#define IPV6_MULTICAST_HOPS 18 +#define IPV6_MULTICAST_LOOP 19 +#define IPV6_ADD_MEMBERSHIP 20 +#define IPV6_DROP_MEMBERSHIP 21 + +#endif /* netinet/inbits.h */ diff --git a/sysdeps/generic/crypt.h b/sysdeps/generic/crypt.h index 0fdef1843a..3f8f960140 100644 --- a/sysdeps/generic/crypt.h +++ b/sysdeps/generic/crypt.h @@ -29,28 +29,30 @@ __BEGIN_DECLS -struct crypt_data -{ - char keysched[(16 * 8) / sizeof (char)]; - char sb0[32768 / sizeof (char)]; - char sb1[32768 / sizeof (char)]; - char sb2[32768 / sizeof (char)]; - char sb3[32768 / sizeof (char)]; - /* end-of-alignment-critical-data */ - char crypt_3_buf[14]; - char current_salt[2]; - long current_saltbits; - int direction, initialized; -}; - /* Encrypt at most 8 characters from KEY using salt to perturb DES. */ extern char *crypt __P ((__const char *__key, __const char *__salt)); +#ifdef __USE_GNU /* Reentrant versions of the functions above. The additional argument points to a structure where the results are placed in. */ +struct crypt_data + { + char keysched[16 * 8]; + char sb0[32768]; + char sb1[32768]; + char sb2[32768]; + char sb3[32768]; + /* end-of-alignment-critical-data */ + char crypt_3_buf[14]; + char current_salt[2]; + long int current_saltbits; + int direction, initialized; + }; + extern char *crypt_r __P ((__const char *__key, __const char *__salt, struct crypt_data *__data)); +#endif __END_DECLS diff --git a/sysdeps/generic/netinet/inbits.h b/sysdeps/generic/netinet/inbits.h deleted file mode 100644 index 7241bd24c3..0000000000 --- a/sysdeps/generic/netinet/inbits.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (C) 1997 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. */ - -/* Generic version. */ - -#ifndef _NETINET_INBITS_H -#define _NETINET_INBITS_H 1 - -/* Link numbers. */ -#define IMPLINK_IP 155 -#define IMPLINK_LOWEXPER 156 -#define IMPLINK_HIGHEXPER 158 - - -/* Options for use with `getsockopt' and `setsockopt' at the IP level. - The first word in the comment at the right is the data type used; - "bool" means a boolean value stored in an `int'. */ -#define IP_OPTIONS 1 /* ip_opts; IP per-packet options. */ -#define IP_HDRINCL 2 /* int; Header is included with data. */ -#define IP_TOS 3 /* int; IP type of service and precedence. */ -#define IP_TTL 4 /* int; IP time to live. */ -#define IP_RECVOPTS 5 /* bool; Receive all IP options w/datagram. */ -#define IP_RECVRETOPTS 6 /* bool; Receive IP options for response. */ -#define IP_RECVDSTADDR 7 /* bool; Receive IP dst addr w/datagram. */ -#define IP_RETOPTS 8 /* ip_opts; Set/get IP per-packet options. */ -#define IP_MULTICAST_IF 9 /* in_addr; set/get IP multicast i/f */ -#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ -#define IP_MULTICAST_LOOP 11 /* i_char; set/get IP multicast loopback */ -#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ -#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ - -/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS. - The `ip_dst' field is used for the first-hop gateway when using a - source route (this gets put into the header proper). */ -struct ip_opts - { - struct in_addr ip_dst; /* First hop; zero without source route. */ - char ip_opts[40]; /* Actually variable in size. */ - }; - -/* Structure used for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. */ -struct ip_mreq -{ - struct in_addr imr_multiaddr; /* IP multicast address of group */ - struct in_addr imr_interface; /* local IP address of interface */ -}; - -/* IPV6 socket options. */ -#define IPV6_ADDRFORM 1 -#define IPV6_RXINFO 2 -#define IPV6_RXHOPOPTS 3 -#define IPV6_RXDSTOPTS 4 -#define IPV6_RXSRCRT 5 -#define IPV6_PKTOPTIONS 6 -#define IPV6_CHECKSUM 7 -#define IPV6_HOPLIMIT 8 - -#define IPV6_TXINFO IPV6_RXINFO -#define SCM_SRCINFO IPV6_TXINFO -#define SCM_SRCRT IPV6_RXSRCRT - -#define IPV6_UNICAST_HOPS 16 -#define IPV6_MULTICAST_IF 17 -#define IPV6_MULTICAST_HOPS 18 -#define IPV6_MULTICAST_LOOP 19 -#define IPV6_ADD_MEMBERSHIP 20 -#define IPV6_DROP_MEMBERSHIP 21 - -#endif /* netinet/inbits.h */ diff --git a/sysdeps/generic/vlimit.c b/sysdeps/generic/vlimit.c index 045eece010..5654be1205 100644 --- a/sysdeps/generic/vlimit.c +++ b/sysdeps/generic/vlimit.c @@ -43,7 +43,7 @@ vlimit (resource, value) return -1; lims.rlim_cur = value; - return setrlimit(rlimit_res, &lims); + return setrlimit (rlimit_res, &lims); } __set_errno (EINVAL); diff --git a/sysdeps/generic/vtimes.c b/sysdeps/generic/vtimes.c index 0c19a918f8..e448da6de1 100644 --- a/sysdeps/generic/vtimes.c +++ b/sysdeps/generic/vtimes.c @@ -38,8 +38,8 @@ vtimes_one (struct vtimes *vt, enum __rusage_who who) if (getrusage (who, &usage) < 0) return -1; - vt->vm_utime = TIMEVAL_TO_VTIMES(usage.ru_utime); - vt->vm_stime = TIMEVAL_TO_VTIMES(usage.ru_stime); + vt->vm_utime = TIMEVAL_TO_VTIMES (usage.ru_utime); + vt->vm_stime = TIMEVAL_TO_VTIMES (usage.ru_stime); vt->vm_idsrss = usage.ru_idrss + usage.ru_isrss; vt->vm_majflt = usage.ru_majflt; vt->vm_minflt = usage.ru_minflt; @@ -58,8 +58,8 @@ vtimes (current, child) struct vtimes *current; struct vtimes *child; { - if (vtimes_one(current, RUSAGE_SELF) < 0 || - vtimes_one(child, RUSAGE_CHILDREN) < 0) + if (vtimes_one (current, RUSAGE_SELF) < 0 + || vtimes_one (child, RUSAGE_CHILDREN) < 0) return -1; return 0; } diff --git a/sysdeps/gnu/errlist.c b/sysdeps/gnu/errlist.c index f998747848..3333f1d467 100644 --- a/sysdeps/gnu/errlist.c +++ b/sysdeps/gnu/errlist.c @@ -249,7 +249,7 @@ TRANS until some external condition makes it possible to read, write, or TRANS connect (whatever the operation). You can use @code{select} to find out TRANS when the operation will be possible; @pxref{Waiting for I/O}. TRANS -TRANS @strong{Portability Note:} In older Unix many systems, this condition +TRANS @strong{Portability Note:} In older many Unix systems, this condition TRANS was indicated by @code{EWOULDBLOCK}, which was a distinct error code TRANS different from @code{EAGAIN}. To make your program portable, you should TRANS check for both codes and treat them the same. diff --git a/sysdeps/i386/elf/bsd-_setjmp.S b/sysdeps/i386/elf/bsd-_setjmp.S new file mode 100644 index 0000000000..1417270201 --- /dev/null +++ b/sysdeps/i386/elf/bsd-_setjmp.S @@ -0,0 +1 @@ +/* We don't need any code here since the setjmp.S file contains it. */ diff --git a/sysdeps/i386/elf/bsd-setjmp.S b/sysdeps/i386/elf/bsd-setjmp.S new file mode 100644 index 0000000000..1417270201 --- /dev/null +++ b/sysdeps/i386/elf/bsd-setjmp.S @@ -0,0 +1 @@ +/* We don't need any code here since the setjmp.S file contains it. */ diff --git a/sysdeps/i386/elf/setjmp.S b/sysdeps/i386/elf/setjmp.S new file mode 100644 index 0000000000..d73e84364f --- /dev/null +++ b/sysdeps/i386/elf/setjmp.S @@ -0,0 +1,72 @@ +/* setjmp for i386, ELF version. + Copyright (C) 1995, 1996, 1997 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. */ + +#include +#define _ASM +#include + + /* We include the BSD entry points here as well but we make + them weak. */ +ENTRY (setjmp) + .weak C_SYMBOL_NAME (setjmp) + popl %eax /* Pop return PC. */ + popl %ecx /* Pop jmp_buf argument. */ + pushl $1 /* Push second argument of zero. */ + pushl %ecx /* Push back first argument. */ + pushl %eax /* Push back return PC. */ + jmp __sigsetjmp +END (setjmp) + + /* Binary compatibility entry point. */ +ENTRY (_setjmp) + .weak C_SYMBOL_NAME (_setjmp) +ENTRY (__setjmp) + popl %eax /* Pop return address. */ + popl %ecx /* Pop jmp_buf. */ + pushl $0 /* Push zero argument. */ + pushl %ecx /* Push jmp_buf. */ + pushl %eax /* Push back return address. */ + +ENTRY (__sigsetjmp) + movl 4(%esp), %eax /* User's jmp_buf in %eax. */ + /* Save registers. */ + movl %ebx, (JB_BX*4)(%eax) + movl %esi, (JB_SI*4)(%eax) + movl %edi, (JB_DI*4)(%eax) + movl %ebp, (JB_BP*4)(%eax) + leal 4(%esp), %ecx /* Save SP as it will be after we return. */ + movl %ecx, (JB_SP*4)(%eax) + movl 0(%esp), %ecx /* Save PC we are returning to now. */ + movl %ecx, (JB_PC*4)(%eax) + + /* Make a tail call to __sigjmp_save; it takes the same args. */ +#ifdef PIC + /* We cannot use the PLT, because it requires that %ebx be set, but + we can't save and restore our caller's value. Instead, we do an + indirect jump through the GOT, using for the temporary register + %ecx, which is call-clobbered. */ + call here +here: popl %ecx + addl $_GLOBAL_OFFSET_TABLE_+[.-here], %ecx + movl C_SYMBOL_NAME(__sigjmp_save@GOT)(%ecx), %ecx + jmp *%ecx +#else + jmp __sigjmp_save +#endif +END (__sigsetjmp) diff --git a/sysdeps/i386/fpu/bits/mathinline.h b/sysdeps/i386/fpu/bits/mathinline.h index 2fc5baf81e..b3736f8417 100644 --- a/sysdeps/i386/fpu/bits/mathinline.h +++ b/sysdeps/i386/fpu/bits/mathinline.h @@ -29,7 +29,7 @@ all floating-point types. */ # define isgreater(x, y) \ ({ int __result; \ - __asm__ ("fucompp; fnstsw; andb $0x45, %%ah; setz %%al;" \ + __asm__ ("fucompp; fnstsw; testb $0x45, %%ah; setz %%al;" \ "andl $0x01, %0" \ : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \ __result; }) @@ -118,11 +118,11 @@ #endif #define __inline_mathop_decl_(float_type, func, op, params...) \ - __MATHINLINE float_type func (float_type); \ - __MATHINLINE float_type func (float_type __x) \ + __MATH_INLINE float_type func (float_type); \ + __MATH_INLINE float_type func (float_type __x) \ { \ register float_type __result; \ - __asm __volatile__ (op : "=t" (__results) : params); \ + __asm __volatile__ (op : "=t" (__result) : params); \ return __result; \ } @@ -163,8 +163,9 @@ } -/* Optimized inline implementation, sometimes woth reduced precision +/* Optimized inline implementation, sometimes with reduced precision and/or argument range. */ + #define __expm1_code \ register long double __value; \ register long double __exponent; \ @@ -266,7 +267,7 @@ __inline_mathcode2 (pow, __x, __y, \ /* NOTREACHED */ \ } \ __asm __volatile__ \ - ("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0) : "st1"); \ + ("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0) : "st(1)"); \ __asm __volatile__ \ ("fmul %%st(1) # y * log2(x)\n\t" \ "fst %%st(1)\n\t" \ @@ -285,26 +286,34 @@ __inline_mathcode2 (pow, __x, __y, \ __inline_mathop (sqrt, "fsqrt") __inline_mathop_ (long double, __sqrtl, "fsqrt") +#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 8) +__inline_mathcode_ (fabs, __x, return __builtin_fabs (__x)) +__inline_mathcode_ (fabsf, __x, return __builtin_fabsf (__x)) +__inline_mathcode_ (fabsl, __x, return __builtin_fabsl (__x)) +__inline_mathcode_ (__fabsl, __x, return __builtin_fabsl (__x)) +#else __inline_mathop (fabs, "fabs") +__inline_mathop_ (long double, __fabsl, "fabs") +#endif /* The argument range of this inline version is reduced. */ __inline_mathop (sin, "fsin") /* The argument range of this inline version is reduced. */ __inline_mathop (cos, "fcos") -__inline_mathop (atan, "fld1; fpatan") +__inline_mathop_decl (atan, "fpatan", "u" (__x), "0" (1.0) : "st(1)") __inline_mathop (log, "fldln2; fxch; fyl2x") __inline_mathop (log10, "fldlg2; fxch; fyl2x") __inline_mathcode (asin, __x, return __atan2l (__x, __sqrtl (1.0 - __x * __x))) __inline_mathcode (acos, __x, return __atan2l (__sqrtl (1.0 - __x * __x), __x)) -__inline_mathcode (__sgn1, __x, return __x >= 0.0 ? 1.0 : -1.0) +__inline_mathcode_ (long double, __sgn1l, __x, return __x >= 0.0 ? 1.0 : -1.0) /* The argument range of the inline version of sinhl is slightly reduced. */ __inline_mathcode (sinh, __x, \ - register long double __exm1 = __expm1l (__builtin_fabsl (__x)); \ + register long double __exm1 = __expm1l (__fabsl (__x)); \ return 0.5 * (__exm1 / (__exm1 + 1.0) + __exm1) * __sgn1l (__x)) __inline_mathcode (cosh, __x, \ @@ -312,7 +321,7 @@ __inline_mathcode (cosh, __x, \ return 0.5 * (__ex + 1.0 / __ex)) __inline_mathcode (tanh, __x, \ - register long double __exm1 = __expm1l (-__builtin_fabsl (__x + __x)); \ + register long double __exm1 = __expm1l (-__fabsl (__x + __x)); \ return __exm1 / (__exm1 + 2.0) * __sgn1l (-__x)) @@ -338,6 +347,20 @@ __inline_mathcode (ceil, __x, \ __asm __volatile ("fldcw %0" : : "m" (__cw)); \ return __value) +#define __ldexp_code \ + register long double __value; \ + __asm __volatile__ \ + ("fscale" \ + : "=t" (__value) : "0" (__x), "u" ((long double) __y)); \ + return __value + +__MATH_INLINE double ldexp (double __x, int __y); +__MATH_INLINE double +ldexp (double __x, int __y) +{ + __ldexp_code; +} + /* Optimized versions for some non-standardized functions. */ #if defined __USE_ISOC9X || defined __USE_MISC @@ -352,7 +375,7 @@ __inline_mathcode (expm1, __x, __expm1_code) __inline_mathcode (log1p, __x, \ register long double __value; \ - if (__builtin_fabsl (__x) >= 1.0 - 0.5 * __M_SQRT2) \ + if (__fabsl (__x) >= 1.0 - 0.5 * __M_SQRT2) \ __value = logl (1.0 + __x); \ else \ __asm __volatile__ \ @@ -365,7 +388,7 @@ __inline_mathcode (log1p, __x, \ /* The argument range of the inline version of asinhl is slightly reduced. */ __inline_mathcode (asinh, __x, \ - register long double __y = __builtin_fabsl (__x); \ + register long double __y = __fabsl (__x); \ return (log1pl (__y * __y / (__sqrtl (__y * __y + 1.0) + 1.0) + __y) \ * __sgn1l (__x)) @@ -373,7 +396,7 @@ __inline_mathcode (acosh, __x, \ return logl (__x + __sqrtl (__x - 1.0) * __sqrtl (__x + 1.0))) __inline_mathcode (atanh, __x, \ - register long double __y = __builtin_fabsl (__x); \ + register long double __y = __fabsl (__x); \ return (-0.5 * log1pl (-(__y + __y) / (1.0 + __y)) * \ __sgn1l (__x))) @@ -389,17 +412,25 @@ __inline_mathcode(logb, __x, \ : "=t" (__junk), "=u" (__value) : "0" (__x)); \ return __value) +__MATH_INLINE float ldexpf (float __x, int __y); +__MATH_INLINE float +ldexpf (float __x, int __y) +{ + __ldexp_code; +} + +__MATH_INLINE long double ldexpl (long double __x, int __y); +__MATH_INLINE long double +ldexpl (long double __x, int __y) +{ + __ldexp_code; +} -__inline_mathcode2 (ldexp, __x, __y, \ - register long double __value; \ - __asm __volatile__ \ - ("fscale" \ - : "=t" (__value) : "0" (__x), "u" ((long double) __y)); \ - return __value) #endif #ifdef __USE_MISC + __inline_mathcode2 (drem, __x, __y, \ register double __value; \ __asm __volatile__ \ @@ -431,7 +462,7 @@ __inline_mathcode (__sgn, __x, \ return __x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0)) __inline_mathcode (__coshm1, __x, \ - register long double __exm1 = __expm1l (__builtin_fabsl (__x)); \ + register long double __exm1 = __expm1l (__fabsl (__x)); \ return 0.5 * (__exm1 / (__exm1 + 1.0)) * __exm1) __inline_mathcode (__acosh1p, __x, \ diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h index 7c62aa2aad..01fc339928 100644 --- a/sysdeps/m68k/dl-machine.h +++ b/sysdeps/m68k/dl-machine.h @@ -80,6 +80,7 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) { Elf32_Addr *got; extern void _dl_runtime_resolve (Elf32_Word); + extern void _dl_runtime_profile (Elf32_Word); if (l->l_info[DT_JMPREL] && lazy) { @@ -90,10 +91,23 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) _GLOBAL_OFFSET_TABLE_[2]. */ got = (Elf32_Addr *) (l->l_addr + l->l_info[DT_PLTGOT]->d_un.d_ptr); got[1] = (Elf32_Addr) l; /* Identify this shared object. */ - /* This function will get called to fix up the GOT entry - indicated by the offset on the stack, and then jump to the - resolved address. */ - got[2] = (Elf32_Addr) &_dl_runtime_resolve; + + /* The got[2] entry contains the address of a function which gets + called to get the address of a so far unresolved function and + jump to it. The profiling extension of the dynamic linker allows + to intercept the calls to collect information. In this case we + don't store the address in the GOT so that all future calls also + end in this function. */ + if (profile) + { + got[2] = (Elf32_Addr) &_dl_runtime_profile; + /* Say that we really want profiling and the timers are started. */ + _dl_profile_map = l; + } + else + /* This function will get called to fix up the GOT entry indicated by + the offset on the stack, and then jump to the resolved address. */ + got[2] = (Elf32_Addr) &_dl_runtime_resolve; } return lazy; @@ -101,16 +115,16 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) /* This code is used in dl-runtime.c to call the `fixup' function and then redirect to the address it returns. */ -#define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\ -| Trampoline for _dl_runtime_resolver - .globl _dl_runtime_resolve - .type _dl_runtime_resolve, @function -_dl_runtime_resolve: +#define TRAMPOLINE_TEMPLATE(tramp_name, fixup_name) \ +"| Trampoline for " #fixup_name " + .globl " #tramp_name " + .type " #tramp_name ", @function +" #tramp_name ": | Save %a0 (struct return address) and %a1. move.l %a0, -(%sp) move.l %a1, -(%sp) | Call the real address resolver. - jbsr fixup + jbsr " #fixup_name " | Restore register %a0 and %a1. move.l (%sp)+, %a1 move.l (%sp)+, %a0 @@ -118,8 +132,17 @@ _dl_runtime_resolve: addq.l #8, %sp | Call real function. jmp (%d0) - .size _dl_runtime_resolve, . - _dl_runtime_resolve -"); + .size " #tramp_name ", . - " #tramp_name "\n" +#ifndef PROF +#define ELF_MACHINE_RUNTIME_TRAMPOLINE \ +asm (TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup) \ + TRAMPOLINE_TEMPLATE (_dl_runtime_profile, profile_fixup)); +#else +#define ELF_MACHINE_RUNTIME_TRAMPOLINE \ +asm (TRAMPOLINE_TEMPLATE (_dl_runtime_resolve, fixup) \ + ".globl _dl_runtime_profile\n" \ + ".set _dl_runtime_profile, _dl_runtime_resolve"); +#endif #define ELF_MACHINE_RUNTIME_FIXUP_ARGS long int save_a0, long int save_a1 /* The PLT uses Elf32_Rela relocs. */ #define elf_machine_relplt elf_machine_rela diff --git a/sysdeps/sparc/dl-machine.h b/sysdeps/sparc/dl-machine.h index b50549c0ec..dc38e17292 100644 --- a/sysdeps/sparc/dl-machine.h +++ b/sysdeps/sparc/dl-machine.h @@ -100,9 +100,9 @@ elf_machine_load_address (void) static inline void elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, - const Elf32_Sym *sym, const struct r_found_version *version) + const Elf32_Sym *sym, const struct r_found_version *version, + Elf32_Addr *const reloc_addr) { - Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset); Elf32_Addr loadbase; if (ELF32_R_TYPE (reloc->r_info) == R_SPARC_RELATIVE) diff --git a/sysdeps/stub/bits/libc-lock.h b/sysdeps/stub/bits/libc-lock.h index fa4dcdde1d..9efd799dab 100644 --- a/sysdeps/stub/bits/libc-lock.h +++ b/sysdeps/stub/bits/libc-lock.h @@ -70,6 +70,20 @@ /* Unlock the recursive named lock variable. */ #define __libc_lock_unlock_recursive(NAME) + +/* Define once control variable. */ +#define __libc_once_define(NAME) int NAME = 0 + +/* Call handler iff the first call. */ +#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \ + do { \ + if ((ONCE_CONTROL) == 0) { \ + INIT_FUNCTION (); \ + (ONCE_CONTROL) = 1; \ + } \ + } while (0) + + /* Start critical region with cleanup. */ #define __libc_cleanup_region_start(FCT, ARG) diff --git a/sysdeps/stub/if_index.c b/sysdeps/stub/if_index.c index c8f9ea8929..ca859f75fc 100644 --- a/sysdeps/stub/if_index.c +++ b/sysdeps/stub/if_index.c @@ -16,28 +16,36 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #define __need_NULL #include unsigned int if_nametoindex (const char *ifname) { + __set_errno (ENOSYS); return 0; } +stub_warning (if_nametoindex) char * if_indextoname (unsigned int ifindex, char *ifname) { + __set_errno (ENOSYS); return NULL; } +stub_warning (if_indextoname) void if_freenameindex (struct if_nameindex *ifn) { } +stub_warning (if_freenameindex) struct if_nameindex * if_nameindex (void) { + __set_errno (ENOSYS); return NULL; } +stub_warning (if_nameindex) diff --git a/sysdeps/unix/sysv/linux/bits/in.h b/sysdeps/unix/sysv/linux/bits/in.h new file mode 100644 index 0000000000..0dd94bef96 --- /dev/null +++ b/sysdeps/unix/sysv/linux/bits/in.h @@ -0,0 +1,75 @@ +/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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. */ + +/* Linux version. */ + +#ifndef _NETINET_INBITS_H +#define _NETINET_INBITS_H 1 + +/* Options for use with `getsockopt' and `setsockopt' at the IP level. + The first word in the comment at the right is the data type used; + "bool" means a boolean value stored in an `int'. */ +#define IP_TOS 1 /* int; IP type of service and precedence. */ +#define IP_TTL 2 /* int; IP time to live. */ +#define IP_HDRINCL 3 /* int; Header is included with data. */ +#define IP_OPTIONS 4 /* ip_opts; IP per-packet options. */ +#define IP_MULTICAST_IF 32 /* in_addr; set/get IP multicast i/f */ +#define IP_MULTICAST_TTL 33 /* u_char; set/get IP multicast ttl */ +#define IP_MULTICAST_LOOP 34 /* i_char; set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 35 /* ip_mreq; add an IP group membership */ +#define IP_DROP_MEMBERSHIP 36 /* ip_mreq; drop an IP group membership */ + +/* To select the IP level. */ +#define SOL_IP 0 + +/* Structure used to describe IP options for IP_OPTIONS. The `ip_dst' + field is used for the first-hop gateway when using a source route + (this gets put into the header proper). */ +struct ip_opts + { + struct in_addr ip_dst; /* First hop; zero without source route. */ + char ip_opts[40]; /* Actually variable in size. */ + }; + +/* Structure used for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. */ +struct ip_mreq + { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ + }; + +/* IPV6 socket options. */ +#define IPV6_ADDRFORM 1 +#define IPV6_PKTINFO 2 +#define IPV6_RXHOPOPTS 3 +#define IPV6_RXDSTOPTS 4 +#define IPV6_RXSRCRT 5 +#define IPV6_PKTOPTIONS 6 +#define IPV6_CHECKSUM 7 +#define IPV6_HOPLIMIT 8 + +#define SCM_SRCRT IPV6_RXSRCRT + +#define IPV6_UNICAST_HOPS 16 +#define IPV6_MULTICAST_IF 17 +#define IPV6_MULTICAST_HOPS 18 +#define IPV6_MULTICAST_LOOP 19 +#define IPV6_ADD_MEMBERSHIP 20 +#define IPV6_DROP_MEMBERSHIP 21 + +#endif /* netinet/inbits.h */ diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c index fc3bd3324f..41bd0535c9 100644 --- a/sysdeps/unix/sysv/linux/if_index.c +++ b/sysdeps/unix/sysv/linux/if_index.c @@ -20,121 +20,158 @@ #include #include #include +#include +#include +#include -#define IF_INET6_FILENAME "/proc/net/if_inet6" - -/* /proc/net/if_inet6 contains lines that look like this: - * - * fe8000000000000000000000836fc168 0b 00 20 80 sit7 - * - * | | | | | | - * address --' | | | | | - * index --------' | | | | - * prefix length ---' | | | - * scope --------------' | | - * flags -----------------' | - * name -------------------------' - * - */ - -static int get_one_interface(FILE *fd, char *interface, int iflen, unsigned int *index) +/* Try to get a socket to talk to the kernel. */ +static int +opensock (void) { - char buffer[80]; - static char seps[] = " \012"; - char *c = buffer; - char *sp; - if (!fgets(buffer, 80, fd)) - return 1; - if (strtok_r(buffer, seps, &sp) == NULL) return 1; - if (c = strtok_r(NULL, seps, &sp), c == NULL) return 1; - *index = strtoul(c, NULL, 16); - if (strtok_r(NULL, seps, &sp) == NULL) return 1; - if (strtok_r(NULL, seps, &sp) == NULL) return 1; - if (strtok_r(NULL, seps, &sp) == NULL) return 1; - if (c = strtok_r(NULL, seps, &sp), c == NULL) return 1; - strncpy(interface, c, iflen); - return 0; -} + /* Cache the last AF that worked, to avoid many redundant calls to + socket(). */ + static int sock_af = -1; + int fd = -1; + __libc_lock_define_initialized (static, lock); -unsigned int if_nametoindex(const char *ifname) -{ - FILE *fd = fopen(IF_INET6_FILENAME, "r"); - char this_ifname[IFNAMSIZ]; - unsigned int this_index; - if (!fd) return 0; - while (get_one_interface(fd, this_ifname, IFNAMSIZ, &this_index) == 0) { - if (!strcmp(this_ifname, ifname)) { - fclose(fd); - return this_index; + if (sock_af != -1) + { + fd = socket (sock_af, SOCK_DGRAM, 0); + if (fd != -1) + return fd; + } + + __libc_lock_lock (lock); + + if (sock_af != -1) + fd = socket (sock_af, SOCK_DGRAM, 0); + + if (fd == -1) + { + fd = socket (sock_af = AF_INET6, SOCK_DGRAM, 0); + if (fd < 0) + fd = socket (sock_af = AF_INET, SOCK_DGRAM, 0); + if (fd < 0) + fd = socket (sock_af = AF_IPX, SOCK_DGRAM, 0); + if (fd < 0) + fd = socket (sock_af = AF_AX25, SOCK_DGRAM, 0); + if (fd < 0) + fd = socket (sock_af = AF_APPLETALK, SOCK_DGRAM, 0); } - } - fclose(fd); - return 0; + + __libc_lock_unlock (lock); + return fd; } -char *if_indextoname(unsigned int ifindex, char *ifname) +unsigned int +if_nametoindex (const char *ifname) { - FILE *fd = fopen(IF_INET6_FILENAME, "r"); - unsigned int this_index; - if (!fd) return NULL; - while (get_one_interface(fd, ifname, IFNAMSIZ, &this_index) == 0) { - if (this_index == ifindex) { - fclose(fd); - return ifname; + struct ifreq ifr; + int fd = opensock (); + + if (fd < 0) + return 0; + + strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); + if (ioctl (fd, SIOGIFINDEX, &ifr) < 0) + { + close (fd); + return 0; } - } - fclose(fd); - return NULL; + close (fd); + return ifr.ifr_ifindex; } -void if_freenameindex(struct if_nameindex *ifn) +void +if_freenameindex (struct if_nameindex *ifn) { struct if_nameindex *ptr = ifn; while (ptr->if_name || ptr->if_index) { if (ptr->if_name) - free(ptr->if_name); - ptr++; + free (ptr->if_name); + ++ptr; } - free(ifn); + free (ifn); } -struct if_nameindex *if_nameindex(void) +struct if_nameindex * +if_nameindex (void) { - FILE *fd = fopen(IF_INET6_FILENAME, "r"); - struct if_nameindex *ifn = NULL; - int nifs = 0; - if (!fd) return NULL; + int fd = opensock (); + struct ifconf ifc; + unsigned int rq_ifs = 4, nifs, i; + struct if_nameindex *idx = NULL; + + if (fd < 0) + return NULL; + + ifc.ifc_buf = NULL; + + /* Read all the interfaces out of the kernel. */ do { - struct if_nameindex *newifn; - nifs++; - newifn = realloc(ifn, nifs*sizeof(struct if_nameindex)); - if (!newifn) + rq_ifs *= 2; + ifc.ifc_len = rq_ifs * sizeof (struct ifreq); + ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len); + if (ifc.ifc_buf == NULL) { - /* We ran out of memory. */ - if (--nifs) - { - free(ifn[nifs-1].if_name); - ifn[nifs-1].if_name = 0; - ifn[nifs-1].if_index = 0; - if_freenameindex(ifn); - } + close(fd); return NULL; } - ifn = newifn; - ifn[nifs-1].if_index = 0; - ifn[nifs-1].if_name = malloc(IFNAMSIZ); - if (ifn[nifs-1].if_name == NULL) + if (ioctl (fd, SIOCGIFCONF, &ifc) < 0) + goto jump; + } + while ((unsigned int) ifc.ifc_len == (rq_ifs * sizeof (struct ifreq))); + + nifs = ifc.ifc_len / sizeof (struct ifreq); + ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len); + + idx = malloc ((nifs+1) * sizeof (struct if_nameindex)); + if (idx == NULL) + goto jump; + + for (i = 0; i < nifs; ++i) + { + struct ifreq *ifr = &ifc.ifc_req[i]; + if ((idx[i].if_name = malloc (strlen (ifr->ifr_name)+1)) == NULL) { - if_freenameindex(ifn); - return NULL; + free (idx); + idx = NULL; + goto jump; + } + strcpy (idx[i].if_name, ifr->ifr_name); + if (ioctl (fd, SIOGIFINDEX, ifr) < 0) + { + free (idx); + idx = NULL; + goto jump; } + idx[i].if_index = ifr->ifr_ifindex; } - while (get_one_interface(fd, ifn[nifs-1].if_name, IFNAMSIZ, - &ifn[nifs-1].if_index) == 0); - free(ifn[nifs-1].if_name); - ifn[nifs-1].if_name = NULL; - fclose(fd); - return ifn; + idx[i].if_index = 0; + idx[i].if_name = NULL; + +jump: + free (ifc.ifc_buf); + close (fd); + return idx; +} + +char * +if_indextoname (unsigned int ifindex, char *ifname) +{ + struct if_nameindex *idx = if_nameindex (); + struct if_nameindex *p; + + for (p = idx; p->if_index || p->if_name; ++p) + if (p->if_index == ifindex) + { + strncpy (ifname, p->if_name, IFNAMSIZ); + if_freenameindex (idx); + return ifname; + } + + if_freenameindex (idx); + return NULL; } diff --git a/sysdeps/unix/sysv/linux/netinet/inbits.h b/sysdeps/unix/sysv/linux/netinet/inbits.h deleted file mode 100644 index 0dd94bef96..0000000000 --- a/sysdeps/unix/sysv/linux/netinet/inbits.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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. */ - -/* Linux version. */ - -#ifndef _NETINET_INBITS_H -#define _NETINET_INBITS_H 1 - -/* Options for use with `getsockopt' and `setsockopt' at the IP level. - The first word in the comment at the right is the data type used; - "bool" means a boolean value stored in an `int'. */ -#define IP_TOS 1 /* int; IP type of service and precedence. */ -#define IP_TTL 2 /* int; IP time to live. */ -#define IP_HDRINCL 3 /* int; Header is included with data. */ -#define IP_OPTIONS 4 /* ip_opts; IP per-packet options. */ -#define IP_MULTICAST_IF 32 /* in_addr; set/get IP multicast i/f */ -#define IP_MULTICAST_TTL 33 /* u_char; set/get IP multicast ttl */ -#define IP_MULTICAST_LOOP 34 /* i_char; set/get IP multicast loopback */ -#define IP_ADD_MEMBERSHIP 35 /* ip_mreq; add an IP group membership */ -#define IP_DROP_MEMBERSHIP 36 /* ip_mreq; drop an IP group membership */ - -/* To select the IP level. */ -#define SOL_IP 0 - -/* Structure used to describe IP options for IP_OPTIONS. The `ip_dst' - field is used for the first-hop gateway when using a source route - (this gets put into the header proper). */ -struct ip_opts - { - struct in_addr ip_dst; /* First hop; zero without source route. */ - char ip_opts[40]; /* Actually variable in size. */ - }; - -/* Structure used for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. */ -struct ip_mreq - { - struct in_addr imr_multiaddr; /* IP multicast address of group */ - struct in_addr imr_interface; /* local IP address of interface */ - }; - -/* IPV6 socket options. */ -#define IPV6_ADDRFORM 1 -#define IPV6_PKTINFO 2 -#define IPV6_RXHOPOPTS 3 -#define IPV6_RXDSTOPTS 4 -#define IPV6_RXSRCRT 5 -#define IPV6_PKTOPTIONS 6 -#define IPV6_CHECKSUM 7 -#define IPV6_HOPLIMIT 8 - -#define SCM_SRCRT IPV6_RXSRCRT - -#define IPV6_UNICAST_HOPS 16 -#define IPV6_MULTICAST_IF 17 -#define IPV6_MULTICAST_HOPS 18 -#define IPV6_MULTICAST_LOOP 19 -#define IPV6_ADD_MEMBERSHIP 20 -#define IPV6_DROP_MEMBERSHIP 21 - -#endif /* netinet/inbits.h */ diff --git a/sysdeps/unix/sysv/linux/ptrace.c b/sysdeps/unix/sysv/linux/ptrace.c index 9f8053b0f0..b50234d2a1 100644 --- a/sysdeps/unix/sysv/linux/ptrace.c +++ b/sysdeps/unix/sysv/linux/ptrace.c @@ -52,6 +52,5 @@ ptrace (enum __ptrace_request request, ...) return res; } - __set_errno (-res); return -1; } diff --git a/sysdeps/unix/sysv/linux/sys/fsuid.h b/sysdeps/unix/sysv/linux/sys/fsuid.h index 8185b95724..fd30542e9f 100644 --- a/sysdeps/unix/sysv/linux/sys/fsuid.h +++ b/sysdeps/unix/sysv/linux/sys/fsuid.h @@ -20,7 +20,7 @@ #define _SYS_FSUID_H 1 #include -#include +#include __BEGIN_DECLS -- cgit v1.2.3