dfd2257ad9
1997-10-12 05:09 Ulrich Drepper <drepper@cygnus.com> * libio/Makefile (routines): Remove iofprintf. * stdio-common/fprintf.c [USE_IN_LIBIO]: Define _IO_fprintf. * libio/filedoalloc.c: Use _G_stat64 instead of stat. * libio/fileops.c (_IO_file_open): Change to take extra argument indicating whether 32 or 64 bit mode is wanted. * libio/iofopen.c: Call _IO_file_open with extra argument set to 0. * libio/iofopen64.c: Call _IO_file_open with extra argument set to 0. * libio/iolibio.h (_IO_freopen, _IO_freopen64): Likewise. * libio/iofgetpos.c: Pretty print. * libio/iofgetpos64.c: Use _IO_fpos64_t for local variable `pos'. * manual/conf.texi: Document all the _SC_ and _CS_ constants. * manual/creature.texi: Document _LARGEFILE_SOURCE, _LARGEFILE64_SOURCE and _FILE_OFFSET_BITS. * manual/llio.texi: Document truncate and ftruncate. * manual/stdio.texi: Document positional parameters for printf. * math/Makefile (headers): Add tgmath.h. (libm-support): Remove s_lrint, s_llrint, s_lround, and s_llround and move to ... (libm-calls): ... here. Add scalbln, s_nextafterx and s_fma. * math/libm-test.c (lround_test, llround_test): Test for all FP formats by using FUNC(). * math/libm.map: Add fma, fmaf, fmal, nextafterx, nextafterxf, nextafterxl, scalbln, scalblnf, scalblnl, lrintf, lrintl, llrintf, llrintl, lroundf, lroundl, llroundf, and llroundl. * math/math.h: Document new platform specific macros from mathdef.h. Remove declaration of lrint, llrint, lround, and llround. * math/test-double.c: Define TEST_DOUBLE. * math/test-idouble.c: Likewise. * math/test-float.c: Define TEST_FLOAT. * math/test-ifloat.c: Likewise. * math/tgmath.h: New file. * math/bits/mathcalls.h: Add nextafterx, scalbln, fma, lrint, llrint, lround, and llround. Change second argument of scalbn to `int'. * sysdeps/libm-ieee754/s_fma.S: New file. * sysdeps/libm-ieee754/s_fmaf.S: New file. * sysdeps/libm-ieee754/s_fmal.S: New file. * sysdeps/libm-i387/s_fma.S: New file. * sysdeps/libm-i387/s_fmaf.S: New file. * sysdeps/libm-i387/s_fmal.S: New file. * sysdeps/libm-i387/s_llrint.S: Change to take double argument. * sysdeps/libm-i387/s_lrint.S: Likewise. * sysdeps/libm-i387/s_llrintf.S: New file. * sysdeps/libm-i387/s_llrintl.S: New file. * sysdeps/libm-i387/s_lrintf.S: New file. * sysdeps/libm-i387/s_lrintl.S: New file. * sysdeps/libm-ieee754/s_llrint.c: Remove version which works on 80bit double. * sysdeps/libm-ieee754/s_lrint.c: Likewise. * sysdeps/libm-ieee754/s_llrintf.S: New file. * sysdeps/libm-ieee754/s_llrintl.S: New file. * sysdeps/libm-ieee754/s_lrintf.S: New file. * sysdeps/libm-ieee754/s_lrintl.S: New file. * sysdeps/libm-i387/s_scalbln.c: New file. Empty file. * sysdeps/libm-i387/s_scalblnf.c: New file. Empty file. * sysdeps/libm-i387/s_scalblnl.c: New file. Empty file. * sysdeps/libm-i387/s_scalbn.c: Add scalbln as alias. * sysdeps/libm-i387/s_scalbnf.c: Add scalblnf as alias. * sysdeps/libm-i387/s_scalbnl.c: Add scalblnl as alias. * sysdeps/libm-ieee754/s_llround.c: Remove version which works on 80bit double. * sysdeps/libm-ieee754/s_lround.c: Likewise. * sysdeps/libm-ieee754/s_llroundf.c: Likewise. * sysdeps/libm-ieee754/s_llroundl.c: Likewise. * sysdeps/libm-ieee754/s_lroundf.c: Likewise. * sysdeps/libm-ieee754/s_lroundl.c: Likewise. * sysdeps/libm-ieee754/s_nextafterl.c: Add alias fo nextafterxl. * sysdeps/libm-ieee754/s_nextafterx.c: New file. * sysdeps/libm-ieee754/s_nextafterxf.c: New file. * sysdeps/libm-ieee754/s_nextafterxl.c: New file. * sysdeps/libm-ieee754/s_scalbln.c: New file. * sysdeps/libm-ieee754/s_scalblnf.c: New file. * sysdeps/libm-ieee754/s_scalblnl.c: New file. * sysdeps/libm-ieee754/s_scalbn.c: Change to take `int' as second arg. * sysdeps/libm-ieee754/s_scalbnf.c: Likewise. * sysdeps/libm-ieee754/s_scalbnl.c: Likewise. * stdlib/stdlib.h: Protect declarations of __strto*l_internal functions by #ifdefs since they are duplicated in inttypes.h. * sysdeps/wordsize-32/inttypes.h: Add definition of strtoimax and strtoumax plus needed declarations. * sysdeps/generic/confname.h (_SC_AIO_LISTIO_MAX): Fix typo. 1997-10-09 Andreas Jaeger <aj@arthur.rhein-neckar.de> * locale/programs/locfile.c (locfile_read): Correct while loop. * db2/makedb.c (main): Add missing parameter for error output. (process_input): Likewise. * resolv/gethnamaddr.c (getanswer): Rewrite a bit to avoid warning. 1997-10-12 05:05 Ulrich Drepper <drepper@cygnus.com> * libc-map: Add __bzero, __mempcpy. 1997-10-10 18:51 David S. Miller <davem@tanya.rutgers.edu> * sysdeps/unix/sysv/linux/sparc/bits/ioctls.h: Remove dependencies on kernel_termios.h 1997-10-09 10:24 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> Add the changes from the Solaris 2.6 header files, use the new public defines/functions. * nis/nis_addmember.c: Updated. * nis/nis_checkpoint.c: Updated. * nis/nis_creategroup.c: updated. * nis/nis_destroygroup.c: Updated. * nis/nis_getservlist.c: Updated. * nis/nis_ismember.c: Updated. * nis/nis_lookup.c: Updated. * nis/nis_modify.c: Updated. * nis/nis_ping.c: Updated. * nis/nis_print.c: Updated. * nis/nis_print_group_entry.c: Updated. * nis/nis_remove.c: Updated. * nis/nis_removemember.c: Updated. * nis/nis_xdr.c: Updated. * nis/nss_nisplus/nisplus-alias.c: Updated. * nis/nss_nisplus/nisplus-ethers.c: Updated. * nis/nss_nisplus/nisplus-hosts.c: Updated. * nis/nss_nisplus/nisplus-network.c: Updated. * nis/nss_nisplus/nisplus-parser.c: Updated. * nis/nss_nisplus/nisplus-proto.c: Updated. * nis/nss_nisplus/nisplus-rpc.c: Updated. * nis/nss_nisplus/nisplus-service.c: Updated. * nis/rpcsvc/nis.h: Updated. * nis/rpcsvc/nis.x: Updated. * nis/rpcsvc/nis_object.x: Updated. * nis/rpcsvc/nis_tags.h: Updated. * nis/rpcsvc/nislib.h: Updated. * nis/lckcache.c: Removed, since Sun has dropped the directory signatures. The old cache version is now a security risk and not longer supported by Sun. * nis/nis_cache.c: Likewise. * nis/rpcsvc/nis_cache.h: Likewise. * nis/rpcsvc/nis_cache.x: Likewise. * nis/nis_call.c: Remove calls to the cache functions. * nis/libnsl.map: Remove cache and depending functions. * nis/nis_intern.h: Likewise. * nis/nis_add.c: Remove #include <rpcsvc/nislib.h>. * nis/nis_domain_of.c: Likewise. * nis/nis_domain_of_r.c: Likewise. * nis/nis_error.c: Likewise. * nis/nis_file.c: Likewise. * nis/nis_local_names.c: Likewise. * nis/nis_mkdir.c: Likewise. * nis/nis_rmdir.c: Likewise. * nis/nis_subr.c: Likewise. * nis/nis_verifygroup.c: Likewise. * nis/nis_clone.c: Removed, replaced by ... * nis/nis_clone_dir.c: New. * nis/nis_clone_obj.c: New. * nis/nis_clone_res.c: New. * nis/nis_table.c: Fixed bugs shown through the new clone functions. * nis/nis_defaults.c: Fixed a lot of race conditions. * nis/nis_free.c: Rewritten. * sunrpc/auth_des.c: Fix use of free'ed pointer. * nis/Makefile (libnsl-routines): Remove nis_clone, nis_cache and lckcache. Add nis_clone_dir, nis_clone_obj, and nis_clone_res. 1997-10-09 Andreas Jaeger <aj@arthur.rhein-neckar.de> * wctype/test_wctype.c (TEST): Add parens to avoid ambiguity. 1997-10-08 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * include/features.h: Don't crash if _XOPEN_SOURCE is defined to be empty. 1997-10-09 05:54 Ulrich Drepper <drepper@cygnus.com> * nss/digits_dots.c: Place `result' in resbuf and not in `buffer'. * nss/getXXbyYY_r.c: Make sure digits_dots.c sees `resbuf' as struct and not a pointer. Little optimizations. 1997-10-09 05:00 Ulrich Drepper <drepper@cygnus.com> * sysdeps/stub/getenv.c: Remove unused file. * sysdeps/stub/lxstat.c: Likewise. * sysdeps/stub/morecore.c: Likewise. * sysdeps/stub/putenv.c: Likewise. * sysdeps/stub/sbrk.c: Likewise. * sysdeps/stub/setenv.c: Likewise. * sysdeps/stub/sysd-stdio.c: Likewise. * sysdeps/stub/sysdep.h: Likewise. Reported by Zack Weinberg <zack@rabi.phys.columbia.edu>. 1997-10-09 04:58 Ulrich Drepper <drepper@cygnus.com> * configure.in: Add __bzero definition to DWARF2 unwind test. Reported by David S. Miller <davem@caip.rutgers.edu>. 1997-10-07 Paul Eggert <eggert@twinsun.com> * intl/loadmsgcat.c (_nl_load_domain): Fix &&/|| typo when checking file size. Check for overflow when stuffing off_t into size_t. 1997-10-07 18:11 Ulrich Drepper <drepper@cygnus.com> * time/africa: Update from tzdata1997i. 1997-10-07 Andreas Jaeger <aj@arthur.rhein-neckar.de> * posix/globtest.sh: Add arguments for name of dynamic linker and call dynamic linker to execute globtest. * posix/Makefile (tests): Supply arguments to globtest.sh. 1997-10-07 Andreas Jaeger <aj@arthur.rhein-neckar.de> * nis/rpcsvc/ypupd.h: Add missing __END_DECLS. 1997-10-03 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * libc.map: Add mempcpy, prctl. 1997-09-30 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/generic/memcmp.c: Avoid warnings. * sysdeps/generic/memset.c: Likewise. * sysdeps/generic/strchr.c: Likewise. * sysdeps/generic/strlen.c: Likewise. 1997-09-29 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * malloc/Makefile ($(objpfx)mtrace): Fix typo. 1997-09-29 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/m68k/dl-machine.h (elf_machine_rela): Fix last change. The R_68K_GLOB_DAT and R_68K_JMP_SLOT relocations really ignore the addend, Richard. (elf_machine_fixup_plt): Don't add the addend. (elf_machine_plt_value): New function. * sysdeps/alpha/dl-machine.h (elf_machine_plt_value): New function. * sysdeps/sparc/sparc32/dl-machine.h (elf_machine_plt_value): New function. * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_plt_value): New function. * sysdeps/powerpc/dl-machine.h (elf_machine_plt_value): New function. * sysdeps/i386/dl-machine.h (elf_machine_plt_value): New function. * elf/dl-runtime.c (fixup, profile_fixup): Don't add in the addend, instead let the machine dependent setup decide. 1997-09-20 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/m68k/m68020/bits/string.h: New file. 1997-10-07 04:27 Richard Henderson <rth@cygnus.com> * Makeconfig (+includes): Add -I$(objpfx). * stdlib/longlong.h [__sparc__]: Prototype __udiv_qrnnd. * sysdeps/alpha/setjmp.S: __setjmp is the same as _setjmp. Make the former a strong symbol and the later a weak alias. * sysdeps/sparc/sparc32/setjmp.S: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/setjmp.S: Likewise. 1997-10-06 21:01 David S. Miller <davem@tanya.rutgers.edu> * sysdeps/unix/sysv/linux/sparc/sparc64/bits/types.h: Make ino_t 64-bits. * sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h: Make st_ino member 64-bits as well, to match the kernel. 1997-10-06 19:35 Ulrich Drepper <drepper@cygnus.com> * sysdeps/sparc/sparc64/sub_n.S: Fix typo. Patch by Jakub Jelinek <jj@sunsite.ms.mff.cuni.cz>. 1997-10-06 01:09 Zack Weinberg <zack@rabi.phys.columbia.edu> * time/README: Correct list of files from tzcode package. Add contact information for tzcode/tzdata maintainers. Correct spelling of author's name. Compact lists. 1997-10-06 01:48 Ulrich Drepper <drepper@cygnus.com> * malloc/malloc.h: Remove hook definition without caller argument. * malloc/malloc.c: Likewise. * string/tester.c: Correct strsep test. * string/bits/string2.h: Define __string2_1bptr_p and use it. Patch by David S. Miller <davem@tanya.rutgers.edu>. * math/Makefile (routines): Add s_clog10. * math/libm-test.c: Add test for clog10. * math/libm.map: Add clog10{,f,l}. * math/bits/cmathcalls.h [__USE_GNU]: Add clog10. * sysdeps/libm-ieee754/s_clog10.c: New file. * sysdeps/libm-ieee754/s_clog10f.c: New file. * sysdeps/libm-ieee754/s_clog10l.c: New file. * manual/math.texi: Describe clog10. * config.h.in: Add USE_REGPARMS and define internal_function based on this. * configure.in: Define USE_REGPARMS for ix86 machines. * gmon/gmon.c: Mark write_hist, write_call_graph and write_bb_counts as internal functions. * inet/getnameinfo.c: Likewise for nrl_domainname. * inet/getnetgrent_r.c: Likewise for __internal_setnetgrent_reuse. * inet/rcmd.c: Likewise for __icheckhost. * intl/dcgettext.c: Likewise for category_to_name and guess_category_value. * intl/localealias.c: Likewise for read_alias_file. * io/fts.c: Likewise for fts_alloc, fts_build, fts_lfree, fts_maxarglen, fts_padjust, fts_palloc, fts_sort, and fts_stat. * libio/genops.c: Likewise for save_for_backup. * malloc/malloc.c (chunk_free, chunk_alloc, chunk_realloc, chunk_align, main_trim, heap_trim): Likewise. * malloc/mtrace.c (tr_where): Likewise. * misc/fstab.c (mnt2fs): Likewise. * misc/getttyent.c (skip, value): Likewise. * misc/syslog.c (openlog_internal): Likewise. * misc/tsearch.c (trecurse, tdestroy_internal): Likewise. * nss/nsswitch.c (nss_lookup_function, nss_parse_file, nss_getline, nss_parse_service_list, nss_new_service): Likewise. * posix/wordexp.c (parse_dollars, parse_backtick, eval_expr): Likewise. * resolv/inet_ntop.c (inet_ntop4, inet_ntop6): Likewise. * resolv/inet_pton.c (inet_pton4, inet_pton6): Likewise. * resolv/res_init.c (res_setoptions): Likewise. * stdio-common/printf_fp.c (group_number): Likewise. * stdio-common/vfprintf.c (buffered_vfprintf, group_number): Likewise. * stdlib/fmtmsg.c (internal_addseverity): Likewise. * sunrpc/auth_des.c (synchronize): Likewise. * sunrpc/auth_unix.c (marshal_new_auth): Likewise. * sunrpc/clnt_perr.c (auth_errmsg): Likewise. * sunrpc/key_call.c (key_call): Likewise. * sunprc/pmap_rmt.c (getbroadcastnets): Likewise. * sunrpc/svc_tcp.c (makefd_xprt): Likewise. * sunrpc/svcauth_des.c (cache_init, cache_spot, cache_ref, invalidate): Likewise. * sunrpc/xdr_rec.c (fix_buf_size, skip_input_bytes, flush_out, set_input_fragment, get_input_bytes): Likewise. * sysdeps/unix/sysv/linux/getsysstats.c (get_proc_path, phys_pages_info): Likewise. * sysdeps/unix/sysv/linux/if_index.c (opensock): Likewise. * sysdeps/unix/sysv/linux/poll.c (__emulate_poll): Likewise. * sysdeps/unix/sysv/linux/readv.c (__atomic_readv_replacement): Likewise. * sysdeps/unix/sysv/linux/readv.c (__atomic_writev_replacement): Likewise. * time/strptime.c (strptime_internal): Likewise. * time/tzfile.c (find_transition, compute_tzname_max): Likewise. * time/tzset.c (compute_change, tz_compute, tzset_internal): Likewise. * libc.map: Remove _libio_using_thunks, add _fp_hw and _dl_addr. * ctype/ctype.h: Pretty print. * grp/grp.h: Likewise. * include/libc-symbols.h: Likewise. * include/limits.h: Likewise. * include/values.h: Likewise. * io/fcntl.h: Likewise. * io/sys/stat.h: Likewise. * libio/stdio.h: Likewise. * malloc/malloc.h: Likewise. * misc/err.h: Likewise. * misc/regexp.h: Likewise. * misc/sys/cdefs.h: Likewise. * misc/sys/file.h: Likewise. * posix/sys/utsname.h: Likewise. * posix/sys/wait.h: Likewise. * pwd/pwd.h: Likewise. * resolv/netdb.h: Likewise. * signal/signal.h: Likewise. * stdlib/stdlib.h: Likewise. * string/endian.h: Likewise. * string/memory.h: Likewise. * sysdeps/mach/hurd/bits/fcntl.h: Likewise. * sysdeps/mach/hurd/sys/param.h: Likewise. * sysdeps/unix/sysv/linux/sys/param.h: Likewise. * termios/termios.h: Likewise. * wcsmbs/wchar.h: Likewise. * wctype/wctype.h: Likewise. * sysdeps/unix/bsd/bsd4.4/wait3.c: Use __WAIT_STATUS in definition. Implement Large File Support API. * include/features.h: Add suuport for _LARGEFILE_SOURCE, _LARGEFILE64_SOURCE, and _FILE_OFFSET_BITS. * libc.map: Add new functions for LFS. * dirent/Makefile (routines): Add readdir64 and readdir64_r. * dirent/dirent.h: Update readdir prototype for LFS and add new prototypes for above functions. * io/Makefile (routines): Add xstat64, fxstat64, lxstat64, statfs64, fstatfs64, lstat64, open64, lseek64, creat64, and ftw64. * io/creat64.c: New file. * io/fstat64.c: New file. * io/lstat64.c: New file. * io/stat64.c: New file. * io/ftw64.c: New file. * io/ftw.c: Rewrite to allow easy definition of ftw64. * io/ftw.h: Add LFS interface. * io/fcntl.h: Likewise. * io/sys/stat.h: Likewise. * io/sys/statfs.h: Likewise. * libio/Makefile (routines): Add iofgetpos64, iofopen64, iofsetpos64, freopen64, fseeko64, and ftello64. * libcio/fseeko64.c: New file. * libio/ftello64.c: New file. * libio/iofgetpos64.c: New file. * libio/iofopen64.c: New file. * libio/iofsetpos64.c: New file. * libio/fileops.c (_IO_file_fopen): Change to use _IO_off64_t. (_IO_file_attach): Likewise. (_IO_do_write): Likewise. (_IO_file_sync): Likewise. (_IO_file_seek): Likewise. (_IO_file_seekoff): Likewise. Use _G_stat64. (_IO_file_fopen64): New function. (_IO_file_jumps): Initialize showmanyc and imbue. * libio/genops.c (_IO_default_seekpos): Change to use _IO_fpos64_t. (_IO_default_seekoff): Likewise. (_IO_default_seek): Likewise. (_IO_default_showmanyc, _IO_default_imbue): New functions. * libio/iofopncook.c (_IO_cookie_seek): Change to use _IO_off64_t. * libio/iolibio.h: Add prototypes for LFS functions. * libio/ioseekoff.c: Change to use _IO_fpos64_t. * libio/ioseekpos.c: Likewise. * libio/libio.h: Define _IO_fpos64_t and _IO_off64_t. (_IO_FILE): Move _offset field to end and change type to _IO_off64_t. (_IO_seekoff, _IO_seekpos): Change prototype. * libio/libioP.h (_IO_seekoff_t, _IO_seekpos_t, _IO_seek_t): Change to use _IO_off64_t. Change prototypes for function from the *ops.c files. * libio/stdio.h: Add LFS interface definition. * libio/strops.c (_IO_str_seekoff): Change to use _IO_fpos64_t. * posix/Makefile (routines): Add pread64 and pwrite64. * posix/confstr.c: Handle _CS_LFS* requests. * posix/getconf.c: Handle LFS* requests. * sysdeps/generic/confname.h: Add _CS_LFS* constants. * posix/unistd.h: Document _LFS64_LARGEFILE and _LFS64_STDIO. Define off_t and off64_t appropriately. Change prototypes of LFS functions. * posix/sys/types.h: Add LFS types. * resources/Makefile (routines): Add getrlimit64 and setlimit64. * resource/sys/resource.h: Change prototypes of LFS functions. * stdio-common/Makefile (routines): Add tmpfile64. * stdio-common/tmpfile64.c: New file. * sysdeps/generic/_G_config.h: Define _G_fpos64_t and _G_off64_t. Define _G_OPEN64, _G_LSEEK64, _G_FSTAT64. * sysdeps/unix/sysv/linux/_G_config.h: Likewise. * sysdeps/generic/bits/resource.h: Add LFS definitions. * sysdeps/unix/bsd/sun/sunos4/bits/resource.h: Likewise. * sysdeps/unix/sysv/linux/bits/resource.h: Likewise. * sysdeps/generic/statfs.h: Use __fsblkcnt_t for some of the fields. * sysdeps/unix/sysv/linux/bits/statfs.h: Likewise. * sysdeps/unix/sysv/linux/mips/bits/statfs.h: Likewise. * sysdeps/generic/types.h: Define LFS types. * sysdeps/unix/sysv/linux/alpha/bits/types.h: Likewise. * sysdeps/unix/sysv/linux/bits/types.h: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/bits/types.h: Likewise. * sysdeps/generic/sys/mman.h: Add LFS definitions. * sysdeps/unix/sysv/linux/sys/mman.h: Likewise. * sysdeps/generic/mach/hurd/bits/fcntl.h: Add flock LFS extensions. * sysdeps/unix/bsd/bits/fcntl.h: Likewise. * sysdeps/unix/sysv/linux/alpha/bits/fcntl.h: Likewise. * sysdeps/unix/sysv/linux/bits/fcntl.h: Likewise. * sysdeps/unix/sysv/linux/mips/bits/fcntl.h: Likewise. * sysdeps/generic/mach/hurd/bits/stat.h: Add stat LFS extensions. * sysdeps/unix/bsd/bits/stat.h: Likewise. * sysdeps/unix/bsd/osf/alpha/bits/stat.h: Likewise. * sysdeps/unix/sysv/linux/alpha/bits/stat.h: Likewise. * sysdeps/unix/sysv/linux/bits/stat.h: Likewise. * sysdeps/unix/sysv/linux/mips/bits/stat.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/stat.h: Likewise. * sysdeps/unix/sysv/sysv4/i386/bits/stat.h: Likewise. * sysdeps/unix/sysv/sysv4/solaris2/bits/stat.h: Likewise. * sysdeps/posix/open64.c: New file. * sysdeps/stub/fstatfs64.c: New file. * sysdeps/stub/fxstat64.c: New file. * sysdeps/stub/getrlimit64.c: New file. * sysdeps/stub/lseek64.c: New file. * sysdeps/stub/lxstat64.c: New file. * sysdeps/stub/open64.c: New file. * sysdeps/stub/pread64.c: New file. * sysdeps/stub/pwrite64.c: New file. * sysdeps/stub/readdir64.c: New file. * sysdeps/stub/readdir64_r.c: New file. * sysdeps/stub/setrlimit64.c: New file. * sysdeps/stub/statfs64.c: New file. * sysdeps/stub/xstat64.c: New file. * sysdeps/unix/sysv/linux/llseek.c: Define as __llseek and make llseek and lseek64 weak aliases. * sysdeps/unix/sysv/linux/lseek64.c: New file. Empty. * sysdeps/unix/sysv/linux/alpha/bits/dirent.h: New file. * sysdeps/unix/sysv/linux/bits/dirent.h: Add LFS definitions. * sysdeps/posix/tempname.c: Add extra argument to trigger use of open64. * sysdeps/stub/tempname.c: Likewise. * stdio-common/tempnam.c: Call __stdio_gen_tempname with extra argument. * stdio-common/tmpfile.c: Likewise. * stdio-common/tmpnam.c: Likewise. * stdio-common/tmpnam_r.c: Likewise. * libio/libioP.h: Add definition ofr showmanyc and imbue callbacks. * libio/fileops.c (_IO_file_jumps): Initialize showmanyc and imbue. * libio/iofopncook.c (_IO_cookie_jumps): Likewise. * libio/iopopen.c (_IO_proc_jumps): Likewise. * libio/memstream.c (_IO_mem_jumps): Likewise. * libio/obprintf.c (_IO_obstack_jumps): Likewise. * libio/vsnprintf.c (_IO_strn_jumps): Likewise. * libio/strops.c (_IO_str_jumps): Likewise. * manual/arith.texi: Add a few words why cabs should be used. * manual/llio.texi: Describe sync, fsync, fdatasync. Tell about cleanup handlers & fcntl,lseek,write,read,close,open. * manual/process.texi: Tell about cleanup handlers & system,waitpid, wait. * manual/signal.texi: Likewise for pause. * manual/terminal.texi: Likewise for tcdrain. * manual/time.texi: Document nanosleep. * posix/exevp.c: Don't use nested function. * stdlib/ucontext.h: New file. * sysdeps/i386/sys/ucontext.h: New file. SysV/i386 API definitions. * sunrpc/xcrypt.c (hexval): Make a macro for efficiency. * sysdeps/i386/setjmp.h: Make `here` label local. * sysdeps/i386/elf/start.S: Define _fp_hw "variable". * sysdeps/stub/fstatfs.c: Correct warning. * sysdeps/stub/fxstat.c: Likewise. * sysdeps/stub/lxstat.c: Likewise. * sysdeps/unix/sysv/i386/i686/time.S: New file. 1997-10-03 20:56 Jason Merrill <jason@yorick.cygnus.com> * malloc/obstack.h (obstack_empty_p): New macro. 1997-10-04 17:41 Philip Blundell <Philip.Blundell@pobox.com> * inet/getnameinfo.c (getnameinfo): Remove spurious `#if INET6'. 1997-09-30 Zack Weinberg <zack@rabi.phys.columbia.edu> * maint.texi: Add copyright terms for libdb (Sleepycat, Harvard). Document new --with-binutils switch; delete reference to --with-gnu-as, --with-gnu-ld, --with-gnu-binutils. Add to description of --without-fp: a kernel FPU emulator is adequate (from FAQ) * INSTALL: Regenerated. 1997-09-30 17:29 Richard Henderson <rth@cygnus.com> * sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela): Move _dl_hwcap declaration to ... (elf_machine_fixup_plt): ... here.
775 lines
20 KiB
C
775 lines
20 KiB
C
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public License as
|
|
published by the Free Software Foundation; either version 2 of the
|
|
License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Library General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
#include <ctype.h>
|
|
#include <dlfcn.h>
|
|
#include <errno.h>
|
|
#include <netdb.h>
|
|
#include <bits/libc-lock.h>
|
|
#include <link.h> /* We need some help from ld.so. */
|
|
#include <search.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#if !defined DO_STATIC_NSS || defined PIC
|
|
# include <gnu/lib-names.h>
|
|
#endif
|
|
|
|
#include "nsswitch.h"
|
|
|
|
/* Prototypes for the local functions. */
|
|
static void *nss_lookup_function (service_user *ni, const char *fct_name)
|
|
internal_function;
|
|
static name_database *nss_parse_file (const char *fname) internal_function;
|
|
static name_database_entry *nss_getline (char *line) internal_function;
|
|
static service_user *nss_parse_service_list (const char *line)
|
|
internal_function;
|
|
static service_library *nss_new_service (name_database *database,
|
|
const char *name) internal_function;
|
|
|
|
|
|
/* Declare external database variables. */
|
|
#define DEFINE_DATABASE(name) \
|
|
extern service_user *__nss_##name##_database; \
|
|
weak_extern (__nss_##name##_database)
|
|
#include "databases.def"
|
|
#undef DEFINE_DATABASE
|
|
|
|
/* Structure to map database name to variable. */
|
|
static struct
|
|
{
|
|
const char *name;
|
|
service_user **dbp;
|
|
} databases[] =
|
|
{
|
|
#define DEFINE_DATABASE(name) \
|
|
{ #name, &__nss_##name##_database },
|
|
#include "databases.def"
|
|
#undef DEFINE_DATABASE
|
|
};
|
|
|
|
|
|
__libc_lock_define_initialized (static, lock)
|
|
|
|
|
|
#if !defined DO_STATIC_NSS || defined PIC
|
|
/* String with revision number of the shared object files. */
|
|
static const char *const __nss_shlib_revision = LIBNSS_FILES_SO + 15;
|
|
#endif
|
|
|
|
/* The root of the whole data base. */
|
|
static name_database *service_table;
|
|
|
|
|
|
/* -1 == database not found
|
|
0 == database entry pointer stored */
|
|
int
|
|
__nss_database_lookup (const char *database, const char *alternate_name,
|
|
const char *defconfig, service_user **ni)
|
|
{
|
|
/* Prevent multiple threads to change the service table. */
|
|
__libc_lock_lock (lock);
|
|
|
|
/* Reconsider database variable in case some other thread called
|
|
`__nss_configure_lookup' while we waited for the lock. */
|
|
if (*ni != NULL)
|
|
{
|
|
__libc_lock_unlock (lock);
|
|
return 0;
|
|
}
|
|
|
|
/* Are we initialized yet? */
|
|
if (service_table == NULL)
|
|
/* Read config file. */
|
|
service_table = nss_parse_file (_PATH_NSSWITCH_CONF);
|
|
|
|
/* Test whether configuration data is available. */
|
|
if (service_table != NULL)
|
|
{
|
|
/* Return first `service_user' entry for DATABASE. */
|
|
name_database_entry *entry;
|
|
|
|
/* XXX Could use some faster mechanism here. But each database is
|
|
only requested once and so this might not be critical. */
|
|
for (entry = service_table->entry; entry != NULL; entry = entry->next)
|
|
if (strcmp (database, entry->name) == 0)
|
|
*ni = entry->service;
|
|
|
|
if (*ni == NULL && alternate_name != NULL)
|
|
/* We haven't found an entry so far. Try to find it with the
|
|
alternative name. */
|
|
for (entry = service_table->entry; entry != NULL; entry = entry->next)
|
|
if (strcmp (alternate_name, entry->name) == 0)
|
|
*ni = entry->service;
|
|
}
|
|
|
|
/* No configuration data is available, either because nsswitch.conf
|
|
doesn't exist or because it doesn't has a line for this database.
|
|
|
|
DEFCONFIG specifies the default service list for this database,
|
|
or null to use the most common default. */
|
|
if (*ni == NULL)
|
|
*ni = nss_parse_service_list (defconfig
|
|
?: "nis [NOTFOUND=return] files");
|
|
|
|
__libc_lock_unlock (lock);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
/* -1 == not found
|
|
0 == adjusted for next function */
|
|
int
|
|
__nss_lookup (service_user **ni, const char *fct_name, void **fctp)
|
|
{
|
|
*fctp = nss_lookup_function (*ni, fct_name);
|
|
|
|
while (*fctp == NULL
|
|
&& nss_next_action (*ni, NSS_STATUS_UNAVAIL) == NSS_ACTION_CONTINUE
|
|
&& (*ni)->next != NULL)
|
|
{
|
|
*ni = (*ni)->next;
|
|
|
|
*fctp = nss_lookup_function (*ni, fct_name);
|
|
}
|
|
|
|
return *fctp != NULL ? 0 : -1;
|
|
}
|
|
|
|
|
|
/* -1 == not found
|
|
0 == adjusted for next function
|
|
1 == finished */
|
|
int
|
|
__nss_next (service_user **ni, const char *fct_name, void **fctp, int status,
|
|
int all_values)
|
|
{
|
|
if (all_values)
|
|
{
|
|
if (nss_next_action (*ni, NSS_STATUS_TRYAGAIN) == NSS_ACTION_RETURN
|
|
&& nss_next_action (*ni, NSS_STATUS_UNAVAIL) == NSS_ACTION_RETURN
|
|
&& nss_next_action (*ni, NSS_STATUS_NOTFOUND) == NSS_ACTION_RETURN
|
|
&& nss_next_action (*ni, NSS_STATUS_SUCCESS) == NSS_ACTION_RETURN)
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
/* This is really only for debugging. */
|
|
if (NSS_STATUS_TRYAGAIN > status || status > NSS_STATUS_RETURN)
|
|
__libc_fatal ("illegal status in " __FUNCTION__);
|
|
|
|
if (nss_next_action (*ni, status) == NSS_ACTION_RETURN)
|
|
return 1;
|
|
}
|
|
|
|
if ((*ni)->next == NULL)
|
|
return -1;
|
|
|
|
do
|
|
{
|
|
*ni = (*ni)->next;
|
|
|
|
*fctp = nss_lookup_function (*ni, fct_name);
|
|
}
|
|
while (*fctp == NULL
|
|
&& nss_next_action (*ni, NSS_STATUS_UNAVAIL) == NSS_ACTION_CONTINUE
|
|
&& (*ni)->next != NULL);
|
|
|
|
return *fctp != NULL ? 0 : -1;
|
|
}
|
|
|
|
|
|
int
|
|
__nss_configure_lookup (const char *dbname, const char *service_line)
|
|
{
|
|
service_user *new_db;
|
|
size_t cnt;
|
|
|
|
for (cnt = 0; cnt < sizeof databases; ++cnt)
|
|
{
|
|
int cmp = strcmp (dbname, databases[cnt].name);
|
|
if (cmp == 0)
|
|
break;
|
|
if (cmp < 0)
|
|
{
|
|
__set_errno (EINVAL);
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
if (cnt == sizeof databases)
|
|
{
|
|
__set_errno (EINVAL);
|
|
return -1;
|
|
}
|
|
|
|
/* Test whether it is really used. */
|
|
if (databases[cnt].dbp == NULL)
|
|
/* Nothing to do, but we could do. */
|
|
return 0;
|
|
|
|
/* Try to generate new data. */
|
|
new_db = nss_parse_service_list (service_line);
|
|
if (new_db == NULL)
|
|
{
|
|
/* Illegal service specification. */
|
|
__set_errno (EINVAL);
|
|
return -1;
|
|
}
|
|
|
|
/* Prevent multiple threads to change the service table. */
|
|
__libc_lock_lock (lock);
|
|
|
|
/* Install new rules. */
|
|
*databases[cnt].dbp = new_db;
|
|
|
|
__libc_lock_unlock (lock);
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
#if !defined DO_STATIC_NSS || defined PIC
|
|
static int
|
|
nss_dlerror_run (void (*operate) (void *), void *args)
|
|
{
|
|
char *last_errstring = NULL;
|
|
const char *last_object_name = NULL;
|
|
int result;
|
|
|
|
(void) _dl_catch_error (&last_errstring, &last_object_name, operate, args);
|
|
|
|
result = last_errstring != NULL;
|
|
if (result)
|
|
free (last_errstring);
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
struct do_open_args
|
|
{
|
|
/* Argument to do_open. */
|
|
char *shlib_name;
|
|
service_user *ni;
|
|
};
|
|
|
|
struct get_sym_args
|
|
{
|
|
/* Arguments to get_sym. */
|
|
struct link_map *map;
|
|
char *name;
|
|
|
|
/* Return values of get_sym. */
|
|
ElfW(Addr) loadbase;
|
|
const ElfW(Sym) *ref;
|
|
};
|
|
|
|
static void
|
|
do_open (void *a)
|
|
{
|
|
struct do_open_args *args = (struct do_open_args *) a;
|
|
/* Open and relocate the shared object. */
|
|
args->ni->library->lib_handle = _dl_open (args->shlib_name, RTLD_LAZY);
|
|
}
|
|
|
|
static void
|
|
get_sym (void *a)
|
|
{
|
|
struct get_sym_args *args = (struct get_sym_args *) a;
|
|
struct link_map *scope[2] = { args->map, NULL };
|
|
args->ref = NULL;
|
|
args->loadbase = _dl_lookup_symbol (args->name, &args->ref,
|
|
scope, args->map->l_name, 0);
|
|
}
|
|
#endif
|
|
|
|
/* Comparison function for searching NI->known tree. */
|
|
static int
|
|
known_compare (const void *p1, const void *p2)
|
|
{
|
|
return p1 == p2 ? 0 : strcmp (*(const char *const *) p1,
|
|
*(const char *const *) p2);
|
|
}
|
|
|
|
|
|
static void *
|
|
internal_function
|
|
nss_lookup_function (service_user *ni, const char *fct_name)
|
|
{
|
|
void **found, *result;
|
|
|
|
/* We now modify global data. Protect it. */
|
|
__libc_lock_lock (lock);
|
|
|
|
/* Search the tree of functions previously requested. Data in the
|
|
tree are `known_function' structures, whose first member is a
|
|
`const char *', the lookup key. The search returns a pointer to
|
|
the tree node structure; the first member of the is a pointer to
|
|
our structure (i.e. what will be a `known_function'); since the
|
|
first member of that is the lookup key string, &FCT_NAME is close
|
|
enough to a pointer to our structure to use as a lookup key that
|
|
will be passed to `known_compare' (above). */
|
|
|
|
found = __tsearch (&fct_name, (void **) &ni->known, &known_compare);
|
|
if (*found != &fct_name)
|
|
/* The search found an existing structure in the tree. */
|
|
result = ((known_function *) *found)->fct_ptr;
|
|
else
|
|
{
|
|
/* This name was not known before. Now we have a node in the tree
|
|
(in the proper sorted position for FCT_NAME) that points to
|
|
&FCT_NAME instead of any real `known_function' structure.
|
|
Allocate a new structure and fill it in. */
|
|
|
|
known_function *known = malloc (sizeof *known);
|
|
if (! known)
|
|
{
|
|
remove_from_tree:
|
|
/* Oops. We can't instantiate this node properly.
|
|
Remove it from the tree. */
|
|
__tdelete (&fct_name, (void **) &ni->known, &known_compare);
|
|
result = NULL;
|
|
}
|
|
else
|
|
{
|
|
/* Point the tree node at this new structure. */
|
|
*found = known;
|
|
known->fct_name = fct_name;
|
|
|
|
if (ni->library == NULL)
|
|
{
|
|
/* This service has not yet been used. Fetch the service
|
|
library for it, creating a new one if need be. If there
|
|
is no service table from the file, this static variable
|
|
holds the head of the service_library list made from the
|
|
default configuration. */
|
|
static name_database default_table;
|
|
ni->library = nss_new_service (service_table ?: &default_table,
|
|
ni->name);
|
|
if (ni->library == NULL)
|
|
{
|
|
/* This only happens when out of memory. */
|
|
free (known);
|
|
goto remove_from_tree;
|
|
}
|
|
}
|
|
|
|
#if !defined DO_STATIC_NSS || defined PIC
|
|
if (ni->library->lib_handle == NULL)
|
|
{
|
|
/* Load the shared library. */
|
|
size_t shlen = (7 + strlen (ni->library->name) + 3
|
|
+ strlen (__nss_shlib_revision) + 1);
|
|
|
|
struct do_open_args args;
|
|
args.shlib_name = __alloca (shlen);
|
|
args.ni = ni;
|
|
|
|
/* Construct shared object name. */
|
|
__stpcpy (__stpcpy (__stpcpy (__stpcpy (args.shlib_name,
|
|
"libnss_"),
|
|
ni->library->name),
|
|
".so"),
|
|
__nss_shlib_revision);
|
|
|
|
if (nss_dlerror_run (do_open, &args) != 0)
|
|
/* Failed to load the library. */
|
|
ni->library->lib_handle = (void *) -1l;
|
|
}
|
|
|
|
if (ni->library->lib_handle == (void *) -1l)
|
|
/* Library not found => function not found. */
|
|
result = NULL;
|
|
else
|
|
{
|
|
/* Get the desired function. Again, GNU ld.so magic ahead. */
|
|
size_t namlen = (5 + strlen (ni->library->name) + 1
|
|
+ strlen (fct_name) + 1);
|
|
struct get_sym_args args;
|
|
args.name = __alloca (namlen);
|
|
args.map = ni->library->lib_handle;
|
|
|
|
/* Construct the function name. */
|
|
__stpcpy (__stpcpy (__stpcpy (__stpcpy (args.name, "_nss_"),
|
|
ni->library->name),
|
|
"_"),
|
|
fct_name);
|
|
|
|
/* Look up the symbol. */
|
|
result = (nss_dlerror_run (get_sym, &args) ? NULL
|
|
: (void *) (args.loadbase + args.ref->st_value));
|
|
}
|
|
#else
|
|
/* We can't get function address dynamically in static linking. */
|
|
{
|
|
# define DEFINE_ENT(h,nm) \
|
|
extern void _nss_##h##_get##nm##ent_r (void); \
|
|
extern void _nss_##h##_end##nm##ent (void); \
|
|
extern void _nss_##h##_set##nm##ent (void);
|
|
# define DEFINE_GET(h,nm) \
|
|
extern void _nss_##h##_get##nm##_r (void);
|
|
# define DEFINE_GETBY(h,nm,ky) \
|
|
extern void _nss_##h##_get##nm##by##ky##_r (void);
|
|
# include "function.def"
|
|
# undef DEFINE_ENT
|
|
# undef DEFINE_GET
|
|
# undef DEFINE_GETBY
|
|
# define DEFINE_ENT(h,nm) \
|
|
{ #h"_get"#nm"ent_r", _nss_##h##_get##nm##ent_r }, \
|
|
{ #h"_end"#nm"ent", _nss_##h##_end##nm##ent }, \
|
|
{ #h"_set"#nm"ent", _nss_##h##_set##nm##ent },
|
|
# define DEFINE_GET(h,nm) \
|
|
{ #h"_get"#nm"_r", _nss_##h##_get##nm##_r },
|
|
# define DEFINE_GETBY(h,nm,ky) \
|
|
{ #h"_get"#nm"by"#ky"_r", _nss_##h##_get##nm##by##ky##_r },
|
|
static struct fct_tbl { const char *fname; void *fp; } *tp, tbl[] =
|
|
{
|
|
# include "function.def"
|
|
{ NULL, NULL }
|
|
};
|
|
size_t namlen = (5 + strlen (ni->library->name) + 1
|
|
+ strlen (fct_name) + 1);
|
|
char name[namlen];
|
|
|
|
/* Construct the function name. */
|
|
__stpcpy (__stpcpy (__stpcpy (name, ni->library->name),
|
|
"_"),
|
|
fct_name);
|
|
|
|
result = NULL;
|
|
for (tp = &tbl[0]; tp->fname; tp++)
|
|
if (strcmp (tp->fname, name) == 0)
|
|
{
|
|
result = tp->fp;
|
|
break;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
/* Remember function pointer for later calls. Even if null, we
|
|
record it so a second try needn't search the library again. */
|
|
known->fct_ptr = result;
|
|
}
|
|
}
|
|
|
|
/* Remove the lock. */
|
|
__libc_lock_unlock (lock);
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
static name_database *
|
|
internal_function
|
|
nss_parse_file (const char *fname)
|
|
{
|
|
FILE *fp;
|
|
name_database *result;
|
|
name_database_entry *last;
|
|
char *line;
|
|
size_t len;
|
|
|
|
/* Open the configuration file. */
|
|
fp = fopen (fname, "r");
|
|
if (fp == NULL)
|
|
return NULL;
|
|
|
|
result = (name_database *) malloc (sizeof (name_database));
|
|
if (result == NULL)
|
|
return NULL;
|
|
|
|
result->entry = NULL;
|
|
result->library = NULL;
|
|
last = NULL;
|
|
line = NULL;
|
|
len = 0;
|
|
do
|
|
{
|
|
name_database_entry *this;
|
|
ssize_t n;
|
|
char *cp;
|
|
|
|
n = __getline (&line, &len, fp);
|
|
if (n < 0)
|
|
break;
|
|
if (line[n - 1] == '\n')
|
|
line[n - 1] = '\0';
|
|
|
|
/* Because the file format does not know any form of quoting we
|
|
can search forward for the next '#' character and if found
|
|
make it terminating the line. */
|
|
cp = strchr (line, '#');
|
|
if (cp != NULL)
|
|
*cp = '\0';
|
|
|
|
/* If the line is blank it is ignored. */
|
|
if (line[0] == '\0')
|
|
continue;
|
|
|
|
/* Each line completely specifies the actions for a database. */
|
|
this = nss_getline (line);
|
|
if (this != NULL)
|
|
{
|
|
if (last != NULL)
|
|
last->next = this;
|
|
else
|
|
result->entry = this;
|
|
|
|
last = this;
|
|
}
|
|
}
|
|
while (!feof (fp));
|
|
|
|
/* Free the buffer. */
|
|
free (line);
|
|
/* Close configuration file. */
|
|
fclose (fp);
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
/* Read the source names:
|
|
`( <source> ( "[" "!"? (<status> "=" <action> )+ "]" )? )*'
|
|
*/
|
|
static service_user *
|
|
internal_function
|
|
nss_parse_service_list (const char *line)
|
|
{
|
|
service_user *result = NULL, **nextp = &result;
|
|
|
|
while (1)
|
|
{
|
|
service_user *new_service;
|
|
const char *name;
|
|
|
|
while (isspace (line[0]))
|
|
++line;
|
|
if (line[0] == '\0')
|
|
/* No source specified. */
|
|
return result;
|
|
|
|
/* Read <source> identifier. */
|
|
name = line;
|
|
while (line[0] != '\0' && !isspace (line[0]) && line[0] != '[')
|
|
++line;
|
|
if (name == line)
|
|
return result;
|
|
|
|
|
|
new_service = (service_user *) malloc (sizeof (service_user));
|
|
if (new_service == NULL)
|
|
return result;
|
|
else
|
|
{
|
|
char *source = (char *) malloc (line - name + 1);
|
|
if (source == NULL)
|
|
{
|
|
free (new_service);
|
|
return result;
|
|
}
|
|
memcpy (source, name, line - name);
|
|
source[line - name] = '\0';
|
|
|
|
new_service->name = source;
|
|
}
|
|
|
|
/* Set default actions. */
|
|
new_service->actions[2 + NSS_STATUS_TRYAGAIN] = NSS_ACTION_CONTINUE;
|
|
new_service->actions[2 + NSS_STATUS_UNAVAIL] = NSS_ACTION_CONTINUE;
|
|
new_service->actions[2 + NSS_STATUS_NOTFOUND] = NSS_ACTION_CONTINUE;
|
|
new_service->actions[2 + NSS_STATUS_SUCCESS] = NSS_ACTION_RETURN;
|
|
new_service->actions[2 + NSS_STATUS_RETURN] = NSS_ACTION_RETURN;
|
|
new_service->library = NULL;
|
|
new_service->known = NULL;
|
|
new_service->next = NULL;
|
|
|
|
while (isspace (line[0]))
|
|
++line;
|
|
|
|
if (line[0] == '[')
|
|
{
|
|
/* Read criterions. */
|
|
do
|
|
++line;
|
|
while (line[0] != '\0' && isspace (line[0]));
|
|
|
|
do
|
|
{
|
|
int not;
|
|
enum nss_status status;
|
|
lookup_actions action;
|
|
|
|
/* Grok ! before name to mean all statii but that one. */
|
|
if (not = line[0] == '!')
|
|
++line;
|
|
|
|
/* Read status name. */
|
|
name = line;
|
|
while (line[0] != '\0' && !isspace (line[0]) && line[0] != '='
|
|
&& line[0] != ']')
|
|
++line;
|
|
|
|
/* Compare with known statii. */
|
|
if (line - name == 7)
|
|
{
|
|
if (__strncasecmp (name, "SUCCESS", 7) == 0)
|
|
status = NSS_STATUS_SUCCESS;
|
|
else if (__strncasecmp (name, "UNAVAIL", 7) == 0)
|
|
status = NSS_STATUS_UNAVAIL;
|
|
else
|
|
return result;
|
|
}
|
|
else if (line - name == 8)
|
|
{
|
|
if (__strncasecmp (name, "NOTFOUND", 8) == 0)
|
|
status = NSS_STATUS_NOTFOUND;
|
|
else if (__strncasecmp (name, "TRYAGAIN", 8) == 0)
|
|
status = NSS_STATUS_TRYAGAIN;
|
|
else
|
|
return result;
|
|
}
|
|
else
|
|
return result;
|
|
|
|
while (isspace (line[0]))
|
|
++line;
|
|
if (line[0] != '=')
|
|
return result;
|
|
do
|
|
++line;
|
|
while (isspace (line[0]));
|
|
|
|
name = line;
|
|
while (line[0] != '\0' && !isspace (line[0]) && line[0] != '='
|
|
&& line[0] != ']')
|
|
++line;
|
|
|
|
if (line - name == 6 && __strncasecmp (name, "RETURN", 6) == 0)
|
|
action = NSS_ACTION_RETURN;
|
|
else if (line - name == 8
|
|
&& __strncasecmp (name, "CONTINUE", 8) == 0)
|
|
action = NSS_ACTION_CONTINUE;
|
|
else
|
|
return result;
|
|
|
|
if (not)
|
|
{
|
|
/* Save the current action setting for this status,
|
|
set them all to the given action, and reset this one. */
|
|
const lookup_actions save = new_service->actions[2 + status];
|
|
new_service->actions[2 + NSS_STATUS_TRYAGAIN] = action;
|
|
new_service->actions[2 + NSS_STATUS_UNAVAIL] = action;
|
|
new_service->actions[2 + NSS_STATUS_NOTFOUND] = action;
|
|
new_service->actions[2 + NSS_STATUS_SUCCESS] = action;
|
|
new_service->actions[2 + status] = save;
|
|
}
|
|
else
|
|
new_service->actions[2 + status] = action;
|
|
|
|
/* Skip white spaces. */
|
|
while (isspace (line[0]))
|
|
++line;
|
|
}
|
|
while (line[0] != ']');
|
|
|
|
/* Skip the ']'. */
|
|
++line;
|
|
}
|
|
|
|
*nextp = new_service;
|
|
nextp = &new_service->next;
|
|
}
|
|
}
|
|
|
|
static name_database_entry *
|
|
internal_function
|
|
nss_getline (char *line)
|
|
{
|
|
const char *name;
|
|
name_database_entry *result;
|
|
|
|
/* Ignore leading white spaces. ATTENTION: this is different from
|
|
what is implemented in Solaris. The Solaris man page says a line
|
|
beginning with a white space character is ignored. We regard
|
|
this as just another misfeature in Solaris. */
|
|
while (isspace (line[0]))
|
|
++line;
|
|
|
|
/* Recognize `<database> ":"'. */
|
|
name = line;
|
|
while (line[0] != '\0' && !isspace (line[0]) && line[0] != ':')
|
|
++line;
|
|
if (line[0] == '\0' || name == line)
|
|
/* Syntax error. */
|
|
return NULL;
|
|
*line++ = '\0';
|
|
|
|
result = (name_database_entry *) malloc (sizeof (name_database_entry));
|
|
if (result == NULL)
|
|
return NULL;
|
|
|
|
/* Save the database name. */
|
|
{
|
|
const size_t len = strlen (name) + 1;
|
|
char *new = malloc (len);
|
|
if (new == NULL)
|
|
{
|
|
free (result);
|
|
return NULL;
|
|
}
|
|
result->name = memcpy (new, name, len);
|
|
}
|
|
|
|
/* Parse the list of services. */
|
|
result->service = nss_parse_service_list (line);
|
|
|
|
result->next = NULL;
|
|
return result;
|
|
}
|
|
|
|
|
|
static service_library *
|
|
internal_function
|
|
nss_new_service (name_database *database, const char *name)
|
|
{
|
|
service_library **currentp = &database->library;
|
|
|
|
while (*currentp != NULL)
|
|
{
|
|
if (strcmp ((*currentp)->name, name) == 0)
|
|
return *currentp;
|
|
currentp = &(*currentp)->next;
|
|
}
|
|
|
|
/* We have to add the new service. */
|
|
*currentp = (service_library *) malloc (sizeof (service_library));
|
|
if (*currentp == NULL)
|
|
return NULL;
|
|
|
|
(*currentp)->name = name;
|
|
(*currentp)->lib_handle = NULL;
|
|
(*currentp)->next = NULL;
|
|
|
|
return *currentp;
|
|
}
|