all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs)))
$(objpfx)version-info.h: $(+sysdir_pfx)config.make $(all-Banner-files)
(files="$(all-Banner-files)"; \
- if [ test -n "$$files" ]; then \
+ if test -n "$$files"; then \
echo "\"Available extensions:"; \
sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
echo "\""; \
The libm is in fact fdlibm (not the same as in Linux libc).
-**** Partly done.
+**** Partly done. But we need someone with numerical experiences for
+ the rest.
[ 6] If you enjoy assembler programming (as I do --drepper :-) you might
Please contact bug-glibc@prep.ai.mit.edu before starting to avoid
duplicated work.
-[11] Write access function for netmasks, bootparams, netgroup, publickey,
- automount, aliases databases for nss_files and nss_db module.
+[11] Write access function for netmasks, bootparams, publickey, automount,
+ and aliases databases for nss_files and nss_db module.
The functions should be embedded in the nss scheme. This is not
hard and not all services must be supported at once.
/* Version information is requested. */
if (do_version)
{
- fprintf (stderr, "gencat (GNU %s) %s\n", PACKAGE, VERSION);
- fprintf (stderr, _("\
+ printf ("gencat (GNU %s) %s\n", PACKAGE, VERSION);
+ printf (_("\
Copyright (C) %s Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"), "1996");
- fprintf (stderr, _("Written by %s.\n"),
- "Ulrich Drepper");
+ printf (_("Written by %s.\n"), "Ulrich Drepper");
exit (EXIT_SUCCESS);
}
program_invocation_name);
else
{
- printf(gettext ("\
+ printf (gettext ("\
Usage: %s [OPTION]... -o OUTPUT-FILE [INPUT-FILE]...\n\
%s [OPTION]... [OUTPUT-FILE [INPUT-FILE]...]\n\
Mandatory arguments to long options are mandatory for short options too.\n\
-V, --version output version information and exit\n\
If INPUT-FILE is -, input is read from standard input. If OUTPUT-FILE\n\
is -, output is written to standard output.\n"),
- program_invocation_name, program_invocation_name);
+ program_invocation_name, program_invocation_name);
fputs (gettext ("Report bugs to <bug-glibc@prep.ai.mit.edu>.\n"),
stdout);
}
if (__gmon_start__)
__gmon_start__ ();
-#ifdef _LIBC_REENTRANT
- {
- /* This is a trick to generate a reference for the symbol
- __libc_force_cancel_wrapper which can be used to force parts of
- the thread library to be used where some functions and system
- calls are overwritten. The value of this variable is always 0. */
- extern const int __libc_force_cancel_wrapper;
- if (__libc_force_cancel_wrapper)
- _init ();
- }
-#endif
-
/* End the here document containing the .init prologue code.
Then fetch the .section directive just written and append that
to crtn.s-new, followed by the function epilogue. */
/* Version information is requested. */
if (do_version)
{
- fprintf (stderr, "makedb (GNU %s) %s\n", PACKAGE, VERSION);
- fprintf (stderr, _("\
+ printf ("makedb (GNU %s) %s\n", PACKAGE, VERSION);
+ printf (_("\
Copyright (C) %s Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"), "1996");
- fprintf (stderr, _("Written by %s.\n"),
- "Ulrich Drepper");
+ printf (_("Written by %s.\n"), "Ulrich Drepper");
exit (EXIT_SUCCESS);
}
+/* You don't really want to know what this hack is for.
+Copyright (C) 1996 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <dlfcn.h>
#include <sys/gmon.h>
#include <sys/gmon_out.h>
-#include <ansidecl.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
-extern int __profile_frequency (void);
+extern int __profile_frequency __P ((void));
struct __bb *__bb_head; /* Head of basic-block list or NULL. */
* all the data structures are ready.
*/
void
-DEFUN(moncontrol, (mode), int mode)
+moncontrol (mode)
+ int mode;
{
struct gmonparam *p = &_gmonparam;
void
-DEFUN(monstartup, (lowpc, highpc), u_long lowpc AND u_long highpc)
+monstartup (lowpc, highpc)
+ u_long lowpc;
+ u_long highpc;
{
register int o;
char *cp;
static void
-DEFUN(write_hist, (fd), int fd)
+write_hist (fd)
+ int fd;
{
const u_char tag = GMON_TAG_TIME_HIST;
struct gmon_hist_hdr thdr;
- int size, rate;
if (_gmonparam.kcountsize > 0)
{
- size = _gmonparam.kcountsize / sizeof(HISTCOUNTER);
- rate = __profile_frequency();
- bcopy(&_gmonparam.lowpc, &thdr.low_pc, sizeof(thdr.low_pc));
- bcopy(&_gmonparam.highpc, &thdr.high_pc, sizeof(thdr.high_pc));
- bcopy(&size, &thdr.hist_size, sizeof(thdr.hist_size));
- bcopy(&rate, &thdr.prof_rate, sizeof(thdr.prof_rate));
- strcpy(thdr.dimen, "seconds");
+ thdr.low_pc = _gmonparam.lowpc;
+ thdr.high_pc = _gmonparam.highpc;
+ thdr.hist_size = _gmonparam.kcountsize / sizeof(HISTCOUNTER);
+ thdr.prof_rate = __profile_frequency();
+ strncpy(thdr.dimen, "seconds", sizeof(thdr.dimen));
thdr.dimen_abbrev = 's';
write(fd, &tag, sizeof(tag));
static void
-DEFUN(write_call_graph, (fd), int fd)
+write_call_graph (fd)
+ int fd;
{
const u_char tag = GMON_TAG_CG_ARC;
struct gmon_cg_arc_record raw_arc;
to_index != 0;
to_index = _gmonparam.tos[to_index].link)
{
- bcopy(&frompc, &raw_arc.from_pc, sizeof(raw_arc.from_pc));
- bcopy(&_gmonparam.tos[to_index].selfpc, &raw_arc.self_pc,
- sizeof(raw_arc.self_pc));
- bcopy(&_gmonparam.tos[to_index].count, &raw_arc.count,
- sizeof(raw_arc.count));
+ raw_arc.from_pc = frompc;
+ raw_arc.self_pc = _gmonparam.tos[to_index].selfpc;
+ raw_arc.count = _gmonparam.tos[to_index].count;
write(fd, &tag, sizeof(tag));
write(fd, &raw_arc, sizeof(raw_arc));
static void
-DEFUN(write_bb_counts, (fd), int fd)
+write_bb_counts (fd)
+ int fd;
{
struct __bb *grp;
const u_char tag = GMON_TAG_BB_COUNT;
void
-DEFUN_VOID(_mcleanup)
+_mcleanup ()
{
- const int version = GMON_VERSION;
struct gmon_hdr ghdr;
int fd;
}
/* write gmon.out header: */
- bcopy(GMON_MAGIC, &ghdr.cookie[0], 4);
- bcopy(&version, &ghdr.version, sizeof(version));
+ memset(&ghdr, 0, sizeof(ghdr));
+ memcpy(&ghdr.cookie[0], GMON_MAGIC, sizeof(ghdr.cookie));
+ ghdr.version = GMON_VERSION;
write(fd, &ghdr, sizeof(ghdr));
/* write PC histogram: */
* perform this optimization.
*/
_MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
- register u_long frompc, selfpc;
{
register u_short *frompcindex;
register struct tostruct *top, *prevtop;
*/
struct gmon_hdr {
char cookie[4];
- char version[4];
- char spare[3 * 4];
+ int version;
+ int spare[3];
};
/* types of records in this file: */
} GMON_Record_Tag;
struct gmon_hist_hdr {
- char low_pc[sizeof (char *)]; /* base pc address of sample buffer */
- char high_pc[sizeof (char *)]; /* max pc address of sampled buffer */
- char hist_size[4]; /* size of sample buffer */
- char prof_rate[4]; /* profiling clock rate */
+ unsigned long low_pc; /* base pc address of sample buffer */
+ unsigned long high_pc; /* max pc address of sampled buffer */
+ int hist_size; /* size of sample buffer */
+ int prof_rate; /* profiling clock rate */
char dimen[15]; /* phys. dim., usually "seconds" */
char dimen_abbrev; /* usually 's' for "seconds" */
};
struct gmon_cg_arc_record {
- char from_pc[sizeof (char *)]; /* address within caller's body */
- char self_pc[sizeof (char *)]; /* address within callee's body */
- char count[4]; /* number of arc traversals */
+ unsigned long from_pc; /* address within caller's body */
+ unsigned long self_pc; /* address within callee's body */
+ int count; /* number of arc traversals */
};
#endif /* !_SYS_GMON_OUT_H_ */
headers := netinet/ether.h netinet/in.h netinet/if_ether.h \
netinet/tcp.h $(wildcard arpa/*.h protocols/*.h)
+distribute := netgroup.h
+
routines := ntohl ntohs htonl htons \
inet_lnaof inet_mkadr \
inet_netof inet_ntoa inet_net herrno \
getrpcent_r getrpcbyname_r getrpcbynumber_r \
ether_aton ether_aton_r ether_hton ether_line \
ether_ntoa ether_ntoa_r ether_ntoh \
- rcmd rexec ruserpass
+ rcmd rexec ruserpass \
+ getnetgrent_r getnetgrent
# No warnings about losing BSD code.
override +gccwarn := -w
--- /dev/null
+/* Copyright (C) 1996 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include <netdb.h>
+
+
+int
+getnetgrent (char **hostp, char **userp, char **domainp)
+{
+ static char buffer[1024]; /* All three strings shouldn't use 1kB. */
+
+ return __getnetgrent_r (hostp, userp, domainp, buffer, sizeof (buffer));
+}
--- /dev/null
+/* Copyright (C) 1996 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include <libc-lock.h>
+#include <netdb.h>
+#include "netgroup.h"
+#include "nsswitch.h"
+
+
+/* Protect above variable against multiple uses at the same time. */
+__libc_lock_define_initialized (static, lock)
+
+/* This handle for the NSS data base is shared between all
+ set/get/endXXXent functions. */
+static service_user *nip;
+/* Remember the first service_entry, it's always the same. */
+static service_user *startp;
+
+
+/* The lookup function for the first entry of this service. */
+extern int __nss_netgroup_lookup (service_user **nip, const char *name,
+ void **fctp);
+
+/* Set up NIP to run through the services. If ALL is zero, use NIP's
+ current location if it's not nil. Return nonzero if there are no
+ services (left). */
+static enum nss_status
+setup (void **fctp, const char *func_name, int all)
+{
+ int no_more;
+ if (startp == NULL)
+ {
+ no_more = __nss_netgroup_lookup (&nip, func_name, fctp);
+ startp = no_more ? (service_user *) -1 : nip;
+ }
+ else if (startp == (service_user *) -1)
+ /* No services at all. */
+ return 1;
+ else
+ {
+ if (all || !nip)
+ /* Reset to the beginning of the service list. */
+ nip = startp;
+ /* Look up the first function. */
+ no_more = __nss_lookup (&nip, func_name, fctp);
+ }
+ return no_more;
+}
+\f
+int
+setnetgrent (const char *group)
+{
+ enum nss_status (*fct) (const char *);
+ enum nss_status status = NSS_STATUS_UNAVAIL;
+ int no_more;
+
+ __libc_lock_lock (lock);
+
+ /* Cycle through all the services and run their setnetgrent functions. */
+ no_more = setup ((void **) &fct, "setnetgrent", 1);
+ while (! no_more)
+ {
+ /* Ignore status, we force check in __NSS_NEXT. */
+ status = (*fct) (group);
+
+ no_more = __nss_next (&nip, "setnetgrent", (void **) &fct, status, 0);
+ }
+
+ __libc_lock_unlock (lock);
+
+ return status == NSS_STATUS_SUCCESS;
+}
+
+
+void
+endnetgrent (void)
+{
+ service_user *old_nip;
+ enum nss_status (*fct) (void);
+ int no_more;
+
+ __libc_lock_lock (lock);
+
+ /* Remember which was the last used service. */
+ old_nip = nip;
+
+ /* Cycle through all the services and run their setnetgrent functions. */
+ no_more = setup ((void **) &fct, "endnetgrent", 1);
+ while (! no_more)
+ {
+ /* Ignore status, we force check in __NSS_NEXT. */
+ (void) (*fct) ();
+
+ no_more = (nip == old_nip
+ || __nss_next (&nip, "endnetgrent", (void **) &fct, 0, 1));
+ }
+
+ __libc_lock_unlock (lock);
+}
+
+
+int
+__getnetgrent_r (char **hostp, char **userp, char **domainp,
+ char *buffer, int buflen)
+{
+ enum nss_status (*fct) (struct __netgrent *, char *, int);
+ struct __netgrent result;
+ int no_more;
+
+ /* Initialize status to return if no more functions are found. */
+ enum nss_status status = NSS_STATUS_NOTFOUND;
+
+ __libc_lock_lock (lock);
+
+ /* Run through available functions, starting with the same function last
+ run. We will repeat each function as long as it succeeds, and then go
+ on to the next service action. */
+ no_more = setup ((void **) &fct, "getnetgrent_r", 0);
+ while (! no_more)
+ {
+ status = (*fct) (&result, buffer, buflen);
+
+ no_more = __nss_next (&nip, "getnetgrent_r", (void **) &fct, status, 0);
+ }
+
+ if (status == NSS_STATUS_SUCCESS)
+ {
+ *hostp = result.host;
+ *userp = result.user;
+ *domainp = result.domain;
+ }
+
+ __libc_lock_unlock (lock);
+
+ return status == NSS_STATUS_SUCCESS ? 1 : 0;
+}
+weak_alias (__getnetgrent_r, getnetgrent_r)
+\f
+/* Test whether given (host,user,domain) triple is in NETGROUP. */
+int
+innetgr (const char *netgroup, const char *host, const char *user,
+ const char *domain)
+{
+ int (*setfct) (const char *);
+ void (*endfct) (void);
+ int (*getfct) (struct __netgrent *, char *, int);
+ int result = 0;
+ int no_more;
+
+ __libc_lock_lock (lock);
+
+ /* Walk through the services until we found an answer or we shall
+ not work further. We can do some optimization here. Since all
+ services must provide the `setnetgrent' function we can do all
+ the work during one walk through the service list. */
+ no_more = setup ((void **) &setfct, "setnetgrent", 1);
+ while (! no_more)
+ {
+ enum nss_status status;
+
+ /* Open netgroup. */
+ status = (*setfct) (netgroup);
+ if (status == NSS_STATUS_SUCCESS
+ && __nss_lookup (&nip, "getnetgrent_r", (void **) &getfct) == 0)
+ {
+ char buffer[1024];
+ struct __netgrent entry;
+
+ while ((*getfct) (&entry, buffer, sizeof buffer)
+ == NSS_STATUS_SUCCESS)
+ {
+ if ((entry.host == NULL || host == NULL
+ || strcmp (entry.host, host) == 0)
+ && (entry.user == NULL || user == NULL
+ || strcmp (entry.user, user) == 0)
+ && (entry.domain == NULL || domain == NULL
+ || strcmp (entry.domain, domain) == 0))
+ {
+ result = 1;
+ break;
+ }
+ }
+
+ if (result != 0)
+ break;
+
+ /* If we found one service which does know the given
+ netgroup we don't try further. */
+ status = NSS_STATUS_RETURN;
+ }
+
+ /* Free all resources of the service. */
+ if (__nss_lookup (&nip, "endnetgrent", (void **) &endfct) == 0)
+ (*endfct) ();
+
+ /* Look for the next service. */
+ no_more = __nss_next (&nip, "setnetgrent", (void **) &setfct, status, 0);
+ }
+
+ __libc_lock_unlock (lock);
+
+ return result;
+}
--- /dev/null
+/* Internal header for netgroup related functions.
+Copyright (C) 1996 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#ifndef _NETGROUP_H
+#define _NETGROUP_H 1
+
+struct __netgrent
+{
+ const char *host;
+ const char *user;
+ const char *domain;
+};
+
+#endif /* netgroup.h */
#include <ctype.h>
#include <string.h>
-#define MIN(A, B) ((A) < (B) ? (A) : (B))
-
int __ivaliduser __P((FILE *, u_int32_t, const char *, const char *));
static int __icheckhost __P((u_int32_t, char *));
#include "stdio.h"
void
-__clearerr_unlocked (fp)
+clearerr_unlocked (fp)
FILE *fp;
{
CHECK_FILE (fp, /*nothing*/);
_IO_clearerr (fp);
}
-
-weak_alias (__clearerr_unlocked, clearerr_unlocked)
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start (_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_getc_unlocked (fp);
__libc_cleanup_region_end (1);
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_putc_unlocked (c, fp);
__libc_cleanup_region_end (1);
#undef fputc_unlocked
int
-__fputc_unlocked (c, fp)
+fputc_unlocked (c, fp)
int c;
_IO_FILE *fp;
{
CHECK_FILE (fp, EOF);
return _IO_putc_unlocked (c, fp);
}
-
-weak_alias (__fputc_unlocked, fputc_unlocked)
CHECK_FILE (fp, NULL);
if (!(fp->_flags & _IO_IS_FILEBUF))
return NULL;
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_freopen (filename, mode, fp);
__libc_cleanup_region_end (1);
{
int result;
CHECK_FILE (fp, -1);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_fseek (fp, offset, whence);
__libc_cleanup_region_end (1);
_IO_ssize_t count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */
if (count > 0)
{
- if (count > more)
+ if ((_IO_size_t) count > more)
count = more;
if (count > 20)
{
_IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr; /* Data available. */
if (count > 0)
{
- if (count > more)
+ if ((_IO_size_t) count > more)
count = more;
if (count > 20)
{
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_getc_unlocked (fp);
__libc_cleanup_region_end (1);
#undef getc_unlocked
int
-__getc_unlocked (fp)
+getc_unlocked (fp)
FILE *fp;
{
CHECK_FILE (fp, EOF);
return _IO_getc_unlocked (fp);
}
-
-weak_alias (__getc_unlocked, getc_unlocked)
getchar ()
{
int result;
- __libc_cleanup_region_start (&_IO_funlockfile, stdin);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ stdin);
_IO_flockfile (stdin);
result = _IO_getc_unlocked (stdin);
__libc_cleanup_region_end (1);
#undef getchar_unlocked
int
-__getchar_unlocked ()
+getchar_unlocked ()
{
return _IO_getc_unlocked (stdin);
}
-
-weak_alias (__getchar_unlocked, getchar_unlocked)
CHECK_FILE(fp, EOF);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
if (fp->_IO_file_flags & _IO_IS_FILEBUF)
status = _IO_file_close_it (fp);
else
status = fp->_flags & _IO_ERR_SEEN ? -1 : 0;
_IO_FINISH (fp);
+ __libc_cleanup_region_end (1);
if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr)
{
fp->_IO_file_flags = 0;
free(fp);
}
- __libc_cleanup_region_end (1);
return status;
}
the executable file might be covered by the GNU General Public License. */
#include "libioP.h"
+#include <stdio.h>
int
_IO_fflush (fp)
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ fp);
_IO_flockfile (fp);
result = _IO_SYNC (fp) ? EOF : 0;
__libc_cleanup_region_end (1);
the executable file might be covered by the GNU General Public License. */
#include "libioP.h"
+#include <stdio.h>
int
-_IO_fflush_unlocked (fp)
+fflush_unlocked (fp)
register _IO_FILE *fp;
{
if (fp == NULL)
return _IO_SYNC (fp) ? EOF : 0;
}
}
-
-weak_alias (_IO_fflush_unlocked, fflush_unlocked)
-
{
_IO_fpos_t pos;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0);
__libc_cleanup_region_end (1);
/*
-Copyright (C) 1993, 1995 Free Software Foundation
+Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU IO Library. This library is free
software; you can redistribute it and/or modify it under the
the executable file might be covered by the GNU General Public License. */
#include "libioP.h"
+#include <stdio.h>
char*
_IO_fgets (buf, n, fp)
CHECK_FILE (fp, NULL);
if (n <= 0)
return NULL;
- __libc_cleanup_region_start (&__funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
__flockfile (fp);
count = _IO_getline (fp, buf, n - 1, '\n', 1);
if (count == 0 || (fp->_IO_file_flags & _IO_ERR_SEEN))
_IO_size_t len = strlen (str);
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
if (_IO_sputn (fp, str, len) != len)
result = EOF;
CHECK_FILE (fp, 0);
if (bytes_requested == 0)
return 0;
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
bytes_read = _IO_sgetn (fp, (char *) buf, bytes_requested);
__libc_cleanup_region_end (1);
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
if (_IO_seekpos (fp, *posp, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD)
{
{
_IO_pos_t pos;
CHECK_FILE (fp, -1L);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0);
__libc_cleanup_region_end (1);
CHECK_FILE (fp, 0);
if (request == 0)
return 0;
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
written = _IO_sputn (fp, (const char *) buf, request);
__libc_cleanup_region_end (1);
return -1;
}
CHECK_FILE (fp, -1);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
if (_IO_ferror_unlocked (fp))
{
-/*
+/*
Copyright (C) 1993 Free Software Foundation
This file is part of the GNU IO Library. This library is free
break;
else
len = fp->_IO_read_end - fp->_IO_read_ptr;
- if (len >= n)
+ if ((_IO_size_t) len >= n)
len = n;
t = (char*)memchr((void*)fp->_IO_read_ptr, delim, len);
if (t != NULL)
_IO_size_t count;
int ch;
- __libc_cleanup_region_start (&_IO_funlockfile, _IO_stdin);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _IO_stdin);
_IO_flockfile (_IO_stdin);
ch = _IO_getc_unlocked (_IO_stdin);
if (ch == EOF)
{
int result;
_IO_size_t len = strlen (str);
- __libc_cleanup_region_start (&_IO_funlockfile, _IO_stdout);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _IO_stdout);
_IO_flockfile (_IO_stdout);
if (_IO_sputn (_IO_stdout, str, len) == len
&& _IO_putc_unlocked ('\n', _IO_stdout) != EOF)
_IO_size_t size;
{
CHECK_FILE (fp, );
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
fp->_flags &= ~_IO_LINE_BUF;
if (!buf)
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
switch (mode)
{
CHECK_FILE (fp, EOF);
if (c == EOF)
return EOF;
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_sputbackc (fp, (unsigned char) c);
__libc_cleanup_region_end (1);
{
int result;
CHECK_FILE (fp, EOF);
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
result = _IO_putc_unlocked (c, fp);
__libc_cleanup_region_end (1);
int c;
{
int result;
- __libc_cleanup_region_start (&_IO_funlockfile, _IO_stdout);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
+ _IO_stdout);
_IO_flockfile (_IO_stdout);
result = _IO_putc_unlocked (c, _IO_stdout);
__libc_cleanup_region_end (1);
-/* Copyright (C) 1993 Free Software Foundation
+/* Copyright (C) 1993, 1996 Free Software Foundation, Inc.
This file is part of the GNU IO Library. This library is free
software; you can redistribute it and/or modify it under the
_IO_FILE* fp;
{
CHECK_FILE (fp, );
- __libc_cleanup_region_start (&_IO_funlockfile, fp);
+ __libc_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
_IO_flockfile (fp);
_IO_rewind (fp);
__libc_cleanup_region_end (1);
-/*
+/*
Copyright (C) 1993 Free Software Foundation
This file is part of the GNU IO Library. This library is free
fp->_flags |= _IO_CURRENTLY_PUTTING;
get_pos = LEN(fp);
}
- if (pos >= _IO_blen(fp) + flush_only)
+ if (pos >= (_IO_size_t) (_IO_blen(fp) + flush_only))
{
if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */
{
register _IO_FILE *fp)
{
_IO_ssize_t put_len = fp->_IO_write_ptr - fp->_IO_write_base;
- if (put_len < LEN(fp))
+ if (put_len < (_IO_ssize_t) LEN(fp))
put_len = LEN(fp);
return put_len;
-}
+}
_IO_pos_t
DEFUN(_IO_str_seekoff, (fp, offset, dir, mode),
default: /* case _IO_seek_set: */
break;
}
- if (offset < 0 || (_IO_size_t)offset > cur_size)
+ if (offset < 0 || (_IO_ssize_t)offset > cur_size)
return EOF;
fp->_IO_read_ptr = fp->_IO_read_base + offset;
fp->_IO_read_end = fp->_IO_read_base + cur_size;
default: /* case _IO_seek_set: */
break;
}
- if (offset < 0 || (_IO_size_t)offset > cur_size)
+ if (offset < 0 || (_IO_ssize_t)offset > cur_size)
return EOF;
LEN(fp) = cur_size;
fp->_IO_write_ptr = fp->_IO_write_base + offset;
{
unsigned int order = ++collate->order_cnt;
- if ((unsigned int) tmp != 0)
+ if ((unsigned long int) tmp != 0ul)
{
lr_error (lr, _("\
collation symbol `.*s' appears more than once: ignore line"),
# include <config.h>
#endif
+#include <alloca.h>
#include <endian.h>
#include <limits.h>
#include <string.h>
struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_TIME)
+ time->cur_num_era - 1
+ time->cur_num_alt_digits - 1
- + 1 + (time->cur_num_era * 9 - 1) * 2];
+ + 1 + (time->cur_num_era * 9 - 1) * 2
+ + (time->cur_num_era == 0)];
struct locale_file data;
u_int32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_TIME)];
size_t cnt, last_idx, num;
/* idx[1 + last_idx] += 8 * sizeof (int32_t) + l; */
}
+ /* We have a problem when no era data is present. In this case the
+ data pointer for _NL_TIME_ERA_ENTRIES_EB and
+ _NL_TIME_ERA_ENTRIES_EL point after the end of the file. So we
+ introduce some dummy data here. */
+ if (time->cur_num_era == 0)
+ {
+ static u_int32_t dummy = 0;
+ iov[2 + cnt].iov_base = (void *) &dummy;
+ iov[2 + cnt].iov_len = 4;
+ ++cnt;
+ }
assert (cnt == (_NL_ITEM_INDEX (_NL_NUM_LC_TIME)
+ time->cur_num_era - 1
+ time->cur_num_alt_digits - 1
- + 1 + (time->cur_num_era * 9 - 1) * 2)
+ + 1 + (time->cur_num_era * 9 - 1) * 2
+ + (time->cur_num_era == 0))
&& last_idx + 1 == _NL_ITEM_INDEX (_NL_NUM_LC_TIME));
write_locale_data (output_path, "LC_TIME", 2 + cnt, iov);
/* Version information is requested. */
if (do_version)
{
- fprintf (stderr, "locale (GNU %s) %s\n", PACKAGE, VERSION);
- fprintf (stderr, _("\
+ printf ("locale (GNU %s) %s\n", PACKAGE, VERSION);
+ printf (_("\
Copyright (C) %s Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"), "1995, 1996");
- fprintf (stderr, _("Written by %s.\n"),
- "Ulrich Drepper");
+ printf (_("Written by %s.\n"), "Ulrich Drepper");
exit (EXIT_SUCCESS);
}
/* Version information is requested. */
if (do_version)
{
- fprintf (stderr, "localedef (GNU %s) %s\n", PACKAGE, VERSION);
- fprintf (stderr, _("\
+ printf ("localedef (GNU %s) %s\n", PACKAGE, VERSION);
+ printf (_("\
Copyright (C) %s Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"), "1995, 1996");
- fprintf (stderr, _("Written by %s.\n"),
- "Ulrich Drepper");
+ printf (_("Written by %s.\n"), "Ulrich Drepper");
exit (0);
}
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
+#include <utmp.h>
int
login_tty(fd)
@item EBADF
The @var{dirstream} argument is not valid.
@end table
+
+@code{readdir} is not thread safe. Multiple threads using
+@code{readdir} on the same @var{dirstream} may overwrite the return
+value. Use @code{readdir_r} when this is critical.
+@end deftypefun
+
+@comment dirent.h
+@comment GNU
+@deftypefun int readdir_r (DIR *@var{dirstream}, struct *@var{entry}, struct **@var{result})
+This function is the reentrant version of @code{reentrant}. Like
+@code{readdir} it returns the next entry from the directory. But to
+prevent conflicts for simultanously running threads the result is not
+stored in some internal memory. Instead the argument @var{entry} has to
+point to a place where the result is stored.
+
+The return value is @code{0} in case the next entry was read
+successfully. In this case a pointer to the result is returned in
+*@var{result}. It is not required that *@var{result} is the same as
+@var{entry}. If somethings goes wrong while exeucting @code{readdir_r}
+the function return @code{-1}. The @code{errno} variable is set like
+described for @code{readdir}.
+
+@strong{Portability Note:} On some systems, @code{readdir_r} may not
+return a terminated string as the file name even if no @code{d_reclen}
+element is available in @code{struct dirent} and the file name as the
+maximal allowed size. Modern systems all have the @code{d_reclen} field
+and on old systems multi threading is not critical. In any case, there
+is no such problem with the @code{readdir} function so that even on
+systems without @code{d_reclen} field one could use multiple threads by
+using external locking.
@end deftypefun
@comment dirent.h
hsearch hsearch_r tsearch lsearch \
err error ustat \
getsysstats
-
-ifneq (,$(filter %REENTRANT, $(defines)))
-routines += force-wrapper
-endif
-
aux := init-misc
distribute := bsd-compat.c
extra-objs := bsd-compat.o
--- /dev/null
+#include <inet/netgroup.h>
# Caution: if you add a database here, you must add its real name
# in databases.def, too.
databases = proto service hosts network grp pwd rpc ethers \
- spwd
+ spwd netgrp
# Specify rules for the nss_* modules. We have some services.
services := files dns db
DEFINE_DATABASE (ethers)
DEFINE_DATABASE (group)
DEFINE_DATABASE (hosts)
+DEFINE_DATABASE (netgroup)
DEFINE_DATABASE (networks)
DEFINE_DATABASE (passwd)
DEFINE_DATABASE (protocols)
DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
- /etc/rpc /etc/services /etc/shadow)
+ /etc/rpc /etc/services /etc/shadow /etc/netgroup)
VAR_DB = /var/db
/^[^#]/ { printf ".%s ", $$1; print }' $^ | \
$(MAKEDB) -o $@ -
@echo "done."
+
+$(VAR_DB)/netgroup.db: /etc/netgroup
+ @echo -n "$(patsubst %.db,%,$(@F))... "
+ @$(AWK) '/^[^#]/ { end=sub(/\\/, " "); \
+ gsub(/[ \t]+/, " "); \
+ if(end == 1) printf "%s", $$0; else print }' $^ | \
+ $(MAKEDB) -o $@ -
+ @echo "done."
#ifdef NEED__RES
if ((_res.options & RES_INIT) == 0 && res_init () == -1)
{
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return NULL;
}
#endif /* need _res */
#ifdef NEED__RES
if ((_res.options & RES_INIT) == 0 && res_init () == -1)
{
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return NULL;
}
#endif /* need _res */
#ifdef NEED__RES
if ((_res.options & RES_INIT) == 0 && res_init () == -1)
{
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return NULL;
}
#endif /* need _res */
-/* readdir_r - Reentrant version of readdir.
-Copyright (C) 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <dirent.h>
+#define DATABASE_NAME netgroup
-/* Some systems have reentrancy problems with their `readdir'
- implementation so they have an additional `readdir_r' version. The
- GNU version does not have these problems but for compatibility
- reasons we provide this function. It is simply a wrapper around
- the normal function.
-
- The actual definition of this functions varies very strong from
- system to system. We chose to follow the POSIX version. */
-int
-readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result)
-{
- *result = readdir (dirp);
-
- return *result != NULL ? 0 : -1;
-}
+#include "XXX-lookup.c"
NSS_STATUS_UNAVAIL,
NSS_STATUS_NOTFOUND,
NSS_STATUS_SUCCESS,
+ NSS_STATUS_RETURN
};
static unsigned int entidx; /* Index for `getENTNAME'. */
/* Open database file if not already opened. */
-static int
+static enum nss_status
internal_setent (int stayopen)
{
- int status = NSS_STATUS_SUCCESS;
+ enum nss_status status = NSS_STATUS_SUCCESS;
if (db == NULL)
{
/* Thread-safe, exported version of that. */
-int
+enum nss_status
CONCAT(_nss_db_set,ENTNAME) (int stayopen)
{
- int status;
+ enum nss_status status;
__libc_lock_lock (lock);
/* Thread-safe, exported version of that. */
-int
+enum nss_status
CONCAT(_nss_db_end,ENTNAME) (void)
{
__libc_lock_lock (lock);
--- /dev/null
+/* Netgroup file parser in nss_db modules.
+Copyright (C) 1996 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include <db.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libc-lock.h>
+#include <paths.h>
+#include "nsswitch.h"
+#include "netgroup.h"
+
+
+#define DBFILE _PATH_VARDB "netgroup.db"
+
+
+/* Locks the static variables in this file. */
+__libc_lock_define_initialized (static, lock)
+\f
+/* Maintenance of the shared handle open on the database. */
+static DB *db;
+static char *entry;
+static char *cursor;
+
+enum nss_status
+_nss_db_setnetgrent (const char *group)
+{
+ enum nss_status status = NSS_STATUS_SUCCESS;
+
+ __libc_lock_lock (lock);
+
+ /* Make sure the data base file is open. */
+ if (db == NULL)
+ {
+ db = dbopen (DBFILE, O_RDONLY, 0, DB_BTREE, NULL);
+
+ if (db == NULL)
+ status = errno = EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
+ }
+
+ if (status == NSS_STATUS_SUCCESS)
+ {
+ DBT key = { data: (void *) group, size: strlen (group) };
+ DBT value;
+
+ if ((*db->get) (db, &key, &value, 0) != 0)
+ status = NSS_STATUS_NOTFOUND;
+ else
+ cursor = entry = value.data;
+ }
+
+ __libc_lock_unlock (lock);
+
+ return status;
+
+}
+
+
+enum nss_status
+_nss_db_endnetgrent (void)
+{
+ __libc_lock_lock (lock);
+
+ if (db != NULL)
+ {
+ (*db->close) (db);
+ db = NULL;
+ }
+
+ __libc_lock_unlock (lock);
+
+ return NSS_STATUS_SUCCESS;
+}
+
+
+extern enum nss_status _nss_netgroup_parseline (char **cursor,
+ struct __netgrent *result,
+ char *buffer, int buflen);
+
+enum nss_status
+_nss_db_getnetgrent_r (struct __netgrent *result, char *buffer, int buflen)
+{
+ int status;
+
+ __libc_lock_lock (lock);
+
+ status = _nss_netgroup_parseline (&cursor, result, buffer, buflen);
+
+ __libc_lock_unlock (lock);
+
+ return status;
+}
OSF/1 has a per-thread h_errno variable. */
if (header_pointer->aa != 0)
{
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
return NSS_STATUS_NOTFOUND;
}
else
{
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return NSS_STATUS_TRYAGAIN;
}
return NSS_STATUS_SUCCESS;
}
- /* XXX Really use global variable??? */
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return NSS_STATUS_TRYAGAIN;
}
--- /dev/null
+/* Netgroup file parser in nss_files modules.
+Copyright (C) 1996 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include <ctype.h>
+#include <errno.h>
+#include <libc-lock.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "nsswitch.h"
+#include "netgroup.h"
+
+#define DATAFILE "/etc/netgroup"
+
+
+/* Locks the static variables in this file. */
+__libc_lock_define_initialized (static, lock)
+\f
+/* We share a single place where we store the data for the current
+ netgroup. This buffer is allocated by `setnetgrent' and freed on
+ the next call of this function or when calling `endnetgrent'. */
+static char *data;
+static size_t data_size;
+static char *cursor;
+static int first;
+
+
+#define EXPAND(needed) \
+ do \
+ { \
+ size_t old_cursor = cursor - data; \
+ \
+ data_size += 512 > 2 * needed ? 512 : 2 * needed; \
+ data = realloc (data, data_size); \
+ \
+ if (data == NULL) \
+ { \
+ status = NSS_STATUS_UNAVAIL; \
+ goto the_end; \
+ } \
+ \
+ cursor = data + old_cursor; \
+ } \
+ while (0)
+
+
+enum nss_status
+_nss_files_setnetgrent (const char *group)
+{
+ FILE *fp;
+ enum nss_status status;
+
+ if (group[0] == '\0')
+ return NSS_STATUS_UNAVAIL;
+
+ __libc_lock_lock (lock);
+
+ /* Find the netgroups file and open it. */
+ fp = fopen (DATAFILE, "r");
+ if (fp == NULL)
+ status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
+ else
+ {
+ /* Read the file line by line and try to find the description
+ GROUP. We must take care for long lines. */
+ char *line = NULL;
+ size_t line_len = 0;
+ const ssize_t group_len = strlen (group);
+
+ status = NSS_STATUS_NOTFOUND;
+ cursor = data;
+
+ while (!feof (fp))
+ {
+ ssize_t curlen = getline (&line, &line_len, fp);
+ int found;
+
+ if (curlen < 0)
+ {
+ status = NSS_STATUS_NOTFOUND;
+ break;
+ }
+
+ found = (curlen > group_len && strncmp (line, group, group_len) == 0
+ && isspace (line[group_len]));
+
+ /* Read the whole line (including continuation) and store it
+ if FOUND in nonzero. Otherwise we don't need it. */
+ if (found)
+ {
+ /* Store the data from the first line. */
+ EXPAND (curlen - group_len);
+ memcpy (cursor, &line[group_len + 1], curlen - group_len);
+ cursor += (curlen - group_len) - 1;
+ }
+
+ while (line[curlen - 1] == '\n' && line[curlen - 2] == '\\')
+ {
+ /* Yes, we have a continuation line. */
+ if (found)
+ /* Remove these characters from the stored line. */
+ cursor -= 2;
+
+ /* Get netxt line. */
+ curlen = getline (&line, &line_len, fp);
+ if (curlen <= 0)
+ break;
+
+ if (found)
+ {
+ /* Make sure we have enough room. */
+ EXPAND (1 + curlen + 1);
+
+ /* Add separator in case next line starts immediately. */
+ *cursor++ = ' ';
+
+ /* Copy new line. */
+ memcpy (cursor, line, curlen + 1);
+ cursor += curlen;
+ }
+ }
+
+ if (found)
+ {
+ /* Now we have read the line. */
+ status = NSS_STATUS_SUCCESS;
+ cursor = data;
+ first = 1;
+ break;
+ }
+ }
+
+ the_end:
+ /* We don't need the file and the line buffer anymore. */
+ free (line);
+ fclose (fp);
+ }
+
+ __libc_lock_unlock (lock);
+
+ return status;
+}
+
+
+int
+_nss_files_endnetgrent (void)
+{
+ __libc_lock_lock (lock);
+
+ /* Free allocated memory for data if some is present. */
+ if (data != NULL)
+ {
+ free (data);
+ data = NULL;
+ data_size = 0;
+ cursor = NULL;
+ }
+
+ __libc_lock_unlock (lock);
+
+ return NSS_STATUS_SUCCESS;
+}
+
+
+enum nss_status
+_nss_netgroup_parseline (char **cursor, struct __netgrent *result,
+ char *buffer, int buflen)
+{
+ enum nss_status status;
+ const char *host, *user, *domain;
+ char *cp = *cursor;
+
+ /* First skip leading spaces. */
+ while (isspace (*cp))
+ ++cp;
+
+ if (*cp != '(')
+ return first ? NSS_STATUS_NOTFOUND : NSS_STATUS_RETURN;
+
+ /* Match host name. */
+ host = ++cp;
+ while (*cp != ',')
+ if (*cp++ == '\0')
+ return first ? NSS_STATUS_NOTFOUND : NSS_STATUS_RETURN;
+
+ /* Match user name. */
+ user = ++cp;
+ while (*cp != ',')
+ if (*cp++ == '\0')
+ return first ? NSS_STATUS_NOTFOUND : NSS_STATUS_RETURN;
+
+ /* Match domain name. */
+ domain = ++cp;
+ while (*cp != ')')
+ if (*cp++ == '\0')
+ return first ? NSS_STATUS_NOTFOUND : NSS_STATUS_RETURN;
+ ++cp;
+
+
+ /* When we got here we have found an entry. Before we can copy it
+ to the private buffer we have to make sure it is big enough. */
+ if (cp - host > buflen)
+ {
+ __set_errno (ERANGE);
+ status = NSS_STATUS_UNAVAIL;
+ }
+ else
+ {
+ memcpy (buffer, host, cp - host);
+
+ buffer[(user - host) - 1] = '\0';
+ result->host = *host == ',' ? NULL : buffer;
+
+ buffer[(domain - host) - 1] = '\0';
+ result->user = *user == ',' ? NULL : buffer + (user - host);
+
+ buffer[(cp - host) - 1] = '\0';
+ result->domain = *domain == ')' ? NULL : buffer + (domain - host);
+
+ status = NSS_STATUS_SUCCESS;
+
+ /* Rememember where we stopped reading. */
+ *cursor = cp;
+
+ first = 0;
+ }
+
+ return status;
+}
+
+
+enum nss_status
+_nss_files_getnetgrent_r (struct __netgrent *result, char *buffer, int buflen)
+{
+ enum nss_status status;
+
+ __libc_lock_lock (lock);
+
+ status = _nss_netgroup_parseline (&cursor, result, buffer, buflen);
+
+ __libc_lock_unlock (lock);
+
+ return status;
+}
else
{
/* This is really only for debugging. */
- if (NSS_STATUS_TRYAGAIN > status || status > NSS_STATUS_SUCCESS)
+ if (NSS_STATUS_TRYAGAIN > status || status > NSS_STATUS_RETURN)
__libc_fatal ("illegal status in " __FUNCTION__);
if (nss_next_action (*ni, status) == NSS_ACTION_RETURN)
new_service->actions[2 + NSS_STATUS_UNAVAIL] = NSS_ACTION_CONTINUE;
new_service->actions[2 + NSS_STATUS_NOTFOUND] = NSS_ACTION_CONTINUE;
new_service->actions[2 + NSS_STATUS_SUCCESS] = NSS_ACTION_RETURN;
+ new_service->actions[2 + NSS_STATUS_RETURN] = NSS_ACTION_RETURN;
new_service->library = NULL;
new_service->known = NULL;
new_service->next = NULL;
services: db files
ethers: db files
rpc: db files
+
+netgroup: db files
/* Name of the service (`files', `dns', `nis', ...). */
const char *name;
/* Action according to result. */
- lookup_actions actions[4];
+ lookup_actions actions[5];
/* Link to the underlying library object. */
service_library *library;
/* Collection of known functions. */
--- /dev/null
+#include <nss/nsswitch.h>
#include <gnu/types.h>
#ifdef __USE_BSD
-#define u_char __u_char
-#define u_short __u_short
-#define u_int __u_int
-#define u_long __u_long
-#define quad_t __quad_t
-#define u_quad_t __u_quad_t
-#define fsid_t __fsid_t
+typedef __u_char u_char;
+typedef __u_short u_short;
+typedef __u_int u_int;
+typedef __u_long u_long;
+typedef __quad_t quad_t;
+typedef __u_quad_t u_quad_t;
+typedef __fsid_t fsid_t;
#endif
-#define dev_t __dev_t
-#define gid_t __gid_t
-#define ino_t __ino_t
-#define mode_t __mode_t
-#define nlink_t __nlink_t
-#define off_t __off_t
-#define loff_t __loff_t
-#define pid_t __pid_t
-#define uid_t __uid_t
-#ifndef ssize_t
-#define ssize_t __ssize_t
+typedef __dev_t dev_t;
+typedef __gid_t gid_t;
+typedef __ino_t ino_t;
+typedef __mode_t mode_t;
+typedef __nlink_t nlink_t;
+typedef __off_t off_t;
+typedef __loff_t loff_t;
+typedef __pid_t pid_t;
+typedef __uid_t uid_t;
+
+#ifndef ssize_t
+typedef __ssize_t ssize_t;
+#define ssize_t ssize_t
#endif
#ifdef __USE_BSD
-#define daddr_t __daddr_t
-#define caddr_t __caddr_t
+typedef __daddr_t daddr_t;
+typedef __caddr_t caddr_t;
+#endif
+
+#ifdef __USE_SVID
+typedef __key_t key_t;
#endif
#define __need_time_t
#ifdef __GNUC__
typedef long long int int64_t;
typedef unsigned long long int u_int64_t;
-typedef int register_t __attribute__ ((__mode__ (word)));
#endif
+typedef int register_t;
#else
#include <gnu/types.h>
#ifndef ssize_t
-#define ssize_t __ssize_t
+typedef __ssize_t ssize_t;
+#define ssize_t ssize_t
#endif
#define __need_size_t
/* Re-construct the password-file line for the given uid
in the given buffer. This knows the format that the caller
will expect, but this need not be the format of the password file. */
+
+int __getpw __P ((__uid_t uid, char *buf));
+
int
-getpw (uid, buf)
+__getpw (uid, buf)
__uid_t uid;
register char *buf;
{
return 0;
}
+weak_alias (__getpw, getpw)
case 2: /* Valid, means one byte of info */
/* Skip any number of spaces. */
- for (NULL; ch != '\0'; ch = *src++)
+ for ( ; ch != '\0'; ch = *src++)
if (!isspace(ch))
break;
/* Make sure there is another trailing = sign. */
* We know this char is an =. Is there anything but
* whitespace after it?
*/
- for (NULL; ch != '\0'; ch = *src++)
+ for ( ; ch != '\0'; ch = *src++)
if (!isspace(ch))
return (-1);
int save = errno;
printf(msg, num);
- errno = save;
+ __set_errno (save);
}
}
#else
buflen = sizeof hostbuf;
cp = answer->buf + HFIXEDSZ;
if (qdcount != 1) {
- h_errno = NO_RECOVERY;
+ __set_h_errno (NO_RECOVERY);
return (NULL);
}
n = dn_expand(answer->buf, eom, cp, bp, buflen);
if ((n < 0) || !(*name_ok)(bp)) {
- h_errno = NO_RECOVERY;
+ __set_h_errno (NO_RECOVERY);
return (NULL);
}
cp += n + QFIXEDSZ;
buflen -= n;
map_v4v6_hostent(&host, &bp, &buflen);
}
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (&host);
#endif
case T_A:
}
if (_res.options & RES_USE_INET6)
map_v4v6_hostent(&host, &bp, &buflen);
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (&host);
}
try_again:
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (NULL);
}
struct hostent *hp;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
if (_res.options & RES_USE_INET6) {
extern struct hostent *_gethtbyname2();
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
type = T_AAAA;
break;
default:
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
errno = EAFNOSUPPORT;
return (NULL);
}
* done a lookup.
*/
if (inet_pton(af, name, host_addr) <= 0) {
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
return (NULL);
}
strncpy(hostbuf, name, MAXDNAME);
host.h_addr_list = h_addr_ptrs;
if (_res.options & RES_USE_INET6)
map_v4v6_hostent(&host, &bp, &len);
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (&host);
}
if (!isdigit(*cp) && *cp != '.')
* done a lookup.
*/
if (inet_pton(af, name, host_addr) <= 0) {
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
return (NULL);
}
strncpy(hostbuf, name, MAXDNAME);
h_addr_ptrs[0] = (char *)host_addr;
h_addr_ptrs[1] = NULL;
host.h_addr_list = h_addr_ptrs;
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (&host);
}
if (!isxdigit(*cp) && *cp != ':' && *cp != '.')
extern struct hostent *_gethtbyaddr();
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
if (af == AF_INET6 && len == IN6ADDRSZ &&
size = IN6ADDRSZ;
break;
default:
- errno = EAFNOSUPPORT;
- h_errno = NETDB_INTERNAL;
+ __set_errno (EAFNOSUPPORT);
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
if (size != len) {
- errno = EINVAL;
- h_errno = NETDB_INTERNAL;
+ __set_errno (EINVAL);
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
switch (af) {
"gethostbyaddr: No A record for %s (verifying [%s])",
hname2, inet_ntoa(*((struct in_addr *)addr)));
_res.options = old_options;
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
return (NULL);
}
_res.options = old_options;
syslog(LOG_NOTICE|LOG_AUTH,
"gethostbyaddr: A record of %s != PTR record [%s]",
hname2, inet_ntoa(*((struct in_addr *)addr)));
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
return (NULL);
}
}
hp->h_addrtype = AF_INET6;
hp->h_length = IN6ADDRSZ;
}
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (hp);
}
int af, len;
if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
again:
if (!(p = fgets(hostbuf, sizeof hostbuf, hostf))) {
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
return (NULL);
}
if (*p == '#')
map_v4v6_hostent(&host, &bp, &buflen);
}
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (&host);
}
cp = answer->buf + HFIXEDSZ;
if (!qdcount) {
if (hp->aa)
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
else
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (NULL);
}
while (qdcount-- > 0)
net_entry.n_aliases++;
return (&net_entry);
}
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (NULL);
}
struct netent *net_entry;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
strcpy(&qbuf[0], net);
#include <errno.h>
#include <stdio.h>
+#include <string.h>
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
/* Use a macro to access always the thread specific `h_errno' variable. */
#define h_errno (*__h_errno_location ())
+
+/* Retain some binary compatibility with old libraries by having both the
+ global variable and the per-thread variable set on error. */
+#define __set_h_errno(x) (h_errno = __h_errno = (x))
+#else
+#define __set_h_errno(x) (h_errno = (x))
#endif
/* Possible values left in `h_errno'. */
#endif /* reentrant */
+/* Establish network group NETGROUP for enumeration. */
+extern int setnetgrent __P ((__const char *__netgroup));
+
+/* Free all space allocated by previous `setnetgrent' call. */
+extern void endnetgrent __P ((void));
+
+/* Get next member of netgroup established by last `setnetgrent' call
+ and return pointers to elements in HOSTP, USERP, and DOMAINP. */
+extern int getnetgrent __P ((char **__hostp, char **__userp,
+ char **__domainp));
+
+/* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN). */
+extern int innetgr __P ((__const char *__netgroup, __const char *__host,
+ __const char *__user, __const char *domain));
+
+#ifdef __USE_REENTRANT
+/* Reentrant version of `getnetgrent' where result is placed in BUFFER. */
+extern int __getnetgrent_r __P ((char **__hostp, char **__userp,
+ char **__domainp,
+ char *__buffer, int __buflen));
+extern int getnetgrent_r __P ((char **__hostp, char **__userp,
+ char **__domainp,
+ char *__buffer, int __buflen));
+#endif
+
__END_DECLS
#endif /* netdb.h */
char base64_key[MAX_KEY_BASE64];
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
cp = __p_fqnname(cp, msg, MAXCDNAME, rrname, sizeof rrname);
u_char *dnptrs[20], **dpp, **lastdnptr;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (-1);
}
#ifdef DEBUG
hp->rcode = NOERROR; /* default */
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (-1);
}
#ifdef DEBUG
if (_res.options & RES_DEBUG)
printf(";; res_query: mkquery failed\n");
#endif
- h_errno = NO_RECOVERY;
+ __set_h_errno (NO_RECOVERY);
return (n);
}
n = res_send(buf, n, answer, anslen);
if (_res.options & RES_DEBUG)
printf(";; res_query: send error\n");
#endif
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (n);
}
#endif
switch (hp->rcode) {
case NXDOMAIN:
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
break;
case SERVFAIL:
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
break;
case NOERROR:
- h_errno = NO_DATA;
+ __set_h_errno (NO_DATA);
break;
case FORMERR:
case NOTIMP:
case REFUSED:
default:
- h_errno = NO_RECOVERY;
+ __set_h_errno (NO_RECOVERY);
break;
}
return (-1);
int got_nodata = 0, got_servfail = 0, tried_as_is = 0;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (-1);
}
__set_errno (0);
- h_errno = HOST_NOT_FOUND; /* default, if we never query */
+ __set_h_errno (HOST_NOT_FOUND); /* default, if we never query */
dots = 0;
for (cp = name; *cp; cp++)
dots += (*cp == '.');
* fully-qualified.
*/
if (errno == ECONNREFUSED) {
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (-1);
}
* the last DNSRCH we did.
*/
if (saved_herrno != -1)
- h_errno = saved_herrno;
+ __set_h_errno (saved_herrno);
else if (got_nodata)
- h_errno = NO_DATA;
+ __set_h_errno (NO_DATA);
else if (got_servfail)
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (-1);
}
int n;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (-1);
}
#ifdef DEBUG
#ifdef USE_IN_LIBIO
# include "../libio/libioP.h"
+# undef ssize_t
# define ssize_t _IO_ssize_t
# define __getdelim _IO_getdelim
#endif
printf_function **__printf_function_table;
+int __register_printf_function __P ((int, printf_function,
+ printf_arginfo_function));
+
/* Register FUNC to be called to format SPEC specifiers. */
int
__register_printf_function (spec, converter, arginfo)
use the protected form here. In stdio it is called `__vscanf' and
in libio `_IO_vscanf'. */
#ifdef USE_IN_LIBIO
+# include <libioP.h>
# define VSCANF _IO_vscanf
#else
# define VSCANF __vscanf
/* By using two buffers we manage to be thread safe in the case
where S != NULL. */
static char buf[L_tmpnam];
- char *tmpbuf[L_tmpnam];
+ char tmpbuf[L_tmpnam];
char *result;
/* In the following call we use the buffer pointed to by S if
-/* Copyright (C) 1992, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <stdio.h>
#ifdef USE_IN_LIBIO
+# undef ssize_t
# define ssize_t _IO_ssize_t
#endif
int
-DEFUN_VOID(main)
+main ()
{
char *buf = NULL;
size_t size = 0;
# define PUTC(C, F) _IO_putc_unlocked (C, F)
# define vfprintf _IO_vfprintf
# define FILE _IO_FILE
+# undef va_list
# define va_list _IO_va_list
# undef BUFSIZ
# define BUFSIZ _IO_BUFSIZ
# include <libioP.h>
# include <libio.h>
+# undef va_list
# define va_list _IO_va_list
# define ungetc(c, s) (--read_in, _IO_ungetc (c, s))
# define inchar() ((c = _IO_getc_unlocked (s)), (void) ++read_in, c)
char *p;
for (i=0; i < 0x100; i++)
{
- p = (char *)((int)(buf + 0xff) & ~0xff) + i;
+ p = (char *)((unsigned long int)(buf + 0xff) & ~0xff) + i;
strcpy (p, "OK");
strcpy (p+3, "BAD/WRONG");
check(strlen(p) == 2, 4+i);
char *p;
for (i=0; i < 0x100; i++)
{
- p = (char *)((int)(buf + 0xff) & ~0xff) + i;
+ p = (char *)((unsigned long int)(buf + 0xff) & ~0xff) + i;
strcpy (p, "OK");
strcpy (p+3, "BAD/WRONG");
check(strchr(p, '/') == NULL, 9+i);
char *p;
for (i=0; i < 0x100; i++)
{
- p = (char *)((int)(buf + 0xff) & ~0xff) + i;
+ p = (char *)((unsigned long int)(buf + 0xff) & ~0xff) + i;
strcpy (p, "OK");
strcpy (p+3, "BAD/WRONG");
check(strrchr(p, '/') == NULL, 9+i);
/* Machine-specific calling sequence for `mcount' profiling function. alpha
-Copyright (C) 1995 Free Software Foundation, Inc.
+Copyright (C) 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#define _MCOUNT_DECL void __mcount
+#define _MCOUNT_DECL(from, self) \
+ void __mcount (u_long from, u_long self)
/* Call __mcount with our the return PC for our caller, and the return
PC our caller will return to. Empty since we use an assembly stub
typedef char *__caddr_t;
typedef long int __time_t;
typedef long int __swblk_t; /* Type of a swap block maybe? */
+typedef long int __key_t; /* Type of an IPC key */
\f
/* fd_set for select. */
static void mcount_internal (u_long frompc, u_long selfpc);
#define _MCOUNT_DECL(frompc, selfpc) \
-static inline void mcount_internal (frompc, selfpc)
+static inline void mcount_internal (u_long frompc, u_long selfpc)
#define MCOUNT \
void _mcount (void) \
#include <string.h>
#include <grp.h>
#include <pty.h>
+#include <utmp.h>
int
openpty(amaster, aslave, name, termp, winp)
struct termios *termp;
struct winsize *winp;
{
- extern int login_tty __P ((int fd));
int master, slave, pid;
if (openpty(&master, &slave, name, termp, winp) == -1)
s = strpbrk (token, delim);
if (s == NULL)
/* This token finishes the string. */
- olds = NULL;
+ olds = strchr (token, '\0');
else
{
/* Terminate the token and make OLDS point past it. */
s = strpbrk (token, delim);
if (s == NULL)
/* This token finishes the string. */
- *save_ptr = NULL;
+ *save_ptr = strchr (token, '\0');
else
{
/* Terminate the token and make *SAVE_PTR point past it. */
print "";
print "#include <errno.h>";
print "";
- print "const char *_sys_errlist[] =";
+ print "const char *const _sys_errlist[] =";
print " {";
print " [0] = N_(\"Success\"),"
}
#include <errno.h>
-const char *_sys_errlist[] =
+const char *const _sys_errlist[] =
{
[0] = N_("Success"),
#ifdef EPERM
extern int errno;
#endif
#ifndef __set_errno
-#define __set_errno(val) errno = 8val)
+#define __set_errno(val) errno = (val)
#endif
#if defined(EACCES) && !defined(EACCESS)
static __sighandler_t wrapped_handlers[NSIG];
static sigset_t wrapped_masks[NSIG];
+static void wrapper_handler __P ((int sig));
+static inline int convert_mask __P ((sigset_t *set, const int mask));
+
static void
wrapper_handler (sig)
int sig;
len = dlen + 1 + plen + 5 + 3;
while (1)
{
- const size_t i;
+ size_t i;
if (*idx >= ((sizeof (letters) - 1) * (sizeof (letters) - 1) *
(sizeof (letters) - 1)))
Create a stream for it. */
#ifdef USE_IN_LIBIO
int save;
+ struct locked_FILE
+ {
+ struct _IO_FILE_plus fp;
+#ifdef _IO_MTSAFE_IO
+ _IO_lock_t lock;
+#endif
+ } *new_f;
struct _IO_FILE_plus *fp;
- fp = (struct _IO_FILE_plus *)
- malloc (sizeof (struct _IO_FILE_plus));
- if (fp == NULL)
+ new_f = (struct locked_FILE *)
+ malloc (sizeof (struct locked_FILE));
+ if (new_f == NULL)
{
/* We lost trying to create a stream (out of memory?).
Nothing to do but remove the file, close the descriptor,
__set_errno (save);
return NULL;
}
+ fp = &new_f->fp;
+#ifdef _IO_MTSAFE_IO
+ fp->file._lock = &new_f->lock;
+#endif
_IO_init (&fp->file, 0);
_IO_JUMPS (&fp->file) = &_IO_file_jumps;
_IO_file_init (&fp->file);
#include <sys/stat.h>
/* Change the flags of FILE to FLAGS. */
+
+int chflags __P ((const char *file, int flags));
+
int
chflags (file, flags)
const char *file;
#include <sys/stat.h>
/* Change the flags of the file FD refers to to FLAGS. */
+
+int fchflags __P ((int fd, int flags));
+
int
fchflags (fd, flags)
int fd;
/* Increase the size of the stack by INCREMENT,
and return the address of the bottom of the stack. */
+
+void *sstk __P ((int increment));
+
void *
sstk (increment)
int increment;
endif
endif
-$(common-objpfx)s-proto.d: $(..)sysdeps/unix/s-proto.S $(before-compile)
+$(common-objpfx)s-proto.d: $(common-objpfx)%.d: $(..)sysdeps/unix/%.S \
+ $(before-compile)
$(+make-deps)
endif
.type errno, @object
.size errno, 4
#endif
+ .globl __errno
+__errno = errno
.text
.align 2
.mask 0x4000001, -16
.prologue 1
- /* Find our pre-thread errno address */
+ /* Store into the "real" variable. */
+ stl v0, errno
+
+ /* Find our per-thread errno address */
jsr ra, __errno_location
/* Store the error value. */
{
struct dirent *dp;
- if (dirp == NULL || dirp->data == NULL)
- {
- __set_errno (EINVAL);
- return NULL;
- }
-
__libc_lock_lock (dirp->lock);
do
--- /dev/null
+/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include <errno.h>
+#include <limits.h>
+#include <stddef.h>
+#include <string.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <assert.h>
+
+#include <dirstream.h>
+
+
+/* Read a directory entry from DIRP. */
+int
+__readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result)
+{
+ struct dirent *dp;
+
+ __libc_lock_lock (dirp->lock);
+
+ do
+ {
+ size_t reclen;
+
+ if (dirp->offset >= dirp->size)
+ {
+ /* We've emptied out our buffer. Refill it. */
+
+ size_t maxread;
+ off_t base;
+ ssize_t bytes;
+
+#ifndef _DIRENT_HAVE_D_RECLEN
+ /* Fixed-size struct; must read one at a time (see below). */
+ maxread = sizeof *dp;
+#else
+ maxread = dirp->allocation;
+#endif
+
+ base = dirp->filepos;
+ bytes = __getdirentries (dirp->fd, dirp->data, maxread, &base);
+ if (bytes <= 0)
+ {
+ dp = NULL;
+ break;
+ }
+ dirp->size = (size_t) bytes;
+
+ /* Reset the offset into the buffer. */
+ dirp->offset = 0;
+ }
+
+ dp = (struct dirent *) &dirp->data[dirp->offset];
+
+#ifdef _DIRENT_HAVE_D_RECLEN
+ reclen = dp->d_reclen;
+#else
+ /* The only version of `struct dirent' that lacks `d_reclen'
+ is fixed-size. */
+ assert (sizeof dp->d_name > 1);
+ reclen = sizeof *dp;
+ /* The name is not terminated if it is the largest possible size.
+ Clobber the following byte to ensure proper null termination. We
+ read just one entry at a time above so we know that byte will not
+ be used later. */
+ dp->d_name[sizeof dp->d_name] = '\0';
+#endif
+
+ dirp->offset += reclen;
+
+#ifdef _DIRENT_HAVE_D_OFF
+ dirp->filepos = dp->d_off;
+#else
+ dirp->filepos += reclen;
+#endif
+
+ /* Skip deleted files. */
+ } while (dp->d_ino == 0);
+
+ if (dp != NULL)
+ {
+ *entry = *dp;
+ *result = entry;
+ }
+
+ __libc_lock_unlock (dirp->lock);
+
+ return dp != NULL ? 0 : -1;
+}
+weak_alias (__readdir_r, readdir_r)
typedef unsigned long __fd_mask;
#ifdef __USE_SVID
-typedef int key_t;
+typedef int __key_t;
#endif
#endif /* gnu/types.h */
#include <sysdep.h>
#include <fpu_control.h>
#include <linux/personality.h>
-#include "init-first.h"
+#include <init-first.h>
extern void __libc_init (int, char **, char **);
extern void __libc_global_ctors (void);
cause ld.so to gain an init function, which is not a cool thing. */
void
-_dl_start ()
+_dl_start (void)
{
abort ();
}
iopl - iopl 1 iopl
ipc msgget ipc 5 __ipc
klogctl EXTRA syslog 3 klogctl
-llseek EXTRA _llseek 5 llseek
+llseek EXTRA _llseek 5 _llseek
mlock EXTRA mlock 2 __mlock mlock
mlockall EXTRA mlockall 1 __mlockall mlockall
mount EXTRA mount 5 __mount mount