mirror of
git://sourceware.org/git/glibc.git
synced 2026-09-09 05:59:27 +08:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e1101a7da | ||
|
|
3e5f555752 | ||
|
|
bc9f6000f6 | ||
|
|
5ae9d168f6 | ||
|
|
f752bfe379 | ||
|
|
c57abfa735 | ||
|
|
e61abf8398 | ||
|
|
6465cfc9cf | ||
|
|
81e9dad672 |
+1
-1
@@ -1,4 +1,4 @@
|
||||
*.d *.o *.so *.po *.go stamp.* *.stamp *.ustamp *.udeps
|
||||
*.d *.o *.so *.po *.go *.bo stamp.* *.stamp *.ustamp *.udeps
|
||||
*.gz *.Z *.tar *.tgz
|
||||
=*
|
||||
TODO COPYING* AUTHORS copyr-* copying.*
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
List of known bugs (certainly very incomplete)
|
||||
----------------------------------------------
|
||||
|
||||
Time-stamp: <1997-03-22T04:31:41+0100 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
|
||||
|
||||
http://pogo.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
|
||||
`glibcbug' shell script which gets installed with GNU libc.
|
||||
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Severity: [ *] to [***]
|
||||
|
||||
|
||||
[ **] For GNU libc on Linux, there is still no solution for the UTMP
|
||||
problem.
|
||||
[Among others: PR libc/39]
|
||||
|
||||
[ **] There are problems with signal handling when using LinuxThreads.
|
||||
|
||||
[ **] The `cbrtl' function is inaccurate. The algorithm used for `double'
|
||||
and `float' is not usable for `long double'.
|
||||
|
||||
[ **] Not really a bug, but it could lead to such:
|
||||
The RPC code is ugly ugly ugly. It's more or less verbatim taken
|
||||
from Sun's code and therefore mostly lacks complete prototypes and
|
||||
(more important) the use of `const'. It *definitely* needs to be
|
||||
cleaned.
|
||||
|
||||
[ *] The precision of the `sinhl' and/or `asinhl' function do not seem
|
||||
to be the best.
|
||||
|
||||
[ *] The syslog function should print to the console if the LOG_CONS
|
||||
flag was given.
|
||||
[PR libc/72]
|
||||
|
||||
[ *] On Linux, the <linux/posix_types.h> is not clean enough to satisfy
|
||||
the C++ namespace rules. Declaring `struct fd_set' also makes
|
||||
`fd_set' available in the global namespace which conflicts with
|
||||
the definition of `fd_set' in glibc.
|
||||
[PR libc/79]
|
||||
|
||||
[ *] On Linux, there should be a way to prevent defining the symbol
|
||||
NGROUPS_MAX in the <linux/limits.h> header file. In glibc it
|
||||
is defined in <posix1_lim.h> which must not make the other
|
||||
symbols in <linux/limits.h> available.
|
||||
[PR libc/140]
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Ulrich Drepper
|
||||
drepper@cygnus.com
|
||||
@@ -1,12 +1,678 @@
|
||||
1997-03-25 02:15 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* gmon/gmon.c: Optimize a bit by using more sets of records to
|
||||
write in a single writev call.
|
||||
|
||||
* math/math.h: Add definitions of macros __MATHCALLX and __MATHDECLX.
|
||||
* math/mathcalls.h: Use __MATHCALLX for fabs, infnan, copysign,
|
||||
nan, isnan, nextafter, trunc, __fpclassify and signbit to mark as
|
||||
`const'.
|
||||
Use __MATHDECLX for isinf and finite.
|
||||
|
||||
* sysdeps/generic/setenv.c [_LIBC]: Define __clearenv and make
|
||||
clearenv a weak alias.
|
||||
|
||||
Implement complex exponential function.
|
||||
* sysdeps/libm-ieee754/s_cexp.c: New file.
|
||||
* sysdeps/libm-ieee754/s_cexpf.c: New file.
|
||||
* sysdeps/libm-ieee754/s_cexpl.c: New file.
|
||||
|
||||
* sysdeps/libm-ieee754/s_nan.c: Define function as __nan and make
|
||||
nan a weak alias.
|
||||
* sysdeps/libm-ieee754/s_nanf.c: Likewise for nanf.
|
||||
* sysdeps/libm-ieee754/s_nanl.c: Likewise for nanl.
|
||||
|
||||
* sysdeps/unix/sysv/linux/iovec.h: Don't use kernel header because
|
||||
of type clashes. Add all definitions here.
|
||||
|
||||
* sysdeps/unix/sysv/linux/shmat.c: Likewise. Correct types according
|
||||
to XPG4.2.
|
||||
* sysdeps/unix/sysv/linux/shmdt.c: Likewise.
|
||||
* sysdeps/unix/sysv/linux/msgrcv.c: Likewise.
|
||||
|
||||
* sysvipc/sys/shm.h (shmat, shmdt): Correct types.
|
||||
|
||||
* sysdeps/unix/sysv/linux/sys/kd.h: Define _LINUX_TYPES_H to avoid
|
||||
use of kernel types.
|
||||
|
||||
1997-03-25 00:00 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sysdeps/unix/sysv/linux/netinet/ip.h (struct ip_timestamp):
|
||||
Correct typos. Reported by a sun <asun@zoology.washington.edu>.
|
||||
|
||||
1997-03-20 21:58 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* sysdeps/libm-ieee754/s_asinhl.c: Fix sign of result.
|
||||
|
||||
1997-03-20 16:20 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* sysdeps/libm-ieee754/e_atan2l.c: Fix typo.
|
||||
|
||||
1997-03-20 14:23 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* sysdeps/m68k/fpu/__math.h (__logb, logb): Don't define.
|
||||
* sysdeps/m68k/fpu/s_logb.c: Removed.
|
||||
* sysdeps/m68k/fpu/s_logbf.c: Removed.
|
||||
* sysdeps/m68k/fpu/s_logbl.c: Removed.
|
||||
|
||||
* sysdeps/m68k/fpu/__math.h (__ieee754_atan2, __ieee754_pow):
|
||||
Don't define here.
|
||||
* sysdeps/m68k/fpu/e_atan2.c: Rewritten.
|
||||
* sysdeps/m68k/fpu/e_pow.c: Likewise.
|
||||
* sysdeps/m68k/fpu/e_atan2f.c: Based on e_atan2.c.
|
||||
* sysdeps/m68k/fpu/e_atan2l.c: Likewise.
|
||||
* sysdeps/m68k/fpu/e_powf.c: Based on e_pow.c.
|
||||
* sysdeps/m68k/fpu/e_powl.c: Likewise.
|
||||
|
||||
* sysdeps/m68k/fpu/s_log2.c: New file.
|
||||
* sysdeps/m68k/fpu/s_log2f.c: New file.
|
||||
* sysdeps/m68k/fpu/s_log2l.c: New file.
|
||||
* sysdeps/m68k/fpu/s_exp2.c: New file.
|
||||
* sysdeps/m68k/fpu/s_exp2f.c: New file.
|
||||
* sysdeps/m68k/fpu/s_exp2l.c: New file.
|
||||
|
||||
1997-03-20 14:46 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* Makeconfig (all): Make sure this is always the default goal.
|
||||
|
||||
1997-03-20 11:09 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* math/libm-test.c: Increase epsilon in many places. Fix many
|
||||
typos. Allow optinal argument also for short option.
|
||||
|
||||
1997-03-20 11:09 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* math/Makefile ($(objpfx)$(tests)): Link against libm.
|
||||
|
||||
1997-03-24 23:14 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sysdeps/libm-ieee754/s_fpclassifyl.c: Correct recognition of
|
||||
denormalized numbers.
|
||||
|
||||
* sysdeps/i386/huge_val.h: Remove references to byte order macros.
|
||||
Don't include <endian.h>.
|
||||
|
||||
1997-03-19 15:18 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
* sysdeps/m68k/huge_val.h: Remove references to byte order macros.
|
||||
Don't include <endian.h>.
|
||||
|
||||
1997-03-24 23:09 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* inet/rcmd.c (iruserok): Use access instead of euidaccess.
|
||||
|
||||
1997-03-15 18:08 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
* math/cmathcalls.h: Remove whitespace before function name in use
|
||||
of __MATHDECL macro, to make it compilable with a traditional
|
||||
preprocessor.
|
||||
|
||||
1997-03-24 15:31 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* configure.in: Use AC_PROG_CC instead of AC_PROG_TOOL to find
|
||||
compiler.
|
||||
|
||||
1997-03-24 02:34 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sysdeps/libm-ieee754/s_finitel.c (__finitel): Shift return value
|
||||
by 31 positions to get 0/1 result.
|
||||
Patch by Joe Keane <jgk@jgk.org>.
|
||||
|
||||
1997-03-23 12:15 H.J. Lu <hjl@gnu.ai.mit.edu>
|
||||
|
||||
* posix/getopt.c (__getopt_nonoption_flags): Make it extern
|
||||
to prevent from ld linking in getopt.o even if there is another
|
||||
incompatible one.
|
||||
|
||||
* posix/getopt_init.c (__getopt_nonoption_flags): Remove extern.
|
||||
|
||||
1997-03-23 23:30 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
|
||||
|
||||
* nis/nis_call.c (__do_niscall): Print message if cold start file
|
||||
does not exist.
|
||||
* nis/nis_file.c: Don't print error messages.
|
||||
* nis/nis_local_name.c (nis_local_host): Fix pointer errors.
|
||||
* nis/rpcsvc/ypclnt.h: Fix copyright and prototypes.
|
||||
* nis/rpcsvc/nis.h: Likewise.
|
||||
* nis/ypclnt.c: Fix prototypes.
|
||||
|
||||
1997-03-24 01:36 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sysdeps/libm-i387/e_scalb.S: Pop additional result before
|
||||
returning.
|
||||
* sysdeps/libm-i387/e_scalbf.S: Likewise.
|
||||
* sysdeps/libm-i387/e_scalbl.S: Likewise.
|
||||
Reported by Andreas Jaeger <aj@arthur.pfalz.de>.
|
||||
|
||||
* elf/rtld.c (dl_main): Set main_map->l_opencount to 1 also if
|
||||
dynamic linker was called implicitly by the kernel.
|
||||
Reported by Eric Youngdale <eric@andante.jic.com>.
|
||||
|
||||
* math/Makefile (CFLAGS-test-float.c, CFLAGS-test-double.c,
|
||||
CFLAGS-test-longdouble.c): New variables. Set to -fno-inline to
|
||||
prevent clever optimizations which corrupt the tests.
|
||||
|
||||
1997-03-23 21:33 Andreas Jaeger <aj@arthur.pfalz.de>
|
||||
|
||||
* math/libm-test.c (scalb_test): New function.
|
||||
(sqrt_test): New function.
|
||||
(scalbn_test): New function.
|
||||
(ilogb_test): New function.
|
||||
(main): Added calls for new test functions.
|
||||
(ldexp_test): Add another test for ldexp(x,0).
|
||||
|
||||
1997-03-23 12:35 Andreas Jaeger <aj@arthur.pfalz.de>
|
||||
|
||||
* math/libm-test.c (remquo_test): Correct messages so that they
|
||||
match the tests.
|
||||
(copysign_test): Likewise.
|
||||
|
||||
1997-03-23 16:28 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* stdio-common/Makefile (routines): Add printf_size.
|
||||
|
||||
* stdio-common/printf.h: Add declarations for printf_size and
|
||||
printf_size_info.
|
||||
|
||||
* stdio-common/printf-parse.h (__printf_arginfo_table): Correct
|
||||
declaration.
|
||||
(parse_one_spec): Test whether __printf_function_table is not NULL
|
||||
before using registered handlers and don't test
|
||||
__printf_arginfo_table. Update nargs also when handler is
|
||||
registered.
|
||||
|
||||
* stdio-common/vfprintf.c (vfprintf): Count number of specifiers
|
||||
processed in fast loop.
|
||||
|
||||
* stdio-common/printf_size: New file.
|
||||
|
||||
1997-03-23 02:11 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* time/sys/time.h: Make values ITIMER_* also available as macros.
|
||||
|
||||
* elf/dl-support.c (_dl_sysdep_read_whole_file): Don't call
|
||||
__fstat but instead __fxstat directly to avoid dependency on
|
||||
libc.a when inline failed.
|
||||
* sysdeps/generic/dl-sysdep.c (_dl_sysdep_read_whole_file): Likewise.
|
||||
|
||||
* math/Makefile (libm-routines): Add s_remquo.
|
||||
* sysdeps/libm-i387/s_remquo.S: New file.
|
||||
* sysdeps/libm-i387/s_remquof.S: New file.
|
||||
* sysdeps/libm-i387/s_remquol.S: New file.
|
||||
* sysdeps/libm-ieee754/s_remquo.c: New file.
|
||||
* sysdeps/libm-ieee754/s_remquof.c: New file.
|
||||
* sysdeps/libm-ieee754/s_remquol.c: New file.
|
||||
|
||||
* math/libm-test.c (remquo_test): New function.
|
||||
|
||||
* sysdeps/libm-ieee754/s_rintl.c: Handle implicit leading one
|
||||
correctly.
|
||||
|
||||
1997-03-22 14:06 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* math/Makefile (libm-calls): Add s_nan.
|
||||
* sysdeps/libm-ieee754/s_nan.c: New file. Implement `nan' function.
|
||||
* sysdeps/libm-ieee754/s_nanf.c: New file. Implement `nanf' function.
|
||||
* sysdeps/libm-ieee754/s_nanl.c: New file. Implement `nanl' function.
|
||||
|
||||
* math/libm-test.c (basic_tests): Add tests for `nan' function.
|
||||
|
||||
* math/libm-test.c (copysign_test): New function.
|
||||
(main): Call copysign_test.
|
||||
|
||||
1997-03-22 06:28 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sysdeps/libm-ieee754/s_nextafter.c: Return y if x == y.
|
||||
* sysdeps/libm-ieee754/s_nextafterf.c: Likewise.
|
||||
* sysdeps/libm-ieee754/s_nextafterl.c: Likewise.
|
||||
* sysdeps/libm-i387/s_nextafterl.c: Likewise.
|
||||
|
||||
* math/libm-test.c (fdim_test, fmin_test, fmax_test, nextafter_test):
|
||||
New functions. Test these functions.
|
||||
(main): Call above new functions.
|
||||
|
||||
1997-03-22 04:53 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* Net release 2.0.2.
|
||||
|
||||
1997-03-22 04:37 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sysdeps/unix/sysv/linux/termbits.h (OXTABS): Define as alias for
|
||||
XTABS.
|
||||
* sysdeps/unix/sysv/linux/alpha/termbits.h (OXTABS): Likewise.
|
||||
* termios/sys/ttydefaults.h: Partly revert patch by Andreas Schwab
|
||||
of Sun Dec 15 16:33:44 1996.
|
||||
Proposed by Thomas Bushnell <thomas@gnu.ai.mit.edu>.
|
||||
|
||||
1997-03-21 13:41 Roland McGrath <roland@baalperazim.frob.com>
|
||||
|
||||
* sysdeps/sparc/dl-machine.h (elf_machine_rel): Rewritten as for i386.
|
||||
Check here for non-SHN_UNDEF STB_LOCAL symbols don't do any lookup or
|
||||
consult their values.
|
||||
(elf_machine_lookup_noexec_p, elf_machine_lookup_noplt_p,
|
||||
ELF_MACHINE_RELOC_NOPLT): New macros.
|
||||
|
||||
* elf/rtld.c (dl_main): Pass ELF_MACHINE_RELOC_NOPLT to
|
||||
_dl_lookup_symbol in place of DL_LOOKUP_NOPLT.
|
||||
* sysdeps/i386/dl-machine.h (ELF_MACHINE_RELOC_NOPLT): New macro.
|
||||
|
||||
* sysdeps/i386/dl-machine.h (elf_machine_rel): Rewritten to do the
|
||||
symbol lookup before checking reloc type except for R_386_RELATIVE.
|
||||
(elf_machine_lookup_noexec_p, elf_machine_lookup_noplt_p): New macros.
|
||||
|
||||
* elf/dl-reloc.c (RESOLVE): Remove STB_LOCAL check; let it be
|
||||
per-machine since it supposedly can't happen on i386.
|
||||
|
||||
* elf/dl-lookup.c (do_lookup): Change arg FLAGS to RELOC_TYPE. Use
|
||||
elf_machine_lookup_{noexec,noplt}_p macros on it. Remove gratuitous
|
||||
indirection from REF arg; change callers.
|
||||
(_dl_lookup_symbol, _dl_lookup_versioned_symbol): Change arg name.
|
||||
(_dl_lookup_symbol_skip, _dl_lookup_versioned_symbol_skip): Remove
|
||||
FLAGS arg altogether.
|
||||
* elf/dlsym.c: Remove argument of FLAGS parameter.
|
||||
* elf/dlvsym.c: Likewise.
|
||||
* elf/link.h: Update decls.
|
||||
|
||||
1997-03-21 20:55 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* Makefile (distribute): Add BUGS.
|
||||
|
||||
* sysdeps/generic/machine-gmon.h: Update copyright.
|
||||
|
||||
* sysdeps/i386/Makefile [$(subdir)=gmon] (sysdep_routines): Add
|
||||
i386-mcount.
|
||||
* sysdeps/i386/dl-machine.h [PROF] (_dl_runtime_resolve): Don't
|
||||
use regparam mechanism for call of `fixup' call.
|
||||
* sysdeps/i386/Dist: New file.
|
||||
* sysdeps/i386/i386-mcount.S: New file. `mcount' entry point.
|
||||
* sysdeps/i386/machine-gmon.h: New file. i386 specific version
|
||||
of gmon definitions.
|
||||
|
||||
1997-03-20 13:39 Andreas Jaeger <aj@arthur.pfalz.de>
|
||||
|
||||
* stdlib/tst-strtol.c (main): Save the value of errno since printf
|
||||
may modify it, use the saved errno everywhere.
|
||||
* stdlib/tst-strtod.c (main): Likewise.
|
||||
|
||||
1997-03-21 05:54 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* posix/glob.c (glob): Fix completely broken handling of
|
||||
GLOB_BRACE and partly broken handling of GLOB_TILDE.
|
||||
Reported by Dennis Henriksen <opus@flamingo.osrl.dk>.
|
||||
|
||||
1997-03-20 20:22 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sysdeps/unix/sysv/linux/readv.c: Don't emulate readv with small
|
||||
UIO_FASTIOV value by multiple readv calls since we need atomicity.
|
||||
* sysdeps/unix/sysv/linux/writev.c: Likewise.
|
||||
Reported by Matthis Urlichs.
|
||||
|
||||
1997-03-20 04:34 Roland McGrath <roland@baalperazim.frob.com>
|
||||
|
||||
* sysdeps/unix/sysv/linux/i386/sysdep.S (CALL_MCOUNT): Clear this
|
||||
macro so ENTRY(__syscall_error) doesn't insert a call to _mcount,
|
||||
which clobbers %eax.
|
||||
|
||||
* Makeconfig [$(elf)=yes] (+prector, +postctor): New variables for
|
||||
crtbegin.o/crtend.o, using gcc to find them.
|
||||
(+link): Use them.
|
||||
|
||||
1997-03-20 00:06 Richard Henderson <rth@tamu.edu>
|
||||
|
||||
* gmon/sys/gmon.h: Revert the bulk of the 960930 changes, as they
|
||||
affect the alignment, and therefore the end padding of the structs.
|
||||
Reported by David Mosberger <davidm@azstarnet.com>.
|
||||
* gmon.c: Declare the variables with aligned tags to compensate.
|
||||
Use __writev instead of write for the I/O.
|
||||
|
||||
* misc/sys/uio.h: Declare __writev and __readv.
|
||||
* sysdeps/posix/readv.c: Rename and alias readv to __readv.
|
||||
* sysdeps/posix/writev.c: Likewise for writev.
|
||||
* sysdeps/stub/readv.c: Likewise.
|
||||
* sysdeps/stub/writev.c: Likewise.
|
||||
* sysdeps/unix/syscalls.list: Likewise.
|
||||
* sysdeps/unix/sysv/linux/readv.c: Likewise.
|
||||
* sysdeps/unix/sysv/linux/writev.c: Likewise.
|
||||
|
||||
* stdlib/testdiv.c: Exit with error status when we have an error.
|
||||
* sysdeps/alpha/div.S: Initialize `quotient' and `mask'.
|
||||
* sysdeps/alpha/ldiv.S: Likewise.
|
||||
|
||||
* sysdeps/unix/sysv/linux/alpha/ioperm.c: Include ctype.h for isdigit.
|
||||
|
||||
1997-03-20 14:51 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* nis/nis_file.c: Unify error handling.
|
||||
|
||||
1997-03-19 18:36 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
|
||||
|
||||
* nis/nis_file.c (writeColdStartFile): Fix typo.
|
||||
* nis/nis_free.c (nis_free_endpoints): Use unsigned int.
|
||||
* nis/nis_free.c (nis_free_servers): Likewise.
|
||||
* nis/rpcsvc/nislib.h: Likewise.
|
||||
|
||||
* sunrpc/rpc/netdb.h: Add setrpcent and endrpcent prototypes.
|
||||
|
||||
1997-03-20 06:07 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sysdeps/powerpc/dl-machine.h: Fix typo in last change.
|
||||
|
||||
* sysdeps/unix/sparc/sysdep.h: Update copyright.
|
||||
|
||||
1997-03-19 15:13 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* linuxthreads/sysdeps/sparc/pt-machine (RELEASE): Fix.
|
||||
|
||||
* stdlib/tst-strtol.c: Save the value of errno, printf may modify
|
||||
it.
|
||||
|
||||
* sysdeps/sparc/DEFS.h [HAVE_ELF]: Use type @function in the FUNC
|
||||
macro on ELF systems.
|
||||
|
||||
* sysdeps/sparc/configure.in: Fix.
|
||||
|
||||
* sysdeps/sparc/dl-machine.h: Fix OPCODE_CALL.
|
||||
|
||||
* sysdeps/sparc/setjmp.S: Fix my bugs.
|
||||
|
||||
* sysdeps/unix/sysv/linux/sparc/Dist: Add start.c, fork.S, and pipe.S.
|
||||
* sysdeps/unix/sysv/linux/sparc/Makefile: Define asm-CPPFLAGS and
|
||||
as-FLAGS-.so.
|
||||
* sysdeps/unix/sysv/linux/sparc/syscalls.list: Add fork, pipe, and
|
||||
syscall.
|
||||
* sysdeps/unix/sysv/linux/sparc/fork.S: New file.
|
||||
* sysdeps/unix/sysv/linux/sparc/pipe.S: New file.
|
||||
* sysdeps/unix/sysv/linux/sparc/socket.S: Fix.
|
||||
* sysdeps/unix/sysv/linux/sparc/sysdep.h: Fix.
|
||||
|
||||
* elf/dl-lookup.c (do_lookup): Return true if we found a weak
|
||||
symbol.
|
||||
(_dl_lookup_symbol): Test against the symbol being global not
|
||||
against the symbol being not weak (fixes important problem with
|
||||
the SPARC linker)
|
||||
|
||||
* sysdeps/unix/sysv/linux/sparc/brk.c: Fix.
|
||||
|
||||
* sysdeps/unix/sysv/linux/sparc/start.c: Startup code for
|
||||
Linux/SPARC (while I get my asmCPPFLAGS-so variable).
|
||||
|
||||
1997-03-20 01:49 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* Makeconfig: (rpath-link): Add math/ directory.
|
||||
(math-objdir): New variable.
|
||||
(link-extra-lib): Define to special version when
|
||||
$(common-objpfx)!=$(objpfx) to allow libraries outside
|
||||
$(common-objpfx) be linked to the application.
|
||||
|
||||
* math/Makefile: Add rules to build and run test programs.
|
||||
* math/libm-test.c (_GNU_SOURCE): Define only if still undefined.
|
||||
(check_equal): Correct check for error.
|
||||
(ceil_test): Fix typo.
|
||||
(log_test): Fix typo.
|
||||
(floor_test): Fix typo.
|
||||
(pow_test): Fix typos.
|
||||
(log10_test): Allow slight incorrectness for `log10(e)'.
|
||||
(modf_test): New functions to test `modf' et.al.
|
||||
(hypot_test): Rewrite test completely.
|
||||
Patch partly by Andreas Jaeger.
|
||||
* math/test-double.h (__NO_MATH_INLINES): Define only if not
|
||||
already defined.
|
||||
* math/test-float.h: Likewise.
|
||||
* math/test-logdouble.h: Likewise.
|
||||
|
||||
* setjmp/setjmp.h: Change references of ANSI C to ISO C.
|
||||
* setjmp/tst-setjmp.c: Correct and extend test suite.
|
||||
* sysdeps/i386/__longjmp.S: Update copyright.
|
||||
* sysdeps/i386/bsd-_setjmp.S: Correct fatal bug in jump to
|
||||
`__sigsetjmp' in PIC code.
|
||||
* sysdeps/i386/bsd-setjmp.S: Likewise.
|
||||
|
||||
* sysdeps/libm-i387/e_pow.S: Correct recognition of mantissa
|
||||
overflow.
|
||||
* sysdeps/libm-i387/e_powf.S: Likewise.
|
||||
* sysdeps/libm-i387/s_expm1.S: Handle x == +-0 as a special
|
||||
case since expm1(-0) == -0.
|
||||
* sysdeps/libm-i387/s_expm1f.S: Likewise.
|
||||
* sysdeps/libm-i387/s_expm1l.S: Likewise.
|
||||
* sysdeps/libm-ieee754/s_modf.c: Optimize code by avoiding unneeded
|
||||
access to FP number.
|
||||
* sysdeps/libm-ieee754/s_modff.c: Likewise.
|
||||
* sysdeps/libm-ieee754/s_modfl.c: Correct former completely bogus
|
||||
code. It never worked correctly.
|
||||
* sysdeps/libm-ieee754/s_tanh.c: Handle x == +-0 as a special
|
||||
case since tanh(-0) == -0.
|
||||
* sysdeps/libm-ieee754/s_tanhf.c: Likewise.
|
||||
* sysdeps/libm-ieee754/s_tanhl.c (__tanhl): Correct handling of -inf.
|
||||
|
||||
1997-03-19 21:13 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* stdlib/strtod.c (STRTOL): Use wchar_t as type for `decimal' and
|
||||
`thousands' to support systems with sizeof(wchar_t) !=
|
||||
sizeof(wint_t). Blargh.
|
||||
|
||||
* sysdeps/unix/sysv/linux/socketbits.h: Remove definition of
|
||||
SOL_IP, SOL_TCP, SOL_UDP, and SOL_IPX as they are defined in
|
||||
appropriate headers.
|
||||
|
||||
* sysdeps/unix/sysv/linux/writev.c: Don't use MAX_IOVEC. Test for
|
||||
UIO_FASTIOV and set to 8 if not available.
|
||||
* sysdeps/unix/sysv/linux/readv.c: Likewise.
|
||||
Patch by HJ Lu.
|
||||
|
||||
* sysdeps/unix/sysv/linux/xstat.c: Include <kernel_stat.h>, not
|
||||
"kernel_stat.h".
|
||||
* sysdeps/unix/sysv/linux/lxstat.c: Likewise.
|
||||
* sysdeps/unix/sysv/linux/fxstat.c: Likewise.
|
||||
Reported by fabsoft@fabsoft2.zarm.uni-bremen.de.
|
||||
|
||||
1997-03-19 01:40 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sysdeps/unix/sysv/sco3.2.4/Dist: New file.
|
||||
|
||||
* sysdeps/unix/sysv/sysv4/Dist: Add __getpgid.c and __setpgid.c.
|
||||
|
||||
* sysdeps/unix/bsd/Dist: Add bsdstat.h, setrgid.c, and setruid.c.
|
||||
|
||||
* sysdeps/unix/sysv/Dist: Add direct.h.
|
||||
|
||||
* sysdeps/unix/sysv/linux/Dist: Add netinet/tcp.h.
|
||||
|
||||
* Make-dist ($(tardir).tar): Prefer writing temporary file to
|
||||
$TMPDIR is available. The default is /tmp.
|
||||
|
||||
* sysdeps/generic/ip.h: Move to...
|
||||
* sysdeps/generic/netinet/ip.h: ...here.
|
||||
|
||||
* Makefile (tests): Quote $(CC) argument to isomac program.
|
||||
Patch by H.J. Lu <hjl@gnu.ai.mit.edu>.
|
||||
|
||||
* sysdeps/i386/setjmp.S (__setjmp): Fix fatal bug where 0 argument
|
||||
is placed in wrong place on the stack.
|
||||
Reported by Marc Lehmann <mlehmann@hildesheim.sgh-net.de>.
|
||||
* sysdeps/tst-setjmp.c: Add new test for above problem.
|
||||
|
||||
* sysdeps/libm-i387/e_pow.S: Compute PIC addres early.
|
||||
* sysdeps/libm-i387/e_powf.S: Likewise.
|
||||
* sysdeps/libm-i387/e_powl.S: Likewise.
|
||||
|
||||
1997-03-18 23:18 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* time/offtime.c (__offtime): Change type of `yg' to long int.
|
||||
Reported by a sun <asun@zoology.washington.edu>.
|
||||
|
||||
1997-03-18 23:08 a sun <asun@zoology.washington.edu>
|
||||
|
||||
* sysdeps/unix/sysv/linux/net/if_ppp.h (PPP_VERSION): Define to
|
||||
2.2.0 to prevent version mismatch.
|
||||
|
||||
1997-03-17 19:26 Andreas Jaeger <aj@arthur.pfalz.de>
|
||||
|
||||
* stdio-common/printf_fphex.c (MIN): Only define MIN if not
|
||||
already defined.
|
||||
|
||||
1997-03-14 23:34 Geoff Keating <geoffk@ozemail.com.au>
|
||||
|
||||
* sysdeps/unix/sysv/linux/powerpc/termbits.h: Leave ioctl numbers
|
||||
in ioctls.h.
|
||||
|
||||
* elf/rtld.c (_dl_start): Call elf_machine_runtime_setup when the
|
||||
loader first relocates itself.
|
||||
* sysdeps/powerpc/elf/start.c (__start1): Fix bug for static objects.
|
||||
* sysdeps/powerpc/dl-machine.h (elf_machine_rela): Fix bugs in
|
||||
jump slot relocation. Prefer relative branches (some PowerPC chips
|
||||
don't predict absolute branches).
|
||||
(elf_machine_runtime_setup): Simplify and correct expressions.
|
||||
(RTLD_START): Fix bug changing _dl_starting_up.
|
||||
* sysdeps/unix/sysv/linux/powerpc/dl-sysdep.c: Added. Deal with
|
||||
strange Linux/PPC padding of initial stack.
|
||||
|
||||
1997-03-11 04:14 Geoff Keating <geoffk@ozemail.com.au>
|
||||
|
||||
* sysdeps/unix/sysv/linux/powerpc/termbits.h: Increase NCCS to 39,
|
||||
for future expansion.
|
||||
* sysdeps/unix/sysv/linux/powerpc/sys/kernel_termios.h: Added.
|
||||
* sysdeps/powerpc/dl-machine.h (elf_machine_rela): Explain why it
|
||||
can't have a switch statement.
|
||||
* sysdeps/powerpc/elf/start.c (__start1): Explain why it can't be
|
||||
static.
|
||||
|
||||
* sysdeps/powerpc/elf/start.c (_start): Use .previous to avoid
|
||||
confusing gcc's idea of the current section.
|
||||
* sysdeps/powerpc/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE,
|
||||
RTLD_START): Likewise.
|
||||
|
||||
1997-03-08 09:10 Geoff Keating <geoffk@ozemail.com.au>
|
||||
|
||||
* sysdeps/powerpc/dl-machine.h (elf_machine_rela,
|
||||
elf_machine_runtime_setup): Flush data & instruction caches when
|
||||
necessary, for 603/604 support. Add better support for large PLTs.
|
||||
(elf_machine_rela): Remove relocations that wouldn't work if
|
||||
anyone ever used them. Use memcpy for copy reloc, it'll be safe.
|
||||
Never target branch relocations at a PLT entry.
|
||||
|
||||
* sysdeps/powerpc/bsd-setjmp.S: Make jump to PLT entry if we are
|
||||
generating PIC.
|
||||
* sysdeps/powerpc/bsd-_setjmp.S: Likewise.
|
||||
* sysdeps/powerpc/setjmp.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/powerpc/clone.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/powerpc/socket.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/powerpc/syscall.S: Likewise.
|
||||
* sysdeps/unix/sysv/linux/powerpc/sysdep.h: Likewise.
|
||||
|
||||
* sysdeps/powerpc/elf/start.c: Clean up.
|
||||
|
||||
* sysdeps/powerpc/__longjmp.S: Return 'value' as result from
|
||||
setjmp call.
|
||||
|
||||
* sysdeps/unix/sysv/linux/powerpc/statbuf.h: New file.
|
||||
|
||||
1997-03-09 12:36 H.J. Lu <hjl@gnu.ai.mit.edu>
|
||||
|
||||
* Make-dist (srcs): Add $(test-srcs).
|
||||
* MakeTAGS (all-sources): Likewise.
|
||||
* Makerules (depfiles, common-mostlyclean): Likewise.
|
||||
* Rules (tests): Likewise.
|
||||
|
||||
1997-03-18 05:28 Roland McGrath <roland@frob.com>
|
||||
|
||||
* elf/dl-reloc.c (RESOLVE): Don't try to resolve local symbols.
|
||||
|
||||
1997-03-17 21:39 Philip Blundell <phil@london.uk.eu.org>
|
||||
|
||||
* nis/nss_nis/nis-service.c (_nss_nis_getservbyname_r): Allow
|
||||
protocol=NULL to match any protocol rather than returning an
|
||||
error.
|
||||
|
||||
1997-03-17 19:00 Philip Blundell <phil@london.uk.eu.org>
|
||||
|
||||
* nss/nss_files/files-service.c (servbyname): Match any protocol
|
||||
if proto==NULL.
|
||||
|
||||
1997-03-18 05:17 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sysdeps/unix/sysv/linux/alpha/fcntlbits.h: Don't define O_NORW.
|
||||
* sysdeps/unix/sysv/linux/fcntlbits.h: Likewise.
|
||||
Proposed by Thomas Bushnell, n/BSG.
|
||||
|
||||
1997-03-18 07:53 H.J. Lu <hjl@gnu.ai.mit.edu>
|
||||
|
||||
* sysdeps/generic/setenv.c (setenv): Don't copy name when we reuse
|
||||
the buffer for replacement.
|
||||
|
||||
1997-03-16 19:30 H.J. Lu <hjl@gnu.ai.mit.edu>
|
||||
|
||||
* sysdeps/unix/sysv/linux/syscalls.list: Add sys_fstat,
|
||||
sys_lstat and sys_stat.
|
||||
|
||||
1997-03-17 12:43 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
|
||||
|
||||
Add NIS+ functions
|
||||
* shlib-versions: Add libnss_nisplus.
|
||||
* nis/Makefile: Add NIS+ source files.
|
||||
* nis/nis_call.c: New file.
|
||||
* nis/nis_clone.c: New file.
|
||||
* nis/nis_error.c: New file.
|
||||
* nis/nis_file.c: New file.
|
||||
* nis/nis_free.c: New file.
|
||||
* nis/nis_intern.c: New file.
|
||||
* nis/nis_intern.h: New file.
|
||||
* nis/nis_local_names.c: New file.
|
||||
* nis/nis_names.c: New file.
|
||||
* nis/nis_print.c: New file.
|
||||
* nis/nis_server.c: New file.
|
||||
* nis/nis_subr.c: New file.
|
||||
* nis/nis_table.c: New file.
|
||||
* nis/nis_xdr.c: New file.
|
||||
* nis/nss-nisplus.h: New file.
|
||||
* nis/nss_nisplus/nisplus-alias.c: New file.
|
||||
* nis/nss_nisplus/nisplus-ethers.c: New file.
|
||||
* nis/nss_nisplus/nisplus-grp.c: New file.
|
||||
* nis/nss_nisplus/nisplus-hosts.c: New file.
|
||||
* nis/nss_nisplus/nisplus-netgrp.c: New file.
|
||||
* nis/nss_nisplus/nisplus-network.c: New file.
|
||||
* nis/nss_nisplus/nisplus-proto.c: New file.
|
||||
* nis/nss_nisplus/nisplus-publickey.c: New file.
|
||||
* nis/nss_nisplus/nisplus-pwd.c: New file.
|
||||
* nis/nss_nisplus/nisplus-rpc.c: New file.
|
||||
* nis/nss_nisplus/nisplus-service.c: New file.
|
||||
* nis/nss_nisplus/nisplus-spwd.c: New file.
|
||||
* nis/rpcsvc/nis.h: New file.
|
||||
* nis/rpcsvc/nis.x: New file.
|
||||
* nis/rpcsvc/nis_object.x: New file.
|
||||
* nis/rpcsvc/nis_tags.h: New file.
|
||||
* nis/rpcsvc/nislib.h: New file.
|
||||
|
||||
1997-03-17 12:52 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
|
||||
|
||||
* mach/devstream.c (output/write_some): Don't try and write more
|
||||
than IO_INBAND_MAX in a single call to device_write_inband.
|
||||
|
||||
1997-03-17 04:00 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sysdeps/libm-ieee754/w_atan2.c: Don't ignore exception if library
|
||||
type is SVID.
|
||||
* sysdeps/libm-ieee754/w_atan2f.c: Likewise.
|
||||
* sysdeps/libm-ieee754/w_atan2l.c: Likewise.
|
||||
|
||||
* sysdeps/unix/sysv/linux/sys/mman.h (msync): Add description for
|
||||
FLAGS parameter.
|
||||
|
||||
1997-03-16 20:28 Philip Blundell <phil@london.uk.eu.org>
|
||||
|
||||
* sysdeps/unix/sysv/linux/socketbits.h: Add more SOL_ values.
|
||||
Change msg_iovlen and msg_controllen (in struct msghdr) to
|
||||
`size_t' to keep in step with kernel.
|
||||
|
||||
1997-03-16 18:43 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* manual/filesys.texi: Add documentation for scandir and alphasort.
|
||||
* manual/examples/dir2.c: New example for scandir.
|
||||
|
||||
* math/math.c (fpclassify): Correct stupid typos.
|
||||
|
||||
* math/libm-test.c: New file. libm test suite by Andreas Jaeger.
|
||||
|
||||
* nss/nss_files/files-hosts.c: Add gethostbyname2 imlementation.
|
||||
* math/test/float.c: New file. Frontend for float tests.
|
||||
* math/test/double.c: New file. Frontend for double tests.
|
||||
* math/test/longdouble.c: New file. Frontend for long double tests.
|
||||
|
||||
* posix/Makefile (routines): Add bsd-getpgrp.
|
||||
* posix/bsd-getpgrp.c: New file.
|
||||
@@ -17,7 +683,7 @@
|
||||
|
||||
* sysdeps/i386/huge_val.h: New file. ix87 specific infinity values.
|
||||
* sysdeps/m68k/huge_val.h: New file. m68k specific infinity values.
|
||||
* sysdeps/generic/huge_val.h: Remove definition of long double
|
||||
* sysdeps/ieee754/huge_val.h: Remove definition of long double
|
||||
definition. Make it the same as the double definition.
|
||||
|
||||
* sysdeps/libm-i387/e_acos.S: Fix bug in FPU stack handling.
|
||||
@@ -29,9 +695,9 @@
|
||||
* sysdeps/libm-i387/e_exp.S: Likewise.
|
||||
* sysdeps/libm-i387/e_expf.S: Likewise.
|
||||
* sysdeps/libm-i387/e_expl.S: Likewise.
|
||||
* sysdeps/libm-i387/e_scalbn.S: Likewise.
|
||||
* sysdeps/libm-i387/e_scalbnf.S: Likewise.
|
||||
* sysdeps/libm-i387/e_scalbnl.S: Likewise.
|
||||
* sysdeps/libm-i387/s_scalbn.S: Likewise.
|
||||
* sysdeps/libm-i387/s_scalbnf.S: Likewise.
|
||||
* sysdeps/libm-i387/s_scalbnl.S: Likewise.
|
||||
|
||||
* sysdeps/libm-i387/e_log.S: Optimize branch code.
|
||||
* sysdeps/libm-i387/e_logf.S: Likewise.
|
||||
@@ -44,14 +710,14 @@
|
||||
* sysdeps/libm-i387/e_powf.S: Likewise.
|
||||
* sysdeps/libm-i387/e_powl.S: Likewise.
|
||||
|
||||
* sysdeps/libm-i387/e_expm1.S: Change return value for -inf
|
||||
* sysdeps/libm-i387/s_expm1.S: Change return value for -inf
|
||||
argument to -1.0.
|
||||
* sysdeps/libm-i387/e_expm1f.S: Likewise.
|
||||
* sysdeps/libm-i387/e_expm1l.S: Likewise.
|
||||
* sysdeps/libm-i387/s_expm1f.S: Likewise.
|
||||
* sysdeps/libm-i387/s_expm1l.S: Likewise.
|
||||
|
||||
* sysdeps/libm-i387/e_isinfl.c: Return -1 for -inf.
|
||||
* sysdeps/libm-i387/s_isinfl.c: Return -1 for -inf.
|
||||
|
||||
* sysdeps/libm-i387/e_logbl.S: Correct return value. Discard first
|
||||
* sysdeps/libm-i387/s_logbl.S: Correct return value. Discard first
|
||||
stack element after fxtract.
|
||||
|
||||
* sysdeps/libm-ieee754/e_atan2l.c: New file. `long double'
|
||||
@@ -81,6 +747,8 @@
|
||||
|
||||
* sysdeps/libm-ieee754/w_pow.c: Distinguish error cases for x is +0
|
||||
or -0.
|
||||
* sysdeps/libm-ieee754/w_powf.c: Likewise.
|
||||
* sysdeps/libm-ieee754/w_powl.c: Likewise.
|
||||
|
||||
* sysdeps/posix/isfdtype.c: Add cast to prevent warning.
|
||||
|
||||
@@ -113,7 +781,7 @@
|
||||
* sysdeps/unix/sysv/linux/statbuf.h (struct stat): Change definition
|
||||
to use prescribed types for elements.
|
||||
(_STAT_VER): Change to value 3.
|
||||
* sysdeps/unix/sysv/linux/alph/statbuf.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/alpha/statbuf.h: Likewise.
|
||||
* sysdeps/unix/sysv/linux/Dist: Add kernel_stat.h.
|
||||
* sysdeps/unix/sysv/linux/alpha/Dist: Likewise.
|
||||
|
||||
@@ -150,6 +818,7 @@
|
||||
* nis/nss_nis/nis-hosts.c (_nss_nis_gethostbyname2_r): New
|
||||
functions. Compare result for correct address type.
|
||||
(_nss_nis_gethostbyname_r): Use _nss_nis_gethostbyname2_r.
|
||||
* nss/nss_files/files-hosts.c: Likewise.
|
||||
Reported by Mirko Streckenbach <mirko@marian.hil.de>.
|
||||
|
||||
1997-02-17 01:40 Zlatko Calusic <zcalusic@srce.hr>
|
||||
@@ -182,7 +851,7 @@
|
||||
Pretty print header.
|
||||
|
||||
* Makerules (build-shlib): Also create symlink if library is versioned.
|
||||
based on a patch by H.J. Lu <hjl@gnu.ai.mit.edu>.
|
||||
Based on a patch by H.J. Lu <hjl@gnu.ai.mit.edu>.
|
||||
Remove special rule to libc.so symlink.
|
||||
|
||||
1997-03-11 20:16 Andreas Jaeger <aj@arthur.pfalz.de>
|
||||
@@ -198,7 +867,7 @@
|
||||
|
||||
1997-03-10 18:16 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
|
||||
|
||||
* ypclnt.c (__yp_bind): Fix possible buffer overflow.
|
||||
* nis/ypclnt.c (__yp_bind): Fix possible buffer overflow.
|
||||
|
||||
1997-03-10 18:06 Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>
|
||||
|
||||
@@ -297,8 +966,6 @@
|
||||
* mach/mach/error.h (mach_error_fn_t): Comment out declaration; it
|
||||
appears to be entirely unused dead code.
|
||||
|
||||
* stdio/stdio.h (freopen): Fix spelling error.
|
||||
|
||||
1997-03-02 13:38 Miles Bader <miles@gnu.ai.mit.edu>
|
||||
|
||||
* string/argz.h (__need_error_t): New macro, before including <errno.h>
|
||||
@@ -315,10 +982,10 @@
|
||||
* configure.in: Substitute ASFLAGS_SO.
|
||||
* sysdeps/sparc/configure.in: New file.
|
||||
|
||||
* posix/unitstd.h: Add prototype for __euidaccess.
|
||||
* posix/unistd.h: Add prototype for __euidaccess.
|
||||
* sysdeps/posix/euidaccess.c: Define as __euidaccess and make
|
||||
euidaccess weak alias.
|
||||
* sysdeps/stubs/euidaccess.c: Likewise.
|
||||
* sysdeps/stub/euidaccess.c: Likewise.
|
||||
* inet/rcmd.c: Use __ protected versions of non-standard functions.
|
||||
|
||||
* locale/setlocale.c (setlocale): Don't set usage_count to
|
||||
@@ -2080,7 +2747,7 @@
|
||||
|
||||
1997-02-11 14:49 Andreas Jaeger <jaeger@informatik.uni-kl.de>
|
||||
|
||||
* stdlib/atoll.c: Undefined atoll, not atol.
|
||||
* stdlib/atoll.c: Undefine atoll, not atol.
|
||||
|
||||
1997-02-08 09:36 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||
|
||||
|
||||
@@ -609,7 +609,7 @@ e.g. i486-linux.
|
||||
# GNU libc version 2 does not supply these;
|
||||
# we want them from GCC.
|
||||
- extra_parts="crtbegin.o crtend.o"
|
||||
+ extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS..o"
|
||||
+ extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
|
||||
;;
|
||||
i[3456]86-go32-msdos | i[3456]86-*-go32)
|
||||
cpu_type=i386
|
||||
|
||||
@@ -142,10 +142,10 @@ ifdef subdir
|
||||
|
||||
foo:=$(shell echo subdir foo >&2)
|
||||
|
||||
+tsrcs := Makefile $(+tsrcs) \
|
||||
$(addsuffix .c,$(others) $(tests)) \
|
||||
$(wildcard $(addsuffix .input,$(tests)) \
|
||||
$(addsuffix .args,$(tests)))
|
||||
+tsrcs := Makefile $(+tsrcs) \
|
||||
$(addsuffix .c,$(others) $(tests) $(test-srcs)) \
|
||||
$(wildcard $(addsuffix .input,$(tests) $(test-srcs)) \
|
||||
$(addsuffix .args,$(tests) $(test-srcs)))
|
||||
+tardeps := $(strip $(+tsrcs))
|
||||
|
||||
verbose = v
|
||||
|
||||
@@ -87,8 +87,8 @@ sources += $(foreach lib,$(extra-libs),$($(lib)-routines:=.c))
|
||||
# Files that are found in the current directory cannot occur in
|
||||
# sysdep directories, so don't bother searching them.
|
||||
sysdep-sources := $(filter-out $(wildcard $(sources)), $(sources))
|
||||
all-sources = $(wildcard $(sort $(sources) $(sources:.c=.S) $(sources:.c=.s) \
|
||||
$(others:=.c) $(tests:=.c))) \
|
||||
all-sources = $(wildcard $(sort $(sources) $(sources:.c=.S) $(sources:.c=.s) \
|
||||
$(others:=.c) $(tests:=.c) $(test-srcs:=.c))) \
|
||||
$(foreach dir,$(all-dirs),\
|
||||
$(wildcard \
|
||||
$(addprefix $(dir)/,\
|
||||
|
||||
+14
-3
@@ -23,6 +23,8 @@ ifneq (,)
|
||||
This makefile requires GNU Make.
|
||||
endif
|
||||
|
||||
all: # Make this the default goal
|
||||
|
||||
ifneq "$(origin +included-Makeconfig)" "file"
|
||||
|
||||
+included-Makeconfig := yes
|
||||
@@ -320,10 +322,10 @@ endif
|
||||
ifndef +link
|
||||
+link = $(CC) -nostdlib -nostartfiles -o $@ \
|
||||
$(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) \
|
||||
$(addprefix $(csu-objpfx),start.o) $(+preinit) \
|
||||
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+prector) \
|
||||
$(filter-out $(addprefix $(csu-objpfx),start.o) $(+preinit) \
|
||||
$(link-extra-libs) $(common-objpfx)libc% $(+postinit),$^) \
|
||||
$(link-extra-libs) $(link-libc) $(+postinit)
|
||||
$(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
|
||||
endif
|
||||
ifndef config-LDFLAGS
|
||||
ifeq (yes,$(build-shared))
|
||||
@@ -347,7 +349,8 @@ else
|
||||
default-rpath = $(libdir)
|
||||
endif
|
||||
# This is how to find at build-time things that will be installed there.
|
||||
rpath-link = $(common-objdir):$(elfobjdir):$(nssobjdir)
|
||||
rpath-link = $(common-objdir):$(mathobjdir):$(elfobjdir):$(nssobjdir)
|
||||
mathobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)math)
|
||||
elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
|
||||
nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
|
||||
else
|
||||
@@ -356,7 +359,13 @@ endif
|
||||
endif
|
||||
ifndef link-extra-libs
|
||||
ifeq (yes,$(build-shared))
|
||||
ifneq ($(common-objpfx),$(objpfx))
|
||||
link-extra-libs = $(foreach lib,$(LDLIBS-$(@F)),\
|
||||
$(wildcard $(common-objpfx)$(lib).so$($(notdir $(lib)).so-version) \
|
||||
$(objpfx)$(lib).so$($(notdir $(lib)).so-version)))
|
||||
else
|
||||
link-extra-libs = $(foreach lib,$(LDLIBS-$(@F)),$(common-objpfx)$(lib).so$($(notdir $(lib)).so-version))
|
||||
endif
|
||||
else
|
||||
link-extra-libs = $(foreach lib,$(LDLIBS-$(@F)),$(common-objpfx)$(lib).a)
|
||||
endif
|
||||
@@ -367,6 +376,8 @@ endif
|
||||
ifeq ($(elf),yes)
|
||||
+preinit = $(addprefix $(csu-objpfx),crti.o)
|
||||
+postinit = $(addprefix $(csu-objpfx),crtn.o)
|
||||
+prector = `$(CC) --print-file-name=crtbegin.o`
|
||||
+postctor = `$(CC) --print-file-name=crtend.o`
|
||||
endif
|
||||
csu-objpfx = $(common-objpfx)csu/
|
||||
elf-objpfx = $(common-objpfx)elf/
|
||||
|
||||
@@ -282,7 +282,7 @@ parent_echo-distinfo:
|
||||
|
||||
# Run a test on the header files we use.
|
||||
tests: $(objpfx)isomac
|
||||
$(objpfx)./isomac $(CC) '$(+sysdep-includes)' \
|
||||
$(objpfx)./isomac '$(CC)' '$(+sysdep-includes)' \
|
||||
>$(common-objpfx)isomac.out
|
||||
|
||||
$(objpfx)isomac: isomac.c
|
||||
@@ -290,7 +290,7 @@ $(objpfx)isomac: isomac.c
|
||||
|
||||
# Make the distribution tarfile.
|
||||
|
||||
distribute := README INSTALL FAQ NOTES NEWS PROJECTS \
|
||||
distribute := README INSTALL FAQ NOTES NEWS PROJECTS BUGS \
|
||||
COPYING.LIB COPYING ChangeLog ChangeLog.[0-9] \
|
||||
Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \
|
||||
extra-lib.mk o-iterator.mk isomac.c \
|
||||
|
||||
@@ -857,9 +857,10 @@ mostlyclean: common-mostlyclean
|
||||
|
||||
# Remove the object files.
|
||||
common-mostlyclean:
|
||||
-rm -f $(addprefix $(objpfx),$(tests) $(others) \
|
||||
$(addsuffix .o,$(tests) $(others)) \
|
||||
$(addsuffix .out,$(tests)))
|
||||
-rm -f $(addprefix $(objpfx),$(tests) $(test-srcs) $(others) \
|
||||
$(addsuffix .o,$(tests) $(test-srcs) \
|
||||
$(others)) \
|
||||
$(addsuffix .out,$(tests) $(test-srcs)))
|
||||
-rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib))
|
||||
-rm -f core $(common-objpfx)stub-$(subdir)
|
||||
$(rmobjs)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
GNU C Library NEWS -- history of user-visible changes. 1997-02-13
|
||||
GNU C Library NEWS -- history of user-visible changes. 1997-03-18
|
||||
|
||||
Copyright (C) 1992, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
|
||||
See the end for copying conditions.
|
||||
@@ -24,6 +24,18 @@ Version 2.1
|
||||
numbers
|
||||
|
||||
* scanf recognizes the %A format for scanning floating point numbers
|
||||
|
||||
* the new header <inttypes.h> from ISO C 9X provides information and
|
||||
interfaces for the available integer types
|
||||
|
||||
* the new header <complex.h> contains definitions of the complex math
|
||||
functions from ISO C 9X
|
||||
|
||||
* Thorsten Kukuk provided an implementation for NIS+, securelevel 0 and 1.
|
||||
The implementation for securelevel 2 will follow as soon as the Diffie-
|
||||
Hellman patent expired.
|
||||
|
||||
* Andreas Jaeger provided a test suite for the math library
|
||||
|
||||
Version 2.0.2
|
||||
|
||||
@@ -32,6 +44,8 @@ Version 2.0.2
|
||||
* add atoll function
|
||||
|
||||
* fix complex problems in Berkeley DB code
|
||||
|
||||
* fix math functions
|
||||
|
||||
Version 2.0.1
|
||||
|
||||
|
||||
@@ -83,19 +83,19 @@ common-generated := $(common-generated) dummy.o dummy.c empty.c empty.o
|
||||
.PHONY: others tests
|
||||
others: $(addprefix $(objpfx),$(others) $(extra-objs))
|
||||
ifeq ($(cross-compiling),yes)
|
||||
tests: $(addprefix $(objpfx),$(tests))
|
||||
tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
|
||||
else
|
||||
tests: $(tests:%=$(objpfx)%.out)
|
||||
endif
|
||||
|
||||
ifneq "$(strip $(others) $(tests))" ""
|
||||
$(addprefix $(objpfx),$(others) $(tests)): %: %.o \
|
||||
ifneq "$(strip $(others) $(tests) $(test-srcs))" ""
|
||||
$(addprefix $(objpfx),$(others) $(tests) $(test-srcs)): %: %.o \
|
||||
$(sort $(filter $(common-objpfx)libc%,$(link-libc))) \
|
||||
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
|
||||
$(+link)
|
||||
endif
|
||||
|
||||
ifneq "$(strip $(tests))" ""
|
||||
ifneq "$(strip $(tests) $(test-srcs))" ""
|
||||
# These are the implicit rules for making test outputs
|
||||
# from the test programs and whatever input files are present.
|
||||
$(objpfx)%.out: %.args $(objpfx)% %.input
|
||||
|
||||
@@ -1120,34 +1120,10 @@ done
|
||||
test -n "$MSGFMT" || MSGFMT=":"
|
||||
|
||||
|
||||
echo $ac_n "checking build system type""... $ac_c" 1>&6
|
||||
echo "configure:1125: checking build system type" >&5
|
||||
|
||||
build_alias=$build
|
||||
case "$build_alias" in
|
||||
NONE)
|
||||
case $nonopt in
|
||||
NONE) build_alias=$host_alias ;;
|
||||
*) build_alias=$nonopt ;;
|
||||
esac ;;
|
||||
esac
|
||||
|
||||
build=`$ac_config_sub $build_alias`
|
||||
build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
|
||||
build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
|
||||
build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
|
||||
echo "$ac_t""$build" 1>&6
|
||||
|
||||
if test $host != $build; then
|
||||
ac_tool_prefix=${host_alias}-
|
||||
else
|
||||
ac_tool_prefix=
|
||||
fi
|
||||
|
||||
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
|
||||
set dummy ${ac_tool_prefix}gcc; ac_word=$2
|
||||
# Extract the first word of "gcc", so it can be a program name with args.
|
||||
set dummy gcc; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1151: checking for $ac_word" >&5
|
||||
echo "configure:1127: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1158,12 +1134,11 @@ else
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -f $ac_dir/$ac_word; then
|
||||
ac_cv_prog_CC="${ac_tool_prefix}gcc"
|
||||
ac_cv_prog_CC="gcc"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="gcc"
|
||||
fi
|
||||
fi
|
||||
CC="$ac_cv_prog_CC"
|
||||
@@ -1173,13 +1148,153 @@ else
|
||||
echo "$ac_t""no" 1>&6
|
||||
fi
|
||||
|
||||
if test -z "$CC"; then
|
||||
# Extract the first word of "cc", so it can be a program name with args.
|
||||
set dummy cc; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1156: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
if test -n "$CC"; then
|
||||
ac_cv_prog_CC="$CC" # Let the user override the test.
|
||||
else
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
|
||||
ac_prog_rejected=no
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -f $ac_dir/$ac_word; then
|
||||
if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
|
||||
ac_prog_rejected=yes
|
||||
continue
|
||||
fi
|
||||
ac_cv_prog_CC="cc"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
if test $ac_prog_rejected = yes; then
|
||||
# We found a bogon in the path, so make sure we never use it.
|
||||
set dummy $ac_cv_prog_CC
|
||||
shift
|
||||
if test $# -gt 0; then
|
||||
# We chose a different compiler from the bogus one.
|
||||
# However, it has the same basename, so the bogon will be chosen
|
||||
# first if we set CC to just the basename; use the full file name.
|
||||
shift
|
||||
set dummy "$ac_dir/$ac_word" "$@"
|
||||
shift
|
||||
ac_cv_prog_CC="$@"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
CC="$ac_cv_prog_CC"
|
||||
if test -n "$CC"; then
|
||||
echo "$ac_t""$CC" 1>&6
|
||||
else
|
||||
echo "$ac_t""no" 1>&6
|
||||
fi
|
||||
|
||||
test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
|
||||
fi
|
||||
|
||||
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
|
||||
echo "configure:1204: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
|
||||
|
||||
ac_ext=c
|
||||
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
|
||||
ac_cpp='$CPP $CPPFLAGS'
|
||||
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
|
||||
ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
|
||||
cross_compiling=$ac_cv_prog_cc_cross
|
||||
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1214 "configure"
|
||||
#include "confdefs.h"
|
||||
main(){return(0);}
|
||||
EOF
|
||||
if { (eval echo configure:1218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
ac_cv_prog_cc_works=yes
|
||||
# If we can't run a trivial program, we are probably using a cross compiler.
|
||||
if (./conftest; exit) 2>/dev/null; then
|
||||
ac_cv_prog_cc_cross=no
|
||||
else
|
||||
ac_cv_prog_cc_cross=yes
|
||||
fi
|
||||
else
|
||||
echo "configure: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
ac_cv_prog_cc_works=no
|
||||
fi
|
||||
rm -fr conftest*
|
||||
|
||||
echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
|
||||
if test $ac_cv_prog_cc_works = no; then
|
||||
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
|
||||
fi
|
||||
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
|
||||
echo "configure:1238: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
|
||||
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
|
||||
cross_compiling=$ac_cv_prog_cc_cross
|
||||
|
||||
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
|
||||
echo "configure:1243: checking whether we are using GNU C" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.c <<EOF
|
||||
#ifdef __GNUC__
|
||||
yes;
|
||||
#endif
|
||||
EOF
|
||||
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1252: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
|
||||
ac_cv_prog_gcc=yes
|
||||
else
|
||||
ac_cv_prog_gcc=no
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_cv_prog_gcc" 1>&6
|
||||
|
||||
if test $ac_cv_prog_gcc = yes; then
|
||||
GCC=yes
|
||||
ac_test_CFLAGS="${CFLAGS+set}"
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS=
|
||||
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
|
||||
echo "configure:1267: checking whether ${CC-cc} accepts -g" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
echo 'void f(){}' > conftest.c
|
||||
if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
|
||||
ac_cv_prog_cc_g=yes
|
||||
else
|
||||
ac_cv_prog_cc_g=no
|
||||
fi
|
||||
rm -f conftest*
|
||||
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
|
||||
if test "$ac_test_CFLAGS" = set; then
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
elif test $ac_cv_prog_cc_g = yes; then
|
||||
CFLAGS="-g -O2"
|
||||
else
|
||||
CFLAGS="-O2"
|
||||
fi
|
||||
else
|
||||
GCC=
|
||||
test "${CFLAGS+set}" = set || CFLAGS="-g"
|
||||
fi
|
||||
|
||||
if test $host != $build; then
|
||||
# Extract the first word of "gcc cc", so it can be a program name with args.
|
||||
set dummy gcc cc; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1183: checking for $ac_word" >&5
|
||||
echo "configure:1298: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_BUILD_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1206,7 +1321,7 @@ fi
|
||||
|
||||
fi
|
||||
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
|
||||
echo "configure:1210: checking how to run the C preprocessor" >&5
|
||||
echo "configure:1325: checking how to run the C preprocessor" >&5
|
||||
# On Suns, sometimes $CPP names a directory.
|
||||
if test -n "$CPP" && test -d "$CPP"; then
|
||||
CPP=
|
||||
@@ -1221,13 +1336,13 @@ else
|
||||
# On the NeXT, cc -E runs the code through the compiler's parser,
|
||||
# not just through cpp.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1225 "configure"
|
||||
#line 1340 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:1231: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:1346: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@@ -1238,13 +1353,13 @@ else
|
||||
rm -rf conftest*
|
||||
CPP="${CC-cc} -E -traditional-cpp"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1242 "configure"
|
||||
#line 1357 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:1248: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:1363: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@@ -1266,10 +1381,34 @@ else
|
||||
fi
|
||||
echo "$ac_t""$CPP" 1>&6
|
||||
|
||||
echo $ac_n "checking build system type""... $ac_c" 1>&6
|
||||
echo "configure:1386: checking build system type" >&5
|
||||
|
||||
build_alias=$build
|
||||
case "$build_alias" in
|
||||
NONE)
|
||||
case $nonopt in
|
||||
NONE) build_alias=$host_alias ;;
|
||||
*) build_alias=$nonopt ;;
|
||||
esac ;;
|
||||
esac
|
||||
|
||||
build=`$ac_config_sub $build_alias`
|
||||
build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
|
||||
build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
|
||||
build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
|
||||
echo "$ac_t""$build" 1>&6
|
||||
|
||||
if test $host != $build; then
|
||||
ac_tool_prefix=${host_alias}-
|
||||
else
|
||||
ac_tool_prefix=
|
||||
fi
|
||||
|
||||
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
|
||||
set dummy ${ac_tool_prefix}ar; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1273: checking for $ac_word" >&5
|
||||
echo "configure:1412: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1300,7 +1439,7 @@ fi
|
||||
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
|
||||
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1304: checking for $ac_word" >&5
|
||||
echo "configure:1443: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1331,7 +1470,7 @@ if test -n "$ac_tool_prefix"; then
|
||||
# Extract the first word of "ranlib", so it can be a program name with args.
|
||||
set dummy ranlib; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1335: checking for $ac_word" >&5
|
||||
echo "configure:1474: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1366,7 +1505,7 @@ fi
|
||||
# Extract the first word of "bash", so it can be a program name with args.
|
||||
set dummy bash; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1370: checking for $ac_word" >&5
|
||||
echo "configure:1509: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_path_BASH'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1407,7 +1546,7 @@ if test "$BASH" = no; then
|
||||
# Extract the first word of "ksh", so it can be a program name with args.
|
||||
set dummy ksh; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:1411: checking for $ac_word" >&5
|
||||
echo "configure:1550: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_path_KSH'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1449,7 +1588,7 @@ fi
|
||||
|
||||
|
||||
echo $ac_n "checking for signed size_t type""... $ac_c" 1>&6
|
||||
echo "configure:1453: checking for signed size_t type" >&5
|
||||
echo "configure:1592: checking for signed size_t type" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_signed_size_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1473,12 +1612,12 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for libc-friendly stddef.h""... $ac_c" 1>&6
|
||||
echo "configure:1477: checking for libc-friendly stddef.h" >&5
|
||||
echo "configure:1616: checking for libc-friendly stddef.h" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_friendly_stddef'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1482 "configure"
|
||||
#line 1621 "configure"
|
||||
#include "confdefs.h"
|
||||
#define __need_size_t
|
||||
#define __need_wchar_t
|
||||
@@ -1493,7 +1632,7 @@ size_t size; wchar_t wchar;
|
||||
if (&size == NULL || &wchar == NULL) abort ();
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1497: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1636: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
libc_cv_friendly_stddef=yes
|
||||
else
|
||||
@@ -1512,7 +1651,7 @@ override stddef.h = # The installed <stddef.h> seems to be libc-friendly."
|
||||
fi
|
||||
|
||||
echo $ac_n "checking whether we need to use -P to assemble .S files""... $ac_c" 1>&6
|
||||
echo "configure:1516: checking whether we need to use -P to assemble .S files" >&5
|
||||
echo "configure:1655: checking whether we need to use -P to assemble .S files" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_need_minus_P'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1535,7 +1674,7 @@ asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives."
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for assembler global-symbol directive""... $ac_c" 1>&6
|
||||
echo "configure:1539: checking for assembler global-symbol directive" >&5
|
||||
echo "configure:1678: checking for assembler global-symbol directive" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_asm_global_directive'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1565,7 +1704,7 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for .set assembler directive""... $ac_c" 1>&6
|
||||
echo "configure:1569: checking for .set assembler directive" >&5
|
||||
echo "configure:1708: checking for .set assembler directive" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_asm_set_directive'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1599,7 +1738,7 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for .symver assembler directive""... $ac_c" 1>&6
|
||||
echo "configure:1603: checking for .symver assembler directive" >&5
|
||||
echo "configure:1742: checking for .symver assembler directive" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_asm_symver_directive'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1618,7 +1757,7 @@ fi
|
||||
|
||||
echo "$ac_t""$libc_cv_asm_symver_directive" 1>&6
|
||||
echo $ac_n "checking for ld --version-script""... $ac_c" 1>&6
|
||||
echo "configure:1622: checking for ld --version-script" >&5
|
||||
echo "configure:1761: checking for ld --version-script" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_ld_version_script_option'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1635,7 +1774,7 @@ VERS {
|
||||
EOF
|
||||
if ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.s 1>&5 2>&5; then
|
||||
if { ac_try='${CC-cc} $CFLAGS --shared -o conftest.so conftest.o
|
||||
-Wl,--version-script,conftest.map'; { (eval echo configure:1639: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
|
||||
-Wl,--version-script,conftest.map'; { (eval echo configure:1778: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
|
||||
then
|
||||
libc_cv_ld_version_script_option=yes
|
||||
else
|
||||
@@ -1665,7 +1804,7 @@ fi
|
||||
|
||||
if test $elf = yes; then
|
||||
echo $ac_n "checking for .previous assembler directive""... $ac_c" 1>&6
|
||||
echo "configure:1669: checking for .previous assembler directive" >&5
|
||||
echo "configure:1808: checking for .previous assembler directive" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_asm_previous_directive'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1673,7 +1812,7 @@ else
|
||||
.section foo_section
|
||||
.previous
|
||||
EOF
|
||||
if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:1677: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
|
||||
if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:1816: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
|
||||
libc_cv_asm_previous_directive=yes
|
||||
else
|
||||
libc_cv_asm_previous_directive=no
|
||||
@@ -1689,7 +1828,7 @@ EOF
|
||||
|
||||
else
|
||||
echo $ac_n "checking for .popsection assembler directive""... $ac_c" 1>&6
|
||||
echo "configure:1693: checking for .popsection assembler directive" >&5
|
||||
echo "configure:1832: checking for .popsection assembler directive" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_asm_popsection_directive'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1697,7 +1836,7 @@ else
|
||||
.pushsection foo_section
|
||||
.popsection
|
||||
EOF
|
||||
if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:1701: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
|
||||
if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:1840: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
|
||||
libc_cv_asm_popsection_directive=yes
|
||||
else
|
||||
libc_cv_asm_popsection_directive=no
|
||||
@@ -1717,12 +1856,12 @@ fi
|
||||
|
||||
if test $elf != yes; then
|
||||
echo $ac_n "checking for .init and .fini sections""... $ac_c" 1>&6
|
||||
echo "configure:1721: checking for .init and .fini sections" >&5
|
||||
echo "configure:1860: checking for .init and .fini sections" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1726 "configure"
|
||||
#line 1865 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
@@ -1731,7 +1870,7 @@ asm (".section .init");
|
||||
asm (".text");
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1735: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1874: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
libc_cv_have_initfini=yes
|
||||
else
|
||||
@@ -1756,19 +1895,19 @@ if test $elf = yes; then
|
||||
libc_cv_asm_underscores=no
|
||||
else
|
||||
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6
|
||||
echo "configure:1760: checking for _ prefix on C symbol names" >&5
|
||||
echo "configure:1899: checking for _ prefix on C symbol names" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1765 "configure"
|
||||
#line 1904 "configure"
|
||||
#include "confdefs.h"
|
||||
asm ("_glibc_foobar:");
|
||||
int main() {
|
||||
glibc_foobar ();
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
if { (eval echo configure:1911: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
|
||||
rm -rf conftest*
|
||||
libc_cv_asm_underscores=yes
|
||||
else
|
||||
@@ -1795,7 +1934,7 @@ if test $elf = yes; then
|
||||
libc_cv_asm_weakext_directive=no
|
||||
else
|
||||
echo $ac_n "checking for assembler .weak directive""... $ac_c" 1>&6
|
||||
echo "configure:1799: checking for assembler .weak directive" >&5
|
||||
echo "configure:1938: checking for assembler .weak directive" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_asm_weak_directive'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1818,7 +1957,7 @@ echo "$ac_t""$libc_cv_asm_weak_directive" 1>&6
|
||||
|
||||
if test $libc_cv_asm_weak_directive = no; then
|
||||
echo $ac_n "checking for assembler .weakext directive""... $ac_c" 1>&6
|
||||
echo "configure:1822: checking for assembler .weakext directive" >&5
|
||||
echo "configure:1961: checking for assembler .weakext directive" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_asm_weakext_directive'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1855,7 +1994,7 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for ld --no-whole-archive""... $ac_c" 1>&6
|
||||
echo "configure:1859: checking for ld --no-whole-archive" >&5
|
||||
echo "configure:1998: checking for ld --no-whole-archive" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_ld_no_whole_archive'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1866,7 +2005,7 @@ __throw () {}
|
||||
EOF
|
||||
if { ac_try='${CC-cc} $CFLAGS
|
||||
-nostdlib -nostartfiles -Wl,--no-whole-archive
|
||||
-o conftest conftest.c'; { (eval echo configure:1870: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
|
||||
-o conftest conftest.c'; { (eval echo configure:2009: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
|
||||
libc_cv_ld_no_whole_archive=yes
|
||||
else
|
||||
libc_cv_ld_no_whole_archive=no
|
||||
@@ -1877,7 +2016,7 @@ fi
|
||||
echo "$ac_t""$libc_cv_ld_no_whole_archive" 1>&6
|
||||
|
||||
echo $ac_n "checking for gcc -fno-exceptions""... $ac_c" 1>&6
|
||||
echo "configure:1881: checking for gcc -fno-exceptions" >&5
|
||||
echo "configure:2020: checking for gcc -fno-exceptions" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_gcc_no_exceptions'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1888,7 +2027,7 @@ __throw () {}
|
||||
EOF
|
||||
if { ac_try='${CC-cc} $CFLAGS
|
||||
-nostdlib -nostartfiles -fno-exceptions
|
||||
-o conftest conftest.c'; { (eval echo configure:1892: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
|
||||
-o conftest conftest.c'; { (eval echo configure:2031: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
|
||||
libc_cv_gcc_no_exceptions=yes
|
||||
else
|
||||
libc_cv_gcc_no_exceptions=no
|
||||
@@ -1940,7 +2079,7 @@ if test "$uname" = generic; then
|
||||
fi
|
||||
|
||||
echo $ac_n "checking OS release for uname""... $ac_c" 1>&6
|
||||
echo "configure:1944: checking OS release for uname" >&5
|
||||
echo "configure:2083: checking OS release for uname" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_uname_release'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1962,7 +2101,7 @@ echo "$ac_t""$libc_cv_uname_release" 1>&6
|
||||
uname_release="$libc_cv_uname_release"
|
||||
|
||||
echo $ac_n "checking OS version for uname""... $ac_c" 1>&6
|
||||
echo "configure:1966: checking OS version for uname" >&5
|
||||
echo "configure:2105: checking OS version for uname" >&5
|
||||
if eval "test \"`echo '$''{'libc_cv_uname_version'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -1984,7 +2123,7 @@ else
|
||||
fi
|
||||
|
||||
echo $ac_n "checking stdio selection""... $ac_c" 1>&6
|
||||
echo "configure:1988: checking stdio selection" >&5
|
||||
echo "configure:2127: checking stdio selection" >&5
|
||||
|
||||
case $stdio in
|
||||
libio) cat >> confdefs.h <<\EOF
|
||||
@@ -2189,14 +2328,14 @@ s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
|
||||
s%@INSTALL_DATA@%$INSTALL_DATA%g
|
||||
s%@LN_S@%$LN_S%g
|
||||
s%@MSGFMT@%$MSGFMT%g
|
||||
s%@CC@%$CC%g
|
||||
s%@BUILD_CC@%$BUILD_CC%g
|
||||
s%@CPP@%$CPP%g
|
||||
s%@build@%$build%g
|
||||
s%@build_alias@%$build_alias%g
|
||||
s%@build_cpu@%$build_cpu%g
|
||||
s%@build_vendor@%$build_vendor%g
|
||||
s%@build_os@%$build_os%g
|
||||
s%@CC@%$CC%g
|
||||
s%@BUILD_CC@%$BUILD_CC%g
|
||||
s%@CPP@%$CPP%g
|
||||
s%@AR@%$AR%g
|
||||
s%@RANLIB@%$RANLIB%g
|
||||
s%@BASH@%$BASH%g
|
||||
|
||||
+1
-1
@@ -359,7 +359,7 @@ fi
|
||||
AC_PROG_LN_S
|
||||
AC_CHECK_PROGS(MSGFMT, msgfmt gmsgfmt, :)
|
||||
|
||||
AC_CHECK_TOOL(CC, gcc)
|
||||
AC_PROG_CC
|
||||
if test $host != $build; then
|
||||
AC_CHECK_PROG(BUILD_CC, gcc cc)
|
||||
fi
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
TODO COPYING* AUTHORS copyr-* copying.*
|
||||
glibc-*
|
||||
distinfo
|
||||
specs
|
||||
|
||||
+26
-28
@@ -22,7 +22,8 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <dl-hash.h>
|
||||
#include "dl-hash.h"
|
||||
#include <dl-machine.h>
|
||||
#include "../stdio-common/_itoa.h"
|
||||
|
||||
#define VERSTAG(tag) (DT_NUM + DT_PROCNUM + DT_VERSIONTAGIDX (tag))
|
||||
@@ -57,10 +58,10 @@ struct sym_val
|
||||
something bad happened. */
|
||||
static inline int
|
||||
do_lookup (const char *undef_name, unsigned long int hash,
|
||||
const ElfW(Sym) **ref, struct sym_val *result,
|
||||
const ElfW(Sym) *ref, struct sym_val *result,
|
||||
struct link_map *list[], size_t i, size_t n,
|
||||
const char *reference_name, const struct r_found_version *version,
|
||||
struct link_map *skip, int flags)
|
||||
struct link_map *skip, int reloc_type)
|
||||
{
|
||||
struct link_map *map;
|
||||
|
||||
@@ -78,7 +79,8 @@ do_lookup (const char *undef_name, unsigned long int hash,
|
||||
continue;
|
||||
|
||||
/* Don't search the executable when resolving a copy reloc. */
|
||||
if (flags & DL_LOOKUP_NOEXEC && map->l_type == lt_executable)
|
||||
if (elf_machine_lookup_noexec_p (reloc_type) &&
|
||||
map->l_type == lt_executable)
|
||||
continue;
|
||||
|
||||
symtab = ((void *) map->l_addr + map->l_info[DT_SYMTAB]->d_un.d_ptr);
|
||||
@@ -98,7 +100,7 @@ do_lookup (const char *undef_name, unsigned long int hash,
|
||||
const ElfW(Sym) *sym = &symtab[symidx];
|
||||
|
||||
if (sym->st_value == 0 || /* No value. */
|
||||
((flags & DL_LOOKUP_NOPLT) != 0 /* Reject PLT entry. */
|
||||
(elf_machine_lookup_noplt_p (reloc_type) /* Reject PLT entry. */
|
||||
&& sym->st_shndx == SHN_UNDEF))
|
||||
continue;
|
||||
|
||||
@@ -113,7 +115,7 @@ do_lookup (const char *undef_name, unsigned long int hash,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sym != *ref && strcmp (strtab + sym->st_name, undef_name))
|
||||
if (sym != ref && strcmp (strtab + sym->st_name, undef_name))
|
||||
/* Not the symbol we are looking for. */
|
||||
continue;
|
||||
|
||||
@@ -188,16 +190,13 @@ do_lookup (const char *undef_name, unsigned long int hash,
|
||||
}
|
||||
|
||||
/* Search loaded objects' symbol tables for a definition of the symbol
|
||||
UNDEF_NAME. FLAGS is a set of flags. If DL_LOOKUP_NOEXEC is set,
|
||||
then don't search the executable for a definition; this used for
|
||||
copy relocs. If DL_LOOKUP_NOPLT is set, then a PLT entry cannot
|
||||
satisfy the reference; some different binding must be found. */
|
||||
UNDEF_NAME. */
|
||||
|
||||
ElfW(Addr)
|
||||
_dl_lookup_symbol (const char *undef_name, const ElfW(Sym) **ref,
|
||||
struct link_map *symbol_scope[],
|
||||
const char *reference_name,
|
||||
int flags)
|
||||
int reloc_type)
|
||||
{
|
||||
const unsigned long int hash = _dl_elf_hash (undef_name);
|
||||
struct sym_val current_value = { 0, NULL };
|
||||
@@ -205,9 +204,9 @@ _dl_lookup_symbol (const char *undef_name, const ElfW(Sym) **ref,
|
||||
|
||||
/* Search the relevant loaded objects for a definition. */
|
||||
for (scope = symbol_scope; *scope; ++scope)
|
||||
if (do_lookup (undef_name, hash, ref, ¤t_value,
|
||||
if (do_lookup (undef_name, hash, *ref, ¤t_value,
|
||||
(*scope)->l_searchlist, 0, (*scope)->l_nsearchlist,
|
||||
reference_name, NULL, NULL, flags))
|
||||
reference_name, NULL, NULL, reloc_type))
|
||||
break;
|
||||
|
||||
if (current_value.s == NULL &&
|
||||
@@ -230,8 +229,7 @@ ElfW(Addr)
|
||||
_dl_lookup_symbol_skip (const char *undef_name, const ElfW(Sym) **ref,
|
||||
struct link_map *symbol_scope[],
|
||||
const char *reference_name,
|
||||
struct link_map *skip_map,
|
||||
int flags)
|
||||
struct link_map *skip_map)
|
||||
{
|
||||
const unsigned long int hash = _dl_elf_hash (undef_name);
|
||||
struct sym_val current_value = { 0, NULL };
|
||||
@@ -243,13 +241,13 @@ _dl_lookup_symbol_skip (const char *undef_name, const ElfW(Sym) **ref,
|
||||
for (i = 0; (*scope)->l_dupsearchlist[i] != skip_map; ++i)
|
||||
assert (i < (*scope)->l_ndupsearchlist);
|
||||
|
||||
if (! do_lookup (undef_name, hash, ref, ¤t_value,
|
||||
if (! do_lookup (undef_name, hash, *ref, ¤t_value,
|
||||
(*scope)->l_dupsearchlist, i, (*scope)->l_ndupsearchlist,
|
||||
reference_name, NULL, skip_map, flags))
|
||||
reference_name, NULL, skip_map, 0))
|
||||
while (*++scope)
|
||||
if (do_lookup (undef_name, hash, ref, ¤t_value,
|
||||
if (do_lookup (undef_name, hash, *ref, ¤t_value,
|
||||
(*scope)->l_dupsearchlist, 0, (*scope)->l_ndupsearchlist,
|
||||
reference_name, NULL, skip_map, flags))
|
||||
reference_name, NULL, skip_map, 0))
|
||||
break;
|
||||
|
||||
*ref = current_value.s;
|
||||
@@ -266,7 +264,8 @@ ElfW(Addr)
|
||||
_dl_lookup_versioned_symbol (const char *undef_name, const ElfW(Sym) **ref,
|
||||
struct link_map *symbol_scope[],
|
||||
const char *reference_name,
|
||||
const struct r_found_version *version, int flags)
|
||||
const struct r_found_version *version,
|
||||
int reloc_type)
|
||||
{
|
||||
const unsigned long int hash = _dl_elf_hash (undef_name);
|
||||
struct sym_val current_value = { 0, NULL };
|
||||
@@ -275,9 +274,9 @@ _dl_lookup_versioned_symbol (const char *undef_name, const ElfW(Sym) **ref,
|
||||
/* Search the relevant loaded objects for a definition. */
|
||||
for (scope = symbol_scope; *scope; ++scope)
|
||||
{
|
||||
int res = do_lookup (undef_name, hash, ref, ¤t_value,
|
||||
int res = do_lookup (undef_name, hash, *ref, ¤t_value,
|
||||
(*scope)->l_searchlist, 0, (*scope)->l_nsearchlist,
|
||||
reference_name, version, NULL, flags);
|
||||
reference_name, version, NULL, reloc_type);
|
||||
if (res > 0)
|
||||
break;
|
||||
|
||||
@@ -312,8 +311,7 @@ _dl_lookup_versioned_symbol_skip (const char *undef_name,
|
||||
struct link_map *symbol_scope[],
|
||||
const char *reference_name,
|
||||
const struct r_found_version *version,
|
||||
struct link_map *skip_map,
|
||||
int flags)
|
||||
struct link_map *skip_map)
|
||||
{
|
||||
const unsigned long int hash = _dl_elf_hash (undef_name);
|
||||
struct sym_val current_value = { 0, NULL };
|
||||
@@ -325,13 +323,13 @@ _dl_lookup_versioned_symbol_skip (const char *undef_name,
|
||||
for (i = 0; (*scope)->l_dupsearchlist[i] != skip_map; ++i)
|
||||
assert (i < (*scope)->l_ndupsearchlist);
|
||||
|
||||
if (! do_lookup (undef_name, hash, ref, ¤t_value,
|
||||
if (! do_lookup (undef_name, hash, *ref, ¤t_value,
|
||||
(*scope)->l_dupsearchlist, i, (*scope)->l_ndupsearchlist,
|
||||
reference_name, version, skip_map, flags))
|
||||
reference_name, version, skip_map, 0))
|
||||
while (*++scope)
|
||||
if (do_lookup (undef_name, hash, ref, ¤t_value,
|
||||
if (do_lookup (undef_name, hash, *ref, ¤t_value,
|
||||
(*scope)->l_dupsearchlist, 0, (*scope)->l_ndupsearchlist,
|
||||
reference_name, version, skip_map, flags))
|
||||
reference_name, version, skip_map, 0))
|
||||
break;
|
||||
|
||||
*ref = current_value.s;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/* Support for dynamic linking code in static libc.
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 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
|
||||
@@ -62,7 +62,7 @@ _dl_sysdep_read_whole_file (const char *file, size_t *sizep, int prot)
|
||||
int fd = __open (file, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
if (__fstat (fd, &st) < 0)
|
||||
if (__fxstat (_STAT_VER, fd, &st) < 0)
|
||||
result = NULL;
|
||||
else
|
||||
{
|
||||
|
||||
+1
-2
@@ -53,8 +53,7 @@ RTLD_NEXT used in code not dynamically loaded"));
|
||||
while (l->l_loader)
|
||||
l = l->l_loader;
|
||||
|
||||
loadbase = _dl_lookup_symbol_skip
|
||||
(name, &ref, &_dl_loaded, NULL, l, 0);
|
||||
loadbase = _dl_lookup_symbol_skip (name, &ref, &_dl_loaded, NULL, l);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ RTLD_NEXT used in code not dynamically loaded"));
|
||||
l = l->l_loader;
|
||||
|
||||
loadbase = _dl_lookup_versioned_symbol_skip
|
||||
(name, &ref, &_dl_loaded, NULL, &version, l, 0);
|
||||
(name, &ref, &_dl_loaded, NULL, &version, l);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+8
-13
@@ -290,18 +290,15 @@ extern void _dl_close (struct link_map *map);
|
||||
null-terminated list of object scopes to search; each object's
|
||||
l_searchlist (i.e. the segment of the dependency tree starting at that
|
||||
object) is searched in turn. REFERENCE_NAME should name the object
|
||||
containing the reference; it is used in error messages. FLAGS is a
|
||||
set of flags: */
|
||||
#define DL_LOOKUP_NOEXEC 1 /* Don't search the executable for a
|
||||
definition; this is used for copy
|
||||
relocs. */
|
||||
#define DL_LOOKUP_NOPLT 2 /* The reference must not be resolved
|
||||
to a PLT entry. */
|
||||
containing the reference; it is used in error messages.
|
||||
RELOC_TYPE is a machine-dependent reloc type, which is passed to
|
||||
the `elf_machine_lookup_*_p' macros in dl-machine.h to affect which
|
||||
symbols can be chosen. */
|
||||
extern ElfW(Addr) _dl_lookup_symbol (const char *undef,
|
||||
const ElfW(Sym) **sym,
|
||||
struct link_map *symbol_scope[],
|
||||
const char *reference_name,
|
||||
int flags);
|
||||
int reloc_type);
|
||||
|
||||
/* Lookup versioned symbol. */
|
||||
extern ElfW(Addr) _dl_lookup_versioned_symbol (const char *undef,
|
||||
@@ -309,15 +306,14 @@ extern ElfW(Addr) _dl_lookup_versioned_symbol (const char *undef,
|
||||
struct link_map *symbol_scope[],
|
||||
const char *reference_name,
|
||||
const struct r_found_version *version,
|
||||
int flags);
|
||||
int reloc_type);
|
||||
|
||||
/* For handling RTLD_NEXT we must be able to skip shared objects. */
|
||||
extern ElfW(Addr) _dl_lookup_symbol_skip (const char *undef,
|
||||
const ElfW(Sym) **sym,
|
||||
struct link_map *symbol_scope[],
|
||||
const char *reference_name,
|
||||
struct link_map *skip_this,
|
||||
int flags);
|
||||
struct link_map *skip_this);
|
||||
|
||||
/* For handling RTLD_NEXT with versioned symbols we must be able to
|
||||
skip shared objects. */
|
||||
@@ -326,8 +322,7 @@ extern ElfW(Addr) _dl_lookup_versioned_symbol_skip (const char *undef,
|
||||
struct link_map *symbol_scope[],
|
||||
const char *reference_name,
|
||||
const struct r_found_version *version,
|
||||
struct link_map *skip_this,
|
||||
int flags);
|
||||
struct link_map *skip_this);
|
||||
|
||||
/* Look up symbol NAME in MAP's scope and return its run-time address. */
|
||||
extern ElfW(Addr) _dl_symbol_value (struct link_map *map, const char *name);
|
||||
|
||||
+3
-1
@@ -106,6 +106,7 @@ _dl_start (void *arg)
|
||||
|
||||
ELF_DYNAMIC_RELOCATE (&bootstrap_map, 0);
|
||||
|
||||
elf_machine_runtime_setup (&bootstrap_map, 0);
|
||||
|
||||
/* Now life is sane; we can call functions and access global data.
|
||||
Set up to use the operating system facilities, and find out from
|
||||
@@ -265,6 +266,7 @@ of this helper program; chances are you did not intend to run this program.\n",
|
||||
main_map->l_phdr = phdr;
|
||||
main_map->l_phnum = phent;
|
||||
main_map->l_entry = *user_entry;
|
||||
main_map->l_opencount = 1;
|
||||
}
|
||||
|
||||
/* Scan the program header table for the dynamic section. */
|
||||
@@ -517,7 +519,7 @@ of this helper program; chances are you did not intend to run this program.\n",
|
||||
ElfW(Addr) loadbase = _dl_lookup_symbol (_dl_argv[i], &ref,
|
||||
&_dl_default_scope[2],
|
||||
"argument",
|
||||
DL_LOOKUP_NOPLT);
|
||||
ELF_MACHINE_RELOC_NOPLT);
|
||||
char buf[20], *bp;
|
||||
buf[sizeof buf - 1] = '\0';
|
||||
bp = _itoa (ref->st_value, &buf[sizeof buf - 1], 16, 0);
|
||||
|
||||
+91
-39
@@ -34,6 +34,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/gmon.h>
|
||||
#include <sys/gmon_out.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
@@ -165,21 +166,26 @@ static void
|
||||
write_hist (fd)
|
||||
int fd;
|
||||
{
|
||||
const u_char tag = GMON_TAG_TIME_HIST;
|
||||
struct gmon_hist_hdr thdr;
|
||||
u_char tag = GMON_TAG_TIME_HIST;
|
||||
struct gmon_hist_hdr thdr __attribute__ ((aligned (__alignof__ (char *))));
|
||||
|
||||
if (_gmonparam.kcountsize > 0)
|
||||
{
|
||||
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));
|
||||
struct iovec iov[3] =
|
||||
{
|
||||
{ &tag, sizeof (tag) },
|
||||
{ &thdr, sizeof (struct gmon_hist_hdr) },
|
||||
{ _gmonparam.kcount, _gmonparam.kcountsize }
|
||||
};
|
||||
|
||||
*(char **) thdr.low_pc = (char *) _gmonparam.lowpc;
|
||||
*(char **) thdr.high_pc = (char *) _gmonparam.highpc;
|
||||
*(int *) thdr.hist_size = _gmonparam.kcountsize / sizeof (HISTCOUNTER);
|
||||
*(int *) thdr.prof_rate = __profile_frequency ();
|
||||
strncpy (thdr.dimen, "seconds", sizeof (thdr.dimen));
|
||||
thdr.dimen_abbrev = 's';
|
||||
|
||||
write(fd, &tag, sizeof(tag));
|
||||
write(fd, &thdr, sizeof(thdr));
|
||||
write(fd, _gmonparam.kcount, _gmonparam.kcountsize);
|
||||
__writev (fd, iov, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,12 +194,26 @@ static void
|
||||
write_call_graph (fd)
|
||||
int fd;
|
||||
{
|
||||
const u_char tag = GMON_TAG_CG_ARC;
|
||||
struct gmon_cg_arc_record raw_arc;
|
||||
u_char tag = GMON_TAG_CG_ARC;
|
||||
struct gmon_cg_arc_record raw_arc[4]
|
||||
__attribute__ ((aligned (__alignof__ (char*))));
|
||||
int from_index, to_index, from_len;
|
||||
u_long frompc;
|
||||
|
||||
from_len = _gmonparam.fromssize / sizeof(*_gmonparam.froms);
|
||||
struct iovec iov[8] =
|
||||
{
|
||||
{ &tag, sizeof (tag) },
|
||||
{ &raw_arc[0], sizeof (struct gmon_cg_arc_record) },
|
||||
{ &tag, sizeof (tag) },
|
||||
{ &raw_arc[1], sizeof (struct gmon_cg_arc_record) },
|
||||
{ &tag, sizeof (tag) },
|
||||
{ &raw_arc[2], sizeof (struct gmon_cg_arc_record) },
|
||||
{ &tag, sizeof (tag) },
|
||||
{ &raw_arc[3], sizeof (struct gmon_cg_arc_record) },
|
||||
};
|
||||
int nfilled = 0;
|
||||
|
||||
from_len = _gmonparam.fromssize / sizeof (*_gmonparam.froms);
|
||||
for (from_index = 0; from_index < from_len; ++from_index)
|
||||
{
|
||||
if (_gmonparam.froms[from_index] == 0)
|
||||
@@ -201,19 +221,24 @@ write_call_graph (fd)
|
||||
|
||||
frompc = _gmonparam.lowpc;
|
||||
frompc += (from_index * _gmonparam.hashfraction
|
||||
* sizeof(*_gmonparam.froms));
|
||||
* sizeof (*_gmonparam.froms));
|
||||
for (to_index = _gmonparam.froms[from_index];
|
||||
to_index != 0;
|
||||
to_index = _gmonparam.tos[to_index].link)
|
||||
{
|
||||
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));
|
||||
if (nfilled > 3)
|
||||
{
|
||||
__writev (fd, iov, 2 * nfilled);
|
||||
nfilled = 0;
|
||||
}
|
||||
*(char **) raw_arc[nfilled].from_pc = (char *)frompc;
|
||||
*(char **) raw_arc[nfilled].self_pc =
|
||||
(char *)_gmonparam.tos[to_index].selfpc;
|
||||
*(int *) raw_arc[nfilled].count = _gmonparam.tos[to_index].count;
|
||||
++nfilled;
|
||||
}
|
||||
}
|
||||
__writev (fd, iov, 2 * nfilled);
|
||||
}
|
||||
|
||||
|
||||
@@ -222,55 +247,82 @@ write_bb_counts (fd)
|
||||
int fd;
|
||||
{
|
||||
struct __bb *grp;
|
||||
const u_char tag = GMON_TAG_BB_COUNT;
|
||||
int ncounts;
|
||||
int i;
|
||||
u_char tag = GMON_TAG_BB_COUNT;
|
||||
size_t ncounts;
|
||||
size_t i;
|
||||
|
||||
struct iovec bbhead[2] =
|
||||
{
|
||||
{ &tag, sizeof (tag) },
|
||||
{ &ncounts, sizeof (ncounts) }
|
||||
};
|
||||
struct iovec bbbody[8];
|
||||
size_t nfilled;
|
||||
|
||||
for (i = 0; i < (sizeof (bbbody) / sizeof (bbbody[0])); i += 2)
|
||||
{
|
||||
bbbody[i].iov_len = sizeof (grp->addresses[0]);
|
||||
bbbody[i + 1].iov_len = sizeof (grp->counts[0]);
|
||||
}
|
||||
|
||||
/* Write each group of basic-block info (all basic-blocks in a
|
||||
compilation unit form a single group). */
|
||||
|
||||
nfilled = 0;
|
||||
for (grp = __bb_head; grp; grp = grp->next)
|
||||
{
|
||||
ncounts = grp->ncounts;
|
||||
write(fd, &tag, sizeof(tag));
|
||||
write(fd, &ncounts, sizeof(ncounts));
|
||||
if (nfilled > 0)
|
||||
{
|
||||
__writev (fd, bbbody, nfilled);
|
||||
nfilled = 0;
|
||||
}
|
||||
__writev (fd, bbhead, 2);
|
||||
for (i = 0; i < ncounts; ++i)
|
||||
{
|
||||
write(fd, &grp->addresses[i], sizeof(grp->addresses[0]));
|
||||
write(fd, &grp->counts[i], sizeof(grp->counts[0]));
|
||||
if (nfilled > (sizeof (bbbody) / sizeof (bbbody[0])) - 2)
|
||||
{
|
||||
__writev (fd, bbbody, nfilled);
|
||||
nfilled = 0;
|
||||
}
|
||||
|
||||
bbbody[nfilled++].iov_base = (char *) &grp->addresses[i];
|
||||
bbbody[nfilled++].iov_base = &grp->counts[i];
|
||||
}
|
||||
}
|
||||
if (nfilled > 0)
|
||||
__writev (fd, bbbody, nfilled);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mcleanup ()
|
||||
{
|
||||
struct gmon_hdr ghdr;
|
||||
struct gmon_hdr ghdr __attribute__ ((aligned (__alignof__ (int))));
|
||||
int fd;
|
||||
|
||||
moncontrol(0);
|
||||
fd = open("gmon.out", O_CREAT|O_TRUNC|O_WRONLY, 0666);
|
||||
moncontrol (0);
|
||||
fd = __open ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY, 0666);
|
||||
if (fd < 0)
|
||||
{
|
||||
perror("_mcleanup: gmon.out");
|
||||
perror ("_mcleanup: gmon.out");
|
||||
return;
|
||||
}
|
||||
|
||||
/* write gmon.out header: */
|
||||
memset(&ghdr, 0, sizeof(ghdr));
|
||||
memcpy(&ghdr.cookie[0], GMON_MAGIC, sizeof(ghdr.cookie));
|
||||
ghdr.version = GMON_VERSION;
|
||||
write(fd, &ghdr, sizeof(ghdr));
|
||||
memset (&ghdr, 0, sizeof (struct gmon_hdr));
|
||||
memcpy (&ghdr.cookie[0], GMON_MAGIC, sizeof (ghdr.cookie));
|
||||
*(int *) ghdr.version = GMON_VERSION;
|
||||
__write (fd, &ghdr, sizeof (struct gmon_hdr));
|
||||
|
||||
/* write PC histogram: */
|
||||
write_hist(fd);
|
||||
write_hist (fd);
|
||||
|
||||
/* write call-graph: */
|
||||
write_call_graph(fd);
|
||||
write_call_graph (fd);
|
||||
|
||||
/* write basic-block execution counts: */
|
||||
write_bb_counts(fd);
|
||||
write_bb_counts (fd);
|
||||
|
||||
close(fd);
|
||||
__close (fd);
|
||||
}
|
||||
|
||||
+27
-21
@@ -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 David Mosberger <davidm@cs.arizona.edu>.
|
||||
|
||||
@@ -40,30 +40,36 @@ __BEGIN_DECLS
|
||||
* always comes first in gmon.out and is then followed by a series
|
||||
* records defined below.
|
||||
*/
|
||||
struct gmon_hdr {
|
||||
char cookie[4];
|
||||
int version;
|
||||
int spare[3];
|
||||
};
|
||||
struct gmon_hdr
|
||||
{
|
||||
char cookie[4];
|
||||
char version[4];
|
||||
char spare[3 * 4];
|
||||
};
|
||||
|
||||
/* types of records in this file: */
|
||||
typedef enum {
|
||||
GMON_TAG_TIME_HIST = 0, GMON_TAG_CG_ARC = 1, GMON_TAG_BB_COUNT = 2
|
||||
} GMON_Record_Tag;
|
||||
typedef enum
|
||||
{
|
||||
GMON_TAG_TIME_HIST = 0,
|
||||
GMON_TAG_CG_ARC = 1,
|
||||
GMON_TAG_BB_COUNT = 2
|
||||
} GMON_Record_Tag;
|
||||
|
||||
struct gmon_hist_hdr {
|
||||
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_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 */
|
||||
char dimen[15]; /* phys. dim., usually "seconds" */
|
||||
char dimen_abbrev; /* usually 's' for "seconds" */
|
||||
};
|
||||
|
||||
struct gmon_cg_arc_record {
|
||||
unsigned long from_pc; /* address within caller's body */
|
||||
unsigned long self_pc; /* address within callee's body */
|
||||
int count; /* number of arc traversals */
|
||||
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 */
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
||||
+1
-1
@@ -338,7 +338,7 @@ again:
|
||||
* reading an NFS mounted file system, can't read files that
|
||||
* are protected read/write owner only.
|
||||
*/
|
||||
if (__euidaccess (pbuf, R_OK) != 0)
|
||||
if (__access (pbuf, R_OK) != 0)
|
||||
hostf = NULL;
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
1997-03-17 03:32 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* sort-test.sh: Call localedef with additional environment variable
|
||||
I18NPATH to point to not-yet-installed locale data files.
|
||||
|
||||
* locales/POSIX: Updated version from maintainer.
|
||||
|
||||
1997-02-15 14:32 15:10 Andreas Jaeger <aj@arthur.pfalz.de>
|
||||
|
||||
* collate-test.c (main): change prototype definition to prevent
|
||||
* collate-test.c (main): Change prototype definition to prevent
|
||||
warning.
|
||||
|
||||
1997-02-15 17:46 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
+129
-129
@@ -3,17 +3,17 @@
|
||||
# As per ISO/IEC 9945-2:1993 specifications
|
||||
# except for these additional identifying comments
|
||||
#
|
||||
# Source: ISO/IEC JTC1/SC22/WG15 RIN
|
||||
# Source: ISO/IEC JTC1/SC22/WG15
|
||||
# Address: C/O DKUUG, Fruebjergvej 3
|
||||
# DK-2900 Copenhagen O, Denmark
|
||||
# DK-2100 Copenhagen O, Denmark
|
||||
# Contact: Keld Simonsen
|
||||
# Email: Keld.Simonsen@dkuug.dk
|
||||
# Tel: +45 - 39179944
|
||||
# Fax: +45 - 39179897
|
||||
# Fax: +45 - 31208948
|
||||
# Language: POSIX
|
||||
# Territory:
|
||||
# Revision: 1.0
|
||||
# Date: 1994-04-02
|
||||
# Revision: 1.1
|
||||
# Date: 1997-03-15
|
||||
# Application: general
|
||||
# Users: general
|
||||
# Repertoiremap: POSIX
|
||||
@@ -78,132 +78,132 @@ LC_COLLATE
|
||||
# This is the POSIX Locale definition for the LC_COLLATE category.
|
||||
# The order is the same as in the ASCII code set.
|
||||
order_start forward
|
||||
<NUL>
|
||||
<SOH>
|
||||
<STX>
|
||||
<ETX>
|
||||
<EOT>
|
||||
<ENQ>
|
||||
<ACK>
|
||||
<alert>
|
||||
<backspace>
|
||||
<tab>
|
||||
<newline>
|
||||
<vertical-tab>
|
||||
<form-feed>
|
||||
<carriage-return>
|
||||
<NUL>
|
||||
<SOH>
|
||||
<STX>
|
||||
<ETX>
|
||||
<EOT>
|
||||
<ENQ>
|
||||
<ACK>
|
||||
<alert>
|
||||
<backspace>
|
||||
<tab>
|
||||
<newline>
|
||||
<vertical-tab>
|
||||
<form-feed>
|
||||
<carriage-return>
|
||||
<SI>
|
||||
<SO>
|
||||
<DLE>
|
||||
<DC1>
|
||||
<DC2>
|
||||
<DC3>
|
||||
<DC4>
|
||||
<NAK>
|
||||
<SYN>
|
||||
<ETB>
|
||||
<CAN>
|
||||
<DLE>
|
||||
<DC1>
|
||||
<DC2>
|
||||
<DC3>
|
||||
<DC4>
|
||||
<NAK>
|
||||
<SYN>
|
||||
<ETB>
|
||||
<CAN>
|
||||
<EM>
|
||||
<SUB>
|
||||
<ESC>
|
||||
<IS4>
|
||||
<IS3>
|
||||
<IS2>
|
||||
<IS1>
|
||||
<space>
|
||||
<exclamation-mark>
|
||||
<quotation-mark>
|
||||
<number-sign>
|
||||
<dollar-sign>
|
||||
<percent-sign>
|
||||
<ampersand>
|
||||
<apostrophe>
|
||||
<left-parenthesis>
|
||||
<right-parenthesis>
|
||||
<asterisk>
|
||||
<plus-sign>
|
||||
<comma>
|
||||
<hyphen>
|
||||
<period>
|
||||
<slash>
|
||||
<zero>
|
||||
<one>
|
||||
<two>
|
||||
<three>
|
||||
<four>
|
||||
<five>
|
||||
<seven>
|
||||
<eight>
|
||||
<nine>
|
||||
<colon>
|
||||
<semicolon>
|
||||
<less-than-sign>
|
||||
<equals-sign>
|
||||
<greater-than-sign>
|
||||
<question-mark>
|
||||
<commercial-at>
|
||||
<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>
|
||||
<left-square-bracket>
|
||||
<backslash>
|
||||
<right-square-bracket>
|
||||
<circumflex>
|
||||
<underscore>
|
||||
<grave-accent>
|
||||
<a>
|
||||
<b>
|
||||
<c>
|
||||
<d>
|
||||
<e>
|
||||
<f>
|
||||
<g>
|
||||
<h>
|
||||
<i>
|
||||
<j>
|
||||
<k>
|
||||
<l>
|
||||
<m>
|
||||
<n>
|
||||
<o>
|
||||
<p>
|
||||
<q>
|
||||
<r>
|
||||
<s>
|
||||
<t>
|
||||
<u>
|
||||
<v>
|
||||
<w>
|
||||
<y>
|
||||
<z>
|
||||
<left-curly-bracket>
|
||||
<vertical-line>
|
||||
<right-curly-bracket>
|
||||
<tilde>
|
||||
<DEL>
|
||||
<SUB>
|
||||
<ESC>
|
||||
<IS4>
|
||||
<IS3>
|
||||
<IS2>
|
||||
<IS1>
|
||||
<space>
|
||||
<exclamation-mark>
|
||||
<quotation-mark>
|
||||
<number-sign>
|
||||
<dollar-sign>
|
||||
<percent-sign>
|
||||
<ampersand>
|
||||
<apostrophe>
|
||||
<left-parenthesis>
|
||||
<right-parenthesis>
|
||||
<asterisk>
|
||||
<plus-sign>
|
||||
<comma>
|
||||
<hyphen>
|
||||
<period>
|
||||
<slash>
|
||||
<zero>
|
||||
<one>
|
||||
<two>
|
||||
<three>
|
||||
<four>
|
||||
<five>
|
||||
<seven>
|
||||
<eight>
|
||||
<nine>
|
||||
<colon>
|
||||
<semicolon>
|
||||
<less-than-sign>
|
||||
<equals-sign>
|
||||
<greater-than-sign>
|
||||
<question-mark>
|
||||
<commercial-at>
|
||||
<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>
|
||||
<left-square-bracket>
|
||||
<backslash>
|
||||
<right-square-bracket>
|
||||
<circumflex>
|
||||
<underscore>
|
||||
<grave-accent>
|
||||
<a>
|
||||
<b>
|
||||
<c>
|
||||
<d>
|
||||
<e>
|
||||
<f>
|
||||
<g>
|
||||
<h>
|
||||
<i>
|
||||
<j>
|
||||
<k>
|
||||
<l>
|
||||
<m>
|
||||
<n>
|
||||
<o>
|
||||
<p>
|
||||
<q>
|
||||
<r>
|
||||
<s>
|
||||
<t>
|
||||
<u>
|
||||
<v>
|
||||
<w>
|
||||
<y>
|
||||
<z>
|
||||
<left-curly-bracket>
|
||||
<vertical-line>
|
||||
<right-curly-bracket>
|
||||
<tilde>
|
||||
<DEL>
|
||||
order_end
|
||||
#
|
||||
END LC_COLLATE
|
||||
@@ -214,7 +214,7 @@ LC_MONETARY
|
||||
#
|
||||
int_curr_symbol ""
|
||||
currency_symbol ""
|
||||
mon_decimal_point "."
|
||||
mon_decimal_point "<period>"
|
||||
mon_thousands_sep ""
|
||||
mon_grouping -1
|
||||
positive_sign ""
|
||||
|
||||
@@ -11,9 +11,9 @@ for l in $lang; do
|
||||
cns=`echo $l | sed 's/\(.*\)[.][^.]*/\1/'`
|
||||
cn=locales/$cns
|
||||
fn=charmaps/`echo $l | sed 's/.*[.]\([^.]*\)/\1/'`
|
||||
LD_LIBRARY_PATH=$common_objpfx $common_objpfx/elf/ld.so \
|
||||
$common_objpfx/locale/localedef --quiet -i $cn -f $fn \
|
||||
$common_objpfx/localedata/$cns
|
||||
LD_LIBRARY_PATH=$common_objpfx I18NPATH=./locales ${common_objpfx}elf/ld.so \
|
||||
${common_objpfx}locale/localedef --quiet -i $cn -f $fn \
|
||||
${common_objpfx}localedata/$cns
|
||||
done
|
||||
|
||||
# Run collation tests.
|
||||
|
||||
+7
-1
@@ -147,10 +147,16 @@ output (FILE *f, int c)
|
||||
{
|
||||
kern_return_t err;
|
||||
int wrote;
|
||||
int thiswrite;
|
||||
|
||||
while (to_write > 0)
|
||||
{
|
||||
thiswrite = to_write;
|
||||
if (thiswrite > IO_INBAND_MAX)
|
||||
thiswrite = IO_INBAND_MAX;
|
||||
|
||||
if (err = device_write_inband ((device_t) f->__cookie, 0,
|
||||
f->__target, p, to_write, &wrote))
|
||||
f->__target, p, thiswrite, &wrote))
|
||||
{
|
||||
errno = err;
|
||||
f->__error = 1;
|
||||
|
||||
+26
-2
@@ -47,8 +47,9 @@ libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \
|
||||
w_atan2 w_atanh w_cosh w_drem w_exp w_fmod w_gamma \
|
||||
w_gamma_r w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r \
|
||||
w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt \
|
||||
s_signbit s_fpclassify s_fmax s_fmin s_fdim \
|
||||
conj cimag creal cabs
|
||||
s_signbit s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc \
|
||||
s_remquo \
|
||||
conj cimag creal cabs s_cexp
|
||||
libm-routines = $(libm-support) $(libm-calls) \
|
||||
$(patsubst %_rf,%f_r,$(libm-calls:=f)) \
|
||||
$(long-m-$(long-double-fcts))
|
||||
@@ -64,6 +65,23 @@ routines = $(calls) $(calls:=f) $(long-c-$(long-double-fcts))
|
||||
long-c-yes = $(calls:=l)
|
||||
distribute += $(long-c-yes:=.c)
|
||||
|
||||
# Rules for the test suite.
|
||||
tests = test-float test-double $(test-longdouble-$(long-double-fcts))
|
||||
# We do the `long double' tests only if this data type is available and
|
||||
# distrinct from `double'.
|
||||
#
|
||||
# XXX This test is disabled for now since the functions are too buggy.
|
||||
#test-longdouble-yes = test-longdouble
|
||||
|
||||
CFLAGS-test-float.c = -fno-inline
|
||||
CFLAGS-test-double.c = -fno-inline
|
||||
CFLAGS-test-longdouble.c = -fno-inline
|
||||
LDLIBS-test-float = libm
|
||||
LDLIBS-test-double = libm
|
||||
LDLIBS-test-longdouble = libm
|
||||
|
||||
distribute += libm-test.c
|
||||
|
||||
|
||||
# The -lieee module sets the _LIB_VERSION_ switch to IEEE mode
|
||||
# for error handling in the -lm functions.
|
||||
@@ -101,3 +119,9 @@ override CFLAGS += -Wno-uninitialized -Wno-write-strings
|
||||
$(objpfx)libieee.a: $(objpfx)ieee-math.o
|
||||
rm -f $@
|
||||
ln $< $@
|
||||
|
||||
ifeq ($(build-shared),yes)
|
||||
$(addprefix $(objpfx),$(tests)): $(objpfx)libm.so$(libm.so-version)
|
||||
else
|
||||
$(addprefix $(objpfx),$(tests)): $(objpfx)libm.a
|
||||
endif
|
||||
|
||||
+4
-4
@@ -103,10 +103,10 @@ __MATHCALL (csqrt, (_Mdouble_complex_ __z));
|
||||
/* Absolute value, projections, conjugates, and projection. */
|
||||
|
||||
/* Absolute value of Z. */
|
||||
__MATHDECL (_Mdouble_, cabs, (_Mdouble_complex_ __z));
|
||||
__MATHDECL (_Mdouble_,cabs, (_Mdouble_complex_ __z));
|
||||
|
||||
/* Argument value of Z. */
|
||||
__MATHDECL (_Mdouble_, carg, (_Mdouble_complex_ __z));
|
||||
__MATHDECL (_Mdouble_,carg, (_Mdouble_complex_ __z));
|
||||
|
||||
/* Complex conjugate of Z. */
|
||||
__MATHCALL (conj, (_Mdouble_complex_ __z));
|
||||
@@ -118,10 +118,10 @@ __MATHCALL (cproj, (_Mdouble_complex_ __z));
|
||||
/* Decomposing complex values. */
|
||||
|
||||
/* Imaginary part of Z. */
|
||||
__MATHDECL (_Mdouble_, cimag, (_Mdouble_complex_ __z));
|
||||
__MATHDECL (_Mdouble_,cimag, (_Mdouble_complex_ __z));
|
||||
|
||||
/* Real part of Z. */
|
||||
__MATHDECL (_Mdouble_, creal, (_Mdouble_complex_ __z));
|
||||
__MATHDECL (_Mdouble_,creal, (_Mdouble_complex_ __z));
|
||||
|
||||
|
||||
/* Now some optimized versions. GCC has handy notations for these
|
||||
|
||||
+503
-117
@@ -40,10 +40,11 @@
|
||||
|
||||
/* This program isn't finished yet.
|
||||
It has tests for acos, acosh, asin, asinh, atan, atan2, atanh,
|
||||
cbrt, ceil, cos, cosh, exp, exp2, expm1, fabs, floor, fpclassify,
|
||||
frexp, ldexp,
|
||||
log, log10, log1p, log2, logb,
|
||||
pow, sin, sinh, tan, tanh, fabs, hypot.
|
||||
cbrt, ceil, copysign, cos, cosh, exp, exp2, expm1,
|
||||
fabs, fdim, floor, fmin, fmax, fpclassify,
|
||||
frexp, hypot, ilogb, ldexp,
|
||||
log, log10, log1p, log2, logb, modf, nextafter,
|
||||
pow, scalb, scalbn, sin, sinh, sqrt, tan, tanh, trunc.
|
||||
Tests for the other libm-functions will come later.
|
||||
|
||||
The routines using random variables are still under construction. I don't
|
||||
@@ -66,8 +67,11 @@
|
||||
log2. */
|
||||
#undef ISO_9X_IMPLEMENTED
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
@@ -100,10 +104,10 @@ static MATHTYPE plus_infty, minus_infty, nan_value;
|
||||
typedef MATHTYPE (*mathfunc) (MATHTYPE);
|
||||
|
||||
|
||||
#define ISINF(x) \
|
||||
(sizeof (x) == sizeof (float) ? \
|
||||
isinff (x) \
|
||||
: sizeof (x) == sizeof (double) ? \
|
||||
#define ISINF(x) \
|
||||
(sizeof (x) == sizeof (float) ? \
|
||||
isinff (x) \
|
||||
: sizeof (x) == sizeof (double) ? \
|
||||
isinf (x) : isinfl (x))
|
||||
|
||||
|
||||
@@ -192,7 +196,7 @@ check_equal (MATHTYPE computed, MATHTYPE supplied, MATHTYPE eps, MATHTYPE * diff
|
||||
|
||||
*diff = FUNC(fabs) (computed - supplied);
|
||||
|
||||
if (*diff <= eps || signbit (computed) != signbit (supplied))
|
||||
if (*diff <= eps && (signbit (computed) == signbit (supplied) || eps != 0.0))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@@ -211,7 +215,7 @@ output_result_bool (const char *test_name, int result)
|
||||
{
|
||||
if (verbose)
|
||||
printf ("Fail: %s\n", test_name);
|
||||
noErrors++;
|
||||
++noErrors;
|
||||
}
|
||||
|
||||
fpstack_test (test_name);
|
||||
@@ -592,7 +596,7 @@ ceil_test (void)
|
||||
check_isinfn ("ceil (-inf) == -inf", FUNC(ceil) (minus_infty));
|
||||
|
||||
check ("ceil (pi) == 4", FUNC(ceil) (M_PI), 4.0);
|
||||
check ("ceil (-pi) == -3", FUNC(ceil) (-M_PI), 3.0);
|
||||
check ("ceil (-pi) == -3", FUNC(ceil) (-M_PI), -3.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -610,8 +614,8 @@ cos_test (void)
|
||||
INVALID_EXCEPTION);
|
||||
|
||||
check_eps ("cos (pi/3) == 0.5", FUNC(cos) (M_PI / 3.0),
|
||||
0.5, CHOOSE (0, 1e-15L, 1e-7L));
|
||||
check_eps ("cos (pi/2) == 0.5", FUNC(cos) (M_PI_2),
|
||||
0.5, CHOOSE (4e-18L, 1e-15L, 1e-7L));
|
||||
check_eps ("cos (pi/2) == 0", FUNC(cos) (M_PI_2),
|
||||
0, CHOOSE (1e-19L, 1e-16L, 1e-7L));
|
||||
|
||||
}
|
||||
@@ -636,7 +640,7 @@ exp_test (void)
|
||||
check_isinfp ("exp (+inf) == +inf", FUNC(exp) (plus_infty));
|
||||
check ("exp (-inf) == 0", FUNC(exp) (minus_infty), 0);
|
||||
|
||||
check ("exp (1) == e", FUNC(exp) (1), M_E);
|
||||
check_eps ("exp (1) == e", FUNC(exp) (1), M_E, CHOOSE (4e-18L, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -663,7 +667,8 @@ expm1_test (void)
|
||||
check_isinfp ("expm1 (+inf) == +inf", FUNC(expm1) (plus_infty));
|
||||
check ("expm1 (-inf) == -1", FUNC(expm1) (minus_infty), -1);
|
||||
|
||||
check ("expm1 (1) == e-1", FUNC(expm1) (1), M_E - 1.0);
|
||||
check_eps ("expm1 (1) == e-1", FUNC(expm1) (1), M_E - 1.0,
|
||||
CHOOSE (4e-18L, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -773,9 +778,36 @@ fpclassify_test (void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ilogb_test (void)
|
||||
{
|
||||
|
||||
/* XXX Are these tests correct? I couldn't find any specification */
|
||||
#if 0
|
||||
/* the source suggests that the following calls should fail -
|
||||
but shall we test these special cases or just ignore them? */
|
||||
check_isinfp ("ilogb (+inf) == +inf", FUNC(ilogb) (plus_infty));
|
||||
check_isinfp ("ilogb (-inf) == +inf", FUNC(ilogb) (minus_infty));
|
||||
|
||||
check_isinfn_exc ("ilogb (+0) == -inf plus divide-by-zero exception",
|
||||
FUNC(ilogb) (0), DIVIDE_BY_ZERO_EXCEPTION);
|
||||
|
||||
check_isinfn_exc ("ilogb (-0) == -inf plus divide-by-zero exception",
|
||||
FUNC(ilogb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
|
||||
#endif
|
||||
check ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
|
||||
check ("ilogb (e) == 1", FUNC(ilogb) (M_E), 1);
|
||||
check ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
|
||||
check ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ldexp_test (void)
|
||||
{
|
||||
MATHTYPE x;
|
||||
|
||||
check ("ldexp (0, 0) == 0", FUNC(ldexp) (0, 0), 0);
|
||||
|
||||
check_isinfp ("ldexp (+inf, 1) == +inf", FUNC(ldexp) (plus_infty, 1));
|
||||
@@ -784,6 +816,10 @@ ldexp_test (void)
|
||||
|
||||
check ("ldexp (0.8, 4) == 12.8", FUNC(ldexp) (0.8L, 4), 12.8L);
|
||||
check ("ldexp (-0.854375, 5) == -27.34", FUNC(ldexp) (-0.854375L, 5), -27.34L);
|
||||
|
||||
x = random_greater (0.0);
|
||||
check_ext ("ldexp (x, 0) == x", FUNC(ldexp) (x, 0L), x, x);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -801,10 +837,12 @@ log_test (void)
|
||||
FUNC(log) (-1), INVALID_EXCEPTION);
|
||||
check_isinfp ("log (+inf) == +inf", FUNC(log) (plus_infty));
|
||||
|
||||
check_eps ("log (e) == 1", FUNC(log) (M_E), 1, CHOOSE (0, 0, 9e-8L));
|
||||
check ("log (1/e) == -1", FUNC(log) (1.0 / M_E), 1);
|
||||
check_eps ("log (e) == 1", FUNC(log) (M_E), 1, CHOOSE (1e-18L, 0, 9e-8L));
|
||||
check_eps ("log (1/e) == -1", FUNC(log) (1.0 / M_E), -1,
|
||||
CHOOSE (2e-18L, 0, 0));
|
||||
check ("log (2) == M_LN2", FUNC(log) (2), M_LN2);
|
||||
check ("log (10) == M_LN10", FUNC(log) (10), M_LN10);
|
||||
check_eps ("log (10) == M_LN10", FUNC(log) (10), M_LN10,
|
||||
CHOOSE (1e-18L, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -823,12 +861,15 @@ log10_test (void)
|
||||
|
||||
check_isinfp ("log10 (+inf) == +inf", FUNC(log10) (plus_infty));
|
||||
|
||||
check ("log10 (0.1) == -1", FUNC(log10) (0.1L), -1);
|
||||
check ("log10 (10) == 1", FUNC(log10) (10.0), 1);
|
||||
check ("log10 (100) == 2", FUNC(log10) (100.0), 2);
|
||||
check_eps ("log10 (0.1) == -1", FUNC(log10) (0.1L), -1,
|
||||
CHOOSE (1e-18L, 0, 0));
|
||||
check_eps ("log10 (10) == 1", FUNC(log10) (10.0), 1,
|
||||
CHOOSE (1e-18L, 0, 0));
|
||||
check_eps ("log10 (100) == 2", FUNC(log10) (100.0), 2,
|
||||
CHOOSE (1e-18L, 0, 0));
|
||||
check ("log10 (10000) == 4", FUNC(log10) (10000.0), 4);
|
||||
check_eps ("log10 (e) == M_LOG10E", FUNC(log10) (M_E), M_LOG10E,
|
||||
CHOOSE (0, 0, 9e-8));
|
||||
CHOOSE (1e-18, 0, 9e-8));
|
||||
}
|
||||
|
||||
|
||||
@@ -845,7 +886,8 @@ log1p_test (void)
|
||||
|
||||
check_isinfp ("log1p (+inf) == +inf", FUNC(log1p) (plus_infty));
|
||||
|
||||
check ("log1p (e-1) == 1", FUNC(log1p) (M_E - 1.0), 1);
|
||||
check_eps ("log1p (e-1) == 1", FUNC(log1p) (M_E - 1.0), 1,
|
||||
CHOOSE (1e-18L, 0, 0));
|
||||
|
||||
}
|
||||
|
||||
@@ -895,6 +937,80 @@ logb_test (void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
modf_test (void)
|
||||
{
|
||||
MATHTYPE result, intpart;
|
||||
|
||||
result = FUNC(modf) (plus_infty, &intpart);
|
||||
check ("modf (+inf, &x) returns +0", result, 0);
|
||||
check_isinfp ("modf (+inf, &x) set x to +inf", intpart);
|
||||
|
||||
result = FUNC(modf) (minus_infty, &intpart);
|
||||
check ("modf (-inf, &x) returns -0", result, minus_zero);
|
||||
check_isinfn ("modf (-inf, &x) sets x to -inf", intpart);
|
||||
|
||||
result = FUNC(modf) (nan_value, &intpart);
|
||||
check_isnan ("modf (NaN, &x) returns NaN", result);
|
||||
check_isnan ("modf (-inf, &x) sets x to NaN", intpart);
|
||||
|
||||
result = FUNC(modf) (0, &intpart);
|
||||
check ("modf (0, &x) returns 0", result, 0);
|
||||
check ("modf (0, &x) sets x to 0", intpart, 0);
|
||||
|
||||
result = FUNC(modf) (minus_zero, &intpart);
|
||||
check ("modf (-0, &x) returns -0", result, minus_zero);
|
||||
check ("modf (-0, &x) sets x to -0", intpart, minus_zero);
|
||||
|
||||
result = FUNC(modf) (2.5, &intpart);
|
||||
check ("modf (2.5, &x) returns 0.5", result, 0.5);
|
||||
check ("modf (2.5, &x) sets x to 2", intpart, 2);
|
||||
|
||||
result = FUNC(modf) (-2.5, &intpart);
|
||||
check ("modf (-2.5, &x) returns -0.5", result, -0.5);
|
||||
check ("modf (-2.5, &x) sets x to -2", intpart, -2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
scalb_test (void)
|
||||
{
|
||||
MATHTYPE x;
|
||||
|
||||
check ("scalb (0, 0) == 0", FUNC(scalb) (0, 0), 0);
|
||||
|
||||
check_isinfp ("scalb (+inf, 1) == +inf", FUNC(scalb) (plus_infty, 1));
|
||||
check_isinfn ("scalb (-inf, 1) == -inf", FUNC(scalb) (minus_infty, 1));
|
||||
check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb) (nan_value, 1));
|
||||
|
||||
check ("scalb (0.8, 4) == 12.8", FUNC(scalb) (0.8L, 4), 12.8L);
|
||||
check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb) (-0.854375L, 5), -27.34L);
|
||||
|
||||
x = random_greater (0.0);
|
||||
check_ext ("scalb (x, 0) == x", FUNC(scalb) (x, 0L), x, x);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
scalbn_test (void)
|
||||
{
|
||||
MATHTYPE x;
|
||||
|
||||
check ("scalbn (0, 0) == 0", FUNC(scalbn) (0, 0), 0);
|
||||
|
||||
check_isinfp ("scalbn (+inf, 1) == +inf", FUNC(scalbn) (plus_infty, 1));
|
||||
check_isinfn ("scalbn (-inf, 1) == -inf", FUNC(scalbn) (minus_infty, 1));
|
||||
check_isnan ("scalbn (NaN, 1) == NaN", FUNC(scalbn) (nan_value, 1));
|
||||
|
||||
check ("scalbn (0.8, 4) == 12.8", FUNC(scalbn) (0.8L, 4), 12.8L);
|
||||
check ("scalbn (-0.854375, 5) == -27.34", FUNC(scalbn) (-0.854375L, 5), -27.34L);
|
||||
|
||||
x = random_greater (0.0);
|
||||
check_ext ("scalbn (x, 0) == x", FUNC(scalbn) (x, 0L), x, x);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
sin_test (void)
|
||||
{
|
||||
@@ -907,7 +1023,8 @@ sin_test (void)
|
||||
FUNC(sin) (minus_infty),
|
||||
INVALID_EXCEPTION);
|
||||
|
||||
check ("sin (pi/6) == 0.5", FUNC(sin) (M_PI / 6.0), 0.5);
|
||||
check_eps ("sin (pi/6) == 0.5", FUNC(sin) (M_PI / 6.0), 0.5,
|
||||
CHOOSE (4e-18L, 0, 0));
|
||||
check ("sin (pi/2) == 1", FUNC(sin) (M_PI_2), 1);
|
||||
}
|
||||
|
||||
@@ -926,14 +1043,15 @@ sinh_test (void)
|
||||
static void
|
||||
tan_test (void)
|
||||
{
|
||||
check ("tan (+0) == -0", FUNC(tan) (0), 0);
|
||||
check ("tan (+0) == +0", FUNC(tan) (0), 0);
|
||||
check ("tan (-0) == -0", FUNC(tan) (minus_zero), minus_zero);
|
||||
check_isnan_exc ("tan (+inf) == NaN plus invalid exception",
|
||||
FUNC(tan) (plus_infty), INVALID_EXCEPTION);
|
||||
check_isnan_exc ("tan (-inf) == NaN plus invalid exception",
|
||||
FUNC(tan) (minus_infty), INVALID_EXCEPTION);
|
||||
|
||||
check_eps ("tan (pi/4) == 1", FUNC(tan) (M_PI_4), 1, CHOOSE (0, 1e-15L, 0));
|
||||
check_eps ("tan (pi/4) == 1", FUNC(tan) (M_PI_4), 1,
|
||||
CHOOSE (2e-18L, 1e-15L, 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -971,58 +1089,33 @@ floor_test (void)
|
||||
check_isinfn ("floor (-inf) == -inf", FUNC(floor) (minus_infty));
|
||||
|
||||
check ("floor (pi) == 3", FUNC(floor) (M_PI), 3.0);
|
||||
check ("floor (-pi) == -4", FUNC(floor) (-M_PI), 4.0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
hypot_report (const char *test_name, MATHTYPE computed, MATHTYPE expected)
|
||||
{
|
||||
MATHTYPE diff;
|
||||
int result;
|
||||
|
||||
result = check_equal (computed, expected, 0, &diff);
|
||||
|
||||
if (result)
|
||||
{
|
||||
if (verbose > 2)
|
||||
printf ("Pass: %s\n", test_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (verbose)
|
||||
printf ("Fail: %s\n", test_name);
|
||||
if (verbose > 1)
|
||||
{
|
||||
printf ("Result:\n");
|
||||
printf (" is: %.20" PRINTF_EXPR, computed);
|
||||
printf (" should be: %.20" PRINTF_EXPR, expected);
|
||||
printf (" difference: %.20" PRINTF_EXPR "\n", diff);
|
||||
}
|
||||
noErrors++;
|
||||
}
|
||||
fpstack_test (test_name);
|
||||
output_result (test_name, result,
|
||||
computed, expected, diff, PRINT, PRINT);
|
||||
check ("floor (-pi) == -4", FUNC(floor) (-M_PI), -4.0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
hypot_test (void)
|
||||
{
|
||||
MATHTYPE a = FUNC(hypot) (12.4L, 0.7L);
|
||||
MATHTYPE a;
|
||||
|
||||
hypot_report ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a);
|
||||
hypot_report ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a);
|
||||
hypot_report ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a);
|
||||
hypot_report ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a);
|
||||
hypot_report ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a);
|
||||
a = random_greater (0);
|
||||
check_isinfp_ext ("hypot (+inf, x) == +inf", FUNC(hypot) (plus_infty, a), a);
|
||||
check_isinfp_ext ("hypot (-inf, x) == +inf", FUNC(hypot) (minus_infty, a), a);
|
||||
|
||||
check_isnan ("hypot (NaN, NaN) == NaN", FUNC(hypot) (nan_value, nan_value));
|
||||
|
||||
a = FUNC(hypot) (12.4L, 0.7L);
|
||||
check ("hypot (x,y) == hypot (y,x)", FUNC(hypot) (0.7L, 12.4L), a);
|
||||
check ("hypot (x,y) == hypot (-x,y)", FUNC(hypot) (-12.4L, 0.7L), a);
|
||||
check ("hypot (x,y) == hypot (-y,x)", FUNC(hypot) (-0.7L, 12.4L), a);
|
||||
check ("hypot (x,y) == hypot (-x,-y)", FUNC(hypot) (-12.4L, -0.7L), a);
|
||||
check ("hypot (x,y) == hypot (-y,-x)", FUNC(hypot) (-0.7L, -12.4L), a);
|
||||
check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-0.7L, 0), 0.7L);
|
||||
check ("hypot (x,0) == fabs (x)", FUNC(hypot) (0.7L, 0), 0.7L);
|
||||
check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L);
|
||||
check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-1.0L, 0), 1.0L);
|
||||
check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L);
|
||||
check ("hypot (x,0) == fabs (x)", FUNC(hypot) (1.0L, 0), 1.0L);
|
||||
check ("hypot (x,0) == fabs (x)", FUNC(hypot) (-5.7e7L, 0), 5.7e7L);
|
||||
check ("hypot (x,0) == fabs (x)", FUNC(hypot) (5.7e7L, 0), 5.7e7L);
|
||||
}
|
||||
|
||||
|
||||
@@ -1054,15 +1147,15 @@ pow_test (void)
|
||||
check ("pow (-0.9, +inf) == +0", FUNC(pow) (-0.9L, plus_infty), 0);
|
||||
check ("pow (-1e-7, +inf) == +0", FUNC(pow) (-1e-7L, plus_infty), 0);
|
||||
|
||||
check ("pow (+1.1, -inf) == +inf", FUNC(pow) (1.1, minus_infty), 0);
|
||||
check ("pow (+inf, -inf) == +inf", FUNC(pow) (plus_infty, minus_infty), 0);
|
||||
check ("pow (-1.1, -inf) == +inf", FUNC(pow) (-1.1, minus_infty), 0);
|
||||
check ("pow (-inf, -inf) == +inf", FUNC(pow) (minus_infty, minus_infty), 0);
|
||||
check ("pow (+1.1, -inf) == 0", FUNC(pow) (1.1, minus_infty), 0);
|
||||
check ("pow (+inf, -inf) == 0", FUNC(pow) (plus_infty, minus_infty), 0);
|
||||
check ("pow (-1.1, -inf) == 0", FUNC(pow) (-1.1, minus_infty), 0);
|
||||
check ("pow (-inf, -inf) == 0", FUNC(pow) (minus_infty, minus_infty), 0);
|
||||
|
||||
check_isinfp ("pow (0.9, -inf) == +0", FUNC(pow) (0.9L, minus_infty));
|
||||
check_isinfp ("pow (1e-7, -inf) == +0", FUNC(pow) (1e-7L, minus_infty));
|
||||
check_isinfp ("pow (-0.9, -inf) == +0", FUNC(pow) (-0.9L, minus_infty));
|
||||
check_isinfp ("pow (-1e-7, -inf) == +0", FUNC(pow) (-1e-7L, minus_infty));
|
||||
check_isinfp ("pow (0.9, -inf) == +inf", FUNC(pow) (0.9L, minus_infty));
|
||||
check_isinfp ("pow (1e-7, -inf) == +inf", FUNC(pow) (1e-7L, minus_infty));
|
||||
check_isinfp ("pow (-0.9, -inf) == +inf", FUNC(pow) (-0.9L, minus_infty));
|
||||
check_isinfp ("pow (-1e-7, -inf) == +inf", FUNC(pow) (-1e-7L, minus_infty));
|
||||
|
||||
check_isinfp ("pow (+inf, 1e-7) == +inf", FUNC(pow) (plus_infty, 1e-7L));
|
||||
check_isinfp ("pow (+inf, 1) == +inf", FUNC(pow) (plus_infty, 1));
|
||||
@@ -1084,9 +1177,9 @@ pow_test (void)
|
||||
check_isinfp ("pow (-inf, 11.1) == +inf", FUNC(pow) (minus_infty, 11.1));
|
||||
check_isinfp ("pow (-inf, 1001.1) == +inf", FUNC(pow) (minus_infty, 1001.1));
|
||||
|
||||
check ("pow (-inf, -1) == -0", FUNC(pow) (-minus_infty, -1), minus_zero);
|
||||
check ("pow (-inf, -11) == -0", FUNC(pow) (-minus_infty, -11), minus_zero);
|
||||
check ("pow (-inf, -1001) == -0", FUNC(pow) (-minus_infty, -1001), minus_zero);
|
||||
check ("pow (-inf, -1) == -0", FUNC(pow) (minus_infty, -1), minus_zero);
|
||||
check ("pow (-inf, -11) == -0", FUNC(pow) (minus_infty, -11), minus_zero);
|
||||
check ("pow (-inf, -1001) == -0", FUNC(pow) (minus_infty, -1001), minus_zero);
|
||||
|
||||
check ("pow (-inf, -2) == +0", FUNC(pow) (minus_infty, -2), 0);
|
||||
check ("pow (-inf, -12) == +0", FUNC(pow) (minus_infty, -12), 0);
|
||||
@@ -1108,11 +1201,11 @@ pow_test (void)
|
||||
|
||||
check_isnan_exc ("pow (+1, +inf) == NaN", FUNC(pow) (1, plus_infty),
|
||||
INVALID_EXCEPTION);
|
||||
check_isnan_exc ("pow (-1, +inf) == NaN", FUNC(pow) (1, plus_infty),
|
||||
check_isnan_exc ("pow (-1, +inf) == NaN", FUNC(pow) (-1, plus_infty),
|
||||
INVALID_EXCEPTION);
|
||||
check_isnan_exc ("pow (+1, -inf) == NaN", FUNC(pow) (1, plus_infty),
|
||||
check_isnan_exc ("pow (+1, -inf) == NaN", FUNC(pow) (1, minus_infty),
|
||||
INVALID_EXCEPTION);
|
||||
check_isnan_exc ("pow (-1, -inf) == NaN", FUNC(pow) (1, plus_infty),
|
||||
check_isnan_exc ("pow (-1, -inf) == NaN", FUNC(pow) (-1, minus_infty),
|
||||
INVALID_EXCEPTION);
|
||||
|
||||
check_isnan_exc ("pow (-0.1, 1.1) == NaN", FUNC(pow) (-0.1, 1.1),
|
||||
@@ -1152,7 +1245,7 @@ pow_test (void)
|
||||
check ("pow (-0, 2) == +0", FUNC(pow) (minus_zero, 2), 0);
|
||||
check ("pow (-0, 11.1) == +0", FUNC(pow) (minus_zero, 11.1), 0);
|
||||
|
||||
x = random_greater (0.0);
|
||||
x = random_greater (1.0);
|
||||
check_isinfp_ext ("pow (x, +inf) == +inf for |x| > 1",
|
||||
FUNC(pow) (x, plus_infty), x);
|
||||
|
||||
@@ -1160,7 +1253,7 @@ pow_test (void)
|
||||
check_ext ("pow (x, +inf) == +0 for |x| < 1",
|
||||
FUNC(pow) (x, plus_infty), 0.0, x);
|
||||
|
||||
x = random_greater (0.0);
|
||||
x = random_greater (1.0);
|
||||
check_ext ("pow (x, -inf) == +0 for |x| > 1",
|
||||
FUNC(pow) (x, minus_infty), 0.0, x);
|
||||
|
||||
@@ -1189,8 +1282,8 @@ pow_test (void)
|
||||
FUNC(pow) (minus_infty, x), minus_zero, x);
|
||||
|
||||
x = ((rand () % 1000000) + 1) * -2.0; /* Get random even integer < 0 */
|
||||
check_ext ("pow (-inf, y) == -0 for y < 0 and not an odd integer",
|
||||
FUNC(pow) (minus_infty, x), minus_zero, x);
|
||||
check_ext ("pow (-inf, y) == +0 for y < 0 and not an odd integer",
|
||||
FUNC(pow) (minus_infty, x), 0.0, x);
|
||||
|
||||
x = (rand () % 1000000) * 2.0 + 1; /* Get random odd integer > 0 */
|
||||
check_ext ("pow (+0, y) == +0 for y an odd integer > 0",
|
||||
@@ -1209,6 +1302,273 @@ pow_test (void)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fdim_test (void)
|
||||
{
|
||||
check ("fdim (+0, +0) = +0", FUNC(fdim) (0, 0), 0);
|
||||
check ("fdim (9, 0) = 9", FUNC(fdim) (9, 0), 9);
|
||||
check ("fdim (0, 9) = 0", FUNC(fdim) (0, 9), 0);
|
||||
check ("fdim (-9, 0) = 9", FUNC(fdim) (-9, 0), 0);
|
||||
check ("fdim (0, -9) = 9", FUNC(fdim) (0, -9), 9);
|
||||
|
||||
check_isinfp ("fdim (+inf, 9) = +inf", FUNC(fdim) (plus_infty, 9));
|
||||
check_isinfp ("fdim (+inf, -9) = +inf", FUNC(fdim) (plus_infty, -9));
|
||||
check ("fdim (-inf, 9) = 0", FUNC(fdim) (minus_infty, 9), 0);
|
||||
check ("fdim (-inf, -9) = 0", FUNC(fdim) (minus_infty, -9), 0);
|
||||
check_isinfp ("fdim (+9, -inf) = +inf", FUNC(fdim) (9, minus_infty));
|
||||
check_isinfp ("fdim (-9, -inf) = +inf", FUNC(fdim) (-9, minus_infty));
|
||||
check ("fdim (9, inf) = 0", FUNC(fdim) (9, plus_infty), 0);
|
||||
check ("fdim (-9, inf) = 0", FUNC(fdim) (-9, plus_infty), 0);
|
||||
|
||||
check_isnan ("fdim (0, NaN) = NaN", FUNC(fdim) (0, nan_value));
|
||||
check_isnan ("fdim (9, NaN) = NaN", FUNC(fdim) (9, nan_value));
|
||||
check_isnan ("fdim (-9, NaN) = NaN", FUNC(fdim) (-9, nan_value));
|
||||
check_isnan ("fdim (NaN, 9) = NaN", FUNC(fdim) (nan_value, 9));
|
||||
check_isnan ("fdim (NaN, -9) = NaN", FUNC(fdim) (nan_value, -9));
|
||||
check_isnan ("fdim (+inf, NaN) = NaN", FUNC(fdim) (plus_infty, nan_value));
|
||||
check_isnan ("fdim (-inf, NaN) = NaN", FUNC(fdim) (minus_infty, nan_value));
|
||||
check_isnan ("fdim (NaN, +inf) = NaN", FUNC(fdim) (nan_value, plus_infty));
|
||||
check_isnan ("fdim (NaN, -inf) = NaN", FUNC(fdim) (nan_value, minus_infty));
|
||||
check_isnan ("fdim (NaN, NaN) = NaN", FUNC(fdim) (nan_value, nan_value));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fmin_test (void)
|
||||
{
|
||||
check ("fmin (+0, +0) = +0", FUNC(fmin) (0, 0), 0);
|
||||
check ("fmin (9, 0) = 0", FUNC(fmin) (9, 0), 0);
|
||||
check ("fmin (0, 9) = 0", FUNC(fmin) (0, 9), 0);
|
||||
check ("fmin (-9, 0) = -9", FUNC(fmin) (-9, 0), -9);
|
||||
check ("fmin (0, -9) = -9", FUNC(fmin) (0, -9), -9);
|
||||
|
||||
check ("fmin (+inf, 9) = 9", FUNC(fmin) (plus_infty, 9), 9);
|
||||
check ("fmin (9, +inf) = 9", FUNC(fmin) (9, plus_infty), 9);
|
||||
check ("fmin (+inf, -9) = -9", FUNC(fmin) (plus_infty, -9), -9);
|
||||
check ("fmin (-9, +inf) = -9", FUNC(fmin) (-9, plus_infty), -9);
|
||||
check_isinfn ("fmin (-inf, 9) = -inf", FUNC(fmin) (minus_infty, 9));
|
||||
check_isinfn ("fmin (-inf, -9) = -inf", FUNC(fmin) (minus_infty, -9));
|
||||
check_isinfn ("fmin (+9, -inf) = -inf", FUNC(fmin) (9, minus_infty));
|
||||
check_isinfn ("fmin (-9, -inf) = -inf", FUNC(fmin) (-9, minus_infty));
|
||||
|
||||
check ("fmin (0, NaN) = 0", FUNC(fmin) (0, nan_value), 0);
|
||||
check ("fmin (9, NaN) = 9", FUNC(fmin) (9, nan_value), 9);
|
||||
check ("fmin (-9, NaN) = 9", FUNC(fmin) (-9, nan_value), -9);
|
||||
check ("fmin (NaN, 0) = 0", FUNC(fmin) (nan_value, 0), 0);
|
||||
check ("fmin (NaN, 9) = NaN", FUNC(fmin) (nan_value, 9), 9);
|
||||
check ("fmin (NaN, -9) = NaN", FUNC(fmin) (nan_value, -9), -9);
|
||||
check_isinfp ("fmin (+inf, NaN) = +inf", FUNC(fmin) (plus_infty, nan_value));
|
||||
check_isinfn ("fmin (-inf, NaN) = -inf", FUNC(fmin) (minus_infty, nan_value));
|
||||
check_isinfp ("fmin (NaN, +inf) = +inf", FUNC(fmin) (nan_value, plus_infty));
|
||||
check_isinfn ("fmin (NaN, -inf) = -inf", FUNC(fmin) (nan_value, minus_infty));
|
||||
check_isnan ("fmin (NaN, NaN) = NaN", FUNC(fmin) (nan_value, nan_value));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fmax_test (void)
|
||||
{
|
||||
check ("fmax (+0, +0) = +0", FUNC(fmax) (0, 0), 0);
|
||||
check ("fmax (9, 0) = 9", FUNC(fmax) (9, 0), 9);
|
||||
check ("fmax (0, 9) = 9", FUNC(fmax) (0, 9), 9);
|
||||
check ("fmax (-9, 0) = 0", FUNC(fmax) (-9, 0), 0);
|
||||
check ("fmax (0, -9) = 0", FUNC(fmax) (0, -9), 0);
|
||||
|
||||
check_isinfp ("fmax (+inf, 9) = +inf", FUNC(fmax) (plus_infty, 9));
|
||||
check_isinfp ("fmax (9, +inf) = +inf", FUNC(fmax) (0, plus_infty));
|
||||
check_isinfp ("fmax (-9, +inf) = +inf", FUNC(fmax) (-9, plus_infty));
|
||||
check_isinfp ("fmax (+inf, -9) = +inf", FUNC(fmax) (plus_infty, -9));
|
||||
check ("fmax (-inf, 9) = 9", FUNC(fmax) (minus_infty, 9), 9);
|
||||
check ("fmax (-inf, -9) = -9", FUNC(fmax) (minus_infty, -9), -9);
|
||||
check ("fmax (+9, -inf) = 9", FUNC(fmax) (9, minus_infty), 9);
|
||||
check ("fmax (-9, -inf) = -9", FUNC(fmax) (-9, minus_infty), -9);
|
||||
|
||||
check ("fmax (0, NaN) = 0", FUNC(fmax) (0, nan_value), 0);
|
||||
check ("fmax (9, NaN) = 9", FUNC(fmax) (9, nan_value), 9);
|
||||
check ("fmax (-9, NaN) = 9", FUNC(fmax) (-9, nan_value), -9);
|
||||
check ("fmax (NaN, 0) = 0", FUNC(fmax) (nan_value, 0), 0);
|
||||
check ("fmax (NaN, 9) = NaN", FUNC(fmax) (nan_value, 9), 9);
|
||||
check ("fmax (NaN, -9) = NaN", FUNC(fmax) (nan_value, -9), -9);
|
||||
check_isinfp ("fmax (+inf, NaN) = +inf", FUNC(fmax) (plus_infty, nan_value));
|
||||
check_isinfn ("fmax (-inf, NaN) = -inf", FUNC(fmax) (minus_infty, nan_value));
|
||||
check_isinfp ("fmax (NaN, +inf) = +inf", FUNC(fmax) (nan_value, plus_infty));
|
||||
check_isinfn ("fmax (NaN, -inf) = -inf", FUNC(fmax) (nan_value, minus_infty));
|
||||
check_isnan ("fmax (NaN, NaN) = NaN", FUNC(fmax) (nan_value, nan_value));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nextafter_test (void)
|
||||
{
|
||||
MATHTYPE x;
|
||||
|
||||
check ("nextafter (+0, +0) = +0", FUNC(nextafter) (0, 0), 0);
|
||||
check ("nextafter (-0, +0) = +0", FUNC(nextafter) (minus_zero, 0), 0);
|
||||
check ("nextafter (+0, -0) = -0", FUNC(nextafter) (0, minus_zero),
|
||||
minus_zero);
|
||||
check ("nextafter (-0, -0) = -0", FUNC(nextafter) (minus_zero, minus_zero),
|
||||
minus_zero);
|
||||
|
||||
check ("nextafter (9, 9) = 9", FUNC(nextafter) (9, 9), 9);
|
||||
check ("nextafter (-9, -9) = -9", FUNC(nextafter) (-9, -9), -9);
|
||||
check_isinfp ("nextafter (+inf, +inf) = +inf",
|
||||
FUNC(nextafter) (plus_infty, plus_infty));
|
||||
check_isinfn ("nextafter (-inf, -inf) = -inf",
|
||||
FUNC(nextafter) (minus_infty, minus_infty));
|
||||
|
||||
x = rand () * 1.1;
|
||||
check_isnan ("nextafter (NaN, x) = NaN", FUNC(nextafter) (nan_value, x));
|
||||
check_isnan ("nextafter (x, NaN) = NaN", FUNC(nextafter) (x, nan_value));
|
||||
check_isnan ("nextafter (NaN, NaN) = NaN", FUNC(nextafter) (nan_value,
|
||||
nan_value));
|
||||
|
||||
/* XXX We need the hexadecimal FP number representation here for further
|
||||
tests. */
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
copysign_test (void)
|
||||
{
|
||||
check ("copysign (0, 4) = 0", FUNC(copysign) (0, 4), 0);
|
||||
check ("copysign (0, -4) = -0", FUNC(copysign) (0, -4), minus_zero);
|
||||
check ("copysign (-0, 4) = 0", FUNC(copysign) (minus_zero, 4), 0);
|
||||
check ("copysign (-0, -4) = -0", FUNC(copysign) (minus_zero, -4),
|
||||
minus_zero);
|
||||
|
||||
check_isinfp ("copysign (+inf, 0) = +inf", FUNC(copysign) (plus_infty, 0));
|
||||
check_isinfn ("copysign (+inf, -0) = -inf", FUNC(copysign) (plus_infty,
|
||||
minus_zero));
|
||||
check_isinfp ("copysign (-inf, 0) = +inf", FUNC(copysign) (minus_infty, 0));
|
||||
check_isinfn ("copysign (-inf, -0) = -inf", FUNC(copysign) (minus_infty,
|
||||
minus_zero));
|
||||
|
||||
check ("copysign (0, +inf) = 0", FUNC(copysign) (0, plus_infty), 0);
|
||||
check ("copysign (0, -inf) = -0", FUNC(copysign) (0, minus_zero),
|
||||
minus_zero);
|
||||
check ("copysign (-0, +inf) = 0", FUNC(copysign) (minus_zero, plus_infty),
|
||||
0);
|
||||
check ("copysign (-0, -inf) = -0", FUNC(copysign) (minus_zero, minus_zero),
|
||||
minus_zero);
|
||||
|
||||
/* XXX More correctly we would have to check the sign of the NaN. */
|
||||
check_isnan ("copysign (+NaN, 0) = +NaN", FUNC(copysign) (nan_value, 0));
|
||||
check_isnan ("copysign (+NaN, -0) = -NaN", FUNC(copysign) (nan_value,
|
||||
minus_zero));
|
||||
check_isnan ("copysign (-NaN, 0) = +NaN", FUNC(copysign) (-nan_value, 0));
|
||||
check_isnan ("copysign (-NaN, -0) = -NaN", FUNC(copysign) (-nan_value,
|
||||
minus_zero));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
trunc_test (void)
|
||||
{
|
||||
check ("trunc(0) = 0", FUNC(trunc) (0), 0);
|
||||
check ("trunc(-0) = -0", FUNC(trunc) (minus_zero), minus_zero);
|
||||
check ("trunc(0.625) = 0", FUNC(trunc) (0.625), 0);
|
||||
check ("trunc(-0.625) = -0", FUNC(trunc) (-0.625), minus_zero);
|
||||
check ("trunc(1) = 1", FUNC(trunc) (1), 1);
|
||||
check ("trunc(-1) = -1", FUNC(trunc) (-1), -1);
|
||||
check ("trunc(1.625) = 1", FUNC(trunc) (1.625), 1);
|
||||
check ("trunc(-1.625) = -1", FUNC(trunc) (-1.625), -1);
|
||||
|
||||
check ("trunc(1048580.625) = 1048580", FUNC(trunc) (1048580.625L),
|
||||
1048580L);
|
||||
check ("trunc(-1048580.625) = -1048580", FUNC(trunc) (-1048580.625L),
|
||||
-1048580L);
|
||||
|
||||
check ("trunc(8388610.125) = 8388610", FUNC(trunc) (8388610.125L),
|
||||
8388610.0L);
|
||||
check ("trunc(-8388610.125) = -8388610", FUNC(trunc) (-8388610.125L),
|
||||
-8388610.0L);
|
||||
|
||||
check ("trunc(4294967296.625) = 4294967296", FUNC(trunc) (4294967296.625L),
|
||||
4294967296.0L);
|
||||
check ("trunc(-4294967296.625) = -4294967296",
|
||||
FUNC(trunc) (-4294967296.625L), -4294967296.0L);
|
||||
|
||||
check_isinfp ("trunc(+inf) = +inf", FUNC(trunc) (plus_infty));
|
||||
check_isinfn ("trunc(-inf) = -inf", FUNC(trunc) (minus_infty));
|
||||
check_isnan ("trunc(NaN) = NaN", FUNC(trunc) (nan_value));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
sqrt_test (void)
|
||||
{
|
||||
MATHTYPE x;
|
||||
|
||||
|
||||
/* XXX Tests fuer negative x are missing */
|
||||
check ("sqrt (0) == 0", FUNC(sqrt) (0), 0);
|
||||
check_isnan ("sqrt (NaN) == NaN", FUNC(sqrt) (nan_value));
|
||||
check_isinfp ("sqrt (+inf) == +inf", FUNC(sqrt) (plus_infty));
|
||||
|
||||
x = random_value (0, 10000);
|
||||
check_ext ("sqrt (x*x) == x", sqrt (x*x), x, x);
|
||||
check ("sqrt (4) == 2", FUNC(sqrt) (4), 2);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
remquo_test (void)
|
||||
{
|
||||
int quo;
|
||||
MATHTYPE result;
|
||||
|
||||
result = FUNC(remquo) (1.625, 1.0, &quo);
|
||||
check ("remquo(1.625, 1.0, &x) == -0.375", result, -0.375);
|
||||
check ("remquo(1.625, 1.0, &x) puts 1 in x", quo, 1);
|
||||
|
||||
result = FUNC(remquo) (-1.625, 1.0, &quo);
|
||||
check ("remquo(-1.625, 1.0, &x) == 0.375", result, 0.375);
|
||||
check ("remquo(-1.625, 1.0, &x) puts -1 in x", quo, -1);
|
||||
|
||||
result = FUNC(remquo) (1.625, -1.0, &quo);
|
||||
check ("remquo(1.125, -1.0, &x) == 0.125", result, 0.125);
|
||||
check ("remquo(1.125, -1.0, &x) puts -1 in x", quo, -1);
|
||||
|
||||
result = FUNC(remquo) (-1.625, -1.0, &quo);
|
||||
check ("remquo(-1.125, -1.0, &x) == 0.125", result, 0.125);
|
||||
check ("remquo(-1.125, -1.0, &x) puts 1 in x", quo, 1);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cexp_test (void)
|
||||
{
|
||||
__complex__ MATHTYPE result;
|
||||
|
||||
result = FUNC(cexp) (plus_zero + 1.0i * plus_zero);
|
||||
check ("real(cexp(0 + 0i)) = 1", __real__ result, 1);
|
||||
check ("imag(cexp(0 + 0i)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (minus_zero + 1.0i * plus_zero);
|
||||
check ("real(cexp(-0 + 0i)) = 1", __real__ result, 1);
|
||||
check ("imag(cexp(-0 + 0i)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (plus_zero + 1.0i * minus_zero);
|
||||
check ("real(cexp(0 - 0i)) = 1", __real__ result, 1);
|
||||
check ("imag(cexp(0 - 0i)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (minus_zero + 1.0i * minus_zero);
|
||||
check ("real(cexp(-0 - 0i)) = 1", __real__ result, 1);
|
||||
check ("imag(cexp(-0 - 0i)) = 0", __imag__ result, 0);
|
||||
|
||||
result = FUNC(cexp) (plus_infty + 1.0i * plus_zero);
|
||||
check_isinfp ("real(cexp(+inf + 0i)) = +inf", __real__ result);
|
||||
check ("imag(cexp(+inf + 0i)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (plus_infty + 1.0i * minus_zero);
|
||||
check_isinfp ("real(cexp(+inf - 0i)) = +inf", __real__ result);
|
||||
check ("imag(cexp(+inf - 0i)) = 0", __imag__ result, 0);
|
||||
|
||||
result = FUNC(cexp) (minus_infty + 1.0i * plus_zero);
|
||||
check ("real(cexp(-inf + 0i)) = 0", __real__ result, 0);
|
||||
check ("imag(cexp(-inf + 0i)) = 0", __imag__ result, 0);
|
||||
result = FUNC(cexp) (minus_infty + 1.0i * minus_zero);
|
||||
check ("real(cexp(-inf - 0i)) = 0", __real__ result, 0);
|
||||
check ("imag(cexp(-inf - 0i)) = 0", __imag__ result, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
inverse_func_pair_test (const char *test_name,
|
||||
mathfunc f1, mathfunc inverse,
|
||||
@@ -1231,33 +1591,33 @@ inverse_func_pair_test (const char *test_name,
|
||||
static void
|
||||
inverse_functions (void)
|
||||
{
|
||||
inverse_func_pair_test ("(asin(sin(x)) == x",
|
||||
FUNC(sin), FUNC(asin), 1.0, CHOOSE (0, 0, 1e-7L));
|
||||
inverse_func_pair_test ("(sin(asin(x)) == x",
|
||||
inverse_func_pair_test ("asin(sin(x)) == x",
|
||||
FUNC(sin), FUNC(asin), 1.0, CHOOSE (2e-18L, 0, 1e-7L));
|
||||
inverse_func_pair_test ("sin(asin(x)) == x",
|
||||
FUNC(asin), FUNC(sin), 1.0, 0.0);
|
||||
|
||||
inverse_func_pair_test ("(acos(cos(x)) == x",
|
||||
FUNC(cos), FUNC(acos), 1.0, CHOOSE (0, 1e-15L, 0));
|
||||
inverse_func_pair_test ("(cos(acos(x)) == x",
|
||||
inverse_func_pair_test ("acos(cos(x)) == x",
|
||||
FUNC(cos), FUNC(acos), 1.0, CHOOSE (4e-18L, 1e-15L, 0));
|
||||
inverse_func_pair_test ("cos(acos(x)) == x",
|
||||
FUNC(acos), FUNC(cos), 1.0, 0.0);
|
||||
inverse_func_pair_test ("(atan(tan(x)) == x",
|
||||
FUNC(tan), FUNC(atan), 1.0, 0.0);
|
||||
inverse_func_pair_test ("(tan(atan(x)) == x",
|
||||
FUNC(atan), FUNC(tan), 1.0, CHOOSE (0, 1e-15L, 0));
|
||||
inverse_func_pair_test ("atan(tan(x)) == x",
|
||||
FUNC(tan), FUNC(atan), 1.0, CHOOSE (2e-18L, 0, 0));
|
||||
inverse_func_pair_test ("tan(atan(x)) == x",
|
||||
FUNC(atan), FUNC(tan), 1.0, CHOOSE (2e-18L, 1e-15L, 0));
|
||||
|
||||
inverse_func_pair_test ("(asinh(sinh(x)) == x",
|
||||
FUNC(sinh), FUNC(asinh), 1.0, CHOOSE (1e-18L, 0, 0));
|
||||
inverse_func_pair_test ("(sinh(asinh(x)) == x",
|
||||
FUNC(asinh), FUNC(sinh), 1.0, 0.0);
|
||||
inverse_func_pair_test ("asinh(sinh(x)) == x",
|
||||
FUNC(sinh), FUNC(asinh), 1.0, CHOOSE (1e-18L, 0, 1e-7));
|
||||
inverse_func_pair_test ("sinh(asinh(x)) == x",
|
||||
FUNC(asinh), FUNC(sinh), 1.0, CHOOSE (2e-18L, 0, 0));
|
||||
|
||||
inverse_func_pair_test ("(acosh(cosh(x)) == x",
|
||||
inverse_func_pair_test ("acosh(cosh(x)) == x",
|
||||
FUNC(cosh), FUNC(acosh), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
|
||||
inverse_func_pair_test ("(cosh(acosh(x)) == x",
|
||||
inverse_func_pair_test ("cosh(acosh(x)) == x",
|
||||
FUNC(acosh), FUNC(cosh), 1.0, 0.0);
|
||||
|
||||
inverse_func_pair_test ("(atanh(tanh(x)) == x",
|
||||
FUNC(tanh), FUNC(atanh), 1.0, CHOOSE (0, 1e-15L, 0));
|
||||
inverse_func_pair_test ("(tanh(atanh(x)) == x",
|
||||
inverse_func_pair_test ("atanh(tanh(x)) == x",
|
||||
FUNC(tanh), FUNC(atanh), 1.0, CHOOSE (1e-18L, 1e-15L, 0));
|
||||
inverse_func_pair_test ("tanh(atanh(x)) == x",
|
||||
FUNC(atanh), FUNC(tanh), 1.0, 0.0);
|
||||
|
||||
}
|
||||
@@ -1327,17 +1687,17 @@ identities3_test (MATHTYPE x, MATHTYPE epsilon)
|
||||
static void
|
||||
identities (void)
|
||||
{
|
||||
identities1_test (0.2L, CHOOSE (1e-19L, 0, 0));
|
||||
identities1_test (0.9L, 0);
|
||||
identities1_test (0.2L, CHOOSE (1e-18L, 0, 2e-7));
|
||||
identities1_test (0.9L, CHOOSE (1e-18L, 0, 0));
|
||||
identities1_test (0, 0);
|
||||
identities1_test (-1, CHOOSE (0, 0, 1e-7));
|
||||
identities1_test (-1, CHOOSE (1e-18L, 0, 1e-7));
|
||||
|
||||
identities2_test (0.2L, CHOOSE (0, 1e-16, 0));
|
||||
identities2_test (0.9L, CHOOSE (0, 1e-15, 0));
|
||||
identities2_test (0, 0);
|
||||
identities2_test (-1, CHOOSE (1e-18L, 1e-15, 0));
|
||||
|
||||
identities3_test (0.2L, CHOOSE (0, 0, 1e-7));
|
||||
identities3_test (0.2L, CHOOSE (1e-18L, 0, 1e-7));
|
||||
identities3_test (0.9L, CHOOSE (1e-18L, 1e-15, 1e-6));
|
||||
identities3_test (0, CHOOSE (0, 0, 1e-6));
|
||||
identities3_test (-1, CHOOSE (1e-18L, 0, 1e-6));
|
||||
@@ -1363,15 +1723,15 @@ basic_tests (void)
|
||||
|
||||
this_does_nothing ();
|
||||
|
||||
check_isinfp ("isinf (1/0) == +1", Inf_var);
|
||||
check_isinfn ("isinf (-1/0) == -1", -Inf_var);
|
||||
check_isinfp ("isinf (inf) == +1", Inf_var);
|
||||
check_isinfn ("isinf (-inf) == -1", -Inf_var);
|
||||
check_bool ("!isinf (1)", !(FUNC(isinf) (one_var)));
|
||||
check_bool ("!isinf (0/0)", !(FUNC(isinf) (NaN_var)));
|
||||
check_bool ("!isinf (NaN)", !(FUNC(isinf) (NaN_var)));
|
||||
|
||||
check_isnan ("isnan (0/0)", NaN_var);
|
||||
check_isnan ("isnan (-(0/0))", -NaN_var);
|
||||
check_isnan ("isnan (NaN)", NaN_var);
|
||||
check_isnan ("isnan (-NaN)", -NaN_var);
|
||||
check_bool ("!isnan (1)", !(FUNC(isnan) (one_var)));
|
||||
check_bool ("!isnan (0/0)", !(FUNC(isnan) (Inf_var)));
|
||||
check_bool ("!isnan (inf)", !(FUNC(isnan) (Inf_var)));
|
||||
|
||||
check_bool ("inf == inf", Inf_var == Inf_var);
|
||||
check_bool ("-inf == -inf", -Inf_var == -Inf_var);
|
||||
@@ -1388,6 +1748,15 @@ basic_tests (void)
|
||||
check_bool ("!isinf (-NAN)", !(isinf (-NAN)));
|
||||
check_bool ("NAN != NAN", NAN != NAN);
|
||||
|
||||
/*
|
||||
And again with the value returned by the `nan' function.
|
||||
*/
|
||||
check_bool ("isnan (NAN)", isnan (FUNC(nan) ("")));
|
||||
check_bool ("isnan (-NAN)", isnan (-FUNC(nan) ("")));
|
||||
check_bool ("!isinf (NAN)", !(isinf (FUNC(nan) (""))));
|
||||
check_bool ("!isinf (-NAN)", !(isinf (-FUNC(nan) (""))));
|
||||
check_bool ("NAN != NAN", FUNC(nan) ("") != FUNC(nan) (""));
|
||||
|
||||
/* test if EPSILON is ok */
|
||||
x1 = MATHCONST (1.0);
|
||||
x2 = x1 + CHOOSE (LDBL_EPSILON, DBL_EPSILON, FLT_EPSILON);
|
||||
@@ -1409,10 +1778,11 @@ basic_tests (void)
|
||||
static void
|
||||
initialize (void)
|
||||
{
|
||||
fpstack_test ("*init*");
|
||||
plus_zero = 0.0;
|
||||
nan_value = plus_zero / plus_zero; /* Suppress GCC warning */
|
||||
|
||||
minus_zero = copysign (0.0, -1.0);
|
||||
minus_zero = FUNC (copysign) (0.0, -1.0);
|
||||
plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
|
||||
minus_infty = -CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF);
|
||||
|
||||
@@ -1439,7 +1809,7 @@ parse_options (int argc, char *argv[])
|
||||
|
||||
while (1)
|
||||
{
|
||||
c = getopt_long (argc, argv, "vs",
|
||||
c = getopt_long (argc, argv, "v::s",
|
||||
long_options, &option_index);
|
||||
|
||||
/* Detect the end of the options. */
|
||||
@@ -1489,6 +1859,7 @@ main (int argc, char *argv[])
|
||||
#endif
|
||||
expm1_test ();
|
||||
frexp_test ();
|
||||
ilogb_test ();
|
||||
ldexp_test ();
|
||||
log_test ();
|
||||
log10_test ();
|
||||
@@ -1497,6 +1868,9 @@ main (int argc, char *argv[])
|
||||
log2_test ();
|
||||
#endif
|
||||
logb_test ();
|
||||
modf_test ();
|
||||
scalb_test ();
|
||||
scalbn_test ();
|
||||
sin_test ();
|
||||
sinh_test ();
|
||||
tan_test ();
|
||||
@@ -1506,6 +1880,18 @@ main (int argc, char *argv[])
|
||||
fpclassify_test ();
|
||||
hypot_test ();
|
||||
pow_test ();
|
||||
fdim_test ();
|
||||
fmin_test ();
|
||||
fmax_test ();
|
||||
nextafter_test ();
|
||||
copysign_test ();
|
||||
sqrt_test ();
|
||||
trunc_test ();
|
||||
#if 0
|
||||
/* XXX I'm not sure what is the correct result. */
|
||||
remquo_test ();
|
||||
#endif
|
||||
cexp_test ();
|
||||
|
||||
identities ();
|
||||
inverse_functions ();
|
||||
|
||||
@@ -48,6 +48,11 @@ __BEGIN_DECLS
|
||||
#define __MATHDECL(type, function,suffix, args) \
|
||||
__MATHDECL_1(type, function,suffix, args); \
|
||||
__MATHDECL_1(type, __CONCAT(__,function),suffix, args)
|
||||
#define __MATHCALLX(function,suffix, args, attrib) \
|
||||
__MATHDECLX (_Mdouble_,function,suffix, args, attrib)
|
||||
#define __MATHDECLX(type, function,suffix, args, attrib) \
|
||||
__MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
|
||||
__MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)
|
||||
#define __MATHDECL_1(type, function,suffix, args) \
|
||||
extern type __MATH_PRECNAME(function,suffix) args
|
||||
|
||||
|
||||
+13
-11
@@ -147,7 +147,7 @@ __MATHCALL (cbrt,, (_Mdouble_ __x));
|
||||
__MATHCALL (ceil,, (_Mdouble_ __x));
|
||||
|
||||
/* Absolute value of X. */
|
||||
__MATHCALL (fabs,, (_Mdouble_ __x));
|
||||
__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
|
||||
|
||||
/* Largest integer not greater than X. */
|
||||
__MATHCALL (floor,, (_Mdouble_ __x));
|
||||
@@ -159,10 +159,10 @@ __MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
|
||||
#ifdef __USE_MISC
|
||||
/* Return 0 if VALUE is finite or NaN, +1 if it
|
||||
is +Infinity, -1 if it is -Infinity. */
|
||||
__MATHDECL (int,isinf,, (_Mdouble_ __value));
|
||||
__MATHDECLX (int,isinf,, (_Mdouble_ __value), (__const__));
|
||||
|
||||
/* Return nonzero if VALUE is finite and not NaN. */
|
||||
__MATHDECL (int,finite,, (_Mdouble_ __value));
|
||||
__MATHDECLX (int,finite,, (_Mdouble_ __value), (__const__));
|
||||
|
||||
/* Deal with an infinite or NaN result.
|
||||
If ERROR is ERANGE, result is +Inf;
|
||||
@@ -170,7 +170,7 @@ __MATHDECL (int,finite,, (_Mdouble_ __value));
|
||||
otherwise result is NaN.
|
||||
This will set `errno' to either ERANGE or EDOM,
|
||||
and may return an infinity or NaN, or may do something else. */
|
||||
__MATHCALL (infnan,, (int __error));
|
||||
__MATHCALLX (infnan,, (int __error), (__const__));
|
||||
|
||||
/* Return X times (2 to the Nth power). */
|
||||
__MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
|
||||
@@ -185,18 +185,18 @@ __MATHCALL (significand,, (_Mdouble_ __x));
|
||||
|
||||
#if defined __USE_MISC || defined __USE_ISOC9X
|
||||
/* Return X with its signed changed to Y's. */
|
||||
__MATHCALL (copysign,, (_Mdouble_ __x, _Mdouble_ __y));
|
||||
__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
|
||||
#endif
|
||||
|
||||
#ifdef __USE_ISOC9X
|
||||
/* Return representation of NaN for double type. */
|
||||
__MATHCALL (nan,, (__const char *__tagb));
|
||||
__MATHCALLX (nan,, (__const char *__tagb), (__const__));
|
||||
#endif
|
||||
|
||||
|
||||
#if defined __USE_MISC || defined __USE_XOPEN
|
||||
/* Return nonzero if VALUE is not a number. */
|
||||
__MATHDECL (int,isnan,, (_Mdouble_ __value));
|
||||
__MATHDECLX (int,isnan,, (_Mdouble_ __value), (__const__));
|
||||
|
||||
/* Return the binary exponent of X, which must be nonzero. */
|
||||
__MATHDECL (int,ilogb,, (_Mdouble_ __x));
|
||||
@@ -235,7 +235,7 @@ __MATHCALL (lgamma,_r, (_Mdouble_, int *));
|
||||
__MATHCALL (rint,, (_Mdouble_ __x));
|
||||
|
||||
/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
|
||||
__MATHCALL (nextafter,, (_Mdouble_ __x, _Mdouble_ __y));
|
||||
__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
|
||||
|
||||
/* Return the remainder of integer divison X / Y with infinite precision. */
|
||||
__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
|
||||
@@ -257,7 +257,7 @@ __MATHCALL (round,, (_Mdouble_ __x));
|
||||
|
||||
/* Round X to the integral value in floating-point format nearest but
|
||||
not larger in magnitude. */
|
||||
__MATHCALL (trunc,, (_Mdouble_ __x));
|
||||
__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
|
||||
|
||||
/* Compute remainder of X and Y and put in *QUO a value with sign of x/y
|
||||
and magnitude congruent `mod 2^n' to the magnitude of the integral
|
||||
@@ -276,8 +276,10 @@ __MATHCALL (fmin,, (_Mdouble_ __x, _Mdouble_ __y));
|
||||
|
||||
|
||||
/* Classify given number. */
|
||||
__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value));
|
||||
__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value))
|
||||
__attribute__ ((__const__));
|
||||
|
||||
/* Test for negative number. */
|
||||
__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value));
|
||||
__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))
|
||||
__attribute__ ((__const__));
|
||||
#endif /* Use ISO C 9X. */
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Andreas Jaeger <aj@arthur.pfalz.de>, 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. */
|
||||
|
||||
#define FUNC(function) function
|
||||
#define MATHTYPE double
|
||||
#define TEST_MSG "testing double (without inline functions)\n"
|
||||
#define MATHCONST(x) x
|
||||
#define CHOOSE(Clongdouble,Cdouble,Cfloat) Cdouble
|
||||
#define PRINTF_EXPR "e"
|
||||
|
||||
#ifndef __NO_MATH_INLINES
|
||||
# define __NO_MATH_INLINES
|
||||
#endif
|
||||
|
||||
#include "libm-test.c"
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Andreas Jaeger <aj@arthur.pfalz.de>, 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. */
|
||||
|
||||
#define FUNC(function) function ## f
|
||||
#define MATHTYPE float
|
||||
#define TEST_MSG "testing float (without inline functions)\n"
|
||||
#define MATHCONST(x) x
|
||||
#define CHOOSE(Clongdouble,Cdouble,Cfloat) Cfloat
|
||||
#define PRINTF_EXPR "e"
|
||||
|
||||
#ifndef __NO_MATH_INLINES
|
||||
# define __NO_MATH_INLINES
|
||||
#endif
|
||||
|
||||
#include "libm-test.c"
|
||||
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Andreas Jaeger <aj@arthur.pfalz.de>, 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. */
|
||||
|
||||
#define FUNC(function) function##l
|
||||
#define MATHTYPE long double
|
||||
#define TEST_MSG "testing long double (without inline functions)\n"
|
||||
#define MATHCONST(x) x##L
|
||||
#define CHOOSE(Clongdouble,Cdouble,Cfloat) Clongdouble
|
||||
#define PRINTF_EXPR "Le"
|
||||
|
||||
#ifndef __NO_MATH_INLINES
|
||||
# define __NO_MATH_INLINES
|
||||
#endif
|
||||
|
||||
#include "libm-test.c"
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1992, 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
|
||||
@@ -34,6 +34,8 @@ __BEGIN_DECLS
|
||||
The buffers are filled in the order specified.
|
||||
Operates just like `read' (see <unistd.h>) except that data are
|
||||
put in VECTOR instead of a contiguous buffer. */
|
||||
extern ssize_t __readv __P ((int __fd, __const struct iovec *__vector,
|
||||
int __count));
|
||||
extern ssize_t readv __P ((int __fd, __const struct iovec *__vector,
|
||||
int __count));
|
||||
|
||||
@@ -42,6 +44,8 @@ extern ssize_t readv __P ((int __fd, __const struct iovec *__vector,
|
||||
The data is written in the order specified.
|
||||
Operates just like `write' (see <unistd.h>) except that the data
|
||||
are taken from VECTOR instead of a contiguous buffer. */
|
||||
extern ssize_t __writev __P ((int __fd, __const struct iovec *__vector,
|
||||
int __count));
|
||||
extern ssize_t writev __P ((int __fd, __const struct iovec *__vector,
|
||||
int __count));
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
NIS(YP) NSS modules 0.9 by Thorsten Kukuk
|
||||
NIS(YP)/NIS+ NSS modules 0.10 by Thorsten Kukuk
|
||||
|
||||
+36
-4
@@ -22,15 +22,15 @@
|
||||
subdir := nis
|
||||
|
||||
headers := $(wildcard rpcsvc/*.[hx])
|
||||
distribute := nss-nis.h
|
||||
distribute := nss-nis.h nss-nisplus.h
|
||||
|
||||
# These are the databases available for the nis (and perhaps later nisplus)
|
||||
# service. This must be a superset of the services in nss.
|
||||
databases = proto service hosts network grp pwd rpc ethers \
|
||||
spwd netgrp alias
|
||||
|
||||
# Specify rules for the nss_* modules. Later we may have nisplus as well.
|
||||
services := nis compat
|
||||
# Specify rules for the nss_* modules.
|
||||
services := nis compat nisplus
|
||||
|
||||
extra-libs = libnsl $(services:%=libnss_%)
|
||||
# These libraries will be built in the `others' pass rather than
|
||||
@@ -41,7 +41,10 @@ extra-libs-others = $(extra-libs)
|
||||
subdir-dirs = $(services:%=nss_%)
|
||||
vpath %.c $(subdir-dirs)
|
||||
|
||||
libnsl-routines = yp_xdr ypclnt ypupdate_xdr
|
||||
libnsl-routines = yp_xdr ypclnt ypupdate_xdr \
|
||||
nis_subr nis_local_names nis_free nis_file \
|
||||
nis_print nis_error nis_call nis_names nis_clone\
|
||||
nis_table nis_xdr nis_intern nis_server
|
||||
|
||||
libnss_compat-routines := $(addprefix compat-,grp pwd spwd)
|
||||
libnss_compat-inhibit-o = $(filter-out .so,$(object-suffixes))
|
||||
@@ -49,6 +52,8 @@ libnss_compat-inhibit-o = $(filter-out .so,$(object-suffixes))
|
||||
libnss_nis-routines := $(addprefix nis-,$(databases))
|
||||
libnss_nis-inhibit-o = $(filter-out .so,$(object-suffixes))
|
||||
|
||||
libnss_nisplus-routines := $(addprefix nisplus-,$(databases))
|
||||
libnss_nisplus-inhibit-o = $(filter-out .so,$(object-suffixes))
|
||||
|
||||
# Sun's header files are not too clean.
|
||||
CFLAGS-compat-pwd.c = -Wno-strict-prototypes
|
||||
@@ -69,6 +74,32 @@ CFLAGS-nis-spwd.c = -Wno-strict-prototypes
|
||||
CFLAGS-ypclnt.c = -Wno-strict-prototypes -Wno-write-strings -Irpcsvc
|
||||
CFLAGS-yp_xdr.c = -Wno-strict-prototypes -Irpcsvc
|
||||
CFLAGS-ypupdate_xdr.c = -Wno-strict-prototypes -Irpcsvc
|
||||
# For the NIS+ Code
|
||||
CFLAGS-nis_call.c = -DNO_DES_RPC -Wno-strict-prototypes
|
||||
CFLAGS-nis_subr.c = -Wno-strict-prototypes
|
||||
CFLAGS-nis_local_names.c = -Wno-strict-prototypes
|
||||
CFLAGS-nis_free.c = -Wno-strict-prototypes
|
||||
CFLAGS-nis_file.c = -Wno-strict-prototypes
|
||||
CFLAGS-nis_print.c = -Wno-strict-prototypes
|
||||
CFLAGS-nis_error.c = -Wno-strict-prototypes
|
||||
CFLAGS-nis_names.c = -Wno-strict-prototypes
|
||||
CFLAGS-nis_clone.c = -Wno-strict-prototypes
|
||||
CFLAGS-nis_table.c = -Wno-strict-prototypes
|
||||
CFLAGS-nis_server.c = -Wno-strict-prototypes
|
||||
CFLAGS-nis_xdr.c = -Wno-strict-prototypes
|
||||
CFLAGS-nis_intern.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-alias.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-ethers.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-grp.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-hosts.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-netgrp.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-network.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-proto.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-publickey.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-pwd.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-rpc.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-service.c = -Wno-strict-prototypes
|
||||
CFLAGS-nisplus-spwd.c = -Wno-strict-prototypes
|
||||
|
||||
include ../Rules
|
||||
|
||||
@@ -77,6 +108,7 @@ $(objpfx)libnss_compat.so: $(objpfx)libnsl.so$(libnsl.so-version) \
|
||||
$(common-objpfx)nss/libnss_files.so
|
||||
$(objpfx)libnss_nis.so: $(objpfx)libnsl.so$(libnsl.so-version) \
|
||||
$(common-objpfx)nss/libnss_files.so
|
||||
$(objpfx)libnss_nisplus.so: $(objpfx)libnsl.so$(libnsl.so-version)
|
||||
|
||||
# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
|
||||
# This ensures they will load libc.so for needed symbols if loaded by
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
* nss_nisplus: When using parser form nss_files, rewrite parser
|
||||
|
||||
* compat could use data from nisplus, too. Implement this
|
||||
|
||||
* nis_server: implement nis_getservlist, nis_stats, nis_servstate
|
||||
|
||||
* nis_groups: implement it
|
||||
|
||||
* nis_ping: implement it
|
||||
|
||||
* __start_clock(), __stop_clock(): Test the interface and
|
||||
implement it
|
||||
|
||||
* What does nis_list give back, if rpc.nisd is not running or
|
||||
if /var/nis/NIS_START_FILE does not exist ?
|
||||
|
||||
* nis_table.c: nis_list():
|
||||
Missing flags: FOLLOW_PATH, ALL_RESULTS
|
||||
callback: Don't simulate it, use server callback thread
|
||||
|
||||
* Possible flags:
|
||||
- FOLLOW_LINKS (nis_list, nis_lookup)
|
||||
- FOLLOW_PATH (nis_list, not supported)
|
||||
- HARD_LOOKUP (__do_niscall, not supported)
|
||||
- ALL_RESULTS (nis_list, not supported, needs server callback)
|
||||
- NO_CACHE (__do_niscall, cache not supported yet)
|
||||
- MASTER_ONLY (__do_niscall, not supported)
|
||||
- EXPAND_NAME (nis_lookup, nis_list)
|
||||
- RETURN_RESULT (nis_table.c)
|
||||
- ADD_OVERWRITE (nis_table.c)
|
||||
- REM_MULTIPLE (nis_table.c)
|
||||
- MOD_SAMEOBJ (nis_table.c)
|
||||
- ADD_RESERVED (nis_table.c)
|
||||
- REM_RESERVED (nis_table.c)
|
||||
- MOD_EXCLUSIVE (nis_table.c)
|
||||
- USE_DGRAM (__do_niscall)
|
||||
- NO_AUTHINFO (__do_niscall)
|
||||
|
||||
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/auth.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "nis_intern.h"
|
||||
|
||||
static struct timeval TIMEOUT = {25, 0};
|
||||
static int const MAXTRIES = 3;
|
||||
|
||||
static unsigned long
|
||||
inetstr2int (const char *str)
|
||||
{
|
||||
char buffer[strlen (str) + 3];
|
||||
size_t buflen;
|
||||
size_t i, j;
|
||||
|
||||
buflen = stpcpy (buffer, str) - buffer;
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i < buflen; ++i)
|
||||
if (buffer[i] == '.')
|
||||
{
|
||||
++j;
|
||||
if (j == 4)
|
||||
{
|
||||
buffer[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return inet_addr (buffer);
|
||||
}
|
||||
|
||||
static CLIENT *
|
||||
__nis_dobind (const nis_server *server, u_long flags)
|
||||
{
|
||||
struct sockaddr_in clnt_saddr;
|
||||
int clnt_sock;
|
||||
size_t i;
|
||||
CLIENT *client = NULL;
|
||||
/* XXX What is this variable for? */
|
||||
void *out = NULL;
|
||||
|
||||
for (i = 0; i < server->ep.ep_len; i++)
|
||||
{
|
||||
memset (&clnt_saddr, '\0', sizeof clnt_saddr);
|
||||
clnt_saddr.sin_family = AF_INET;
|
||||
if (strcmp (server->ep.ep_val[i].family,"loopback") == 0)
|
||||
{
|
||||
if (server->ep.ep_val[i].uaddr[i] == '-')
|
||||
clnt_saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
||||
else
|
||||
if (strcmp (server->ep.ep_val[i].proto,"udp") == 0)
|
||||
{
|
||||
if ((flags & USE_DGRAM) == USE_DGRAM)
|
||||
clnt_saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if (strcmp (server->ep.ep_val[i].proto,"tcp") == 0)
|
||||
{
|
||||
if ((flags & USE_DGRAM) == USE_DGRAM)
|
||||
continue;
|
||||
else
|
||||
clnt_saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (strcmp (server->ep.ep_val[i].family,"inet") == 0)
|
||||
{
|
||||
if (server->ep.ep_val[i].uaddr[i] == '-')
|
||||
clnt_saddr.sin_addr.s_addr =
|
||||
inetstr2int (server->ep.ep_val[i].uaddr);
|
||||
else
|
||||
if (strcmp (server->ep.ep_val[i].proto,"udp") == 0)
|
||||
{
|
||||
if ((flags & USE_DGRAM) == USE_DGRAM)
|
||||
clnt_saddr.sin_addr.s_addr =
|
||||
inetstr2int (server->ep.ep_val[i].uaddr);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if (strcmp (server->ep.ep_val[i].proto,"tcp") == 0)
|
||||
{
|
||||
if ((flags & USE_DGRAM) == USE_DGRAM)
|
||||
continue;
|
||||
else
|
||||
clnt_saddr.sin_addr.s_addr =
|
||||
inetstr2int (server->ep.ep_val[i].uaddr);
|
||||
}
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
||||
clnt_sock = RPC_ANYSOCK;
|
||||
if ((flags & USE_DGRAM) == USE_DGRAM)
|
||||
client = clntudp_create (&clnt_saddr, NIS_PROG, NIS_VERSION,
|
||||
TIMEOUT, &clnt_sock);
|
||||
else
|
||||
client = clnttcp_create (&clnt_saddr, NIS_PROG, NIS_VERSION,
|
||||
&clnt_sock, 0, 0);
|
||||
|
||||
if (client == NULL)
|
||||
continue;
|
||||
#if 1
|
||||
if (clnt_call (client, 0, (xdrproc_t) xdr_void, NULL,
|
||||
(xdrproc_t) xdr_void, out, TIMEOUT) != RPC_SUCCESS)
|
||||
{
|
||||
clnt_destroy (client);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if ((flags & NO_AUTHINFO) != NO_AUTHINFO)
|
||||
{
|
||||
#if !defined(NO_DES_RPC)
|
||||
if (server->key_type == NIS_PK_DH)
|
||||
{
|
||||
char netname[MAXNETNAMELEN+1];
|
||||
char *p;
|
||||
|
||||
strcpy (netname, "unix.");
|
||||
strncat (netname, server->name,MAXNETNAMELEN-5);
|
||||
netname[MAXNETNAMELEN-5] = '\0';
|
||||
p = strchr (netname, '.');
|
||||
*p = '@';
|
||||
client->cl_auth =
|
||||
authdes_pk_create (netname, &server->pkey, 300, NULL, NULL);
|
||||
if (!client->cl_auth)
|
||||
client->cl_auth = authunix_create_default ();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
client->cl_auth = authunix_create_default ();
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nis_error
|
||||
__do_niscall (const nis_server *serv, int serv_len, u_long prog,
|
||||
xdrproc_t xargs, caddr_t req, xdrproc_t xres, caddr_t resp,
|
||||
u_long flags)
|
||||
{
|
||||
CLIENT *clnt;
|
||||
directory_obj *dir = NULL;
|
||||
const nis_server *server;
|
||||
int try, result, server_len;
|
||||
|
||||
if (serv == NULL || serv_len == 0)
|
||||
{
|
||||
dir = readColdStartFile ();
|
||||
if (dir == NULL)
|
||||
{
|
||||
fputs (_("Error: could not find a NIS_COLD_START file\n"), stderr);
|
||||
return NIS_UNAVAIL;
|
||||
}
|
||||
server = dir->do_servers.do_servers_val;
|
||||
server_len = dir->do_servers.do_servers_len;
|
||||
}
|
||||
else
|
||||
{
|
||||
server = serv;
|
||||
server_len = serv_len;
|
||||
}
|
||||
|
||||
try = 0;
|
||||
result = NIS_NAMEUNREACHABLE;
|
||||
|
||||
while (try < MAXTRIES && result != RPC_SUCCESS)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
++try;
|
||||
for (i = 0; i < server_len; i++)
|
||||
{
|
||||
if ((clnt = __nis_dobind (&server[i], flags)) == NULL)
|
||||
continue;
|
||||
|
||||
result = clnt_call (clnt, prog, xargs, req, xres, resp, TIMEOUT);
|
||||
|
||||
if (result != RPC_SUCCESS)
|
||||
{
|
||||
/* XXX Grrr. The cast is needed for now since Sun code does
|
||||
note know about `const'. */
|
||||
clnt_perror (clnt, (char *) "do_niscall: clnt_call");
|
||||
clnt_destroy (clnt);
|
||||
result = NIS_RPCERROR;
|
||||
}
|
||||
else
|
||||
clnt_destroy (clnt);
|
||||
}
|
||||
}
|
||||
|
||||
if (dir != NULL)
|
||||
nis_free_directory (dir);
|
||||
return result;
|
||||
}
|
||||
+551
@@ -0,0 +1,551 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <string.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
directory_obj *
|
||||
nis_clone_directory (const directory_obj *src, directory_obj *dest)
|
||||
{
|
||||
directory_obj *res;
|
||||
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
if (dest == NULL)
|
||||
{
|
||||
res = calloc (1, sizeof (directory_obj));
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res = dest;
|
||||
|
||||
if (src->do_name)
|
||||
res->do_name = strdup (src->do_name);
|
||||
else
|
||||
res->do_name = NULL;
|
||||
res->do_type = src->do_type;
|
||||
if (src->do_servers.do_servers_len > 0)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
res->do_servers.do_servers_len = src->do_servers.do_servers_len;
|
||||
if ((res->do_servers.do_servers_val =
|
||||
malloc (src->do_servers.do_servers_len * sizeof (nis_server)))
|
||||
== NULL)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < src->do_servers.do_servers_len; ++i)
|
||||
{
|
||||
if (src->do_servers.do_servers_val[i].name != NULL)
|
||||
res->do_servers.do_servers_val[i].name =
|
||||
strdup (src->do_servers.do_servers_val[i].name);
|
||||
else
|
||||
res->do_servers.do_servers_val[i].name = NULL;
|
||||
|
||||
res->do_servers.do_servers_val[i].ep.ep_len =
|
||||
src->do_servers.do_servers_val[i].ep.ep_len;
|
||||
if (res->do_servers.do_servers_val[i].ep.ep_len > 0)
|
||||
{
|
||||
size_t j;
|
||||
|
||||
res->do_servers.do_servers_val[i].ep.ep_val =
|
||||
malloc (src->do_servers.do_servers_val[i].ep.ep_len *
|
||||
sizeof (endpoint));
|
||||
for (j = 0; j < res->do_servers.do_servers_val[i].ep.ep_len; ++j)
|
||||
{
|
||||
if (src->do_servers.do_servers_val[i].ep.ep_val[j].uaddr)
|
||||
res->do_servers.do_servers_val[i].ep.ep_val[j].uaddr
|
||||
= strdup (src->do_servers.do_servers_val[i].ep.ep_val[j].uaddr);
|
||||
else
|
||||
res->do_servers.do_servers_val[i].ep.ep_val[j].uaddr = NULL;
|
||||
|
||||
if (src->do_servers.do_servers_val[i].ep.ep_val[j].family)
|
||||
res->do_servers.do_servers_val[i].ep.ep_val[j].family
|
||||
= strdup (src->do_servers.do_servers_val[i].ep.ep_val[j].family);
|
||||
else
|
||||
res->do_servers.do_servers_val[i].ep.ep_val[j].family = NULL;
|
||||
|
||||
if (src->do_servers.do_servers_val[i].ep.ep_val[j].proto)
|
||||
res->do_servers.do_servers_val[i].ep.ep_val[j].proto
|
||||
= strdup (src->do_servers.do_servers_val[i].ep.ep_val[j].proto);
|
||||
else
|
||||
res->do_servers.do_servers_val[i].ep.ep_val[j].proto = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res->do_servers.do_servers_val[i].ep.ep_val = NULL;
|
||||
}
|
||||
res->do_servers.do_servers_val[i].key_type =
|
||||
src->do_servers.do_servers_val[i].key_type;
|
||||
res->do_servers.do_servers_val[i].pkey.n_len =
|
||||
src->do_servers.do_servers_val[i].pkey.n_len;
|
||||
if (res->do_servers.do_servers_val[i].pkey.n_len > 0)
|
||||
{
|
||||
res->do_servers.do_servers_val[i].pkey.n_bytes =
|
||||
malloc (src->do_servers.do_servers_val[i].pkey.n_len);
|
||||
if (res->do_servers.do_servers_val[i].pkey.n_bytes == NULL)
|
||||
return NULL;
|
||||
memcpy (res->do_servers.do_servers_val[i].pkey.n_bytes,
|
||||
src->do_servers.do_servers_val[i].pkey.n_bytes,
|
||||
src->do_servers.do_servers_val[i].pkey.n_len);
|
||||
}
|
||||
else
|
||||
res->do_servers.do_servers_val[i].pkey.n_bytes = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res->do_servers.do_servers_len = 0;
|
||||
res->do_servers.do_servers_val = NULL;
|
||||
}
|
||||
res->do_ttl = src->do_ttl;
|
||||
res->do_armask.do_armask_len = src->do_armask.do_armask_len;
|
||||
if (res->do_armask.do_armask_len > 0)
|
||||
{
|
||||
if ((res->do_armask.do_armask_val =
|
||||
malloc (src->do_armask.do_armask_len * sizeof (oar_mask))) == NULL)
|
||||
return NULL;
|
||||
memcpy (res->do_armask.do_armask_val, src->do_armask.do_armask_val,
|
||||
src->do_armask.do_armask_len * sizeof (oar_mask));
|
||||
}
|
||||
else
|
||||
{
|
||||
res->do_armask.do_armask_val = NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
group_obj *
|
||||
nis_clone_group (const group_obj *src, group_obj *dest)
|
||||
{
|
||||
size_t i;
|
||||
group_obj *res = NULL;
|
||||
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
if (dest == NULL)
|
||||
{
|
||||
res = calloc (1, sizeof (group_obj));
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res = dest;
|
||||
|
||||
res->gr_flags = src->gr_flags;
|
||||
|
||||
res->gr_members.gr_members_len = src->gr_members.gr_members_len;
|
||||
if (res->gr_members.gr_members_len > 0)
|
||||
{
|
||||
if (res->gr_members.gr_members_val == NULL)
|
||||
{
|
||||
res->gr_members.gr_members_val =
|
||||
malloc (res->gr_members.gr_members_len * sizeof (nis_name));
|
||||
if (res->gr_members.gr_members_val == NULL)
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < res->gr_members.gr_members_len; ++i)
|
||||
if (src->gr_members.gr_members_val[i] != NULL)
|
||||
res->gr_members.gr_members_val[i] =
|
||||
strdup (src->gr_members.gr_members_val[i]);
|
||||
else
|
||||
res->gr_members.gr_members_val[i] = NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
table_obj *
|
||||
nis_clone_table (const table_obj *src, table_obj *dest)
|
||||
{
|
||||
size_t i;
|
||||
table_obj *res = NULL;
|
||||
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
if (dest == NULL)
|
||||
{
|
||||
res = calloc (1, sizeof (table_obj));
|
||||
if (res == NULL)
|
||||
return res;
|
||||
}
|
||||
else
|
||||
res = dest;
|
||||
|
||||
if (src->ta_type != NULL)
|
||||
{
|
||||
if ((res->ta_type = strdup (src->ta_type)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res->ta_type = NULL;
|
||||
|
||||
res->ta_maxcol = src->ta_maxcol;
|
||||
res->ta_sep = src->ta_sep;
|
||||
res->ta_cols.ta_cols_len = src->ta_cols.ta_cols_len;
|
||||
if (res->ta_cols.ta_cols_val == NULL)
|
||||
{
|
||||
res->ta_cols.ta_cols_val =
|
||||
malloc (src->ta_cols.ta_cols_len * sizeof (table_col));
|
||||
if (res->ta_cols.ta_cols_val == NULL)
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < res->ta_cols.ta_cols_len; i++)
|
||||
{
|
||||
if (src->ta_cols.ta_cols_val[i].tc_name == NULL)
|
||||
res->ta_cols.ta_cols_val[i].tc_name = NULL;
|
||||
else
|
||||
res->ta_cols.ta_cols_val[i].tc_name =
|
||||
strdup (src->ta_cols.ta_cols_val[i].tc_name);
|
||||
res->ta_cols.ta_cols_val[i].tc_flags =
|
||||
src->ta_cols.ta_cols_val[i].tc_flags;
|
||||
res->ta_cols.ta_cols_val[i].tc_rights =
|
||||
src->ta_cols.ta_cols_val[i].tc_rights;
|
||||
}
|
||||
|
||||
if (src->ta_path != NULL)
|
||||
{
|
||||
if ((res->ta_path = strdup (src->ta_path)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res->ta_path = NULL;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
entry_obj *
|
||||
nis_clone_entry (const entry_obj *src, entry_obj *dest)
|
||||
{
|
||||
size_t i;
|
||||
entry_obj *res = NULL;
|
||||
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
if (dest == NULL)
|
||||
{
|
||||
res = calloc (1, sizeof (entry_obj));
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res = dest;
|
||||
|
||||
if (src->en_type)
|
||||
res->en_type = strdup (src->en_type);
|
||||
else
|
||||
res->en_type = NULL;
|
||||
|
||||
res->en_cols.en_cols_len = src->en_cols.en_cols_len;
|
||||
if (res->en_cols.en_cols_val == NULL && src->en_cols.en_cols_len > 0)
|
||||
{
|
||||
res->en_cols.en_cols_val =
|
||||
malloc (src->en_cols.en_cols_len * sizeof (entry_col));
|
||||
if (res->en_cols.en_cols_val == NULL)
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < res->en_cols.en_cols_len; ++i)
|
||||
{
|
||||
res->en_cols.en_cols_val[i].ec_flags =
|
||||
src->en_cols.en_cols_val[i].ec_flags;
|
||||
res->en_cols.en_cols_val[i].ec_value.ec_value_len =
|
||||
src->en_cols.en_cols_val[i].ec_value.ec_value_len;
|
||||
if (res->en_cols.en_cols_val[i].ec_value.ec_value_val == NULL &&
|
||||
src->en_cols.en_cols_val[i].ec_value.ec_value_len > 0)
|
||||
res->en_cols.en_cols_val[i].ec_value.ec_value_val =
|
||||
malloc (src->en_cols.en_cols_val[i].ec_value.ec_value_len);
|
||||
memcpy (res->en_cols.en_cols_val[i].ec_value.ec_value_val,
|
||||
src->en_cols.en_cols_val[i].ec_value.ec_value_val,
|
||||
res->en_cols.en_cols_val[i].ec_value.ec_value_len);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_attr *
|
||||
nis_clone_nis_attr (const nis_attr *src, nis_attr *dest)
|
||||
{
|
||||
nis_attr *res = NULL;
|
||||
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
if (dest == NULL)
|
||||
{
|
||||
res = calloc (1, sizeof (nis_attr));
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res = dest;
|
||||
|
||||
if (src->zattr_ndx != NULL)
|
||||
{
|
||||
if ((res->zattr_ndx = strdup (src->zattr_ndx)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res->zattr_ndx = NULL;
|
||||
|
||||
res->zattr_val.zattr_val_len = src->zattr_val.zattr_val_len;
|
||||
if (res->zattr_val.zattr_val_val == NULL)
|
||||
{
|
||||
res->zattr_val.zattr_val_val =
|
||||
malloc (src->zattr_val.zattr_val_len);
|
||||
if (res->zattr_val.zattr_val_val == NULL)
|
||||
return NULL;
|
||||
}
|
||||
memcpy (res->zattr_val.zattr_val_val, src->zattr_val.zattr_val_val,
|
||||
src->zattr_val.zattr_val_len);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static nis_attr *
|
||||
__nis_clone_attrs (const nis_attr *src, nis_attr *dest, u_int len)
|
||||
{
|
||||
unsigned int i;
|
||||
nis_attr *res;
|
||||
|
||||
if (len == 0)
|
||||
return dest;
|
||||
|
||||
if (dest == NULL)
|
||||
{
|
||||
res = calloc (len, sizeof (nis_attr));
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res = dest;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
nis_clone_nis_attr(&src[i], &res[i]);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
link_obj *
|
||||
nis_clone_link (const link_obj *src, link_obj *dest)
|
||||
{
|
||||
link_obj *res = NULL;
|
||||
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
if (dest == NULL)
|
||||
{
|
||||
res = calloc (1, sizeof (link_obj));
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res = dest;
|
||||
|
||||
res->li_rtype = src->li_rtype;
|
||||
|
||||
res->li_attrs.li_attrs_len = src->li_attrs.li_attrs_len;
|
||||
res->li_attrs.li_attrs_val =
|
||||
__nis_clone_attrs (src->li_attrs.li_attrs_val,
|
||||
res->li_attrs.li_attrs_val,
|
||||
src->li_attrs.li_attrs_len);
|
||||
|
||||
if ((res->li_name = strdup (src->li_name)) == NULL)
|
||||
return NULL;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
objdata *
|
||||
nis_clone_objdata (const objdata *src, objdata *dest)
|
||||
{
|
||||
objdata *res = NULL;
|
||||
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
if (dest == NULL)
|
||||
{
|
||||
res = calloc (1, sizeof (objdata));
|
||||
if (res == NULL)
|
||||
return res;
|
||||
}
|
||||
else
|
||||
res = dest;
|
||||
|
||||
res->zo_type = src->zo_type;
|
||||
|
||||
switch (src->zo_type)
|
||||
{
|
||||
case BOGUS_OBJ:
|
||||
break;
|
||||
case NO_OBJ:
|
||||
break;
|
||||
case DIRECTORY_OBJ:
|
||||
if (nis_clone_directory (&src->objdata_u.di_data,
|
||||
&res->objdata_u.di_data) == NULL)
|
||||
return NULL;
|
||||
break;
|
||||
case GROUP_OBJ:
|
||||
if (nis_clone_group (&src->objdata_u.gr_data,
|
||||
&res->objdata_u.gr_data) == NULL)
|
||||
return NULL;
|
||||
break;
|
||||
case TABLE_OBJ:
|
||||
if (nis_clone_table (&src->objdata_u.ta_data,
|
||||
&res->objdata_u.ta_data) == NULL)
|
||||
return NULL;
|
||||
break;
|
||||
case ENTRY_OBJ:
|
||||
if (nis_clone_entry (&src->objdata_u.en_data,
|
||||
&res->objdata_u.en_data) == NULL)
|
||||
return NULL;
|
||||
break;
|
||||
case LINK_OBJ:
|
||||
if (nis_clone_link (&src->objdata_u.li_data,
|
||||
&res->objdata_u.li_data) == NULL)
|
||||
return NULL;
|
||||
break;
|
||||
case PRIVATE_OBJ:
|
||||
res->objdata_u.po_data.po_data_len =
|
||||
src->objdata_u.po_data.po_data_len;
|
||||
if (src->objdata_u.po_data.po_data_val)
|
||||
{
|
||||
res->objdata_u.po_data.po_data_val =
|
||||
malloc (res->objdata_u.po_data.po_data_len);
|
||||
if (res->objdata_u.po_data.po_data_val == NULL)
|
||||
return NULL;
|
||||
memcpy (res->objdata_u.po_data.po_data_val,
|
||||
src->objdata_u.po_data.po_data_val,
|
||||
src->objdata_u.po_data.po_data_len);
|
||||
if (res->objdata_u.po_data.po_data_val == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
res->objdata_u.po_data.po_data_val = NULL;
|
||||
res->objdata_u.po_data.po_data_len = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_object *
|
||||
nis_clone_object (const nis_object *src, nis_object *dest)
|
||||
{
|
||||
nis_object *res = NULL;
|
||||
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
if (dest == NULL)
|
||||
{
|
||||
res = calloc (1, sizeof (nis_object));
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res = dest;
|
||||
|
||||
res->zo_oid = src->zo_oid;
|
||||
|
||||
if ((res->zo_name = strdup (src->zo_name)) == NULL)
|
||||
return NULL;
|
||||
if ((res->zo_owner = strdup (src->zo_owner)) == NULL)
|
||||
return NULL;
|
||||
if ((res->zo_group = strdup (src->zo_group)) == NULL)
|
||||
return NULL;
|
||||
if ((res->zo_domain = strdup (src->zo_domain)) == NULL)
|
||||
return NULL;
|
||||
|
||||
res->zo_access = src->zo_access;
|
||||
res->zo_ttl = src->zo_ttl;
|
||||
|
||||
if (nis_clone_objdata (&src->zo_data, &res->zo_data) == NULL)
|
||||
return NULL;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static nis_object *
|
||||
__nis_clone_objects (const nis_object *src, nis_object *dest, u_int len)
|
||||
{
|
||||
unsigned int i;
|
||||
nis_object *res;
|
||||
|
||||
if (len == 0)
|
||||
return dest;
|
||||
|
||||
if (dest == NULL)
|
||||
{
|
||||
res = calloc (len, sizeof (nis_object));
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res = dest;
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
nis_clone_object(&src[i], &res[i]);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_result *
|
||||
nis_clone_result (const nis_result *src, nis_result *dest)
|
||||
{
|
||||
nis_result *res = NULL;
|
||||
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
if (dest == NULL)
|
||||
{
|
||||
res = calloc (1, sizeof (nis_result));
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
res = dest;
|
||||
|
||||
res->status = src->status;
|
||||
res->objects.objects_len = src->objects.objects_len;
|
||||
res->objects.objects_val =
|
||||
__nis_clone_objects (src->objects.objects_val,
|
||||
res->objects.objects_val,
|
||||
src->objects.objects_len);
|
||||
res->zticks = src->zticks;
|
||||
res->dticks = src->dticks;
|
||||
res->aticks = src->aticks;
|
||||
res->cticks = src->cticks;
|
||||
|
||||
return res;
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
|
||||
static const char *nis_errlist[] =
|
||||
{
|
||||
N_("Success"),
|
||||
N_("Probable success"),
|
||||
N_("Not found"),
|
||||
N_("Probably not found"),
|
||||
N_("Cache expired"),
|
||||
N_("NIS+ servers unreachable"),
|
||||
N_("Unknown object"),
|
||||
N_("Server busy, try again"),
|
||||
N_("Generic system error"),
|
||||
N_("First/Next chain broken"),
|
||||
N_("Permission denied"),
|
||||
N_("Not owner"),
|
||||
N_("Name not served by this server"),
|
||||
N_("Server out of memory"),
|
||||
N_("Object with same name exists"),
|
||||
N_("Not master server for this domain"),
|
||||
N_("Invalid Object for operation"),
|
||||
N_("Malformed Name, or illegal name"),
|
||||
N_("Unable to create callback"),
|
||||
N_("Results Sent to callback proc"),
|
||||
N_("Not Found, no such name"),
|
||||
N_("Name/entry isn't unique"),
|
||||
N_("Modification failed"),
|
||||
N_("Database for table does not exist"),
|
||||
N_("Entry/Table type mismatch"),
|
||||
N_("Link Points to illegal name"),
|
||||
N_("Partial Success"),
|
||||
N_("Too Many Attributes"),
|
||||
N_("Error in RPC subsystem"),
|
||||
N_("Missing or malformed attribute"),
|
||||
N_("Named object is not searchable"),
|
||||
N_("Error while talking to callback proc"),
|
||||
N_("Non NIS+ namespace encountered"),
|
||||
N_("Illegal object type for operation"),
|
||||
N_("Passed object is not the same object on server"),
|
||||
N_("Modify operation failed"),
|
||||
N_("Query illegal for named table"),
|
||||
N_("Attempt to remove a non-empty table"),
|
||||
N_("Error in accessing NIS+ cold start file. Is NIS+ installed?"),
|
||||
N_("Full resync required for directory"),
|
||||
N_("NIS+ operation failed"),
|
||||
N_("NIS+ service is unavailable or not installed"),
|
||||
N_("Yes, 42 is the meaning of life"),
|
||||
N_("Unable to authenticate NIS+ server"),
|
||||
N_("Unable to authenticate NIS+ client"),
|
||||
N_("No file space on server"),
|
||||
N_("Unable to create process on server"),
|
||||
N_("Master server busy, full dump rescheduled.")
|
||||
};
|
||||
|
||||
const char *
|
||||
nis_sperrno (const nis_error status)
|
||||
{
|
||||
if (status >= (sizeof (nis_errlist) / sizeof (nis_errlist[0])))
|
||||
return "???";
|
||||
else
|
||||
return gettext (nis_errlist[status]);
|
||||
}
|
||||
|
||||
void
|
||||
nis_perror (const nis_error status, const char *label)
|
||||
{
|
||||
fprintf (stderr, "%s: %s\n", label, nis_sperrno (status));
|
||||
}
|
||||
|
||||
void
|
||||
nis_lerror (const nis_error status, const char *label)
|
||||
{
|
||||
syslog (LOG_ERR, "%s: %s", label, nis_sperrno (status));
|
||||
}
|
||||
|
||||
char *
|
||||
nis_sperror_r (const nis_error status, const char *label,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
const char *cptr;
|
||||
|
||||
cptr = nis_sperrno (status);
|
||||
|
||||
if ((strlen (cptr) + strlen (label) + 3) > buflen)
|
||||
{
|
||||
errno = ERANGE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sprintf (buffer, "%s: %s", label, cptr);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char *
|
||||
nis_sperror (const nis_error status, const char *label)
|
||||
{
|
||||
static char buffer[NIS_MAXNAMELEN +1];
|
||||
|
||||
return nis_sperror_r (status, label, buffer, sizeof (buffer));
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
|
||||
static const char cold_start_file[] = "/var/nis/NIS_COLD_START";
|
||||
|
||||
directory_obj *
|
||||
readColdStartFile (void)
|
||||
{
|
||||
XDR xdrs;
|
||||
FILE *in;
|
||||
directory_obj obj;
|
||||
|
||||
in = fopen (cold_start_file, "rb");
|
||||
if (in == NULL)
|
||||
return NULL;
|
||||
memset (&obj, '\0', sizeof (obj));
|
||||
xdrstdio_create (&xdrs, in, XDR_DECODE);
|
||||
if (!xdr_directory_obj (&xdrs, &obj))
|
||||
return NULL;
|
||||
|
||||
return nis_clone_directory (&obj, NULL);
|
||||
}
|
||||
|
||||
bool_t
|
||||
writeColdStartFile (const directory_obj *obj)
|
||||
{
|
||||
XDR xdrs;
|
||||
FILE *out;
|
||||
|
||||
out = fopen (cold_start_file, "wb");
|
||||
if (out == NULL)
|
||||
return FALSE;
|
||||
|
||||
xdrstdio_create (&xdrs, out, XDR_ENCODE);
|
||||
if (!xdr_directory_obj (&xdrs, (directory_obj *) obj))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
nis_object *
|
||||
nis_read_obj (const char *name)
|
||||
{
|
||||
XDR xdrs;
|
||||
FILE *in;
|
||||
nis_object obj;
|
||||
|
||||
in = fopen (name, "rb");
|
||||
if (in == NULL)
|
||||
return NULL;
|
||||
|
||||
memset (&obj, '\0', sizeof (obj));
|
||||
xdrstdio_create (&xdrs, in, XDR_DECODE);
|
||||
if (!xdr_nis_object (&xdrs, &obj))
|
||||
return NULL;
|
||||
|
||||
return nis_clone_object (&obj, NULL);
|
||||
}
|
||||
|
||||
bool_t
|
||||
nis_write_obj (const char *name, const nis_object *obj)
|
||||
{
|
||||
XDR xdrs;
|
||||
FILE *out;
|
||||
|
||||
out = fopen (name, "wb");
|
||||
if (out == NULL)
|
||||
return FALSE;
|
||||
|
||||
xdrstdio_create (&xdrs, out, XDR_ENCODE);
|
||||
/* XXX The following cast is bad! Shouldn't the XDR functions take
|
||||
pointers to const objects? */
|
||||
if (!xdr_nis_object (&xdrs, (nis_object *) obj))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
+334
@@ -0,0 +1,334 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
void
|
||||
nis_free_attr (nis_attr *obj)
|
||||
{
|
||||
if (obj == NULL)
|
||||
return;
|
||||
|
||||
if (obj->zattr_ndx)
|
||||
{
|
||||
free (obj->zattr_ndx);
|
||||
obj->zattr_ndx = NULL;
|
||||
}
|
||||
|
||||
if (obj->zattr_val.zattr_val_val)
|
||||
{
|
||||
free (obj->zattr_val.zattr_val_val);
|
||||
obj->zattr_val.zattr_val_val = NULL;
|
||||
obj->zattr_val.zattr_val_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_free_request (ib_request *ibreq)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ibreq->ibr_srch.ibr_srch_len; ++i)
|
||||
{
|
||||
nis_free_attr (&(ibreq->ibr_srch.ibr_srch_val)[i]);
|
||||
ibreq->ibr_srch.ibr_srch_val = NULL;
|
||||
ibreq->ibr_srch.ibr_srch_len = 0;
|
||||
}
|
||||
|
||||
if (ibreq->ibr_name)
|
||||
{
|
||||
free (ibreq->ibr_name);
|
||||
ibreq->ibr_name = NULL;
|
||||
}
|
||||
|
||||
if (ibreq->ibr_cookie.n_bytes)
|
||||
{
|
||||
free (ibreq->ibr_cookie.n_bytes);
|
||||
ibreq->ibr_cookie.n_bytes = NULL;
|
||||
ibreq->ibr_cookie.n_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_free_endpoints (endpoint *ep, unsigned int len)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (ep == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
if (ep[i].uaddr)
|
||||
{
|
||||
free (ep[i].uaddr);
|
||||
ep[i].uaddr = NULL;
|
||||
}
|
||||
if (ep[i].family)
|
||||
{
|
||||
free (ep[i].family);
|
||||
ep[i].family = NULL;
|
||||
}
|
||||
if (ep[i].proto)
|
||||
{
|
||||
free (ep[i].proto);
|
||||
ep[i].proto = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_free_servers (nis_server *obj, unsigned int len)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (obj == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (obj[i].name)
|
||||
{
|
||||
free (obj[i].name);
|
||||
obj[i].name = NULL;
|
||||
}
|
||||
if (obj[i].ep.ep_len > 0)
|
||||
{
|
||||
nis_free_endpoints (obj[i].ep.ep_val, obj[i].ep.ep_len);
|
||||
free (obj[i].ep.ep_val);
|
||||
obj[i].ep.ep_val = NULL;
|
||||
obj[i].ep.ep_len = 0;
|
||||
}
|
||||
if (obj[i].pkey.n_bytes && obj[i].pkey.n_len > 0)
|
||||
{
|
||||
free (obj[i].pkey.n_bytes);
|
||||
obj[i].pkey.n_bytes = NULL;
|
||||
obj[i].pkey.n_len = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_free_directory (directory_obj *obj)
|
||||
{
|
||||
if (obj == NULL)
|
||||
return;
|
||||
if (obj->do_name)
|
||||
{
|
||||
free (obj->do_name);
|
||||
obj->do_name = NULL;
|
||||
}
|
||||
if (obj->do_servers.do_servers_len > 0)
|
||||
{
|
||||
nis_free_servers (obj->do_servers.do_servers_val,
|
||||
obj->do_servers.do_servers_len);
|
||||
free (obj->do_servers.do_servers_val);
|
||||
obj->do_servers.do_servers_val = NULL;
|
||||
obj->do_servers.do_servers_len = 0;
|
||||
}
|
||||
if (obj->do_armask.do_armask_len > 0)
|
||||
{
|
||||
free (obj->do_armask.do_armask_val);
|
||||
obj->do_armask.do_armask_val = NULL;
|
||||
obj->do_armask.do_armask_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_free_group (group_obj *obj)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (obj->gr_members.gr_members_len > 0)
|
||||
{
|
||||
for (i = 0; i < obj->gr_members.gr_members_len; ++i)
|
||||
if (obj->gr_members.gr_members_val[i])
|
||||
free (obj->gr_members.gr_members_val[i]);
|
||||
free (obj->gr_members.gr_members_val);
|
||||
obj->gr_members.gr_members_val = NULL;
|
||||
obj->gr_members.gr_members_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_free_table (table_obj *obj)
|
||||
{
|
||||
if (obj == NULL)
|
||||
return;
|
||||
|
||||
if (obj->ta_type)
|
||||
{
|
||||
free (obj->ta_type);
|
||||
obj->ta_type = NULL;
|
||||
}
|
||||
|
||||
if (obj->ta_cols.ta_cols_val)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < obj->ta_cols.ta_cols_len; ++i)
|
||||
if (obj->ta_cols.ta_cols_val[i].tc_name)
|
||||
free (obj->ta_cols.ta_cols_val[i].tc_name);
|
||||
free (obj->ta_cols.ta_cols_val);
|
||||
obj->ta_cols.ta_cols_val = NULL;
|
||||
obj->ta_cols.ta_cols_len = 0;
|
||||
}
|
||||
|
||||
if (obj->ta_path)
|
||||
{
|
||||
free (obj->ta_path);
|
||||
obj->ta_path = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_free_entry (entry_obj *obj)
|
||||
{
|
||||
if (obj == NULL)
|
||||
return;
|
||||
|
||||
if (obj->en_type)
|
||||
{
|
||||
free (obj->en_type);
|
||||
obj->en_type = 0;
|
||||
}
|
||||
|
||||
if (obj->en_cols.en_cols_val)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < obj->en_cols.en_cols_len; ++i)
|
||||
if (obj->en_cols.en_cols_val[i].ec_value.ec_value_val)
|
||||
free (obj->en_cols.en_cols_val[i].ec_value.ec_value_val);
|
||||
free (obj->en_cols.en_cols_val);
|
||||
obj->en_cols.en_cols_val = NULL;
|
||||
obj->en_cols.en_cols_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_free_link (link_obj *obj)
|
||||
{
|
||||
if (obj == NULL)
|
||||
return;
|
||||
|
||||
if (obj->li_attrs.li_attrs_val)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < obj->li_attrs.li_attrs_len; ++i)
|
||||
{
|
||||
if (obj->li_attrs.li_attrs_val[i].zattr_ndx)
|
||||
free (obj->li_attrs.li_attrs_val[i].zattr_ndx);
|
||||
if (obj->li_attrs.li_attrs_val[i].zattr_val.zattr_val_val)
|
||||
free (obj->li_attrs.li_attrs_val[i].zattr_val.zattr_val_val);
|
||||
}
|
||||
free (obj->li_attrs.li_attrs_val);
|
||||
obj->li_attrs.li_attrs_val = NULL;
|
||||
obj->li_attrs.li_attrs_len = 0;
|
||||
}
|
||||
|
||||
if (obj->li_name)
|
||||
{
|
||||
free (obj->li_name);
|
||||
obj->li_name = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_free_object (nis_object *obj)
|
||||
{
|
||||
|
||||
if (obj == NULL)
|
||||
return;
|
||||
|
||||
if (obj->zo_name)
|
||||
{
|
||||
free (obj->zo_name);
|
||||
obj->zo_name = NULL;
|
||||
}
|
||||
if (obj->zo_owner)
|
||||
{
|
||||
free (obj->zo_owner);
|
||||
obj->zo_owner = NULL;
|
||||
}
|
||||
if (obj->zo_group)
|
||||
{
|
||||
free (obj->zo_group);
|
||||
obj->zo_group = NULL;
|
||||
}
|
||||
if (obj->zo_domain)
|
||||
{
|
||||
free (obj->zo_domain);
|
||||
obj->zo_domain = NULL;
|
||||
}
|
||||
switch (obj->zo_data.zo_type)
|
||||
{
|
||||
case BOGUS_OBJ:
|
||||
break;
|
||||
case NO_OBJ:
|
||||
break;
|
||||
case DIRECTORY_OBJ:
|
||||
nis_free_directory (&obj->zo_data.objdata_u.di_data);
|
||||
break;
|
||||
case GROUP_OBJ:
|
||||
nis_free_group (&obj->zo_data.objdata_u.gr_data);
|
||||
break;
|
||||
case TABLE_OBJ:
|
||||
nis_free_table (&obj->zo_data.objdata_u.ta_data);
|
||||
break;
|
||||
case ENTRY_OBJ:
|
||||
nis_free_entry (&obj->zo_data.objdata_u.en_data);
|
||||
break;
|
||||
case LINK_OBJ:
|
||||
nis_free_link (&obj->zo_data.objdata_u.li_data);
|
||||
break;
|
||||
case PRIVATE_OBJ:
|
||||
if (obj->zo_data.objdata_u.po_data.po_data_val)
|
||||
{
|
||||
free (obj->zo_data.objdata_u.po_data.po_data_val);
|
||||
obj->zo_data.objdata_u.po_data.po_data_val = NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
obj->zo_data.zo_type = NO_OBJ;
|
||||
}
|
||||
|
||||
void
|
||||
nis_freeresult (nis_result *res)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (res == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i < res->objects.objects_len; i++)
|
||||
nis_free_object (&(res->objects.objects_val)[i]);
|
||||
|
||||
if (res->objects.objects_val != NULL)
|
||||
free (res->objects.objects_val);
|
||||
|
||||
if (res->cookie.n_bytes != NULL && res->cookie.n_len > 0)
|
||||
free (res->cookie.n_bytes);
|
||||
|
||||
free (res);
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <string.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
#include "nis_intern.h"
|
||||
|
||||
/* Nearly the same as nis_getnames, but nis_getnames stopped
|
||||
when 2 points left */
|
||||
nis_name *
|
||||
__nis_expandname (const nis_name name)
|
||||
{
|
||||
nis_name *getnames = NULL;
|
||||
char local_domain[NIS_MAXNAMELEN + 1];
|
||||
char *path, *cp;
|
||||
int count, pos;
|
||||
|
||||
strncpy (local_domain, nis_local_directory (), NIS_MAXNAMELEN);
|
||||
local_domain[NIS_MAXNAMELEN] = '\0';
|
||||
|
||||
count = 1;
|
||||
if ((getnames = malloc ((count + 1) * sizeof (char *))) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Do we have a fully qualified NIS+ name ? If yes, give it back */
|
||||
if (name[strlen (name) - 1] == '.')
|
||||
{
|
||||
if ((getnames[0] = strdup (name)) == NULL)
|
||||
{
|
||||
free (getnames);
|
||||
return NULL;
|
||||
}
|
||||
getnames[1] = NULL;
|
||||
|
||||
return getnames;
|
||||
}
|
||||
|
||||
/* Get the search path, where we have to search "name" */
|
||||
path = getenv ("NIS_PATH");
|
||||
if (path == NULL)
|
||||
path = strdupa ("$");
|
||||
else
|
||||
path = strdupa (path);
|
||||
|
||||
pos = 0;
|
||||
|
||||
cp = strtok (path, ":");
|
||||
while (cp)
|
||||
{
|
||||
if (strcmp (cp, "$") == 0)
|
||||
{
|
||||
char *cptr = local_domain;
|
||||
char *tmp;
|
||||
|
||||
while (*cptr != '\0')
|
||||
{
|
||||
if (pos >= count)
|
||||
{
|
||||
count += 5;
|
||||
getnames = realloc (getnames, (count + 1) * sizeof (char *));
|
||||
}
|
||||
tmp = malloc (strlen (cptr) + strlen (local_domain) +
|
||||
strlen (name) + 2);
|
||||
if (tmp == NULL)
|
||||
return NULL;
|
||||
|
||||
getnames[pos] = tmp;
|
||||
tmp = stpcpy (tmp, name);
|
||||
if (*cptr != '.')
|
||||
*tmp++ = '.';
|
||||
stpcpy (tmp, cptr);
|
||||
|
||||
++pos;
|
||||
|
||||
++cptr;
|
||||
while ((*cptr != '\0') && (*cptr != '.'))
|
||||
++cptr;
|
||||
|
||||
if ((*cptr == '.') && (cptr[1] != '\0'))
|
||||
++cptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
if (cp[strlen (cp) - 1] == '$')
|
||||
{
|
||||
tmp = malloc (strlen (cp) + strlen (local_domain) +
|
||||
strlen (name) + 2);
|
||||
if (tmp == NULL)
|
||||
return NULL;
|
||||
|
||||
getnames[pos] = tmp;
|
||||
tmp = stpcpy (tmp, name);
|
||||
*tmp++ = '.';
|
||||
tmp = stpcpy (tmp, cp);
|
||||
--tmp;
|
||||
if (tmp[- 1] != '.')
|
||||
*tmp++ = '.';
|
||||
stpcpy (tmp, local_domain);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = malloc (strlen (cp) + strlen (name) + 2);
|
||||
if (tmp == NULL)
|
||||
return NULL;
|
||||
|
||||
tmp = stpcpy (tmp, name);
|
||||
*tmp++ = '.';
|
||||
stpcpy (tmp, cp);
|
||||
}
|
||||
|
||||
if (pos > count)
|
||||
{
|
||||
count += 5;
|
||||
getnames = realloc (getnames, (count + 1) * sizeof (char *));
|
||||
}
|
||||
getnames[pos] = tmp;
|
||||
pos++;
|
||||
}
|
||||
cp = strtok (NULL, ":");
|
||||
}
|
||||
|
||||
getnames[pos] = NULL;
|
||||
|
||||
return getnames;
|
||||
}
|
||||
|
||||
fd_result *
|
||||
__nis_finddirectoy (nis_name dir_name)
|
||||
{
|
||||
fd_args args;
|
||||
nis_error status;
|
||||
fd_result *res;
|
||||
|
||||
args.dir_name = dir_name;
|
||||
args.requester = nis_local_principal ();
|
||||
|
||||
res = calloc (1, sizeof (fd_result));
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((status = __do_niscall (NULL, 0, NIS_FINDDIRECTORY,
|
||||
(xdrproc_t) xdr_fd_args,
|
||||
(caddr_t) & args,
|
||||
(xdrproc_t) xdr_fd_result,
|
||||
(caddr_t) res, 0)) != RPC_SUCCESS)
|
||||
res->status = status;
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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 __NIS_INTERN_H
|
||||
|
||||
#define __NIS_INTERN_H
|
||||
#include <features.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern nis_error __do_niscall (__const nis_server *server, int server_len,
|
||||
u_long prog, xdrproc_t xargs, caddr_t req,
|
||||
xdrproc_t xres, caddr_t resp, u_long flags);
|
||||
#if !defined(NO_DES_RPC)
|
||||
extern AUTH *authdes_pk_create (char *, netobj *, u_int,
|
||||
struct sockaddr *, des_block *);
|
||||
#endif
|
||||
|
||||
extern nis_name *__nis_expandname (__const nis_name);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,187 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
nis_name
|
||||
nis_local_group (void)
|
||||
{
|
||||
static char __nisgroup[NIS_MAXNAMELEN + 1];
|
||||
|
||||
if (__nisgroup[0] == '\0')
|
||||
{
|
||||
char *cptr;
|
||||
|
||||
if ((cptr = getenv ("NIS_GROUP")) == NULL)
|
||||
return __nisgroup;
|
||||
|
||||
if (strlen (cptr) >= NIS_MAXNAMELEN)
|
||||
return __nisgroup;
|
||||
|
||||
strcpy (__nisgroup, cptr);
|
||||
|
||||
if (__nisgroup[strlen (__nisgroup) - 1] != '.')
|
||||
{
|
||||
cptr = nis_local_directory ();
|
||||
if (strlen (__nisgroup) + strlen (cptr) + 1 < NIS_MAXNAMELEN)
|
||||
{
|
||||
strcat (__nisgroup, ".");
|
||||
strcat (__nisgroup, cptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
__nisgroup[0] = '\0';
|
||||
return __nisgroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return __nisgroup;
|
||||
}
|
||||
|
||||
|
||||
nis_name
|
||||
nis_local_directory (void)
|
||||
{
|
||||
static char __nisdomainname[NIS_MAXNAMELEN + 1];
|
||||
int len;
|
||||
|
||||
if (__nisdomainname[0] == '\0')
|
||||
{
|
||||
if (getdomainname (__nisdomainname, NIS_MAXNAMELEN) < 0)
|
||||
strcpy (__nisdomainname, "\0");
|
||||
else
|
||||
{
|
||||
len = strlen (__nisdomainname);
|
||||
|
||||
/* Missing trailing dot? */
|
||||
if (__nisdomainname[len - 1] != '.')
|
||||
{
|
||||
__nisdomainname[len] = '.';
|
||||
__nisdomainname[len + 1] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return __nisdomainname;
|
||||
}
|
||||
|
||||
nis_name
|
||||
nis_local_principal (void)
|
||||
{
|
||||
static char __principal[NIS_MAXNAMELEN + 1];
|
||||
|
||||
if (__principal[0] == '\0')
|
||||
{
|
||||
char buf[NIS_MAXNAMELEN + 1];
|
||||
nis_result *res;
|
||||
uid_t uid = geteuid ();
|
||||
|
||||
if (uid != 0)
|
||||
{
|
||||
snprintf (buf, NIS_MAXNAMELEN - 1,
|
||||
"[auth_name=%d,auth_type=LOCAL],cred.org_dir.%s",
|
||||
uid, nis_local_directory ());
|
||||
|
||||
if (buf[strlen (buf) - 1] != '.')
|
||||
strcat (buf, ".");
|
||||
|
||||
res = nis_list (buf, USE_DGRAM + NO_AUTHINFO + FOLLOW_LINKS +
|
||||
FOLLOW_PATH, NULL, NULL);
|
||||
|
||||
if (res == NULL)
|
||||
{
|
||||
strcpy (__principal, "nobody");
|
||||
return __principal;
|
||||
}
|
||||
|
||||
if (res->status == NIS_SUCCESS)
|
||||
{
|
||||
if (res->objects.objects_len > 1)
|
||||
{
|
||||
/* More than one principal with same uid? something
|
||||
wrong with cred table. Should be unique Warn user
|
||||
and continue. */
|
||||
printf (_("\
|
||||
LOCAL entry for UID %d in directory %s not unique\n"),
|
||||
uid, nis_local_directory ());
|
||||
}
|
||||
strcpy (__principal, ENTRY_VAL (res->objects.objects_val, 0));
|
||||
nis_freeresult (res);
|
||||
return __principal;
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_freeresult (res);
|
||||
strcpy (__principal, "nobody");
|
||||
return __principal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy (__principal, nis_local_host ());
|
||||
return __principal;
|
||||
}
|
||||
|
||||
/* Should be never reached */
|
||||
strcpy (__principal, "nobody");
|
||||
return __principal;
|
||||
}
|
||||
return __principal;
|
||||
}
|
||||
|
||||
nis_name
|
||||
nis_local_host (void)
|
||||
{
|
||||
static char __nishostname[NIS_MAXNAMELEN + 1];
|
||||
int len;
|
||||
|
||||
if (__nishostname[0] == '\0')
|
||||
{
|
||||
if (gethostname (__nishostname, NIS_MAXNAMELEN) < 0)
|
||||
__nishostname[0] = '\0';
|
||||
else
|
||||
{
|
||||
char *cp;
|
||||
len = strlen(__nishostname);
|
||||
|
||||
/* Hostname already fully qualified? */
|
||||
if (__nishostname[len - 1] == '.')
|
||||
return __nishostname;
|
||||
|
||||
if ((strlen (__nishostname) + strlen (nis_local_directory ()) + 1) >
|
||||
NIS_MAXNAMELEN)
|
||||
{
|
||||
__nishostname[0] = '\0';
|
||||
return __nishostname;
|
||||
}
|
||||
|
||||
cp = &__nishostname[len];
|
||||
*cp++ = '.';
|
||||
strncpy (cp, nis_local_directory (), NIS_MAXNAMELEN - len -1);
|
||||
__nishostname[NIS_MAXNAMELEN] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return __nishostname;
|
||||
}
|
||||
+238
@@ -0,0 +1,238 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@uni-paderborn.de>, 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. */
|
||||
|
||||
#include <string.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include "nis_intern.h"
|
||||
|
||||
nis_result *
|
||||
nis_lookup (const nis_name name, const u_long flags)
|
||||
{
|
||||
nis_result *res;
|
||||
struct ns_request req;
|
||||
nis_name *names;
|
||||
nis_error status;
|
||||
int is_link = 1; /* We should go at least once in the while loop */
|
||||
int count_links = 0; /* We will follow only 16 links in the deep */
|
||||
int i;
|
||||
|
||||
res = calloc (1, sizeof (nis_result));
|
||||
|
||||
if (flags & EXPAND_NAME)
|
||||
{
|
||||
names = __nis_expandname (name);
|
||||
if (names == NULL)
|
||||
{
|
||||
res->status = NIS_NAMEUNREACHABLE;
|
||||
return res;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (names[i] != NULL && (i == 0 || res->status > 1))
|
||||
{
|
||||
req.ns_name = names[i];
|
||||
|
||||
while (is_link)
|
||||
{
|
||||
req.ns_object.ns_object_len = 0;
|
||||
req.ns_object.ns_object_val = NULL;
|
||||
memset (res, '\0', sizeof (nis_result));
|
||||
|
||||
if ((status = __do_niscall (NULL, 0, NIS_LOOKUP,
|
||||
(xdrproc_t) xdr_ns_request,
|
||||
(caddr_t) & req,
|
||||
(xdrproc_t) xdr_nis_result,
|
||||
(caddr_t) res, flags)) != RPC_SUCCESS)
|
||||
{
|
||||
res->status = status;
|
||||
nis_freenames (names);
|
||||
return res;
|
||||
}
|
||||
|
||||
if ((res->status == NIS_SUCCESS || res->status == NIS_S_SUCCESS)
|
||||
&& (res->objects.objects_len > 0 &&
|
||||
res->objects.objects_val->zo_data.zo_type == LINK_OBJ))
|
||||
is_link = 1;
|
||||
else
|
||||
is_link = 0;
|
||||
|
||||
if (is_link)
|
||||
{
|
||||
if ((flags & FOLLOW_LINKS) == FOLLOW_LINKS)
|
||||
{
|
||||
if (count_links == 16)
|
||||
{
|
||||
res->status = NIS_LINKNAMEERROR;
|
||||
return res;
|
||||
}
|
||||
else
|
||||
++count_links;
|
||||
|
||||
req.ns_name = res->objects.objects_val->LI_data.li_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
res->status = NIS_NOTSEARCHABLE;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++i;
|
||||
if (res->status == NIS_NOT_ME)
|
||||
res->status = NIS_NOSUCHNAME;
|
||||
}
|
||||
|
||||
nis_freenames (names);
|
||||
}
|
||||
else
|
||||
{
|
||||
req.ns_name = name;
|
||||
|
||||
while (is_link)
|
||||
{
|
||||
req.ns_object.ns_object_len = 0;
|
||||
req.ns_object.ns_object_val = NULL;
|
||||
memset (res, '\0', sizeof (nis_result));
|
||||
|
||||
if ((status = __do_niscall (NULL, 0, NIS_LOOKUP,
|
||||
(xdrproc_t) xdr_ns_request,
|
||||
(caddr_t) & req,
|
||||
(xdrproc_t) xdr_nis_result,
|
||||
(caddr_t) res, flags)) != RPC_SUCCESS)
|
||||
{
|
||||
res->status = status;
|
||||
return res;
|
||||
}
|
||||
|
||||
if ((res->status == NIS_SUCCESS || res->status == NIS_S_SUCCESS) &&
|
||||
(res->objects.objects_len > 0 &&
|
||||
res->objects.objects_val->zo_data.zo_type == LINK_OBJ))
|
||||
is_link = 1;
|
||||
else
|
||||
is_link = 0;
|
||||
|
||||
if (is_link)
|
||||
{
|
||||
if ((flags & FOLLOW_LINKS) == FOLLOW_LINKS)
|
||||
{
|
||||
if (count_links == 16)
|
||||
{
|
||||
res->status = NIS_LINKNAMEERROR;
|
||||
return res;
|
||||
}
|
||||
else
|
||||
++count_links;
|
||||
|
||||
req.ns_name = res->objects.objects_val->LI_data.li_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
res->status = NIS_NOTSEARCHABLE;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_result *
|
||||
nis_add (const nis_name name, const nis_object *obj)
|
||||
{
|
||||
nis_result *res;
|
||||
nis_error status;
|
||||
struct ns_request req;
|
||||
|
||||
res = calloc (1, sizeof (nis_result));
|
||||
|
||||
req.ns_name = name;
|
||||
|
||||
req.ns_object.ns_object_len = 1;
|
||||
req.ns_object.ns_object_val = nis_clone_object (obj, NULL);
|
||||
|
||||
if ((status = __do_niscall (NULL, 0, NIS_ADD, (xdrproc_t) xdr_ns_request,
|
||||
(caddr_t) & req, (xdrproc_t) xdr_nis_result,
|
||||
(caddr_t) res, 0)) != RPC_SUCCESS)
|
||||
res->status = status;
|
||||
|
||||
nis_destroy_object (req.ns_object.ns_object_val);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_result *
|
||||
nis_remove (const nis_name name, const nis_object *obj)
|
||||
{
|
||||
nis_result *res;
|
||||
nis_error status;
|
||||
struct ns_request req;
|
||||
|
||||
res = calloc (1, sizeof (nis_result));
|
||||
|
||||
req.ns_name = name;
|
||||
|
||||
if (obj != NULL)
|
||||
{
|
||||
req.ns_object.ns_object_len = 1;
|
||||
req.ns_object.ns_object_val = nis_clone_object (obj, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
req.ns_object.ns_object_len = 0;
|
||||
req.ns_object.ns_object_val = NULL;
|
||||
}
|
||||
|
||||
if ((status = __do_niscall (NULL, 0, NIS_REMOVE, (xdrproc_t) xdr_ns_request,
|
||||
(caddr_t) & req, (xdrproc_t) xdr_nis_result,
|
||||
(caddr_t) res, 0)) != RPC_SUCCESS)
|
||||
res->status = status;
|
||||
|
||||
nis_destroy_object (req.ns_object.ns_object_val);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_result *
|
||||
nis_modify (const nis_name name, const nis_object *obj)
|
||||
{
|
||||
nis_result *res;
|
||||
nis_error status;
|
||||
struct ns_request req;
|
||||
|
||||
res = calloc (1, sizeof (nis_result));
|
||||
|
||||
req.ns_name = name;
|
||||
|
||||
req.ns_object.ns_object_len = 1;
|
||||
req.ns_object.ns_object_val = nis_clone_object (obj, NULL);
|
||||
|
||||
if ((status = __do_niscall (NULL, 0, NIS_REMOVE, (xdrproc_t) xdr_ns_request,
|
||||
(caddr_t) & req, (xdrproc_t) xdr_nis_result,
|
||||
(caddr_t) res, 0)) != RPC_SUCCESS)
|
||||
res->status = status;
|
||||
|
||||
nis_destroy_object (req.ns_object.ns_object_val);
|
||||
|
||||
return res;
|
||||
}
|
||||
+308
@@ -0,0 +1,308 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <time.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
static const char *
|
||||
nis_nstype2str (const nstype type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case NIS:
|
||||
return N_("NIS");
|
||||
case SUNYP:
|
||||
return N_("SUNYP");
|
||||
case IVY:
|
||||
return N_("IVY");
|
||||
case DNS:
|
||||
return N_("DNS");
|
||||
case X500:
|
||||
return N_("X500");
|
||||
case DNANS:
|
||||
return N_("DNANS");
|
||||
case XCHS:
|
||||
return N_("XCHS");
|
||||
case CDS:
|
||||
return N_("CDS");
|
||||
default:
|
||||
return N_("UNKNOWN");
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
nis_ttl2str (const u_long ttl)
|
||||
{
|
||||
static char buf[64];
|
||||
unsigned long int time, s, m, h;
|
||||
|
||||
time = ttl;
|
||||
|
||||
h = time / (60 * 60);
|
||||
time %= (60 * 60);
|
||||
m = time / 60;
|
||||
time %= 60;
|
||||
s = time;
|
||||
snprintf (buf, 63, "%lu:%02lu:%02lu", h, m, s);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char *
|
||||
nis_flags2str (const u_long flags)
|
||||
{
|
||||
static char buf[1024];
|
||||
|
||||
snprintf (buf, 1023, "%lu", flags);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
nis_print_rights (const u_long access)
|
||||
{
|
||||
char result[17];
|
||||
u_long acc;
|
||||
int i;
|
||||
|
||||
acc = access; /* Parameter is const ! */
|
||||
result[i = 16] = '\0';
|
||||
while (i > 0)
|
||||
{
|
||||
i -= 4;
|
||||
result[i + 0] = (acc & NIS_READ_ACC) ? 'r' : '-';
|
||||
result[i + 1] = (acc & NIS_MODIFY_ACC) ? 'm' : '-';
|
||||
result[i + 2] = (acc & NIS_CREATE_ACC) ? 'c' : '-';
|
||||
result[i + 3] = (acc & NIS_DESTROY_ACC) ? 'd' : '-';
|
||||
|
||||
acc >>= 8;
|
||||
}
|
||||
printf ("%s", result);
|
||||
}
|
||||
|
||||
void
|
||||
nis_print_directory (const directory_obj *dir)
|
||||
{
|
||||
nis_server *sptr;
|
||||
unsigned int i;
|
||||
|
||||
printf (_("Name : '%s'\n"), dir->do_name);
|
||||
printf (_("Type : %s\n"), gettext (nis_nstype2str (dir->do_type)));
|
||||
sptr = dir->do_servers.do_servers_val;
|
||||
for (i = 0; i < dir->do_servers.do_servers_len; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
fputs (_("Master Server :\n"), stdout);
|
||||
else
|
||||
fputs (_("Replicate :\n"), stdout);
|
||||
printf (_("\tName : %s\n"), sptr->name);
|
||||
fputs (_("\tPublic Key : "), stdout);
|
||||
switch (sptr->key_type)
|
||||
{
|
||||
case NIS_PK_NONE:
|
||||
fputs (_("None.\n"), stdout);
|
||||
break;
|
||||
case NIS_PK_DH:
|
||||
fputs (_("DH.\n"), stdout);
|
||||
break;
|
||||
case NIS_PK_RSA:
|
||||
fputs (_("RSA.\n"), stdout);
|
||||
break;
|
||||
case NIS_PK_KERB:
|
||||
fputs (_("Kerberous.\n"), stdout);
|
||||
break;
|
||||
default:
|
||||
fputs (_("Unknown.\n"), stdout);
|
||||
break;
|
||||
}
|
||||
|
||||
if (sptr->ep.ep_len != 0)
|
||||
{
|
||||
unsigned int j;
|
||||
|
||||
endpoint *ptr;
|
||||
ptr = sptr->ep.ep_val;
|
||||
printf (_("\tUniversal addresses (%u)\n"), sptr->ep.ep_len);
|
||||
for (j = 0; j < sptr->ep.ep_len; j++)
|
||||
{
|
||||
printf ("\t[%d] - ", j + 1);
|
||||
if (ptr->proto != NULL && strlen (ptr->proto) > 0)
|
||||
printf ("%s, ", ptr->proto);
|
||||
else
|
||||
printf ("-, ");
|
||||
if (ptr->family != NULL && strlen (ptr->family) > 0)
|
||||
printf ("%s, ", ptr->family);
|
||||
else
|
||||
printf ("-, ");
|
||||
if (ptr->uaddr != NULL && strlen (ptr->uaddr) > 0)
|
||||
printf ("%s\n", ptr->uaddr);
|
||||
else
|
||||
printf ("-\n");
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
sptr++;
|
||||
}
|
||||
|
||||
printf (_("Time to live : %s\n"), nis_ttl2str (dir->do_ttl));
|
||||
if (dir->do_armask.do_armask_len != 0)
|
||||
{
|
||||
oar_mask *ptr;
|
||||
|
||||
ptr = dir->do_armask.do_armask_val;
|
||||
for (i = 0; i < dir->do_armask.do_armask_len; i++)
|
||||
{
|
||||
fputs (_("Default Access rights: "), stdout);
|
||||
nis_print_rights (ptr->oa_rights);
|
||||
printf (_("\nDirect Type : %d\n"), ptr->oa_otype);
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_print_group (const group_obj *obj)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
fputs (_("Group Flags :"), stdout);
|
||||
if (obj->gr_flags)
|
||||
printf ("0x%08lX", obj->gr_flags);
|
||||
fputs (_("\nGroup Members :\n"), stdout);
|
||||
|
||||
for (i = 0; i < obj->gr_members.gr_members_len; i++)
|
||||
printf ("\t%s\n", obj->gr_members.gr_members_val[i]);
|
||||
}
|
||||
|
||||
void
|
||||
nis_print_table (const table_obj *obj)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
printf (_("Table Type : %s\n"), obj->ta_type);
|
||||
printf (_("Number of Columns : %d\n"), obj->ta_maxcol);
|
||||
printf (_("Character Separator : %c\n"), obj->ta_sep);
|
||||
printf (_("Search Path : %s\n"), obj->ta_path);
|
||||
fputs (_("Columns :\n"), stdout);
|
||||
for (i = 0; i < obj->ta_cols.ta_cols_len; i++)
|
||||
{
|
||||
printf (_("\t[%d]\tName : %s\n"), i,
|
||||
obj->ta_cols.ta_cols_val[i].tc_name);
|
||||
printf (_("\t\tAttributes : %s\n"),
|
||||
nis_flags2str (obj->ta_cols.ta_cols_val[i].tc_flags));
|
||||
fputs (_("\t\tAccess Rights : "), stdout);
|
||||
nis_print_rights (obj->ta_cols.ta_cols_val[i].tc_rights);
|
||||
fputc ('\n', stdout);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_print_link (const link_obj *obj)
|
||||
{
|
||||
printf (_("Type : %d\n"), obj->li_rtype);
|
||||
printf (_("Name : %s\n"), obj->li_name);
|
||||
printf (_("Attributes : %d\n"), obj->li_attrs.li_attrs_len);
|
||||
}
|
||||
|
||||
void
|
||||
nis_print_entry (const entry_obj *obj)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
printf (_("\tEntry data of type %s\n"), obj->en_type);
|
||||
for (i = 0; i < obj->en_cols.en_cols_len; i++)
|
||||
{
|
||||
printf (_("\t[%u] - [%u bytes] "), i,
|
||||
obj->en_cols.en_cols_val[i].ec_value.ec_value_len);
|
||||
if ((obj->en_cols.en_cols_val[i].ec_flags & EN_CRYPT) == EN_CRYPT)
|
||||
fputs (_("Encrypted data\n"), stdout);
|
||||
else if ((obj->en_cols.en_cols_val[i].ec_flags & EN_BINARY) == EN_BINARY)
|
||||
fputs (_("Binary data\n"), stdout);
|
||||
else
|
||||
printf ("%s\n", obj->en_cols.en_cols_val[i].ec_value.ec_value_val);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_print_object (const nis_object * obj)
|
||||
{
|
||||
printf (_("Object Name : %s\n"), obj->zo_name);
|
||||
printf (_("Directory : %s\n"), obj->zo_domain);
|
||||
printf (_("Owner : %s\n"), obj->zo_owner);
|
||||
printf (_("Group : %s\n"), obj->zo_group);
|
||||
fputs (_("Access Rights : "), stdout);
|
||||
nis_print_rights (obj->zo_access);
|
||||
printf (_("\nTime to Live : %lu (seconds)\n"), obj->zo_ttl);
|
||||
printf (_("Creation Time : %s"), ctime (&obj->zo_oid.ctime));
|
||||
printf (_("Mod. Time : %s"), ctime (&obj->zo_oid.mtime));
|
||||
fputs (_("Object Type : "), stdout);
|
||||
switch (obj->zo_data.zo_type)
|
||||
{
|
||||
case BOGUS_OBJ:
|
||||
fputs (_("BOGUS OBJECT\n"), stdout);
|
||||
break;
|
||||
case NO_OBJ:
|
||||
fputs (_("NO OBJECT\n"), stdout);
|
||||
break;
|
||||
case DIRECTORY_OBJ:
|
||||
fputs (_("DIRECTORY\n"), stdout);
|
||||
nis_print_directory (&obj->zo_data.objdata_u.di_data);
|
||||
break;
|
||||
case GROUP_OBJ:
|
||||
fputs (_("GROUP\n"), stdout);
|
||||
nis_print_group (&obj->zo_data.objdata_u.gr_data);
|
||||
break;
|
||||
case TABLE_OBJ:
|
||||
fputs (_("TABLE\n"), stdout);
|
||||
nis_print_table (&obj->zo_data.objdata_u.ta_data);
|
||||
break;
|
||||
case ENTRY_OBJ:
|
||||
fputs (_("ENTRY\n"), stdout);
|
||||
nis_print_entry (&obj->zo_data.objdata_u.en_data);
|
||||
break;
|
||||
case LINK_OBJ:
|
||||
fputs (_("LINK\n"), stdout);
|
||||
nis_print_link (&obj->zo_data.objdata_u.li_data);
|
||||
break;
|
||||
case PRIVATE_OBJ:
|
||||
fputs (_("PRIVATE\n"), stdout);
|
||||
printf (_(" Data Length = %u\n"),
|
||||
obj->zo_data.objdata_u.po_data.po_data_len);
|
||||
break;
|
||||
default:
|
||||
fputs (_("(Unknown object)\n"), stdout);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_print_result (const nis_result *res)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
printf (_("Status : %s\n"), nis_sperrno (res->status));
|
||||
printf (_("Number of objects : %u\n"), res->objects.objects_len);
|
||||
|
||||
for (i = 0; i < res->objects.objects_len; i++)
|
||||
{
|
||||
printf (_("Object #%d:\n"), i);
|
||||
nis_print_object (&res->objects.objects_val[i]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
#include "nis_intern.h"
|
||||
|
||||
nis_error
|
||||
nis_mkdir (const nis_name dir, const nis_server *server)
|
||||
{
|
||||
nis_error res;
|
||||
|
||||
if (server == NULL)
|
||||
{
|
||||
int result;
|
||||
if ((result = __do_niscall (NULL, 0, NIS_MKDIR, (xdrproc_t) xdr_nis_name,
|
||||
(caddr_t) dir, (xdrproc_t) xdr_nis_error,
|
||||
(caddr_t) & res, 0)) != RPC_SUCCESS)
|
||||
{
|
||||
fprintf (stderr, _("__do_niscall: Error #%d\n"), result);
|
||||
return NIS_RPCERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int result;
|
||||
if ((result = __do_niscall (server, 1, NIS_MKDIR,
|
||||
(xdrproc_t) xdr_nis_name,
|
||||
(caddr_t) dir, (xdrproc_t) xdr_nis_error,
|
||||
(caddr_t) & res, 0)) != RPC_SUCCESS)
|
||||
{
|
||||
fprintf (stderr, _("__do_niscall: Error #%d\n"), result);
|
||||
return NIS_RPCERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_error
|
||||
nis_rmdir (const nis_name dir, const nis_server *server)
|
||||
{
|
||||
nis_error res;
|
||||
|
||||
if (server == NULL)
|
||||
{
|
||||
int result;
|
||||
if ((result = __do_niscall (NULL, 0, NIS_RMDIR, (xdrproc_t) xdr_nis_name,
|
||||
(caddr_t) dir, (xdrproc_t) xdr_nis_error,
|
||||
(caddr_t) & res, 0)) != RPC_SUCCESS)
|
||||
{
|
||||
fprintf (stderr, _("__do_niscall: Error #%d\n"), result);
|
||||
return NIS_RPCERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int result;
|
||||
if ((result = __do_niscall (server, 1, NIS_RMDIR,
|
||||
(xdrproc_t) xdr_nis_name,
|
||||
(caddr_t) dir, (xdrproc_t) xdr_nis_error,
|
||||
(caddr_t) & res, 0)) != RPC_SUCCESS)
|
||||
{
|
||||
fprintf (stderr, _("__do_niscall: Error #%d\n"), result);
|
||||
return NIS_RPCERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_error
|
||||
nis_servstate (const nis_server *serv, const nis_tag *tags,
|
||||
const int numtags, nis_tag **result)
|
||||
{
|
||||
*result = NULL;
|
||||
return NIS_FAIL;
|
||||
}
|
||||
stub_warning (nis_servstate)
|
||||
|
||||
nis_error
|
||||
nis_stats (const nis_server *serv, const nis_tag *tags,
|
||||
const int numtags, nis_tag **result)
|
||||
{
|
||||
result = malloc (sizeof (nis_tag *));
|
||||
if (result != NULL)
|
||||
result[0] = NULL;
|
||||
return NIS_FAIL;
|
||||
}
|
||||
stub_warning (nis_stats);
|
||||
|
||||
void
|
||||
nis_freetags (nis_tag *tags, const int numtags)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numtags; ++i)
|
||||
free (tags->tag_val);
|
||||
free (tags);
|
||||
}
|
||||
|
||||
nis_server **
|
||||
nis_getservlist (const nis_name dir)
|
||||
{
|
||||
nis_server **serv;
|
||||
|
||||
serv = malloc (sizeof (nis_server *));
|
||||
if (serv != NULL)
|
||||
serv[0] = NULL;
|
||||
|
||||
return serv;
|
||||
}
|
||||
stub_warning (nis_getservlist);
|
||||
|
||||
void
|
||||
nis_freeservlist (nis_server **serv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (serv == NULL)
|
||||
return;
|
||||
|
||||
i = 0;
|
||||
while (serv[i] != NULL)
|
||||
nis_free_servers (serv[i], 1);
|
||||
free (serv);
|
||||
}
|
||||
+310
@@ -0,0 +1,310 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
nis_name
|
||||
nis_leaf_of (const nis_name name)
|
||||
{
|
||||
static char result[NIS_MAXNAMELEN + 1];
|
||||
|
||||
return nis_leaf_of_r (name, result, NIS_MAXNAMELEN);
|
||||
}
|
||||
|
||||
nis_name
|
||||
nis_leaf_of_r (const nis_name name, char *buffer, size_t buflen)
|
||||
{
|
||||
size_t i = 0;
|
||||
|
||||
buffer[0] = '\0';
|
||||
|
||||
while (name[i] != '.' && name[i] != '\0')
|
||||
i++;
|
||||
|
||||
if (i > buflen - 1)
|
||||
{
|
||||
errno = ERANGE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (i > 1)
|
||||
strncpy (buffer, name, i - 1);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
nis_name
|
||||
nis_name_of (const nis_name name)
|
||||
{
|
||||
static char result[NIS_MAXNAMELEN + 1];
|
||||
|
||||
return nis_name_of_r (name, result, NIS_MAXNAMELEN);
|
||||
}
|
||||
|
||||
nis_name
|
||||
nis_name_of_r (const nis_name name, char *buffer, size_t buflen)
|
||||
{
|
||||
char *local_domain;
|
||||
int diff;
|
||||
|
||||
local_domain = nis_local_directory ();
|
||||
|
||||
diff = strlen (name) - strlen (local_domain);
|
||||
if (diff <= 0)
|
||||
return NULL;
|
||||
|
||||
if (strcmp (&name[diff], local_domain) != 0)
|
||||
return NULL;
|
||||
|
||||
if ((size_t) diff >= buflen)
|
||||
{
|
||||
errno = ERANGE;
|
||||
return NULL;
|
||||
}
|
||||
memcpy (buffer, name, diff - 1);
|
||||
buffer[diff - 1] = '\0';
|
||||
|
||||
if (diff - 1 == 0)
|
||||
return NULL;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
nis_name
|
||||
nis_domain_of (const nis_name name)
|
||||
{
|
||||
static char result[NIS_MAXNAMELEN + 1];
|
||||
|
||||
return nis_domain_of_r (name, result, NIS_MAXNAMELEN);
|
||||
}
|
||||
|
||||
nis_name
|
||||
nis_domain_of_r (const nis_name name, char *buffer, size_t buflen)
|
||||
{
|
||||
char *cptr;
|
||||
size_t cptr_len;
|
||||
|
||||
cptr = strchr (name, '.'); /* XXX What happens if the NIS name
|
||||
does not contain a `.'? */
|
||||
++cptr;
|
||||
cptr_len = strlen (cptr);
|
||||
|
||||
if (cptr_len == 0)
|
||||
strcpy (buffer, ".");
|
||||
else if (cptr_len >= buflen)
|
||||
{
|
||||
errno = ERANGE;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
memcpy (buffer, cptr, cptr_len + 1);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static int
|
||||
count_dots (const nis_name str)
|
||||
{
|
||||
int count = 0;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < strlen (str); ++i)
|
||||
if (str[i] == '.')
|
||||
++count;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
nis_name *
|
||||
nis_getnames (const nis_name name)
|
||||
{
|
||||
nis_name *getnames = NULL;
|
||||
char local_domain[NIS_MAXNAMELEN + 1];
|
||||
char *path, *cp;
|
||||
int count, pos;
|
||||
|
||||
|
||||
strncpy (local_domain, nis_local_directory (), NIS_MAXNAMELEN);
|
||||
local_domain[NIS_MAXNAMELEN] = '\0';
|
||||
|
||||
count = 1;
|
||||
if ((getnames = malloc ((count + 1) * sizeof (char *))) == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Do we have a fully qualified NIS+ name ? If yes, give it back */
|
||||
if (name[strlen (name) - 1] == '.')
|
||||
{
|
||||
if ((getnames[0] = strdup (name)) == NULL)
|
||||
{
|
||||
free (getnames);
|
||||
return NULL;
|
||||
}
|
||||
getnames[1] = NULL;
|
||||
|
||||
return getnames;
|
||||
}
|
||||
|
||||
/* Get the search path, where we have to search "name" */
|
||||
path = getenv ("NIS_PATH");
|
||||
if (path == NULL)
|
||||
path = strdupa ("$");
|
||||
else
|
||||
path = strdupa (path);
|
||||
|
||||
pos = 0;
|
||||
|
||||
cp = strtok (path, ":");
|
||||
while (cp)
|
||||
{
|
||||
if (strcmp (cp, "$") == 0)
|
||||
{
|
||||
char *cptr = local_domain;
|
||||
char *tmp;
|
||||
|
||||
while (count_dots (cptr) >= 2)
|
||||
{
|
||||
if (pos >= count)
|
||||
{
|
||||
count += 5;
|
||||
getnames = realloc (getnames, (count + 1) * sizeof (char *));
|
||||
}
|
||||
tmp = malloc (strlen (cptr) + strlen (local_domain) +
|
||||
strlen (name) + 2);
|
||||
if (tmp == NULL)
|
||||
return NULL;
|
||||
|
||||
getnames[pos] = tmp;
|
||||
tmp = stpcpy (tmp, name);
|
||||
*tmp++ = '.';
|
||||
stpcpy (tmp, cptr);
|
||||
|
||||
++pos;
|
||||
|
||||
while (*cptr != '.')
|
||||
++cptr;
|
||||
++cptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
if (cp[strlen (cp) - 1] == '$')
|
||||
{
|
||||
tmp = malloc (strlen (cp) + strlen (local_domain) +
|
||||
strlen (name) + 2);
|
||||
if (tmp == NULL)
|
||||
return NULL;
|
||||
|
||||
tmp = stpcpy (tmp, name);
|
||||
*tmp++ = '.';
|
||||
tmp = stpcpy (tmp, cp);
|
||||
--tmp;
|
||||
if (tmp[-1] != '.')
|
||||
*tmp++ = '.';
|
||||
stpcpy (tmp, local_domain);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp = malloc (strlen (cp) + strlen (name) + 2);
|
||||
if (tmp == NULL)
|
||||
return NULL;
|
||||
|
||||
tmp = stpcpy (tmp, name);
|
||||
*tmp++ = '.';
|
||||
stpcpy (tmp, cp);
|
||||
}
|
||||
|
||||
if (pos > count)
|
||||
{
|
||||
count += 5;
|
||||
getnames = realloc (getnames, (count + 1) * sizeof (char *));
|
||||
if (getnames == NULL)
|
||||
return NULL;
|
||||
}
|
||||
getnames[pos] = tmp;
|
||||
++pos;
|
||||
}
|
||||
cp = strtok (NULL, ":");
|
||||
}
|
||||
|
||||
getnames[pos] = NULL;
|
||||
|
||||
return getnames;
|
||||
}
|
||||
|
||||
void
|
||||
nis_freenames (nis_name *names)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while (names[i] != NULL)
|
||||
{
|
||||
free (names[i]);
|
||||
++i;
|
||||
}
|
||||
|
||||
free (names);
|
||||
}
|
||||
|
||||
name_pos
|
||||
nis_dir_cmp (const nis_name n1, const nis_name n2)
|
||||
{
|
||||
int len1, len2;
|
||||
|
||||
len1 = strlen (n1);
|
||||
len2 = strlen (n2);
|
||||
|
||||
if (len1 == len2)
|
||||
{
|
||||
if (strcmp (n1, n2) == 0)
|
||||
return SAME_NAME;
|
||||
else
|
||||
return NOT_SEQUENTIAL;
|
||||
}
|
||||
|
||||
if (len1 < len2)
|
||||
{
|
||||
if (n2[len2 - len1 - 1] != '.')
|
||||
return NOT_SEQUENTIAL;
|
||||
else if (strcmp (&n2[len2 - len1], n1) == 0)
|
||||
return HIGHER_NAME;
|
||||
else
|
||||
return NOT_SEQUENTIAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (n1[len1 - len2 - 1] != '.')
|
||||
return NOT_SEQUENTIAL;
|
||||
else if (strcmp (&n1[len1 - len2], n2) == 0)
|
||||
return LOWER_NAME;
|
||||
else
|
||||
return NOT_SEQUENTIAL;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nis_destroy_object (nis_object *obj)
|
||||
{
|
||||
nis_free_object (obj);
|
||||
}
|
||||
+417
@@ -0,0 +1,417 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <string.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
#include "nis_intern.h"
|
||||
|
||||
static void
|
||||
splitname (const nis_name name, nis_name *ibr_name, int *srch_len,
|
||||
nis_attr **srch_val)
|
||||
{
|
||||
char *cptr, *key, *val, *next;
|
||||
int size;
|
||||
|
||||
if (name == NULL)
|
||||
return;
|
||||
|
||||
cptr = strdup (name);
|
||||
if (srch_len)
|
||||
*srch_len = 0;
|
||||
if (srch_val)
|
||||
*srch_val = NULL;
|
||||
size = 0;
|
||||
|
||||
/* Not of "[key=value,key=value,...],foo.." format? */
|
||||
if (cptr[0] != '[')
|
||||
{
|
||||
*ibr_name = cptr;
|
||||
return;
|
||||
}
|
||||
|
||||
*ibr_name = strchr (cptr, ']');
|
||||
if (*ibr_name == NULL || (*ibr_name)[1] != ',')
|
||||
{
|
||||
free (cptr);
|
||||
*ibr_name = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
*ibr_name[0] = '\0';
|
||||
*ibr_name += 2;
|
||||
*ibr_name = strdup (*ibr_name);
|
||||
|
||||
if (srch_len == NULL || srch_val == NULL)
|
||||
{
|
||||
free (cptr);
|
||||
return;
|
||||
}
|
||||
|
||||
key = (cptr) + 1;
|
||||
do
|
||||
{
|
||||
next = strchr (key, ',');
|
||||
if (next)
|
||||
{
|
||||
next[0] = '\0';
|
||||
++next;
|
||||
}
|
||||
|
||||
val = strchr (key, '=');
|
||||
if (!val)
|
||||
{
|
||||
free (cptr);
|
||||
*srch_val = malloc (sizeof (char *));
|
||||
if (*srch_val == NULL)
|
||||
{
|
||||
free (cptr);
|
||||
free (*ibr_name);
|
||||
*ibr_name = NULL;
|
||||
return;
|
||||
}
|
||||
(*srch_val)[*srch_len].zattr_val.zattr_val_len = 0;
|
||||
(*srch_val)[*srch_len].zattr_val.zattr_val_val = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
val[0] = '\0';
|
||||
++val;
|
||||
|
||||
if ((*srch_len) + 1 >= size)
|
||||
{
|
||||
size += 10;
|
||||
if (size == 10)
|
||||
*srch_val = malloc (size * sizeof (char *));
|
||||
else
|
||||
*srch_val = realloc (val, size * sizeof (char *));
|
||||
if (*srch_val == NULL)
|
||||
{
|
||||
free (cptr);
|
||||
free (*ibr_name);
|
||||
*ibr_name = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
(*srch_val)[*srch_len].zattr_ndx = strdup (key);
|
||||
if (((*srch_val)[*srch_len].zattr_ndx) == NULL)
|
||||
{
|
||||
free (cptr);
|
||||
free (*ibr_name);
|
||||
*ibr_name = NULL;
|
||||
return;
|
||||
}
|
||||
(*srch_val)[*srch_len].zattr_val.zattr_val_len = strlen (val) + 1;
|
||||
(*srch_val)[*srch_len].zattr_val.zattr_val_val = strdup (val);
|
||||
if ((*srch_val)[*srch_len].zattr_val.zattr_val_val == NULL)
|
||||
{
|
||||
free (cptr);
|
||||
free (*ibr_name);
|
||||
*ibr_name = NULL;
|
||||
return;
|
||||
}
|
||||
++(*srch_len);
|
||||
|
||||
key = next;
|
||||
|
||||
}
|
||||
while (next);
|
||||
|
||||
free (cptr);
|
||||
}
|
||||
|
||||
static struct ib_request *
|
||||
__create_ib_request (const nis_name name, struct ib_request *ibreq,
|
||||
u_long flags)
|
||||
{
|
||||
splitname (name, &ibreq->ibr_name, &ibreq->ibr_srch.ibr_srch_len,
|
||||
&ibreq->ibr_srch.ibr_srch_val);
|
||||
if (ibreq->ibr_name == NULL)
|
||||
return NULL;
|
||||
if ((flags & EXPAND_NAME) == EXPAND_NAME)
|
||||
{
|
||||
nis_name *names;
|
||||
|
||||
names = __nis_expandname (ibreq->ibr_name);
|
||||
free (ibreq->ibr_name);
|
||||
ibreq->ibr_name = NULL;
|
||||
if (names == NULL)
|
||||
return NULL;
|
||||
ibreq->ibr_name = strdup (names[0]);
|
||||
nis_freenames (names);
|
||||
}
|
||||
|
||||
ibreq->ibr_flags = (flags & (RETURN_RESULT | ADD_OVERWRITE | REM_MULTIPLE |
|
||||
MOD_SAMEOBJ | ADD_RESERVED | REM_RESERVED |
|
||||
MOD_EXCLUSIVE));
|
||||
ibreq->ibr_obj.ibr_obj_len = 0;
|
||||
ibreq->ibr_obj.ibr_obj_val = NULL;
|
||||
ibreq->ibr_cbhost.ibr_cbhost_len = 0;
|
||||
ibreq->ibr_cbhost.ibr_cbhost_val = NULL;
|
||||
ibreq->ibr_bufsize = 0;
|
||||
ibreq->ibr_cookie.n_len = 0;
|
||||
ibreq->ibr_cookie.n_bytes = NULL;
|
||||
|
||||
return ibreq;
|
||||
}
|
||||
|
||||
nis_result *
|
||||
nis_list (const nis_name name, const u_long flags,
|
||||
int (*callback) (const nis_name name,
|
||||
const nis_object *object,
|
||||
const void *userdata),
|
||||
const void *userdata)
|
||||
{
|
||||
nis_result *res = NULL;
|
||||
struct ib_request ibreq;
|
||||
int result;
|
||||
int count_links = 0; /* We will only follow 16 links! */
|
||||
int is_link = 1; /* We should go at least once in the while loop */
|
||||
|
||||
res = calloc (1, sizeof (nis_result));
|
||||
|
||||
if (__create_ib_request (name, &ibreq, flags) == NULL)
|
||||
{
|
||||
res->status = NIS_BADNAME;
|
||||
return res;
|
||||
}
|
||||
|
||||
while (is_link)
|
||||
{
|
||||
memset (res, '\0', sizeof (nis_result));
|
||||
|
||||
if ((result = __do_niscall (NULL, 0, NIS_IBLIST,
|
||||
(xdrproc_t) xdr_ib_request,
|
||||
(caddr_t) & ibreq, (xdrproc_t) xdr_nis_result,
|
||||
(caddr_t) res, flags)) != RPC_SUCCESS)
|
||||
{
|
||||
res->status = result;
|
||||
nis_free_request (&ibreq);
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_free_request (&ibreq);
|
||||
|
||||
if ((res->status == NIS_SUCCESS || res->status == NIS_S_SUCCESS) &&
|
||||
(res->objects.objects_len > 0 &&
|
||||
res->objects.objects_val->zo_data.zo_type == LINK_OBJ))
|
||||
is_link = 1;
|
||||
else
|
||||
is_link = 0;
|
||||
|
||||
if (is_link)
|
||||
{
|
||||
if ((flags & FOLLOW_LINKS) == FOLLOW_LINKS)
|
||||
{
|
||||
if (count_links == 16)
|
||||
{
|
||||
res->status = NIS_LINKNAMEERROR;
|
||||
return res;
|
||||
}
|
||||
else
|
||||
++count_links;
|
||||
|
||||
if (__create_ib_request (res->objects.objects_val->LI_data.li_name,
|
||||
&ibreq, flags) == NULL)
|
||||
{
|
||||
res->status = NIS_BADNAME;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res->status = NIS_NOTSEARCHABLE;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (callback != NULL &&
|
||||
(res->status == NIS_SUCCESS || res->status == NIS_S_SUCCESS))
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < res->objects.objects_len; ++i)
|
||||
if ((*callback) (name, &(res->objects.objects_val)[i], userdata) != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_result *
|
||||
nis_add_entry (const nis_name name, const nis_object *obj,
|
||||
const u_long flags)
|
||||
{
|
||||
nis_result *res;
|
||||
struct ib_request ibreq;
|
||||
nis_error status;
|
||||
|
||||
res = calloc (1, sizeof (nis_result));
|
||||
|
||||
if (__create_ib_request (name, &ibreq, flags) == NULL)
|
||||
{
|
||||
res->status = NIS_BADNAME;
|
||||
return res;
|
||||
}
|
||||
|
||||
ibreq.ibr_flags = flags;
|
||||
ibreq.ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
|
||||
ibreq.ibr_obj.ibr_obj_len = 1;
|
||||
|
||||
if ((status = __do_niscall (NULL, 0, NIS_IBADD,
|
||||
(xdrproc_t) xdr_ib_request,
|
||||
(caddr_t) & ibreq,
|
||||
(xdrproc_t) xdr_nis_result,
|
||||
(caddr_t) res, 0)) != RPC_SUCCESS)
|
||||
res->status = status;
|
||||
|
||||
nis_free_request (&ibreq);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_result *
|
||||
nis_modify_entry (const nis_name name, const nis_object *obj,
|
||||
const u_long flags)
|
||||
{
|
||||
nis_result *res;
|
||||
struct ib_request ibreq;
|
||||
nis_error status;
|
||||
|
||||
res = calloc (1, sizeof (nis_result));
|
||||
|
||||
if (__create_ib_request (name, &ibreq, flags) == NULL)
|
||||
{
|
||||
res->status = NIS_BADNAME;
|
||||
return res;
|
||||
}
|
||||
|
||||
ibreq.ibr_flags = flags;
|
||||
ibreq.ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
|
||||
ibreq.ibr_obj.ibr_obj_len = 1;
|
||||
|
||||
if ((status = __do_niscall (NULL, 0, NIS_IBMODIFY,
|
||||
(xdrproc_t) xdr_ib_request,
|
||||
(caddr_t) & ibreq, (xdrproc_t) xdr_nis_result,
|
||||
(caddr_t) res, 0)) != RPC_SUCCESS)
|
||||
res->status = status;
|
||||
|
||||
nis_free_request (&ibreq);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_result *
|
||||
nis_remove_entry (const nis_name name, const nis_object *obj,
|
||||
const u_long flags)
|
||||
{
|
||||
nis_result *res;
|
||||
struct ib_request ibreq;
|
||||
nis_error status;
|
||||
|
||||
res = calloc (1, sizeof (nis_result));
|
||||
|
||||
if (__create_ib_request (name, &ibreq, flags) == NULL)
|
||||
{
|
||||
res->status = NIS_BADNAME;
|
||||
return res;
|
||||
}
|
||||
|
||||
ibreq.ibr_flags = flags;
|
||||
if (obj != NULL)
|
||||
{
|
||||
ibreq.ibr_obj.ibr_obj_val = nis_clone_object (obj, NULL);
|
||||
ibreq.ibr_obj.ibr_obj_len = 1;
|
||||
}
|
||||
|
||||
if ((status = __do_niscall (NULL, 0, NIS_IBREMOVE,
|
||||
(xdrproc_t) xdr_ib_request,
|
||||
(caddr_t) & ibreq, (xdrproc_t) xdr_nis_result,
|
||||
(caddr_t) res, 0)) != RPC_SUCCESS)
|
||||
res->status = status;
|
||||
|
||||
nis_free_request (&ibreq);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_result *
|
||||
nis_first_entry (const nis_name name)
|
||||
{
|
||||
nis_result *res;
|
||||
struct ib_request ibreq;
|
||||
nis_error status;
|
||||
|
||||
res = calloc (1, sizeof (nis_result));
|
||||
|
||||
if (__create_ib_request (name, &ibreq, 0) == NULL)
|
||||
{
|
||||
res->status = NIS_BADNAME;
|
||||
return res;
|
||||
}
|
||||
|
||||
if ((status = __do_niscall (NULL, 0, NIS_IBFIRST, (xdrproc_t) xdr_ib_request,
|
||||
(caddr_t) & ibreq, (xdrproc_t) xdr_nis_result,
|
||||
(caddr_t) res, 0)) != RPC_SUCCESS)
|
||||
res->status = status;
|
||||
|
||||
nis_free_request (&ibreq);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nis_result *
|
||||
nis_next_entry (const nis_name name, const netobj *cookie)
|
||||
{
|
||||
nis_result *res;
|
||||
struct ib_request ibreq;
|
||||
nis_error status;
|
||||
|
||||
res = calloc (1, sizeof (nis_result));
|
||||
|
||||
if (__create_ib_request (name, &ibreq, 0) == NULL)
|
||||
{
|
||||
res->status = NIS_BADNAME;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (cookie != NULL)
|
||||
{
|
||||
ibreq.ibr_cookie.n_bytes = malloc (cookie->n_len);
|
||||
if (ibreq.ibr_cookie.n_bytes == NULL)
|
||||
{
|
||||
res->status = NIS_NOMEMORY;
|
||||
free (res);
|
||||
return NULL;
|
||||
}
|
||||
memcpy (ibreq.ibr_cookie.n_bytes, cookie->n_bytes, cookie->n_len);
|
||||
ibreq.ibr_cookie.n_len = cookie->n_len;
|
||||
}
|
||||
|
||||
if ((status = __do_niscall (NULL, 0, NIS_IBNEXT, (xdrproc_t) xdr_ib_request,
|
||||
(caddr_t) & ibreq, (xdrproc_t) xdr_nis_result,
|
||||
(caddr_t) res, 0)) != RPC_SUCCESS)
|
||||
res->status = status;
|
||||
|
||||
nis_free_request (&ibreq);
|
||||
|
||||
return res;
|
||||
}
|
||||
+572
@@ -0,0 +1,572 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <rpcsvc/nis.h>
|
||||
|
||||
bool_t
|
||||
xdr_nis_attr (XDR *xdrs, nis_attr *objp)
|
||||
{
|
||||
if (!xdr_string (xdrs, &objp->zattr_ndx, ~0))
|
||||
return FALSE;
|
||||
if (!xdr_bytes (xdrs, (char **) &objp->zattr_val.zattr_val_val,
|
||||
(u_int *) & objp->zattr_val.zattr_val_len, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nis_name (XDR *xdrs, nis_name *objp)
|
||||
{
|
||||
if (!xdr_string (xdrs, objp, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_zotypes (XDR *xdrs, zotypes *objp)
|
||||
{
|
||||
if (!xdr_enum (xdrs, (enum_t *) objp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nstype (XDR *xdrs, nstype *objp)
|
||||
{
|
||||
if (!xdr_enum (xdrs, (enum_t *) objp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_oar_mask (XDR *xdrs, oar_mask *objp)
|
||||
{
|
||||
if (!xdr_u_long (xdrs, &objp->oa_rights))
|
||||
return FALSE;
|
||||
if (!xdr_zotypes (xdrs, &objp->oa_otype))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_endpoint (XDR *xdrs, endpoint *objp)
|
||||
{
|
||||
if (!xdr_string (xdrs, &objp->uaddr, ~0))
|
||||
return FALSE;
|
||||
if (!xdr_string (xdrs, &objp->family, ~0))
|
||||
return FALSE;
|
||||
if (!xdr_string (xdrs, &objp->proto, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nis_server (XDR *xdrs, nis_server *objp)
|
||||
{
|
||||
if (!xdr_nis_name (xdrs, &objp->name))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->ep.ep_val, (u_int *) &objp->ep.ep_len,
|
||||
~0, sizeof (endpoint), (xdrproc_t) xdr_endpoint))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->key_type))
|
||||
return FALSE;
|
||||
if (!xdr_netobj (xdrs, &objp->pkey))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_directory_obj (XDR *xdrs, directory_obj *objp)
|
||||
{
|
||||
if (!xdr_nis_name (xdrs, &objp->do_name))
|
||||
return FALSE;
|
||||
if (!xdr_nstype (xdrs, &objp->do_type))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->do_servers.do_servers_val,
|
||||
(u_int *) & objp->do_servers.do_servers_len, ~0,
|
||||
sizeof (nis_server), (xdrproc_t) xdr_nis_server))
|
||||
return FALSE;
|
||||
|
||||
if (!xdr_u_long (xdrs, &objp->do_ttl))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->do_armask.do_armask_val,
|
||||
(u_int *) & objp->do_armask.do_armask_len, ~0,
|
||||
sizeof (oar_mask), (xdrproc_t) xdr_oar_mask))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_entry_col (XDR *xdrs, entry_col *objp)
|
||||
{
|
||||
if (!xdr_u_long (xdrs, &objp->ec_flags))
|
||||
return FALSE;
|
||||
if (!xdr_bytes (xdrs, (char **) &objp->ec_value.ec_value_val,
|
||||
(u_int *) &objp->ec_value.ec_value_len, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_entry_obj (XDR *xdrs, entry_obj *objp)
|
||||
{
|
||||
if (!xdr_string (xdrs, &objp->en_type, ~0))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->en_cols.en_cols_val,
|
||||
(u_int *) &objp->en_cols.en_cols_len, ~0,
|
||||
sizeof (entry_col), (xdrproc_t) xdr_entry_col))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_group_obj (XDR *xdrs, group_obj *objp)
|
||||
{
|
||||
if (!xdr_u_long (xdrs, &objp->gr_flags))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->gr_members.gr_members_val,
|
||||
(u_int *) &objp->gr_members.gr_members_len, ~0,
|
||||
sizeof (nis_name), (xdrproc_t) xdr_nis_name))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_link_obj (XDR *xdrs, link_obj *objp)
|
||||
{
|
||||
if (!xdr_zotypes (xdrs, &objp->li_rtype))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->li_attrs.li_attrs_val,
|
||||
(u_int *) &objp->li_attrs.li_attrs_len, ~0,
|
||||
sizeof (nis_attr), (xdrproc_t) xdr_nis_attr))
|
||||
return FALSE;
|
||||
if (!xdr_nis_name (xdrs, &objp->li_name))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_table_col (XDR *xdrs, table_col *objp)
|
||||
{
|
||||
if (!xdr_string (xdrs, &objp->tc_name, 64))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->tc_flags))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->tc_rights))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_table_obj (XDR *xdrs, table_obj *objp)
|
||||
{
|
||||
if (!xdr_string (xdrs, &objp->ta_type, 64))
|
||||
return FALSE;
|
||||
if (!xdr_int (xdrs, &objp->ta_maxcol))
|
||||
return FALSE;
|
||||
if (!xdr_u_char (xdrs, &objp->ta_sep))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->ta_cols.ta_cols_val,
|
||||
(u_int *) &objp->ta_cols.ta_cols_len, ~0,
|
||||
sizeof (table_col), (xdrproc_t) xdr_table_col))
|
||||
return FALSE;
|
||||
if (!xdr_string (xdrs, &objp->ta_path, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_objdata (XDR *xdrs, objdata *objp)
|
||||
{
|
||||
if (!xdr_zotypes (xdrs, &objp->zo_type))
|
||||
return FALSE;
|
||||
switch (objp->zo_type)
|
||||
{
|
||||
case DIRECTORY_OBJ:
|
||||
if (!xdr_directory_obj (xdrs, &objp->objdata_u.di_data))
|
||||
return FALSE;
|
||||
break;
|
||||
case GROUP_OBJ:
|
||||
if (!xdr_group_obj (xdrs, &objp->objdata_u.gr_data))
|
||||
return FALSE;
|
||||
break;
|
||||
case TABLE_OBJ:
|
||||
if (!xdr_table_obj (xdrs, &objp->objdata_u.ta_data))
|
||||
return FALSE;
|
||||
break;
|
||||
case ENTRY_OBJ:
|
||||
if (!xdr_entry_obj (xdrs, &objp->objdata_u.en_data))
|
||||
return FALSE;
|
||||
break;
|
||||
case LINK_OBJ:
|
||||
if (!xdr_link_obj (xdrs, &objp->objdata_u.li_data))
|
||||
return FALSE;
|
||||
break;
|
||||
case PRIVATE_OBJ:
|
||||
if (!xdr_bytes (xdrs, (char **) &objp->objdata_u.po_data.po_data_val,
|
||||
(u_int *) & objp->objdata_u.po_data.po_data_len, ~0))
|
||||
return FALSE;
|
||||
break;
|
||||
case NO_OBJ:
|
||||
break;
|
||||
case BOGUS_OBJ:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nis_oid (XDR *xdrs, nis_oid *objp)
|
||||
{
|
||||
if (!xdr_u_long (xdrs, &objp->ctime))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->mtime))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nis_object (XDR *xdrs, nis_object *objp)
|
||||
{
|
||||
if (!xdr_nis_oid (xdrs, &objp->zo_oid))
|
||||
return FALSE;
|
||||
if (!xdr_nis_name (xdrs, &objp->zo_name))
|
||||
return FALSE;
|
||||
if (!xdr_nis_name (xdrs, &objp->zo_owner))
|
||||
return FALSE;
|
||||
if (!xdr_nis_name (xdrs, &objp->zo_group))
|
||||
return FALSE;
|
||||
if (!xdr_nis_name (xdrs, &objp->zo_domain))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->zo_access))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->zo_ttl))
|
||||
return FALSE;
|
||||
if (!xdr_objdata (xdrs, &objp->zo_data))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nis_error (XDR *xdrs, nis_error *objp)
|
||||
{
|
||||
if (!xdr_enum (xdrs, (enum_t *) objp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nis_result (XDR *xdrs, nis_result *objp)
|
||||
{
|
||||
register long *buf;
|
||||
|
||||
if (xdrs->x_op == XDR_ENCODE)
|
||||
{
|
||||
if (!xdr_nis_error (xdrs, &objp->status))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->objects.objects_val,
|
||||
(u_int *) &objp->objects.objects_len, ~0,
|
||||
sizeof (nis_object), (xdrproc_t) xdr_nis_object))
|
||||
return FALSE;
|
||||
if (!xdr_netobj (xdrs, &objp->cookie))
|
||||
return FALSE;
|
||||
buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL)
|
||||
{
|
||||
if (!xdr_u_long (xdrs, &objp->zticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_u_long (xdrs, &objp->dticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_u_long (xdrs, &objp->aticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_u_long (xdrs, &objp->cticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
IXDR_PUT_U_LONG (buf, objp->zticks);
|
||||
IXDR_PUT_U_LONG (buf, objp->dticks);
|
||||
IXDR_PUT_U_LONG (buf, objp->aticks);
|
||||
IXDR_PUT_U_LONG (buf, objp->cticks);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else if (xdrs->x_op == XDR_DECODE)
|
||||
{
|
||||
if (!xdr_nis_error (xdrs, &objp->status))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_array (xdrs, (char **) &objp->objects.objects_val,
|
||||
(u_int *) &objp->objects.objects_len, ~0,
|
||||
sizeof (nis_object), (xdrproc_t) xdr_nis_object))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_netobj (xdrs, &objp->cookie))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
|
||||
if (buf == NULL)
|
||||
{
|
||||
if (!xdr_u_long (xdrs, &objp->zticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_u_long (xdrs, &objp->dticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_u_long (xdrs, &objp->aticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_u_long (xdrs, &objp->cticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
objp->zticks = IXDR_GET_U_LONG (buf);
|
||||
objp->dticks = IXDR_GET_U_LONG (buf);
|
||||
objp->aticks = IXDR_GET_U_LONG (buf);
|
||||
objp->cticks = IXDR_GET_U_LONG (buf);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!xdr_nis_error (xdrs, &objp->status))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_array (xdrs, (char **) &objp->objects.objects_val,
|
||||
(u_int *) &objp->objects.objects_len, ~0,
|
||||
sizeof (nis_object), (xdrproc_t) xdr_nis_object))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_netobj (xdrs, &objp->cookie))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_u_long (xdrs, &objp->zticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_u_long (xdrs, &objp->dticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_u_long (xdrs, &objp->aticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_u_long (xdrs, &objp->cticks))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_ns_request (XDR *xdrs, ns_request *objp)
|
||||
{
|
||||
if (!xdr_nis_name (xdrs, &objp->ns_name))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->ns_object.ns_object_val,
|
||||
(u_int *) &objp->ns_object.ns_object_len, 1,
|
||||
sizeof (nis_object), (xdrproc_t) xdr_nis_object))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_ib_request (XDR *xdrs, ib_request *objp)
|
||||
{
|
||||
if (!xdr_nis_name (xdrs, &objp->ibr_name))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->ibr_srch.ibr_srch_val,
|
||||
(u_int *) &objp->ibr_srch.ibr_srch_len, ~0,
|
||||
sizeof (nis_attr), (xdrproc_t) xdr_nis_attr))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->ibr_flags))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->ibr_obj.ibr_obj_val,
|
||||
(u_int *) &objp->ibr_obj.ibr_obj_len, 1,
|
||||
sizeof (nis_object), (xdrproc_t) xdr_nis_object))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->ibr_cbhost.ibr_cbhost_val,
|
||||
(u_int *) &objp->ibr_cbhost.ibr_cbhost_len, 1,
|
||||
sizeof (nis_server), (xdrproc_t) xdr_nis_server))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->ibr_bufsize))
|
||||
return FALSE;
|
||||
if (!xdr_netobj (xdrs, &objp->ibr_cookie))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_ping_args (XDR *xdrs, ping_args *objp)
|
||||
{
|
||||
if (!xdr_nis_name (xdrs, &objp->dir))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->stamp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_log_entry_t (XDR *xdrs, log_entry_t *objp)
|
||||
{
|
||||
if (!xdr_enum (xdrs, (enum_t *) objp))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_log_entry (XDR *xdrs, log_entry *objp)
|
||||
{
|
||||
if (!xdr_u_long (xdrs, &objp->le_time))
|
||||
return FALSE;
|
||||
if (!xdr_log_entry_t (xdrs, &objp->le_type))
|
||||
return FALSE;
|
||||
if (!xdr_nis_name (xdrs, &objp->le_princp))
|
||||
return FALSE;
|
||||
if (!xdr_nis_name (xdrs, &objp->le_name))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->le_attrs.le_attrs_val,
|
||||
(u_int *) &objp->le_attrs.le_attrs_len, ~0,
|
||||
sizeof (nis_attr), (xdrproc_t) xdr_nis_attr))
|
||||
return FALSE;
|
||||
if (!xdr_nis_object (xdrs, &objp->le_object))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_log_result (XDR *xdrs, log_result *objp)
|
||||
{
|
||||
if (!xdr_nis_error (xdrs, &objp->lr_status))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_netobj (xdrs, &objp->lr_cookie))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_array (xdrs, (char **) &objp->lr_entries.lr_entries_val,
|
||||
(u_int *) &objp->lr_entries.lr_entries_len, ~0,
|
||||
sizeof (log_entry), (xdrproc_t) xdr_log_entry))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_cp_result (XDR *xdrs, cp_result *objp)
|
||||
{
|
||||
if (!xdr_nis_error (xdrs, &objp->cp_status))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->cp_zticks))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->cp_dticks))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nis_tag (XDR *xdrs, nis_tag *objp)
|
||||
{
|
||||
if (!xdr_u_long (xdrs, &objp->tag_type))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!xdr_string (xdrs, &objp->tag_val, 1024))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_nis_taglist (XDR *xdrs, nis_taglist *objp)
|
||||
{
|
||||
if (!xdr_array (xdrs, (char **) &objp->tags.tags_val,
|
||||
(u_int *) &objp->tags.tags_len, ~0, sizeof (nis_tag),
|
||||
(xdrproc_t) xdr_nis_tag))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_dump_args (XDR *xdrs, dump_args *objp)
|
||||
{
|
||||
if (!xdr_nis_name (xdrs, &objp->da_dir))
|
||||
return FALSE;
|
||||
if (!xdr_u_long (xdrs, &objp->da_time))
|
||||
return FALSE;
|
||||
if (!xdr_array (xdrs, (char **) &objp->da_cbhost.da_cbhost_val,
|
||||
(u_int *) &objp->da_cbhost.da_cbhost_len, 1,
|
||||
sizeof (nis_server), (xdrproc_t) xdr_nis_server))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_fd_args (XDR *xdrs, fd_args *objp)
|
||||
{
|
||||
if (!xdr_nis_name (xdrs, &objp->dir_name))
|
||||
return FALSE;
|
||||
if (!xdr_nis_name (xdrs, &objp->requester))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
xdr_fd_result (XDR *xdrs, fd_result *objp)
|
||||
{
|
||||
if (!xdr_nis_error (xdrs, &objp->status))
|
||||
return FALSE;
|
||||
if (!xdr_nis_name (xdrs, &objp->source))
|
||||
return FALSE;
|
||||
if (!xdr_bytes (xdrs, (char **) &objp->dir_data.dir_data_val,
|
||||
(u_int *) &objp->dir_data.dir_data_len, ~0))
|
||||
return FALSE;
|
||||
if (!xdr_bytes (xdrs, (char **) &objp->signature.signature_val,
|
||||
(u_int *) &objp->signature.signature_len, ~0))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@uni-paderborn.de>, 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 _NIS_NSS_NISPLUS_H
|
||||
#define _NIS_NSS_NISPLUS_H 1
|
||||
|
||||
#include <rpcsvc/nis.h>
|
||||
|
||||
#include "nsswitch.h"
|
||||
|
||||
|
||||
/* Convert NIS+ error number to NSS error number. */
|
||||
static enum nss_status niserr2nss_tab[] =
|
||||
{
|
||||
[NIS_SUCCESS] = NSS_STATUS_SUCCESS,
|
||||
[NIS_S_SUCCESS] = NSS_STATUS_SUCCESS,
|
||||
[NIS_NOTFOUND] = NSS_STATUS_NOTFOUND,
|
||||
[NIS_S_NOTFOUND] = NSS_STATUS_TRYAGAIN,
|
||||
[NIS_CACHEEXPIRED] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NAMEUNREACHABLE] = NSS_STATUS_TRYAGAIN,
|
||||
[NIS_UNKNOWNOBJ] = NSS_STATUS_NOTFOUND,
|
||||
[NIS_TRYAGAIN] = NSS_STATUS_TRYAGAIN,
|
||||
[NIS_SYSTEMERROR] = NSS_STATUS_UNAVAIL, /* Maybe TRYAGAIN ? */
|
||||
[NIS_CHAINBROKEN] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_PERMISSION] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOTOWNER] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOT_ME] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOMEMORY] = NSS_STATUS_TRYAGAIN,
|
||||
[NIS_NAMEEXISTS] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOTMASTER] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_INVALIDOBJ] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_BADNAME] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOCALLBACK] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_CBRESULTS] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOSUCHNAME] = NSS_STATUS_NOTFOUND,
|
||||
[NIS_NOTUNIQUE] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_IBMODERROR] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOSUCHTABLE] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_TYPEMISMATCH] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_LINKNAMEERROR] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_PARTIAL] = NSS_STATUS_NOTFOUND,
|
||||
[NIS_TOOMANYATTRS] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_RPCERROR] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_BADATTRIBUTE] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOTSEARCHABLE] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_CBERROR] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_FOREIGNNS] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_BADOBJECT] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOTSAMEOBJ] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_MODFAIL] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_BADREQUEST] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOTEMPTY] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_COLDSTART_ERR] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_RESYNC] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_FAIL] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_UNAVAIL] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_RES2BIG] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_SRVAUTH] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_CLNTAUTH] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOFILESPACE] = NSS_STATUS_UNAVAIL,
|
||||
[NIS_NOPROC] = NSS_STATUS_TRYAGAIN,
|
||||
[NIS_DUMPLATER] = NSS_STATUS_UNAVAIL
|
||||
};
|
||||
#define NISERR_COUNT (sizeof (niserr2nss_tab) / sizeof (niserr2nss_tab[0]))
|
||||
|
||||
static inline enum nss_status
|
||||
niserr2nss (int errval)
|
||||
{
|
||||
if ((unsigned int) errval > NISERR_COUNT)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
return niserr2nss_tab[errval];
|
||||
}
|
||||
|
||||
#endif /* nis/nss-nisplus.h */
|
||||
@@ -204,7 +204,7 @@ _nss_nis_getservbyname_r (const char *name, char *protocol,
|
||||
enum nss_status status;
|
||||
int found;
|
||||
|
||||
if (name == NULL || protocol == NULL)
|
||||
if (name == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
@@ -219,7 +219,7 @@ _nss_nis_getservbyname_r (const char *name, char *protocol,
|
||||
((status = internal_nis_getservent_r (serv, buffer, buflen, &data))
|
||||
== NSS_STATUS_SUCCESS))
|
||||
{
|
||||
if (strcmp (serv->s_proto, protocol) == 0)
|
||||
if (protocol == NULL || strcmp (serv->s_proto, protocol) == 0)
|
||||
{
|
||||
char **cp;
|
||||
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <aliases.h>
|
||||
#include <libc-lock.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include "nss-nisplus.h"
|
||||
|
||||
__libc_lock_define_initialized (static, lock)
|
||||
|
||||
static nis_result *result = NULL;
|
||||
static nis_name *names = NULL;
|
||||
|
||||
#define NISENTRYVAL(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
|
||||
|
||||
#define NISENTRYLEN(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len)
|
||||
|
||||
static int
|
||||
_nss_nisplus_parse_aliasent (nis_result *result, struct aliasent *alias,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_len != 1 ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"mail_aliases") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 2)
|
||||
return -1;
|
||||
else
|
||||
{
|
||||
char *first_unused = buffer + NISENTRYLEN(0, 1, result) + 1;
|
||||
size_t room_left =
|
||||
buflen - (buflen % __alignof__ (char *)) -
|
||||
NISENTRYLEN(0, 1, result) - 2;
|
||||
char *line;
|
||||
char *cp;
|
||||
|
||||
if (NISENTRYLEN(0, 1, result) >= buflen)
|
||||
{
|
||||
/* The line is too long for our buffer. */
|
||||
no_more_room:
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy (buffer, NISENTRYVAL(0, 1, result), NISENTRYLEN(0, 1, result));
|
||||
buffer[NISENTRYLEN(0, 1, result)] = '\0';
|
||||
}
|
||||
|
||||
if (NISENTRYLEN(0, 0, result) >= room_left)
|
||||
goto no_more_room;
|
||||
|
||||
alias->alias_local = 0;
|
||||
alias->alias_members_len = 0;
|
||||
*first_unused = '\0';
|
||||
++first_unused;
|
||||
strcpy (first_unused, NISENTRYVAL(0, 0, result));
|
||||
first_unused[NISENTRYLEN(0, 0, result)] = '\0';
|
||||
alias->alias_name = first_unused;
|
||||
|
||||
/* Terminate the line for any case. */
|
||||
cp = strpbrk (alias->alias_name, "#\n");
|
||||
if (cp != NULL)
|
||||
*cp = '\0';
|
||||
|
||||
first_unused += strlen (alias->alias_name) +1;
|
||||
/* Adjust the pointer so it is aligned for
|
||||
storing pointers. */
|
||||
first_unused += __alignof__ (char *) - 1;
|
||||
first_unused -= ((first_unused - (char *) 0) % __alignof__ (char *));
|
||||
alias->alias_members = (char **) first_unused;
|
||||
|
||||
line = buffer;
|
||||
|
||||
while (*line != '\0')
|
||||
{
|
||||
/* Skip leading blanks. */
|
||||
while (isspace (*line))
|
||||
line++;
|
||||
|
||||
if (*line == '\0')
|
||||
break;
|
||||
|
||||
if (room_left < sizeof (char *))
|
||||
goto no_more_room;
|
||||
room_left -= sizeof (char *);
|
||||
alias->alias_members[alias->alias_members_len] = line;
|
||||
|
||||
while (*line != '\0' && *line != ',')
|
||||
line++;
|
||||
|
||||
if (line != alias->alias_members[alias->alias_members_len])
|
||||
{
|
||||
*line = '\0';
|
||||
line++;
|
||||
alias->alias_members_len++;
|
||||
}
|
||||
}
|
||||
|
||||
return alias->alias_members_len == 0 ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_setaliasent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_endaliasent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum nss_status
|
||||
internal_nisplus_getaliasent_r (struct aliasent *alias,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
/* Get the next entry until we found a correct one. */
|
||||
do
|
||||
{
|
||||
if (result == NULL)
|
||||
{
|
||||
names = nis_getnames("mail_aliases.org_dir");
|
||||
if (names == NULL || names[0] == NULL)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
result = nis_first_entry(names[0]);
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *res2;
|
||||
|
||||
res2 = nis_next_entry(names[0], &result->cookie);
|
||||
nis_freeresult (result);
|
||||
result = res2;
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_aliasent (result, alias, buffer, buflen);
|
||||
} while (!parse_res);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getaliasent_r (struct aliasent *result, char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
int status;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = internal_nisplus_getaliasent_r (result, buffer, buflen);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getaliasbyname_r (const char *name, struct aliasent *alias,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
if (name == NULL || strlen(name) > 8)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
else
|
||||
{
|
||||
nis_result *result;
|
||||
char buf[strlen (name) + 30];
|
||||
|
||||
sprintf(buf, "[name=%s],mail_aliases.org_dir", name);
|
||||
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
|
||||
parse_res = _nss_nisplus_parse_aliasent (result, alias, buffer, buflen);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <libc-lock.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/ether.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
#include <netinet/if_ether.h>
|
||||
|
||||
#include "nss-nisplus.h"
|
||||
|
||||
__libc_lock_define_initialized (static, lock)
|
||||
|
||||
static nis_result *result = NULL;
|
||||
static nis_name *names = NULL;
|
||||
|
||||
/* Because the `ethers' lookup does not fit so well in the scheme so
|
||||
we define a dummy struct here which helps us to use the available
|
||||
functions. */
|
||||
struct etherent
|
||||
{
|
||||
const char *e_name;
|
||||
struct ether_addr e_addr;
|
||||
};
|
||||
struct etherent_data {};
|
||||
|
||||
#define ENTNAME etherent
|
||||
#define DATABASE "ethers"
|
||||
#include "../../nss/nss_files/files-parse.c"
|
||||
LINE_PARSER
|
||||
("#",
|
||||
/* Read the ethernet address: 6 x 8bit hexadecimal number. */
|
||||
{
|
||||
size_t cnt;
|
||||
|
||||
for (cnt = 0; cnt < 6; ++cnt)
|
||||
{
|
||||
unsigned int number;
|
||||
|
||||
if (cnt < 5)
|
||||
INT_FIELD (number, ISCOLON , 0, 16, (unsigned int))
|
||||
else
|
||||
INT_FIELD (number, isspace, 0, 16, (unsigned int))
|
||||
|
||||
if (number > 0xff)
|
||||
return 0;
|
||||
result->e_addr.ether_addr_octet[cnt] = number;
|
||||
}
|
||||
};
|
||||
STRING_FIELD (result->e_name, isspace, 1);
|
||||
)
|
||||
|
||||
#define NISENTRYVAL(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
|
||||
|
||||
#define NISENTRYLEN(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len)
|
||||
|
||||
static int
|
||||
_nss_nisplus_parse_etherent (nis_result *result, struct etherent *ether,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
char *p = buffer;
|
||||
size_t room_left = buflen;
|
||||
struct parser_data *data = (void *) buffer;
|
||||
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_len != 1 ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"ethers_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 2)
|
||||
return -1;
|
||||
|
||||
memset (p, '\0', room_left);
|
||||
|
||||
/* Generate the ether entry format and use the normal parser */
|
||||
if (NISENTRYLEN (0, 0, result) +1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strncpy (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result));
|
||||
room_left -= (NISENTRYLEN (0, 0, result) +1);
|
||||
|
||||
if (NISENTRYLEN (0, 1, result) +1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, "\t");
|
||||
strncat (p, NISENTRYVAL (0, 1, result), NISENTRYLEN (0, 1, result));
|
||||
room_left -= (NISENTRYLEN (0, 1, result) + 1);
|
||||
|
||||
return _nss_files_parse_etherent (p,ether, data, buflen);
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_setetherent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_endetherent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum nss_status
|
||||
internal_nisplus_getetherent_r (struct etherent *ether, char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
/* Get the next entry until we found a correct one. */
|
||||
do
|
||||
{
|
||||
if (result == NULL)
|
||||
{
|
||||
names = nis_getnames("ethers.org_dir");
|
||||
if (names == NULL || names[0] == NULL)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
result = nis_first_entry(names[0]);
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *res2;
|
||||
|
||||
res2 = nis_next_entry(names[0], &result->cookie);
|
||||
nis_freeresult (result);
|
||||
result = res2;
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_etherent (result, ether, buffer, buflen);
|
||||
} while (!parse_res);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getetherent_r (struct etherent *result, char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
int status;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = internal_nisplus_getetherent_r (result, buffer, buflen);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_gethostton_r (const char *name, struct etherent *eth,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
if (name == NULL)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
else
|
||||
{
|
||||
nis_result *result;
|
||||
char buf[strlen (name) + 255];
|
||||
|
||||
sprintf(buf, "[name=%s],ethers.org_dir", name);
|
||||
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
|
||||
parse_res = _nss_nisplus_parse_etherent (result, eth, buffer, buflen);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getntohost_r (const struct ether_addr *addr,
|
||||
struct etherent *eth,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
nis_result *result;
|
||||
char buf[255];
|
||||
|
||||
if (addr == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
memset (&buf, '\0', sizeof (buf));
|
||||
snprintf(buf, sizeof (buf), "[addr=%x:%x:%x:%x:%x:%x],ethers.org_dir",
|
||||
addr->ether_addr_octet[0], addr->ether_addr_octet[1],
|
||||
addr->ether_addr_octet[2], addr->ether_addr_octet[3],
|
||||
addr->ether_addr_octet[4], addr->ether_addr_octet[5]);
|
||||
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
|
||||
parse_res = _nss_nisplus_parse_etherent (result, eth, buffer, buflen);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <grp.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <libc-lock.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include "nss-nisplus.h"
|
||||
|
||||
__libc_lock_define_initialized (static, lock);
|
||||
|
||||
static nis_result *result = NULL;
|
||||
static nis_name *names = NULL;
|
||||
|
||||
#define NISENTRYVAL(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
|
||||
|
||||
#define NISENTRYLEN(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len)
|
||||
|
||||
#define STRUCTURE group
|
||||
#define ENTNAME grent
|
||||
struct grent_data {};
|
||||
|
||||
#define TRAILING_LIST_MEMBER gr_mem
|
||||
#define TRAILING_LIST_SEPARATOR_P(c) ((c) == ',')
|
||||
#include "../../nss/nss_files/files-parse.c"
|
||||
LINE_PARSER
|
||||
(,
|
||||
STRING_FIELD (result->gr_name, ISCOLON, 0);
|
||||
if (line[0] == '\0'
|
||||
&& (result->gr_name[0] == '+' || result->gr_name[0] == '-'))
|
||||
{
|
||||
result->gr_passwd = NULL;
|
||||
result->gr_gid = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
STRING_FIELD (result->gr_passwd, ISCOLON, 0);
|
||||
if (result->gr_name[0] == '+' || result->gr_name[0] == '-')
|
||||
INT_FIELD_MAYBE_NULL (result->gr_gid, ISCOLON, 0, 10, , 0)
|
||||
else
|
||||
INT_FIELD (result->gr_gid, ISCOLON, 0, 10,)
|
||||
}
|
||||
)
|
||||
|
||||
static int
|
||||
_nss_nisplus_parse_grent (nis_result * result, struct group *gr,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
#if 0
|
||||
/* XXX here is a bug, sometimes we get some special characters at the
|
||||
end of a line */
|
||||
char *first_unused = buffer;
|
||||
size_t room_left = buflen;
|
||||
char *line;
|
||||
int count;
|
||||
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_len != 1 ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"group_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 4)
|
||||
return -1;
|
||||
|
||||
if (NISENTRYLEN (0, 0, result) >= room_left)
|
||||
{
|
||||
/* The line is too long for our buffer. */
|
||||
no_more_room:
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL (0, 0, result),
|
||||
NISENTRYLEN (0, 0, result));
|
||||
first_unused[NISENTRYLEN (0, 0, result)] = '\0';
|
||||
gr->gr_name = first_unused;
|
||||
room_left -= (strlen (first_unused) + 1);
|
||||
first_unused += strlen (first_unused) + 1;
|
||||
|
||||
if (NISENTRYLEN (0, 1, result) >= room_left)
|
||||
goto no_more_room;
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL (0, 1, result),
|
||||
NISENTRYLEN (0, 1, result));
|
||||
first_unused[NISENTRYLEN (0, 1, result)] = '\0';
|
||||
gr->gr_passwd = first_unused;
|
||||
room_left -= (strlen (first_unused) + 1);
|
||||
first_unused += strlen (first_unused) + 1;
|
||||
|
||||
if (NISENTRYLEN (0, 2, result) >= room_left)
|
||||
goto no_more_room;
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL (0, 2, result),
|
||||
NISENTRYLEN (0, 2, result));
|
||||
first_unused[NISENTRYLEN (0, 2, result)] = '\0';
|
||||
gr->gr_gid = atoi (first_unused);
|
||||
room_left -= (strlen (first_unused) + 1);
|
||||
first_unused += strlen (first_unused) + 1;
|
||||
|
||||
if (NISENTRYLEN (0, 3, result) >= room_left)
|
||||
goto no_more_room;
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL (0, 3, result),
|
||||
NISENTRYLEN (0, 3, result));
|
||||
first_unused[NISENTRYLEN (0, 3, result)] = '\0';
|
||||
line = first_unused;
|
||||
room_left -= (strlen (line) + 1);
|
||||
first_unused += strlen (line) + 1;
|
||||
/* Adjust the pointer so it is aligned for
|
||||
storing pointers. */
|
||||
first_unused += __alignof__ (char *) - 1;
|
||||
first_unused -= ((first_unused - (char *) 0) % __alignof__ (char *));
|
||||
gr->gr_mem = (char **) first_unused;
|
||||
|
||||
count = 0;
|
||||
while (*line != '\0')
|
||||
{
|
||||
/* Skip leading blanks. */
|
||||
while (isspace (*line))
|
||||
++line;
|
||||
|
||||
if (*line == '\0')
|
||||
break;
|
||||
|
||||
if (room_left < sizeof (char *))
|
||||
goto no_more_room;
|
||||
room_left -= sizeof (char *);
|
||||
gr->gr_mem[count] = line;
|
||||
|
||||
while (*line != '\0' && *line != ',' && !isspace(*line))
|
||||
++line;
|
||||
|
||||
if (line != gr->gr_mem[count])
|
||||
{
|
||||
*line = '\0';
|
||||
++line;
|
||||
++count;
|
||||
}
|
||||
else
|
||||
gr->gr_mem[count] = NULL;
|
||||
}
|
||||
if (room_left < sizeof (char *))
|
||||
goto no_more_room;
|
||||
room_left -= sizeof (char *);
|
||||
gr->gr_mem[count] = NULL;
|
||||
|
||||
return 1;
|
||||
#else
|
||||
char *p = buffer;
|
||||
size_t room_left = buflen;
|
||||
struct parser_data *data = (void *) buffer;
|
||||
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_len != 1 ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"group_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 4)
|
||||
return -1;
|
||||
|
||||
memset (p, '\0', room_left);
|
||||
|
||||
if (NISENTRYLEN (0, 0, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strncpy (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result));
|
||||
room_left -= (NISENTRYLEN (0, 0, result) + 1);
|
||||
strcat (p, ":");
|
||||
|
||||
if (NISENTRYLEN (0, 1, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strncat (p, NISENTRYVAL (0, 1, result), NISENTRYLEN (0, 1, result));
|
||||
room_left -= (NISENTRYLEN (0, 1, result) + 1);
|
||||
strcat (p, ":");
|
||||
if (NISENTRYLEN (0, 2, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strncat (p, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result));
|
||||
room_left -= (NISENTRYLEN (0, 2, result) + 1);
|
||||
strcat (p, ":");
|
||||
if (NISENTRYLEN (0, 3, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strncat (p, NISENTRYVAL (0, 3, result), NISENTRYLEN (0, 3, result));
|
||||
room_left -= (NISENTRYLEN (0, 3, result) + 1);
|
||||
|
||||
return _nss_files_parse_grent (p, gr, data, buflen);
|
||||
#endif
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_setgrent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_endgrent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum nss_status
|
||||
internal_nisplus_getgrent_r (struct group *gr, char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
/* Get the next entry until we found a correct one. */
|
||||
do
|
||||
{
|
||||
if (result == NULL)
|
||||
{
|
||||
names = nis_getnames ("group.org_dir");
|
||||
if (names == NULL || names[0] == NULL)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
result = nis_first_entry (names[0]);
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *res;
|
||||
|
||||
res = nis_next_entry (names[0], &result->cookie);
|
||||
nis_freeresult (result);
|
||||
result = res;
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_grent (result, gr, buffer, buflen);
|
||||
}
|
||||
while (!parse_res);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getgrent_r (struct group *result, char *buffer, size_t buflen)
|
||||
{
|
||||
int status;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = internal_nisplus_getgrent_r (result, buffer, buflen);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getgrnam_r (const char *name, struct group *gr,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
if (name == NULL || strlen (name) > 8)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
else
|
||||
{
|
||||
nis_result *result;
|
||||
char buf[strlen (name) + 24];
|
||||
|
||||
sprintf (buf, "[name=%s],group.org_dir", name);
|
||||
|
||||
result = nis_list (buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
enum nss_status status = niserr2nss (result->status);
|
||||
|
||||
nis_freeresult (result);
|
||||
return status;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_grent (result, gr, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getgrgid_r (const gid_t gid, struct group *gr,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
nis_result *result;
|
||||
char buf[36];
|
||||
|
||||
sprintf (buf, "[gid=%d],group.org_dir", gid);
|
||||
|
||||
result = nis_list (buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
enum nss_status status = niserr2nss (result->status);
|
||||
|
||||
nis_freeresult (result);
|
||||
return status;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_grent (result, gr, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
@@ -0,0 +1,412 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <libc-lock.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include "nss-nisplus.h"
|
||||
|
||||
__libc_lock_define_initialized (static, lock)
|
||||
|
||||
static nis_result *result = NULL;
|
||||
static nis_name *names = NULL;
|
||||
|
||||
#define NISENTRYVAL(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
|
||||
|
||||
#define NISENTRYLEN(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len)
|
||||
|
||||
/* Get implementation for some internal functions. */
|
||||
#include "../../resolv/mapv4v6addr.h"
|
||||
#include "../../resolv/mapv4v6hostent.h"
|
||||
|
||||
#define ENTNAME hostent
|
||||
#define DATABASE "hosts"
|
||||
#define NEED_H_ERRNO
|
||||
|
||||
#define ENTDATA hostent_data
|
||||
struct hostent_data
|
||||
{
|
||||
unsigned char host_addr[16]; /* IPv4 or IPv6 address. */
|
||||
char *h_addr_ptrs[2]; /* Points to that and null terminator. */
|
||||
};
|
||||
|
||||
#define TRAILING_LIST_MEMBER h_aliases
|
||||
#define TRAILING_LIST_SEPARATOR_P isspace
|
||||
#include "../../nss/nss_files/files-parse.c"
|
||||
LINE_PARSER
|
||||
("#",
|
||||
{
|
||||
char *addr;
|
||||
|
||||
STRING_FIELD (addr, isspace, 1);
|
||||
|
||||
/* Parse address. */
|
||||
if ((_res.options & RES_USE_INET6)
|
||||
&& inet_pton (AF_INET6, addr, entdata->host_addr) > 0)
|
||||
{
|
||||
result->h_addrtype = AF_INET6;
|
||||
result->h_length = IN6ADDRSZ;
|
||||
}
|
||||
else
|
||||
if (inet_pton (AF_INET, addr, entdata->host_addr) > 0)
|
||||
{
|
||||
if (_res.options & RES_USE_INET6)
|
||||
{
|
||||
map_v4v6_address ((char *) entdata->host_addr,
|
||||
(char *) entdata->host_addr);
|
||||
result->h_addrtype = AF_INET6;
|
||||
result->h_length = IN6ADDRSZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->h_addrtype = AF_INET;
|
||||
result->h_length = INADDRSZ;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* Illegal address: ignore line. */
|
||||
return 0;
|
||||
|
||||
/* Store a pointer to the address in the expected form. */
|
||||
entdata->h_addr_ptrs[0] = entdata->host_addr;
|
||||
entdata->h_addr_ptrs[1] = NULL;
|
||||
result->h_addr_list = entdata->h_addr_ptrs;
|
||||
|
||||
/* If we need the host entry in IPv6 form change it now. */
|
||||
if (_res.options & RES_USE_INET6)
|
||||
{
|
||||
char *bufptr = data->linebuffer;
|
||||
size_t buflen = (char *) data + datalen - bufptr;
|
||||
map_v4v6_hostent (result, &bufptr, &buflen);
|
||||
}
|
||||
|
||||
STRING_FIELD (result->h_name, isspace, 1);
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
static int
|
||||
_nss_nisplus_parse_hostent (nis_result *result, struct hostent *host,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
char *p = buffer;
|
||||
size_t room_left = buflen;
|
||||
int parse_res, i;
|
||||
struct parser_data *data = (void *) buffer;
|
||||
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"hosts_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 4)
|
||||
return -1;
|
||||
|
||||
memset (p, '\0', room_left);
|
||||
|
||||
/* Generate the hosts entry format and use the normal parser */
|
||||
if (NISENTRYLEN (0, 2, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strncpy (p, NISENTRYVAL (0, 2, result),
|
||||
NISENTRYLEN (0, 2, result));
|
||||
room_left -= (NISENTRYLEN (0, 2, result) + 1);
|
||||
|
||||
if (NISENTRYLEN (0, 0, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, "\t");
|
||||
strncat (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result));
|
||||
room_left -= (NISENTRYLEN (0, 0, result) + 1);
|
||||
/* + 1: We overwrite the last \0 */
|
||||
|
||||
for (i = 1; i < result->objects.objects_len; i++)
|
||||
{
|
||||
if (NISENTRYLEN (i, 1, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, " ");
|
||||
strcat (p, NISENTRYVAL (i, 1, result));
|
||||
room_left -= (NISENTRYLEN (i, 1, result) + 1);
|
||||
}
|
||||
|
||||
parse_res = parse_line (p, host, data, buflen);
|
||||
|
||||
return parse_res;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_sethostent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_endhostent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum nss_status
|
||||
internal_nisplus_gethostent_r (struct hostent *host, char *buffer,
|
||||
size_t buflen, int *herrnop)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
/* Get the next entry until we found a correct one. */
|
||||
do
|
||||
{
|
||||
if (result == NULL)
|
||||
{
|
||||
names = nis_getnames("hosts.org_dir");
|
||||
if (names == NULL || names[0] == NULL)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
result = nis_first_entry(names[0]);
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
int retval;
|
||||
|
||||
retval = niserr2nss (result->status);
|
||||
if (retval == NSS_STATUS_TRYAGAIN)
|
||||
{
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
__set_errno (EAGAIN);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *res2;
|
||||
|
||||
res2 = nis_next_entry(names[0], &result->cookie);
|
||||
nis_freeresult (result);
|
||||
result = res2;
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
int retval;
|
||||
|
||||
retval = niserr2nss (result->status);
|
||||
if (retval == NSS_STATUS_TRYAGAIN)
|
||||
{
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
__set_errno (EAGAIN);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_hostent (result, host, buffer, buflen);
|
||||
if (!parse_res && errno == ERANGE)
|
||||
{
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
}
|
||||
|
||||
} while (!parse_res);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_gethostent_r (struct hostent *result, char *buffer,
|
||||
size_t buflen, int *herrnop)
|
||||
{
|
||||
int status;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = internal_nisplus_gethostent_r (result, buffer, buflen, herrnop);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host,
|
||||
char *buffer, size_t buflen, int *herrnop)
|
||||
{
|
||||
int parse_res, retval;
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *result;
|
||||
char buf[strlen (name) + 255];
|
||||
|
||||
/* Search at first in the alias list, and use the correct name
|
||||
for the next search */
|
||||
sprintf(buf, "[name=%s],hosts.org_dir", name);
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
/* If we do not find it, try it as original name. But if the
|
||||
database is correct, we should find it in the first case, too */
|
||||
if ((result->status != NIS_SUCCESS &&
|
||||
result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"hosts_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len
|
||||
< 3)
|
||||
sprintf(buf, "[cname=%s],hosts.org_dir", name);
|
||||
else
|
||||
sprintf(buf, "[cname=%s],hosts.org_dir", NISENTRYVAL(0, 0, result));
|
||||
|
||||
nis_freeresult (result);
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
retval = niserr2nss (result->status);
|
||||
if (retval != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
if (retval == NSS_STATUS_TRYAGAIN)
|
||||
{
|
||||
__set_errno (EAGAIN);
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
}
|
||||
nis_freeresult (result);
|
||||
return retval;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_hostent (result, host, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_gethostbyname_r (const char *name, struct hostent *host,
|
||||
char *buffer, size_t buflen, int *h_errnop)
|
||||
{
|
||||
if (_res.options & RES_USE_INET6)
|
||||
{
|
||||
enum nss_status status;
|
||||
|
||||
status = _nss_nisplus_gethostbyname2_r (name, AF_INET6, host, buffer,
|
||||
buflen, h_errnop);
|
||||
if (status == NSS_STATUS_SUCCESS)
|
||||
return status;
|
||||
}
|
||||
|
||||
return _nss_nisplus_gethostbyname2_r (name, AF_INET, host, buffer,
|
||||
buflen, h_errnop);
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_gethostbyaddr_r (const char *addr, struct hostent *host,
|
||||
char *buffer, size_t buflen, int *herrnop)
|
||||
{
|
||||
if (addr == NULL)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
else
|
||||
{
|
||||
nis_result *result;
|
||||
char buf[24 + strlen (addr)];
|
||||
int retval, parse_res;
|
||||
|
||||
sprintf(buf, "[addr=%s],hosts.org_dir", addr);
|
||||
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
retval = niserr2nss (result->status);
|
||||
if (retval != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
if (retval == NSS_STATUS_TRYAGAIN)
|
||||
{
|
||||
__set_errno (EAGAIN);
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
}
|
||||
nis_freeresult (result);
|
||||
return retval;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_hostent (result, host, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <netgroup.h>
|
||||
#include <libc-lock.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include "nss-nisplus.h"
|
||||
|
||||
__libc_lock_define_initialized (static, lock)
|
||||
|
||||
static char *data = NULL;
|
||||
static size_t data_size = 0;
|
||||
static char *cursor = NULL;;
|
||||
|
||||
extern enum nss_status
|
||||
_nss_netgroup_parseline (char **cursor, struct __netgrent *result,
|
||||
char *buffer, size_t buflen);
|
||||
|
||||
#define NISENTRYVAL(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
|
||||
|
||||
#define NISENTRYLEN(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len)
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_setnetgrent (char *group)
|
||||
|
||||
{
|
||||
enum nss_status status;
|
||||
nis_result *result;
|
||||
char buf[strlen (group) + 30];
|
||||
int i;
|
||||
size_t len;
|
||||
|
||||
if (group == NULL || group[0] == '\0')
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
status = NSS_STATUS_SUCCESS;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (data != NULL)
|
||||
{
|
||||
free (data);
|
||||
data = NULL;
|
||||
data_size = 0;
|
||||
cursor = NULL;
|
||||
}
|
||||
|
||||
sprintf(buf, "[name=%s],netgroup.org_dir", group);
|
||||
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
status = niserr2nss (result->status);
|
||||
|
||||
len = 0;
|
||||
for (i = 0; i < result->objects.objects_len; i++)
|
||||
len += 1 + NISENTRYLEN (i, 1, result) + 1 + NISENTRYLEN(i,2,result)
|
||||
+ 1 + NISENTRYLEN(i,3,result) + 1 + NISENTRYLEN(i,4,result) + 2;
|
||||
|
||||
data = malloc (len+1);
|
||||
memset (data, '\0', len+1);
|
||||
|
||||
for (i = 0; i < result->objects.objects_len; i++)
|
||||
{
|
||||
strncat (data, NISENTRYVAL (i, 1, result), NISENTRYLEN (i, 1, result));
|
||||
strcat (data," (");
|
||||
strncat (data, NISENTRYVAL(i,2,result), NISENTRYLEN (i, 2, result));
|
||||
strcat (data, ",");
|
||||
strncat (data, NISENTRYVAL(i,3,result), NISENTRYLEN (i, 3, result));
|
||||
strcat (data, ",");
|
||||
strncat (data, NISENTRYVAL(i,4,result), NISENTRYLEN (i, 4, result));
|
||||
strcat (data, ") ");
|
||||
}
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_endnetgrent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (data != NULL)
|
||||
{
|
||||
free (data);
|
||||
data = NULL;
|
||||
data_size = 0;
|
||||
cursor = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getnetgrent_r (struct __netgrent *result,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
enum nss_status status;
|
||||
|
||||
if (cursor == NULL)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = _nss_netgroup_parseline (&cursor, result, buffer, buflen);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <libc-lock.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include "nss-nisplus.h"
|
||||
|
||||
/* Get the declaration of the parser function. */
|
||||
#define ENTNAME netent
|
||||
#define DATABASE "networks"
|
||||
#define TRAILING_LIST_MEMBER n_aliases
|
||||
#define TRAILING_LIST_SEPARATOR_P isspace
|
||||
#include "../nss/nss_files/files-parse.c"
|
||||
LINE_PARSER
|
||||
("#",
|
||||
{
|
||||
char *addr;
|
||||
|
||||
STRING_FIELD (result->n_name, isspace, 1);
|
||||
|
||||
STRING_FIELD (addr, isspace, 1);
|
||||
result->n_net = inet_network (addr);
|
||||
|
||||
})
|
||||
|
||||
__libc_lock_define_initialized (static, lock)
|
||||
|
||||
static nis_result *result = NULL;
|
||||
static nis_name *names = NULL;
|
||||
|
||||
#define NISENTRYVAL(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
|
||||
|
||||
#define NISENTRYLEN(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len)
|
||||
|
||||
|
||||
static int
|
||||
_nss_nisplus_parse_netent (nis_result *result, struct netent *network,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
char *p = buffer;
|
||||
size_t room_left = buflen;
|
||||
int i;
|
||||
struct parser_data *data = (void *) buffer;
|
||||
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"networks_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 3)
|
||||
return -1;
|
||||
|
||||
/* Generate the network entry format and use the normal parser */
|
||||
if (NISENTRYLEN (0, 0, result) +1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset (p, '\0', room_left);
|
||||
|
||||
strncpy (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result));
|
||||
room_left -= (NISENTRYLEN (0, 0, result) +1);
|
||||
|
||||
if (NISENTRYLEN (0, 2, result) +1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, "\t");
|
||||
strncat (p, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result));
|
||||
room_left -= (NISENTRYLEN (0, 2, result) + 1);
|
||||
/* + 1: We overwrite the last \0 */
|
||||
|
||||
for (i = 1; i < result->objects.objects_len; i++)
|
||||
/* XXX should we start with i = 0 or with i = 1 ? */
|
||||
{
|
||||
if (NISENTRYLEN (i, 1, result) +1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, " ");
|
||||
strncat (p, NISENTRYVAL (i, 1, result), NISENTRYLEN (i, 1, result));
|
||||
room_left -= (NISENTRYLEN (i, 1, result) + 1);
|
||||
}
|
||||
|
||||
return _nss_files_parse_netent (p, network, data, buflen);
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_setnetent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_endnetent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum nss_status
|
||||
internal_nisplus_getnetent_r (struct netent *network, char *buffer,
|
||||
size_t buflen, int *herrnop)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
/* Get the next entry until we found a correct one. */
|
||||
do
|
||||
{
|
||||
if (result == NULL)
|
||||
{
|
||||
names = nis_getnames("networks.org_dir");
|
||||
if (names == NULL || names[0] == NULL)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
result = nis_first_entry(names[0]);
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
int retval;
|
||||
|
||||
retval = niserr2nss (result->status);
|
||||
if (retval == NSS_STATUS_TRYAGAIN)
|
||||
{
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
__set_errno (EAGAIN);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *res;
|
||||
|
||||
res = nis_next_entry(names[0], &result->cookie);
|
||||
nis_freeresult (result);
|
||||
result = res;
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
int retval;
|
||||
|
||||
retval = niserr2nss (result->status);
|
||||
if (retval == NSS_STATUS_TRYAGAIN)
|
||||
{
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
__set_errno (EAGAIN);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_netent (result, network, buffer, buflen);
|
||||
if (!parse_res && errno == ERANGE)
|
||||
{
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
}
|
||||
|
||||
} while (!parse_res);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getnetent_r (struct netent *result, char *buffer,
|
||||
size_t buflen, int *herrnop)
|
||||
{
|
||||
int status;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = internal_nisplus_getnetent_r (result, buffer, buflen, herrnop);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getnetbyname_r (const char *name, struct netent *network,
|
||||
char *buffer, size_t buflen, int *herrnop)
|
||||
{
|
||||
int parse_res, retval;
|
||||
|
||||
if (name == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *result;
|
||||
char buf[strlen (name) + 255];
|
||||
|
||||
|
||||
/* Search at first in the alias list, and use the correct name
|
||||
for the next search */
|
||||
sprintf(buf, "[name=%s],networks.org_dir", name);
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
/* If we do not find it, try it as original name. But if the
|
||||
database is correct, we should find it in the first case, too */
|
||||
if ((result->status != NIS_SUCCESS &&
|
||||
result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"networks_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 3)
|
||||
sprintf(buf, "[cname=%s],networks.org_dir", name);
|
||||
else
|
||||
sprintf(buf, "[cname=%s],networks.org_dir", NISENTRYVAL(0, 0, result));
|
||||
|
||||
nis_freeresult (result);
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
retval = niserr2nss (result->status);
|
||||
if (retval != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
if (retval == NSS_STATUS_TRYAGAIN)
|
||||
{
|
||||
__set_errno (EAGAIN);
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
}
|
||||
nis_freeresult (result);
|
||||
return retval;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_netent (result, network, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX type is ignored, SUN's NIS+ table doesn't support it */
|
||||
enum nss_status
|
||||
_nss_nisplus_getnetbyaddr_r (const unsigned long addr, const int type,
|
||||
struct netent *network,
|
||||
char *buffer, size_t buflen, int *herrnop)
|
||||
{
|
||||
int parse_res, retval;
|
||||
nis_result *result;
|
||||
char buf[1024];
|
||||
struct in_addr in;
|
||||
|
||||
in = inet_makeaddr (addr, 0);
|
||||
snprintf(buf, sizeof (buf) - 1, "[addr=%s],networks.org_dir",
|
||||
inet_ntoa (in));
|
||||
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
retval = niserr2nss (result->status);
|
||||
if (retval != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
if (retval == NSS_STATUS_TRYAGAIN)
|
||||
{
|
||||
__set_errno (EAGAIN);
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
}
|
||||
nis_freeresult (result);
|
||||
return retval;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_netent (result, network, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
*herrnop = NETDB_INTERNAL;
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <libc-lock.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include "nss-nisplus.h"
|
||||
|
||||
__libc_lock_define_initialized (static, lock)
|
||||
|
||||
static nis_result *result = NULL;
|
||||
static nis_name *names = NULL;
|
||||
|
||||
#define ENTNAME protoent
|
||||
#define DATABASE "protocols"
|
||||
#define TRAILING_LIST_MEMBER p_aliases
|
||||
#define TRAILING_LIST_SEPARATOR_P isspace
|
||||
#include "../../nss/nss_files/files-parse.c"
|
||||
LINE_PARSER
|
||||
("#",
|
||||
STRING_FIELD (result->p_name, isspace, 1);
|
||||
INT_FIELD (result->p_proto, isspace, 1, 10,);
|
||||
)
|
||||
|
||||
#define NISENTRYVAL(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
|
||||
|
||||
#define NISENTRYLEN(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len)
|
||||
|
||||
static int
|
||||
_nss_nisplus_parse_protoent (nis_result * result, struct protoent *proto,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
char *p = buffer;
|
||||
size_t room_left = buflen;
|
||||
int i;
|
||||
struct parser_data *data = (void *) buffer;
|
||||
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"protocols_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 3)
|
||||
return -1;
|
||||
|
||||
memset (p, '\0', room_left);
|
||||
|
||||
/* Generate the protocols entry format and use the normal parser */
|
||||
if (NISENTRYLEN (0, 0, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strncpy (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result));
|
||||
room_left -= (NISENTRYLEN (0, 0, result) + 1);
|
||||
|
||||
if (NISENTRYLEN (0, 2, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, "\t");
|
||||
strncat (p, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result));
|
||||
room_left -= (NISENTRYLEN (0, 2, result) + 1);
|
||||
/* + 1: We overwrite the last \0 */
|
||||
|
||||
for (i = 1; i < result->objects.objects_len; i++)
|
||||
{
|
||||
if (NISENTRYLEN (i, 1, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, " ");
|
||||
strncat (p, NISENTRYVAL (i, 1, result), NISENTRYLEN (i, 1, result));
|
||||
room_left -= (NISENTRYLEN (i, 1, result) + 1);
|
||||
}
|
||||
|
||||
return _nss_files_parse_protoent (p, proto, data, buflen);
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_setprotoent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_endprotoent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum nss_status
|
||||
internal_nisplus_getprotoent_r (struct protoent *proto, char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
/* Get the next entry until we found a correct one. */
|
||||
do
|
||||
{
|
||||
if (result == NULL)
|
||||
{
|
||||
names = nis_getnames ("protocols.org_dir");
|
||||
if (names == NULL || names[0] == NULL)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
result = nis_first_entry (names[0]);
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *res;
|
||||
|
||||
res = nis_next_entry (names[0], &result->cookie);
|
||||
nis_freeresult (result);
|
||||
result = res;
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_protoent (result, proto, buffer, buflen);
|
||||
}
|
||||
while (!parse_res);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getprotoent_r (struct protoent *result, char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
int status;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = internal_nisplus_getprotoent_r (result, buffer, buflen);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getprotobyname_r (const char *name, struct protoent *proto,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
if (name == NULL)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
else
|
||||
{
|
||||
nis_result *result;
|
||||
char buf[strlen (name) + 255];
|
||||
|
||||
/* Search at first in the alias list, and use the correct name
|
||||
for the next search */
|
||||
sprintf (buf, "[name=%s],protocols.org_dir", name);
|
||||
result = nis_list (buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
/* If we do not find it, try it as original name. But if the
|
||||
database is correct, we should find it in the first case, too */
|
||||
if ((result->status != NIS_SUCCESS &&
|
||||
result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"protocols_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 3)
|
||||
sprintf (buf, "[cname=%s],protocols.org_dir", name);
|
||||
else
|
||||
sprintf (buf, "[cname=%s],protocols.org_dir", NISENTRYVAL (0, 0, result));
|
||||
|
||||
nis_freeresult (result);
|
||||
result = nis_list (buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
enum nss_status status = niserr2nss (result->status);
|
||||
|
||||
nis_freeresult (result);
|
||||
return status;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_protoent (result, proto, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getprotobynumber_r (const int number, struct protoent *proto,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
nis_result *result;
|
||||
char buf[46];
|
||||
|
||||
snprintf (buf, sizeof (buf), "[number=%d],protocols.org_dir", number);
|
||||
|
||||
result = nis_list (buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
enum nss_status status = niserr2nss (result->status);
|
||||
|
||||
nis_freeresult (result);
|
||||
return status;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_protoent (result, proto, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
/* Copyright (c) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <rpc/key_prot.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include <nss-nisplus.h>
|
||||
|
||||
extern int xdecrypt (char *, char *);
|
||||
|
||||
/* If we found the entry, we give a SUCCESS and an empty key back. */
|
||||
enum nss_status
|
||||
_nss_nisplus_getpublickey (const char *netname, char *pkey)
|
||||
{
|
||||
nis_result *res;
|
||||
enum nss_status retval;
|
||||
char buf[NIS_MAXNAMELEN+2];
|
||||
char *domain, *cptr;
|
||||
int len;
|
||||
|
||||
pkey[0] = 0;
|
||||
|
||||
if (netname == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
domain = strchr (netname, '@');
|
||||
if (!domain)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
domain++;
|
||||
|
||||
snprintf (buf, NIS_MAXNAMELEN,
|
||||
"[auth_name=%s,auth_type=DES],cred.org_dir.%s",
|
||||
netname, domain);
|
||||
|
||||
if (buf[strlen (buf)-1] != '.')
|
||||
strcat(buf, ".");
|
||||
|
||||
res = nis_list(buf, USE_DGRAM+NO_AUTHINFO+FOLLOW_LINKS+FOLLOW_PATH,
|
||||
NULL, NULL);
|
||||
|
||||
retval = niserr2nss (res->status);
|
||||
|
||||
if (retval != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
if (retval == NSS_STATUS_TRYAGAIN)
|
||||
__set_errno (EAGAIN);
|
||||
nis_freeresult (res);
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (res->objects.objects_len > 1)
|
||||
{
|
||||
/*
|
||||
* More than one principal with same uid?
|
||||
* something wrong with cred table. Should be unique
|
||||
* Warn user and continue.
|
||||
*/
|
||||
printf (_("DES entry for netname %s not unique\n"), netname);
|
||||
nis_freeresult (res);
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
len = ENTRY_LEN (res->objects.objects_val, 3);
|
||||
memcpy (pkey, ENTRY_VAL (res->objects.objects_val,3), len);
|
||||
pkey[len] = 0;
|
||||
cptr = strchr (pkey, ':');
|
||||
if (cptr)
|
||||
cptr[0] = '\0';
|
||||
nis_freeresult (res);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getsecretkey (const char *netname, char *skey, char *passwd)
|
||||
{
|
||||
nis_result *res;
|
||||
enum nss_status retval;
|
||||
char buf[NIS_MAXNAMELEN+2];
|
||||
char *domain, *cptr;
|
||||
int len;
|
||||
|
||||
skey[0] = 0;
|
||||
|
||||
if (netname == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
domain = strchr (netname, '@');
|
||||
if (!domain)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
domain++;
|
||||
|
||||
snprintf (buf, NIS_MAXNAMELEN,
|
||||
"[auth_name=%s,auth_type=DES],cred.org_dir.%s",
|
||||
netname, domain);
|
||||
|
||||
if (buf[strlen(buf)-1] != '.')
|
||||
strcat(buf, ".");
|
||||
|
||||
res = nis_list (buf, USE_DGRAM+NO_AUTHINFO+FOLLOW_LINKS+FOLLOW_PATH,
|
||||
NULL, NULL);
|
||||
|
||||
retval = niserr2nss (res->status);
|
||||
|
||||
if (retval != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
if (retval == NSS_STATUS_TRYAGAIN)
|
||||
__set_errno (EAGAIN);
|
||||
nis_freeresult (res);
|
||||
return retval;
|
||||
}
|
||||
|
||||
if (res->objects.objects_len > 1)
|
||||
{
|
||||
/*
|
||||
* More than one principal with same uid?
|
||||
* something wrong with cred table. Should be unique
|
||||
* Warn user and continue.
|
||||
*/
|
||||
printf (_("DES entry for netname %s not unique\n"), netname);
|
||||
nis_freeresult (res);
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
len = ENTRY_LEN (res->objects.objects_val, 4);
|
||||
memcpy (buf, ENTRY_VAL (res->objects.objects_val,4), len);
|
||||
skey[len] = 0;
|
||||
cptr = strchr (skey, ':');
|
||||
if (cptr)
|
||||
cptr[0] = '\0';
|
||||
nis_freeresult (res);
|
||||
|
||||
if (!xdecrypt (buf, passwd))
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (memcmp (buf, &(buf[HEXKEYBYTES]), KEYCHECKSUMSIZE) != 0)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
buf[HEXKEYBYTES] = 0;
|
||||
strcpy (skey, buf);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Parse information from the passed string.
|
||||
The format of the string passed is gid,grp,grp, ... */
|
||||
static enum nss_status
|
||||
parse_grp_str (const char *s, gid_t *gidp, int *gidlenp, gid_t *gidlist)
|
||||
{
|
||||
int gidlen;
|
||||
|
||||
if (!s || (!isdigit (*s)))
|
||||
{
|
||||
syslog (LOG_ERR, "netname2user: missing group id list in '%s'.", s);
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
|
||||
*gidp = (atoi (s));
|
||||
|
||||
gidlen = 0;
|
||||
|
||||
while ((s = strchr (s, ',')) != NULL)
|
||||
{
|
||||
s++;
|
||||
gidlist[gidlen++] = atoi (s);
|
||||
}
|
||||
*gidlenp = gidlen;
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
|
||||
gid_t *gidp, int *gidlenp, gid_t *gidlist)
|
||||
{
|
||||
char *domain;
|
||||
nis_result *res;
|
||||
char sname[NIS_MAXNAMELEN+1]; /* search criteria + table name */
|
||||
char principal[NIS_MAXNAMELEN+1];
|
||||
int len;
|
||||
|
||||
/* 1. Get home domain of user. */
|
||||
domain = strchr (netname, '@');
|
||||
if (! domain)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
domain++; /* skip '@' */
|
||||
|
||||
/* 2. Get user's nisplus principal name. */
|
||||
if ((strlen (netname) + strlen (domain)+45) >
|
||||
(size_t) NIS_MAXNAMELEN)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
snprintf (sname, NIS_MAXNAMELEN,
|
||||
"[auth_name=%s,auth_type=DES],cred.org_dir.%s",
|
||||
netname, domain);
|
||||
if (sname[strlen (sname) - 1] != '.')
|
||||
strcat(sname, ".");
|
||||
|
||||
/* must use authenticated call here */
|
||||
/* XXX but we cant, for now. XXX */
|
||||
res = nis_list (sname, USE_DGRAM+NO_AUTHINFO+FOLLOW_LINKS+FOLLOW_PATH,
|
||||
NULL, NULL);
|
||||
switch(res->status)
|
||||
{
|
||||
case NIS_SUCCESS:
|
||||
case NIS_S_SUCCESS:
|
||||
break; /* go and do something useful */
|
||||
case NIS_NOTFOUND:
|
||||
case NIS_PARTIAL:
|
||||
case NIS_NOSUCHNAME:
|
||||
case NIS_NOSUCHTABLE:
|
||||
nis_freeresult (res);
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
case NIS_S_NOTFOUND:
|
||||
case NIS_TRYAGAIN:
|
||||
syslog (LOG_ERR, "netname2user: (nis+ lookup): %s\n",
|
||||
nis_sperrno (res->status));
|
||||
nis_freeresult (res);
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
default:
|
||||
syslog (LOG_ERR, "netname2user: (nis+ lookup): %s\n",
|
||||
nis_sperrno (res->status));
|
||||
nis_freeresult (res);
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
if (res->objects.objects_len > 1)
|
||||
{
|
||||
/*
|
||||
* A netname belonging to more than one principal?
|
||||
* Something wrong with cred table. should be unique.
|
||||
* Warn user and continue.
|
||||
*/
|
||||
syslog (LOG_ALERT,
|
||||
_("netname2user: DES entry for %s in directory %s not unique"),
|
||||
netname, domain);
|
||||
}
|
||||
|
||||
len = ENTRY_LEN(res->objects.objects_val, 0);
|
||||
strncpy(principal, ENTRY_VAL(res->objects.objects_val, 0), len);
|
||||
principal[len] = '\0';
|
||||
nis_freeresult(res);
|
||||
|
||||
if (principal[0] == '\0')
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
/*
|
||||
* 3. Use principal name to look up uid/gid information in
|
||||
* LOCAL entry in **local** cred table.
|
||||
*/
|
||||
domain = nis_local_directory ();
|
||||
if ((strlen(principal)+strlen(domain)+45) >
|
||||
(size_t) NIS_MAXNAMELEN)
|
||||
{
|
||||
syslog (LOG_ERR, _("netname2user: principal name '%s' too long"),
|
||||
principal);
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
sprintf(sname, "[cname=%s,auth_type=LOCAL],cred.org_dir.%s",
|
||||
principal, domain);
|
||||
if (sname[strlen(sname) - 1] != '.')
|
||||
strcat(sname, ".");
|
||||
|
||||
/* must use authenticated call here */
|
||||
/* XXX but we cant, for now. XXX */
|
||||
res = nis_list(sname, USE_DGRAM+NO_AUTHINFO+FOLLOW_LINKS+FOLLOW_PATH,
|
||||
NULL, NULL);
|
||||
switch(res->status) {
|
||||
case NIS_NOTFOUND:
|
||||
case NIS_PARTIAL:
|
||||
case NIS_NOSUCHNAME:
|
||||
case NIS_NOSUCHTABLE:
|
||||
nis_freeresult (res);
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
case NIS_S_NOTFOUND:
|
||||
case NIS_TRYAGAIN:
|
||||
syslog (LOG_ERR,
|
||||
"netname2user: (nis+ lookup): %s\n",
|
||||
nis_sperrno (res->status));
|
||||
nis_freeresult (res);
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
case NIS_SUCCESS:
|
||||
case NIS_S_SUCCESS:
|
||||
break; /* go and do something useful */
|
||||
default:
|
||||
syslog (LOG_ERR, "netname2user: (nis+ lookup): %s\n",
|
||||
nis_sperrno (res->status));
|
||||
nis_freeresult (res);
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
if (res->objects.objects_len > 1)
|
||||
{
|
||||
/*
|
||||
* A principal can have more than one LOCAL entry?
|
||||
* Something wrong with cred table.
|
||||
* Warn user and continue.
|
||||
*/
|
||||
syslog(LOG_ALERT,
|
||||
_("netname2user: LOCAL entry for %s in directory %s not unique"),
|
||||
netname, domain);
|
||||
}
|
||||
/* Fetch the uid */
|
||||
*uidp = (atoi (ENTRY_VAL (res->objects.objects_val, 2)));
|
||||
|
||||
if (*uidp == 0)
|
||||
{
|
||||
syslog (LOG_ERR, _("netname2user: should not have uid 0"));
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
|
||||
parse_grp_str (ENTRY_VAL (res->objects.objects_val, 3),
|
||||
gidp, gidlenp, gidlist);
|
||||
|
||||
nis_freeresult (res);
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <string.h>
|
||||
#include <libc-lock.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include "nss-nisplus.h"
|
||||
|
||||
__libc_lock_define_initialized (static, lock)
|
||||
|
||||
static nis_result *result = NULL;
|
||||
static nis_name *names = NULL;
|
||||
|
||||
#define NISENTRYVAL(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
|
||||
|
||||
#define NISENTRYLEN(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len)
|
||||
|
||||
static int
|
||||
_nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
char *first_unused = buffer;
|
||||
size_t room_left = buflen;
|
||||
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_len != 1 ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"passwd_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 7)
|
||||
return -1;
|
||||
|
||||
if (NISENTRYLEN(0, 0, result) >= room_left)
|
||||
{
|
||||
/* The line is too long for our buffer. */
|
||||
no_more_room:
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL(0, 0, result),
|
||||
NISENTRYLEN (0, 0, result));
|
||||
first_unused[NISENTRYLEN(0, 0, result)] = '\0';
|
||||
pw->pw_name = first_unused;
|
||||
room_left -= (strlen (first_unused) +1);
|
||||
first_unused += strlen (first_unused) +1;
|
||||
|
||||
if (NISENTRYLEN(0, 1, result) >= room_left)
|
||||
goto no_more_room;
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL(0, 1, result),
|
||||
NISENTRYLEN (0, 1, result));
|
||||
first_unused[NISENTRYLEN(0, 1, result)] = '\0';
|
||||
pw->pw_passwd = first_unused;
|
||||
room_left -= (strlen (first_unused) +1);
|
||||
first_unused += strlen (first_unused) +1;
|
||||
|
||||
if (NISENTRYLEN(0, 2, result) >= room_left)
|
||||
goto no_more_room;
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL (0, 2, result),
|
||||
NISENTRYLEN (0, 2, result));
|
||||
first_unused[NISENTRYLEN(0, 2, result)] = '\0';
|
||||
pw->pw_uid = atoi (first_unused);
|
||||
room_left -= (strlen (first_unused) +1);
|
||||
first_unused += strlen (first_unused) +1;
|
||||
|
||||
if (NISENTRYLEN(0, 3, result) >= room_left)
|
||||
goto no_more_room;
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL(0, 3, result),
|
||||
NISENTRYLEN (0, 3, result));
|
||||
first_unused[NISENTRYLEN(0, 3, result)] = '\0';
|
||||
pw->pw_gid = atoi (first_unused);
|
||||
room_left -= (strlen (first_unused) +1);
|
||||
first_unused += strlen (first_unused) +1;
|
||||
|
||||
if (NISENTRYLEN(0, 4, result) >= room_left)
|
||||
goto no_more_room;
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL(0, 4, result),
|
||||
NISENTRYLEN (0, 4, result));
|
||||
first_unused[NISENTRYLEN(0, 4, result)] = '\0';
|
||||
pw->pw_gecos = first_unused;
|
||||
room_left -= (strlen (first_unused) +1);
|
||||
first_unused += strlen (first_unused) +1;
|
||||
|
||||
if (NISENTRYLEN(0, 5, result) >= room_left)
|
||||
goto no_more_room;
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL (0, 5, result),
|
||||
NISENTRYLEN (0, 5, result));
|
||||
first_unused[NISENTRYLEN(0, 5, result)] = '\0';
|
||||
pw->pw_dir = first_unused;
|
||||
room_left -= (strlen (first_unused) +1);
|
||||
first_unused += strlen (first_unused) +1;
|
||||
|
||||
if (NISENTRYLEN(0, 6, result) >= room_left)
|
||||
goto no_more_room;
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL (0, 6, result),
|
||||
NISENTRYLEN (0, 6, result));
|
||||
first_unused[NISENTRYLEN (0, 6, result)] = '\0';
|
||||
pw->pw_shell = first_unused;
|
||||
room_left -= (strlen (first_unused) +1);
|
||||
first_unused += strlen (first_unused) +1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_setpwent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_endpwent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum nss_status
|
||||
internal_nisplus_getpwent_r (struct passwd *pw, char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
/* Get the next entry until we found a correct one. */
|
||||
do
|
||||
{
|
||||
if (result == NULL)
|
||||
{
|
||||
names = nis_getnames ("passwd.org_dir");
|
||||
if (names == NULL || names[0] == NULL)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
result = nis_first_entry(names[0]);
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *res;
|
||||
|
||||
res = nis_next_entry(names[0], &result->cookie);
|
||||
nis_freeresult (result);
|
||||
result = res;
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_pwent (result, pw, buffer, buflen);
|
||||
} while (!parse_res);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getpwent_r (struct passwd *result, char *buffer, size_t buflen)
|
||||
{
|
||||
int status;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = internal_nisplus_getpwent_r (result, buffer, buflen);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getpwnam_r (const char *name, struct passwd *pw,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
if (name == NULL || strlen (name) > 8)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
else
|
||||
{
|
||||
nis_result *result;
|
||||
char buf[strlen (name) + 24];
|
||||
|
||||
sprintf(buf, "[name=%s],passwd.org_dir", name);
|
||||
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
enum nss_status status = niserr2nss (result->status);
|
||||
|
||||
nis_freeresult (result);
|
||||
return status;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_pwent (result, pw, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getpwuid_r (const uid_t uid, struct passwd *pw,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
nis_result *result;
|
||||
char buf[100];
|
||||
|
||||
sprintf(buf, "[uid=%d],passwd.org_dir", uid);
|
||||
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
enum nss_status status = niserr2nss (result->status);
|
||||
|
||||
nis_freeresult (result);
|
||||
return status;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_pwent (result, pw, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <libc-lock.h>
|
||||
#include <rpc/netdb.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include "nss-nisplus.h"
|
||||
|
||||
__libc_lock_define_initialized (static, lock)
|
||||
|
||||
static nis_result *result = NULL;
|
||||
static nis_name *names = NULL;
|
||||
|
||||
#define ENTNAME rpcent
|
||||
#define DATABASE "rpc"
|
||||
#define TRAILING_LIST_MEMBER r_aliases
|
||||
#define TRAILING_LIST_SEPARATOR_P isspace
|
||||
#include "../../nss/nss_files/files-parse.c"
|
||||
LINE_PARSER
|
||||
("#",
|
||||
STRING_FIELD (result->r_name, isspace, 1);
|
||||
INT_FIELD (result->r_number, isspace, 1, 10,);
|
||||
)
|
||||
|
||||
#define NISENTRYVAL(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
|
||||
|
||||
#define NISENTRYLEN(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len)
|
||||
|
||||
static int
|
||||
_nss_nisplus_parse_rpcent (nis_result *result, struct rpcent *rpc,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
char *p = buffer;
|
||||
size_t room_left = buflen;
|
||||
int i;
|
||||
struct parser_data *data = (void *) buffer;
|
||||
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp(result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"rpc_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 3)
|
||||
return -1;
|
||||
|
||||
memset (p, '\0', room_left);
|
||||
|
||||
/* Generate the rpc entry format and use the normal parser */
|
||||
if (NISENTRYLEN (0, 0, result) +1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strncpy (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result));
|
||||
room_left -= (NISENTRYLEN (0, 0, result) +1);
|
||||
|
||||
if (NISENTRYLEN (0, 2, result) +1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, "\t");
|
||||
strncat (p, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result));
|
||||
room_left -= (NISENTRYLEN (0, 2, result) + 1);
|
||||
/* + 1: We overwrite the last \0 */
|
||||
|
||||
for (i = 0; i < result->objects.objects_len; i++)
|
||||
/* XXX should we start with i = 0 or with i = 1 ? */
|
||||
{
|
||||
if (NISENTRYLEN (i, 1, result) +1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, " ");
|
||||
strncat (p, NISENTRYVAL (i, 1, result), NISENTRYLEN (i, 1, result));
|
||||
room_left -= (NISENTRYLEN (i, 1, result) + 1);
|
||||
}
|
||||
|
||||
return _nss_files_parse_rpcent (p, rpc, data, buflen);
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_setrpcent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_endrpcent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum nss_status
|
||||
internal_nisplus_getrpcent_r (struct rpcent *rpc, char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
/* Get the next entry until we found a correct one. */
|
||||
do
|
||||
{
|
||||
if (result == NULL)
|
||||
{
|
||||
names = nis_getnames ("rpc.org_dir");
|
||||
if (names == NULL || names[0] == NULL)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
result = nis_first_entry(names[0]);
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *res;
|
||||
|
||||
res = nis_next_entry (names[0], &result->cookie);
|
||||
nis_freeresult (result);
|
||||
result = res;
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_rpcent (result, rpc, buffer, buflen);
|
||||
} while (!parse_res);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getrpcent_r (struct rpcent *result, char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
int status;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = internal_nisplus_getrpcent_r (result, buffer, buflen);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getrpcbyname_r (const char *name, struct rpcent *rpc,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
if (name == NULL)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
else
|
||||
{
|
||||
nis_result *result;
|
||||
char buf[strlen (name) + 255];
|
||||
|
||||
/* Search at first in the alias list, and use the correct name
|
||||
for the next search */
|
||||
sprintf (buf, "[name=%s],rpc.org_dir", name);
|
||||
result = nis_list (buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
/* If we do not find it, try it as original name. But if the
|
||||
database is correct, we should find it in the first case, too */
|
||||
if ((result->status != NIS_SUCCESS &&
|
||||
result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"rpc_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 3)
|
||||
sprintf (buf, "[cname=%s],rpc.org_dir", name);
|
||||
else
|
||||
sprintf (buf, "[cname=%s],rpc.org_dir", NISENTRYVAL(0, 0, result));
|
||||
|
||||
nis_freeresult (result);
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
enum nss_status status = niserr2nss (result->status);
|
||||
|
||||
nis_freeresult (result);
|
||||
return status;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_rpcent (result, rpc, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getrpcbynumber_r (const int number, struct rpcent *rpc,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
nis_result *result;
|
||||
char buf[100];
|
||||
|
||||
snprintf (buf, sizeof (buf), "[number=%d],rpc.org_dir", number);
|
||||
|
||||
result = nis_list(buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
enum nss_status status = niserr2nss (result->status);
|
||||
|
||||
nis_freeresult (result);
|
||||
return status;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_rpcent (result, rpc, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <libc-lock.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include "nss-nisplus.h"
|
||||
|
||||
__libc_lock_define_initialized (static, lock);
|
||||
|
||||
static nis_result *result = NULL;
|
||||
static nis_name *names = NULL;
|
||||
|
||||
#define ENTNAME servent
|
||||
#define DATABASE "services"
|
||||
#define TRAILING_LIST_MEMBER s_aliases
|
||||
#define TRAILING_LIST_SEPARATOR_P isspace
|
||||
#include "../../nss/nss_files/files-parse.c"
|
||||
#define ISSLASH(c) ((c) == '/')
|
||||
LINE_PARSER
|
||||
("#",
|
||||
STRING_FIELD (result->s_name, isspace, 1);
|
||||
INT_FIELD (result->s_port, ISSLASH, 10, 0, htons);
|
||||
STRING_FIELD (result->s_proto, isspace, 1);
|
||||
)
|
||||
|
||||
|
||||
#define NISENTRYVAL(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
|
||||
|
||||
#define NISENTRYLEN(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len)
|
||||
|
||||
static int
|
||||
_nss_nisplus_parse_servent (nis_result *result, struct servent *serv,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
char *p = buffer;
|
||||
size_t room_left = buflen;
|
||||
int i;
|
||||
struct parser_data *data = (void *) buffer;
|
||||
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"services_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 4)
|
||||
return -1;
|
||||
|
||||
memset (p, '\0', room_left);
|
||||
|
||||
/* Generate the services entry format and use the normal parser */
|
||||
if (NISENTRYLEN (0, 0, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strncpy (p, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result));
|
||||
room_left -= (NISENTRYLEN (0, 0, result) + 1);
|
||||
|
||||
if (NISENTRYLEN (0, 3, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, "\t");
|
||||
strncat (p, NISENTRYVAL (0, 3, result), NISENTRYLEN (0, 3, result));
|
||||
room_left -= (NISENTRYLEN (0, 3, result) + 1);
|
||||
if (NISENTRYLEN (0, 2, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, "/");
|
||||
strncat (p, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result));
|
||||
room_left -= (NISENTRYLEN (0, 2, result) + 1);
|
||||
|
||||
for (i = 1; i < result->objects.objects_len; i++)
|
||||
{
|
||||
if (NISENTRYLEN (i, 1, result) + 1 > room_left)
|
||||
{
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
strcat (p, " ");
|
||||
strcat (p, NISENTRYVAL (i, 1, result));
|
||||
room_left -= (NISENTRYLEN (i, 1, result) + 1);
|
||||
}
|
||||
|
||||
return _nss_files_parse_servent (p, serv, data, buflen);
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_setservent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_endservent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum nss_status
|
||||
internal_nisplus_getservent_r (struct servent *serv, char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
/* Get the next entry until we found a correct one. */
|
||||
do
|
||||
{
|
||||
if (result == NULL)
|
||||
{
|
||||
names = nis_getnames ("services.org_dir");
|
||||
if (names == NULL || names[0] == NULL)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
result = nis_first_entry (names[0]);
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *res;
|
||||
|
||||
res = nis_next_entry (names[0], &result->cookie);
|
||||
nis_freeresult (result);
|
||||
result = res;
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_servent (result, serv, buffer, buflen);
|
||||
}
|
||||
while (!parse_res);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getservent_r (struct servent *result, char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
int status;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = internal_nisplus_getservent_r (result, buffer, buflen);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getservbyname_r (const char *name, const char *protocol,
|
||||
struct servent *serv,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
if (name == NULL || protocol == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *result;
|
||||
char buf[strlen (name) + 255];
|
||||
|
||||
/* Search at first in the alias list, and use the correct name
|
||||
for the next search */
|
||||
sprintf (buf, "[name=%s,proto=%s],services.org_dir", name,
|
||||
protocol);
|
||||
result = nis_list (buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
/* If we do not find it, try it as original name. But if the
|
||||
database is correct, we should find it in the first case, too */
|
||||
if ((result->status != NIS_SUCCESS &&
|
||||
result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"services_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 4)
|
||||
sprintf (buf, "[cname=%s,proto=%s],services.org_dir", name, protocol);
|
||||
else
|
||||
sprintf (buf, "[cname=%s,proto=%s],services.org_dir",
|
||||
NISENTRYVAL (0, 0, result), protocol);
|
||||
|
||||
nis_freeresult (result);
|
||||
result = nis_list (buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
enum nss_status status = niserr2nss (result->status);
|
||||
|
||||
nis_freeresult (result);
|
||||
return status;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_servent (result, serv, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getservbynumber_r (const int number, const char *protocol,
|
||||
struct servent *serv,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
nis_result *result;
|
||||
char buf[60 + strlen (protocol)];
|
||||
|
||||
if (protocol == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
|
||||
snprintf (buf, sizeof (buf), "[number=%d,proto=%s],services.org_dir",
|
||||
number, protocol);
|
||||
|
||||
result = nis_list (buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
enum nss_status status = niserr2nss (result->status);
|
||||
|
||||
nis_freeresult (result);
|
||||
return status;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_servent (result, serv, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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. */
|
||||
|
||||
#include <nss.h>
|
||||
#include <errno.h>
|
||||
#include <shadow.h>
|
||||
#include <string.h>
|
||||
#include <libc-lock.h>
|
||||
#include <rpcsvc/nis.h>
|
||||
#include <rpcsvc/nislib.h>
|
||||
|
||||
#include "nss-nisplus.h"
|
||||
|
||||
__libc_lock_define_initialized (static, lock)
|
||||
|
||||
static nis_result *result = NULL;
|
||||
static nis_name *names = NULL;
|
||||
|
||||
#define NISENTRYVAL(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val)
|
||||
|
||||
#define NISENTRYLEN(idx,col,res) \
|
||||
((res)->objects.objects_val[(idx)].zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len)
|
||||
|
||||
static int
|
||||
_nss_nisplus_parse_spent (nis_result *result, struct spwd *sp,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
char *first_unused = buffer;
|
||||
size_t room_left = buflen;
|
||||
char *line, *cp;
|
||||
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
|
||||
if ((result->status != NIS_SUCCESS && result->status != NIS_S_SUCCESS) ||
|
||||
result->objects.objects_len != 1 ||
|
||||
result->objects.objects_val[0].zo_data.zo_type != ENTRY_OBJ ||
|
||||
strcmp (result->objects.objects_val[0].zo_data.objdata_u.en_data.en_type,
|
||||
"passwd_tbl") != 0 ||
|
||||
result->objects.objects_val[0].zo_data.objdata_u.en_data.en_cols.en_cols_len < 8)
|
||||
return -1;
|
||||
|
||||
if (NISENTRYLEN(0, 0, result) >= room_left)
|
||||
{
|
||||
/* The line is too long for our buffer. */
|
||||
no_more_room:
|
||||
__set_errno (ERANGE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL (0, 0, result),
|
||||
NISENTRYLEN (0, 0, result));
|
||||
first_unused[NISENTRYLEN(0, 0, result)] = '\0';
|
||||
sp->sp_namp = first_unused;
|
||||
room_left -= (strlen (first_unused) +1);
|
||||
first_unused += strlen (first_unused) +1;
|
||||
|
||||
if (NISENTRYLEN(0, 1, result) >= room_left)
|
||||
goto no_more_room;
|
||||
|
||||
strncpy (first_unused, NISENTRYVAL (0, 1, result),
|
||||
NISENTRYLEN (0, 1, result));
|
||||
first_unused[NISENTRYLEN(0, 1, result)] = '\0';
|
||||
sp->sp_pwdp = first_unused;
|
||||
room_left -= (strlen (first_unused) +1);
|
||||
first_unused += strlen (first_unused) +1;
|
||||
|
||||
sp->sp_lstchg = sp->sp_min = sp->sp_max = sp->sp_warn = sp->sp_inact =
|
||||
sp->sp_expire = sp->sp_flag = -1;
|
||||
|
||||
line = NISENTRYVAL (0, 7, result);
|
||||
cp = strchr (line, ':');
|
||||
if (cp == NULL)
|
||||
return 0;
|
||||
*cp++ = '\0';
|
||||
sp->sp_lstchg = atoi (line);
|
||||
|
||||
line = cp;
|
||||
cp = strchr (line, ':');
|
||||
if (cp == NULL)
|
||||
return 0;
|
||||
*cp++ = '\0';
|
||||
sp->sp_min = atoi(line);
|
||||
|
||||
line = cp;
|
||||
cp = strchr (line, ':');
|
||||
if (cp == NULL)
|
||||
return 0;
|
||||
*cp++ = '\0';
|
||||
sp->sp_max = atoi(line);
|
||||
|
||||
line = cp;
|
||||
cp = strchr (line, ':');
|
||||
if (cp == NULL)
|
||||
return 0;
|
||||
*cp++ = '\0';
|
||||
sp->sp_warn = atoi(line);
|
||||
|
||||
line = cp;
|
||||
cp = strchr (line, ':');
|
||||
if (cp == NULL)
|
||||
return 0;
|
||||
*cp++ = '\0';
|
||||
sp->sp_inact = atoi(line);
|
||||
|
||||
line = cp;
|
||||
cp = strchr (line, ':');
|
||||
if (cp == NULL)
|
||||
return 0;
|
||||
*cp++ = '\0';
|
||||
sp->sp_expire = atoi(line);
|
||||
|
||||
line = cp;
|
||||
if (line == NULL)
|
||||
return 0;
|
||||
sp->sp_flag = atoi(line);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_setspent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_endspent (void)
|
||||
{
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
if (result)
|
||||
nis_freeresult (result);
|
||||
result = NULL;
|
||||
if (names)
|
||||
{
|
||||
nis_freenames (names);
|
||||
names = NULL;
|
||||
}
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static enum nss_status
|
||||
internal_nisplus_getspent_r (struct spwd *sp, char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
/* Get the next entry until we found a correct one. */
|
||||
do
|
||||
{
|
||||
if (result == NULL)
|
||||
{
|
||||
names = nis_getnames ("passwd.org_dir");
|
||||
if (names == NULL || names[0] == NULL)
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
|
||||
result = nis_first_entry (names[0]);
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
else
|
||||
{
|
||||
nis_result *res;
|
||||
|
||||
res = nis_next_entry (names[0], &result->cookie);
|
||||
nis_freeresult (result);
|
||||
result = res;
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
return niserr2nss (result->status);
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_spent (result, sp, buffer, buflen);
|
||||
} while (!parse_res);
|
||||
|
||||
return NSS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getspent_r (struct spwd *result, char *buffer, size_t buflen)
|
||||
{
|
||||
int status;
|
||||
|
||||
__libc_lock_lock (lock);
|
||||
|
||||
status = internal_nisplus_getspent_r (result, buffer, buflen);
|
||||
|
||||
__libc_lock_unlock (lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
enum nss_status
|
||||
_nss_nisplus_getspnam_r (const char *name, struct spwd *sp,
|
||||
char *buffer, size_t buflen)
|
||||
{
|
||||
int parse_res;
|
||||
|
||||
if (name == NULL || strlen (name) > 8)
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
else
|
||||
{
|
||||
nis_result *result;
|
||||
char buf[strlen (name) + 24];
|
||||
|
||||
sprintf (buf, "[name=%s],passwd.org_dir", name);
|
||||
|
||||
result = nis_list (buf, EXPAND_NAME, NULL, NULL);
|
||||
|
||||
if (niserr2nss (result->status) != NSS_STATUS_SUCCESS)
|
||||
{
|
||||
enum nss_status status = niserr2nss (result->status);
|
||||
|
||||
nis_freeresult (result);
|
||||
return status;
|
||||
}
|
||||
|
||||
parse_res = _nss_nisplus_parse_spent (result, sp, buffer, buflen);
|
||||
|
||||
nis_freeresult (result);
|
||||
|
||||
if (parse_res)
|
||||
return NSS_STATUS_SUCCESS;
|
||||
|
||||
if (!parse_res && errno == ERANGE)
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
else
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
}
|
||||
+1012
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,446 @@
|
||||
%/*
|
||||
% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
% * unrestricted use provided that this legend is included on all tape
|
||||
% * media and as a part of the software program in whole or part. Users
|
||||
% * may copy or modify Sun RPC without charge, but are not authorized
|
||||
% * to license or distribute it to anyone else except as part of a product or
|
||||
% * program developed by the user or with the express written consent of
|
||||
% * Sun Microsystems, Inc.
|
||||
% *
|
||||
% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||
% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||
% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
||||
% *
|
||||
% * Sun RPC is provided with no support and without any obligation on the
|
||||
% * part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||
% * modification or enhancement.
|
||||
% *
|
||||
% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||
% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||
% * OR ANY PART THEREOF.
|
||||
% *
|
||||
% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||
% * or profits or other special, indirect and consequential damages, even if
|
||||
% * Sun has been advised of the possibility of such damages.
|
||||
% *
|
||||
% * Sun Microsystems, Inc.
|
||||
% * 2550 Garcia Avenue
|
||||
% * Mountain View, California 94043
|
||||
% */
|
||||
|
||||
/*
|
||||
* From 4.1 : @(#)nis.x 1.61 Copyright 1989 Sun Microsystems
|
||||
*
|
||||
* RPC Language Protocol description file for NIS Plus
|
||||
* This version : 1.61
|
||||
* Last Modified : 3/19/91
|
||||
*/
|
||||
#ifdef RPC_HDR
|
||||
%/*
|
||||
% * nis.h
|
||||
% *
|
||||
% * This file is the main include file for NIS clients. It contains
|
||||
% * both the client library function defines and the various data
|
||||
% * 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
|
||||
% * simple sed script to remove some unneeded lines. (See the
|
||||
% * Makefile target nis.h)
|
||||
% *
|
||||
% */
|
||||
%#include <rpcsvc/nis_tags.h>
|
||||
#endif
|
||||
|
||||
/* This gets stuffed into the source files. */
|
||||
#if RPC_HDR
|
||||
%#include <rpc/xdr.h>
|
||||
#endif
|
||||
#if RPC_SVC
|
||||
%#include "nis_svc.h"
|
||||
#endif
|
||||
|
||||
/* Include the RPC Language description of NIS objects */
|
||||
#include "nis_object.x"
|
||||
|
||||
/* Errors that can be returned by the service */
|
||||
enum nis_error {
|
||||
NIS_SUCCESS = 0, /* A-ok, let's rock n roll */
|
||||
NIS_S_SUCCESS = 1, /* Name found (maybe) */
|
||||
NIS_NOTFOUND = 2, /* Name definitely not found */
|
||||
NIS_S_NOTFOUND = 3, /* Name maybe not found */
|
||||
NIS_CACHEEXPIRED = 4, /* Name exists but cache out of date */
|
||||
NIS_NAMEUNREACHABLE = 5, /* Can't get there from here */
|
||||
NIS_UNKNOWNOBJ = 6, /* Object type is bogus */
|
||||
NIS_TRYAGAIN = 7, /* I'm busy, call back */
|
||||
NIS_SYSTEMERROR = 8, /* Out of band failure */
|
||||
NIS_CHAINBROKEN = 9, /* First/Next warning */
|
||||
NIS_PERMISSION = 10, /* Not enough permission to access */
|
||||
NIS_NOTOWNER = 11, /* You don't own it, sorry */
|
||||
NIS_NOT_ME = 12, /* I don't serve this name */
|
||||
NIS_NOMEMORY = 13, /* Outta VM! Help! */
|
||||
NIS_NAMEEXISTS = 14, /* Can't create over another name */
|
||||
NIS_NOTMASTER = 15, /* I'm justa secondaray, don't ask me */
|
||||
NIS_INVALIDOBJ = 16, /* Object is broken somehow */
|
||||
NIS_BADNAME = 17, /* Unparsable name */
|
||||
NIS_NOCALLBACK = 18, /* Couldn't talk to call back proc */
|
||||
NIS_CBRESULTS = 19, /* Results being called back to you */
|
||||
NIS_NOSUCHNAME = 20, /* Name unknown */
|
||||
NIS_NOTUNIQUE = 21, /* Value is not uniques (entry) */
|
||||
NIS_IBMODERROR = 22, /* Inf. Base. Modify error. */
|
||||
NIS_NOSUCHTABLE = 23, /* Name for table was wrong */
|
||||
NIS_TYPEMISMATCH = 24, /* Entry and table type mismatch */
|
||||
NIS_LINKNAMEERROR = 25, /* Link points to bogus name */
|
||||
NIS_PARTIAL = 26, /* Partial success, found table */
|
||||
NIS_TOOMANYATTRS = 27, /* Too many attributes */
|
||||
NIS_RPCERROR = 28, /* RPC error encountered */
|
||||
NIS_BADATTRIBUTE = 29, /* Bad or invalid attribute */
|
||||
NIS_NOTSEARCHABLE = 30, /* Non-searchable object searched */
|
||||
NIS_CBERROR = 31, /* Error during callback (svc crash) */
|
||||
NIS_FOREIGNNS = 32, /* Foreign Namespace */
|
||||
NIS_BADOBJECT = 33, /* Malformed object structure */
|
||||
NIS_NOTSAMEOBJ = 34, /* Object swapped during deletion */
|
||||
NIS_MODFAIL = 35, /* Failure during a Modify. */
|
||||
NIS_BADREQUEST = 36, /* Illegal query for table */
|
||||
NIS_NOTEMPTY = 37, /* Attempt to remove a non-empty tbl */
|
||||
NIS_COLDSTART_ERR = 38, /* Error accesing the cold start file */
|
||||
NIS_RESYNC = 39, /* Transaction log too far out of date */
|
||||
NIS_FAIL = 40, /* NIS operation failed. */
|
||||
NIS_UNAVAIL = 41, /* NIS+ service is unavailable (client) */
|
||||
NIS_RES2BIG = 42, /* NIS+ result too big for datagram */
|
||||
NIS_SRVAUTH = 43, /* NIS+ server wasn't authenticated. */
|
||||
NIS_CLNTAUTH = 44, /* NIS+ Client wasn't authenticated. */
|
||||
NIS_NOFILESPACE = 45, /* NIS+ server ran out of disk space */
|
||||
NIS_NOPROC = 46, /* NIS+ server couldn't create new proc */
|
||||
NIS_DUMPLATER = 47 /* NIS+ server already has dump child */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* 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
|
||||
* requests.
|
||||
*/
|
||||
|
||||
struct nis_result {
|
||||
nis_error status; /* Status of the response */
|
||||
nis_object objects<>; /* objects found */
|
||||
netobj cookie; /* Cookie Data */
|
||||
u_long zticks; /* server ticks */
|
||||
u_long dticks; /* DBM ticks. */
|
||||
u_long aticks; /* Cache (accel) ticks */
|
||||
u_long cticks; /* Client ticks */
|
||||
};
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
struct ns_request {
|
||||
nis_name ns_name; /* Name in the NIS name space */
|
||||
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
|
||||
* callback program number. If the callback program number is provided
|
||||
* the server will send back objects one at a time, otherwise it will
|
||||
* return them all in the response.
|
||||
*/
|
||||
|
||||
struct ib_request {
|
||||
nis_name ibr_name; /* The name of the Table */
|
||||
nis_attr ibr_srch<>; /* The search critereia */
|
||||
u_long ibr_flags; /* Optional flags */
|
||||
nis_object ibr_obj<1>; /* optional object (add/modify) */
|
||||
nis_server ibr_cbhost<1>; /* Optional callback info */
|
||||
u_long ibr_bufsize; /* Optional first/next bufsize */
|
||||
netobj ibr_cookie; /* The first/next cookie */
|
||||
};
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
struct ping_args {
|
||||
nis_name dir; /* Directory that had the change */
|
||||
u_long stamp; /* timestamp of the transaction */
|
||||
};
|
||||
|
||||
/*
|
||||
* 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
|
||||
* the log backwards to back out transactions and forwards to propogate
|
||||
* updated.
|
||||
*/
|
||||
enum log_entry_t {
|
||||
LOG_NOP = 0,
|
||||
ADD_NAME = 1, /* Name Added to name space */
|
||||
REM_NAME = 2, /* Name removed from name space */
|
||||
MOD_NAME_OLD = 3, /* Name was modified in the name space */
|
||||
MOD_NAME_NEW = 4, /* Name was modified in the name space */
|
||||
ADD_IBASE = 5, /* Entry added to information base */
|
||||
REM_IBASE = 6, /* Entry removed from information base */
|
||||
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
|
||||
* 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'.
|
||||
*/
|
||||
struct log_entry {
|
||||
u_long le_time; /* Time in seconds */
|
||||
log_entry_t le_type; /* Type of log entry */
|
||||
nis_name le_princp; /* Principal making the change */
|
||||
nis_name le_name; /* Name of table/dir involved */
|
||||
nis_attr le_attrs<>; /* List of AV pairs. */
|
||||
nis_object le_object; /* Actual object value */
|
||||
};
|
||||
|
||||
struct log_result {
|
||||
nis_error lr_status; /* The status itself */
|
||||
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' */
|
||||
u_long cp_dticks; /* Database 'ticks' */
|
||||
};
|
||||
|
||||
/*
|
||||
* 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).
|
||||
* These are used to report statistics (see tag definitions below)
|
||||
* and to set or reset state variables.
|
||||
*/
|
||||
struct nis_tag {
|
||||
u_long tag_type; /* Statistic tag (may vary) */
|
||||
string tag_val<1024>; /* Statistic value may also vary */
|
||||
};
|
||||
|
||||
struct nis_taglist {
|
||||
nis_tag tags<>; /* List of tags */
|
||||
};
|
||||
|
||||
struct dump_args {
|
||||
nis_name da_dir; /* Directory to dump */
|
||||
u_long da_time; /* From this timestamp */
|
||||
nis_server da_cbhost<1>; /* Callback to use. */
|
||||
};
|
||||
|
||||
struct fd_args {
|
||||
nis_name dir_name; /* The directory we're looking for */
|
||||
nis_name requester; /* Host principal name for signature */
|
||||
};
|
||||
|
||||
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 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).
|
||||
*/
|
||||
#ifdef RPC_SVC
|
||||
%#include "nis_svc.h"
|
||||
#endif
|
||||
#ifdef RPC_CLNT
|
||||
%#include "nis_clnt.h"
|
||||
#endif
|
||||
|
||||
program NIS_PROG {
|
||||
|
||||
/* RPC Language description of the NIS+ protocol */
|
||||
version NIS_VERSION {
|
||||
/* The name service functions */
|
||||
nis_result NIS_LOOKUP(ns_request) = 1;
|
||||
nis_result NIS_ADD(ns_request) = 2;
|
||||
nis_result NIS_MODIFY(ns_request) = 3;
|
||||
nis_result NIS_REMOVE(ns_request) = 4;
|
||||
|
||||
/* The information base functions */
|
||||
nis_result NIS_IBLIST(ib_request) = 5;
|
||||
nis_result NIS_IBADD(ib_request) = 6;
|
||||
nis_result NIS_IBMODIFY(ib_request) = 7;
|
||||
nis_result NIS_IBREMOVE(ib_request) = 8;
|
||||
nis_result NIS_IBFIRST(ib_request) = 9;
|
||||
nis_result NIS_IBNEXT(ib_request) = 10;
|
||||
|
||||
/* NIS Administrative functions */
|
||||
fd_result NIS_FINDDIRECTORY(fd_args) = 12;
|
||||
|
||||
/* 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;
|
||||
|
||||
/* Check status of callback thread */
|
||||
bool NIS_CALLBACK(netobj) = 17;
|
||||
|
||||
/* Return last update time for named dir */
|
||||
u_long NIS_CPTIME(nis_name) = 18;
|
||||
|
||||
/* Checkpoint directory or table named */
|
||||
cp_result NIS_CHECKPOINT(nis_name) = 19;
|
||||
|
||||
/* 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;
|
||||
} = 100300;
|
||||
|
||||
/*
|
||||
* Included below are the defines that become part of nis.h,
|
||||
* they are technically not part of the protocol, but do define
|
||||
* key aspects of the implementation and are therefore useful
|
||||
* in building a conforming server or client.
|
||||
*/
|
||||
#if RPC_HDR
|
||||
%/*
|
||||
% * Generic "hash" datastructures, used by all types of hashed data.
|
||||
% */
|
||||
%struct nis_hash_data {
|
||||
% nis_name name; /* NIS name of hashed item */
|
||||
% int keychain; /* It's hash key (for pop) */
|
||||
% struct nis_hash_data *next; /* Hash collision pointer */
|
||||
% struct nis_hash_data *prv_item; /* A serial, doubly linked list */
|
||||
% struct nis_hash_data *nxt_item; /* of items in the hash table */
|
||||
%};
|
||||
%typedef struct nis_hash_data NIS_HASH_ITEM;
|
||||
%
|
||||
%struct nis_hash_table {
|
||||
% NIS_HASH_ITEM *keys[64]; /* A hash table of items */
|
||||
% NIS_HASH_ITEM *first; /* The first "item" in serial list */
|
||||
%};
|
||||
%typedef struct nis_hash_table NIS_HASH_TABLE;
|
||||
%
|
||||
%/* Structure for storing dynamically allocated static data */
|
||||
%struct nis_sdata {
|
||||
% void *buf; /* Memory allocation pointer */
|
||||
% u_long size; /* Buffer size */
|
||||
%};
|
||||
%
|
||||
%/* Generic client creating flags */
|
||||
%#define ZMH_VC 1
|
||||
%#define ZMH_DG 2
|
||||
%#define ZMH_AUTH 4
|
||||
%
|
||||
%/* Testing Access rights for objects */
|
||||
%
|
||||
%#define NIS_READ_ACC 1
|
||||
%#define NIS_MODIFY_ACC 2
|
||||
%#define NIS_CREATE_ACC 4
|
||||
%#define NIS_DESTROY_ACC 8
|
||||
%/* Test macros. a == access rights, m == desired rights. */
|
||||
%#define WORLD(a, m) (((a) & (m)) != 0)
|
||||
%#define GROUP(a, m) (((a) & ((m) << 8)) != 0)
|
||||
%#define OWNER(a, m) (((a) & ((m) << 16)) != 0)
|
||||
%#define NOBODY(a, m) (((a) & ((m) << 24)) != 0)
|
||||
%
|
||||
%#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype)
|
||||
%#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights)
|
||||
%#define WORLD_DEFAULT (NIS_READ_ACC)
|
||||
%#define GROUP_DEFAULT (NIS_READ_ACC << 8)
|
||||
%#define OWNER_DEFAULT ((NIS_READ_ACC +\
|
||||
NIS_MODIFY_ACC +\
|
||||
NIS_CREATE_ACC +\
|
||||
NIS_DESTROY_ACC) << 16)
|
||||
%#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT)
|
||||
%
|
||||
%/* Result manipulation defines ... */
|
||||
%#define NIS_RES_NUMOBJ(x) ((x)->objects.objects_len)
|
||||
%#define NIS_RES_OBJECT(x) ((x)->objects.objects_val)
|
||||
%#define NIS_RES_COOKIE(x) ((x)->cookie)
|
||||
%#define NIS_RES_STATUS(x) ((x)->status)
|
||||
%
|
||||
%/* These defines make getting at the variant part of the object easier. */
|
||||
%#define TA_data zo_data.objdata_u.ta_data
|
||||
%#define EN_data zo_data.objdata_u.en_data
|
||||
%#define DI_data zo_data.objdata_u.di_data
|
||||
%#define LI_data zo_data.objdata_u.li_data
|
||||
%#define GR_data zo_data.objdata_u.gr_data
|
||||
%
|
||||
%#define __type_of(o) ((o)->zo_data.zo_type)
|
||||
%
|
||||
%/* Declarations for the internal subroutines in nislib.c */
|
||||
%enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME};
|
||||
%typedef enum name_pos name_pos;
|
||||
%
|
||||
%/*
|
||||
% * Defines for getting at column data in entry objects. Because RPCGEN
|
||||
% * generates some rather wordy structures, we create some defines that
|
||||
% * collapse the needed keystrokes to access a particular value using
|
||||
% * these definitions they take an nis_object *, and an int and return
|
||||
% * a u_char * for Value, and an int for length.
|
||||
% */
|
||||
%#define ENTRY_VAL(obj, col) \
|
||||
% (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
|
||||
%#define ENTRY_LEN(obj, col) \
|
||||
% (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
|
||||
%
|
||||
%#ifdef __cplusplus
|
||||
%}
|
||||
%#endif
|
||||
%
|
||||
%/* Prototypes, and extern declarations for the NIS library functions. */
|
||||
%#include <rpcsvc/nislib.h>
|
||||
%#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
|
||||
% * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead
|
||||
% * and then remake this file.
|
||||
% */
|
||||
%#ifndef __nis_3_h
|
||||
%#define __nis_3_h
|
||||
%#ifdef __cplusplus
|
||||
%extern "C" {
|
||||
%#endif
|
||||
#endif
|
||||
@@ -0,0 +1,287 @@
|
||||
/*
|
||||
* nis_object.x
|
||||
*
|
||||
* Copyright (c) 1988-1992 Sun Microsystems Inc
|
||||
* All Rights Reserved.
|
||||
*/
|
||||
|
||||
%#pragma ident "@(#)nis_object.x 1.7 92/07/14 SMI"
|
||||
|
||||
#if RPC_HDR
|
||||
%
|
||||
%#ifndef __nis_object_h
|
||||
%#define __nis_object_h
|
||||
%
|
||||
#endif
|
||||
/*
|
||||
* This file defines the format for a NIS object in RPC language.
|
||||
* It is included by the main .x file and the database access protocol
|
||||
* file. It is common because both of them need to deal with the same
|
||||
* type of object. Generating the actual code though is a bit messy because
|
||||
* the nis.x file and the nis_dba.x file will generate xdr routines to
|
||||
* encode/decode objects when only one set is needed. Such is life when
|
||||
* one is using rpcgen.
|
||||
*
|
||||
* Note, the protocol doesn't specify any limits on such things as
|
||||
* maximum name length, number of attributes, etc. These are enforced
|
||||
* by the database backend. When you hit them you will no. Also see
|
||||
* the db_getlimits() function for fetching the limit values.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Some manifest constants, chosen to maximize flexibility without
|
||||
* plugging the wire full of data.
|
||||
*/
|
||||
const NIS_MAXSTRINGLEN = 255;
|
||||
const NIS_MAXNAMELEN = 1024;
|
||||
const NIS_MAXATTRNAME = 32;
|
||||
const NIS_MAXATTRVAL = 2048;
|
||||
const NIS_MAXCOLUMNS = 64;
|
||||
const NIS_MAXATTR = 16;
|
||||
const NIS_MAXPATH = 1024;
|
||||
const NIS_MAXREPLICAS = 128;
|
||||
const NIS_MAXLINKS = 16;
|
||||
|
||||
const NIS_PK_NONE = 0; /* no public key (unix/sys auth) */
|
||||
const NIS_PK_DH = 1; /* Public key is Diffie-Hellman type */
|
||||
const NIS_PK_RSA = 2; /* Public key if RSA type */
|
||||
const NIS_PK_KERB = 3; /* Use kerberos style authentication */
|
||||
|
||||
/*
|
||||
* The fundamental name type of NIS. The name may consist of two parts,
|
||||
* the first being the fully qualified name, and the second being an
|
||||
* optional set of attribute/value pairs.
|
||||
*/
|
||||
struct nis_attr {
|
||||
string zattr_ndx<>; /* name of the index */
|
||||
opaque zattr_val<>; /* Value for the attribute. */
|
||||
};
|
||||
|
||||
typedef string nis_name<>; /* The NIS name itself. */
|
||||
|
||||
/* NIS object types are defined by the following enumeration. The numbers
|
||||
* they use are based on the following scheme :
|
||||
* 0 - 1023 are reserved for Sun,
|
||||
* 1024 - 2047 are defined to be private to a particular tree.
|
||||
* 2048 - 4095 are defined to be user defined.
|
||||
* 4096 - ... are reserved for future use.
|
||||
*/
|
||||
|
||||
enum zotypes {
|
||||
BOGUS_OBJ = 0, /* Uninitialized object structure */
|
||||
NO_OBJ = 1, /* NULL object (no data) */
|
||||
DIRECTORY_OBJ = 2, /* Directory object describing domain */
|
||||
GROUP_OBJ = 3, /* Group object (a list of names) */
|
||||
TABLE_OBJ = 4, /* Table object (a database schema) */
|
||||
ENTRY_OBJ = 5, /* Entry object (a database record) */
|
||||
LINK_OBJ = 6, /* A name link. */
|
||||
PRIVATE_OBJ = 7 /* Private object (all opaque data) */
|
||||
};
|
||||
|
||||
/*
|
||||
* The types of Name services NIS knows about. They are enumerated
|
||||
* here. The Binder code will use this type to determine if it has
|
||||
* a set of library routines that will access the indicated name service.
|
||||
*/
|
||||
enum nstype {
|
||||
UNKNOWN = 0,
|
||||
NIS = 1, /* Nis Plus Service */
|
||||
SUNYP = 2, /* Old NIS Service */
|
||||
IVY = 3, /* Nis Plus Plus Service */
|
||||
DNS = 4, /* Domain Name Service */
|
||||
X500 = 5, /* ISO/CCCIT X.500 Service */
|
||||
DNANS = 6, /* Digital DECNet Name Service */
|
||||
XCHS = 7, /* Xerox ClearingHouse Service */
|
||||
CDS= 8
|
||||
};
|
||||
|
||||
/*
|
||||
* DIRECTORY - The name service object. These objects identify other name
|
||||
* servers that are serving some portion of the name space. Each has a
|
||||
* type associated with it. The resolver library will note whether or not
|
||||
* is has the needed routines to access that type of service.
|
||||
* The oarmask structure defines an access rights mask on a per object
|
||||
* type basis for the name spaces. The only bits currently used are
|
||||
* create and destroy. By enabling or disabling these access rights for
|
||||
* a specific object type for a one of the accessor entities (owner,
|
||||
* group, world) the administrator can control what types of objects
|
||||
* may be freely added to the name space and which require the
|
||||
* administrator's approval.
|
||||
*/
|
||||
struct oar_mask {
|
||||
u_long oa_rights; /* Access rights mask */
|
||||
zotypes oa_otype; /* Object type */
|
||||
};
|
||||
|
||||
struct endpoint {
|
||||
string uaddr<>;
|
||||
string family<>; /* Transport family (INET, OSI, etc) */
|
||||
string proto<>; /* Protocol (TCP, UDP, CLNP, etc) */
|
||||
};
|
||||
|
||||
/*
|
||||
* Note: pkey is a netobj which is limited to 1024 bytes which limits the
|
||||
* keysize to 8192 bits. This is consider to be a reasonable limit for
|
||||
* the expected lifetime of this service.
|
||||
*/
|
||||
struct nis_server {
|
||||
nis_name name; /* Principal name of the server */
|
||||
endpoint ep<>; /* Universal addr(s) for server */
|
||||
u_long key_type; /* Public key type */
|
||||
netobj pkey; /* server's public key */
|
||||
};
|
||||
|
||||
struct directory_obj {
|
||||
nis_name do_name; /* Name of the directory being served */
|
||||
nstype do_type; /* one of NIS, DNS, IVY, YP, or X.500 */
|
||||
nis_server do_servers<>; /* <0> == Primary name server */
|
||||
u_long do_ttl; /* Time To Live (for caches) */
|
||||
oar_mask do_armask<>; /* Create/Destroy rights by object type */
|
||||
};
|
||||
|
||||
/*
|
||||
* ENTRY - This is one row of data from an information base.
|
||||
* The type value is used by the client library to convert the entry to
|
||||
* it's internal structure representation. The Table name is a back pointer
|
||||
* to the table where the entry is stored. This allows the client library
|
||||
* to determine where to send a request if the client wishes to change this
|
||||
* entry but got to it through a LINK rather than directly.
|
||||
* If the entry is a "standalone" entry then this field is void.
|
||||
*/
|
||||
const EN_BINARY = 1; /* Indicates value is binary data */
|
||||
const EN_CRYPT = 2; /* Indicates the value is encrypted */
|
||||
const EN_XDR = 4; /* Indicates the value is XDR encoded */
|
||||
const EN_MODIFIED = 8; /* Indicates entry is modified. */
|
||||
const EN_ASN1 = 64; /* Means contents use ASN.1 encoding */
|
||||
|
||||
struct entry_col {
|
||||
u_long ec_flags; /* Flags for this value */
|
||||
opaque ec_value<>; /* It's textual value */
|
||||
};
|
||||
|
||||
struct entry_obj {
|
||||
string en_type<>; /* Type of entry such as "passwd" */
|
||||
entry_col en_cols<>; /* Value for the entry */
|
||||
};
|
||||
|
||||
/*
|
||||
* GROUP - The group object contains a list of NIS principal names. Groups
|
||||
* are used to authorize principals. Each object has a set of access rights
|
||||
* for members of its group. Principal names in groups are in the form
|
||||
* name.directory and recursive groups are expressed as @groupname.directory
|
||||
*/
|
||||
struct group_obj {
|
||||
u_long gr_flags; /* Flags controlling group */
|
||||
nis_name gr_members<>; /* List of names in group */
|
||||
};
|
||||
|
||||
/*
|
||||
* LINK - This is the LINK object. It is quite similar to a symbolic link
|
||||
* in the UNIX filesystem. The attributes in the main object structure are
|
||||
* relative to the LINK data and not what it points to (like the file system)
|
||||
* "modify" privleges here indicate the right to modify what the link points
|
||||
* at and not to modify that actual object pointed to by the link.
|
||||
*/
|
||||
struct link_obj {
|
||||
zotypes li_rtype; /* Real type of the object */
|
||||
nis_attr li_attrs<>; /* Attribute/Values for tables */
|
||||
nis_name li_name; /* The object's real NIS name */
|
||||
};
|
||||
|
||||
/*
|
||||
* TABLE - This is the table object. It implements a simple
|
||||
* data base that applications and use for configuration or
|
||||
* administration purposes. The role of the table is to group together
|
||||
* a set of related entries. Tables are the simple database component
|
||||
* of NIS. Like many databases, tables are logically divided into columns
|
||||
* and rows. The columns are labeled with indexes and each ENTRY makes
|
||||
* up a row. Rows may be addressed within the table by selecting one
|
||||
* or more indexes, and values for those indexes. Each row which has
|
||||
* a value for the given index that matches the desired value is returned.
|
||||
* Within the definition of each column there is a flags variable, this
|
||||
* variable contains flags which determine whether or not the column is
|
||||
* searchable, contains binary data, and access rights for the entry objects
|
||||
* column value.
|
||||
*/
|
||||
|
||||
const TA_BINARY = 1; /* Means table data is binary */
|
||||
const TA_CRYPT = 2; /* Means value should be encrypted */
|
||||
const TA_XDR = 4; /* Means value is XDR encoded */
|
||||
const TA_SEARCHABLE = 8; /* Means this column is searchable */
|
||||
const TA_CASE = 16; /* Means this column is Case Sensitive */
|
||||
const TA_MODIFIED = 32; /* Means this columns attrs are modified*/
|
||||
const TA_ASN1 = 64; /* Means contents use ASN.1 encoding */
|
||||
|
||||
struct table_col {
|
||||
string tc_name<64>; /* Column Name */
|
||||
u_long tc_flags; /* control flags */
|
||||
u_long tc_rights; /* Access rights mask */
|
||||
};
|
||||
|
||||
struct table_obj {
|
||||
string ta_type<64>; /* Table type such as "passwd" */
|
||||
int ta_maxcol; /* Total number of columns */
|
||||
u_char ta_sep; /* Separator character */
|
||||
table_col ta_cols<>; /* The number of table indexes */
|
||||
string ta_path<>; /* A search path for this table */
|
||||
};
|
||||
|
||||
/*
|
||||
* This union joins together all of the currently known objects.
|
||||
*/
|
||||
union objdata switch (zotypes zo_type) {
|
||||
case DIRECTORY_OBJ :
|
||||
struct directory_obj di_data;
|
||||
case GROUP_OBJ :
|
||||
struct group_obj gr_data;
|
||||
case TABLE_OBJ :
|
||||
struct table_obj ta_data;
|
||||
case ENTRY_OBJ:
|
||||
struct entry_obj en_data;
|
||||
case LINK_OBJ :
|
||||
struct link_obj li_data;
|
||||
case PRIVATE_OBJ :
|
||||
opaque po_data<>;
|
||||
case NO_OBJ :
|
||||
void;
|
||||
case BOGUS_OBJ :
|
||||
void;
|
||||
default :
|
||||
void;
|
||||
};
|
||||
|
||||
/*
|
||||
* This is the basic NIS object data type. It consists of a generic part
|
||||
* which all objects contain, and a specialized part which varies depending
|
||||
* on the type of the object. All of the specialized sections have been
|
||||
* described above. You might have wondered why they all start with an
|
||||
* integer size, followed by the useful data. The answer is, when the
|
||||
* server doesn't recognize the type returned it treats it as opaque data.
|
||||
* And the definition for opaque data is {int size; char *data;}. In this
|
||||
* way, servers and utility routines that do not understand a given type
|
||||
* may still pass it around. One has to be careful in setting
|
||||
* this variable accurately, it must take into account such things as
|
||||
* XDR padding of structures etc. The best way to set it is to note one's
|
||||
* position in the XDR encoding stream, encode the structure, look at the
|
||||
* new position and calculate the size.
|
||||
*/
|
||||
struct nis_oid {
|
||||
u_long ctime; /* Time of objects creation */
|
||||
u_long mtime; /* Time of objects modification */
|
||||
};
|
||||
|
||||
struct nis_object {
|
||||
nis_oid zo_oid; /* object identity verifier. */
|
||||
nis_name zo_name; /* The NIS name for this object */
|
||||
nis_name zo_owner; /* NIS name of object owner. */
|
||||
nis_name zo_group; /* NIS name of access group. */
|
||||
nis_name zo_domain; /* The administrator for the object */
|
||||
u_long zo_access; /* Access rights (owner, group, world) */
|
||||
u_long zo_ttl; /* Object's time to live in seconds. */
|
||||
objdata zo_data; /* Data structure for this type */
|
||||
};
|
||||
#if RPC_HDR
|
||||
%
|
||||
%#endif /* if __nis_object_h */
|
||||
%
|
||||
#endif
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 1991, Sun Microsystems Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* nis_tags.h
|
||||
*
|
||||
* This file contains the tags and statistics definitions. It is
|
||||
* automatically included by nis.h
|
||||
*/
|
||||
|
||||
#ifndef _RPCSVC_NIS_TAGS_H
|
||||
#define _RPCSVC_NIS_TAGS_H
|
||||
|
||||
#pragma ident "@(#)nis_tags.h 1.13 95/02/17 SMI"
|
||||
/* from file: zns_tags.h 1.7 Copyright (c) 1990 Sun Microsystems */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define NIS_DIR "data"
|
||||
|
||||
/* Lookup and List function flags */
|
||||
#define FOLLOW_LINKS (1<<0) /* Follow link objects */
|
||||
#define FOLLOW_PATH (1<<1) /* Follow the path in a table */
|
||||
#define HARD_LOOKUP (1<<2) /* Block until successful */
|
||||
#define ALL_RESULTS (1<<3) /* Retrieve all results */
|
||||
#define NO_CACHE (1<<4) /* Do not return 'cached' results */
|
||||
#define MASTER_ONLY (1<<5) /* Get value only from master server */
|
||||
#define EXPAND_NAME (1<<6) /* Expand partitially qualified names */
|
||||
|
||||
/* Semantic modification for table operations flags */
|
||||
#define RETURN_RESULT (1<<7) /* Return resulting object to client */
|
||||
#define ADD_OVERWRITE (1<<8) /* Allow overwrites on ADD */
|
||||
#define REM_MULTIPLE (1<<9) /* Allow wildcard deletes */
|
||||
#define MOD_SAMEOBJ (1<<10) /* Check modified object before write */
|
||||
#define ADD_RESERVED (1<<11) /* Spare ADD semantic */
|
||||
#define REM_RESERVED (1<<12) /* Spare REM semantic */
|
||||
#define MOD_EXCLUSIVE (1<<13) /* Modify no overwrite on modified keys */
|
||||
|
||||
/* Transport specific modifications to the operation */
|
||||
#define USE_DGRAM (1<<16) /* Use a datagram transport */
|
||||
#define NO_AUTHINFO (1<<17) /* Don't bother attaching auth info */
|
||||
|
||||
/*
|
||||
* Declarations for "standard" NIS+ tags
|
||||
* State variable tags have values 0 - 2047
|
||||
* Statistic tags have values 2048 - 65535
|
||||
* User Tags have values >2^16
|
||||
*/
|
||||
#define TAG_DEBUG 1 /* set debug level */
|
||||
#define TAG_STATS 2 /* Enable/disable statistics */
|
||||
#define TAG_GCACHE 3 /* Flush the Group Cache */
|
||||
#define TAG_GCACHE_ALL TAG_GCACHE
|
||||
#define TAG_DCACHE 4 /* Flush the directory cache */
|
||||
#define TAG_DCACHE_ONE TAG_DCACHE
|
||||
#define TAG_OCACHE 5 /* Flush the Object Cache */
|
||||
#define TAG_SECURE 6 /* Set the security level */
|
||||
#define TAG_TCACHE_ONE 7 /* Flush the table cache */
|
||||
#define TAG_DCACHE_ALL 8 /* Flush entire directory cache */
|
||||
#define TAG_TCACHE_ALL 9 /* Flush entire table cache */
|
||||
#define TAG_GCACHE_ONE 10 /* Flush one group object */
|
||||
#define TAG_DCACHE_ONE_REFRESH 11 /* Flush and refresh one DO */
|
||||
|
||||
#define TAG_OPSTATS 2048 /* NIS+ operations statistics */
|
||||
#define TAG_THREADS 2049 /* Child process/thread status */
|
||||
#define TAG_HEAP 2050 /* Heap usage statistics */
|
||||
#define TAG_UPDATES 2051 /* Updates to this service */
|
||||
#define TAG_VISIBLE 2052 /* First update that isn't replicated */
|
||||
#define TAG_S_DCACHE 2053 /* Directory cache statistics */
|
||||
#define TAG_S_OCACHE 2054 /* Object cache statistics */
|
||||
#define TAG_S_GCACHE 2055 /* Group cache statistics */
|
||||
#define TAG_S_STORAGE 2056 /* Group cache statistics */
|
||||
#define TAG_UPTIME 2057 /* Time that server has been up */
|
||||
#define TAG_DIRLIST 2058 /* Dir served by this server */
|
||||
#define TAG_NISCOMPAT 2059 /* Whether supports NIS compat mode */
|
||||
#define TAG_DNSFORWARDING 2060 /* Whether DNS forwarding supported */
|
||||
#define TAG_SECURITY_LEVEL 2061 /* Security level of the server */
|
||||
#define TAG_ROOTSERVER 2062 /* Whether root server */
|
||||
|
||||
/*
|
||||
* Declarations for the Group object flags. Currently
|
||||
* there are only 3.
|
||||
*/
|
||||
#define IMPMEM_GROUPS 1 /* Implicit Membership allowed */
|
||||
#define RECURS_GROUPS 2 /* Recursive Groups allowed */
|
||||
#define NEGMEM_GROUPS 4 /* Negative Groups allowed */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _RPCSVC_NIS_TAGS_H */
|
||||
@@ -0,0 +1,165 @@
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 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 <features.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*
|
||||
** nis_names
|
||||
*/
|
||||
extern nis_result *nis_lookup __P ((__const nis_name, const u_long));
|
||||
extern nis_result *nis_add __P ((__const nis_name, const nis_object *));
|
||||
extern nis_result *nis_remove __P ((__const nis_name, const nis_object *));
|
||||
extern nis_result *nis_modify __P ((__const nis_name, const nis_object *));
|
||||
/*
|
||||
** nis_table
|
||||
*/
|
||||
extern nis_result *nis_list __P ((__const nis_name, const u_long,
|
||||
int (*)(__const nis_name,
|
||||
__const nis_object *,
|
||||
__const void *), __const void *));
|
||||
extern nis_result *nis_add_entry __P ((__const nis_name, __const nis_object *,
|
||||
__const u_long));
|
||||
extern nis_result *nis_modify_entry __P ((__const nis_name,
|
||||
__const nis_object *,
|
||||
__const u_long));
|
||||
extern nis_result *nis_remove_entry __P ((__const nis_name,
|
||||
__const nis_object *,
|
||||
__const u_long));
|
||||
extern nis_result *nis_first_entry __P ((__const nis_name));
|
||||
extern nis_result *nis_next_entry __P ((__const nis_name, __const netobj *));
|
||||
/*
|
||||
** nis_server
|
||||
*/
|
||||
extern nis_error nis_mkdir __P ((__const nis_name, __const nis_server *));
|
||||
extern nis_error nis_rmdir __P ((__const nis_name, __const nis_server *));
|
||||
extern nis_error nis_servstate __P ((__const nis_server *, __const nis_tag *,
|
||||
__const int, nis_tag **));
|
||||
extern nis_error nis_stats __P ((__const nis_server *, __const nis_tag *,
|
||||
__const int, nis_tag **));
|
||||
extern void nis_freetags __P ((nis_tag *, __const int));
|
||||
extern nis_server **nis_getservlist __P ((__const nis_name));
|
||||
extern void nis_freeservlist __P ((nis_server **));
|
||||
/*
|
||||
** nis_subr
|
||||
*/
|
||||
extern nis_name nis_leaf_of __P ((__const nis_name));
|
||||
extern nis_name nis_leaf_of_r __P ((__const nis_name, char *, size_t));
|
||||
extern nis_name nis_name_of __P ((__const nis_name));
|
||||
extern nis_name nis_name_of_r __P ((__const nis_name, char *, size_t));
|
||||
extern nis_name nis_domain_of __P ((__const nis_name));
|
||||
extern nis_name nis_domain_of_r __P ((__const nis_name, char *, size_t));
|
||||
extern nis_name *nis_getnames __P ((__const nis_name));
|
||||
extern void nis_freenames __P ((nis_name *));
|
||||
extern name_pos nis_dir_cmp __P ((nis_name, nis_name));
|
||||
extern nis_object *nis_clone_object __P ((__const nis_object *, nis_object *));
|
||||
extern void nis_destroy_object __P ((nis_object *));
|
||||
extern void nis_print_object __P ((__const nis_object *));
|
||||
/*
|
||||
** 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));
|
||||
extern void nis_perror __P ((__const nis_error, __const char *));
|
||||
extern void nis_lerror __P ((__const nis_error, __const char *));
|
||||
extern char *nis_sperror __P ((__const nis_error, __const char *));
|
||||
extern char *nis_sperror_r __P ((__const nis_error, __const char *,
|
||||
char *, size_t));
|
||||
/*
|
||||
** nis_groups
|
||||
*/
|
||||
extern bool_t nis_ismember __P ((__const nis_name, __const nis_name));
|
||||
extern nis_error nis_addmember __P ((__const nis_name, __const nis_name));
|
||||
extern nis_error nis_removemember __P ((__const nis_name, __const nis_name));
|
||||
extern nis_error nis_creategroup __P ((__const nis_name, __const u_long));
|
||||
extern nis_error nis_destroygroup __P ((__const nis_name));
|
||||
extern void nis_print_group_entry __P ((__const nis_name));
|
||||
extern nis_error nis_verifygroup __P ((__const nis_name));
|
||||
/*
|
||||
** nis_ping
|
||||
*/
|
||||
extern void nis_ping __P ((__const nis_name, __const u_long,
|
||||
__const nis_object *));
|
||||
extern nis_result *nis_checkpoint __P ((__const nis_name));
|
||||
|
||||
/*
|
||||
** nis_print (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
|
||||
*/
|
||||
extern void nis_print_result __P ((__const nis_result *));
|
||||
extern void nis_print_rights __P ((__const u_long));
|
||||
extern void nis_print_directory __P ((__const directory_obj *));
|
||||
extern void nis_print_group __P ((__const group_obj *));
|
||||
extern void nis_print_table __P ((__const table_obj *));
|
||||
extern void nis_print_link __P ((__const link_obj *));
|
||||
extern void nis_print_entry __P ((__const entry_obj *));
|
||||
/*
|
||||
** nis_file (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
|
||||
*/
|
||||
extern directory_obj *readColdStartFile __P ((void));
|
||||
extern bool_t writeColdStartFile __P ((__const directory_obj *));
|
||||
extern nis_object *nis_read_obj __P ((__const char *));
|
||||
extern bool_t nis_write_obj __P ((__const char *, __const nis_object *));
|
||||
/*
|
||||
** nis_clone - (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!)
|
||||
*/
|
||||
|
||||
extern directory_obj *nis_clone_directory __P ((__const directory_obj *,
|
||||
directory_obj *));
|
||||
extern group_obj *nis_clone_group __P ((__const group_obj *, group_obj *));
|
||||
extern table_obj *nis_clone_table __P ((__const table_obj *, table_obj *));
|
||||
extern entry_obj *nis_clone_entry __P ((__const entry_obj *, entry_obj *));
|
||||
extern link_obj *nis_clone_link __P ((__const link_obj *, link_obj *));
|
||||
extern objdata *nis_clone_objdata __P ((__const objdata *, objdata *));
|
||||
extern nis_result *nis_clone_result __P ((__const nis_result *, nis_result *));
|
||||
/*
|
||||
** nis_free - nis_freeresult
|
||||
*/
|
||||
extern void nis_freeresult __P ((nis_result *));
|
||||
/* (XXX INTERNAL FUNCTIONS, SHOULD NOT BE USED !!) */
|
||||
extern void nis_free_attr __P ((nis_attr *));
|
||||
extern void nis_free_request __P ((ib_request *));
|
||||
extern void nis_free_endpoints __P ((endpoint *, unsigned int));
|
||||
extern void nis_free_servers __P ((nis_server *, unsigned int));
|
||||
extern void nis_free_directory __P ((directory_obj *));
|
||||
extern void nis_free_group __P ((group_obj *));
|
||||
extern void nis_free_table __P ((table_obj *));
|
||||
extern void nis_free_entry __P ((entry_obj *));
|
||||
extern void nis_free_link __P ((link_obj *));
|
||||
extern void nis_free_object __P ((nis_object *));
|
||||
|
||||
/* This is the SUN definition, but I don't know for what we need
|
||||
the directory_obj parameter */
|
||||
/* extern fd_result *nis_finddirectory __P ((directory_obj *, nis_name)); */
|
||||
extern fd_result *__nis_finddirectory __P ((nis_name));
|
||||
extern int __start_clock(int);
|
||||
extern u_long __stop_clock(int);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* __RPCSVC_NISLIB_H__ */
|
||||
+30
-29
@@ -1,23 +1,22 @@
|
||||
/*
|
||||
** Copyright (c) 1996 Thorsten Kukuk, Germany
|
||||
**
|
||||
** This 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.
|
||||
**
|
||||
** This 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 this library; if not, write to the Free
|
||||
** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
**
|
||||
** Author: Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
|
||||
**
|
||||
*/
|
||||
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
#ifndef __RPCSVC_YPCLNT_H__
|
||||
#define __RPCSVC_YPCLNT_H__
|
||||
@@ -52,24 +51,26 @@
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* struct ypall_callback * is the arg which must be passed to yp_all */
|
||||
struct ypall_callback {
|
||||
int (*foreach)();
|
||||
char *data;
|
||||
};
|
||||
struct ypall_callback
|
||||
{
|
||||
int (*foreach) __P ((int __status, char *__key, int __keylen,
|
||||
char *__val, int __vallen, char *__data));
|
||||
char *data;
|
||||
};
|
||||
|
||||
/* External NIS client function references. */
|
||||
extern int yp_bind __P ((__const char *));
|
||||
extern void yp_unbind __P ((__const char *));
|
||||
extern int yp_get_default_domain __P ((char **));
|
||||
extern int yp_match __P ((__const char *, __const char *, __const char *,
|
||||
extern int yp_match __P ((__const char *, __const char *, __const char *,
|
||||
__const int, char **, int *));
|
||||
extern int yp_first __P ((__const char *, __const char *, char **,
|
||||
extern int yp_first __P ((__const char *, __const char *, char **,
|
||||
int *, char **, int *));
|
||||
extern int yp_next __P ((__const char *, __const char *, __const char *,
|
||||
extern int yp_next __P ((__const char *, __const char *, __const char *,
|
||||
__const int, char **, int *, char **, int *));
|
||||
extern int yp_master __P ((__const char *, __const char *, char **));
|
||||
extern int yp_order __P ((__const char *, __const char *, unsigned int *));
|
||||
extern int yp_all __P ((__const char *, __const char *,
|
||||
extern int yp_all __P ((__const char *, __const char *,
|
||||
__const struct ypall_callback *));
|
||||
extern __const char *yperr_string __P ((__const int));
|
||||
extern __const char *ypbinderr_string __P ((__const int));
|
||||
@@ -81,7 +82,7 @@ extern int yp_maplist __P ((__const char *, struct ypmaplist **));
|
||||
#endif
|
||||
|
||||
/* Exist only under BSD and Linux systems */
|
||||
extern int __yp_check __P ((char **));
|
||||
extern int __yp_check __P ((char **));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
+7
-5
@@ -123,9 +123,9 @@ __yp_bind (const char *domain, dom_binding ** ypdb)
|
||||
}
|
||||
|
||||
if (clnt_call (client, YPBINDPROC_DOMAIN,
|
||||
(xdrproc_t) xdr_domainname, &domain,
|
||||
(xdrproc_t) xdr_domainname, (caddr_t) &domain,
|
||||
(xdrproc_t) xdr_ypbind_resp,
|
||||
&ypbr, TIMEOUT) != RPC_SUCCESS)
|
||||
(caddr_t) &ypbr, TIMEOUT) != RPC_SUCCESS)
|
||||
{
|
||||
clnt_destroy (client);
|
||||
if (is_new)
|
||||
@@ -526,7 +526,8 @@ yp_order (const char *indomain, const char *inmap, unsigned int *outorder)
|
||||
}
|
||||
|
||||
static void *ypall_data;
|
||||
static int (*ypall_foreach) ();
|
||||
static int (*ypall_foreach) __P ((int status, char *key, int keylen,
|
||||
char *val, int vallen, char *data));
|
||||
|
||||
static bool_t
|
||||
__xdr_ypresp_all (XDR * xdrs, u_long * objp)
|
||||
@@ -628,8 +629,9 @@ yp_all (const char *indomain, const char *inmap,
|
||||
ypall_foreach = incallback->foreach;
|
||||
ypall_data = (void *) incallback->data;
|
||||
|
||||
result = clnt_call (clnt, YPPROC_ALL, (xdrproc_t) xdr_ypreq_nokey, &req,
|
||||
(xdrproc_t) __xdr_ypresp_all, &status, TIMEOUT);
|
||||
result = clnt_call (clnt, YPPROC_ALL, (xdrproc_t) xdr_ypreq_nokey,
|
||||
(caddr_t) &req, (xdrproc_t) __xdr_ypresp_all,
|
||||
(caddr_t) &status, TIMEOUT);
|
||||
|
||||
if (result != RPC_SUCCESS)
|
||||
{
|
||||
|
||||
@@ -41,8 +41,8 @@ LINE_PARSER
|
||||
|
||||
DB_LOOKUP (servbyname, 1 + strlen (name), (".%s/%s", name, proto),
|
||||
{
|
||||
/* Must match both protocol and name. */
|
||||
if (strcmp (result->s_proto, proto))
|
||||
/* Must match both protocol (if specified) and name. */
|
||||
if (proto != NULL && strcmp (result->s_proto, proto))
|
||||
continue;
|
||||
LOOKUP_NAME (s_name, s_aliases)
|
||||
},
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
[a-z]*.pot *.mo
|
||||
ttt
|
||||
|
||||
+3
-1
@@ -253,7 +253,9 @@ static int last_nonopt;
|
||||
/* Bash 2.0 gives us an environment variable containing flags
|
||||
indicating ARGV elements that should not be considered arguments. */
|
||||
|
||||
char *__getopt_nonoption_flags;
|
||||
/* Defined in getopt_init.c */
|
||||
extern char *__getopt_nonoption_flags;
|
||||
|
||||
static int nonoption_flags_max_len;
|
||||
static int nonoption_flags_len;
|
||||
|
||||
|
||||
+2
-2
@@ -29,8 +29,8 @@
|
||||
|
||||
#include "../stdio-common/_itoa.h"
|
||||
|
||||
/* External variable to synchronize work. */
|
||||
extern char *__getopt_nonoption_flags;
|
||||
/* Variable to synchronize work. */
|
||||
char *__getopt_nonoption_flags;
|
||||
|
||||
extern pid_t __libc_pid;
|
||||
|
||||
|
||||
+188
-108
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@@ -33,6 +33,10 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* Outcomment the following line for production quality code. */
|
||||
/* #define NDEBUG 1 */
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
@@ -159,7 +163,7 @@ extern void bcopy ();
|
||||
((void) ((better_be_zero) == 0 ? (bzero((s), (n)), 0) : (abort(), 0)))
|
||||
#endif /* Not ANSI_STRING. */
|
||||
|
||||
#ifndef HAVE_STRCOLL
|
||||
#if !defined HAVE_STRCOLL && !defined _LIBC
|
||||
#define strcoll strcmp
|
||||
#endif
|
||||
|
||||
@@ -254,6 +258,51 @@ static int glob_in_dir __P ((const char *pattern, const char *directory,
|
||||
static int prefix_array __P ((const char *prefix, char **array, size_t n));
|
||||
static int collated_compare __P ((const __ptr_t, const __ptr_t));
|
||||
|
||||
|
||||
/* Find the end of the sub-pattern in a brace expression. We define
|
||||
this as an inline function if the compiler permits. */
|
||||
static
|
||||
#if __GNUC__ - 0 >= 2
|
||||
inline
|
||||
#endif
|
||||
const char *
|
||||
next_brace_sub (const char *begin)
|
||||
{
|
||||
unsigned int depth = 0;
|
||||
const char *cp = begin;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (depth == 0)
|
||||
{
|
||||
if (*cp != ',' && *cp != '}' && *cp != '\0')
|
||||
{
|
||||
if (*cp == '{')
|
||||
++depth;
|
||||
++cp;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (*cp != '\0' && (*cp != '}' || depth > 0))
|
||||
{
|
||||
if (*cp == '}')
|
||||
++depth;
|
||||
++cp;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
/* An incorrectly terminated brace expression. */
|
||||
return NULL;
|
||||
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return cp;
|
||||
}
|
||||
|
||||
/* Do glob searching for PATTERN, placing results in PGLOB.
|
||||
The bits defined above may be set in FLAGS.
|
||||
If a directory cannot be opened or read and ERRFUNC is not nil,
|
||||
@@ -286,38 +335,59 @@ glob (pattern, flags, errfunc, pglob)
|
||||
const char *begin = strchr (pattern, '{');
|
||||
if (begin != NULL)
|
||||
{
|
||||
/* Allocate working buffer large enough for our work. Note that
|
||||
we have at least an opening and closing brace. */
|
||||
int firstc;
|
||||
size_t restlen;
|
||||
const char *p, *end, *next;
|
||||
unsigned int depth = 0;
|
||||
|
||||
/* Find the end of the brace expression, by counting braces.
|
||||
While we're at it, notice the first comma at top brace level. */
|
||||
end = begin + 1;
|
||||
next = NULL;
|
||||
while (1)
|
||||
char *alt_start;
|
||||
const char *p;
|
||||
const char *next;
|
||||
const char *rest;
|
||||
size_t rest_len;
|
||||
#ifdef __GNUC__
|
||||
char onealt[strlen (pattern) - 1];
|
||||
#else
|
||||
char *onealt = (char *) malloc (strlen (pattern) - 1);
|
||||
if (onealt == NULL)
|
||||
{
|
||||
switch (*end++)
|
||||
{
|
||||
case ',':
|
||||
if (depth == 0 && next == NULL)
|
||||
next = end;
|
||||
continue;
|
||||
case '{':
|
||||
++depth;
|
||||
continue;
|
||||
case '}':
|
||||
if (depth-- == 0)
|
||||
break;
|
||||
continue;
|
||||
case '\0':
|
||||
return glob (pattern, flags &~ GLOB_BRACE, errfunc, pglob);
|
||||
}
|
||||
break;
|
||||
if (!(flags & GLOB_APPEND))
|
||||
globfree (pglob);
|
||||
return GLOB_NOSPACE;
|
||||
}
|
||||
restlen = strlen (end) + 1;
|
||||
#endif
|
||||
|
||||
/* We know the prefix for all sub-patterns. */
|
||||
memcpy (onealt, pattern, begin - pattern);
|
||||
alt_start = &onealt[begin - pattern];
|
||||
|
||||
/* Find the first sub-pattern and at the same time find the
|
||||
rest after the closing brace. */
|
||||
next = next_brace_sub (begin + 1);
|
||||
if (next == NULL)
|
||||
next = end;
|
||||
{
|
||||
/* It is an illegal expression. */
|
||||
#ifndef __GNUC__
|
||||
free (onealt);
|
||||
#endif
|
||||
return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob);
|
||||
}
|
||||
|
||||
/* Now find the end of the whole brace expression. */
|
||||
rest = next;
|
||||
while (*rest != '}')
|
||||
{
|
||||
rest = next_brace_sub (rest + 1);
|
||||
if (rest == NULL)
|
||||
{
|
||||
/* It is an illegal expression. */
|
||||
#ifndef __GNUC__
|
||||
free (onealt);
|
||||
#endif
|
||||
return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob);
|
||||
}
|
||||
}
|
||||
/* Please note that we now can be sure the brace expression
|
||||
is well-formed. */
|
||||
rest_len = strlen (++rest) + 1;
|
||||
|
||||
/* We have a brace expression. BEGIN points to the opening {,
|
||||
NEXT points past the terminator of the first element, and END
|
||||
@@ -334,72 +404,47 @@ glob (pattern, flags, errfunc, pglob)
|
||||
}
|
||||
firstc = pglob->gl_pathc;
|
||||
|
||||
/* In this loop P points to the beginning of the current element
|
||||
and NEXT points past its terminator. */
|
||||
p = begin + 1;
|
||||
while (1)
|
||||
{
|
||||
/* Construct a whole name that is one of the brace
|
||||
alternatives in a temporary buffer. */
|
||||
int result;
|
||||
size_t bufsz = (begin - pattern) + (next - 1 - p) + restlen;
|
||||
#ifdef __GNUC__
|
||||
char onealt[bufsz];
|
||||
#else
|
||||
char *onealt = malloc (bufsz);
|
||||
if (onealt == NULL)
|
||||
{
|
||||
if (!(flags & GLOB_APPEND))
|
||||
globfree (pglob);
|
||||
return GLOB_NOSPACE;
|
||||
}
|
||||
#endif
|
||||
memcpy (onealt, pattern, begin - pattern);
|
||||
memcpy (&onealt[begin - pattern], p, next - 1 - p);
|
||||
memcpy (&onealt[(begin - pattern) + (next - 1 - p)],
|
||||
end, restlen);
|
||||
|
||||
/* Construct the new glob expression. */
|
||||
memcpy (alt_start, p, next - p);
|
||||
memcpy (&alt_start[next - p], rest, rest_len);
|
||||
|
||||
result = glob (onealt,
|
||||
((flags & ~(GLOB_NOCHECK|GLOB_NOMAGIC)) |
|
||||
GLOB_APPEND), errfunc, pglob);
|
||||
#ifndef __GNUC__
|
||||
free (onealt);
|
||||
#endif
|
||||
((flags & ~(GLOB_NOCHECK|GLOB_NOMAGIC))
|
||||
| GLOB_APPEND), errfunc, pglob);
|
||||
|
||||
/* If we got an error, return it. */
|
||||
if (result && result != GLOB_NOMATCH)
|
||||
{
|
||||
#ifndef __GNUC__
|
||||
free (onealt);
|
||||
#endif
|
||||
if (!(flags & GLOB_APPEND))
|
||||
globfree (pglob);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Advance past this alternative and process the next. */
|
||||
p = next;
|
||||
depth = 0;
|
||||
scan:
|
||||
switch (*p++)
|
||||
{
|
||||
case ',':
|
||||
if (depth == 0)
|
||||
{
|
||||
/* Found the next alternative. Loop to glob it. */
|
||||
next = p;
|
||||
continue;
|
||||
}
|
||||
goto scan;
|
||||
case '{':
|
||||
++depth;
|
||||
goto scan;
|
||||
case '}':
|
||||
if (depth-- == 0)
|
||||
/* End of the brace expression. Break out of the loop. */
|
||||
break;
|
||||
goto scan;
|
||||
}
|
||||
if (*next == '}')
|
||||
/* We saw the last entry. */
|
||||
break;
|
||||
|
||||
p = next + 1;
|
||||
next = next_brace_sub (p);
|
||||
assert (next != NULL);
|
||||
}
|
||||
|
||||
if (pglob->gl_pathc == firstc &&
|
||||
!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
|
||||
#ifndef __GNUC__
|
||||
free (onealt);
|
||||
#endif
|
||||
|
||||
if (pglob->gl_pathc != firstc)
|
||||
/* We found some entries. */
|
||||
return 0;
|
||||
else if (!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
|
||||
return GLOB_NOMATCH;
|
||||
}
|
||||
}
|
||||
@@ -452,19 +497,19 @@ glob (pattern, flags, errfunc, pglob)
|
||||
#ifndef VMS
|
||||
if ((flags & GLOB_TILDE) && dirname[0] == '~')
|
||||
{
|
||||
if (dirname[1] == '\0')
|
||||
if (dirname[1] == '\0' || dirname[1] == '/')
|
||||
{
|
||||
/* Look up home directory. */
|
||||
dirname = getenv ("HOME");
|
||||
char *home_dir = getenv ("HOME");
|
||||
#ifdef _AMIGA
|
||||
if (dirname == NULL || dirname[0] == '\0')
|
||||
dirname = "SYS:";
|
||||
if (home_dir == NULL || home_dir[0] == '\0')
|
||||
home_dir = "SYS:";
|
||||
#else
|
||||
#ifdef WIN32
|
||||
if (dirname == NULL || dirname[0] == '\0')
|
||||
dirname = "c:/users/default"; /* poor default */
|
||||
if (home_dir == NULL || home_dir[0] == '\0')
|
||||
home_dir = "c:/users/default"; /* poor default */
|
||||
#else
|
||||
if (dirname == NULL || dirname[0] == '\0')
|
||||
if (home_dir == NULL || home_dir[0] == '\0')
|
||||
{
|
||||
extern char *getlogin __P ((void));
|
||||
extern int getlogin_r __P ((char *, size_t));
|
||||
@@ -501,39 +546,74 @@ glob (pattern, flags, errfunc, pglob)
|
||||
success = p != NULL;
|
||||
#endif
|
||||
if (success)
|
||||
dirname = p->pw_dir;
|
||||
home_dir = p->pw_dir;
|
||||
}
|
||||
}
|
||||
if (dirname == NULL || dirname[0] == '\0')
|
||||
dirname = (char *) "~"; /* No luck. */
|
||||
if (home_dir == NULL || home_dir[0] == '\0')
|
||||
home_dir = (char *) "~"; /* No luck. */
|
||||
#endif /* WIN32 */
|
||||
#endif
|
||||
/* Now construct the full directory. */
|
||||
if (dirname[1] == '\0')
|
||||
dirname = home_dir;
|
||||
else
|
||||
{
|
||||
char *newp;
|
||||
size_t home_len = strlen (home_dir);
|
||||
newp = __alloca (home_len + dirlen);
|
||||
memcpy (newp, home_dir, home_len);
|
||||
memcpy (&newp[home_len], &dirname[1], dirlen);
|
||||
dirname = newp;
|
||||
}
|
||||
}
|
||||
#if !defined _AMIGA && !defined WIN32
|
||||
else
|
||||
{
|
||||
#ifdef _AMIGA
|
||||
if (dirname == NULL || dirname[0] == '\0')
|
||||
dirname = "SYS:";
|
||||
#else
|
||||
#ifdef WIN32
|
||||
if (dirname == NULL || dirname[0] == '\0')
|
||||
dirname = "c:/users/default"; /* poor default */
|
||||
#else
|
||||
char *end_name = strchr (dirname, '/');
|
||||
char *user_name;
|
||||
char *home_dir;
|
||||
|
||||
if (end_name == NULL)
|
||||
user_name = dirname + 1;
|
||||
else
|
||||
{
|
||||
user_name = __alloca (end_name - dirname);
|
||||
memcpy (user_name, dirname + 1, end_name - dirname);
|
||||
user_name[end_name - dirname - 1] = '\0';
|
||||
}
|
||||
|
||||
/* Look up specific user's home directory. */
|
||||
{
|
||||
#if defined HAVE_GETPWNAM_R || defined _LIBC
|
||||
size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
|
||||
char *pwtmpbuf = __alloca (buflen);
|
||||
struct passwd pwbuf, *p;
|
||||
if (__getpwnam_r (dirname + 1, &pwbuf, pwtmpbuf, buflen, &p) >= 0)
|
||||
dirname = p->pw_dir;
|
||||
size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
|
||||
char *pwtmpbuf = __alloca (buflen);
|
||||
struct passwd pwbuf, *p;
|
||||
if (__getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) >= 0)
|
||||
home_dir = p->pw_dir;
|
||||
else
|
||||
home_dir = NULL;
|
||||
#else
|
||||
struct passwd *p = getpwnam (dirname + 1);
|
||||
if (p != NULL)
|
||||
dirname = p->pw_dir;
|
||||
#endif
|
||||
#endif /* WIN32 */
|
||||
struct passwd *p = getpwnam (user_name);
|
||||
if (p != NULL)
|
||||
home_dir = p->pw_dir;
|
||||
else
|
||||
home_dir = NULL;
|
||||
#endif
|
||||
}
|
||||
/* If we found a home directory use this. */
|
||||
if (home_dir != NULL)
|
||||
{
|
||||
char *newp;
|
||||
size_t home_len = strlen (home_dir);
|
||||
size_t rest_len = end_name == NULL ? 0 : strlen (end_name);
|
||||
newp = __alloca (home_len + rest_len + 1);
|
||||
memcpy (newp, home_dir, home_len);
|
||||
memcpy (&newp[home_len], end_name, rest_len);
|
||||
newp[home_len + rest_len] = '\0';
|
||||
dirname = newp;
|
||||
}
|
||||
}
|
||||
#endif /* Not Amiga && not Win32. */
|
||||
}
|
||||
#endif /* Not VMS. */
|
||||
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
|
||||
/* 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
|
||||
@@ -51,7 +51,7 @@ extern int __sigsetjmp __P ((jmp_buf __env, int __savemask));
|
||||
#ifndef __FAVOR_BSD
|
||||
/* Set ENV to the current position and return 0, not saving the signal mask.
|
||||
This is just like `sigsetjmp (ENV, 0)'.
|
||||
The ANSI C standard says `setjmp' is a macro. */
|
||||
The ISO C standard says `setjmp' is a macro. */
|
||||
#define setjmp(env) __sigsetjmp ((env), 0)
|
||||
#else
|
||||
/* We are in 4.3 BSD-compatibility mode in which `setjmp'
|
||||
@@ -61,7 +61,7 @@ extern int __sigsetjmp __P ((jmp_buf __env, int __savemask));
|
||||
|
||||
#ifdef __USE_BSD
|
||||
/* Set ENV to the current position and return 0, not saving the signal mask.
|
||||
This is the 4.3 BSD name for ANSI `setjmp'. */
|
||||
This is the 4.3 BSD name for ISO `setjmp'. */
|
||||
#define _setjmp(env) __sigsetjmp ((env), 0)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -52,6 +52,62 @@ main (void)
|
||||
jump (value + 1);
|
||||
}
|
||||
|
||||
if (!lose && value == 10)
|
||||
{
|
||||
/* Do a second test, this time without `setjmp' being a macro.
|
||||
This is not required by ISO C but we have this for compatibility. */
|
||||
#undef setjmp
|
||||
extern int setjmp (jmp_buf);
|
||||
|
||||
last_value = -1;
|
||||
lose = 0;
|
||||
|
||||
value = setjmp (env);
|
||||
if (value != last_value + 1)
|
||||
{
|
||||
fputs("Shouldn't have ", stdout);
|
||||
lose = 1;
|
||||
}
|
||||
last_value = value;
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
puts("Saved environment.");
|
||||
jump (0);
|
||||
default:
|
||||
printf ("Jumped to %d.\n", value);
|
||||
if (value < 10)
|
||||
jump (value + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!lose && value == 10)
|
||||
{
|
||||
/* And again for the `__setjmp' function. */
|
||||
extern int __setjmp (jmp_buf);
|
||||
|
||||
last_value = -1;
|
||||
lose = 0;
|
||||
|
||||
value = __setjmp (env);
|
||||
if (value != last_value + 1)
|
||||
{
|
||||
fputs("Shouldn't have ", stdout);
|
||||
lose = 1;
|
||||
}
|
||||
last_value = value;
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
puts("Saved environment.");
|
||||
jump (0);
|
||||
default:
|
||||
printf ("Jumped to %d.\n", value);
|
||||
if (value < 10)
|
||||
jump (value + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (lose || value != 10)
|
||||
puts ("Test FAILED!");
|
||||
else
|
||||
|
||||
+3
-1
@@ -56,13 +56,15 @@ alpha-.*-linux.* libnss_dns=1.1
|
||||
alpha-.*-linux.* libnss_db=1.1
|
||||
alpha-.*-linux.* libnss_compat=1.1
|
||||
alpha-.*-linux.* libnss_nis=1.1
|
||||
alpha-.*-linux.* libnss_nisplus=1.1
|
||||
.*-.*-.* libnss_files=1
|
||||
.*-.*-.* libnss_dns=1
|
||||
.*-.*-.* libnss_db=1
|
||||
.*-.*-.* libnss_compat=1
|
||||
.*-.*-.* libnss_nis=1
|
||||
.*-.*-.* libnss_nisplus=1
|
||||
|
||||
# Version for libnsl with YP functions.
|
||||
# Version for libnsl with YP and NIS+ functions.
|
||||
alpha-.*-linux.* libnsl=1.1
|
||||
.*-.*-.* libnsl=1
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ headers := stdio_lim.h printf.h
|
||||
routines := \
|
||||
ctermid cuserid \
|
||||
vfprintf vprintf printf_fp reg-printf printf-prs _itoa printf_fphex \
|
||||
fprintf printf snprintf sprintf asprintf dprintf \
|
||||
printf_size fprintf printf snprintf sprintf asprintf dprintf \
|
||||
vfscanf \
|
||||
fscanf scanf sscanf \
|
||||
perror psignal \
|
||||
|
||||
+14
-13
@@ -1,5 +1,5 @@
|
||||
/* Internal header for parsing printf format strings.
|
||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of th GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@@ -106,8 +106,9 @@ find_spec (const char *format, mbstate_t *ps)
|
||||
}
|
||||
|
||||
|
||||
/* This is defined in reg-printf.c. */
|
||||
extern printf_arginfo_function **__printf_arginfo_table;
|
||||
/* These are defined in reg-printf.c. */
|
||||
extern printf_arginfo_function *__printf_arginfo_table[];
|
||||
extern printf_function **__printf_function_table;
|
||||
|
||||
|
||||
/* FORMAT must point to a '%' at the beginning of a spec. Fills in *SPEC
|
||||
@@ -299,8 +300,9 @@ parse_one_spec (const UCHAR_T *format, size_t posn, struct printf_spec *spec,
|
||||
|
||||
/* Get the format specification. */
|
||||
spec->info.spec = (wchar_t) *format++;
|
||||
if (__printf_arginfo_table != NULL &&
|
||||
__printf_arginfo_table[spec->info.spec] != NULL)
|
||||
if (__printf_function_table != NULL
|
||||
&& spec->info.spec <= UCHAR_MAX
|
||||
&& __printf_arginfo_table[spec->info.spec] != NULL)
|
||||
/* We don't try to get the types for all arguments if the format
|
||||
uses more than one. The normal case is covered though. */
|
||||
spec->ndata_args = (*__printf_arginfo_table[spec->info.spec])
|
||||
@@ -362,15 +364,14 @@ parse_one_spec (const UCHAR_T *format, size_t posn, struct printf_spec *spec,
|
||||
spec->ndata_args = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (spec->data_arg == -1 && spec->ndata_args > 0)
|
||||
{
|
||||
/* There are args consumed, but no positional spec.
|
||||
Use the next sequential arg position. */
|
||||
spec->data_arg = posn;
|
||||
posn += spec->ndata_args;
|
||||
nargs += spec->ndata_args;
|
||||
}
|
||||
if (spec->data_arg == -1 && spec->ndata_args > 0)
|
||||
{
|
||||
/* There are args consumed, but no positional spec. Use the
|
||||
next sequential arg position. */
|
||||
spec->data_arg = posn;
|
||||
nargs += spec->ndata_args;
|
||||
}
|
||||
|
||||
if (spec->info.spec == L'\0')
|
||||
|
||||
+16
-1
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 92, 93, 95, 96 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 92, 93, 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
|
||||
@@ -122,6 +122,21 @@ enum
|
||||
#define PA_FLAG_PTR (1 << 11)
|
||||
|
||||
|
||||
|
||||
/* Function which can be registered as `printf'-handlers. */
|
||||
|
||||
/* Print floating point value using using abbreviations for the orders
|
||||
of magnitude used for numbers ('k' for kilo, 'm' for mega etc). If
|
||||
the format specifier is a uppercase character powers of 1000 are
|
||||
used. Otherwise powers of 1024. */
|
||||
extern int printf_size __P ((FILE *__fp, __const struct printf_info *__info,
|
||||
__const void *__const *args));
|
||||
|
||||
/* This is the appropriate argument information function for `printf_size'. */
|
||||
extern int printf_size_info __P ((__const struct printf_info *__info,
|
||||
size_t __n, int *__argtypes));
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* printf.h */
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
/* Print size value using units for orders of magnitude.
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
||||
Based on a proposal by Larry McVoy <lm@sgi.com>.
|
||||
|
||||
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 <ieee754.h>
|
||||
#include <math.h>
|
||||
#include <printf.h>
|
||||
#ifdef USE_IN_LIBIO
|
||||
# include <libioP.h>
|
||||
#else
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* This defines make it possible to use the same code for GNU C library and
|
||||
the GNU I/O library. */
|
||||
#ifdef USE_IN_LIBIO
|
||||
# define PUT(f, s, n) _IO_sputn (f, s, n)
|
||||
# define PAD(f, c, n) _IO_padn (f, c, n)
|
||||
/* We use this file GNU C library and GNU I/O library. So make
|
||||
names equal. */
|
||||
# undef putc
|
||||
# define putc(c, f) _IO_putc_unlocked (c, f)
|
||||
# define size_t _IO_size_t
|
||||
# define FILE _IO_FILE
|
||||
#else /* ! USE_IN_LIBIO */
|
||||
# define PUT(f, s, n) fwrite (s, 1, n, f)
|
||||
# define PAD(f, c, n) __printf_pad (f, c, n)
|
||||
ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */
|
||||
#endif /* USE_IN_LIBIO */
|
||||
|
||||
/* Macros for doing the actual output. */
|
||||
|
||||
#define outchar(ch) \
|
||||
do \
|
||||
{ \
|
||||
register const int outc = (ch); \
|
||||
if (putc (outc, fp) == EOF) \
|
||||
return -1; \
|
||||
++done; \
|
||||
} while (0)
|
||||
|
||||
#define PRINT(ptr, len) \
|
||||
do \
|
||||
{ \
|
||||
register size_t outlen = (len); \
|
||||
if (len > 20) \
|
||||
{ \
|
||||
if (PUT (fp, ptr, outlen) != outlen) \
|
||||
return -1; \
|
||||
ptr += outlen; \
|
||||
done += outlen; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
while (outlen-- > 0) \
|
||||
outchar (*ptr++); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PADN(ch, len) \
|
||||
do \
|
||||
{ \
|
||||
if (PAD (fp, ch, len) != len) \
|
||||
return -1; \
|
||||
done += len; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* Prototype for helper functions. */
|
||||
extern int __printf_fp (FILE *fp, const struct printf_info *info,
|
||||
const void *const *args);
|
||||
|
||||
|
||||
int
|
||||
printf_size (FILE *fp, const struct printf_info *info, const void *const *args)
|
||||
{
|
||||
/* Units for the both formats. */
|
||||
static const char units[2][8] =
|
||||
{
|
||||
" kmgtps", /* For binary format. */
|
||||
" KMGTPS" /* For decimal format. */
|
||||
};
|
||||
const char *tag = units[isupper (info->spec) != 0];
|
||||
int divisor = isupper (info->spec) ? 1000 : 1024;
|
||||
|
||||
/* The floating-point value to output. */
|
||||
union
|
||||
{
|
||||
union ieee754_double dbl;
|
||||
union ieee854_long_double ldbl;
|
||||
}
|
||||
fpnum;
|
||||
const void *ptr = &fpnum;
|
||||
|
||||
int negative = 0;
|
||||
|
||||
/* "NaN" or "Inf" for the special cases. */
|
||||
const char *special = NULL;
|
||||
|
||||
struct printf_info fp_info;
|
||||
int done = 0;
|
||||
|
||||
|
||||
/* Fetch the argument value. */
|
||||
if (info->is_long_double && sizeof (long double) > sizeof (double))
|
||||
{
|
||||
fpnum.ldbl.d = *(const long double *) args[0];
|
||||
|
||||
/* Check for special values: not a number or infinity. */
|
||||
if (__isnanl (fpnum.ldbl.d))
|
||||
{
|
||||
special = "nan";
|
||||
negative = 0;
|
||||
}
|
||||
else if (__isinfl (fpnum.ldbl.d))
|
||||
{
|
||||
special = "inf";
|
||||
|
||||
negative = fpnum.ldbl.d < 0;
|
||||
}
|
||||
else
|
||||
while (fpnum.ldbl.d >= divisor && tag[1] != '\0')
|
||||
{
|
||||
fpnum.ldbl.d /= divisor;
|
||||
++tag;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fpnum.dbl.d = *(const double *) args[0];
|
||||
|
||||
/* Check for special values: not a number or infinity. */
|
||||
if (__isnan (fpnum.dbl.d))
|
||||
{
|
||||
special = "nan";
|
||||
negative = 0;
|
||||
}
|
||||
else if (__isinf (fpnum.dbl.d))
|
||||
{
|
||||
special = "inf";
|
||||
|
||||
negative = fpnum.dbl.d < 0;
|
||||
}
|
||||
else
|
||||
while (fpnum.dbl.d >= divisor && tag[1] != '\0')
|
||||
{
|
||||
fpnum.dbl.d /= divisor;
|
||||
++tag;
|
||||
}
|
||||
}
|
||||
|
||||
if (special)
|
||||
{
|
||||
int width = info->prec > info->width ? info->prec : info->width;
|
||||
|
||||
if (negative || info->showsign || info->space)
|
||||
--width;
|
||||
width -= 3;
|
||||
|
||||
if (!info->left && width > 0)
|
||||
PADN (' ', width);
|
||||
|
||||
if (negative)
|
||||
outchar ('-');
|
||||
else if (info->showsign)
|
||||
outchar ('+');
|
||||
else if (info->space)
|
||||
outchar (' ');
|
||||
|
||||
PRINT (special, 3);
|
||||
|
||||
if (info->left && width > 0)
|
||||
PADN (' ', width);
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
/* Prepare to print the number. We want to use `__printf_fp' so we
|
||||
have to prepare a `printf_info' structure. */
|
||||
fp_info.spec = 'f';
|
||||
fp_info.prec = info->prec < 0 ? 3 : info->prec;
|
||||
fp_info.is_long_double = info->is_long_double;
|
||||
fp_info.is_short = info->is_short;
|
||||
fp_info.is_long = info->is_long;
|
||||
fp_info.alt = info->alt;
|
||||
fp_info.space = info->space;
|
||||
fp_info.left = info->left;
|
||||
fp_info.showsign = info->showsign;
|
||||
fp_info.group = info->group;
|
||||
fp_info.extra = info->extra;
|
||||
fp_info.pad = info->pad;
|
||||
|
||||
if (fp_info.left && fp_info.pad == L' ')
|
||||
{
|
||||
/* We must do the padding ourself since the unit character must
|
||||
be placed before the padding spaces. */
|
||||
fp_info.width = 0;
|
||||
|
||||
done = __printf_fp (fp, &fp_info, &ptr);
|
||||
if (done > 0)
|
||||
{
|
||||
outchar (*tag);
|
||||
if (info->width > done)
|
||||
PADN (' ', info->width - done);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We can let __printf_fp do all the printing and just add our
|
||||
unit character afterwards. */
|
||||
fp_info.width = info->width - 1;
|
||||
|
||||
done = __printf_fp (fp, &fp_info, &ptr);
|
||||
if (done > 0)
|
||||
outchar (*tag);
|
||||
}
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
/* This is the function used by `vfprintf' to determine number and
|
||||
type of the arguments. */
|
||||
int
|
||||
printf_size_info (const struct printf_info *info, size_t n, int *argtypes)
|
||||
{
|
||||
/* We need only one double or long double argument. */
|
||||
if (n >= 1)
|
||||
argtypes[0] = PA_DOUBLE | (info->is_long_double ? PA_FLAG_LONG_DOUBLE : 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1117,7 +1117,6 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
is_long = sizeof (size_t) > sizeof (unsigned int);
|
||||
JUMP (*++f, step4_jumps);
|
||||
|
||||
|
||||
/* Process current format. */
|
||||
while (1)
|
||||
{
|
||||
@@ -1136,6 +1135,9 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
|
||||
goto do_positional;
|
||||
}
|
||||
|
||||
/* The format is correctly handled. */
|
||||
++nspecs_done;
|
||||
|
||||
/* Look for next format specifier. */
|
||||
f = find_spec ((end_of_spec = ++f), &mbstate);
|
||||
|
||||
|
||||
+11
-14
@@ -383,15 +383,13 @@ INTERNAL (STRTOF) (nptr, endptr, group)
|
||||
typedef unsigned int wint_t;
|
||||
#endif
|
||||
/* The radix character of the current locale. */
|
||||
wint_t decimal;
|
||||
wchar_t decimal;
|
||||
/* The thousands character of the current locale. */
|
||||
wint_t thousands;
|
||||
wchar_t thousands;
|
||||
/* The numeric grouping specification of the current locale,
|
||||
in the format described in <locale.h>. */
|
||||
const char *grouping;
|
||||
|
||||
assert (sizeof (wchar_t) == sizeof (wint_t));
|
||||
|
||||
if (group)
|
||||
{
|
||||
grouping = _NL_CURRENT (LC_NUMERIC, GROUPING);
|
||||
@@ -400,10 +398,9 @@ INTERNAL (STRTOF) (nptr, endptr, group)
|
||||
else
|
||||
{
|
||||
/* Figure out the thousands separator character. */
|
||||
if (mbtowc ((wchar_t *) &thousands,
|
||||
_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP),
|
||||
if (mbtowc (&thousands, _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP),
|
||||
strlen (_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP))) <= 0)
|
||||
thousands = (wint_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP);
|
||||
thousands = (wchar_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP);
|
||||
if (thousands == L'\0')
|
||||
grouping = NULL;
|
||||
}
|
||||
@@ -417,7 +414,7 @@ INTERNAL (STRTOF) (nptr, endptr, group)
|
||||
/* Find the locale's decimal point character. */
|
||||
if (mbtowc ((wchar_t *) &decimal, _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT),
|
||||
strlen (_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT))) <= 0)
|
||||
decimal = (wint_t) *_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
|
||||
decimal = (wchar_t) *_NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
|
||||
assert (decimal != L'\0');
|
||||
|
||||
/* Prepare number representation. */
|
||||
@@ -445,7 +442,7 @@ INTERNAL (STRTOF) (nptr, endptr, group)
|
||||
/* Return 0.0 if no legal string is found.
|
||||
No character is used even if a sign was found. */
|
||||
if ((c < L_('0') || c > L_('9'))
|
||||
&& ((wint_t) c != decimal || cp[1] < L_('0') || cp[1] > L_('9')))
|
||||
&& ((wchar_t) c != decimal || cp[1] < L_('0') || cp[1] > L_('9')))
|
||||
{
|
||||
int matched = 0;
|
||||
/* Check for `INF' or `INFINITY'. */
|
||||
@@ -511,14 +508,14 @@ INTERNAL (STRTOF) (nptr, endptr, group)
|
||||
start_of_digits = startp = cp;
|
||||
|
||||
/* Ignore leading zeroes. This helps us to avoid useless computations. */
|
||||
while (c == L_('0') || (thousands != L'\0' && (wint_t) c == thousands))
|
||||
while (c == L_('0') || (thousands != L'\0' && (wchar_t) c == thousands))
|
||||
c = *++cp;
|
||||
|
||||
/* If no other digit but a '0' is found the result is 0.0.
|
||||
Return current read pointer. */
|
||||
if ((c < L_('0') || c > L_('9')) &&
|
||||
(base == 16 && (c < TOLOWER (L_('a')) || c > TOLOWER (L_('f')))) &&
|
||||
(wint_t) c != decimal &&
|
||||
(wchar_t) c != decimal &&
|
||||
(base == 16 && (cp == start_of_digits || TOLOWER (c) != L_('p'))) &&
|
||||
(base != 16 && TOLOWER (c) != L_('e')))
|
||||
{
|
||||
@@ -540,7 +537,7 @@ INTERNAL (STRTOF) (nptr, endptr, group)
|
||||
if ((c >= L_('0') && c <= L_('9'))
|
||||
|| (base == 16 && TOLOWER (c) >= L_('a') && TOLOWER (c) <= L_('f')))
|
||||
++dig_no;
|
||||
else if (thousands == L'\0' || (wint_t) c != thousands)
|
||||
else if (thousands == L'\0' || (wchar_t) c != thousands)
|
||||
/* Not a digit or separator: end of the integer part. */
|
||||
break;
|
||||
c = *++cp;
|
||||
@@ -590,7 +587,7 @@ INTERNAL (STRTOF) (nptr, endptr, group)
|
||||
|
||||
/* Read the fractional digits. A special case are the 'american style'
|
||||
numbers like `16.' i.e. with decimal but without trailing digits. */
|
||||
if ((wint_t) c == decimal)
|
||||
if ((wchar_t) c == decimal)
|
||||
{
|
||||
c = *++cp;
|
||||
while (c >= L_('0') && c <= L_('9') ||
|
||||
@@ -693,7 +690,7 @@ INTERNAL (STRTOF) (nptr, endptr, group)
|
||||
if (lead_zero)
|
||||
{
|
||||
/* Find the decimal point */
|
||||
while ((wint_t) *startp != decimal)
|
||||
while ((wchar_t) *startp != decimal)
|
||||
++startp;
|
||||
startp += lead_zero + 1;
|
||||
exponent -= base == 16 ? 4 * lead_zero : lead_zero;
|
||||
|
||||
+10
-2
@@ -22,11 +22,19 @@
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int err = 0;
|
||||
int i, j;
|
||||
while (scanf ("%d %d\n", &i, &j) == 2)
|
||||
{
|
||||
div_t d = div (i, j);
|
||||
printf ("%d / %d = %d + %d/%d\n", i, j, d.quot, d.rem, j);
|
||||
printf ("%d / %d = %d + %d/%d", i, j, d.quot, d.rem, j);
|
||||
if (i == d.quot * j + d.rem)
|
||||
fputs (" OK\n", stdout);
|
||||
else
|
||||
{
|
||||
fputs (" FAILED\n", stdout);
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
+18
-15
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 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
|
||||
@@ -49,6 +49,7 @@ main (int argc, char ** argv)
|
||||
register const struct ltest *lt;
|
||||
char *ep;
|
||||
int status = 0;
|
||||
int save_errno;
|
||||
|
||||
for (lt = tests; lt->str != NULL; ++lt)
|
||||
{
|
||||
@@ -56,30 +57,32 @@ main (int argc, char ** argv)
|
||||
|
||||
errno = 0;
|
||||
d = strtod(lt->str, &ep);
|
||||
printf("strtod(\"%s\") test %u",
|
||||
save_errno = errno;
|
||||
printf ("strtod (\"%s\") test %u",
|
||||
lt->str, (unsigned int) (lt - tests));
|
||||
if (d == lt->expect && *ep == lt->left && errno == lt->err)
|
||||
puts("\tOK");
|
||||
if (d == lt->expect && *ep == lt->left && save_errno == lt->err)
|
||||
puts ("\tOK");
|
||||
else
|
||||
{
|
||||
puts("\tBAD");
|
||||
puts ("\tBAD");
|
||||
if (d != lt->expect)
|
||||
printf(" returns %.60g, expected %.60g\n", d, lt->expect);
|
||||
printf (" returns %.60g, expected %.60g\n", d, lt->expect);
|
||||
if (lt->left != *ep)
|
||||
{
|
||||
char exp1[5], exp2[5];
|
||||
expand(exp1, *ep);
|
||||
expand(exp2, lt->left);
|
||||
printf(" leaves '%s', expected '%s'\n", exp1, exp2);
|
||||
expand (exp1, *ep);
|
||||
expand (exp2, lt->left);
|
||||
printf (" leaves '%s', expected '%s'\n", exp1, exp2);
|
||||
}
|
||||
if (errno != lt->err)
|
||||
printf(" errno %d (%s) instead of %d (%s)\n",
|
||||
errno, strerror(errno), lt->err, strerror(lt->err));
|
||||
if (save_errno != lt->err)
|
||||
printf (" errno %d (%s) instead of %d (%s)\n",
|
||||
save_errno, strerror (save_errno),
|
||||
lt->err, strerror (lt->err));
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
exit(status ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
exit (status ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -87,11 +90,11 @@ expand (dst, c)
|
||||
char *dst;
|
||||
register int c;
|
||||
{
|
||||
if (isprint(c))
|
||||
if (isprint (c))
|
||||
{
|
||||
dst[0] = c;
|
||||
dst[1] = '\0';
|
||||
}
|
||||
else
|
||||
(void) sprintf(dst, "%#.3o", (unsigned int) c);
|
||||
(void) sprintf (dst, "%#.3o", (unsigned int) c);
|
||||
}
|
||||
|
||||
+32
-26
@@ -79,16 +79,19 @@ main (int argc, char ** argv)
|
||||
register const struct ltest *lt;
|
||||
char *ep;
|
||||
int status = 0;
|
||||
int save_errno;
|
||||
|
||||
for (lt = tests; lt->str != NULL; ++lt)
|
||||
{
|
||||
register long int l;
|
||||
|
||||
errno = 0;
|
||||
l = strtol(lt->str, &ep, lt->base);
|
||||
printf("strtol(\"%s\", , %d) test %u",
|
||||
lt->str, lt->base, (unsigned int) (lt - tests));
|
||||
if (l == (long int) lt->expect && *ep == lt->left && errno == lt->err)
|
||||
l = strtol (lt->str, &ep, lt->base);
|
||||
save_errno = errno;
|
||||
printf ("strtol(\"%s\", , %d) test %u",
|
||||
lt->str, lt->base, (unsigned int) (lt - tests));
|
||||
if (l == (long int) lt->expect && *ep == lt->left
|
||||
&& save_errno == lt->err)
|
||||
puts("\tOK");
|
||||
else
|
||||
{
|
||||
@@ -99,13 +102,14 @@ main (int argc, char ** argv)
|
||||
if (lt->left != *ep)
|
||||
{
|
||||
char exp1[5], exp2[5];
|
||||
expand(exp1, *ep);
|
||||
expand(exp2, lt->left);
|
||||
printf(" leaves '%s', expected '%s'\n", exp1, exp2);
|
||||
expand (exp1, *ep);
|
||||
expand (exp2, lt->left);
|
||||
printf (" leaves '%s', expected '%s'\n", exp1, exp2);
|
||||
}
|
||||
if (errno != lt->err)
|
||||
printf(" errno %d (%s) instead of %d (%s)\n",
|
||||
errno, strerror(errno), lt->err, strerror(lt->err));
|
||||
if (save_errno != lt->err)
|
||||
printf (" errno %d (%s) instead of %d (%s)\n",
|
||||
save_errno, strerror (save_errno),
|
||||
lt->err, strerror (lt->err));
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
@@ -115,32 +119,34 @@ main (int argc, char ** argv)
|
||||
register unsigned long int ul;
|
||||
|
||||
errno = 0;
|
||||
ul = strtoul(lt->str, &ep, lt->base);
|
||||
printf("strtoul(\"%s\", , %d) test %u",
|
||||
lt->str, lt->base, (unsigned int) (lt - tests));
|
||||
if (ul == lt->expect && *ep == lt->left && errno == lt->err)
|
||||
ul = strtoul (lt->str, &ep, lt->base);
|
||||
save_errno = errno;
|
||||
printf ("strtoul(\"%s\", , %d) test %u",
|
||||
lt->str, lt->base, (unsigned int) (lt - tests));
|
||||
if (ul == lt->expect && *ep == lt->left && save_errno == lt->err)
|
||||
puts("\tOK");
|
||||
else
|
||||
{
|
||||
puts("\tBAD");
|
||||
puts ("\tBAD");
|
||||
if (ul != lt->expect)
|
||||
printf(" returns %lu, expected %lu\n",
|
||||
ul, lt->expect);
|
||||
printf (" returns %lu, expected %lu\n",
|
||||
ul, lt->expect);
|
||||
if (lt->left != *ep)
|
||||
{
|
||||
char exp1[5], exp2[5];
|
||||
expand(exp1, *ep);
|
||||
expand(exp2, lt->left);
|
||||
printf(" leaves '%s', expected '%s'\n", exp1, exp2);
|
||||
expand (exp1, *ep);
|
||||
expand (exp2, lt->left);
|
||||
printf (" leaves '%s', expected '%s'\n", exp1, exp2);
|
||||
}
|
||||
if (errno != lt->err)
|
||||
printf(" errno %d (%s) instead of %d (%s)\n",
|
||||
errno, strerror(errno), lt->err, strerror(lt->err));
|
||||
if (save_errno != lt->err)
|
||||
printf (" errno %d (%s) instead of %d (%s)\n",
|
||||
save_errno, strerror (save_errno),
|
||||
lt->err, strerror (lt->err));
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
exit(status ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
exit (status ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -148,11 +154,11 @@ expand (dst, c)
|
||||
char *dst;
|
||||
int c;
|
||||
{
|
||||
if (isprint(c))
|
||||
if (isprint (c))
|
||||
{
|
||||
dst[0] = c;
|
||||
dst[1] = '\0';
|
||||
}
|
||||
else
|
||||
(void) sprintf(dst, "%#.3o", (unsigned int) c);
|
||||
(void) sprintf (dst, "%#.3o", (unsigned int) c);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ struct rpcent
|
||||
int r_number; /* RPC program number. */
|
||||
};
|
||||
|
||||
extern void setrpcent __P ((int _stayopen));
|
||||
extern void endrpcent __P ((void));
|
||||
extern struct rpcent *getrpcbyname __P ((__const char *__name));
|
||||
extern struct rpcent *getrpcbynumber __P ((int __number));
|
||||
extern struct rpcent *getrpcent __P ((void));
|
||||
|
||||
+10
-11
@@ -1,7 +1,6 @@
|
||||
/* Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson (rth@tamu.edu)
|
||||
|
||||
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson <rth@tamu.edu>.
|
||||
|
||||
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
|
||||
@@ -14,10 +13,9 @@
|
||||
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. */
|
||||
|
||||
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 <sysdep.h>
|
||||
|
||||
@@ -44,7 +42,6 @@ div:
|
||||
.prologue 0
|
||||
#endif
|
||||
|
||||
#define dividend t0
|
||||
#define divisor t1
|
||||
#define mask t2
|
||||
#define quotient t3
|
||||
@@ -54,11 +51,13 @@ div:
|
||||
#define compare t7
|
||||
|
||||
/* find correct sign for input to unsigned divide loop. */
|
||||
negl a1, modulus # e0 :
|
||||
negl a2, divisor # .. e1 :
|
||||
sextl a1, a1 # e0 :
|
||||
sextl a2, a2 # .. e1 :
|
||||
negl a1, dividend # e0 :
|
||||
negl a2, divisor # .. e1 :
|
||||
cmovge a1, a1, dividend # e0 :
|
||||
mov zero, quotient # e0 :
|
||||
mov 1, mask # .. e1 :
|
||||
cmovge a1, a1, modulus # e0 :
|
||||
cmovge a2, a2, divisor # .. e1 :
|
||||
beq a2, $divbyzero # e1 :
|
||||
unop # :
|
||||
|
||||
+9
-10
@@ -1,7 +1,6 @@
|
||||
/* Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson (rth@tamu.edu)
|
||||
|
||||
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Richard Henderson <rth@tamu.edu>.
|
||||
|
||||
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
|
||||
@@ -14,10 +13,9 @@
|
||||
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. */
|
||||
|
||||
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 <sysdep.h>
|
||||
|
||||
@@ -44,7 +42,6 @@ ldiv:
|
||||
.prologue 0
|
||||
#endif
|
||||
|
||||
#define dividend t0
|
||||
#define divisor t1
|
||||
#define mask t2
|
||||
#define quotient t3
|
||||
@@ -54,11 +51,13 @@ ldiv:
|
||||
#define compare t7
|
||||
|
||||
/* find correct sign for input to unsigned divide loop. */
|
||||
mov a1, dividend # e0 :
|
||||
mov a1, modulus # e0 :
|
||||
mov a2, divisor # .. e1 :
|
||||
negq a1, tmp1 # e0 :
|
||||
negq a2, tmp2 # .. e1 :
|
||||
cmovlt a1, tmp1, dividend # e0 :
|
||||
mov zero, quotient # e0 :
|
||||
mov 1, mask # .. e1 :
|
||||
cmovlt a1, tmp1, modulus # e0 :
|
||||
cmovlt a2, tmp2, divisor # .. e1 :
|
||||
beq a2, $divbyzero # e1 :
|
||||
unop # :
|
||||
|
||||
@@ -154,7 +154,7 @@ _dl_sysdep_read_whole_file (const char *file, size_t *sizep, int prot)
|
||||
int fd = __open (file, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
if (__fstat (fd, &st) < 0)
|
||||
if (__fxstat (_STAT_VER, fd, &st) < 0)
|
||||
result = NULL;
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/* Machine-dependent definitions for profiling support. Generic GCC 2 version.
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Copyright (C) 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 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.
|
||||
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. */
|
||||
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. */
|
||||
|
||||
/* GCC version 2 gives us a perfect magical function to get
|
||||
just the information we need:
|
||||
|
||||
@@ -56,6 +56,12 @@ __libc_lock_define_initialized (static, envlock)
|
||||
# define UNLOCK
|
||||
#endif
|
||||
|
||||
/* In the GNU C library we must keep the namespace clean. */
|
||||
#ifdef _LIBC
|
||||
# define clearenv __clearenv
|
||||
#endif
|
||||
|
||||
|
||||
/* If this variable is not a null pointer we allocated the current
|
||||
environment. */
|
||||
static char **last_environ;
|
||||
@@ -132,9 +138,9 @@ setenv (name, value, replace)
|
||||
return -1;
|
||||
}
|
||||
*ep = new;
|
||||
memcpy (*ep, name, namelen);
|
||||
(*ep)[namelen] = '=';
|
||||
}
|
||||
memcpy (*ep, name, namelen);
|
||||
(*ep)[namelen] = '=';
|
||||
memcpy (&(*ep)[namelen + 1], value, vallen);
|
||||
}
|
||||
|
||||
@@ -188,3 +194,7 @@ clearenv ()
|
||||
|
||||
return 0;
|
||||
}
|
||||
#ifdef _LIBC
|
||||
# undef clearenv
|
||||
weak_alias (__clearenv, clearenv)
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
i386-mcount.S
|
||||
machine-gmon.h
|
||||
@@ -5,6 +5,10 @@ asm-CPPFLAGS := $(asm-CPPFLAGS) -DGAS_SYNTAX
|
||||
# The i386 `long double' is a distinct type we support.
|
||||
long-double-fcts = yes
|
||||
|
||||
ifeq ($(subdir),gmon)
|
||||
sysdep_routines += i386-mcount
|
||||
endif
|
||||
|
||||
ifeq ($(subdir),elf)
|
||||
CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused
|
||||
CFLAGS-dl-load.c += -Wno-unused
|
||||
|
||||
+14
-14
@@ -1,21 +1,21 @@
|
||||
/* longjmp for i386.
|
||||
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
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 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.
|
||||
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. */
|
||||
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 <sysdep.h>
|
||||
#define _ASM
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user