./libc-linux/ 40755 1676 334 0 5567152202 11023 5ustar hjlisl./libc-linux/ChangeLog100644 1676 334 113455 5550064570 12745 0ustar hjlislMon Apr 4 15:24:19 1994 H.J. Lu (hlu@fudan) * version 4.5.26 is released. * jump/libm/jump.params: * jump/libc.lite/jump.params: * jump/libc/jump.params: bump up to version 4.5.26. * <_G_config.h>: update verion to 4.5.26. Mon Apr 4 14:49:33 1994 Nickolay Saukh (nms@ussr.EU.net) * locale/setlocale.c: new. * locale/collate: * locale/ctype: * locale/monetary: * locale/numeric: * locale/response: * locale/time: new. Mon Apr 4 13:49:33 1994 H.J. Lu (hlu@fudan) * Makeconfig: add CHARFLAGS=-funsigned-char. * : define _PATH_LOCALE as "/usr/lib/locale". * posix/cuserid.c: use getlogin () for multiply names with the same id. * login/getlogin.c: add check for fd 1 and 2. * : add ctermid (). * posix/ctermid.c: include . * : fix typo in ut_host [UT_NAMESIZE]. It should be ut_host[UT_HOSTSIZE]. * Makeconfig (NLSCFLAGS): add -I$(TOPDIR)/nls. * : renamed from . * nls/nl_types.h: removed. * ./libio/ioperror.c: * ./bsd/psignal.c: * ./posix/getopt.c: * ./string/strerror.c: * ./string/strsignal.c: * ./rpc/svc_au_ux.c: * ./rpc/get_myaddr.c: * ./rpc/pmap_getmaps.c: * ./rpc/svc_run.c: * ./rpc/pmap_clnt.c: * ./rpc/xdr_ref.c: * ./rpc/svc_simple.c: * ./rpc/xdr_array.c: * ./rpc/clnt_perror.c: * ./rpc/clnt_raw.c: * ./rpc/auth_unix.c: * ./rpc/svc_tcp.c: * ./rpc/pmap_rmt.c: * ./rpc/xdr.c: * ./rpc/clnt_tcp.c: * ./rpc/svc_udp.c: * ./rpc/xdr_rec.c: * ./rpc/clnt_udp.c: * ./inet/gethstnmad.c: * ./inet/herror.c: * ./inet/rcmd.c: * ./inet/rexec.c: * ./inet/ruserpass.c: change #include "../nls/nl_types.h" to #include "nl_types.h" Sat Mar 26 14:10:17 1994 H.J. Lu (hlu@fudan) * version 4.5.25 is released. * login/getlogin.c: don't include "pathnames.h". * jump/libc/jump.funcs: * jump/libc.lite/jump.funcs: fix a typo. * libbsd/logout.c: * libbsd/logwtmp.c: include . * : copied/modified from . * : include . * : removed. * time/strftime.c: "%j" should print the day of the yera in the range from 001 to 366. * Makefile (DIRS): * sysdeps/linux/Makefile (lib all): * sysdeps/linux/i386/Makefile (lib all): * sysdeps/linux/m68k/Makefile (lib all): check MATH. * misc/syslog.c (openlog): use sizeof(SyslogAddr) - sizeof(SyslogAddr.sa_data) + strlen(SyslogAddr.sa_data) for the address size. (vsyslog): close the log when write () fails. it will try to reconnect it next time. * nls/msgcat.c (catclose): * (catclose): change return from void to int. * login/getlogin.c: check USER_PROCESS. * : * sysdeps/linux/m68k/sysdep.h: fix a m68k bug. from "hamish (h.i.) macdonald" . * jump/libm/jump.params: * jump/libc.lite/jump.params: * jump/libc/jump.params: bump up to version 4.5.25. * <_G_config.h>: update verion to 4.5.25. * sysdeps/linux/i386/math/atanh.c: check x == -1.0. from "James H. Cloos Jr." . * login/getlogin.c: undo the change of Fri Mar 11. Fri Mar 18 13:35:20 1994 flebbe@pluto.tat.physik.uni-tuebingen.de (Olaf Flebbe) * : add cbrt (). (__finite): check __isnan (). * sysdeps/linux/i386/math/cbrt.c: new from SUN libm. * sysdeps/linux/i386/math/Makefile (SRC1S): add cbrt.c. * jump/libm/jump.funcs: add _cbrt. Fri Mar 11 15:00:58 1994 H.J. Lu (hlu@fudan) * version 4.5.24 is released. * jump/libm/jump.params: * jump/libc.lite/jump.params: * jump/libc/jump.params: bump up to version 4.5.24. * <_G_config.h>: update verion to 4.5.24. * Makerules: fix typos. * jump/libc/Makefile (install): * jump/libm/Makefile (install): move the old shared library to backup/$SHLIB_FILE.$$. * login/getlogin.c: call getpwnam(name). from Mitchum DSouza . * sbin/lib/i386/Makefile: * sbin/lib/m68k/Makefile: * sbin/lib/Makefile: * sysdeps/linux/Makefile: * jump/Makefile: * sbin/Makefile: * sysdeps/Makefile: * Maketargets: Use $(MAKE) -C $$i $@. * Makefile (install.static): delete __.SYMDEF from libc.a. (install.debug): delete __.SYMDEF from libg.a. (install.profile): delete __.SYMDEF from libc_p.a. * jump/libc/Makefile (JUMP_PARAMS): * jump/libc.lite/Makefile (JUMP_PARAMS): * jump/libm/Makefile (JUMP_PARAMS): change that to $(JUMP_DIR)/jump.params. * jump/libc/jump.params.build: * jump/libc.lite/jump.params.build: * jump/libm/jump.params.build: removed. Thu Mar 10 09:14:39 1994 H.J. Lu (hlu@fudan) * ./sysdeps/linux/i386/Makefile $(DIRS): don't add "math crt" if LITE is "true". * : for linux, only include . * : include . * : include . * Makeconfig: fix a typo. * jump/libc.lite/jump.funcs (_syscall): * jump/libc/jump.funcs (_syscall): mark it "T". * : change __syscall back to syscall. * ./sysdeps/linux/i386/Makefile $(SRC3S): change __syscall.S to syscall.S. * ./sysdeps/linux/i386/__syscall.S: removed. * ./sysdeps/linux/i386/syscall.S: new file. Sun Mar 6 21:52:39 1994 H.J. Lu (hlu@fudan) * version 4.5.23 is released. * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.23. * <_G_config.h>: update verion to 4.5.23. * Makeconfig (TARGET_LIBM_SO_DIR): change back to /lib. * ./libio/ChangeLog: new entries. * ./sysdeps/linux/i386/libc_exit.c: fixed for PIC. * ./sysdeps/linux/i386/Makefile $(SRC3S): add __syscall.S. Sat Mar 5 16:55:09 1994 H.J. Lu (hlu@fudan) * version 4.5.22 is released. * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.22 * <_G_config.h>: update verion to 4.5.22. * ./libio/ChangeLog: new entries. * stdlib/exit.c (exit): call _IO_flush_all directly if __PIC__ or __pic__ is defined. * (HAVE_GNU_LD): don't define it if __PIC__ or __pic__ is defined. * rpc/get_myaddr.c: change "#ifdef linux" to "#if 0". * jump/libc.lite/jump.funcs (_syscall): * jump/libc/jump.funcs (_syscall): mark it "U". * : change syscall to __syscall. * (__ipc): new. * ./sysdeps/linux/Makefile $(SRC2S): add __ipc.S. * ./sysdeps/linux/__ipc.S: new file. * ./sysdeps/linux/msgctl.c: * ./sysdeps/linux/msgget.c: * ./sysdeps/linux/msgrcv.c: * ./sysdeps/linux/msgsnd.c: * ./sysdeps/linux/semctl.c: * ./sysdeps/linux/semget.c: * ./sysdeps/linux/semop.c: * ./sysdeps/linux/shmat.c: * ./sysdeps/linux/shmctl.c: * ./sysdeps/linux/shmdt.c: * ./sysdeps/linux/shmget.c: use __ipc (). * ./sysdeps/linux/i386/Makefile (SRC1S): remove syscall.c. $(SRC3S): add __syscall.S. * ./sysdeps/linux/i386/__syscall.S: new file. * ./sysdeps/linux/i386/__ioctl.c: * ./sysdeps/linux/i386/__fcntl.c: * ./sysdeps/linux/i386/__open.c: * ./sysdeps/linux/i386/syscall.c: removed. * ./sysdeps/linux/__adjtime.c: * ./sysdeps/linux/__ntpgttm.c: don't include , include . * : new for cplus_demangle (). * Makefile: * Makeconfig: * Makerules: * Maketargets: add PIC from Mitchum DSouza . Tue Mar 1 14:37:46 1994 Matthias Urlichs * inet/res_send.c (res_send): if sethostent(1) has been called, the resolver opens a TCP connection to the nameserver. If a request is interrupted by a signal and we're longjmp()ing out, that connection goes out of sync. Ugh. Solution: If that happens, the connection should be closed and reopened. Flushing residual data might be an alternate idea except that the server might not have answered by the time we're trying the next request. Sat Feb 26 14:01:18 1994 H.J. Lu (hlu@nighthawk) * version 4.5.21 is re-released :-(. * ./sysdeps/linux/i386/gmon: moved from ./gmon. * ./sysdeps/linux/i386/gmon/Makefile (TOPDIR): change it to "../../../..". * ./sysdeps/linux/i386/Makefile (DIRS): add "gmon" if PROFILE == true. * ./gmon: moved to ./sysdeps/linux/i386. * ./Makefile (CLEAN_DIRS): (DIRS): remove "gmon". Tue Feb 22 14:23:06 1994 H.J. Lu (hlu@nighthawk) * version 4.5.21 is released. * sysdeps/linux/__adjtime.c: define SIMPLE_ADJTIME. * rpc/get_myaddr.c (USE_GETHOSTNAME): undo the change of Tue Feb 15. Mon Feb 21 13:18:20 1994 H.J. Lu (hlu@nighthawk) * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.21 * <_G_config.h>: update verion to 4.5.21. * ./libio/ChangeLog: new entries. * rpc/pmap_rmt.c (getbroadcastnets): change "#ifdef linux" to "#if 0". (SIOCGIFBRDADDR): use addrs[i++] = inet_makeaddr((int)inet_netof (sin->sin_addr), INADDR_ANY); need 0.99 pl15g or above. * : copied from glibc 1.07.4. Please check out if it is compatible with the old one. * misc/obstack.c: copied from glibc 1.07.4. * nls/linux/French/errlist.m: fix typoes. Sat Feb 19 13:19:34 1994 H.J. Lu (hlu@nighthawk) * : declcare cuserid (). * posix/cuserid.c: include . Tue Feb 15 12:01:14 1994 H.J. Lu (hlu@nighthawk) * version 4.5.20 is released. * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.20 * <_G_config.h>: update verion to 4.5.20. * jump/libc/Makefile (install): * jump/libm/Makefile (install): copy the old shared library to SHLIB_FILE.$$. * jump/libm/Makefile (install): replace TARGET_SO_DIR with TARGET_LIBM_SO_DIR. * Makeconfig (TARGET_LIBM_SO_DIR): new, make it /usr/lib. * configure: add credit for Mitchum Dsouza . * mntent/Makefile (SCR1S): change mntent.o to mntent.c. * (MNTMAXSTR): change that to 512 from 128. * : include . add __BEGIN_DECLS and __END_DECLS. * time/strftime.c (strftime): don't set the values before they are called for since not all the fields in the struct tm pointer passed are valid. * nls/linux/Makefile (FR-SRCS) (FRENCH-SRCS): (french:) new for French. * nls/linux/French/LISEZMOI: * nls/linux/French/auth.m: * nls/linux/French/clnt-misc.m: * nls/linux/French/errlist-u.m: * nls/linux/French/errlist.m: * nls/linux/French/getopt.m: * nls/linux/French/h-errlist.m: * nls/linux/French/net-misc.m: * nls/linux/French/rpc-errlist.m: * nls/linux/French/rpc-misc.m: * nls/linux/French/siglist-u.m: * nls/linux/French/siglist.m: new for French. * Makefile (DIRS): new entry for CHECKER == true. (install.checker): new. * curses/Makefile (CHECKER_LIB): * gcc/Makefile (CHECKER_LIB): * gdbm/Makefile (CHECKER_LIB): * libbsd/Makefile (CHECKER_LIB): * termcap/Makefile (CHECKER_LIB): new. * checker/Makefile: new. * sysdeps/linux/i386/crt/Makefile (lib): fix a typo in the chkrcrt0.o rule. * nls/Makefile (BASE_CFLAGS): no -DHAVE_MMAP if CHECKER is true. * Maketargets (lib): add a new rule for CHECKER_LIB. * : include( . (MAP_ANON, MAP_FILE): new. * ./libio/ChangeLog: new entries. * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: add _getpgid. * sysdeps/linux/Makefile (SRC2S): add getpgid.S. * sysdeps/linux/getpgid.S: new. need kernel 0.99 pl 15. * (getpgid): new. * (SYS_getpgid): new. * : copied from gawk 2.15.4. * regex/regex.c: copied and modified from gawk 2.15.4. * regex/regex.diff: modification to gawk 2.15.4. * rpc/get_myaddr.c (USE_GETHOSTNAME): defined. * sysdeps/linux/__adjtime.c: handle large time. * cureses/Makefile (SHARED_LIB): * gcc/Makefile (LIBGCC): * gdbm/Makefile (SHARED_LIB): * termcap/Makefile (SHARED_LIB): use $(SHARED_DIR) * cureses/Makefile (STATIC_LIB): * gdbm/Makefile (STATIC_LIB): * libbsd/Makefile (STATIC_LIB): * termcap/Makefile (STATIC_LIB): use $(STATIC_DIR) * : add some appropriate "const" in the prototypes. * malloc/Makefile (LIBMCHECK_SRCS): remove mcheck.c. (SRC1S): add mcheck.c. (lib): don't make $(LIBMCHECK). * Makefile (install.static): add libmalias.a for libm.a. (install.debug): copy debug/libc/mcheck-init.o to libmcheck.a. * sysdeps/linux/set-init.c: copied from glibc 1.07.2. * sysdeps/linux/m68k/math/Makefile (SRC1S): remove drem.c. * sysdeps/linux/m68k/math/drem.c: removed. * sysdeps/linux/i386/math/Makefile (SRC2S): remove drem.S. * sysdeps/linux/i386/math/drem.S: removed. * ./mntent/mntent.c (getmntent): return NULL if fgets () returns NULL. * Makeconfig: define LDCONFIG as "ldconfig" if the host machine is running Linux, otherwise as "true". (SHARED_LITE_DIR): new, "shared.lite". (SHARED_DIR): defined as $(SHARED_LITE_DIR) for the light shared C library if LITE is true. (OBJS_DIR): remove "shared.lite", add $(SHARED_LITE_DIR) * Maketargets (depend): add "$(SHARED_LITE_DIR)/$(SUBDIR)/\1". * jump/libc/Makefile (install): * jump/libm/Makefile (install): run $(LDCONFIG) if the host machine is running Linux. Wed Feb 2 22:15:36 1994 H.J. Lu (hlu@nighthawk) * version 4.5.19 is released. * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.19. * <_G_config.h>: update verion to 4.5.19. * inet/ruserpass.c (ruserpass): change the size of namebuf from 16 to 256. * inet/res_debug.c (nbuf): change the size to 256. * sysdeps/linux/i386/math/exp.S: add fwait for the buggy IIT 387 coprocessor. according to the i387 documentations, fwait is not needed as opposite to 8088/8087, 80286/80287. from echtien@pasiphae.rz.Uni-Osnabrueck.DE (Jens-Heiner Rechtien) Tue Feb 1 13:34:41 1994 H.J. Lu (hlu@nighthawk) * version 4.5.18 is released. * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.18. * <_G_config.h>: update verion to 4.5.18. * ./libio/ChangeLog: new entries. * Makeconfig (SHARED_DIR): use "shared.lite" for the light shared C library if LITE is true. (OBJS_DIR): add "shared.lite". Sun Jan 30 16:31:41 1994 H.J. Lu (hlu@nighthawk) * version 4.5.17 is released. * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.17. * : * : new files for debuggers. * <_G_config.h>: update verion to 4.5.17. * curses/addbytes.c (waddbytes): update x and y after " " is inserted for '/t'. * inet/ruserpass.c (ruserpass): check NULL pointers while copying hostname before call rnetrc (). * ./libio/ChangeLog: new entries. * Maketargets: minor changes. * malloc/Makefile (LIBMCHECK): add mcheck.o. * malloc/mcheck-init.c: undo the change of Jan 29. * sysdeps/linux/set-init.c: new, copied from glibc 1.06.12. * sysdeps/linux/Makefile (SRC1S): add set-init.c. * sysdeps/linux/i386/crt/chkrcrt0.S: * sysdeps/linux/i386/crt/crt0.S: * sysdeps/linux/i386/crt/gcrt0.S: * sysdeps/linux/m68k/crt/crt0.S: * sysdeps/linux/m68k/crt/gcrt0.S: call __libc_init () before calling main (). * jump/libc/Makefile (STATIC_OBJS): add set-init.o. Sat Jan 29 23:52:27 1994 H.J. Lu (hlu@nighthawk) * version 4.5.16 is released. * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.16. * Makerules ((%): %): delete the object file if we want to compile the shared/static object file in one pass. * malloc/mcheck-init.c: add turn_on_mcheck () to the __CTOR_LIST__ list. * ./libio/ChangeLog: new entries. Fri Jan 28 16:33:08 1994 H.J. Lu (hlu@nighthawk) * version 4.5.15 is released. * jump/libc/Makefilke: * jump/libm/Makefilke: change ifeq($(TARGET_LIB_DIR),/lib) to ifeq($(TARGET_SO_DIR),/lib) * : include only if __GNU_LIBRARY__ is defined. * ./inet/gethstnmad.c: fix a segmentation fault coredump problem if the "reorder" option is set to "on" in the /etc/host.conf file. from Mitch DSouza : * : * : add more m68k support. * : * : * : update. * configure: use highlight for ansi*, xterm*, vt* and cons* only. * sbin/lib/m68k: renamed from sbin/lib/m86k. Sun Jan 23 13:53:55 1994 H.J. Lu (hlu@nighthawk) * version 4.5.14 is released. * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.14. * jump/libc.lite/jump.vars (_re_max_failures): (_re_set_syntax): * jump/libc/jump.vars (_re_max_failures): * jump/libc/jump.vars (_re_set_syntax): * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: saved them in the files with the suffix ".rx". undo the changes of Jan. 22. * (_PATH_DEFPATH_ROOT): defined as "/sbin:/bin:/usr/sbin:/usr/bin" * : moved to ./regex. * : restored. * compat/Makefile (SRC1S): comment out aliases.c and __old_regex.c. * regex/Makefile (SCRS): change rx.c to regex.c. * regex/regex.c: restored. * regex/ChangeLog.rx: copied from sed 2.03. Sat Jan 22 13:53:55 1994 H.J. Lu (hlu@nighthawk) * version 4.5.13 is released. * configure: cosmetic changes. * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.13. * jump/libc.lite/jump.vars (_re_max_failures): * jump/libc/jump.vars (_re_max_failures): comment out. * jump/libc.lite/jump.vars (_re_set_syntax): * jump/libc/jump.vars (_re_set_syntax): change filename "regex" to "rx". * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: move _re_compile_fastmap, _re_compile_pattern, _re_match, _re_match_2, _re_search, _re_search_2, _re_set_registers, _re_set_syntax, _regcomp, _regerror, _regexec and _regfree to libcompat. create new entries for them and use "rx" as filename. * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: add "_rx_compile". * Maketargets: create ./static, ./shared, ./debug and ./profile only if necessry. * Makerules: don't build the libraries not asked for. (.x.o:): remove LD/MV. * Makeconfig: don't add '/' if the root dir == '/'. * inet/ruserpass.c (ruserpass): copy hostname before call rnetrc (). * : new file from sed 2.03 with modifications for Linux. * regex/rx.c: new file from sed 2.03 with modifications for Linux. * regex/rx.diff: the Linux diff. * regex/Makefile (SRCS): change regex.c to rx.c. * ./compat/aliases.c: aliases for __old_re_compile_fastmap, __old_re_compile_pattern, __old_re_match_2, __old_re_match, __old_re_search_2, __old_re_search and __old_re_set_registers. * ./compat/__old_regex.c: moved from ./regex/regex.c. * ./compat/regex.h: moved from . * ./compat/Makefile: add __old_regex.c. * ./regex/regex.c: moved to ./compat as ./compat/__old_regex.c. * : moved to ./compat. make a symbolic link to rx.h. * ./libio/ChangeLog: new entries. * malloc/Makefile (SRC1S): add memalign.c mstats.c mtrace.c. * jump/libc/Makefile (lib): fix typos. * : include . (_PATH_UTMP), (_PATH_WTMP), (_PATH_LASTLOG): removed. * (_PATH_MAILDIR): from "/usr/spool/mail" to "/var/spool/mail". (_PATH_SENDMAILI): from "/usr/lib/sendmail" to "/usr/sbin/sendmail". (_PATH_WTMP): defined as "/var/adm/wtmp". (_PATH_LASTLOG): defined as "/var/adm/lastlog". (_PATH_DEFPATH): add "/usr/local/bin" to prefix. (_PATH_LOGIN): defined as "/bin/login". (_PATH_DEFPATH_ROOT): defined as "/bin:/usr/bin:/etc". * (WTMP_FILE): from "/usr/adm/wtmp" to "/var/adm/wtmp". Tue Jan 18 23:31:59 1994 H.J. Lu (hlu@nighthawk) * version 4.5.12 is released. * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.12. * configure: cosmetic changes. * malloc/Makefile: change target "debug_lib" to "lib". * Maketargets: create ./static, ./shared, ./debug and ./profile. * (_PATH_LASTLOG): undo the change of Tue Jan 18 19:05:55 1994. * (_PATH_MAILDIR): undo the change of Tue Jan 18 19:05:55 1994. * (WTMP_FILE): undo the change of Tue Jan 18 19:05:55 1994. Tue Jan 18 19:05:55 1994 H.J. Lu (hlu@nighthawk) * version 4.5.11 is released. * README: modified. * (_PATH_LASTLOG): from "/usr/adm/lastlog" to "/var/adm/lastlog". * (_PATH_MAILDIR): from "/usr/spool/mail" to "/var/spool/mail". (_PATH_SENDMAILI): from "/usr/lib/sendmail" to "/usr/sbin/sendmail". * : check if __GNUC__ == 2 before check __GNUC_MINOR__ < 5. * (WTMP_FILE): from "/usr/adm/wtmp" to "/var/adm/wtmp". * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.11. * ./libio/ChangeLog: new entries. Mon Jan 17 22:04:43 1994 H.J. Lu (hlu@nighthawk) * rpc/clnt_perror.c (clnt_sperrno): minor NLS fix. * Makeconfig: set ARFLAGS == AR_FLAGS. * Makerules: fix rules for .x.y: * Maketargets: use libfoo.a (foo.o, ...) for the library dependency. * sysdeps/linux/libc_exit.S: removed. * sysdeps/linux/Makefile (SRC2S): remove libc_exit.S. * ./Makefile: * ./bsd/Makefile: * ./compat/Makefile: * ./compat/i386/Makefile: * ./compat/math/Makefile: * ./ctype/Makefile: * ./curses/Makefile: * ./cvt/Makefile: * ./dirent/Makefile: * ./gcc/Makefile: * ./gdbm/Makefile: * ./gmon/Makefile: * ./grp/Makefile: * ./inet/Makefile: * ./io/Makefile: * ./jump/Makefile: * ./jump/libc.lite/Makefile: * ./jump/libc/Makefile: * ./jump/libm/Makefile: * ./libbsd/Makefile: * ./libio/Makefile: * ./libio/stdio/Makefile: * ./locale/Makefile: * ./login/Makefile: * ./malloc-930716/Makefile: * ./malloc/Makefile: * ./math/Makefile: * ./misc/Makefile: * ./mntent/Makefile: * ./nls/Makefile: * ./posix/Makefile: * ./pwd/Makefile: * ./regex/Makefile: * ./rpc/Makefile: * ./sbin/Makefile: * ./sbin/lib/Makefile: * ./sbin/lib/i386/Makefile: * ./sbin/lib/i386/crt/Makefile: * ./setjmp/Makefile: * ./shadow/Makefile: * ./signal/Makefile: * ./stdlib/Makefile: * ./string/Makefile: * ./sysdeps/Makefile: * ./sysdeps/generic/Makefile: * ./sysdeps/i386/Makefile: * ./sysdeps/i386/setjmp/Makefile: * ./sysdeps/linux/Makefile: * ./sysdeps/linux/i386/Makefile: * ./sysdeps/linux/i386/crt/Makefile: * ./sysdeps/linux/i386/math/Makefile: * ./termcap/Makefile: * ./time/Makefile: * ./ufc/Makefile: * ./yp/Makefile: add TOPDIR and use it to find the include files. * configure: new file. * config.in: automatically generated by "configure". * Makeconfig: add a missing "(" to ifeq ($SHADOW_COMPAT),true). check TARGET_ARCH_486. use TOPDIR to get SRCDIR. * : don't inline toupper () and tolower () if __STRICT_ANSI__ is defined. Wed Jan 12 16:43:50 1994 H.J. Lu (hlu@nighthawk) * version 4.5.10 is released. * ./string/memchr.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/memchr.c: modified and moved from ./string. * ./string/memcmp.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/memcmp.c: modified and moved from ./string. * ./string/memset.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/memset.c: modified and moved from ./string. * ./string/bzero.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/bzero.c: modified and moved from ./string. * ./string/strcat.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/strcat.c: modified and moved from ./string. * ./string/strchr.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/strchr.c: modified and moved from ./string. * ./string/strcmp.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/strcmp.c: modified and moved from ./string. * ./string/strcspn.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/strcspn.c: modified and moved from ./string. * ./string/strlen.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/strlen.c: modified and moved from ./string. * ./string/strncmp.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/strncmp.c: modified and moved from ./string. * ./string/strpbrk.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/strpbrk.c: modified and moved from ./string. * ./string/strrchr.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/strrchr.c: modified and moved from ./string. * ./string/strspn.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/strspn.c: modified and moved from ./string. * ./string/ffs.c: modified and moved to ./sysdeps/i386. * ./sysdeps/i386/ffs.c: modified and moved from ./string. * ./string/memcopy.h: removed. * ./sysdeps/i386/memcopy.h: * ./sysdeps/generic/memcopy.h: * ./sysdeps/generic/ffs.c: * ./sysdeps/generic/strspn.c: * ./sysdeps/generic/strrchr.c: * ./sysdeps/generic/strpbrk.c: * ./sysdeps/generic/strncmp.c: * ./sysdeps/generic/strlen.c: * ./sysdeps/generic/strcspn.c: * ./sysdeps/generic/strcmp.c: * ./sysdeps/generic/strchr.c: * ./sysdeps/generic/strcat.c: * ./sysdeps/generic/bzero.c: * ./sysdeps/generic/memset.c: * ./sysdeps/generic/memcmp.c: * ./sysdeps/generic/memchr.c: * ./sysdeps/generic/modf.c: copied from glibc 1.06.9. * ./Makefile: * ./signal/Makefile: * ./libio/Makefile: * ./libio/stdio/Makefile: * ./bsd/Makefile: * ./ctype/Makefile: * ./curses/Makefile: * ./cvt/Makefile: * ./dirent/Makefile: * ./grp/Makefile: * ./setjmp/Makefile: * ./locale/Makefile: * ./login/Makefile: * ./malloc/Makefile: * ./misc/Makefile: * ./posix/Makefile: * ./pwd/Makefile: * ./regex/Makefile: * ./yp/Makefile: * ./stdlib/Makefile: * ./string/Makefile: * ./termcap/Makefile: * ./time/Makefile: * ./ufc/Makefile: * ./mntent/Makefile: * ./io/Makefile: * ./rpc/Makefile: * ./inet/Makefile: * ./gmon/Makefile: * ./gcc/Makefile: * ./gdbm/Makefile: * ./sysdeps/i386/Makefile: * ./sysdeps/i386/setjmp/Makefile: * ./sysdeps/linux/i386/Makefile: * ./sysdeps/linux/i386/math/Makefile: * ./sysdeps/linux/i386/crt/Makefile: * ./sysdeps/linux/Makefile: * ./sysdeps/Makefile: * ./jump/libc/Makefile: * ./jump/libc.lite/Makefile: * ./jump/libm/Makefile: * ./jump/Makefile: * ./math/Makefile: * ./compat/Makefile: * ./compat/i386/Makefile: * ./compat/math/Makefile: * ./shadow/Makefile: * ./libbsd/Makefile: * ./sbin/lib/Makefile: * ./sbin/Makefile: * ./malloc-930716/Makefile: * ./nls/Makefile: massive changes. * ./sbin/crt: moved to ./sbin/lib/i386/crt. * ./sbin/lib/i386/crt: moved from ./sbin/crt. * ./sbin/lib/m68k: new for m68k. * ./sbin/lib/i386/Makefile: * ./sbin/lib/i386/crt/Makefile: new files. * ./sysdeps/linux/fsync.c: removed * ./sysdeps/linux/i386/__adjtime.c: * ./sysdeps/linux/i386/__adjtimex.S: * ./sysdeps/linux/i386/__load.c: * ./sysdeps/linux/i386/config.h: * ./sysdeps/linux/i386/fixups.h: * ./sysdeps/linux/i386/__ntpgttm.c: * ./sysdeps/linux/i386/__vfork.c: * ./sysdeps/linux/i386/vfork.c: * ./sysdeps/linux/i386/__wait.c: * ./sysdeps/linux/i386/__wait3.c: * ./sysdeps/linux/i386/__waitpid.c: * ./sysdeps/linux/i386/accept.c: * ./sysdeps/linux/i386/bind.c: * ./sysdeps/linux/i386/connect.c: * ./sysdeps/linux/i386/getpeernam.c: * ./sysdeps/linux/i386/getsocknam.c: * ./sysdeps/linux/i386/getsockopt.c: * ./sysdeps/linux/i386/listen.c: * ./sysdeps/linux/i386/mmap.c: * ./sysdeps/linux/i386/shmat.c: * ./sysdeps/linux/i386/shmctl.c: * ./sysdeps/linux/i386/shmdt.c: * ./sysdeps/linux/i386/shmget.c: * ./sysdeps/linux/i386/msgctl.c: * ./sysdeps/linux/i386/msgget.c: * ./sysdeps/linux/i386/msgrcv.c: * ./sysdeps/linux/i386/msgsnd.c: * ./sysdeps/linux/i386/semctl.c: * ./sysdeps/linux/i386/semget.c: * ./sysdeps/linux/i386/semop.c: * ./sysdeps/linux/i386/recv.c: * ./sysdeps/linux/i386/revcfrom.c: * ./sysdeps/linux/i386/send.c: * ./sysdeps/linux/i386/sendto.c: * ./sysdeps/linux/i386/setpgrp.c: * ./sysdeps/linux/i386/setsockopt.c: * ./sysdeps/linux/i386/shutdown.c: * ./sysdeps/linux/i386/socket.c: * ./sysdeps/linux/i386/socketpair.c: * ./sysdeps/linux/i386/tell.c: * ./sysdeps/linux/i386/ulimit.c: moved to ./sysdeps/linux. * ./sysdeps/linux/shm.c: removed. * ./sysdeps/linux/__adjtime.c: * ./sysdeps/linux/__adjtimex.S: * ./sysdeps/linux/__load.c: * ./sysdeps/linux/config.h: * ./sysdeps/linux/fixups.h: * ./sysdeps/linux/__ntpgttm.c: * ./sysdeps/linux/__vfork.c: * ./sysdeps/linux/vfork.c: * ./sysdeps/linux/__wait.c: * ./sysdeps/linux/__wait3.c: * ./sysdeps/linux/__waitpid.c: * ./sysdeps/linux/accept.c: * ./sysdeps/linux/bind.c: * ./sysdeps/linux/connect.c: * ./sysdeps/linux/getpeernam.c: * ./sysdeps/linux/getsocknam.c: * ./sysdeps/linux/getsockopt.c: * ./sysdeps/linux/listen.c: * ./sysdeps/linux/mmap.c: * ./sysdeps/linux/shmat.c: * ./sysdeps/linux/shmctl.c: * ./sysdeps/linux/shmdt.c: * ./sysdeps/linux/shmget.c: * ./sysdeps/linux/msgctl.c: * ./sysdeps/linux/msgget.c: * ./sysdeps/linux/msgrcv.c: * ./sysdeps/linux/msgsnd.c: * ./sysdeps/linux/semctl.c: * ./sysdeps/linux/semget.c: * ./sysdeps/linux/semop.c: * ./sysdeps/linux/recv.c: * ./sysdeps/linux/revcfrom.c: * ./sysdeps/linux/send.c: * ./sysdeps/linux/sendto.c: * ./sysdeps/linux/setpgrp.c: * ./sysdeps/linux/setsockopt.c: * ./sysdeps/linux/shutdown.c: * ./sysdeps/linux/socket.c: * ./sysdeps/linux/socketpair.c: * ./sysdeps/linux/tell.c: * ./sysdeps/linux/ulimit.c: moved from ./sysdeps/linux/i386. * ./sysdeps/linux/i386/shm.c: removed. * ./misc/modf.c: moved to ./sysdeps/i386. * ./sysdeps/i386/modf.c: moved from ./misc. * ./sysdeps/i386/__longjmp.c: * ./sysdeps/i386/__setjmp.c: moved to ./sysdeps/i386/setjmp. * ./sysdeps/i386/setjmp/__longjmp.c: * ./sysdeps/i386/setjmp/__setjmp.c: moved from ./sysdeps/i386. * ./crt: moved to ./sysdeps/linux/i386/crt. * ./sysdeps/linux/i386/crt: moved from ./crt. * compat/__old_libm.c: moved to compat/math/__old_libm.c. * compat/math/__old_libm.c: moved from compat/__old_libm.c. * ./sysdeps/i386/setjmp/Makefile: * compat/math/Makefile: new file. * ./sysdeps/i386/Makefile: * ./misc/Makefile: * ./compat/Makefile: * ./compat/i386/Makefile: * ./sysdeps/linux/i386/crt/Makefile: * Makerules: * Makeconfig: * Maketargets: massive changes * config.in: new file. * : * : * : * : support m68k. * : dummy. * : define the jump buffer for m68k. * : define the inline system call interfaces for m68k. * : moved from , i387 control. * : define the jump buffer for i386. * : define the inline system call interfaces for i386. Mon Jan 10 11:45:49 1993 H.J. Lu (hlu@nighthawk) * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.10. * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: comment out _endspent, _fgetspent, _getspent, _getspnam, _putspent, _setspent, _sgetspent, _endsgent, _fgetsgent, _getsgent, _getsgnam, _putsgent, _setsgent and _sgetsgent. add _svc_exit. * jump/libc.lite/jump.vars: * jump/libc/jump.vars: comment out ___new_handler. * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: cghange ___builtin_delete, ___builtin_new, ___set_new_handler, _set_new_handler and ___eprintf to the type 't' from 'T'. * <_G_config.h>: add the version string _LINUX_C_LIB_VERSION and define it as "4.5.10". add and define #define _LINUX_C_LIB_VERSION_MAJOR 4 #define _LINUX_C_LIB_VERSION_MINOR 5 #define _LINUX_C_LIB_VERSION_SUBMINOR 10 * nls/msgcat.c: speed up. * rpc/svc_run.c: svc_exit (), new function for NYS from Peter Eriksson . set svc_stop. (svc_run): reset svc_stop and check svc_stop in the loop. * gcc/aliases.c: new file for __set_new_handler. * gcc/Makefile: add aliases.o. * jump/libc.lite/Makefile: * jump/libc/Makefile: * jump/libm/Makefile: add jump.log to the removal list. * : remove __line for malloc () and calloc (). * sysdeps/linux/i386/math/pow.c: new version from Chris Flatters . * inet/gethstnmad.c: * mntent/mntent.c: don't do fclose (NULL). * libbsd/Makefile: comment out getusersh.c. * libbsd/getusersh.c: removed. * pwd/getpwent.c: * pwd/getpwnam.c: * pwd/getpwuid.c: * pwd/pwdread.c: minor changes. * grp/getgrent.c: * grp/getgrnam.c: * grp/getgrgid.c: * grp/grpread.c: minor changes. * yp/xdryp.c: * yp/yplib.c: * yp/xdryppasswd.c: update. from swen@uni-paderborn.de. Tue Jan 4 16:34:34 1993 H.J. Lu (hlu@nighthawk) * sysdeps/linux/__load.c: write a message for the static linked binaries. * grp/Makefile (SRCS): comment out gshadow.c. * pwd/Makefile (SRCS): comment out shadow.c. * README: * Makeconfig: define NO_SHADOW only if SHADOW_COMPAT is defined. * Makeconfig: define SHARED_LIBRARY if SHARED is defined. * nls/msgcat.c: comment out rcsid. Sun Jan 2 12:12:23 1993 H.J. Lu (hlu@nighthawk) * version 4.5.9 is released. * jump/libm/jump.params: * jump/libm/jump.params.build: * jump/libc.lite/jump.params: * jump/libc.lite/jump.params.build: * jump/libc/jump.params: * jump/libc/jump.params.build: bump up to version 4.5.9. * : change _PATH_SENDMAIL to "/usr/lib/sendmail". * sysdeps/linux/i386/__adjtime.c: change mode to ADJ_OFFSET_SINGLESHOT from ADJ_OFFSET. * locale/setlocale.c: fix a wrong `}'. * README: * Makeconfig: add NO_SHADOW. * : fix a small typo in comments. * ./libio/ChangeLog: new entries. * ./libio/stdio/ChangeLog: new entries. ./libc-linux/jump/ 40755 1676 334 0 5550065621 11776 5ustar hjlisl./libc-linux/jump/libc.lite/ 40755 1676 334 0 5550065621 13643 5ustar hjlisl./libc-linux/jump/libc.lite/jump.params100644 1676 334 135 5550061522 16073 0ustar hjlislName=libc-lite Text=0x60000000 Data=0x60090000 Jump=0x00004000 GOT=0x00001000 Version=4.5.26 ./libc-linux/jump/libc.lite/jump.params.build100644 1676 334 135 5536421742 17201 0ustar hjlislName=libc-lite Text=0x60000000 Data=0x60090000 Jump=0x00004000 GOT=0x00001000 Version=4.5.23 ./libc-linux/jump/libc.lite/jump.funcs100644 1676 334 164227 5545077472 16042 0ustar hjlisl00000000 T ___siggetmask libc __siggtmsk 00000000 T ___sigsetmask libc __sigstmsk 00000000 t ___builtin_delete libgcc _op_delete 00000000 t ___builtin_new libgcc _op_new 00000000 U ___builtin_vec_delete libgcc _builtin_del 00000000 U ___builtin_vec_new libgcc _caps_New 00000000 t ___eprintf libgcc _eprintf 00000000 U ___fillbf libc emulate 00000000 U ___flshfp libc emulate 00000000 U __free_internal libc free 00000000 t _____old_getdtablesize libcompat __old_gdtbsz 00000000 T ___getpagesize libc __getpgsz 00000000 T ___grpalloc libc grpread 00000000 T ___grpopen libc grpopen 00000000 T ___grpread libc grpread 00000000 T ___initstate libc __random 00000000 T ___longjmp libc __longjmp 00000000 T ___overflow libc genos 00000000 T ___pwdalloc libc pwdread 00000000 T ___pwdopen libc pwdopen 00000000 T ___pwdread libc pwdread 00000000 T ___random libc __random 00000000 t ___set_new_handler libgcc _new_handler 00000000 T ___setjmp libc __setjmp 00000000 T ___setstate libc __random 00000000 T ___sigblock libc __sigblock 00000000 T ___sigpause libc __sigpause 00000000 T ___srandom libc __random 00000000 T ___underflow libc genos 00000000 T __IO_flush_all libc genos 00000000 T __exit libc libc_exit 00000000 U __filbuf libc emulate 00000000 U __flsbuf libc emulate 00000000 T __getlong libc res_comp 00000000 T __getopt_internal libc getopt 00000000 T __getshort libc res_comp 00000000 t ___longjmp libcompat 00000000 T __pututline libc utmp2 00000000 t ___setjmp libcompat 00000000 T __tolower libc ctype-extn 00000000 T __toupper libc ctype-extn 00000000 T _abort libc abort 00000000 t _labs libcompat 00000000 T _accept libc accept 00000000 T ___access libc __access 00000000 T _acct libc acct 00000000 T _addmntent libc mntent 00000000 T _alarm libc alarm 00000000 T _alphasort libc alphasort 00000000 T _asctime libc bsdtime 00000000 T _atexit libc atexit 00000000 T _atof libc atof 00000000 T _atoi libc atoi 00000000 T _atol libc atol 00000000 T _bcmp libc bcmp 00000000 T _bcopy libc bcopy 00000000 T _bind libc bind 00000000 U _box libcurses box 00000000 T ___brk libc __brk 00000000 T _bsearch libc bsearch 00000000 T _bzero libc bzero 00000000 T _calloc libc calloc 00000000 T _cfgetispeed libc cfsetget 00000000 T _cfgetospeed libc cfsetget 00000000 t _free libcompat 00000000 T _cfsetispeed libc cfsetget 00000000 T _cfsetospeed libc cfsetget 00000000 T ___chdir libc __chdir 00000000 T ___chmod libc __chmod 00000000 T ___chown libc __chown 00000000 T _chroot libc chroot 00000000 T _clearerr libc clearerr 00000000 T _clock libc clock 00000000 T ___close libc __close 00000000 T _closedir libc closedir 00000000 T _confstr libc confstr 00000000 T _connect libc connect 00000000 T _creat libc creat 00000000 T _crypt libc crypt_util 00000000 T _ctermid libc ctermid 00000000 T _ctime libc bsdtime 00000000 T _cuserid libc cuserid 00000000 U _dbm_close libdbm dbmclose 00000000 U _dbm_delete libdbm dbmdelete 00000000 U _dbm_dirfno libdbm dbmdirfno 00000000 U _dbm_fetch libdbm dbmfetch 00000000 U _dbm_firstkey libdbm dbmseq 00000000 U _dbm_nextkey libdbm dbmseq 00000000 U _dbm_open libdbm dbmopen 00000000 U _dbm_pagfno libdbm dbmpagfno 00000000 U _dbm_store libdbm dbmstore 00000000 U _dbminit libdbm dbminit 00000000 U _delete libdbm delete 00000000 U _delwin libcurses delwin 00000000 T _difftime libc difftime 00000000 t _ldiv libcompat 00000000 T _dn_comp libc res_comp 00000000 T _dn_expand libc res_comp 00000000 T _dn_skipname libc res_comp 00000000 T _drand48 libc drand48 00000000 T __IO_dtoa libc floatconv 00000000 T ___dup libc __dup 00000000 T ___dup2 libc __dup2 00000000 T _ecvt libc cvt 00000000 T _encrypt libc crypt_util 00000000 T _endgrent libc getgrent 00000000 T _endhostent libc sethostent 00000000 T _endmntent libc mntent 00000000 T _endnetent libc getnetent 00000000 T _endprotoent libc getprtent 00000000 T _endpwent libc getpwent 00000000 T _endservent libc getservent 00000000 T _endutent libc utmp2 00000000 U _endwin libcurses endwin 00000000 T _erand48 libc drand48 00000000 T _execl libc execl 00000000 T _execle libc execle 00000000 T _execlp libc execlp 00000000 T _execv libc execv 00000000 T ___execve libc __execve 00000000 T _execvp libc execvp 00000000 T _exit libc exit 00000000 T ___fchmod libc __fchmod 00000000 T ___fchown libc __fchown 00000000 T __IO_fclose libc iofclose 00000000 T ___fcntl libc __fcntl 00000000 T _fcvt libc cvt 00000000 T __IO_fdopen libc iofdopen 00000000 T _feof libc feof 00000000 T _ferror libc ferror 00000000 U _fetch libdbm fetch 00000000 T __IO_fflush libc iofflush 00000000 T _ffs libc ffs 00000000 T _fgetc libc fgetc 00000000 T _fgetgrent libc fgetgrent 00000000 T __IO_fgetpos libc iofgetpos 00000000 T _fgetpwent libc fgetpwent 00000000 T __IO_fgets libc iofgets 00000000 T _fileno libc fileno 00000000 U _firstkey libdbm seq 00000000 T _fnmatch libc fnmatch 00000000 T __IO_fopen libc iofopen 00000000 T ___fork libc __fork 00000000 T ___fpathconf libc __fpathconf 00000000 T __IO_fprintf libc iofprintf 00000000 T _fputc libc fputc 00000000 T __IO_fputs libc iofputs 00000000 T __IO_fread libc iofread 00000000 T _free libc free 00000000 T _freopen libc freopen 00000000 T __IO_fscanf libc iofscanf 00000000 T _fseek libc fseek 00000000 T __IO_fsetpos libc iofsetpos 00000000 T ___fstat libc __fstat 00000000 T ___fstatfs libc __fstatfs 00000000 T __IO_ftell libc ioftell 00000000 T _ftime libc ftime 00000000 T _ftruncate libc ftruncate 00000000 T _ftw libc ftw 00000000 T __IO_fwrite libc iofwrite 00000000 T _gcvt libc gcvt 00000000 U _gdbm_close libdbm gdbmclose 00000000 U _gdbm_delete libdbm gdbmdelete 00000000 U _gdbm_fetch libdbm gdbmfetch 00000000 U _gdbm_firstkey libdbm gdbmseq 00000000 U _gdbm_nextkey libdbm gdbmseq 00000000 U _gdbm_open libdbm gdbmopen 00000000 U _gdbm_reorganize libdbm gdbmreorg 00000000 U _gdbm_store libdbm gdbmstore 00000000 T _getc libc getc 00000000 U _getcap libcurses cr_tty 00000000 T _getchar libc getchar 00000000 T _getcwd libc getcwd 00000000 t _____old_getdtablesize libcompat __old_gdtbsz 00000000 T ___getegid libc __getegid 00000000 T _getenv libc getenv 00000000 T ___geteuid libc __geteuid 00000000 T ___getgid libc __getgid 00000000 T _getgrent libc getgrent 00000000 T _getgrgid libc getgrgid 00000000 T _getgrnam libc getgrnam 00000000 T ___getgroups libc __getgrps 00000000 T _gethostbyaddr libc gethstnmad 00000000 T _gethostbyname libc gethstnmad 00000000 T ___old__gethostname libcompat __old__ghn 00000000 T ___getitimer libc __getitmr 00000000 T _getlogin libc getlogin 00000000 T _getmntent libc mntent 00000000 T _getnetbyaddr libc getnetbyad 00000000 T _getnetbyname libc getnetbynm 00000000 T _getnetent libc getnetent 00000000 T _getopt libc getopt 00000000 T _getopt_long libc getopt1 00000000 T _getopt_long_only libc getopt1 00000000 t ___getpagesize libcompat 00000000 T _getpass libc getpass 00000000 T _getpeername libc getpeernam 00000000 T _getpgrp libc getpgrp 00000000 T ___getpid libc __getpid 00000000 T ___getppid libc __getppid 00000000 T _getpriority libc getprio 00000000 T _getprotobyname libc getprtname 00000000 T _getprotobynumber libc getproto 00000000 T _getprotoent libc getprtent 00000000 T _getpw libc getpw 00000000 T _getpwent libc getpwent 00000000 T _getpwnam libc getpwnam 00000000 T _getpwuid libc getpwuid 00000000 T _getrlimit libc getrlimit 00000000 T ___getrusage libc __getrusag 00000000 T __IO_gets libc iogets 00000000 T _getservbyname libc getsrvbynm 00000000 T _getservbyport libc getsrvbypt 00000000 T _getservent libc getservent 00000000 T _getsockname libc getsocknam 00000000 T _getsockopt libc getsockopt 00000000 T ___gettimeofday libc __gettod 00000000 U _gettmode libcurses cr_tty 00000000 T ___getuid libc __getuid 00000000 T _getutent libc utmp2 00000000 T _getutid libc utmp2 00000000 T _getutline libc utmp2 00000000 T _getw libc getw 00000000 T _getwd libc getwd 00000000 t ___old_glob libcompat __old_glob 00000000 t ___old_globfree libcompat __old_glob 00000000 T _gmtime libc bsdtime 00000000 T _hasmntopt libc mntent 00000000 T _herror libc herror 00000000 T _htonl libc hton 00000000 T _htons libc hton 00000000 U _idlok libcurses idlok 00000000 t _strchr libcompat 00000000 T _inet_addr libc inet_addr 00000000 T _inet_lnaof libc inet_lnaof 00000000 T _inet_makeaddr libc inet_mkadr 00000000 T _inet_netof libc inet_netof 00000000 T _inet_network libc inet_net 00000000 T _inet_ntoa libc inet_ntoa 00000000 T _initgroups libc initgroups 00000000 U _initscr libcurses initscr 00000000 t ___initstate libcompat 00000000 T ___ioctl libc __ioctl 00000000 T _ioperm libc ioperm 00000000 T _iopl libc iopl 00000000 T _isalnum libc ctype 00000000 T _isalpha libc ctype 00000000 T _isascii libc ctype-extn 00000000 T ___isatty libc __isatty 00000000 T _isblank libc ctype-extn 00000000 T _iscntrl libc ctype 00000000 T _isdigit libc ctype 00000000 T _isgraph libc ctype 00000000 T _islower libc ctype 00000000 T _isprint libc ctype 00000000 T _ispunct libc ctype 00000000 T _isspace libc ctype 00000000 T _isupper libc ctype 00000000 T _isxdigit libc ctype 00000000 T _jrand48 libc drand48 00000000 T ___kill libc __kill 00000000 T _killpg libc killpg 00000000 T _labs libc labs 00000000 T _lcong48 libc drand48 00000000 T _ldexp libc ldexp 00000000 T _ldiv libc ldiv 00000000 T ___link libc __link 00000000 T _listen libc listen 00000000 T _localtime libc bsdtime 00000000 t ___longjmp libcompat 00000000 U _longname libcurses longname 00000000 T _lrand48 libc drand48 00000000 T ___lseek libc __lseek 00000000 T ___lstat libc __lstat 00000000 T _malloc libc malloc 00000000 T _mblen libc mblen 00000000 T _mbstowcs libc mbstowcs 00000000 T _mbtowc libc mbtowc 00000000 U _memalign libc memalign 00000000 T ___memccpy libc __memccpy 00000000 T _memchr libc memchr 00000000 T _memcmp libc memcmp 00000000 T _memcpy libc memcpy 00000000 T _memmove libc memmove 00000000 T _memset libc memset 00000000 T ___mkdir libc __mkdir 00000000 T _mkfifo libc mkfifo 00000000 T ___mknod libc __mknod 00000000 T _mktemp libc mktemp 00000000 T _mktime libc bsdtime 00000000 T _mmap libc mmap 00000000 T _modf libc modf 00000000 T _mount libc mount 00000000 T _mrand48 libc drand48 00000000 T _munmap libc munmap 00000000 U _mvcur libcurses cr_put 00000000 U _mvprintw libcurses mvprintw 00000000 U _mvscanw libcurses mvscanw 00000000 U _mvwin libcurses mvwin 00000000 U _mvwprintw libcurses mvprintw 00000000 U _mvwscanw libcurses mvscanw 00000000 U _newwin libcurses newwin 00000000 U _nextkey libdbm seq 00000000 T _nice libc nice 00000000 T _nrand48 libc drand48 00000000 t _htonl libcompat 00000000 t _htons libcompat 00000000 T _on_exit libc on_exit 00000000 T ___open libc __open 00000000 T _opendir libc opendir 00000000 U _overlay libcurses overlay 00000000 U _overwrite libcurses overwrite 00000000 T _p_type libc res_debug 00000000 T ___pathconf libc __pathconf 00000000 T _pause libc pause 00000000 T _pclose libc popen 00000000 T __IO_perror libc ioperror 00000000 T ___pipe libc __pipe 00000000 T __IO_popen libc iopopen 00000000 T __IO_printf libc ioprintf 00000000 U _printw libcurses printw 00000000 T _psignal libc psignal 00000000 T _ptrace libc ptrace 00000000 T _putc libc putc 00000000 T _putchar libc putchar 00000000 T _putenv libc putenv 00000000 T _putlong libc res_comp 00000000 T _putpwent libc putpwent 00000000 T __IO_puts libc ioputs 00000000 T _putshort libc res_comp 00000000 T _pututline libc utmp2 00000000 T _putw libc putw 00000000 T _qsort libc qsort 00000000 T _raise libc raise 00000000 T _rand libc rand 00000000 t ___random libcompat 00000000 T _rcmd libc rcmd 00000000 T _re_comp libc regex 00000000 T _re_compile_fastmap libc regex 00000000 T _re_compile_pattern libc regex 00000000 T _re_exec libc regex 00000000 T _re_match libc regex 00000000 T _re_match_2 libc regex 00000000 T _re_search libc regex 00000000 T _re_search_2 libc regex 00000000 T _re_set_syntax libc regex 00000000 T ___read libc __read 00000000 T _readdir libc readdir 00000000 T ___readlink libc __readlink 00000000 T _readv libc readv 00000000 T _realloc libc realloc 00000000 T _reboot libc reboot 00000000 T _recv libc recv 00000000 T _recvfrom libc recvfrom 00000000 T _regcomp libc regex 00000000 T _regerror libc regex 00000000 T _regexec libc regex 00000000 T _regfree libc regex 00000000 t ___unlink libcompat 00000000 T _rename libc rename 00000000 T _res_init libc res_init 00000000 T _res_mkquery libc res_mkqry 00000000 T _res_query libc res_query 00000000 T _res_querydomain libc res_query 00000000 T _res_search libc res_query 00000000 T _res_send libc res_send 00000000 T _rewind libc rewind 00000000 T _rewinddir libc rewinddir 00000000 T _rexec libc rexec 00000000 t _strrchr libcompat 00000000 T ___rmdir libc __rmdir 00000000 T _rresvport libc rcmd 00000000 T _ruserok libc rcmd 00000000 T _ruserpass libc ruserpass 00000000 T ___sbrk libc __sbrk 00000000 T _scandir libc scandir 00000000 T __IO_scanf libc ioscanf 00000000 U _scanw libcurses scanw 00000000 U _scroll libcurses scroll 00000000 T _seed48 libc drand48 00000000 T _seekdir libc seekdir 00000000 t ___old_select libcompat __old_sel 00000000 T _send libc send 00000000 T _sendto libc sendto 00000000 t _set_new_handler libgcc _new_handler 00000000 T _setbuf libc setbuf 00000000 T __IO_setbuffer libc iosetbuffer 00000000 T _setenv libc setenv 00000000 T _setfileno libc setfileno 00000000 T ___setgid libc __setgid 00000000 T _setgrent libc getgrent 00000000 T _setgroups libc setgroups 00000000 T _sethostent libc sethostent 00000000 T _sethostname libc sethstnm 00000000 T ___setitimer libc __setitmr 00000000 T _setkey libc crypt_util 00000000 T _setlinebuf libc setlinebuf 00000000 T _setlocale libc setlocale 00000000 t __IO_fopen libcompat 00000000 T _setnetent libc getnetent 00000000 T _setpgid libc setpgid 00000000 T _setpgrp libc setpgrp 00000000 T _setpriority libc setprio 00000000 T _setprotoent libc getprtent 00000000 T _setpwent libc getpwent 00000000 T ___setregid libc __setregid 00000000 T ___setreuid libc __setreuid 00000000 T _setrlimit libc setrlimit 00000000 T _setservent libc getservent 00000000 T ___setsid libc __setsid 00000000 T _setsockopt libc setsockopt 00000000 t ___setstate libcompat 00000000 U _setterm libcurses cr_tty 00000000 T ___settimeofday libc __settod 00000000 T ___setuid libc __setuid 00000000 T _setutent libc utmp2 00000000 T __IO_setvbuf libc iosetvbuf 00000000 T _shutdown libc shutdown 00000000 T ___sigaction libc __sigact 00000000 T _sigaddset libc sigaddset 00000000 t ___sigblock libcompat 00000000 T _sigdelset libc sigdelset 00000000 T _sigemptyset libc sigempty 00000000 T _sigfillset libc sigfillset 00000000 t ___siggetmask libcompat 00000000 T _sigismember libc sigismem 00000000 T _siglongjmp libc siglongjmp 00000000 T _signal libc signal 00000000 t ___sigpause libcompat 00000000 T _sigpending libc sigpending 00000000 T ___sigprocmask libc __sigproc 00000000 T ___old_sigsetjmp libcompat __old_sigsj 00000000 t ___sigsetmask libcompat 00000000 T _sigsuspend libc sigsuspend 00000000 T _sleep libc sleep 00000000 T _socket libc socket 00000000 T _socketpair libc socketpair 00000000 T __IO_sprintf libc iosprintf 00000000 t ___srandom libcompat 00000000 T _srand48 libc drand48 00000000 t ___srandom libcompat 00000000 T __IO_sscanf libc iosscanf 00000000 T ___stat libc __stat 00000000 T ___statfs libc __statfs 00000000 T _stime libc stime 00000000 U _store libdbm store 00000000 T _strcasecmp libc strcasecmp 00000000 T _strcat libc strcat 00000000 T _strchr libc strchr 00000000 T _strcmp libc strcmp 00000000 T _strcoll libc strcoll 00000000 T _strcpy libc strcpy 00000000 T _strcspn libc strcspn 00000000 T _strdup libc strdup 00000000 T _strerror libc strerror 00000000 T _strftime libc strftime 00000000 T _strlen libc strlen 00000000 T _strncasecmp libc strncscmp 00000000 T _strncat libc strncat 00000000 T _strncmp libc strncmp 00000000 T _strncpy libc strncpy 00000000 T _strpbrk libc strpbrk 00000000 T _strrchr libc strrchr 00000000 T _strsignal libc strsignal 00000000 T _strspn libc strspn 00000000 T _strstr libc strstr 00000000 T __IO_strtod libc floatconv 00000000 T _strtok libc strtok 00000000 T _strtol libc strtol 00000000 T _strtoul libc strtoul 00000000 T _strxfrm libc strxfrm 00000000 U _subwin libcurses newwin 00000000 T _swab libc swab 00000000 T _swapon libc swapon 00000000 T ___symlink libc __symlink 00000000 T _sync libc sync 00000000 T ___sysconf libc __sysconf 00000000 T _system libc system 00000000 T _tcdrain libc tcdrain 00000000 T _tcflow libc tcflow 00000000 T _tcflush libc tcflush 00000000 T ___tcgetattr libc __tcgetatr 00000000 T _tcgetpgrp libc tcgetpgrp 00000000 T _tcsendbreak libc tcsendbrk 00000000 T _tcsetattr libc tcsetattr 00000000 T _tcsetpgrp libc tcsetpgrp 00000000 T _tell libc tell 00000000 T _telldir libc telldir 00000000 T _tempnam libc tempnam 00000000 T _tgetent libtermcap termcap 00000000 T _tgetflag libtermcap termcap 00000000 T _tgetnum libtermcap termcap 00000000 T _tgetstr libtermcap termcap 00000000 T _tgoto libtermcap tparam 00000000 T _time libc time 00000000 T ___times libc __times 00000000 T _tmpfile libc tmpfile 00000000 T _tmpnam libc tmpnam 00000000 T _toascii libc ctype-extn 00000000 T _tolower libc ctype 00000000 U _touchline libcurses touchwin 00000000 U _touchwin libcurses touchwin 00000000 T _toupper libc ctype 00000000 T _tparam libtermcap tparam 00000000 T _tputs libtermcap termcap 00000000 T _truncate libc truncate 00000000 T _ttyname libc ttyname 00000000 T _tzset libc bsdtime 00000000 T _ulimit libc ulimit 00000000 T ___umask libc __umask 00000000 T _umount libc umount 00000000 T ___old__uname libcompat __old__uname 00000000 T __IO_ungetc libc ioungetc 00000000 T ___unlink libc __unlink 00000000 T _unsetenv libc setenv 00000000 T _uselib libc uselib 00000000 T _usleep libc usleep 00000000 T _ustat libc ustat 00000000 T _utime libc utime 00000000 T _utmpname libc utmp2 00000000 T _valloc libc valloc 00000000 t ___fork libcompat 00000000 T __IO_vfprintf libc iovfprintf 00000000 T _vfscanf libc vfscanf 00000000 T _vhangup libc vhangup 00000000 T _vprintf libc vprintf 00000000 T _vscanf libc vscanf 00000000 T __IO_vsprintf libc iovsprintf 00000000 T __IO_vsscanf libc iovsscanf 00000000 U _waddbytes libcurses addbytes 00000000 U _waddch libcurses addch 00000000 U _waddstr libcurses addstr 00000000 T ___wait libc __wait 00000000 T ___wait3 libc __wait3 00000000 T ___wait4 libc __wait4 00000000 T ___waitpid libc __waitpid 00000000 U _wclear libcurses clear 00000000 U _wclrtobot libcurses clrtobot 00000000 U _wclrtoeol libcurses clrtoeol 00000000 T _wcstombs libc wcstombs 00000000 T _wctomb libc wctomb 00000000 U _wdelch libcurses delch 00000000 U _wdeleteln libcurses deleteln 00000000 U _werase libcurses erase 00000000 U _wgetch libcurses getch 00000000 U _wgetstr libcurses getstr 00000000 U _winsch libcurses insch 00000000 U _winsertln libcurses insertln 00000000 U _wmove libcurses move 00000000 U _wprintw libcurses printw 00000000 U _wrefresh libcurses refresh 00000000 T ___write libc __write 00000000 T _writev libc writev 00000000 U _wscanw libcurses scanw 00000000 U _wstandend libcurses standout 00000000 U _wstandout libcurses standout 00000000 U _mcheck libc mcheck 00000000 U _mtrace libc mtrace 00000000 U _mstats libc mstats 00000000 T _swapoff libc swapoff 00000000 T _vm86 libc vm86 00000000 T ___flock libc __flock 00000000 T _fp_query libc res_debug 00000000 T _hostalias libc res_query 00000000 T ___new_exitfn libc atexit 00000000 T _p_class libc res_debug 00000000 T _p_time libc res_debug 00000000 T ___utimes libc __utimes 00000000 T __quicksort libc _quicksort 00000000 T _bindresvport libc bindresvport 00000000 T _cfmakeraw libc cfmakeraw 00000000 T _endusershell libc getusersh 00000000 T _fcrypt libc crypt_util 00000000 T _get_current_dir_name libc getdirname 00000000 T _getusershell libc getusersh 00000000 T _idle libc idle 00000000 T _init_des libc crypt_util 00000000 T _insque libc insremque 00000000 T _localeconv libc localeconv 00000000 T _memfrob libc memfrob 00000000 T _memmem libc memmem 00000000 T _mkstemp libc mkstemp 00000000 T _nlist libc nlist 00000000 T _re_set_registers libc regex 00000000 T _remque libc insremque 00000000 T _setegid libc setegid 00000000 T _seteuid libc seteuid 00000000 T _setusershell libc getusersh 00000000 T _strfry libc strfry 00000000 T _strsep libc strsep 00000000 T _syscall libc syscall 00000000 T __authenticate libc svc_auth 00000000 T __rpc_dtablesize libc rpc_dtblsz 00000000 T __seterr_reply libc rpc_prot 00000000 T __svcauth_null libc svc_auth 00000000 T __svcauth_short libc svc_au_ux 00000000 T __svcauth_unix libc svc_au_ux 00000000 T _authnone_create libc auth_none 00000000 T _authunix_create libc auth_unix 00000000 T _authunix_create_default libc auth_unix 00000000 T _callrpc libc clnt_simple 00000000 T _clnt_broadcast libc pmap_rmt 00000000 T _clnt_create libc clnt_generic 00000000 T _clnt_pcreateerror libc clnt_perror 00000000 T _clnt_perrno libc clnt_perror 00000000 T _clnt_perror libc clnt_perror 00000000 T _clnt_spcreateerror libc clnt_perror 00000000 T _clnt_sperrno libc clnt_perror 00000000 T _clnt_sperror libc clnt_perror 00000000 T _clntraw_create libc clnt_raw 00000000 T _clnttcp_create libc clnt_tcp 00000000 T _clntudp_bufcreate libc clnt_udp 00000000 T _clntudp_create libc clnt_udp 00000000 T _endrpcent libc getrpcent 00000000 T _get_myaddress libc get_myaddr 00000000 T _getrpcbyname libc getrpcent 00000000 T _getrpcbynumber libc getrpcent 00000000 T _getrpcent libc getrpcent 00000000 T _getrpcport libc getrpcport 00000000 T _pmap_getmaps libc pmap_getmaps 00000000 T _pmap_getport libc pmap_getport 00000000 T _pmap_rmtcall libc pmap_rmt 00000000 T _pmap_set libc pmap_clnt 00000000 T _pmap_unset libc pmap_clnt 00000000 T _registerrpc libc svc_simple 00000000 T _setrpcent libc getrpcent 00000000 T _svc_getreq libc svc 00000000 T _svc_getreqset libc svc 00000000 T _svc_register libc svc 00000000 T _svc_run libc svc_run 00000000 T _svc_sendreply libc svc 00000000 T _svc_unregister libc svc 00000000 T _svcerr_auth libc svc 00000000 T _svcerr_decode libc svc 00000000 T _svcerr_noproc libc svc 00000000 T _svcerr_noprog libc svc 00000000 T _svcerr_progvers libc svc 00000000 T _svcerr_systemerr libc svc 00000000 T _svcerr_weakauth libc svc 00000000 T _svcfd_create libc svc_tcp 00000000 T _svcraw_create libc svc_raw 00000000 T _svctcp_create libc svc_tcp 00000000 T _svcudp_bufcreate libc svc_udp 00000000 T _svcudp_create libc svc_udp 00000000 T _svcudp_enablecache libc svc_udp 00000000 T _xdr_accepted_reply libc rpc_prot 00000000 T _xdr_array libc xdr_array 00000000 T _xdr_authunix_parms libc auth_prot 00000000 T _xdr_bool libc xdr 00000000 T _xdr_bytes libc xdr 00000000 T _xdr_callhdr libc rpc_prot 00000000 T _xdr_callmsg libc rpc_callmsg 00000000 T _xdr_char libc xdr 00000000 T _xdr_des_block libc rpc_prot 00000000 T _xdr_double libc xdr_float 00000000 T _xdr_enum libc xdr 00000000 T _xdr_float libc xdr_float 00000000 T _xdr_free libc xdr 00000000 T _xdr_int libc xdr 00000000 T _xdr_long libc xdr 00000000 T _xdr_netobj libc xdr 00000000 T _xdr_opaque libc xdr 00000000 T _xdr_opaque_auth libc rpc_prot 00000000 T _xdr_pmap libc pmap_prot 00000000 T _xdr_pmaplist libc pmap_prot2 00000000 T _xdr_pointer libc xdr_ref 00000000 T _xdr_reference libc xdr_ref 00000000 T _xdr_rejected_reply libc rpc_prot 00000000 T _xdr_replymsg libc rpc_prot 00000000 T _xdr_rmtcall_args libc pmap_rmt 00000000 T _xdr_rmtcallres libc pmap_rmt 00000000 T _xdr_short libc xdr 00000000 T _xdr_string libc xdr 00000000 T _xdr_u_char libc xdr 00000000 T _xdr_u_int libc xdr 00000000 T _xdr_u_long libc xdr 00000000 T _xdr_u_short libc xdr 00000000 T _xdr_union libc xdr 00000000 T _xdr_vector libc xdr_array 00000000 T _xdr_void libc xdr 00000000 T _xdr_wrapstring libc xdr 00000000 T _xdrmem_create libc xdr_mem 00000000 T _xdrrec_create libc xdr_rec 00000000 T _xdrrec_endofrecord libc xdr_rec 00000000 T _xdrrec_eof libc xdr_rec 00000000 T _xdrrec_skiprecord libc xdr_rec 00000000 T _xdrstdio_create libc xdr_stdio 00000000 T _xprt_register libc svc 00000000 T _xprt_unregister libc svc 00000000 T _glob libc glob 00000000 T _globfree libc glob 00000000 T _closelog libc syslog 00000000 T _openlog libc syslog 00000000 T _setlogmask libc syslog 00000000 T _syslog libc syslog 00000000 T _vsyslog libc syslog 00000000 T ___select libc __select 00000000 T ___getdtablesize libc __getdtsz 00000000 U ___muldi3 libgcc _muldi3 00000000 U ___udivdi3 libgcc _udivdi3 00000000 U ___udivmoddi4 libgcc _udivmoddi4 00000000 U ___umoddi3 libgcc _umoddi3 00000000 U ___stdio_gen_tempname libc tempname 00000000 T __IO_adjust_column libc genos 00000000 T __IO_default_doallocate libc genos 00000000 T __IO_default_finish libc genos 00000000 T __IO_default_pbackfail libc genos 00000000 T __IO_default_read libc genos 00000000 T __IO_default_seek libc genos 00000000 T __IO_default_seekoff libc genos 00000000 T __IO_default_seekpos libc genos 00000000 T __IO_default_setbuf libc genos 00000000 T __IO_default_stat libc genos 00000000 T __IO_default_write libc genos 00000000 T __IO_default_xsgetn libc genos 00000000 T __IO_default_xsputn libc genos 00000000 T __IO_do_write libc fileops 00000000 T __IO_doallocbuf libc genos 00000000 T __IO_file_attach libc fileops 00000000 T __IO_file_close libc fileops 00000000 T __IO_file_doallocate libc filedoalloc 00000000 T __IO_file_finish libc fileops 00000000 T __IO_file_fopen libc fileops 00000000 T __IO_file_init libc fileops 00000000 T __IO_file_overflow libc fileops 00000000 T __IO_file_read libc fileops 00000000 T __IO_file_seek libc fileops 00000000 T __IO_file_seekoff libc fileops 00000000 T __IO_file_setbuf libc fileops 00000000 T __IO_file_stat libc fileops 00000000 T __IO_file_sync libc fileops 00000000 T __IO_file_underflow libc fileops 00000000 T __IO_file_write libc fileops 00000000 T __IO_file_xsputn libc fileops 00000000 T __IO_flush_all_linebuffered libc genos 00000000 T __IO_free_backup_area libc genos 00000000 T __IO_get_column libc genos 00000000 T __IO_getline libc iogetline 00000000 T __IO_ignore libc ioignore 00000000 T __IO_init libc genos 00000000 T __IO_init_marker libc genos 00000000 T __IO_least_marker libc genos 00000000 T __IO_link_in libc genos 00000000 T __IO_marker_delta libc genos 00000000 T __IO_marker_difference libc genos 00000000 T __IO_nobackup_pbackfail libc genos 00000000 T __IO_outfloat libc outfloat 00000000 T __IO_padn libc iopadn 00000000 T __IO_proc_close libc iopopen 00000000 T __IO_proc_open libc iopopen 00000000 T __IO_remove_marker libc genos 00000000 T __IO_seekmark libc genos 00000000 T __IO_seekoff libc ioseekoff 00000000 T __IO_seekpos libc ioseekpos 00000000 T __IO_set_column libc genos 00000000 T __IO_setb libc genos 00000000 T __IO_sgetn libc genos 00000000 T __IO_sputbackc libc genos 00000000 T __IO_str_count libc strops 00000000 T __IO_str_finish libc strops 00000000 T __IO_str_init_readonly libc strops 00000000 T __IO_str_init_static libc strops 00000000 T __IO_str_overflow libc strops 00000000 T __IO_str_pbackfail libc strops 00000000 T __IO_str_seekoff libc strops 00000000 T __IO_str_underflow libc strops 00000000 T __IO_sungetc libc genos 00000000 T __IO_switch_to_backup_area libc genos 00000000 T __IO_switch_to_get_mode libc genos 00000000 T __IO_switch_to_main_get_area libc genos 00000000 T __IO_sync libc genos 00000000 T __IO_un_link libc genos 00000000 T __IO_unsave_markers libc genos 00000000 T __IO_vfscanf libc iovfscanf 00000000 T __IO_gen_tempname libc iotempname 00000000 U _endspent libc shadow 00000000 U _fgetspent libc shadow 00000000 U _getspent libc shadow 00000000 U _getspnam libc shadow 00000000 U _putspent libc shadow 00000000 U _setspent libc shadow 00000000 U _sgetspent libc shadow 00000000 U _endsgent libc gshadow 00000000 U _fgetsgent libc gshadow 00000000 U _getsgent libc gshadow 00000000 U _getsgnam libc gshadow 00000000 U _putsgent libc gshadow 00000000 U _setsgent libc gshadow 00000000 U _sgetsgent libc gshadow 00000000 T __IO_file_close_it libc fileops 00000000 T __IO_default_underflow libc genos 00000000 T _svc_exit libc svc_run 00000000 U _getpgid libc getpgid 00000000 U _readable__3ios libc streambuf 00000000 U _writable__3ios libc streambuf 00000000 U _is_open__3ios libc streambuf 00000000 U _init_const__12strstreambuf libc strstream 00000000 U ___12strstreambuf libc strstream 00000000 U ___12strstreambufi libc strstream 00000000 U ___12strstreambufPFUi_PvPFPv_v libc strstream 00000000 U ___12strstreambufPciT1 libc strstream 00000000 U ___12strstreambufPUciT1 libc strstream 00000000 U ___12strstreambufPCci libc strstream 00000000 U ___12strstreambufPCUci libc strstream 00000000 U ___12strstreambufPSciT1 libc strstream 00000000 U ___12strstreambufPCSci libc strstream 00000000 U _frozen__12strstreambuf libc strstream 00000000 U _freeze__12strstreambufi libc strstream 00000000 U _rdbuf__13strstreambase libc strstream 00000000 U ___13strstreambasei libc strstream 00000000 U __$_13strstreambase libc strstream 00000000 U __$_10istrstream libc strstream 00000000 U ___10ostrstreamiPcii libc strstream 00000000 U _pcount__10ostrstream libc strstream 00000000 U _str__10ostrstream libc strstream 00000000 U _freeze__10ostrstreami libc strstream 00000000 U _frozen__10ostrstream libc strstream 00000000 U __$_10ostrstream libc strstream 00000000 U ___9strstreami libc strstream 00000000 U ___9strstreamiPcii libc strstream 00000000 U _pcount__9strstream libc strstream 00000000 U _str__9strstream libc strstream 00000000 U _freeze__9strstreami libc strstream 00000000 U _frozen__9strstream libc strstream 00000000 U __$_9strstream libc strstream 00000000 U ___10istrstreamiPCci libc strstream 00000000 U ___10ostrstreami libc strstream 00000000 U ___13strstreambaseiPcii libc strstream 00000000 U _str__12strstreambuf libc strstream 00000000 U _pcount__12strstreambuf libc strstream 00000000 U _overflow__12strstreambufi libc strstream 00000000 U _underflow__12strstreambuf libc strstream 00000000 U _init_dynamic__12strstreambufPFUi_PvPFPv_vi libc strstream 00000000 U _init_static__12strstreambufPciT1 libc strstream 00000000 U __$_12strstreambuf libc strstream 00000000 U _seekoff__12strstreambuflQ23ios8seek_diri libc strstream 00000000 U _pbackfail__12strstreambufi libc strstream 00000000 U _rdbuf__C11fstreambase libc fstream 00000000 U _is_open__C11fstreambase libc fstream 00000000 U _setbuf__11fstreambasePci libc fstream 00000000 U _filedesc__11fstreambase libc fstream 00000000 U _raw__11fstreambase libc fstream 00000000 U __$_11fstreambase libc fstream 00000000 U ___8ifstreami libc fstream 00000000 U ___8ifstreamii libc fstream 00000000 U ___8ifstreamiPCcii libc fstream 00000000 U _open__8ifstreamPCcii libc fstream 00000000 U __$_8ifstream libc fstream 00000000 U ___8ofstreami libc fstream 00000000 U ___8ofstreamii libc fstream 00000000 U ___8ofstreamiPCcii libc fstream 00000000 U _open__8ofstreamPCcii libc fstream 00000000 U __$_8ofstream libc fstream 00000000 U ___7fstreami libc fstream 00000000 U ___7fstreamii libc fstream 00000000 U ___7fstreamiPCcii libc fstream 00000000 U _open__7fstreamPCcii libc fstream 00000000 U __$_7fstream libc fstream 00000000 U ___11fstreambasei libc fstream 00000000 U ___11fstreambaseii libc fstream 00000000 U ___11fstreambaseiPCcii libc fstream 00000000 U _open__11fstreambasePCcii libc fstream 00000000 U _close__11fstreambase libc fstream 00000000 U _getline__7istreamPcic libc igetline 00000000 U _get__7istreamPcic libc igetline 00000000 U _gets__7istreamPPcc libc igetline 00000000 U _get__7istreamR9streambufc libc igetsb 00000000 U ___iomanip_setbase__FR3iosi libc iomanip 00000000 U ___iomanip_setfill__FR3iosi libc iomanip 00000000 U ___iomanip_setprecision__FR3iosi libc iomanip 00000000 U ___iomanip_setw__FR3iosi libc iomanip 00000000 U ___iomanip_setiosflags__FR3iosUl libc iomanip 00000000 U ___iomanip_resetiosflags__FR3iosUl libc iomanip 00000000 U ___7ostreami libc iostream 00000000 U _opfx__7ostream libc iostream 00000000 U _osfx__7ostream libc iostream 00000000 U _ostreambuf__C7ostream libc iostream 00000000 U _put__7ostreamc libc iostream 00000000 U _put__7ostreamUc libc iostream 00000000 U _write__7ostreamPCUci libc iostream 00000000 U _put__7ostreamSc libc iostream 00000000 U _write__7ostreamPCSci libc iostream 00000000 U _write__7ostreamPCvi libc iostream 00000000 U ___ls__7ostreamUc libc iostream 00000000 U ___ls__7ostreamSc libc iostream 00000000 U ___ls__7ostreamPCUc libc iostream 00000000 U ___ls__7ostreamPCSc libc iostream 00000000 U ___ls__7ostreams libc iostream 00000000 U ___ls__7ostreamUs libc iostream 00000000 U ___ls__7ostreamf libc iostream 00000000 U ___ls__7ostreamPFR7ostream_R7ostream libc iostream 00000000 U ___ls__7ostreamPFR3ios_R3ios libc iostream 00000000 U __$_7ostream libc iostream 00000000 U ___7istreami libc iostream 00000000 U _istreambuf__C7istream libc iostream 00000000 U _get__7istreamPUcic libc iostream 00000000 U _get__7istreamRUc libc iostream 00000000 U _getline__7istreamPUcic libc iostream 00000000 U _get__7istreamRSc libc iostream 00000000 U _get__7istreamPScic libc iostream 00000000 U _getline__7istreamPScic libc iostream 00000000 U _read__7istreamPUci libc iostream 00000000 U _read__7istreamPSci libc iostream 00000000 U _read__7istreamPvi libc iostream 00000000 U _ipfx__7istreami libc iostream 00000000 U _ipfx0__7istream libc iostream 00000000 U _ipfx1__7istream libc iostream 00000000 U _get__7istream libc iostream 00000000 U _peek__7istream libc iostream 00000000 U _gcount__7istream libc iostream 00000000 U _putback__7istreamc libc iostream 00000000 U _unget__7istream libc iostream 00000000 U _unget__7istreamc libc iostream 00000000 U ___rs__7istreamPUc libc iostream 00000000 U ___rs__7istreamPSc libc iostream 00000000 U ___rs__7istreamRUc libc iostream 00000000 U ___rs__7istreamRSc libc iostream 00000000 U ___rs__7istreamPFR3ios_R3ios libc iostream 00000000 U ___rs__7istreamPFR7istream_R7istream libc iostream 00000000 U __$_7istream libc iostream 00000000 U ___8iostreami libc iostream 00000000 U __$_8iostream libc iostream 00000000 U _dec__FR3ios libc iostream 00000000 U _hex__FR3ios libc iostream 00000000 U _oct__FR3ios libc iostream 00000000 U ___7istreamiP9streambufP7ostream libc iostream 00000000 U _skip_ws__FP9streambuf libc iostream 00000000 U _get__7istreamRc libc iostream 00000000 U _ignore__7istreamii libc iostream 00000000 U _read__7istreamPci libc iostream 00000000 U _seekg__7istreaml libc iostream 00000000 U _seekg__7istreamlQ23ios8seek_dir libc iostream 00000000 U _tellg__7istream libc iostream 00000000 U _scan__7istreamPCce libc iostream 00000000 U _vscan__7istreamPCcPv libc iostream 00000000 U ___rs__7istreamRc libc iostream 00000000 U ___rs__7istreamPc libc iostream 00000000 U ___rs__7istreamRs libc iostream 00000000 U ___rs__7istreamRUs libc iostream 00000000 U ___rs__7istreamRi libc iostream 00000000 U ___rs__7istreamRUi libc iostream 00000000 U ___rs__7istreamRl libc iostream 00000000 U ___rs__7istreamRUl libc iostream 00000000 U ___rs__7istreamRx libc iostream 00000000 U ___rs__7istreamRUx libc iostream 00000000 U ___rs__7istreamRd libc iostream 00000000 U ___rs__7istreamRf libc iostream 00000000 U ___rs__7istreamP9streambuf libc iostream 00000000 U ___ls__7ostreamc libc iostream 00000000 U ___ls__7ostreami libc iostream 00000000 U ___ls__7ostreamUi libc iostream 00000000 U ___ls__7ostreaml libc iostream 00000000 U ___ls__7ostreamUl libc iostream 00000000 U ___ls__7ostreamx libc iostream 00000000 U ___ls__7ostreamUx libc iostream 00000000 U ___ls__7ostreamd libc iostream 00000000 U ___ls__7ostreamPCc libc iostream 00000000 U ___ls__7ostreamPCv libc iostream 00000000 U ___ls__7ostreamP9streambuf libc iostream 00000000 U ___7ostreamiP9streambufPT0 libc iostream 00000000 U _seekp__7ostreaml libc iostream 00000000 U _seekp__7ostreamlQ23ios8seek_dir libc iostream 00000000 U _tellp__7ostream libc iostream 00000000 U _form__7ostreamPCce libc iostream 00000000 U _vform__7ostreamPCcPv libc iostream 00000000 U _flush__7ostream libc iostream 00000000 U _flush__FR7ostream libc iostream 00000000 U _ws__FR7istream libc iostream 00000000 U __skip_ws__7istream libc iostream 00000000 U _ends__FR7ostream libc iostream 00000000 U _endl__FR7ostream libc iostream 00000000 U _write__7ostreamPCci libc iostream 00000000 U _do_osfx__7ostream libc iostream 00000000 U ___8iostreamiP9streambufP7ostream libc iostream 00000000 U _close__3ios libc iostream 00000000 U _skip__7istreami libc iostream 00000000 U _stdiofile__C8stdiobuf libc stdiostream 00000000 U __$_8stdiobuf libc stdiostream 00000000 U ___8stdiobufP6__FILE libc stdiostream 00000000 U _sys_read__8stdiobufPcUi libc stdiostream 00000000 U _sys_write__8stdiobufPCvl libc stdiostream 00000000 U _sys_seek__8stdiobuflQ23ios8seek_dir libc stdiostream 00000000 U _sys_close__8stdiobuf libc stdiostream 00000000 U _sync__8stdiobuf libc stdiostream 00000000 U _overflow__8stdiobufi libc stdiostream 00000000 U _xsputn__8stdiobufPCci libc stdiostream 00000000 U _sync_with_stdio__3iosi libc stdstreams 00000000 U _form__FPCce libc stream 00000000 U _dec__Fli libc stream 00000000 U _dec__Fii libc stream 00000000 U _dec__FUli libc stream 00000000 U _dec__FUii libc stream 00000000 U _hex__Fli libc stream 00000000 U _hex__Fii libc stream 00000000 U _hex__FUli libc stream 00000000 U _hex__FUii libc stream 00000000 U _oct__Fli libc stream 00000000 U _oct__Fii libc stream 00000000 U _oct__FUli libc stream 00000000 U _oct__FUii libc stream 00000000 T __validuser libc rcmd 00000000 T _fsync libc fsync 00000000 T _siginterrupt libc sigint 00000000 T ___sigjmp_save libc sigjmp 00000000 T __obstack_allocated_p libc obstack 00000000 T __obstack_begin libc obstack 00000000 T __obstack_begin_1 libc obstack 00000000 T __obstack_free libc obstack 00000000 T __obstack_newchunk libc obstack 00000000 T _obstack_free libc obstack 00000000 T ___uname libc __uname 00000000 T _getdomainname libc getdnnm 00000000 T _setdomainname libc setdnnm 00000000 T ___gethostname libc __gethstnm 00000000 T ___bsd_signal libc __bsd_sig 00000000 T _ftok libc ftok 00000000 T _msgctl libc msgctl 00000000 T _msgget libc msgget 00000000 T _msgrcv libc msgrcv 00000000 T _msgsnd libc msgsnd 00000000 T _semctl libc semctl 00000000 T _semget libc semget 00000000 T _semop libc semop 00000000 T _shmat libc shmat 00000000 T _shmctl libc shmctl 00000000 T _shmdt libc shmdt 00000000 T _shmget libc shmget 00000000 U _xdr_domainname libc xdryp 00000000 U _xdr_peername libc xdryp 00000000 U _xdr_datum libc xdryp 00000000 U _xdr_mapname libc xdryp 00000000 U _xdr_ypreq_key libc xdryp 00000000 U _xdr_ypreq_nokey libc xdryp 00000000 U _xdr_yp_inaddr libc xdryp 00000000 U _xdr_ypbind_binding libc xdryp 00000000 U _xdr_ypbind_resptype libc xdryp 00000000 U _xdr_ypstat libc xdryp 00000000 U _xdr_ypbind_resp libc xdryp 00000000 U _xdr_ypresp_val libc xdryp 00000000 U _xdr_ypbind_setdom libc xdryp 00000000 U _xdr_ypresp_key_val libc xdryp 00000000 U _xdr_ypresp_all libc xdryp 00000000 U _xdr_ypresp_all_seq libc xdryp 00000000 U _xdr_ypresp_master libc xdryp 00000000 U _xdr_ypmaplist_str libc xdryp 00000000 U _xdr_ypmaplist libc xdryp 00000000 U _xdr_ypresp_maplist libc xdryp 00000000 U _xdr_ypresp_order libc xdryp 00000000 U _xdr_passwd libc xdryppasswd 00000000 U _xdr_yppasswd libc xdryppasswd 00000000 U _yp_bind libc yplib 00000000 U _yp_unbind libc yplib 00000000 U _yp_match libc yplib 00000000 U _yp_get_default_domain libc yplib 00000000 U _yp_first libc yplib 00000000 U _yp_next libc yplib 00000000 U _yp_all libc yplib 00000000 U _yp_order libc yplib 00000000 U _yp_master libc yplib 00000000 U _yp_maplist libc yplib 00000000 U _yperr_string libc yplib 00000000 U _ypprot_err libc yplib 00000000 U ___yp_check libc yplib 00000000 T _gethostid libc hostid 00000000 T _sethostid libc hostid 00000000 T _mprotect libc mprotect 00000000 T ___adjtime libc __adjtime 00000000 T ___adjtimex libc __adjtimex 00000000 T ___ntp_gettime libc __ntp_gettime 00000000 U _catopen libc msgcat 00000000 U _catgets libc msgcat 00000000 U _catclose libc msgcat 00000000 U _MCGetSet libc msgcat 00000000 U _MCGetMsg libc msgcat 00000000 T _realpath libc realpath ./libc-linux/jump/libc.lite/Makefile100644 1676 334 3674 5537625072 15421 0ustar hjlisl# TOPDIR=../.. include $(TOPDIR)/Makeconfig JUMP_DIR:=$(TOPDIR)/jump/libc.lite JUMP_PARAMS=$(JUMP_DIR)/jump.params SHLIB_NAME:= $(shell awk -F= ' { if ($$1 == "Name") print $$2 }' $(JUMP_PARAMS)) SHLIB_TEXT:= $(shell awk -F= ' { if ($$1 == "Text") print $$2 }' $(JUMP_PARAMS)) SHLIB_DATA:= $(shell awk -F= ' { if ($$1 == "Data") print $$2 }' $(JUMP_PARAMS)) SHLIB_JUMP:= $(shell awk -F= ' { if ($$1 == "Jump") print $$2 }' $(JUMP_PARAMS)) SHLIB_GOT:= $(shell awk -F= ' { if ($$1 == "GOT") print $$2 }' $(JUMP_PARAMS)) SHLIB_VERSION:= $(shell awk -F= ' { if ($$1 == "Version") print $$2 }' $(JUMP_PARAMS)) SHLIB_VERSION_MAJOR:=$(shell awk -F= ' { \ if ($$1 == "Version") { \ for (i = 1; i <= length ($$2); i++) { \ if (substr ($$2, i, 1) == ".") { \ print substr ($$2, 1, i - 1); break; \ } } } } ' $(JUMP_PARAMS)) SHLIB_FILE:=$(basename $(SHLIB_NAME)).so.$(SHLIB_VERSION) SHLIB_FILE_MAJOR:=$(basename $(SHLIB_NAME)).so.$(SHLIB_VERSION_MAJOR) SYSLIBS:= $(SHARED_DIR)/libgcc/libgcc3.a \ $(SHARED_DIR)/libcompat/libcompat.a $(TOPDIR)/libalias.a STUBNAMES=libc libtermcap STUBLIBS:= $(foreach lib, $(STUBNAMES), $(lib).sa) SHLIBS:= $(foreach lib, $(STUBNAMES), $(lib).a) all lib: (cd $(TOPDIR); for l in *.a; do \ $(AR) -d $$l __.SYMDEF; \ $(REALRANLIB) $$l; done) ($(AR) -d $(SHARED_DIR)/libcompat/libcompat.a __.SYMDEF; \ $(REALRANLIB) $(SHARED_DIR)/libcompat/libcompat.a; ) (cd $(SHARED_DIR); for l in *.a; do \ $(AR) -d $$l __.SYMDEF; \ $(REALRANLIB) $$l; done) $(MKIMAGE) -l $(SHLIB_NAME) -v $(SHLIB_VERSION) -a $(SHLIB_TEXT) \ -d $(SHLIB_DATA) -j $(SHLIB_JUMP) -g $(SHLIB_GOT) \ -- $(SHLIBS:%=$(SHARED_DIR)/%) $(SYSLIBS) mv $(SHLIB_FILE) lib.so # do this trick for stupid fs $(STRIP) lib.so mv lib.so $(SHLIB_FILE) realclean clean: $(RM) -f core *.o *.s *.sa *.so.* *.a verify.out *.log install: if [ ! -d $(TARGET_SO_DIR) ]; then \ $(MKDIR) $(TARGET_SO_DIR); \ else true; fi cp $(SHLIB_FILE) $(TARGET_SO_DIR) ./libc-linux/jump/libc/ 40755 1676 334 0 5550065621 12707 5ustar hjlisl./libc-linux/jump/libc/jump.params100644 1676 334 130 5550056265 15142 0ustar hjlislName=libc Text=0x60000000 Data=0x60090000 Jump=0x00004000 GOT=0x00001000 Version=4.5.26 ./libc-linux/jump/libc/jump.params.build100644 1676 334 130 5536421760 16240 0ustar hjlislName=libc Text=0x60000000 Data=0x60090000 Jump=0x00004000 GOT=0x00001000 Version=4.5.23 ./libc-linux/jump/libc/jump.funcs100644 1676 334 164231 5545077502 15073 0ustar hjlisl00000000 T ___siggetmask libc __siggtmsk 00000000 T ___sigsetmask libc __sigstmsk 00000000 t ___builtin_delete libgcc _op_delete 00000000 t ___builtin_new libgcc _op_new 00000000 U ___builtin_vec_delete libgcc _builtin_del 00000000 U ___builtin_vec_new libgcc _caps_New 00000000 t ___eprintf libgcc _eprintf 00000000 U ___fillbf libc emulate 00000000 U ___flshfp libc emulate 00000000 U __free_internal libc free 00000000 t _____old_getdtablesize libcompat __old_gdtbsz 00000000 T ___getpagesize libc __getpgsz 00000000 T ___grpalloc libc grpread 00000000 T ___grpopen libc grpopen 00000000 T ___grpread libc grpread 00000000 T ___initstate libc __random 00000000 T ___longjmp libc __longjmp 00000000 T ___overflow libc genos 00000000 T ___pwdalloc libc pwdread 00000000 T ___pwdopen libc pwdopen 00000000 T ___pwdread libc pwdread 00000000 T ___random libc __random 00000000 t ___set_new_handler libgcc _new_handler 00000000 T ___setjmp libc __setjmp 00000000 T ___setstate libc __random 00000000 T ___sigblock libc __sigblock 00000000 T ___sigpause libc __sigpause 00000000 T ___srandom libc __random 00000000 T ___underflow libc genos 00000000 T __IO_flush_all libc genos 00000000 T __exit libc libc_exit 00000000 U __filbuf libc emulate 00000000 U __flsbuf libc emulate 00000000 T __getlong libc res_comp 00000000 T __getopt_internal libc getopt 00000000 T __getshort libc res_comp 00000000 t ___longjmp libcompat 00000000 T __pututline libc utmp2 00000000 t ___setjmp libcompat 00000000 T __tolower libc ctype-extn 00000000 T __toupper libc ctype-extn 00000000 T _abort libc abort 00000000 t _labs libcompat 00000000 T _accept libc accept 00000000 T ___access libc __access 00000000 T _acct libc acct 00000000 T _addmntent libc mntent 00000000 T _alarm libc alarm 00000000 T _alphasort libc alphasort 00000000 T _asctime libc bsdtime 00000000 T _atexit libc atexit 00000000 T _atof libc atof 00000000 T _atoi libc atoi 00000000 T _atol libc atol 00000000 T _bcmp libc bcmp 00000000 T _bcopy libc bcopy 00000000 T _bind libc bind 00000000 T _box libcurses box 00000000 T ___brk libc __brk 00000000 T _bsearch libc bsearch 00000000 T _bzero libc bzero 00000000 T _calloc libc calloc 00000000 T _cfgetispeed libc cfsetget 00000000 T _cfgetospeed libc cfsetget 00000000 t _free libcompat 00000000 T _cfsetispeed libc cfsetget 00000000 T _cfsetospeed libc cfsetget 00000000 T ___chdir libc __chdir 00000000 T ___chmod libc __chmod 00000000 T ___chown libc __chown 00000000 T _chroot libc chroot 00000000 T _clearerr libc clearerr 00000000 T _clock libc clock 00000000 T ___close libc __close 00000000 T _closedir libc closedir 00000000 T _confstr libc confstr 00000000 T _connect libc connect 00000000 T _creat libc creat 00000000 T _crypt libc crypt_util 00000000 T _ctermid libc ctermid 00000000 T _ctime libc bsdtime 00000000 T _cuserid libc cuserid 00000000 T _dbm_close libdbm dbmclose 00000000 T _dbm_delete libdbm dbmdelete 00000000 T _dbm_dirfno libdbm dbmdirfno 00000000 T _dbm_fetch libdbm dbmfetch 00000000 T _dbm_firstkey libdbm dbmseq 00000000 T _dbm_nextkey libdbm dbmseq 00000000 T _dbm_open libdbm dbmopen 00000000 T _dbm_pagfno libdbm dbmpagfno 00000000 T _dbm_store libdbm dbmstore 00000000 T _dbminit libdbm dbminit 00000000 T _delete libdbm delete 00000000 T _delwin libcurses delwin 00000000 T _difftime libc difftime 00000000 t _ldiv libcompat 00000000 T _dn_comp libc res_comp 00000000 T _dn_expand libc res_comp 00000000 T _dn_skipname libc res_comp 00000000 T _drand48 libc drand48 00000000 T __IO_dtoa libc floatconv 00000000 T ___dup libc __dup 00000000 T ___dup2 libc __dup2 00000000 T _ecvt libc cvt 00000000 T _encrypt libc crypt_util 00000000 T _endgrent libc getgrent 00000000 T _endhostent libc sethostent 00000000 T _endmntent libc mntent 00000000 T _endnetent libc getnetent 00000000 T _endprotoent libc getprtent 00000000 T _endpwent libc getpwent 00000000 T _endservent libc getservent 00000000 T _endutent libc utmp2 00000000 T _endwin libcurses endwin 00000000 T _erand48 libc drand48 00000000 T _execl libc execl 00000000 T _execle libc execle 00000000 T _execlp libc execlp 00000000 T _execv libc execv 00000000 T ___execve libc __execve 00000000 T _execvp libc execvp 00000000 T _exit libc exit 00000000 T ___fchmod libc __fchmod 00000000 T ___fchown libc __fchown 00000000 T __IO_fclose libc iofclose 00000000 T ___fcntl libc __fcntl 00000000 T _fcvt libc cvt 00000000 T __IO_fdopen libc iofdopen 00000000 T _feof libc feof 00000000 T _ferror libc ferror 00000000 T _fetch libdbm fetch 00000000 T __IO_fflush libc iofflush 00000000 T _ffs libc ffs 00000000 T _fgetc libc fgetc 00000000 T _fgetgrent libc fgetgrent 00000000 T __IO_fgetpos libc iofgetpos 00000000 T _fgetpwent libc fgetpwent 00000000 T __IO_fgets libc iofgets 00000000 T _fileno libc fileno 00000000 T _firstkey libdbm seq 00000000 T _fnmatch libc fnmatch 00000000 T __IO_fopen libc iofopen 00000000 T ___fork libc __fork 00000000 T ___fpathconf libc __fpathconf 00000000 T __IO_fprintf libc iofprintf 00000000 T _fputc libc fputc 00000000 T __IO_fputs libc iofputs 00000000 T __IO_fread libc iofread 00000000 T _free libc free 00000000 T _freopen libc freopen 00000000 T __IO_fscanf libc iofscanf 00000000 T _fseek libc fseek 00000000 T __IO_fsetpos libc iofsetpos 00000000 T ___fstat libc __fstat 00000000 T ___fstatfs libc __fstatfs 00000000 T __IO_ftell libc ioftell 00000000 T _ftime libc ftime 00000000 T _ftruncate libc ftruncate 00000000 T _ftw libc ftw 00000000 T __IO_fwrite libc iofwrite 00000000 T _gcvt libc gcvt 00000000 T _gdbm_close libdbm gdbmclose 00000000 T _gdbm_delete libdbm gdbmdelete 00000000 T _gdbm_fetch libdbm gdbmfetch 00000000 T _gdbm_firstkey libdbm gdbmseq 00000000 T _gdbm_nextkey libdbm gdbmseq 00000000 T _gdbm_open libdbm gdbmopen 00000000 T _gdbm_reorganize libdbm gdbmreorg 00000000 T _gdbm_store libdbm gdbmstore 00000000 T _getc libc getc 00000000 T _getcap libcurses cr_tty 00000000 T _getchar libc getchar 00000000 T _getcwd libc getcwd 00000000 t _____old_getdtablesize libcompat __old_gdtbsz 00000000 T ___getegid libc __getegid 00000000 T _getenv libc getenv 00000000 T ___geteuid libc __geteuid 00000000 T ___getgid libc __getgid 00000000 T _getgrent libc getgrent 00000000 T _getgrgid libc getgrgid 00000000 T _getgrnam libc getgrnam 00000000 T ___getgroups libc __getgrps 00000000 T _gethostbyaddr libc gethstnmad 00000000 T _gethostbyname libc gethstnmad 00000000 T ___old__gethostname libcompat __old__ghn 00000000 T ___getitimer libc __getitmr 00000000 T _getlogin libc getlogin 00000000 T _getmntent libc mntent 00000000 T _getnetbyaddr libc getnetbyad 00000000 T _getnetbyname libc getnetbynm 00000000 T _getnetent libc getnetent 00000000 T _getopt libc getopt 00000000 T _getopt_long libc getopt1 00000000 T _getopt_long_only libc getopt1 00000000 t ___getpagesize libcompat 00000000 T _getpass libc getpass 00000000 T _getpeername libc getpeernam 00000000 T _getpgrp libc getpgrp 00000000 T ___getpid libc __getpid 00000000 T ___getppid libc __getppid 00000000 T _getpriority libc getprio 00000000 T _getprotobyname libc getprtname 00000000 T _getprotobynumber libc getproto 00000000 T _getprotoent libc getprtent 00000000 T _getpw libc getpw 00000000 T _getpwent libc getpwent 00000000 T _getpwnam libc getpwnam 00000000 T _getpwuid libc getpwuid 00000000 T _getrlimit libc getrlimit 00000000 T ___getrusage libc __getrusag 00000000 T __IO_gets libc iogets 00000000 T _getservbyname libc getsrvbynm 00000000 T _getservbyport libc getsrvbypt 00000000 T _getservent libc getservent 00000000 T _getsockname libc getsocknam 00000000 T _getsockopt libc getsockopt 00000000 T ___gettimeofday libc __gettod 00000000 T _gettmode libcurses cr_tty 00000000 T ___getuid libc __getuid 00000000 T _getutent libc utmp2 00000000 T _getutid libc utmp2 00000000 T _getutline libc utmp2 00000000 T _getw libc getw 00000000 T _getwd libc getwd 00000000 t ___old_glob libcompat __old_glob 00000000 t ___old_globfree libcompat __old_glob 00000000 T _gmtime libc bsdtime 00000000 T _hasmntopt libc mntent 00000000 T _herror libc herror 00000000 T _htonl libc hton 00000000 T _htons libc hton 00000000 T _idlok libcurses idlok 00000000 t _strchr libcompat 00000000 T _inet_addr libc inet_addr 00000000 T _inet_lnaof libc inet_lnaof 00000000 T _inet_makeaddr libc inet_mkadr 00000000 T _inet_netof libc inet_netof 00000000 T _inet_network libc inet_net 00000000 T _inet_ntoa libc inet_ntoa 00000000 T _initgroups libc initgroups 00000000 T _initscr libcurses initscr 00000000 t ___initstate libcompat 00000000 T ___ioctl libc __ioctl 00000000 T _ioperm libc ioperm 00000000 T _iopl libc iopl 00000000 T _isalnum libc ctype 00000000 T _isalpha libc ctype 00000000 T _isascii libc ctype-extn 00000000 T ___isatty libc __isatty 00000000 T _isblank libc ctype-extn 00000000 T _iscntrl libc ctype 00000000 T _isdigit libc ctype 00000000 T _isgraph libc ctype 00000000 T _islower libc ctype 00000000 T _isprint libc ctype 00000000 T _ispunct libc ctype 00000000 T _isspace libc ctype 00000000 T _isupper libc ctype 00000000 T _isxdigit libc ctype 00000000 T _jrand48 libc drand48 00000000 T ___kill libc __kill 00000000 T _killpg libc killpg 00000000 T _labs libc labs 00000000 T _lcong48 libc drand48 00000000 T _ldexp libc ldexp 00000000 T _ldiv libc ldiv 00000000 T ___link libc __link 00000000 T _listen libc listen 00000000 T _localtime libc bsdtime 00000000 t ___longjmp libcompat 00000000 T _longname libcurses longname 00000000 T _lrand48 libc drand48 00000000 T ___lseek libc __lseek 00000000 T ___lstat libc __lstat 00000000 T _malloc libc malloc 00000000 T _mblen libc mblen 00000000 T _mbstowcs libc mbstowcs 00000000 T _mbtowc libc mbtowc 00000000 U _memalign libc memalign 00000000 T ___memccpy libc __memccpy 00000000 T _memchr libc memchr 00000000 T _memcmp libc memcmp 00000000 T _memcpy libc memcpy 00000000 T _memmove libc memmove 00000000 T _memset libc memset 00000000 T ___mkdir libc __mkdir 00000000 T _mkfifo libc mkfifo 00000000 T ___mknod libc __mknod 00000000 T _mktemp libc mktemp 00000000 T _mktime libc bsdtime 00000000 T _mmap libc mmap 00000000 T _modf libc modf 00000000 T _mount libc mount 00000000 T _mrand48 libc drand48 00000000 T _munmap libc munmap 00000000 T _mvcur libcurses cr_put 00000000 T _mvprintw libcurses mvprintw 00000000 T _mvscanw libcurses mvscanw 00000000 T _mvwin libcurses mvwin 00000000 T _mvwprintw libcurses mvprintw 00000000 T _mvwscanw libcurses mvscanw 00000000 T _newwin libcurses newwin 00000000 T _nextkey libdbm seq 00000000 T _nice libc nice 00000000 T _nrand48 libc drand48 00000000 t _htonl libcompat 00000000 t _htons libcompat 00000000 T _on_exit libc on_exit 00000000 T ___open libc __open 00000000 T _opendir libc opendir 00000000 T _overlay libcurses overlay 00000000 T _overwrite libcurses overwrite 00000000 T _p_type libc res_debug 00000000 T ___pathconf libc __pathconf 00000000 T _pause libc pause 00000000 T _pclose libc popen 00000000 T __IO_perror libc ioperror 00000000 T ___pipe libc __pipe 00000000 T __IO_popen libc iopopen 00000000 T __IO_printf libc ioprintf 00000000 T _printw libcurses printw 00000000 T _psignal libc psignal 00000000 T _ptrace libc ptrace 00000000 T _putc libc putc 00000000 T _putchar libc putchar 00000000 T _putenv libc putenv 00000000 T _putlong libc res_comp 00000000 T _putpwent libc putpwent 00000000 T __IO_puts libc ioputs 00000000 T _putshort libc res_comp 00000000 T _pututline libc utmp2 00000000 T _putw libc putw 00000000 T _qsort libc qsort 00000000 T _raise libc raise 00000000 T _rand libc rand 00000000 t ___random libcompat 00000000 T _rcmd libc rcmd 00000000 T _re_comp libc regex 00000000 T _re_compile_fastmap libc regex 00000000 T _re_compile_pattern libc regex 00000000 T _re_exec libc regex 00000000 T _re_match libc regex 00000000 T _re_match_2 libc regex 00000000 T _re_search libc regex 00000000 T _re_search_2 libc regex 00000000 T _re_set_syntax libc regex 00000000 T ___read libc __read 00000000 T _readdir libc readdir 00000000 T ___readlink libc __readlink 00000000 T _readv libc readv 00000000 T _realloc libc realloc 00000000 T _reboot libc reboot 00000000 T _recv libc recv 00000000 T _recvfrom libc recvfrom 00000000 T _regcomp libc regex 00000000 T _regerror libc regex 00000000 T _regexec libc regex 00000000 T _regfree libc regex 00000000 t ___unlink libcompat 00000000 T _rename libc rename 00000000 T _res_init libc res_init 00000000 T _res_mkquery libc res_mkqry 00000000 T _res_query libc res_query 00000000 T _res_querydomain libc res_query 00000000 T _res_search libc res_query 00000000 T _res_send libc res_send 00000000 T _rewind libc rewind 00000000 T _rewinddir libc rewinddir 00000000 T _rexec libc rexec 00000000 t _strrchr libcompat 00000000 T ___rmdir libc __rmdir 00000000 T _rresvport libc rcmd 00000000 T _ruserok libc rcmd 00000000 T _ruserpass libc ruserpass 00000000 T ___sbrk libc __sbrk 00000000 T _scandir libc scandir 00000000 T __IO_scanf libc ioscanf 00000000 T _scanw libcurses scanw 00000000 T _scroll libcurses scroll 00000000 T _seed48 libc drand48 00000000 T _seekdir libc seekdir 00000000 t ___old_select libcompat __old_sel 00000000 T _send libc send 00000000 T _sendto libc sendto 00000000 t _set_new_handler libgcc _new_handler 00000000 T _setbuf libc setbuf 00000000 T __IO_setbuffer libc iosetbuffer 00000000 T _setenv libc setenv 00000000 T _setfileno libc setfileno 00000000 T ___setgid libc __setgid 00000000 T _setgrent libc getgrent 00000000 T _setgroups libc setgroups 00000000 T _sethostent libc sethostent 00000000 T _sethostname libc sethstnm 00000000 T ___setitimer libc __setitmr 00000000 T _setkey libc crypt_util 00000000 T _setlinebuf libc setlinebuf 00000000 T _setlocale libc setlocale 00000000 t __IO_fopen libcompat 00000000 T _setnetent libc getnetent 00000000 T _setpgid libc setpgid 00000000 T _setpgrp libc setpgrp 00000000 T _setpriority libc setprio 00000000 T _setprotoent libc getprtent 00000000 T _setpwent libc getpwent 00000000 T ___setregid libc __setregid 00000000 T ___setreuid libc __setreuid 00000000 T _setrlimit libc setrlimit 00000000 T _setservent libc getservent 00000000 T ___setsid libc __setsid 00000000 T _setsockopt libc setsockopt 00000000 t ___setstate libcompat 00000000 T _setterm libcurses cr_tty 00000000 T ___settimeofday libc __settod 00000000 T ___setuid libc __setuid 00000000 T _setutent libc utmp2 00000000 T __IO_setvbuf libc iosetvbuf 00000000 T _shutdown libc shutdown 00000000 T ___sigaction libc __sigact 00000000 T _sigaddset libc sigaddset 00000000 t ___sigblock libcompat 00000000 T _sigdelset libc sigdelset 00000000 T _sigemptyset libc sigempty 00000000 T _sigfillset libc sigfillset 00000000 t ___siggetmask libcompat 00000000 T _sigismember libc sigismem 00000000 T _siglongjmp libc siglongjmp 00000000 T _signal libc signal 00000000 t ___sigpause libcompat 00000000 T _sigpending libc sigpending 00000000 T ___sigprocmask libc __sigproc 00000000 T ___old_sigsetjmp libcompat __old_sigsj 00000000 t ___sigsetmask libcompat 00000000 T _sigsuspend libc sigsuspend 00000000 T _sleep libc sleep 00000000 T _socket libc socket 00000000 T _socketpair libc socketpair 00000000 T __IO_sprintf libc iosprintf 00000000 t ___srandom libcompat 00000000 T _srand48 libc drand48 00000000 t ___srandom libcompat 00000000 T __IO_sscanf libc iosscanf 00000000 T ___stat libc __stat 00000000 T ___statfs libc __statfs 00000000 T _stime libc stime 00000000 T _store libdbm store 00000000 T _strcasecmp libc strcasecmp 00000000 T _strcat libc strcat 00000000 T _strchr libc strchr 00000000 T _strcmp libc strcmp 00000000 T _strcoll libc strcoll 00000000 T _strcpy libc strcpy 00000000 T _strcspn libc strcspn 00000000 T _strdup libc strdup 00000000 T _strerror libc strerror 00000000 T _strftime libc strftime 00000000 T _strlen libc strlen 00000000 T _strncasecmp libc strncscmp 00000000 T _strncat libc strncat 00000000 T _strncmp libc strncmp 00000000 T _strncpy libc strncpy 00000000 T _strpbrk libc strpbrk 00000000 T _strrchr libc strrchr 00000000 T _strsignal libc strsignal 00000000 T _strspn libc strspn 00000000 T _strstr libc strstr 00000000 T __IO_strtod libc floatconv 00000000 T _strtok libc strtok 00000000 T _strtol libc strtol 00000000 T _strtoul libc strtoul 00000000 T _strxfrm libc strxfrm 00000000 T _subwin libcurses newwin 00000000 T _swab libc swab 00000000 T _swapon libc swapon 00000000 T ___symlink libc __symlink 00000000 T _sync libc sync 00000000 T ___sysconf libc __sysconf 00000000 T _system libc system 00000000 T _tcdrain libc tcdrain 00000000 T _tcflow libc tcflow 00000000 T _tcflush libc tcflush 00000000 T ___tcgetattr libc __tcgetatr 00000000 T _tcgetpgrp libc tcgetpgrp 00000000 T _tcsendbreak libc tcsendbrk 00000000 T _tcsetattr libc tcsetattr 00000000 T _tcsetpgrp libc tcsetpgrp 00000000 T _tell libc tell 00000000 T _telldir libc telldir 00000000 T _tempnam libc tempnam 00000000 T _tgetent libtermcap termcap 00000000 T _tgetflag libtermcap termcap 00000000 T _tgetnum libtermcap termcap 00000000 T _tgetstr libtermcap termcap 00000000 T _tgoto libtermcap tparam 00000000 T _time libc time 00000000 T ___times libc __times 00000000 T _tmpfile libc tmpfile 00000000 T _tmpnam libc tmpnam 00000000 T _toascii libc ctype-extn 00000000 T _tolower libc ctype 00000000 T _touchline libcurses touchwin 00000000 T _touchwin libcurses touchwin 00000000 T _toupper libc ctype 00000000 T _tparam libtermcap tparam 00000000 T _tputs libtermcap termcap 00000000 T _truncate libc truncate 00000000 T _ttyname libc ttyname 00000000 T _tzset libc bsdtime 00000000 T _ulimit libc ulimit 00000000 T ___umask libc __umask 00000000 T _umount libc umount 00000000 T ___old__uname libcompat __old__uname 00000000 T __IO_ungetc libc ioungetc 00000000 T ___unlink libc __unlink 00000000 T _unsetenv libc setenv 00000000 T _uselib libc uselib 00000000 T _usleep libc usleep 00000000 T _ustat libc ustat 00000000 T _utime libc utime 00000000 T _utmpname libc utmp2 00000000 T _valloc libc valloc 00000000 t ___fork libcompat 00000000 T __IO_vfprintf libc iovfprintf 00000000 T _vfscanf libc vfscanf 00000000 T _vhangup libc vhangup 00000000 T _vprintf libc vprintf 00000000 T _vscanf libc vscanf 00000000 T __IO_vsprintf libc iovsprintf 00000000 T __IO_vsscanf libc iovsscanf 00000000 T _waddbytes libcurses addbytes 00000000 T _waddch libcurses addch 00000000 T _waddstr libcurses addstr 00000000 T ___wait libc __wait 00000000 T ___wait3 libc __wait3 00000000 T ___wait4 libc __wait4 00000000 T ___waitpid libc __waitpid 00000000 T _wclear libcurses clear 00000000 T _wclrtobot libcurses clrtobot 00000000 T _wclrtoeol libcurses clrtoeol 00000000 T _wcstombs libc wcstombs 00000000 T _wctomb libc wctomb 00000000 T _wdelch libcurses delch 00000000 T _wdeleteln libcurses deleteln 00000000 T _werase libcurses erase 00000000 T _wgetch libcurses getch 00000000 T _wgetstr libcurses getstr 00000000 T _winsch libcurses insch 00000000 T _winsertln libcurses insertln 00000000 T _wmove libcurses move 00000000 T _wprintw libcurses printw 00000000 T _wrefresh libcurses refresh 00000000 T ___write libc __write 00000000 T _writev libc writev 00000000 T _wscanw libcurses scanw 00000000 T _wstandend libcurses standout 00000000 T _wstandout libcurses standout 00000000 U _mcheck libc mcheck 00000000 U _mtrace libc mtrace 00000000 U _mstats libc mstats 00000000 T _swapoff libc swapoff 00000000 T _vm86 libc vm86 00000000 T ___flock libc __flock 00000000 T _fp_query libc res_debug 00000000 T _hostalias libc res_query 00000000 T ___new_exitfn libc atexit 00000000 T _p_class libc res_debug 00000000 T _p_time libc res_debug 00000000 T ___utimes libc __utimes 00000000 T __quicksort libc _quicksort 00000000 T _bindresvport libc bindresvport 00000000 T _cfmakeraw libc cfmakeraw 00000000 T _endusershell libc getusersh 00000000 T _fcrypt libc crypt_util 00000000 T _get_current_dir_name libc getdirname 00000000 T _getusershell libc getusersh 00000000 T _idle libc idle 00000000 T _init_des libc crypt_util 00000000 T _insque libc insremque 00000000 T _localeconv libc localeconv 00000000 T _memfrob libc memfrob 00000000 T _memmem libc memmem 00000000 T _mkstemp libc mkstemp 00000000 T _nlist libc nlist 00000000 T _re_set_registers libc regex 00000000 T _remque libc insremque 00000000 T _setegid libc setegid 00000000 T _seteuid libc seteuid 00000000 T _setusershell libc getusersh 00000000 T _strfry libc strfry 00000000 T _strsep libc strsep 00000000 T _syscall libc syscall 00000000 T __authenticate libc svc_auth 00000000 T __rpc_dtablesize libc rpc_dtblsz 00000000 T __seterr_reply libc rpc_prot 00000000 T __svcauth_null libc svc_auth 00000000 T __svcauth_short libc svc_au_ux 00000000 T __svcauth_unix libc svc_au_ux 00000000 T _authnone_create libc auth_none 00000000 T _authunix_create libc auth_unix 00000000 T _authunix_create_default libc auth_unix 00000000 T _callrpc libc clnt_simple 00000000 T _clnt_broadcast libc pmap_rmt 00000000 T _clnt_create libc clnt_generic 00000000 T _clnt_pcreateerror libc clnt_perror 00000000 T _clnt_perrno libc clnt_perror 00000000 T _clnt_perror libc clnt_perror 00000000 T _clnt_spcreateerror libc clnt_perror 00000000 T _clnt_sperrno libc clnt_perror 00000000 T _clnt_sperror libc clnt_perror 00000000 T _clntraw_create libc clnt_raw 00000000 T _clnttcp_create libc clnt_tcp 00000000 T _clntudp_bufcreate libc clnt_udp 00000000 T _clntudp_create libc clnt_udp 00000000 T _endrpcent libc getrpcent 00000000 T _get_myaddress libc get_myaddr 00000000 T _getrpcbyname libc getrpcent 00000000 T _getrpcbynumber libc getrpcent 00000000 T _getrpcent libc getrpcent 00000000 T _getrpcport libc getrpcport 00000000 T _pmap_getmaps libc pmap_getmaps 00000000 T _pmap_getport libc pmap_getport 00000000 T _pmap_rmtcall libc pmap_rmt 00000000 T _pmap_set libc pmap_clnt 00000000 T _pmap_unset libc pmap_clnt 00000000 T _registerrpc libc svc_simple 00000000 T _setrpcent libc getrpcent 00000000 T _svc_getreq libc svc 00000000 T _svc_getreqset libc svc 00000000 T _svc_register libc svc 00000000 T _svc_run libc svc_run 00000000 T _svc_sendreply libc svc 00000000 T _svc_unregister libc svc 00000000 T _svcerr_auth libc svc 00000000 T _svcerr_decode libc svc 00000000 T _svcerr_noproc libc svc 00000000 T _svcerr_noprog libc svc 00000000 T _svcerr_progvers libc svc 00000000 T _svcerr_systemerr libc svc 00000000 T _svcerr_weakauth libc svc 00000000 T _svcfd_create libc svc_tcp 00000000 T _svcraw_create libc svc_raw 00000000 T _svctcp_create libc svc_tcp 00000000 T _svcudp_bufcreate libc svc_udp 00000000 T _svcudp_create libc svc_udp 00000000 T _svcudp_enablecache libc svc_udp 00000000 T _xdr_accepted_reply libc rpc_prot 00000000 T _xdr_array libc xdr_array 00000000 T _xdr_authunix_parms libc auth_prot 00000000 T _xdr_bool libc xdr 00000000 T _xdr_bytes libc xdr 00000000 T _xdr_callhdr libc rpc_prot 00000000 T _xdr_callmsg libc rpc_callmsg 00000000 T _xdr_char libc xdr 00000000 T _xdr_des_block libc rpc_prot 00000000 T _xdr_double libc xdr_float 00000000 T _xdr_enum libc xdr 00000000 T _xdr_float libc xdr_float 00000000 T _xdr_free libc xdr 00000000 T _xdr_int libc xdr 00000000 T _xdr_long libc xdr 00000000 T _xdr_netobj libc xdr 00000000 T _xdr_opaque libc xdr 00000000 T _xdr_opaque_auth libc rpc_prot 00000000 T _xdr_pmap libc pmap_prot 00000000 T _xdr_pmaplist libc pmap_prot2 00000000 T _xdr_pointer libc xdr_ref 00000000 T _xdr_reference libc xdr_ref 00000000 T _xdr_rejected_reply libc rpc_prot 00000000 T _xdr_replymsg libc rpc_prot 00000000 T _xdr_rmtcall_args libc pmap_rmt 00000000 T _xdr_rmtcallres libc pmap_rmt 00000000 T _xdr_short libc xdr 00000000 T _xdr_string libc xdr 00000000 T _xdr_u_char libc xdr 00000000 T _xdr_u_int libc xdr 00000000 T _xdr_u_long libc xdr 00000000 T _xdr_u_short libc xdr 00000000 T _xdr_union libc xdr 00000000 T _xdr_vector libc xdr_array 00000000 T _xdr_void libc xdr 00000000 T _xdr_wrapstring libc xdr 00000000 T _xdrmem_create libc xdr_mem 00000000 T _xdrrec_create libc xdr_rec 00000000 T _xdrrec_endofrecord libc xdr_rec 00000000 T _xdrrec_eof libc xdr_rec 00000000 T _xdrrec_skiprecord libc xdr_rec 00000000 T _xdrstdio_create libc xdr_stdio 00000000 T _xprt_register libc svc 00000000 T _xprt_unregister libc svc 00000000 T _glob libc glob 00000000 T _globfree libc glob 00000000 T _closelog libc syslog 00000000 T _openlog libc syslog 00000000 T _setlogmask libc syslog 00000000 T _syslog libc syslog 00000000 T _vsyslog libc syslog 00000000 T ___select libc __select 00000000 T ___getdtablesize libc __getdtsz 00000000 U ___muldi3 libgcc _muldi3 00000000 U ___udivdi3 libgcc _udivdi3 00000000 U ___udivmoddi4 libgcc _udivmoddi4 00000000 U ___umoddi3 libgcc _umoddi3 00000000 U ___stdio_gen_tempname libc tempname 00000000 T __IO_adjust_column libc genos 00000000 T __IO_default_doallocate libc genos 00000000 T __IO_default_finish libc genos 00000000 T __IO_default_pbackfail libc genos 00000000 T __IO_default_read libc genos 00000000 T __IO_default_seek libc genos 00000000 T __IO_default_seekoff libc genos 00000000 T __IO_default_seekpos libc genos 00000000 T __IO_default_setbuf libc genos 00000000 T __IO_default_stat libc genos 00000000 T __IO_default_write libc genos 00000000 T __IO_default_xsgetn libc genos 00000000 T __IO_default_xsputn libc genos 00000000 T __IO_do_write libc fileops 00000000 T __IO_doallocbuf libc genos 00000000 T __IO_file_attach libc fileops 00000000 T __IO_file_close libc fileops 00000000 T __IO_file_doallocate libc filedoalloc 00000000 T __IO_file_finish libc fileops 00000000 T __IO_file_fopen libc fileops 00000000 T __IO_file_init libc fileops 00000000 T __IO_file_overflow libc fileops 00000000 T __IO_file_read libc fileops 00000000 T __IO_file_seek libc fileops 00000000 T __IO_file_seekoff libc fileops 00000000 T __IO_file_setbuf libc fileops 00000000 T __IO_file_stat libc fileops 00000000 T __IO_file_sync libc fileops 00000000 T __IO_file_underflow libc fileops 00000000 T __IO_file_write libc fileops 00000000 T __IO_file_xsputn libc fileops 00000000 T __IO_flush_all_linebuffered libc genos 00000000 T __IO_free_backup_area libc genos 00000000 T __IO_get_column libc genos 00000000 T __IO_getline libc iogetline 00000000 T __IO_ignore libc ioignore 00000000 T __IO_init libc genos 00000000 T __IO_init_marker libc genos 00000000 T __IO_least_marker libc genos 00000000 T __IO_link_in libc genos 00000000 T __IO_marker_delta libc genos 00000000 T __IO_marker_difference libc genos 00000000 T __IO_nobackup_pbackfail libc genos 00000000 T __IO_outfloat libc outfloat 00000000 T __IO_padn libc iopadn 00000000 T __IO_proc_close libc iopopen 00000000 T __IO_proc_open libc iopopen 00000000 T __IO_remove_marker libc genos 00000000 T __IO_seekmark libc genos 00000000 T __IO_seekoff libc ioseekoff 00000000 T __IO_seekpos libc ioseekpos 00000000 T __IO_set_column libc genos 00000000 T __IO_setb libc genos 00000000 T __IO_sgetn libc genos 00000000 T __IO_sputbackc libc genos 00000000 T __IO_str_count libc strops 00000000 T __IO_str_finish libc strops 00000000 T __IO_str_init_readonly libc strops 00000000 T __IO_str_init_static libc strops 00000000 T __IO_str_overflow libc strops 00000000 T __IO_str_pbackfail libc strops 00000000 T __IO_str_seekoff libc strops 00000000 T __IO_str_underflow libc strops 00000000 T __IO_sungetc libc genos 00000000 T __IO_switch_to_backup_area libc genos 00000000 T __IO_switch_to_get_mode libc genos 00000000 T __IO_switch_to_main_get_area libc genos 00000000 T __IO_sync libc genos 00000000 T __IO_un_link libc genos 00000000 T __IO_unsave_markers libc genos 00000000 T __IO_vfscanf libc iovfscanf 00000000 T __IO_gen_tempname libc iotempname 00000000 U _endspent libc shadow 00000000 U _fgetspent libc shadow 00000000 U _getspent libc shadow 00000000 U _getspnam libc shadow 00000000 U _putspent libc shadow 00000000 U _setspent libc shadow 00000000 U _sgetspent libc shadow 00000000 U _endsgent libc gshadow 00000000 U _fgetsgent libc gshadow 00000000 U _getsgent libc gshadow 00000000 U _getsgnam libc gshadow 00000000 U _putsgent libc gshadow 00000000 U _setsgent libc gshadow 00000000 U _sgetsgent libc gshadow 00000000 T __IO_file_close_it libc fileops 00000000 T __IO_default_underflow libc genos 00000000 T _svc_exit libc svc_run 00000000 U _getpgid libc getpgid 00000000 U _readable__3ios libc streambuf 00000000 U _writable__3ios libc streambuf 00000000 U _is_open__3ios libc streambuf 00000000 U _init_const__12strstreambuf libc strstream 00000000 U ___12strstreambuf libc strstream 00000000 U ___12strstreambufi libc strstream 00000000 U ___12strstreambufPFUi_PvPFPv_v libc strstream 00000000 U ___12strstreambufPciT1 libc strstream 00000000 U ___12strstreambufPUciT1 libc strstream 00000000 U ___12strstreambufPCci libc strstream 00000000 U ___12strstreambufPCUci libc strstream 00000000 U ___12strstreambufPSciT1 libc strstream 00000000 U ___12strstreambufPCSci libc strstream 00000000 U _frozen__12strstreambuf libc strstream 00000000 U _freeze__12strstreambufi libc strstream 00000000 U _rdbuf__13strstreambase libc strstream 00000000 U ___13strstreambasei libc strstream 00000000 U __$_13strstreambase libc strstream 00000000 U __$_10istrstream libc strstream 00000000 U ___10ostrstreamiPcii libc strstream 00000000 U _pcount__10ostrstream libc strstream 00000000 U _str__10ostrstream libc strstream 00000000 U _freeze__10ostrstreami libc strstream 00000000 U _frozen__10ostrstream libc strstream 00000000 U __$_10ostrstream libc strstream 00000000 U ___9strstreami libc strstream 00000000 U ___9strstreamiPcii libc strstream 00000000 U _pcount__9strstream libc strstream 00000000 U _str__9strstream libc strstream 00000000 U _freeze__9strstreami libc strstream 00000000 U _frozen__9strstream libc strstream 00000000 U __$_9strstream libc strstream 00000000 U ___10istrstreamiPCci libc strstream 00000000 U ___10ostrstreami libc strstream 00000000 U ___13strstreambaseiPcii libc strstream 00000000 U _str__12strstreambuf libc strstream 00000000 U _pcount__12strstreambuf libc strstream 00000000 U _overflow__12strstreambufi libc strstream 00000000 U _underflow__12strstreambuf libc strstream 00000000 U _init_dynamic__12strstreambufPFUi_PvPFPv_vi libc strstream 00000000 U _init_static__12strstreambufPciT1 libc strstream 00000000 U __$_12strstreambuf libc strstream 00000000 U _seekoff__12strstreambuflQ23ios8seek_diri libc strstream 00000000 U _pbackfail__12strstreambufi libc strstream 00000000 U _rdbuf__C11fstreambase libc fstream 00000000 U _is_open__C11fstreambase libc fstream 00000000 U _setbuf__11fstreambasePci libc fstream 00000000 U _filedesc__11fstreambase libc fstream 00000000 U _raw__11fstreambase libc fstream 00000000 U __$_11fstreambase libc fstream 00000000 U ___8ifstreami libc fstream 00000000 U ___8ifstreamii libc fstream 00000000 U ___8ifstreamiPCcii libc fstream 00000000 U _open__8ifstreamPCcii libc fstream 00000000 U __$_8ifstream libc fstream 00000000 U ___8ofstreami libc fstream 00000000 U ___8ofstreamii libc fstream 00000000 U ___8ofstreamiPCcii libc fstream 00000000 U _open__8ofstreamPCcii libc fstream 00000000 U __$_8ofstream libc fstream 00000000 U ___7fstreami libc fstream 00000000 U ___7fstreamii libc fstream 00000000 U ___7fstreamiPCcii libc fstream 00000000 U _open__7fstreamPCcii libc fstream 00000000 U __$_7fstream libc fstream 00000000 U ___11fstreambasei libc fstream 00000000 U ___11fstreambaseii libc fstream 00000000 U ___11fstreambaseiPCcii libc fstream 00000000 U _open__11fstreambasePCcii libc fstream 00000000 U _close__11fstreambase libc fstream 00000000 U _getline__7istreamPcic libc igetline 00000000 U _get__7istreamPcic libc igetline 00000000 U _gets__7istreamPPcc libc igetline 00000000 U _get__7istreamR9streambufc libc igetsb 00000000 U ___iomanip_setbase__FR3iosi libc iomanip 00000000 U ___iomanip_setfill__FR3iosi libc iomanip 00000000 U ___iomanip_setprecision__FR3iosi libc iomanip 00000000 U ___iomanip_setw__FR3iosi libc iomanip 00000000 U ___iomanip_setiosflags__FR3iosUl libc iomanip 00000000 U ___iomanip_resetiosflags__FR3iosUl libc iomanip 00000000 U ___7ostreami libc iostream 00000000 U _opfx__7ostream libc iostream 00000000 U _osfx__7ostream libc iostream 00000000 U _ostreambuf__C7ostream libc iostream 00000000 U _put__7ostreamc libc iostream 00000000 U _put__7ostreamUc libc iostream 00000000 U _write__7ostreamPCUci libc iostream 00000000 U _put__7ostreamSc libc iostream 00000000 U _write__7ostreamPCSci libc iostream 00000000 U _write__7ostreamPCvi libc iostream 00000000 U ___ls__7ostreamUc libc iostream 00000000 U ___ls__7ostreamSc libc iostream 00000000 U ___ls__7ostreamPCUc libc iostream 00000000 U ___ls__7ostreamPCSc libc iostream 00000000 U ___ls__7ostreams libc iostream 00000000 U ___ls__7ostreamUs libc iostream 00000000 U ___ls__7ostreamf libc iostream 00000000 U ___ls__7ostreamPFR7ostream_R7ostream libc iostream 00000000 U ___ls__7ostreamPFR3ios_R3ios libc iostream 00000000 U __$_7ostream libc iostream 00000000 U ___7istreami libc iostream 00000000 U _istreambuf__C7istream libc iostream 00000000 U _get__7istreamPUcic libc iostream 00000000 U _get__7istreamRUc libc iostream 00000000 U _getline__7istreamPUcic libc iostream 00000000 U _get__7istreamRSc libc iostream 00000000 U _get__7istreamPScic libc iostream 00000000 U _getline__7istreamPScic libc iostream 00000000 U _read__7istreamPUci libc iostream 00000000 U _read__7istreamPSci libc iostream 00000000 U _read__7istreamPvi libc iostream 00000000 U _ipfx__7istreami libc iostream 00000000 U _ipfx0__7istream libc iostream 00000000 U _ipfx1__7istream libc iostream 00000000 U _get__7istream libc iostream 00000000 U _peek__7istream libc iostream 00000000 U _gcount__7istream libc iostream 00000000 U _putback__7istreamc libc iostream 00000000 U _unget__7istream libc iostream 00000000 U _unget__7istreamc libc iostream 00000000 U ___rs__7istreamPUc libc iostream 00000000 U ___rs__7istreamPSc libc iostream 00000000 U ___rs__7istreamRUc libc iostream 00000000 U ___rs__7istreamRSc libc iostream 00000000 U ___rs__7istreamPFR3ios_R3ios libc iostream 00000000 U ___rs__7istreamPFR7istream_R7istream libc iostream 00000000 U __$_7istream libc iostream 00000000 U ___8iostreami libc iostream 00000000 U __$_8iostream libc iostream 00000000 U _dec__FR3ios libc iostream 00000000 U _hex__FR3ios libc iostream 00000000 U _oct__FR3ios libc iostream 00000000 U ___7istreamiP9streambufP7ostream libc iostream 00000000 U _skip_ws__FP9streambuf libc iostream 00000000 U _get__7istreamRc libc iostream 00000000 U _ignore__7istreamii libc iostream 00000000 U _read__7istreamPci libc iostream 00000000 U _seekg__7istreaml libc iostream 00000000 U _seekg__7istreamlQ23ios8seek_dir libc iostream 00000000 U _tellg__7istream libc iostream 00000000 U _scan__7istreamPCce libc iostream 00000000 U _vscan__7istreamPCcPv libc iostream 00000000 U ___rs__7istreamRc libc iostream 00000000 U ___rs__7istreamPc libc iostream 00000000 U ___rs__7istreamRs libc iostream 00000000 U ___rs__7istreamRUs libc iostream 00000000 U ___rs__7istreamRi libc iostream 00000000 U ___rs__7istreamRUi libc iostream 00000000 U ___rs__7istreamRl libc iostream 00000000 U ___rs__7istreamRUl libc iostream 00000000 U ___rs__7istreamRx libc iostream 00000000 U ___rs__7istreamRUx libc iostream 00000000 U ___rs__7istreamRd libc iostream 00000000 U ___rs__7istreamRf libc iostream 00000000 U ___rs__7istreamP9streambuf libc iostream 00000000 U ___ls__7ostreamc libc iostream 00000000 U ___ls__7ostreami libc iostream 00000000 U ___ls__7ostreamUi libc iostream 00000000 U ___ls__7ostreaml libc iostream 00000000 U ___ls__7ostreamUl libc iostream 00000000 U ___ls__7ostreamx libc iostream 00000000 U ___ls__7ostreamUx libc iostream 00000000 U ___ls__7ostreamd libc iostream 00000000 U ___ls__7ostreamPCc libc iostream 00000000 U ___ls__7ostreamPCv libc iostream 00000000 U ___ls__7ostreamP9streambuf libc iostream 00000000 U ___7ostreamiP9streambufPT0 libc iostream 00000000 U _seekp__7ostreaml libc iostream 00000000 U _seekp__7ostreamlQ23ios8seek_dir libc iostream 00000000 U _tellp__7ostream libc iostream 00000000 U _form__7ostreamPCce libc iostream 00000000 U _vform__7ostreamPCcPv libc iostream 00000000 U _flush__7ostream libc iostream 00000000 U _flush__FR7ostream libc iostream 00000000 U _ws__FR7istream libc iostream 00000000 U __skip_ws__7istream libc iostream 00000000 U _ends__FR7ostream libc iostream 00000000 U _endl__FR7ostream libc iostream 00000000 U _write__7ostreamPCci libc iostream 00000000 U _do_osfx__7ostream libc iostream 00000000 U ___8iostreamiP9streambufP7ostream libc iostream 00000000 U _close__3ios libc iostream 00000000 U _skip__7istreami libc iostream 00000000 U _stdiofile__C8stdiobuf libc stdiostream 00000000 U __$_8stdiobuf libc stdiostream 00000000 U ___8stdiobufP6__FILE libc stdiostream 00000000 U _sys_read__8stdiobufPcUi libc stdiostream 00000000 U _sys_write__8stdiobufPCvl libc stdiostream 00000000 U _sys_seek__8stdiobuflQ23ios8seek_dir libc stdiostream 00000000 U _sys_close__8stdiobuf libc stdiostream 00000000 U _sync__8stdiobuf libc stdiostream 00000000 U _overflow__8stdiobufi libc stdiostream 00000000 U _xsputn__8stdiobufPCci libc stdiostream 00000000 U _sync_with_stdio__3iosi libc stdstreams 00000000 U _form__FPCce libc stream 00000000 U _dec__Fli libc stream 00000000 U _dec__Fii libc stream 00000000 U _dec__FUli libc stream 00000000 U _dec__FUii libc stream 00000000 U _hex__Fli libc stream 00000000 U _hex__Fii libc stream 00000000 U _hex__FUli libc stream 00000000 U _hex__FUii libc stream 00000000 U _oct__Fli libc stream 00000000 U _oct__Fii libc stream 00000000 U _oct__FUli libc stream 00000000 U _oct__FUii libc stream 00000000 T __validuser libc rcmd 00000000 T _fsync libc fsync 00000000 T _siginterrupt libc sigint 00000000 T ___sigjmp_save libc sigjmp 00000000 T __obstack_allocated_p libc obstack 00000000 T __obstack_begin libc obstack 00000000 T __obstack_begin_1 libc obstack 00000000 T __obstack_free libc obstack 00000000 T __obstack_newchunk libc obstack 00000000 T _obstack_free libc obstack 00000000 T ___uname libc __uname 00000000 T _getdomainname libc getdnnm 00000000 T _setdomainname libc setdnnm 00000000 T ___gethostname libc __gethstnm 00000000 T ___bsd_signal libc __bsd_sig 00000000 T _ftok libc ftok 00000000 T _msgctl libc msgctl 00000000 T _msgget libc msgget 00000000 T _msgrcv libc msgrcv 00000000 T _msgsnd libc msgsnd 00000000 T _semctl libc semctl 00000000 T _semget libc semget 00000000 T _semop libc semop 00000000 T _shmat libc shmat 00000000 T _shmctl libc shmctl 00000000 T _shmdt libc shmdt 00000000 T _shmget libc shmget 00000000 T _xdr_domainname libc xdryp 00000000 T _xdr_peername libc xdryp 00000000 T _xdr_datum libc xdryp 00000000 T _xdr_mapname libc xdryp 00000000 T _xdr_ypreq_key libc xdryp 00000000 T _xdr_ypreq_nokey libc xdryp 00000000 T _xdr_yp_inaddr libc xdryp 00000000 T _xdr_ypbind_binding libc xdryp 00000000 T _xdr_ypbind_resptype libc xdryp 00000000 T _xdr_ypstat libc xdryp 00000000 T _xdr_ypbind_resp libc xdryp 00000000 T _xdr_ypresp_val libc xdryp 00000000 T _xdr_ypbind_setdom libc xdryp 00000000 T _xdr_ypresp_key_val libc xdryp 00000000 T _xdr_ypresp_all libc xdryp 00000000 T _xdr_ypresp_all_seq libc xdryp 00000000 T _xdr_ypresp_master libc xdryp 00000000 T _xdr_ypmaplist_str libc xdryp 00000000 T _xdr_ypmaplist libc xdryp 00000000 T _xdr_ypresp_maplist libc xdryp 00000000 T _xdr_ypresp_order libc xdryp 00000000 T _xdr_passwd libc xdryppasswd 00000000 T _xdr_yppasswd libc xdryppasswd 00000000 T _yp_bind libc yplib 00000000 T _yp_unbind libc yplib 00000000 T _yp_match libc yplib 00000000 T _yp_get_default_domain libc yplib 00000000 T _yp_first libc yplib 00000000 T _yp_next libc yplib 00000000 T _yp_all libc yplib 00000000 T _yp_order libc yplib 00000000 T _yp_master libc yplib 00000000 T _yp_maplist libc yplib 00000000 T _yperr_string libc yplib 00000000 T _ypprot_err libc yplib 00000000 T ___yp_check libc yplib 00000000 T _gethostid libc hostid 00000000 T _sethostid libc hostid 00000000 T _mprotect libc mprotect 00000000 T ___adjtime libc __adjtime 00000000 T ___adjtimex libc __adjtimex 00000000 T ___ntp_gettime libc __ntp_gettime 00000000 T _catopen libc msgcat 00000000 T _catgets libc msgcat 00000000 T _catclose libc msgcat 00000000 T _MCGetSet libc msgcat 00000000 T _MCGetMsg libc msgcat 00000000 T _realpath libc realpath ./libc-linux/jump/libc/Makefile100644 1676 334 6510 5540354476 14456 0ustar hjlisl# TOPDIR=../.. include $(TOPDIR)/Makeconfig JUMP_DIR:=$(TOPDIR)/jump/libc JUMP_PARAMS=$(JUMP_DIR)/jump.params SHLIB_NAME:= $(shell awk -F= ' { if ($$1 == "Name") print $$2 }' $(JUMP_PARAMS)) SHLIB_TEXT:= $(shell awk -F= ' { if ($$1 == "Text") print $$2 }' $(JUMP_PARAMS)) SHLIB_DATA:= $(shell awk -F= ' { if ($$1 == "Data") print $$2 }' $(JUMP_PARAMS)) SHLIB_JUMP:= $(shell awk -F= ' { if ($$1 == "Jump") print $$2 }' $(JUMP_PARAMS)) SHLIB_GOT:= $(shell awk -F= ' { if ($$1 == "GOT") print $$2 }' $(JUMP_PARAMS)) SHLIB_VERSION:= $(shell awk -F= ' { if ($$1 == "Version") print $$2 }' $(JUMP_PARAMS)) SHLIB_VERSION_MAJOR:=$(shell awk -F= ' { \ if ($$1 == "Version") { \ for (i = 1; i <= length ($$2); i++) { \ if (substr ($$2, i, 1) == ".") { \ print substr ($$2, 1, i - 1); break; \ } } } } ' $(JUMP_PARAMS)) SHLIB_FILE:=$(basename $(SHLIB_NAME)).so.$(SHLIB_VERSION) SHLIB_FILE_MAJOR:=$(basename $(SHLIB_NAME)).so.$(SHLIB_VERSION_MAJOR) SYSLIBS:= $(SHARED_DIR)/libgcc/libgcc3.a \ $(SHARED_DIR)/libcompat/libcompat.a $(TOPDIR)/libalias.a STUBNAMES=libc libcurses libtermcap libdbm STUBLIBS:= $(foreach lib, $(STUBNAMES), $(lib).sa) SHLIBS:= $(foreach lib, $(STUBNAMES), $(lib).a) STATIC_OBJS=__fpu_control.o __load.o __setfpucw.o set-init.o all lib: (cd $(TOPDIR); for l in *.a; do \ $(AR) -d $$l __.SYMDEF; \ $(REALRANLIB) $$l; done) ($(AR) -d $(SHARED_DIR)/libcompat/libcompat.a __.SYMDEF; \ $(REALRANLIB) $(SHARED_DIR)/libcompat/libcompat.a; ) (cd $(SHARED_DIR); for l in *.a; do \ $(AR) -d $$l __.SYMDEF; \ $(REALRANLIB) $$l; done) $(MKIMAGE) -l $(SHLIB_NAME) -v $(SHLIB_VERSION) -a $(SHLIB_TEXT) \ -d $(SHLIB_DATA) -j $(SHLIB_JUMP) -g $(SHLIB_GOT) \ -- $(SHLIBS:%=$(SHARED_DIR)/%) $(SYSLIBS) $(MKSTUBS) -l $(SHLIB_NAME) -v $(SHLIB_VERSION) -a $(SHLIB_TEXT) \ -d $(SHLIB_DATA) -j $(SHLIB_JUMP) -g $(SHLIB_GOT) \ -- $(STUBNAMES) $(VERIFY) -l $(SHLIB_FILE) $(STUBLIBS) mv $(SHLIB_FILE) lib.so # do this trick for stupid fs $(STRIP) lib.so mv lib.so $(SHLIB_FILE) $(RM) -rf ./tmpcopy; mkdir tmpcopy; \ (cd ./tmpcopy ;\ $(AR) -x ../$(TOPDIR)/libalias.a; \ $(AR) -x ../$(SHARED_DIR)/libc.a $(STATIC_OBJS); \ $(AR) $(AR_FLAGS) ../libc.sa *.o; \ cd ..; $(RM) -rf ./tmpcopy;) for l in *.sa; do \ $(AR) -d $$l __.SYMDEF; \ $(REALRANLIB) $$l; \ done realclean clean: $(RM) -f core *.o *.s *.sa *.so.* *.a verify.out *.log ifeq ($(TARGET_SO_DIR),/lib) install: if [ ! -d $(TARGET_LIB_DIR) ]; then \ $(MKDIR) $(TARGET_LIB_DIR); \ else true; fi cp $(STUBLIBS) $(TARGET_LIB_DIR) if [ ! -d $(TARGET_SO_DIR) ]; then \ $(MKDIR) $(TARGET_SO_DIR); \ else true; fi if [ -f $(TARGET_SO_DIR)/$(SHLIB_FILE) ]; then \ (cd $(TARGET_SO_DIR); \ cp $(SHLIB_FILE) /tmp; \ if [ $$? -eq 0 ]; then \ ln -sf /tmp/$(SHLIB_FILE) $(SHLIB_FILE_MAJOR); \ else exit 1; fi; \ if [ ! -d backup ]; then \ $(MKDIR) backup; \ else true; fi; \ mv $(SHLIB_FILE) backup/$(SHLIB_FILE).$$$$); \ else true; fi cp $(SHLIB_FILE) $(TARGET_SO_DIR) (cd $(TARGET_SO_DIR); \ ln -sf $(SHLIB_FILE) $(SHLIB_FILE_MAJOR)) $(LDCONFIG) -v else install: if [ ! -d $(TARGET_LIB_DIR) ]; then \ $(MKDIR) $(TARGET_LIB_DIR); \ else true; fi cp $(STUBLIBS) $(TARGET_LIB_DIR) if [ ! -d $(TARGET_SO_DIR) ]; then \ $(MKDIR) $(TARGET_SO_DIR); \ else true; fi cp $(SHLIB_FILE) $(TARGET_SO_DIR) endif ./libc-linux/jump/libm/ 40755 1676 334 0 5550065621 12721 5ustar hjlisl./libc-linux/jump/libm/jump.params100644 1676 334 130 5550056550 15151 0ustar hjlislName=libm Text=0x600e0000 Data=0x600f8000 Jump=0x00000800 GOT=0x00000100 Version=4.5.26 ./libc-linux/jump/libm/jump.params.build100644 1676 334 130 5536421775 16260 0ustar hjlislName=libm Text=0x600e0000 Data=0x600f8000 Jump=0x00000800 GOT=0x00000100 Version=4.5.23 ./libc-linux/jump/libm/Makefile100644 1676 334 6161 5540144112 14452 0ustar hjlisl# TOPDIR=../.. include $(TOPDIR)/Makeconfig JUMP_DIR:=$(TOPDIR)/jump/libm JUMP_PARAMS=$(JUMP_DIR)/jump.params SHLIB_NAME:= $(shell awk -F= ' { if ($$1 == "Name") print $$2 }' $(JUMP_PARAMS)) SHLIB_TEXT:= $(shell awk -F= ' { if ($$1 == "Text") print $$2 }' $(JUMP_PARAMS)) SHLIB_DATA:= $(shell awk -F= ' { if ($$1 == "Data") print $$2 }' $(JUMP_PARAMS)) SHLIB_JUMP:= $(shell awk -F= ' { if ($$1 == "Jump") print $$2 }' $(JUMP_PARAMS)) SHLIB_GOT:= $(shell awk -F= ' { if ($$1 == "GOT") print $$2 }' $(JUMP_PARAMS)) SHLIB_VERSION:= $(shell awk -F= ' { if ($$1 == "Version") print $$2 }' $(JUMP_PARAMS)) SHLIB_VERSION_MAJOR:=$(shell awk -F= ' { \ if ($$1 == "Version") { \ for (i = 1; i <= length ($$2); i++) { \ if (substr ($$2, i, 1) == ".") { \ print substr ($$2, 1, i - 1); break; \ } } } } ' $(JUMP_PARAMS)) SHLIB_FILE:=$(basename $(SHLIB_NAME)).so.$(SHLIB_VERSION) SHLIB_FILE_MAJOR:=$(basename $(SHLIB_NAME)).so.$(SHLIB_VERSION_MAJOR) SYSLIBS:= $(SHARED_DIR)/libgcc/libgcc3.a \ -lc $(TOPDIR)/libmalias.a STUBNAMES=libm STUBLIBS:= $(foreach lib, $(STUBNAMES), $(lib).sa) SHLIBS:= $(foreach lib, $(STUBNAMES), $(lib).a) all lib: (cd $(TOPDIR); for l in *.a; do \ $(AR) -d $$l __.SYMDEF; \ $(REALRANLIB) $$l; done) (cd $(SHARED_DIR); for l in *.a; do \ $(AR) -d $$l __.SYMDEF; \ $(REALRANLIB) $$l; done) $(MKIMAGE) -l $(SHLIB_NAME) -v $(SHLIB_VERSION) -a $(SHLIB_TEXT) \ -d $(SHLIB_DATA) -j $(SHLIB_JUMP) -g $(SHLIB_GOT) \ -- $(SHLIBS:%=$(SHARED_DIR)/%) $(SYSLIBS) $(MKSTUBS) -l $(SHLIB_NAME) -v $(SHLIB_VERSION) -a $(SHLIB_TEXT) \ -d $(SHLIB_DATA) -j $(SHLIB_JUMP) -g $(SHLIB_GOT) \ -- $(STUBNAMES) $(VERIFY) -l $(SHLIB_FILE) $(STUBLIBS) mv $(SHLIB_FILE) lib.so # do this trick for stupid fs $(STRIP) lib.so mv lib.so $(SHLIB_FILE) if [ -d tmpcopy ]; then $(RM) -f ./tmpcopy/*; \ else mkdir tmpcopy; fi; \ (cd ./tmpcopy ;\ $(AR) -x ../../../libmalias.a ; $(AR) $(AR_FLAGS) ../libm.sa *.o ;\ cd ..; $(RM) -rf ./tmpcopy;) for l in *.sa; do \ $(AR) -d $$l __.SYMDEF; \ $(REALRANLIB) $$l; \ done realclean clean: $(RM) -f core *.o *.s *.sa *.so.* *.a verify.out *.log ifeq ($(TARGET_LIBM_SO_DIR),/usr/lib) install: if [ ! -d $(TARGET_LIB_DIR) ]; then \ $(MKDIR) $(TARGET_LIB_DIR); \ else true; fi cp $(STUBLIBS) $(TARGET_LIB_DIR) if [ ! -d $(TARGET_LIBM_SO_DIR) ]; then \ $(MKDIR) $(TARGET_LIBM_SO_DIR); \ else true; fi if [ -f $(TARGET_LIBM_SO_DIR)/$(SHLIB_FILE) ]; then \ (cd $(TARGET_LIBM_SO_DIR); \ cp $(SHLIB_FILE) /tmp; \ if [ $$? -eq 0 ]; then \ ln -sf /tmp/$(SHLIB_FILE) $(SHLIB_FILE_MAJOR); \ else exit 1; fi; \ if [ ! -d backup ]; then \ $(MKDIR) backup; \ else true; fi; \ mv $(SHLIB_FILE) back/$(SHLIB_FILE).$$$$); \ else true; fi cp $(SHLIB_FILE) $(TARGET_LIBM_SO_DIR) (cd $(TARGET_LIBM_SO_DIR); \ ln -sf $(SHLIB_FILE) $(SHLIB_FILE_MAJOR)) $(LDCONFIG) -v else install: if [ ! -d $(TARGET_LIB_DIR) ]; then \ $(MKDIR) $(TARGET_LIB_DIR); \ else true; fi cp $(STUBLIBS) $(TARGET_LIB_DIR) if [ ! -d $(TARGET_LIBM_SO_DIR) ]; then \ $(MKDIR) $(TARGET_LIBM_SO_DIR); \ else true; fi cp $(SHLIB_FILE) $(TARGET_LIBM_SO_DIR) endif ./libc-linux/jump/libm/jump.funcs100644 1676 334 4462 5542372562 15045 0ustar hjlisl00000000 T _acos libm acos 00000000 T _acosh libm acosh 00000000 T _asin libm asin 00000000 T _asinh libm asinh 00000000 T _atan libm atan 00000000 T _atan2 libm atan2 00000000 T _atanh libm atanh 00000000 T _ceil libm ceil 00000000 T _cos libm cos 00000000 T _cosh libm cosh 00000000 T ___drem libm __drem 00000000 T _erf libm erf 00000000 T _erfc libm erf 00000000 T _exp libm exp 00000000 T _fabs libm fabs 00000000 T _floor libm floor 00000000 T _fmod libm fmod 00000000 T _frexp libm frexp 00000000 T _hypot libm hypot 00000000 T _j0 libm j0 00000000 T _j1 libm j1 00000000 T _jn libm jn 00000000 T _lgamma libm lgamma 00000000 T _log libm log 00000000 T _log10 libm log10 00000000 T _pow libm pow 00000000 T _pow10 libm exp 00000000 T _pow2 libm exp 00000000 T _sin libm sin 00000000 T _sinh libm sinh 00000000 T _sqrt libm sqrt 00000000 T _tan libm tan 00000000 T _tanh libm tanh 00000000 T _y0 libm j0 00000000 T _y1 libm j1 00000000 T _yn libm jn 00000000 T ___copysign libm __copysign 00000000 T ___finite libm __finite 00000000 T ___infnan libm __infnan 00000000 T ___isinf libm __isinf 00000000 T ___isnan libm __isnan 00000000 T ___rint libm __rint 00000000 T _expm1 libm expm1 00000000 T _log1p libm log1p 00000000 T _cbrt libm cbrt ./libc-linux/jump/Makefile100644 1676 334 557 5540142136 13516 0ustar hjlisl# TOPDIR=.. include $(TOPDIR)/Makeconfig CLEAN_DIRS=libc libc.lite libm ifeq ($(LITE),true) DIRS=libc.lite else DIRS=libc libm endif all lib install: @for d in $(DIRS); do \ echo makeing $@ in $$d; \ ($(MAKE) -C $$d $@); \ done realclean clean: @for d in $(CLEAN_DIRS); do \ echo makeing $@ in $$d; \ ($(MAKE) -C $$d $@); \ done depend: @true ./libc-linux/libio/ 40755 1676 334 0 5567152201 12120 5ustar hjlisl./libc-linux/libio/ChangeLog100644 1676 334 54141 5536422326 14020 0ustar hjlislSun Mar 06 13:10:21 1994 H.J. Lu (hjl@fudan) * floatconv.c (_IO_dtoa ()): fix a small memory leak, set the "on_stack" field to be 0 if "result" is not NULL. check if "result" is NULL before accessing the "k" field. Sat Mar 05 13:18:20 1994 H.J. Lu (hjl@jalod) * cleanup.c: don't do anything for linux if HAVE_GNU_LD is not defined. * floatconv.c (_IO_dtoa ()): if the number of digits of the floating point number is more than the previous one, free the old string and allocate a new one. Mon Feb 21 13:18:20 1994 H.J. Lu (hjl@jalod) * libio.h (_IO_PENDING_OUTPUT_COUNT(_fp)): return the pending output count in _fp. Mon Feb 14 23:48:40 1994 Per Bothner (bothner@kalessin.cygnus.com) * isgetline.cc (istream& istream::getline(char* buf, int len, char delim)): tentative fix. may change in furure. Sun Feb 13 22:32:31 1994 H.J. Lu (hjl@jalod) * libioP.h (CHECK_FILE): fix typos for _OLD_IO_MAGIC. * iofread.c (CHECK_FILE): * iofwrite.c (CHECK_FILE): return 0 if fp is invalid. Fri Feb 11 11:08:01 1994 SBPM Marc GINGOLD * iovfprintf.c (helper_vfprintf): add hp->_IO_file_flags = _IO_MAGIC|(_IO_IS_FILEBUF+_IO_NO_READS); Mon Jan 31 09:28:34 1994 H.J. Lu (hjl@jalod) * fileops.c (_IO_file_underflow): remove the errno == 0 testing introduced on Jan. 30. Sun Jan 30 12:25:09 1994 H.J. Lu (hjl@jalod) * fileops.c (_IO_file_underflow): set the EOF flag if errno from read is 0, EAGAIN or EWOULDBLOCK. * cleanup.c: check HAVE_GNU_LD instead of __linux__. Sat Jan 29 23:16:14 1994 H.J. Lu (hjl@jalod) * fileops.c (_IO_do_write): (_IO_file_underflow): (_IO_file_xsputn): (_IO_default_xsgetn): change "_IO_size_t count" to "_IO_ssize_t count". Sat Jan 29 06:52:27 1994 H.J. Lu (hjl@jalod) * fileops.c (_IO_file_fopen): (_IO_file_attach): don't return NULL if errno == ESPIPE while seek failes. Thu Jan 20 13:48:40 1994 Per Bothner (bothner@kalessin.cygnus.com) If no characters are read by fgets, ANSI C doesn't allow '\0' to be written to the buffer, but it is requried by ANSI C++ for istream::get and istream::getline. Both use _IO_getline ... * iogetline.c (_IO_getline): Don't write a '\0' at the end of the read data. The input buffer length does not include space for a '\0'. * iofgets.c, iogets.c: Change appropriately. Also check for _IO_ERR_SEEN, as required by ANSI. * isgetline.cc: Update accordingly. Tue Jan 18 10:08:01 1993 H.J. Lu (hjl@jalod) * libioP.h: modify CHECK_FILE(FILE,RET) to check _IO_MAGIC_MASK. * iofclose.c: don't clear fp->_IO_file_flags. malloc/free will modify it. Tue Jan 4 01:32:28 1993 H.J. Lu (hjl@jalod) * genops.c (_IO_default_xsputn): (_IO_default_xsgetn): * ioignore.c: change "_IO_size_t count" to "_IO_ssize_t count". * iogetline.c: change "_IO_size_t len" to "_IO_ssize_t len". Sat Jan 1 21:13:59 1993 H.J. Lu (hjl@jalod) * libioP.h: add CHECK_FILE(FILE,RET). * iofclose.c: * iofflush.c: * iofgetpos.c: * iofgets.c: * iofprintf.c: * iofputs.c: * iofread.c: * iofscanf.c: * iofsetpos.c: * ioftell.c: * iofwrite.c: * iosetbuffer.c: * iosetvbuf.c: * ioungetc.c: check fp with CHECK_FILE(FILE,RET). Wed Dec 29 20:59:17 1993 H.J. Lu (hjl@jalod) * libio.h (_IO_putc): add parentheses for "_ch". Tue Dec 21 13:02:48 1993 H.J. Lu (hjl@jalod) * libio.h: include . change const to __const. * iovfscanf.c: enforce the sequence of the conversion specification. * genops.c: * iopopen.c: * iofopen.c: * iofclose.c: don't include which is included in "libioP.h". * iopopen.c (_IO_proc_close) : check if fp is on the list before close it. * libioP.h: define CLOSED_FILEBUF_FLAGS as the one used to be in fileops.c. * fileops.c: remove the definition of CLOSED_FILEBUF_FLAGS, which is in libioP.h now. * fileops.c (_IO_file_fopen): * iofdopen.c (_IO_fdopen): * iopopen.c (_IO_proc_open): _flags |= CLOSED_FILEBUF_FLAGS before setting _flags. * iovfprintf.c: * cleanup.c: * ioperror.c: * iovfprintf.c: * iovfscanf.c: * strfile.h: * libioP.h: * libio.h: * iolibio.h: replace __PARAMS with __P to be compatible with the GNU C library. * iofopen.c (_IO_fopen): don't check fp == NULL after IO_file_init(&fp->_file). * filedoalloc.c: include . * iolibio.h: check and define _IOLIBIO_H. * config.shared: add $(LIBIO_CONFIG_FLAGS) to rules. * libioP.h: include _LIBIO_CONFIG_H if defined. include if __STDC__ is defined. * config/linux.mt: new files. define LIBIO_CONFIG_FLAGS=-D_LIBIO_CONFIG_H=\"config/linux.h\" -I./stdio * config/linux.h: new file for linux. * iofdopen.c (_IO_fdopen ()): call fcntl () to set up the currect status flag from the flag passing from fdopen (). * fileops.c (_IO_file_attach ()): seek to the current R/W pointer. * floatconv.c (_IO_strtod ()): make "+" and "-" as error. * libioP.h (_IO_ignore): (_IO_least_marker): (_IO_switch_to_main_get_are): (_IO_switch_to_backup_are): (_IO_syn): (_IO_get_column): (_IO_set_column): (_IO_str_finish): (IO_nobackup_pbackfail): new declaration. (_IO_flush_all): (_IO_flush_all_linebuffered): use ___P((void)); * iolibio.h (_IO_fscanf): (_IO_printf): (_IO_vfscanf): (_IO_fread): new declaration. * cleanup.c: for linux, comment out "function_alias" and use text_set_element instead. * libio.h: define _IO_uid_t and _IO_HAVE_ST_BLKSIZE as _G_xxxxxxxx. * iomanip.h (template class iapp): change ostream to istream. * libioP.h: * cleanup.c: * filedoalloc.c: ifdef out _IO_cleanup_registration_needed stuff for Linux. it is handled in cleanup.c. * configure.in (CLEAN): add tmp-params.h, dummy.C, dummy.o, dummy.c, dummy.out, TMP and a.out. add *linux*) my_target=linux;; to case "${target}" in. Also remove all libio object files for Linux since they are in libc.a. * iostrerror.c: do nothing if __linux__ is defined. * ioperror.c: add a new version for __linux__. may be used with glibc. * libioP.h: add _IO_gen_tempname (). * iotempname.c: new file for _IO_gen_tempname (). It is used for the temporary filename functions. * Makefile.in: add iotempname.o. * ioprims.c: #include . do nothing if __linux__ is defined. also glibc? Mon Dec 20 00:31:21 1993 Per Bothner (bothner@kalessin.cygnus.com) * config.shared (CXXINCLUDES): Fix quoting of $(NOSTDINC). Sun Dec 19 21:03:45 1993 Per Bothner (bothner@kalessin.cygnus.com) * Makefile.in (VERSION): Increase to 0.63. Fri Dec 17 13:02:44 1993 Per Bothner (bothner@kalessin.cygnus.com) * iofread.c (_IO_fread): Return 0 if either size or count is 0. * iofwrite.c (_IO_fwrite): Return 0 if either size or count is 0. (This is consistent with fread, and most implementations, but not with a literal reading of the ANSI spec.) * iovfscanf.c (_IO_vfscanf): If got EOF while skipping spaces, set seen_eof and break (instead of returning). * sbscan.cc (streambuf::vscan): Set error state before returning. * streambuf.h: Add a forward declarations for class istream to work around a g++ vtable name mangling bug. (Patch from harry@pdsrc.hilco.com via Jeffrey A Law .) * NEWS: New file. Sat Dec 11 16:21:08 1993 Per Bothner (bothner@kalessin.cygnus.com) * iovfprintf.c (struct helper_file, _IO_helper_overflow, helper_vfprintf, _IO_helper_jumps): New structs and functions. (_IO_vfprintf): Use helper_vfprintf to make printing to unbuffered files more efficient. * genops.c (_IO_default_underflow), libioP.h: New function. * iovsscanf.c (_IO_vsscanf): The input string's length marks its logical end-of-file. Wed Dec 8 13:20:46 1993 Per Bothner (bothner@kalessin.cygnus.com) * indstream.cc (indirectbuf::sync()): Don't crash if get_stream() or put_stream() are NULL; sync() both streams even if error. Sun Dec 5 19:24:29 1993 Brendan Kehoe (brendan@lisa.cygnus.com) * iostreamP.h (convert_to_seekflags): Use _IO_seek_set instead of 0 inside the conditial expressions. * iofsetpos.c (_IO_fsetpos): Delete unused var `pos'. Sat Dec 4 15:57:26 1993 Per Bothner (bothner@kalessin.cygnus.com) * filedoalloc.c (_IO_file_doallocate): Change type of couldbetty to int, and type of size to _IO_size_t, instead of size_t. (Change needed for Ultrix, which incorrectly deliberately doesn't define size_t in if _POSIX_SOURCE is defined.) Thu Dec 2 22:43:03 1993 Per Bothner (bothner@kalessin.cygnus.com) * fileops.c (_IO_file_finish): Remove redundant call to _IO_un_link. * iofclose.c (_IO_fclose): Don't call fp->_jumps->__close; it's too low-level. Instead call _IO_file_close_it. * dbz/Makefile.in (rclean, distclean): Add some missing files. Wed Dec 1 13:19:14 1993 Per Bothner (bothner@kalessin.cygnus.com) * config/hpux.mt (MATH_H_INLINES): No longer define. Patch from Jeffrey A Law . Fri Nov 26 13:28:36 1993 Per Bothner (bothner@kalessin.cygnus.com) * config.shared (CINCLUDES): Define default if libg++. * iofread.c: Use _IO_sgetn.c. * iolibio.h (_IO_clearerr): Fix typo. * genops.c (_IO_seekmark): Return 0 on success. * floactconv.c (Binit): Change to static. * iofclose.c (_IO_fclose): Check if file is _IO_stdin, _IO_stdout, or _IO_stderr; if so don't try to free it. Fix from hjl@nynexst.com. * genops.c (_IO_default_sync), libioP.h: New function. * libioP.h (_IO_default_close): Use _IO_default_sync -same interface. * Makefile.in: Increase version to 0.62. * iopopen.c (_IO_proc_close): Use waitpid (available in libibarty, if needed), rather than wait. Don't block/ignore SIGINT etc, as this is counter to Posix.2. * iopopen.c: Chain open proc_files, and have the child close the ones that are open (as required by Posix.2). * fstream.h (fstreambase::rdbuf), strstream.h (strstreambase ::rdbuf): Call ios::rdbuf() instead of getting _strbuf directly. * sbscan.cc (streambuf::vscan): Comment out duplicate default arg. * floatconv.c: Recognize Alpha and i860 as little-endian. * streambuf.cc: Return two bogus value returns from void functions. * iolibio.h, iofwrite.c: Fix buffer type to (const void*). * libio.h: Predefine of struct _IO_FILE to help non-g++-compilers. * libioP.h, pfstream.cc, stdfiles.c, iovfscanf.c: Cleanup syntax junk. * stdstreams.cc: Minor simplification. * streambuf.h, builtinbuf.cc: Add non-const ios::_IO_fix_vtable() for temporary binary compatibility. * filedoalloc.c, fileops.c: Add _POSIX_SOURCE. * fileops.c, iofopen.c, iofputs.c, iostream.cc, strops.c, strstream.cc, genops.c: Add some missing #includes. * iofopen.c, iofdopen.c: Return NULL if malloc fails. * iovfscanf.c: Fix return type in strtol prototype. * fwrite.c: Remove bogus file. Wed Nov 17 14:09:42 1993 Per Bothner (bothner@cygnus.com) * builtinbuf.cc (ios::_IO_fix_vtable), streambuf.h: Make method const, to reduce problems with -Wcast-qual. Tue Nov 16 19:30:42 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) * config.shared (CXXINCLUDE): use ${} instead of $() for NOSTDINC Tue Nov 16 14:15:45 1993 Per Bothner (bothner@kalessin.cygnus.com) * iopopen.c (_IO_proc_close): Re-structure to avoid declarations after statements. * floatconv.c: If not __STDC__, #define DBL_MANT_DIG. * config/isc.mt (G_CONFIG_ARGS): Remove bogus spaces. Patch from David A. Avery . Tue Nov 16 15:58:31 1993 Mark Eichin (eichin@cygnus.com) * Makefile.in (_G_config.h): explicitly use $(SHELL) to run gen-params, since we know it is a script (we're explicitly looking in ${srcdir} for it) and /bin/sh might not be good enough. Mon Nov 15 13:26:22 1993 Per Bothner (bothner@kalessin.cygnus.com) * builtinbuf.cc: Don't depend on initialization of static variable builtinbuf::vtable, since that might happen after we need it (for a static constructor). Instead, initialize it when needed by inlining the code from get_builtin_vtable into ios::_IO_fix_vtable(). * floatconv.c: Avoid using #elif, which some C compilers lack. * iogetline.c, libioP.h: Make char parameter be int, to avoid some default promotion anomalies. Fri Nov 5 11:49:46 1993 Per Bothner (bothner@kalessin.cygnus.com) * config.shared (do-clean-dvi): Remove TeX work files. * iopopen.c (extern _IO_fork): Don't use parameter type void. * strops.c (_IO_str_init_static): Clear the allocate_buffer function pointer, to mark the strfile as being static. Bug fix from Mike Raisbeck . Thu Nov 4 10:44:24 1993 Per Bothner (bothner@kalessin.cygnus.com) * filebuf.cc (filebuf:): Use sseekoff rather than seekoff (which loses if vtable pointer is NULL). * iostream.cc (ostream::operator<<(long long n)): Fix thinko. * Makefile.in (VERSION): Increase to 0.60. * Makefile.in (IO_OBJECTS): Added iopopen.o. * config.shared (DISTCLEAN): Also remove Make.pack. * config.shared (CXXINCLUDES): Add $(NOSTDINC). * config.shared (INSTALL): Fix so it ues the correct install.sh whether $srcdir is absolute or relative. * floatconv.c (DBL_MAX_10_EXP): Fix default value. Wed Nov 3 10:20:49 1993 Per Bothner (bothner@kalessin.cygnus.com) * gen-params: Make more robust to allow random junk (NeXT has spaces) before typedefs. * fileops.c (_IO_file_overflow): Reduce code duplication. * Makefile.in (IO_OBJECTS): Remove ioputs.o. * iovfscanf.c, libio.h: Extra parameter to _IO_vfscanf, for optionally setting an error indication.. * iofscanf.c, ioscanf.c, iofscanf.c, iovsscanf.c: Fix calls to _IO_vfscanf to pass an extra NULL. * sbscan.cc (streambuf::vscan): If passed an extra stream, set its error state (using new _IO_vfscanf parameter. * filedoalloc.c, fileops.c, genops.c, iogetline.c, ioignore.c, libio.h, libioP.h, streambuf.cc streambuf.h, strfile.h, strops.c, strstream.cc: Replace macros (_base, _ebuf, _eback, _gptr, _egptr, _pbase, _pptr, _epptr) by field names (_IO_buf_base, _IO_buf_end, _IO_read_base, _IO_read_pre, IO_read_end, _IO_write_base, _IO_write_ptr, _IO_write_end). * libio.h: Remove the old macros (which fixes a conflict. Mon Nov 1 15:22:12 1993 Per Bothner (bothner@kalessin.cygnus.com) * iostream.cc: Use _IO_sputn instead of sputn. _IO_sputn does not require a vtable pointer, and is also slightly faster. * builtinbuf.{h,cc} (builtinbuf::setbuf): Fix return and parameter types. Mon Oct 25 12:56:33 1993 Per Bothner (bothner@kalessin.cygnus.com) Kludge to make sure _IO_FILE buffers get flushed before exit. * dbz/dbzmain.c, dbz/fake.c, dbz/byteflip.c: Invoke DBZ_FINISH macro (if defined) before (normal) exits. * dbz/Makefile.in (CFLAGS): Define DBZ_FINISH to call _IO_flush_all. Sat Oct 23 22:10:53 1993 Per Bothner (bothner@kalessin.cygnus.com) * Makefile.in (VERSION): Set to 0.60 for libg++ release. * fileops.c (_IO_file_attach): Set _offset to _IO_pos_BAD. * iostream.cc (ostream::flush): Fix thinkp. * editbuf.cc, isgetsb.cc, isscan.cc, osform.cc, parsestream.cc, pfstream.cc, sbform.cc, sbscan.cc, stdstreams.cc, stream.cc: Replace #include "ioprivate.h" by #include "libioP.h" (and sometimes stdarg.h, stdlib.h and/or string.h). * ioprivate.h: Removed. Thu Oct 21 19:24:02 1993 Per Bothner (bothner@kalessin.cygnus.com) * PlotFile.h, SFile.h, editbuf.cc, editbuf.h, filebuf.cc, fstream.cc, fstream.h, indstream.cc, indstream.h, iomanip.cc, iomanip.h, ioprivate.h, iostream.cc, iostream.h, isgetline.cc, isgetsb.cc, parsestream.cc, parsestream.h, pfstream.cc, pfstream.h, procbuf.cc, procbuf.h, stdiostream.cc, stdiostream.h, stdstreams.cc, streambuf.cc, streambuf.h, strstream.cc, strstream.h: Remove old (duplicate) copyright notices. * iostream.cc: Fix calls to sync() to be safe in the presence of vtable-less streambufs. Wed Oct 20 15:22:04 1993 Per Bothner (bothner@kalessin.cygnus.com) * streambuf.h (streambuf::underflow, streambuf::overflow): Don't make virtual functions pure. * streambuf.cc (streambuf::underflow, streambuf::overflow): Default definitions (return EOF). * fstream.h: Add new (int fd, char* buf, int len) constructors. These are deprecated, but added for AT&T compatibility. * fstream.cc fstreambase::fstreambase(int fd, char *p, int l): New. Thu Oct 14 14:57:01 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) * configure.in: use 'mv -f' instead of 'mv' Tue Oct 12 05:01:44 1993 Mike Stump (mrs@cygnus.com) * floatconv.c: Fix typo, change __STDC to __STDC__. Mon Oct 11 17:03:12 1993 Per Bothner (bothner@kalessin.cygnus.com) * cleanup.c: It should be #if _G_HAVE_ATEXIT, not #ifdef. * floatconv.c, iostrerror.c, iovfprintf.c, iovfscanf.c, libioP.h: Bunch of fixes to allow use of non-ANSI (K&R) C compilers. * Makefile.in (iostream.list): Use CC=$(CXX) to force use of gcc. * README: New file. Fri Oct 8 16:19:58 1993 Per Bothner (bothner@kalessin.cygnus.com) * Makefile.in: Move ioungetc.o from STDIO_WRAP_OBJECTS to IO_OBJECTS (since it is needed for iovfscanf.c). * iostrerror.c: Add declaration of strerror. Thu Oct 7 12:02:28 1993 Per Bothner (bothner@kalessin.cygnus.com) * cleanup.c: New file, to cause flushing at exit. * filedoalloc.c: Cause flushing on exit. * Makefile.in (OSPRIM_OBJECTS): Add cleanup.o. * gen-params: Check for atexit. Tue Oct 5 19:11:14 1993 Mike Stump (mrs@cygnus.com) * ioperror.c (_IO_strerror): Add missing ()s in _PARAMS usage. Tue Oct 5 10:33:37 1993 Per Bothner (bothner@kalessin.cygnus.com) * iofprintf.c, iofscanf.c, ioprintf.c, ioscanf.c, iosprintf.c, iosscanf.c: Remove bogus semi-colon after va_dcl. * ioperror.c: Fix typos in declaration. Mon Oct 4 17:12:22 1993 Per Bothner (bothner@kalessin.cygnus.com) * configure.in (CLEAN): Define (as _G_config.h *.a). * fileops.c (_IO_file_read): Don't assume EINTR is defined. * iosetbuf.c: Replace by generalized ... * iosetbuffer.c: ... variant, derived from BSD. * Makefile.in (STDIO_WRAP_OBJECTS): Change correspondingly. * iosetvbuf.c (iosetvbuf): Minor ANSI tweak. * iostdio.h (setbuf, setlinebuf): New #defines. * iolibio.h (_IO_setbuf, _IO_setlinebuf): (Re-)define as macros. * Makefile.in (LIBIO_OBJECTS): New macro. Tue Sep 28 14:15:52 1993 Per Bothner (bothner@kalessin.cygnus.com) * libioP.h (_IO_proc_open, _IO_proc_close): Add missing return types. * procbuf.cc: Belated fixes. Mon Sep 27 14:04:47 1993 Per Bothner (bothner@kalessin.cygnus.com) * Makefile.in: List new files. Add STDIO_WRAP_OBJECTS macro. * floatconv.c (d2b): Use Exp_msk11 instead of Exp_msk1. * iofgetpos.c (_IO_fgetpos), iofsetpos.c (_IO_fsetpos): Clean up. * iolibio.h: New file. Declarations of _IO_foo, for most foo where foo is a stdio function. (Remove these from libio.h.) * iostream.h (istream::istreambuf, ostream::ostreambuf): Move obsolete functions inside #ifdef _STREAM_COMPAT. * libio.h, libioP.h, streambuf.h, parsestream.h, stdiostream.h: Use _IO_fpos_t rather than _IO_pos_t. * iopopen.c: New file type, for pipe (popen-like) streams. * procbuf.cc: Now just a C++ wrapper for the files in iopopen.c. * streambuf.h (ios::unsetf): Return complete old value of flags. * iogets.c (_IO_gets(), ioungetc.c (_IO_ungetc), ioperror.c (_IO_perror), iostrerror.c (_IO_strerror): New files and functions, for stdio implementation. * iostdio.h: Add declarations for various recently-added functions. Sun Sep 12 14:24:55 1993 Per Bothner (bothner@kalessin.cygnus.com) * streambuf.h (ios::showpos):: Fix typo. Fri Aug 27 12:05:47 1993 Per Bothner (bothner@kalessin.cygnus.com) * iopadn.c (_IO_padn): Change to return count of chars written. * outfloat.c, iovfprintf.c: Change for new _IO_padn interface. * iostream.cc (ostream::operator<<): Make sure to set badbit on a failure (many places). Use _IO_padn more. * iostream.cc (ostream& ostream::operator<<(const void *p): Move to * osform.cc: ... here, to reduce linking-in-the-world syndrome. * osform.cc: Use rdbuf(), instead of _strbuf directly. * genops.c (_IO_sgetn), libio.h: New function. * streambuf.h (streambuf.h::sgetn): Use _IO_sgetn. * SFile.cc (SFile::operator[]): Use sseekoff, not seekoff. Thu Aug 26 10:16:31 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) * config.shared (SUBDIRS): only recurse if the directory is configured Wed Aug 25 12:56:12 1993 Per Bothner (bothner@kalessin.cygnus.com) * config/{hpux.mt, isc.mt, sco4.mt}: Moved from ../libg++/config (since they affect _G_config.h). * configure.in: Set target_make_frag to one of the above files. Fri Aug 20 00:53:14 1993 Per Bothner (bothner@kalessin.cygnus.com) * iofopen.c (iofopen): Fix type passed to _IO_un_link(). * Makefile.in (_G_config.h): Pass $CC (not $CXX) as CC. * configure.in (configdirs): Add dbz and stdio. * fileops.c (_IO_file_seekoff): Convert more old functionality. * iofdopen.c: Use mode parameter to set _flags. * iofscanf.c, ioputs.c, ioscanf.c, iosprintf.c: New files. * Makefile.in (IO_OBJECTS): Added new objects. * iostdio.h: Add feof. fscanf, puts, sprintf, vsprintf. * libio.h: Add _IO_vprintf macro. * iofopen.c: Invoke _IO_un_link if failure. * iovsprintf.c: Write terminating NUL. * libioP.h: Add COERCE_FILE macro (by default does nothing). * iofclose.c, iofflush.c, iofgets.c, iofprintf.c, iofputs.c, iofread.c, ioftell.c, iofwrite.c, iosetbuf.c, iosetvbuf.c: Invoke COERCE_FILE macro. * ioftell.c: Use _IO_seekoff. Wed Aug 18 22:49:56 1993 Per Bothner (bothner@kalessin.cygnus.com) * sbform.cc (streambuf::form), sbscan.cc (streambuf::scan): Remove cast to _IO_va_list. (Loses if array type.) * libio.h: Handle _IO_va_list for systems that need . * floatconv.h: Fix typo (reported by H.J.Lu). Wed Aug 18 19:34:04 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) * configure.in (INSTALLDIR): handle native vs. cross case * Makefile.in (install): don't use $TARGETLIB, set INSTALLDIR to $(libdir) Wed Aug 18 12:10:03 1993 Per Bothner (bothner@kalessin.cygnus.com) * Makefile.in: Rename iostream-files to iostream.list. * configure.in: Add iostream.list to MOSTLYCLEAN. Tue Aug 17 18:56:59 1993 Per Bothner (bothner@kalessin.cygnus.com) * Makefile.in: Depend on _G_config.h where appropriate. * config.shared (CXXINCLUDES): If doing libg++, search ../libio. Tue Aug 17 17:34:24 1993 Per Bothner (bothner@kalessin.cygnus.com) New directory. Based on old libg++/iostream code, but extensively re-written. ./libc-linux/libio/cleanup.c100644 1676 334 1437 5536016163 14017 0ustar hjlisl#include "libioP.h" #ifdef HAVE_GNU_LD #include "stdio.h" #include #include #include #if 1 function_alias(_cleanup, _IO_flush_all, void, (), DEFUN_VOID(_cleanup)) #else /* We don't want this since we are building the shared library. * We want the shared library selfcontained. __libc_atexit will * ruin it unless we take exit () out of the shared library. */ text_set_element(__libc_atexit, _IO_flush_all); #endif #else #if !defined (__linux__) #if _G_HAVE_ATEXIT #include typedef void (*voidfunc) __P((void)); static void _IO_register_cleanup () { atexit ((voidfunc)_IO_flush_all); _IO_cleanup_registration_needed = 0; } void (*_IO_cleanup_registration_needed)() = _IO_register_cleanup; #endif /* _G_HAVE_ATEXIT */ #endif #endif ./libc-linux/libio/floatconv.c100644 1676 334 216424 5536421607 14432 0ustar hjlisl/* Copyright (C) 1993 Free Software Foundation This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, 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 General Public License for more details. You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, if you link this library with files compiled with a GNU compiler to produce an executable, this does not cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. */ #include #ifdef USE_DTOA /**************************************************************** * * The author of this software is David M. Gay. * * Copyright (c) 1991 by AT&T. * * Permission to use, copy, modify, and distribute this software for any * purpose without fee is hereby granted, provided that this entire notice * is included in all copies of any software which is or includes a copy * or modification of this software and in all copies of the supporting * documentation for such software. * * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. * ***************************************************************/ /* Some cleaning up by Per Bothner, bothner@cygnus.com, 1992, 1993. Re-written to not need static variables (except result, result_k, HIWORD, LOWORD). */ /* Please send bug reports to David M. Gay AT&T Bell Laboratories, Room 2C-463 600 Mountain Avenue Murray Hill, NJ 07974-2070 U.S.A. dmg@research.att.com or research!dmg */ /* strtod for IEEE-, VAX-, and IBM-arithmetic machines. * * This strtod returns a nearest machine number to the input decimal * string (or sets errno to ERANGE). With IEEE arithmetic, ties are * broken by the IEEE round-even rule. Otherwise ties are broken by * biased rounding (add half and chop). * * Inspired loosely by William D. Clinger's paper "How to Read Floating * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. * * Modifications: * * 1. We only require IEEE, IBM, or VAX double-precision * arithmetic (not IEEE double-extended). * 2. We get by with floating-point arithmetic in a case that * Clinger missed -- when we're computing d * 10^n * for a small integer d and the integer n is not too * much larger than 22 (the maximum integer k for which * we can represent 10^k exactly), we may be able to * compute (d*10^k) * 10^(e-k) with just one roundoff. * 3. Rather than a bit-at-a-time adjustment of the binary * result in the hard case, we use floating-point * arithmetic to determine the adjustment to within * one bit; only in really hard cases do we need to * compute a second residual. * 4. Because of 3., we don't need a large table of powers of 10 * for ten-to-e (just some small tables, e.g. of 10^k * for 0 <= k <= 22). */ /* * #define IEEE_8087 for IEEE-arithmetic machines where the least * significant byte has the lowest address. * #define IEEE_MC68k for IEEE-arithmetic machines where the most * significant byte has the lowest address. * #define Sudden_Underflow for IEEE-format machines without gradual * underflow (i.e., that flush to zero on underflow). * #define IBM for IBM mainframe-style floating-point arithmetic. * #define VAX for VAX-style floating-point arithmetic. * #define Unsigned_Shifts if >> does treats its left operand as unsigned. * #define No_leftright to omit left-right logic in fast floating-point * computation of dtoa. * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3. * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines * that use extended-precision instructions to compute rounded * products and quotients) with IBM. * #define ROUND_BIASED for IEEE-format with biased rounding. * #define Inaccurate_Divide for IEEE-format with correctly rounded * products but inaccurate quotients, e.g., for Intel i860. * #define KR_headers for old-style C function headers. */ #ifdef DEBUG #include #define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} #endif #ifdef __STDC__ #include #include #include #define CONST const #else #define CONST #define KR_headers /* In this case, we assume IEEE floats. */ #define FLT_ROUNDS 1 #define FLT_RADIX 2 #define DBL_MANT_DIG 53 #define DBL_DIG 15 #define DBL_MAX_10_EXP 308 #define DBL_MAX_EXP 1024 #endif #include #ifndef __MATH_H__ #include #endif #ifdef Unsigned_Shifts #define Sign_Extend(a,b) if (b < 0) a |= 0xffff0000; #else #define Sign_Extend(a,b) /*no-op*/ #endif #if defined(__i386__) || defined(__i860__) || defined(clipper) #define IEEE_8087 #endif #if defined(MIPSEL) || defined(__alpha__) #define IEEE_8087 #endif #if defined(__sparc__) || defined(sparc) || defined(MIPSEB) #define IEEE_MC68k #endif #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 #if FLT_RADIX==16 #define IBM #else #if DBL_MANT_DIG==56 #define VAX #else #if DBL_MANT_DIG==53 && DBL_MAX_10_EXP==308 #define IEEE_Unknown #else Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. #endif #endif #endif #endif #ifdef IEEE_8087 #define HIWORD 1 #define LOWORD 0 #define TEST_ENDIANNESS /* nothing */ #else #if defined(IEEE_MC68k) #define HIWORD 0 #define LOWORD 1 #define TEST_ENDIANNESS /* nothing */ #else static int HIWORD = -1, LOWORD; static void test_endianness() { union doubleword { double d; unsigned long u[2]; } dw; dw.d = 10; if (dw.u[0] != 0) /* big-endian */ HIWORD=0, LOWORD=1; else HIWORD=1, LOWORD=0; } #define TEST_ENDIANNESS if (HIWORD<0) test_endianness(); #endif #endif #if 0 union { double d; unsigned long x[2]; } _temp; #endif #define word0(x) ((unsigned long *)&x)[HIWORD] #if 0 #define word0(X) (_temp.d = X, _temp.x[HIWORD]) #define setword0(D,X) (_temp.d = D, _temp.x[HIWORD] = X, D = _temp.d) #endif #define word1(x) ((unsigned long *)&x)[LOWORD] /* The following definition of Storeinc is appropriate for MIPS processors. */ #if defined(IEEE_8087) + defined(VAX) #define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \ ((unsigned short *)a)[0] = (unsigned short)c, a++) #else #if defined(IEEE_MC68k) #define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ ((unsigned short *)a)[1] = (unsigned short)c, a++) #else #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) #endif #endif /* #define P DBL_MANT_DIG */ /* Ten_pmax = floor(P*log(2)/log(5)) */ /* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ /* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ /* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(IEEE_Unknown) #define Exp_shift 20 #define Exp_shift1 20 #define Exp_msk1 0x100000 #define Exp_msk11 0x100000 #define Exp_mask 0x7ff00000 #define P 53 #define Bias 1023 #define IEEE_Arith #define Emin (-1022) #define Exp_1 0x3ff00000 #define Exp_11 0x3ff00000 #define Ebits 11 #define Frac_mask 0xfffff #define Frac_mask1 0xfffff #define Ten_pmax 22 #define Bletch 0x10 #define Bndry_mask 0xfffff #define Bndry_mask1 0xfffff #define LSB 1 #define Sign_bit 0x80000000 #define Log2P 1 #define Tiny0 0 #define Tiny1 1 #define Quick_max 14 #define Int_max 14 #define Infinite(x) (word0(x) == 0x7ff00000) /* sufficient test for here */ #else #undef Sudden_Underflow #define Sudden_Underflow #ifdef IBM #define Exp_shift 24 #define Exp_shift1 24 #define Exp_msk1 0x1000000 #define Exp_msk11 0x1000000 #define Exp_mask 0x7f000000 #define P 14 #define Bias 65 #define Exp_1 0x41000000 #define Exp_11 0x41000000 #define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ #define Frac_mask 0xffffff #define Frac_mask1 0xffffff #define Bletch 4 #define Ten_pmax 22 #define Bndry_mask 0xefffff #define Bndry_mask1 0xffffff #define LSB 1 #define Sign_bit 0x80000000 #define Log2P 4 #define Tiny0 0x100000 #define Tiny1 0 #define Quick_max 14 #define Int_max 15 #else /* VAX */ #define Exp_shift 23 #define Exp_shift1 7 #define Exp_msk1 0x80 #define Exp_msk11 0x800000 #define Exp_mask 0x7f80 #define P 56 #define Bias 129 #define Exp_1 0x40800000 #define Exp_11 0x4080 #define Ebits 8 #define Frac_mask 0x7fffff #define Frac_mask1 0xffff007f #define Ten_pmax 24 #define Bletch 2 #define Bndry_mask 0xffff007f #define Bndry_mask1 0xffff007f #define LSB 0x10000 #define Sign_bit 0x8000 #define Log2P 1 #define Tiny0 0x80 #define Tiny1 0 #define Quick_max 15 #define Int_max 15 #endif #endif #ifndef IEEE_Arith #define ROUND_BIASED #endif #ifdef RND_PRODQUOT #define rounded_product(a,b) a = rnd_prod(a, b) #define rounded_quotient(a,b) a = rnd_quot(a, b) extern double rnd_prod(double, double), rnd_quot(double, double); #else #define rounded_product(a,b) a *= b #define rounded_quotient(a,b) a /= b #endif #define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) #define Big1 0xffffffff #define Kmax 15 /* (1<on_stack = 1; v->k = BIGINT_MINIMUM_K; v->maxwds = 1 << BIGINT_MINIMUM_K; v->sign = v->wds = 0; return v; } /* Allocate a Bigint with '1<k = k; rv->maxwds = x; rv->sign = rv->wds = 0; rv->on_stack = 0; return rv; } static void Bfree #ifdef KR_headers (v) Bigint *v; #else (Bigint *v) #endif { if (v && !v->on_stack) free (v); } static void Bcopy #ifdef KR_headers (x, y) Bigint *x, *y; #else (Bigint *x, Bigint *y) #endif { register unsigned long *xp, *yp; register int i = y->wds; x->sign = y->sign; x->wds = i; for (xp = x->x, yp = y->x; --i >= 0; ) *xp++ = *yp++; } /* Make sure b has room for at least 1<k >= k) return b; else { Bigint *rv = Balloc (k); Bcopy(rv, b); Bfree(b); return rv; } } /* Return b*m+a. b is modified. Assumption: 0xFFFF*m+a fits in 32 bits. */ static Bigint * multadd #ifdef KR_headers (b, m, a) Bigint *b; int m, a; #else (Bigint *b, int m, int a) #endif { int i, wds; unsigned long *x, y; unsigned long xi, z; wds = b->wds; x = b->x; i = 0; do { xi = *x; y = (xi & 0xffff) * m + a; z = (xi >> 16) * m + (y >> 16); a = (int)(z >> 16); *x++ = (z << 16) + (y & 0xffff); } while(++i < wds); if (a) { if (wds >= b->maxwds) b = Brealloc(b, b->k+1); b->x[wds++] = a; b->wds = wds; } return b; } static Bigint * s2b #ifdef KR_headers (result, s, nd0, nd, y9) Bigint *result; CONST char *s; int nd0, nd; unsigned long y9; #else (Bigint *result, CONST char *s, int nd0, int nd, unsigned long y9) #endif { int i, k; long x, y; x = (nd + 8) / 9; for(k = 0, y = 1; x > y; y <<= 1, k++) ; result = Brealloc(result, k); result->x[0] = y9; result->wds = 1; i = 9; if (9 < nd0) { s += 9; do result = multadd(result, 10, *s++ - '0'); while (++i < nd0); s++; } else s += 10; for(; i < nd; i++) result = multadd(result, 10, *s++ - '0'); return result; } static int hi0bits #ifdef KR_headers (x) register unsigned long x; #else (register unsigned long x) #endif { register int k = 0; if (!(x & 0xffff0000)) { k = 16; x <<= 16; } if (!(x & 0xff000000)) { k += 8; x <<= 8; } if (!(x & 0xf0000000)) { k += 4; x <<= 4; } if (!(x & 0xc0000000)) { k += 2; x <<= 2; } if (!(x & 0x80000000)) { k++; if (!(x & 0x40000000)) return 32; } return k; } static int lo0bits #ifdef KR_headers (y) unsigned long *y; #else (unsigned long *y) #endif { register int k; register unsigned long x = *y; if (x & 7) { if (x & 1) return 0; if (x & 2) { *y = x >> 1; return 1; } *y = x >> 2; return 2; } k = 0; if (!(x & 0xffff)) { k = 16; x >>= 16; } if (!(x & 0xff)) { k += 8; x >>= 8; } if (!(x & 0xf)) { k += 4; x >>= 4; } if (!(x & 0x3)) { k += 2; x >>= 2; } if (!(x & 1)) { k++; x >>= 1; if (!x & 1) return 32; } *y = x; return k; } static Bigint * i2b #ifdef KR_headers (result, i) Bigint *result; int i; #else (Bigint* result, int i) #endif { result = Brealloc(result, 1); result->x[0] = i; result->wds = 1; return result; } /* Do: c = a * b. */ static Bigint * mult #ifdef KR_headers (c, a, b) Bigint *a, *b, *c; #else (Bigint *c, Bigint *a, Bigint *b) #endif { int k, wa, wb, wc; unsigned long carry, y, z; unsigned long *x, *xa, *xae, *xb, *xbe, *xc, *xc0; unsigned long z2; if (a->wds < b->wds) { Bigint *tmp = a; a = b; b = tmp; } k = a->k; wa = a->wds; wb = b->wds; wc = wa + wb; if (wc > a->maxwds) k++; c = Brealloc(c, k); for(x = c->x, xa = x + wc; x < xa; x++) *x = 0; xa = a->x; xae = xa + wa; xb = b->x; xbe = xb + wb; xc0 = c->x; for(; xb < xbe; xb++, xc0++) { if (y = *xb & 0xffff) { x = xa; xc = xc0; carry = 0; do { z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; carry = z >> 16; z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; carry = z2 >> 16; Storeinc(xc, z2, z); } while(x < xae); *xc = carry; } if (y = *xb >> 16) { x = xa; xc = xc0; carry = 0; z2 = *xc; do { z = (*x & 0xffff) * y + (*xc >> 16) + carry; carry = z >> 16; Storeinc(xc, z, z2); z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; carry = z2 >> 16; } while(x < xae); *xc = z2; } } for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; c->wds = wc; return c; } /* Returns b*(5**k). b is modified. */ /* Re-written by Per Bothner to not need a static list. */ static Bigint * pow5mult #ifdef KR_headers (b, k) Bigint *b; int k; #else (Bigint *b, int k) #endif { static int p05[6] = { 5, 25, 125, 625, 3125, 15625 }; for (; k > 6; k -= 6) b = multadd(b, 15625, 0); /* b *= 5**6 */ if (k == 0) return b; else return multadd(b, p05[k-1], 0); } /* Re-written by Per Bothner so shift can be in place. */ static Bigint * lshift #ifdef KR_headers (b, k) Bigint *b; int k; #else (Bigint *b, int k) #endif { int i; unsigned long *x, *x1, *xe; int old_wds = b->wds; int n = k >> 5; int k1 = b->k; int n1 = n + old_wds + 1; if (k == 0) return b; for(i = b->maxwds; n1 > i; i <<= 1) k1++; b = Brealloc(b, k1); xe = b->x; /* Source limit */ x = xe + old_wds; /* Source pointer */ x1 = x + n; /* Destination pointer */ if (k &= 0x1f) { int k1 = 32 - k; unsigned long z = *--x; if ((*x1 = (z >> k1)) != 0) { ++n1; } while (x > xe) { unsigned long w = *--x; *--x1 = (z << k) | (w >> k1); z = w; } *--x1 = z << k; } else do { *--x1 = *--x; } while(x > xe); while (x1 > xe) *--x1 = 0; b->wds = n1 - 1; return b; } static int cmp #ifdef KR_headers (a, b) Bigint *a, *b; #else (Bigint *a, Bigint *b) #endif { unsigned long *xa, *xa0, *xb, *xb0; int i, j; i = a->wds; j = b->wds; #ifdef DEBUG if (i > 1 && !a->x[i-1]) Bug("cmp called with a->x[a->wds-1] == 0"); if (j > 1 && !b->x[j-1]) Bug("cmp called with b->x[b->wds-1] == 0"); #endif if (i -= j) return i; xa0 = a->x; xa = xa0 + j; xb0 = b->x; xb = xb0 + j; for(;;) { if (*--xa != *--xb) return *xa < *xb ? -1 : 1; if (xa <= xa0) break; } return 0; } /* Do: c = a-b. */ static Bigint * diff #ifdef KR_headers (c, a, b) Bigint *c, *a, *b; #else (Bigint *c, Bigint *a, Bigint *b) #endif { int i, wa, wb; long borrow, y; /* We need signed shifts here. */ unsigned long *xa, *xae, *xb, *xbe, *xc; long z; i = cmp(a,b); if (!i) { c = Brealloc(c, 0); c->wds = 1; c->x[0] = 0; return c; } if (i < 0) { Bigint *tmp = a; a = b; b = tmp; i = 1; } else i = 0; c = Brealloc(c, a->k); c->sign = i; wa = a->wds; xa = a->x; xae = xa + wa; wb = b->wds; xb = b->x; xbe = xb + wb; xc = c->x; borrow = 0; do { y = (*xa & 0xffff) - (*xb & 0xffff) + borrow; borrow = y >> 16; Sign_Extend(borrow, y); z = (*xa++ >> 16) - (*xb++ >> 16) + borrow; borrow = z >> 16; Sign_Extend(borrow, z); Storeinc(xc, z, y); } while(xb < xbe); while(xa < xae) { y = (*xa & 0xffff) + borrow; borrow = y >> 16; Sign_Extend(borrow, y); z = (*xa++ >> 16) + borrow; borrow = z >> 16; Sign_Extend(borrow, z); Storeinc(xc, z, y); } while(!*--xc) wa--; c->wds = wa; return c; } static double ulp #ifdef KR_headers (x) double x; #else (double x) #endif { register long L; double a; L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; #ifndef Sudden_Underflow if (L > 0) { #endif #ifdef IBM L |= Exp_msk1 >> 4; #endif word0(a) = L; word1(a) = 0; #ifndef Sudden_Underflow } else { L = -L >> Exp_shift; if (L < Exp_shift) { word0(a) = 0x80000 >> L; word1(a) = 0; } else { word0(a) = 0; L -= Exp_shift; word1(a) = L >= 31 ? 1 : 1 << 31 - L; } } #endif return a; } static double b2d #ifdef KR_headers (a, e) Bigint *a; int *e; #else (Bigint *a, int *e) #endif { unsigned long *xa, *xa0, w, y, z; int k; double d; #ifdef VAX unsigned long d0, d1; #else #define d0 word0(d) #define d1 word1(d) #endif xa0 = a->x; xa = xa0 + a->wds; y = *--xa; #ifdef DEBUG if (!y) Bug("zero y in b2d"); #endif k = hi0bits(y); *e = 32 - k; if (k < Ebits) { d0 = Exp_1 | y >> Ebits - k; w = xa > xa0 ? *--xa : 0; d1 = y << (32-Ebits) + k | w >> Ebits - k; goto ret_d; } z = xa > xa0 ? *--xa : 0; if (k -= Ebits) { d0 = Exp_1 | y << k | z >> 32 - k; y = xa > xa0 ? *--xa : 0; d1 = z << k | y >> 32 - k; } else { d0 = Exp_1 | y; d1 = z; } ret_d: #ifdef VAX word0(d) = d0 >> 16 | d0 << 16; word1(d) = d1 >> 16 | d1 << 16; #else #undef d0 #undef d1 #endif return d; } static Bigint * d2b #ifdef KR_headers (result, d, e, bits) Bigint *result; double d; int *e, *bits; #else (Bigint *result, double d, int *e, int *bits) #endif { int de, i, k; unsigned long *x, y, z; #ifdef VAX unsigned long d0, d1; d0 = word0(d) >> 16 | word0(d) << 16; d1 = word1(d) >> 16 | word1(d) << 16; #else #define d0 word0(d) #define d1 word1(d) #endif result = Brealloc(result, 1); x = result->x; z = d0 & Frac_mask; d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ de = (int)(d0 >> Exp_shift); /* The exponent part of d. */ /* Put back the suppressed high-order bit, if normalized. */ #ifndef IBM #ifndef Sudden_Underflow if (de) #endif z |= Exp_msk11; #endif if (y = d1) { if (k = lo0bits(&y)) { x[0] = y | z << 32 - k; z >>= k; } else x[0] = y; i = result->wds = (x[1] = z) ? 2 : 1; } else { #ifdef DEBUG if (!z) Bug("Zero passed to d2b"); #endif k = lo0bits(&z); x[0] = z; i = result->wds = 1; k += 32; } #ifndef Sudden_Underflow if (de) { #endif #ifdef IBM *e = (de - Bias - (P-1) << 2) + k; *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask); #else *e = de - Bias - (P-1) + k; *bits = P - k; #endif #ifndef Sudden_Underflow } else { *e = de - Bias - (P-1) + 1 + k; *bits = 32*i - hi0bits(x[i-1]); } #endif return result; } #undef d0 #undef d1 static double ratio #ifdef KR_headers (a, b) Bigint *a, *b; #else (Bigint *a, Bigint *b) #endif { double da, db; int k, ka, kb; da = b2d(a, &ka); db = b2d(b, &kb); k = ka - kb + 32*(a->wds - b->wds); #ifdef IBM if (k > 0) { word0(da) += (k >> 2)*Exp_msk1; if (k &= 3) da *= 1 << k; } else { k = -k; word0(db) += (k >> 2)*Exp_msk1; if (k &= 3) db *= 1 << k; } #else if (k > 0) word0(da) += k*Exp_msk1; else { k = -k; word0(db) += k*Exp_msk1; } #endif return da / db; } static double tens[] = { 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22 #ifdef VAX , 1e23, 1e24 #endif }; static double #ifdef IEEE_Arith bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; static double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256 }; #define n_bigtens 5 #else #ifdef IBM bigtens[] = { 1e16, 1e32, 1e64 }; static double tinytens[] = { 1e-16, 1e-32, 1e-64 }; #define n_bigtens 3 #else bigtens[] = { 1e16, 1e32 }; static double tinytens[] = { 1e-16, 1e-32 }; #define n_bigtens 2 #endif #endif double _IO_strtod #ifdef KR_headers (s00, se) CONST char *s00; char **se; #else (CONST char *s00, char **se) #endif { int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; CONST char *s, *s0, *s1; double aadj, aadj1, adj, rv, rv0; long L; unsigned long y, z; Bigint _bb, _b_avail, _bd, _bd0, _bs, _delta; Bigint *bb = Binit(&_bb); Bigint *bd = Binit(&_bd); Bigint *bd0 = Binit(&_bd0); Bigint *bs = Binit(&_bs); Bigint *b_avail = Binit(&_b_avail); Bigint *delta = Binit(&_delta); TEST_ENDIANNESS; sign = nz0 = nz = 0; rv = 0.; for(s = s00;;s++) switch(*s) { case '-': sign = 1; /* no break */ case '+': if (*++s) goto break2; /* no break */ case 0: /* "+" and "-" should be reported as an error? */ sign = 0; s = s00; goto ret; case '\t': case '\n': case '\v': case '\f': case '\r': case ' ': continue; default: goto break2; } break2: if (*s == '0') { nz0 = 1; while(*++s == '0') ; if (!*s) goto ret; } s0 = s; y = z = 0; for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) if (nd < 9) y = 10*y + c - '0'; else if (nd < 16) z = 10*z + c - '0'; nd0 = nd; if (c == '.') { c = *++s; if (!nd) { for(; c == '0'; c = *++s) nz++; if (c > '0' && c <= '9') { s0 = s; nf += nz; nz = 0; goto have_dig; } goto dig_done; } for(; c >= '0' && c <= '9'; c = *++s) { have_dig: nz++; if (c -= '0') { nf += nz; for(i = 1; i < nz; i++) if (nd++ < 9) y *= 10; else if (nd <= DBL_DIG + 1) z *= 10; if (nd++ < 9) y = 10*y + c; else if (nd <= DBL_DIG + 1) z = 10*z + c; nz = 0; } } } dig_done: e = 0; if (c == 'e' || c == 'E') { if (!nd && !nz && !nz0) { s = s00; goto ret; } s00 = s; esign = 0; switch(c = *++s) { case '-': esign = 1; case '+': c = *++s; } if (c >= '0' && c <= '9') { while(c == '0') c = *++s; if (c > '0' && c <= '9') { e = c - '0'; s1 = s; while((c = *++s) >= '0' && c <= '9') e = 10*e + c - '0'; if (s - s1 > 8) /* Avoid confusion from exponents * so large that e might overflow. */ e = 9999999; if (esign) e = -e; } else e = 0; } else s = s00; } if (!nd) { if (!nz && !nz0) s = s00; goto ret; } e1 = e -= nf; /* Now we have nd0 digits, starting at s0, followed by a * decimal point, followed by nd-nd0 digits. The number we're * after is the integer represented by those digits times * 10**e */ if (!nd0) nd0 = nd; k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; rv = y; if (k > 9) rv = tens[k - 9] * rv + z; if (nd <= DBL_DIG #ifndef RND_PRODQUOT && FLT_ROUNDS == 1 #endif ) { if (!e) goto ret; if (e > 0) { if (e <= Ten_pmax) { #ifdef VAX goto vax_ovfl_check; #else /* rv = */ rounded_product(rv, tens[e]); goto ret; #endif } i = DBL_DIG - nd; if (e <= Ten_pmax + i) { /* A fancier test would sometimes let us do * this for larger i values. */ e -= i; rv *= tens[i]; #ifdef VAX /* VAX exponent range is so narrow we must * worry about overflow here... */ vax_ovfl_check: word0(rv) -= P*Exp_msk1; /* rv = */ rounded_product(rv, tens[e]); if ((word0(rv) & Exp_mask) > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) goto ovfl; word0(rv) += P*Exp_msk1; #else /* rv = */ rounded_product(rv, tens[e]); #endif goto ret; } } #ifndef Inaccurate_Divide else if (e >= -Ten_pmax) { /* rv = */ rounded_quotient(rv, tens[-e]); goto ret; } #endif } e1 += nd - k; /* Get starting approximation = rv * 10**e1 */ if (e1 > 0) { if (i = e1 & 15) rv *= tens[i]; if (e1 &= ~15) { if (e1 > DBL_MAX_10_EXP) { ovfl: errno = ERANGE; #if defined(sun) && !defined(__svr4__) /* SunOS defines HUGE_VAL as __infinity(), which is in libm. */ #undef HUGE_VAL #endif #ifndef HUGE_VAL #define HUGE_VAL 1.7976931348623157E+308 #endif rv = HUGE_VAL; goto ret; } if (e1 >>= 4) { for(j = 0; e1 > 1; j++, e1 >>= 1) if (e1 & 1) rv *= bigtens[j]; /* The last multiplication could overflow. */ word0(rv) -= P*Exp_msk1; rv *= bigtens[j]; if ((z = word0(rv) & Exp_mask) > Exp_msk1*(DBL_MAX_EXP+Bias-P)) goto ovfl; if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { /* set to largest number */ /* (Can't trust DBL_MAX) */ word0(rv) = Big0; word1(rv) = Big1; } else word0(rv) += P*Exp_msk1; } } } else if (e1 < 0) { e1 = -e1; if (i = e1 & 15) rv /= tens[i]; if (e1 &= ~15) { e1 >>= 4; for(j = 0; e1 > 1; j++, e1 >>= 1) if (e1 & 1) rv *= tinytens[j]; /* The last multiplication could underflow. */ rv0 = rv; rv *= tinytens[j]; if (!rv) { rv = 2.*rv0; rv *= tinytens[j]; if (!rv) { undfl: rv = 0.; errno = ERANGE; goto ret; } word0(rv) = Tiny0; word1(rv) = Tiny1; /* The refinement below will clean * this approximation up. */ } } } /* Now the hard part -- adjusting rv to the correct value.*/ /* Put digits into bd: true value = bd * 10^e */ bd0 = s2b(bd0, s0, nd0, nd, y); bd = Brealloc(bd, bd0->k); for(;;) { Bcopy(bd, bd0); bb = d2b(bb, rv, &bbe, &bbbits); /* rv = bb * 2^bbe */ bs = i2b(bs, 1); if (e >= 0) { bb2 = bb5 = 0; bd2 = bd5 = e; } else { bb2 = bb5 = -e; bd2 = bd5 = 0; } if (bbe >= 0) bb2 += bbe; else bd2 -= bbe; bs2 = bb2; #ifdef Sudden_Underflow #ifdef IBM j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); #else j = P + 1 - bbbits; #endif #else i = bbe + bbbits - 1; /* logb(rv) */ if (i < Emin) /* denormal */ j = bbe + (P-Emin); else j = P + 1 - bbbits; #endif bb2 += j; bd2 += j; i = bb2 < bd2 ? bb2 : bd2; if (i > bs2) i = bs2; if (i > 0) { bb2 -= i; bd2 -= i; bs2 -= i; } if (bb5 > 0) { Bigint *b_tmp; bs = pow5mult(bs, bb5); b_tmp = mult(b_avail, bs, bb); b_avail = bb; bb = b_tmp; } if (bb2 > 0) bb = lshift(bb, bb2); if (bd5 > 0) bd = pow5mult(bd, bd5); if (bd2 > 0) bd = lshift(bd, bd2); if (bs2 > 0) bs = lshift(bs, bs2); delta = diff(delta, bb, bd); dsign = delta->sign; delta->sign = 0; i = cmp(delta, bs); if (i < 0) { /* Error is less than half an ulp -- check for * special case of mantissa a power of two. */ if (dsign || word1(rv) || word0(rv) & Bndry_mask) break; delta = lshift(delta,Log2P); if (cmp(delta, bs) > 0) goto drop_down; break; } if (i == 0) { /* exactly half-way between */ if (dsign) { if ((word0(rv) & Bndry_mask1) == Bndry_mask1 && word1(rv) == 0xffffffff) { /*boundary case -- increment exponent*/ word0(rv) = (word0(rv) & Exp_mask) + Exp_msk1 #ifdef IBM | Exp_msk1 >> 4 #endif ; word1(rv) = 0; break; } } else if (!(word0(rv) & Bndry_mask) && !word1(rv)) { drop_down: /* boundary case -- decrement exponent */ #ifdef Sudden_Underflow L = word0(rv) & Exp_mask; #ifdef IBM if (L < Exp_msk1) #else if (L <= Exp_msk1) #endif goto undfl; L -= Exp_msk1; #else L = (word0(rv) & Exp_mask) - Exp_msk1; #endif word0(rv) = L | Bndry_mask1; word1(rv) = 0xffffffff; #ifdef IBM continue; #else break; #endif } #ifndef ROUND_BIASED if (!(word1(rv) & LSB)) break; #endif if (dsign) rv += ulp(rv); #ifndef ROUND_BIASED else { rv -= ulp(rv); #ifndef Sudden_Underflow if (!rv) goto undfl; #endif } #endif break; } if ((aadj = ratio(delta, bs)) <= 2.) { if (dsign) aadj = aadj1 = 1.; else if (word1(rv) || word0(rv) & Bndry_mask) { #ifndef Sudden_Underflow if (word1(rv) == Tiny1 && !word0(rv)) goto undfl; #endif aadj = 1.; aadj1 = -1.; } else { /* special case -- power of FLT_RADIX to be */ /* rounded down... */ if (aadj < 2./FLT_RADIX) aadj = 1./FLT_RADIX; else aadj *= 0.5; aadj1 = -aadj; } } else { aadj *= 0.5; aadj1 = dsign ? aadj : -aadj; #ifdef Check_FLT_ROUNDS switch(FLT_ROUNDS) { case 2: /* towards +infinity */ aadj1 -= 0.5; break; case 0: /* towards 0 */ case 3: /* towards -infinity */ aadj1 += 0.5; } #else if (FLT_ROUNDS == 0) aadj1 += 0.5; #endif } y = word0(rv) & Exp_mask; /* Check for overflow */ if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { rv0 = rv; word0(rv) -= P*Exp_msk1; adj = aadj1 * ulp(rv); rv += adj; if ((word0(rv) & Exp_mask) >= Exp_msk1*(DBL_MAX_EXP+Bias-P)) { if (word0(rv0) == Big0 && word1(rv0) == Big1) goto ovfl; word0(rv) = Big0; word1(rv) = Big1; continue; } else word0(rv) += P*Exp_msk1; } else { #ifdef Sudden_Underflow if ((word0(rv) & Exp_mask) <= P*Exp_msk1) { rv0 = rv; word0(rv) += P*Exp_msk1; adj = aadj1 * ulp(rv); rv += adj; #ifdef IBM if ((word0(rv) & Exp_mask) < P*Exp_msk1) #else if ((word0(rv) & Exp_mask) <= P*Exp_msk1) #endif { if (word0(rv0) == Tiny0 && word1(rv0) == Tiny1) goto undfl; word0(rv) = Tiny0; word1(rv) = Tiny1; continue; } else word0(rv) -= P*Exp_msk1; } else { adj = aadj1 * ulp(rv); rv += adj; } #else /* Compute adj so that the IEEE rounding rules will * correctly round rv + adj in some half-way cases. * If rv * ulp(rv) is denormalized (i.e., * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid * trouble from bits lost to denormalization; * example: 1.2e-307 . */ if (y <= (P-1)*Exp_msk1 && aadj >= 1.) { aadj1 = (double)(int)(aadj + 0.5); if (!dsign) aadj1 = -aadj1; } adj = aadj1 * ulp(rv); rv += adj; #endif } z = word0(rv) & Exp_mask; if (y == z) { /* Can we stop now? */ L = (long)aadj; aadj -= L; /* The tolerances below are conservative. */ if (dsign || word1(rv) || word0(rv) & Bndry_mask) { if (aadj < .4999999 || aadj > .5000001) break; } else if (aadj < .4999999/FLT_RADIX) break; } } Bfree(bb); Bfree(bd); Bfree(bs); Bfree(bd0); Bfree(delta); Bfree(b_avail); ret: if (se) *se = (char *)s; return sign ? -rv : rv; } static int quorem #ifdef KR_headers (b, S) Bigint *b, *S; #else (Bigint *b, Bigint *S) #endif { int n; long borrow, y; unsigned long carry, q, ys; unsigned long *bx, *bxe, *sx, *sxe; long z; unsigned long si, zs; n = S->wds; #ifdef DEBUG /*debug*/ if (b->wds > n) /*debug*/ Bug("oversize b in quorem"); #endif if (b->wds < n) return 0; sx = S->x; sxe = sx + --n; bx = b->x; bxe = bx + n; q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ #ifdef DEBUG /*debug*/ if (q > 9) /*debug*/ Bug("oversized quotient in quorem"); #endif if (q) { borrow = 0; carry = 0; do { si = *sx++; ys = (si & 0xffff) * q + carry; zs = (si >> 16) * q + (ys >> 16); carry = zs >> 16; y = (*bx & 0xffff) - (ys & 0xffff) + borrow; borrow = y >> 16; Sign_Extend(borrow, y); z = (*bx >> 16) - (zs & 0xffff) + borrow; borrow = z >> 16; Sign_Extend(borrow, z); Storeinc(bx, z, y); } while(sx <= sxe); if (!*bxe) { bx = b->x; while(--bxe > bx && !*bxe) --n; b->wds = n; } } if (cmp(b, S) >= 0) { q++; borrow = 0; carry = 0; bx = b->x; sx = S->x; do { si = *sx++; ys = (si & 0xffff) + carry; zs = (si >> 16) + (ys >> 16); carry = zs >> 16; y = (*bx & 0xffff) - (ys & 0xffff) + borrow; borrow = y >> 16; Sign_Extend(borrow, y); z = (*bx >> 16) - (zs & 0xffff) + borrow; borrow = z >> 16; Sign_Extend(borrow, z); Storeinc(bx, z, y); } while(sx <= sxe); bx = b->x; bxe = bx + n; if (!*bxe) { while(--bxe > bx && !*bxe) --n; b->wds = n; } } return q; } /* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. * * Inspired by "How to Print Floating-Point Numbers Accurately" by * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101]. * * Modifications: * 1. Rather than iterating, we use a simple numeric overestimate * to determine k = floor(log10(d)). We scale relevant * quantities using O(log2(k)) rather than O(k) multiplications. * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't * try to generate digits strictly left to right. Instead, we * compute with fewer bits and propagate the carry if necessary * when rounding the final digit up. This is often faster. * 3. Under the assumption that input will be rounded nearest, * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. * That is, we allow equality in stopping tests when the * round-nearest rule will give the same floating-point value * as would satisfaction of the stopping test with strict * inequality. * 4. We remove common factors of powers of 2 from relevant * quantities. * 5. When converting floating-point integers less than 1e16, * we use floating-point arithmetic rather than resorting * to multiple-precision integers. * 6. When asked to produce fewer than 15 digits, we first try * to get by with floating-point arithmetic; we resort to * multiple-precision integer arithmetic only if we cannot * guarantee that the floating-point calculation has given * the correctly rounded result. For k requested digits and * "uniformly" distributed input, the probability is * something like 10^(k-15) that we must resort to the long * calculation. */ char * _IO_dtoa #ifdef KR_headers (d, mode, ndigits, decpt, sign, rve) double d; int mode, ndigits, *decpt, *sign; char **rve; #else (double d, int mode, int ndigits, int *decpt, int *sign, char **rve) #endif { /* Arguments ndigits, decpt, sign are similar to those of ecvt and fcvt; trailing zeros are suppressed from the returned string. If not null, *rve is set to point to the end of the return value. If d is +-Infinity or NaN, then *decpt is set to 9999. mode: 0 ==> shortest string that yields d when read in and rounded to nearest. 1 ==> like 0, but with Steele & White stopping rule; e.g. with IEEE P754 arithmetic , mode 0 gives 1e23 whereas mode 1 gives 9.999999999999999e22. 2 ==> max(1,ndigits) significant digits. This gives a return value similar to that of ecvt, except that trailing zeros are suppressed. 3 ==> through ndigits past the decimal point. This gives a return value similar to that from fcvt, except that trailing zeros are suppressed, and ndigits can be negative. 4-9 should give the same return values as 2-3, i.e., 4 <= mode <= 9 ==> same return as mode 2 + (mode & 1). These modes are mainly for debugging; often they run slower but sometimes faster than modes 2-3. 4,5,8,9 ==> left-to-right digit generation. 6-9 ==> don't try fast floating-point estimate (if applicable). Values of mode other than 0-9 are treated as mode 0. Sufficient space is allocated to the return value to hold the suppressed trailing zeros. */ int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, spec_case, try_quick; long L; #ifndef Sudden_Underflow int denorm; #endif Bigint _b_avail, _b, _mhi, _mlo, _S; Bigint *b_avail = Binit(&_b_avail); Bigint *b = Binit(&_b); Bigint *S = Binit(&_S); /* mhi and mlo are only set and used if leftright. */ Bigint *mhi = NULL, *mlo = NULL; double d2, ds, eps; char *s, *s0; static Bigint *result = NULL; static int result_k; TEST_ENDIANNESS; if (result) { result->k = result_k; result->maxwds = 1 << result_k; result->on_stack = 0; } if (word0(d) & Sign_bit) { /* set sign for everything, including 0's and NaNs */ *sign = 1; word0(d) &= ~Sign_bit; /* clear sign bit */ } else *sign = 0; #if defined(IEEE_Arith) + defined(VAX) #ifdef IEEE_Arith if ((word0(d) & Exp_mask) == Exp_mask) #else if (word0(d) == 0x8000) #endif { /* Infinity or NaN */ *decpt = 9999; #ifdef IEEE_Arith if (!word1(d) && !(word0(d) & 0xfffff)) { s = "Infinity"; if (rve) *rve = s + 8; } else #endif { s = "NaN"; if (rve) *rve = s +3; } return s; } #endif #ifdef IBM d += 0; /* normalize */ #endif if (!d) { *decpt = 1; s = "0"; if (rve) *rve = s + 1; return s; } b = d2b(b, d, &be, &bbits); i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); #ifndef Sudden_Underflow if (i) { #endif d2 = d; word0(d2) &= Frac_mask1; word0(d2) |= Exp_11; #ifdef IBM if (j = 11 - hi0bits(word0(d2) & Frac_mask)) d2 /= 1 << j; #endif i -= Bias; #ifdef IBM i <<= 2; i += j; #endif #ifndef Sudden_Underflow denorm = 0; } else { /* d is denormalized */ unsigned long x; i = bbits + be + (Bias + (P-1) - 1); x = i > 32 ? word0(d) << 64 - i | word1(d) >> i - 32 : word1(d) << 32 - i; d2 = x; word0(d2) -= 31*Exp_msk1; /* adjust exponent */ i -= (Bias + (P-1) - 1) + 1; denorm = 1; } #endif /* Now i is the unbiased base-2 exponent. */ /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 * log10(x) = log(x) / log(10) * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) * log10(d) = i*log(2)/log(10) + log10(d2) * * This suggests computing an approximation k to log10(d) by * * k = i*0.301029995663981 * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); * * We want k to be too large rather than too small. * The error in the first-order Taylor series approximation * is in our favor, so we just round up the constant enough * to compensate for any error in the multiplication of * (i) by 0.301029995663981; since |i| <= 1077, * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, * adding 1e-13 to the constant term more than suffices. * Hence we adjust the constant term to 0.1760912590558. * (We could get a more accurate k by invoking log10, * but this is probably not worthwhile.) */ ds = (d2-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; k = (int)ds; if (ds < 0. && ds != k) k--; /* want k = floor(ds) */ k_check = 1; if (k >= 0 && k <= Ten_pmax) { if (d < tens[k]) k--; k_check = 0; } j = bbits - i - 1; if (j >= 0) { b2 = 0; s2 = j; } else { b2 = -j; s2 = 0; } if (k >= 0) { b5 = 0; s5 = k; s2 += k; } else { b2 -= k; b5 = -k; s5 = 0; } if (mode < 0 || mode > 9) mode = 0; try_quick = 1; if (mode > 5) { mode -= 4; try_quick = 0; } leftright = 1; switch(mode) { case 0: case 1: ilim = ilim1 = -1; i = 18; ndigits = 0; break; case 2: leftright = 0; /* no break */ case 4: if (ndigits <= 0) ndigits = 1; ilim = ilim1 = i = ndigits; break; case 3: leftright = 0; /* no break */ case 5: i = ndigits + k + 1; ilim = i; ilim1 = i - 1; if (i <= 0) i = 1; } /* i is now an upper bound of the number of digits to generate. */ j = sizeof(unsigned long) * (1< result->k) { Bfree (result); result = Balloc(result_k); } s = s0 = (char *)result; if (ilim >= 0 && ilim <= Quick_max && try_quick) { /* Try to get by with floating-point arithmetic. */ i = 0; d2 = d; k0 = k; ilim0 = ilim; ieps = 2; /* conservative */ if (k > 0) { ds = tens[k&0xf]; j = k >> 4; if (j & Bletch) { /* prevent overflows */ j &= Bletch - 1; d /= bigtens[n_bigtens-1]; ieps++; } for(; j; j >>= 1, i++) if (j & 1) { ieps++; ds *= bigtens[i]; } d /= ds; } else if (j1 = -k) { d *= tens[j1 & 0xf]; for(j = j1 >> 4; j; j >>= 1, i++) if (j & 1) { ieps++; d *= bigtens[i]; } } if (k_check && d < 1. && ilim > 0) { if (ilim1 <= 0) goto fast_failed; ilim = ilim1; k--; d *= 10.; ieps++; } eps = ieps*d + 7.; word0(eps) -= (P-1)*Exp_msk1; if (ilim == 0) { d -= 5.; if (d > eps) goto one_digit; if (d < -eps) goto no_digits; goto fast_failed; } #ifndef No_leftright if (leftright) { /* Use Steele & White method of only * generating digits needed. */ eps = 0.5/tens[ilim-1] - eps; for(i = 0;;) { L = (long)d; d -= L; *s++ = '0' + (int)L; if (d < eps) goto ret1; if (1. - d < eps) goto bump_up; if (++i >= ilim) break; eps *= 10.; d *= 10.; } } else { #endif /* Generate ilim digits, then fix them up. */ eps *= tens[ilim-1]; for(i = 1;; i++, d *= 10.) { L = (long)d; d -= L; *s++ = '0' + (int)L; if (i == ilim) { if (d > 0.5 + eps) goto bump_up; else if (d < 0.5 - eps) { while(*--s == '0'); s++; goto ret1; } break; } } #ifndef No_leftright } #endif fast_failed: s = s0; d = d2; k = k0; ilim = ilim0; } /* Do we have a "small" integer? */ if (be >= 0 && k <= Int_max) { /* Yes. */ ds = tens[k]; if (ndigits < 0 && ilim <= 0) { if (ilim < 0 || d <= 5*ds) goto no_digits; goto one_digit; } for(i = 1;; i++) { L = (long)(d / ds); d -= L*ds; #ifdef Check_FLT_ROUNDS /* If FLT_ROUNDS == 2, L will usually be high by 1 */ if (d < 0) { L--; d += ds; } #endif *s++ = '0' + (int)L; if (i == ilim) { d += d; if (d > ds || d == ds && L & 1) { bump_up: while(*--s == '9') if (s == s0) { k++; *s = '0'; break; } ++*s++; } break; } if (!(d *= 10.)) break; } goto ret1; } m2 = b2; m5 = b5; if (leftright) { if (mode < 2) { i = #ifndef Sudden_Underflow denorm ? be + (Bias + (P-1) - 1 + 1) : #endif #ifdef IBM 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3); #else 1 + P - bbits; #endif } else { j = ilim - 1; if (m5 >= j) m5 -= j; else { s5 += j -= m5; b5 += j; m5 = 0; } if ((i = ilim) < 0) { m2 -= i; i = 0; } } b2 += i; s2 += i; mhi = i2b(Binit(&_mhi), 1); } if (m2 > 0 && s2 > 0) { i = m2 < s2 ? m2 : s2; b2 -= i; m2 -= i; s2 -= i; } if (b5 > 0) { if (leftright) { if (m5 > 0) { Bigint *b_tmp; mhi = pow5mult(mhi, m5); b_tmp = mult(b_avail, mhi, b); b_avail = b; b = b_tmp; } if (j = b5 - m5) b = pow5mult(b, j); } else b = pow5mult(b, b5); } S = i2b(S, 1); if (s5 > 0) S = pow5mult(S, s5); /* Check for special case that d is a normalized power of 2. */ if (mode < 2) { if (!word1(d) && !(word0(d) & Bndry_mask) #ifndef Sudden_Underflow && word0(d) & Exp_mask #endif ) { /* The special case */ b2 += Log2P; s2 += Log2P; spec_case = 1; } else spec_case = 0; } /* Arrange for convenient computation of quotients: * shift left if necessary so divisor has 4 leading 0 bits. * * Perhaps we should just compute leading 28 bits of S once * and for all and pass them and a shift to quorem, so it * can do shifts and ors to compute the numerator for q. */ if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f) i = 32 - i; if (i > 4) { i -= 4; b2 += i; m2 += i; s2 += i; } else if (i < 4) { i += 28; b2 += i; m2 += i; s2 += i; } if (b2 > 0) b = lshift(b, b2); if (s2 > 0) S = lshift(S, s2); if (k_check) { if (cmp(b,S) < 0) { k--; b = multadd(b, 10, 0); /* we botched the k estimate */ if (leftright) mhi = multadd(mhi, 10, 0); ilim = ilim1; } } if (ilim <= 0 && mode > 2) { if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) { /* no digits, fcvt style */ no_digits: k = -1 - ndigits; goto ret; } one_digit: *s++ = '1'; k++; goto ret; } if (leftright) { if (m2 > 0) mhi = lshift(mhi, m2); /* Compute mlo -- check for special case * that d is a normalized power of 2. */ if (spec_case) { mlo = Brealloc(Binit(&_mlo), mhi->k); Bcopy(mlo, mhi); mhi = lshift(mhi, Log2P); } else mlo = mhi; for(i = 1;;i++) { dig = quorem(b,S) + '0'; /* Do we yet have the shortest decimal string * that will round to d? */ j = cmp(b, mlo); b_avail = diff(b_avail, S, mhi); /* b_avail = S - mi */ j1 = b_avail->sign ? 1 : cmp(b, b_avail); #ifndef ROUND_BIASED if (j1 == 0 && !mode && !(word1(d) & 1)) { if (dig == '9') goto round_9_up; if (j > 0) dig++; *s++ = dig; goto ret; } #endif if (j < 0 || j == 0 && !mode #ifndef ROUND_BIASED && !(word1(d) & 1) #endif ) { if (j1 > 0) { b = lshift(b, 1); j1 = cmp(b, S); if ((j1 > 0 || j1 == 0 && dig & 1) && dig++ == '9') goto round_9_up; } *s++ = dig; goto ret; } if (j1 > 0) { if (dig == '9') { /* possible if i == 1 */ round_9_up: *s++ = '9'; goto roundoff; } *s++ = dig + 1; goto ret; } *s++ = dig; if (i == ilim) break; b = multadd(b, 10, 0); if (mlo == mhi) mlo = mhi = multadd(mhi, 10, 0); else { mlo = multadd(mlo, 10, 0); mhi = multadd(mhi, 10, 0); } } } else for(i = 1;; i++) { *s++ = dig = quorem(b,S) + '0'; if (i >= ilim) break; b = multadd(b, 10, 0); } /* Round off last digit */ b = lshift(b, 1); j = cmp(b, S); if (j > 0 || j == 0 && dig & 1) { roundoff: while(*--s == '9') if (s == s0) { k++; *s++ = '1'; goto ret; } ++*s++; } else { while(*--s == '0'); s++; } ret: Bfree(b_avail); Bfree(S); if (mhi) { if (mlo && mlo != mhi) Bfree(mlo); Bfree(mhi); } ret1: Bfree(b); *s = 0; *decpt = k + 1; if (rve) *rve = s; return s0; } #endif /* USE_DTOA */ ./libc-linux/libio/ioperror.c100644 1676 334 4337 5547117732 14241 0ustar hjlisl/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "libioP.h" #include #ifndef errno extern int errno; #endif #if NLS #include "nl_types.h" #endif /* Also glibc? */ #ifdef __linux__ /* Print a line on stderr consisting of the text in S, a colon, a space, a message describing the meaning of the contents of `errno' and a newline. If S is NULL or "", the colon and space are omitted. */ void DEFUN(_IO_perror, (s), register CONST char *s) { int errnum = errno; CONST char *colon; #if NLS libc_nls_init(); #endif if (s == NULL || *s == '\0') s = colon = ""; else colon = ": "; if (errnum >= 0 && errnum < _sys_nerr) #if NLS (void) _IO_fprintf(_IO_stderr, "%s%s%s\n", s, colon, catgets(_libc_cat, ErrorListSet, errnum +1, (char *) _sys_errlist[errnum])); #else (void) _IO_fprintf(_IO_stderr, "%s%s%s\n", s, colon, _sys_errlist[errnum]); #endif else #if NLS (void) _IO_fprintf(_IO_stderr, "%s%s%s %d\n", s, colon, catgets(_libc_cat, ErrorListSet, 1, "Unknown error"), errnum); #else (void) _IO_fprintf(_IO_stderr, "%s%sUnknown error %d\n", s, colon, errnum); #endif } #else #include #ifndef _IO_strerror extern char* _IO_strerror __P((int)); #endif void _IO_perror (s) const char *s; { char *error = _IO_strerror (errno); if (s != NULL && *s != '\0') _IO_fprintf (_IO_stderr, "%s:", s); _IO_fprintf (_IO_stderr, "%s\n", error ? error : ""); } #endif ./libc-linux/sysdeps/ 40755 1676 334 0 5545104720 12513 5ustar hjlisl./libc-linux/sysdeps/linux/ 40755 1676 334 0 5550065404 13653 5ustar hjlisl./libc-linux/sysdeps/linux/Makefile100644 1676 334 4311 5540143105 15401 0ustar hjlisl# # Makefile for Linux specific functions # TOPDIR=../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS= -I./$(TARGET_ARCH) -I$(TOPDIR) BASE_CFLAGS:= $(BASE_CFLAGS) -DLDSO_ADDR=$(LDSO_ENTRY) ifeq ($(MATH),true) lib all: ($(MAKE) -C $(TARGET_ARCH) $@) else # the math library DIRS=$(TARGET_ARCH) SRC1S= __bsd_sig.c __flock.c __fpathconf.c __getdtsz.c \ __gethstnm.c __getpgsz.c __isatty.c __pathconf.c \ __sigblock.c __siggtmsk.c __sigpause.c __sigstmsk.c \ __sysconf.c __tcgetatr.c __utimes.c _errlist.c _siglist.c \ getdnnm.c mkfifo.c morecore.c nlist.c setegid.c \ seteuid.c signal.c \ __adjtime.c __load.c __ntpgttm.c __wait.c __wait3.c \ __waitpid.c accept.c bind.c connect.c getpeernam.c \ getsocknam.c getsockopt.c listen.c mmap.c \ shmat.c shmctl.c shmdt.c shmget.c \ msgctl.c msgget.c msgrcv.c msgsnd.c \ semctl.c semget.c semop.c \ recv.c revcfrom.c send.c sendto.c setpgrp.c setsockopt.c \ shutdown.c socket.c socketpair.c tell.c ulimit.c \ set-init.c SRC2S= __access.S __chdir.S __chmod.S __chown.S __close.S __dup.S \ __dup2.S __execve.S __fchmod.S __fchown.S __fcntl.S \ __fork.S __fstat.S __fstatfs.S __getegid.S __geteuid.S \ __getgid.S __getgrps.S __getitmr.S __getpid.S __getppid.S \ __getrusag.S __gettod.S __getuid.S __ioctl.S __kill.S \ __link.S __lseek.S __lstat.S __mkdir.S __mknod.S __open.S \ __pipe.S __read.S __readlink.S __rmdir.S __setgid.S \ __setitmr.S __setregid.S __setreuid.S __setsid.S __settod.S \ __setuid.S __sigproc.S __stat.S __statfs.S \ __symlink.S __times.S __umask.S __uname.S __unlink.S \ __wait4.S __write.S acct.S alarm.S chroot.S creat.S \ fsync.S ftruncate.S getpgrp.S getrlimit.S idle.S ioperm.S \ iopl.S mount.S munmap.S nice.S pause.S reboot.S \ rename.S setdnnm.S setgroups.S sethstnm.S setpgid.S \ setprio.S setrlimit.S sigpending.S stime.S swapoff.S \ swapon.S sync.S time.S truncate.S umount.S uselib.S \ ustat.S utime.S vhangup.S vm86.S mprotect.S \ __adjtimex.S getpgid.S __ipc.S SRC3S= fstatfs.c statfs.c uname.c __vfork.c vfork.c SRCS=$(SRC1S) $(SRC2S) $(SRC3S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.S=.s) $(SRC3S:.c=.s) OBJS= $(SRC1S:.c=.o) $(SRC2S:.S=.o) ALIASES=$(SRC3S:.c=.o) include $(TOPDIR)/Maketargets endif # the math library ./libc-linux/sysdeps/linux/__ipc.S100644 1676 334 1554 5536010050 15141 0ustar hjlisl/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include SYSCALL__ (ipc, 5) ret ./libc-linux/sysdeps/linux/msgctl.c100644 1676 334 251 5536010127 15357 0ustar hjlisl#include #define __KERNEL__ #include int msgctl (int msqid, int cmd, struct msqid_ds *buf) { return __ipc (MSGCTL, msqid, cmd, 0, buf); } ./libc-linux/sysdeps/linux/msgget.c100644 1676 334 230 5536010137 15352 0ustar hjlisl#include #define __KERNEL__ #include int msgget (key_t key, int msgflg) { return __ipc (MSGGET, key, msgflg, 0, NULL); } ./libc-linux/sysdeps/linux/msgrcv.c100644 1676 334 426 5536010154 15373 0ustar hjlisl#include #define __KERNEL__ #include int msgrcv (int msqid, struct msgbuf *msgp, int msgsz, long msgtyp, int msgflg) { struct ipc_kludge tmp; tmp.msgp = msgp; tmp.msgtyp = msgtyp; return __ipc (MSGRCV, msqid, msgsz, msgflg, &tmp); } ./libc-linux/sysdeps/linux/msgsnd.c100644 1676 334 277 5536010164 15372 0ustar hjlisl#include #define __KERNEL__ #include int msgsnd (int msqid, struct msgbuf *msgp, int msgsz, int msgflg) { return __ipc (MSGSND, msqid, msgsz, msgflg, msgp); } ./libc-linux/sysdeps/linux/semctl.c100644 1676 334 267 5536010173 15365 0ustar hjlisl#include #define __KERNEL__ #include int semctl (int semid, int semnum, int cmd, union semun arg) { return __ipc (SEMCTL, semid, semnum, cmd, &arg); } ./libc-linux/sysdeps/linux/semget.c100644 1676 334 247 5536010203 15352 0ustar hjlisl#include #define __KERNEL__ #include int semget (key_t key, int nsems, int semflg) { return __ipc (SEMGET, key, nsems, semflg, NULL); } ./libc-linux/sysdeps/linux/semop.c100644 1676 334 266 5536010213 15213 0ustar hjlisl#include #define __KERNEL__ #include int semop (int semid, struct sembuf *sops, unsigned nsops) { return __ipc (SEMOP, semid, (int) nsops, 0, sops); } ./libc-linux/sysdeps/linux/shmat.c100644 1676 334 430 5536010223 15176 0ustar hjlisl#include #define __KERNEL__ #include char * shmat (int shmid, char *shmaddr, int shmflg) { int rval; unsigned long raddr; rval = __ipc (SHMAT, shmid, shmflg, (int) &raddr, shmaddr); return rval < 0 ? (char *) rval : (char *) raddr; } ./libc-linux/sysdeps/linux/shmctl.c100644 1676 334 251 5536010231 15354 0ustar hjlisl#include #define __KERNEL__ #include int shmctl (int shmid, int cmd, struct shmid_ds *buf) { return __ipc (SHMCTL, shmid, cmd, 0, buf); } ./libc-linux/sysdeps/linux/shmdt.c100644 1676 334 212 5536010243 15201 0ustar hjlisl#include #define __KERNEL__ #include int shmdt (char *shmaddr) { return __ipc (SHMDT, 0, 0, 0, shmaddr); } ./libc-linux/sysdeps/linux/shmget.c100644 1676 334 245 5536010252 15357 0ustar hjlisl#include #define __KERNEL__ #include int shmget (key_t key, int size, int shmflg) { return __ipc (SHMGET, key, size, shmflg, NULL); } ./libc-linux/sysdeps/linux/i386/ 40755 1676 334 0 5550065404 14344 5ustar hjlisl./libc-linux/sysdeps/linux/i386/Makefile100644 1676 334 2461 5544117257 16113 0ustar hjlisl# # Makefile of Linux specific functions for i386 # TOPDIR=../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I$(TOPDIR) -I. ifeq ($(MATH),true) lib all: ($(MAKE) -C math $@) else ifneq ($(LITE),true) DIRS:=math crt endif ifeq ($(PROFILE),true) DIRS:=$(DIRS) gmon endif SRC1S = __brk.c __sbrk.c __select.c __sigact.c getprio.c \ ptrace.c readdir.c sigsuspend.c libc_exit.c \ __setfpucw.c __fpu_control.c # __load.c __adjtime.c __ntpgttm.c __wait.c __wait3.c __waitpid.c # accept.c bind.c msgget.c msgrcv.c msgsnd.c msgctl.c semget.c # semop.c semctl.c listen.c mmap.c socket.c socketpair.c tell.c # ulimit.c recv.c revcfrom.c send.c sendto.c setpgrp.c setsockopt.c # shutdown.c connect.c getpeernam.c getsocknam.c getsockopt.c # shmget.c shmat.c shmdt.c shmctl.c #SRC2S = __vfork.c vfork.c SRC3S = ____sig.S syscall.S # __adjtimex.S SRCS= $(SRC1S) $(SRC2S) $(SRC3S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) $(SRC3S:.S=.s) OBJS= $(SRC1S:.c=.o) $(SRC3S:.S=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ifeq ($(STATIC),true) LIBIEEE=$(STATIC_DIR)/libieee.a lib:: $(LIBIEEE) $(STATIC_DIR)/$(SUBDIR)/ieee.o: ieee.c $(CC) $(CFLAGS) -c $< -o $@ $(LIBIEEE): $(STATIC_DIR)/$(SUBDIR)/ieee.o $(RM) -f $(LIBIEEE) $(AR) $(AR_FLAGS) $(LIBIEEE) $? $(REALRANLIB) $(LIBIEEE) endif endif ./libc-linux/sysdeps/linux/i386/syscall.S100644 1676 334 5355 5537512407 16254 0ustar hjlisl/* Copyright (C) 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Linux takes system call arguments in registers: 0: %eax This is the system call number. 1: %ebx This is the first argument. 2: %ecx 3: %edx 4: %esi 5: %edi */ #define PUSH_0 /* No arguments to push. */ #define PUSH_1 pushl %ebx; #define PUSH_2 PUSH_1 #define PUSH_3 PUSH_1 #define PUSH_4 pushl %esi; PUSH_3 #define PUSH_5 pushl %edi; PUSH_4 #if defined(__PIC__) || defined (__pic__) #define MOVE_0 movl 8(%esp),%eax; #define MOVE_1 movl 12(%esp),%eax; movl 16(%esp),%ebx; #define MOVE_2 MOVE_1 movl 20(%esp),%ecx; #define MOVE_3 MOVE_2 movl 24(%esp),%edx; #define MOVE_4 movl 16(%esp),%eax; movl 20(%esp),%ebx; \ movl 24(%esp),%ecx; movl 28(%esp),%edx; \ movl 32(%esp),%esi; #define MOVE_5 movl 20(%esp),%eax; movl 24(%esp),%ebx; \ movl 28(%esp),%ecx; movl 32(%esp),%edx; \ movl 36(%esp),%esi; movl 40(%esp),%edi; #else #define MOVE_0 movl 4(%esp),%eax; #define MOVE_1 movl 8(%esp),%eax; movl 12(%esp),%ebx; #define MOVE_2 MOVE_1 movl 16(%esp),%ecx; #define MOVE_3 MOVE_2 movl 20(%esp),%edx; #define MOVE_4 movl 12(%esp),%eax; movl 16(%esp),%ebx; \ movl 20(%esp),%ecx; movl 24(%esp),%edx; \ movl 28(%esp),%esi; #define MOVE_5 movl 16(%esp),%eax; movl 20(%esp),%ebx; \ movl 24(%esp),%ecx; movl 28(%esp),%edx; \ movl 32(%esp),%esi; movl 36(%esp),%edi; #endif #define POP_0 /* No arguments to pop. */ #define POP_1 popl %ebx; #define POP_2 POP_1 #define POP_3 POP_1 #define POP_4 POP_3 popl %esi; #define POP_5 POP_4 popl %edi; .text #if defined(__i486__) || defined(i486) .align 4 #else .align 2 #endif .globl _syscall _syscall: PUSH_5 #if defined(__PIC__) || defined (__pic__) call L4 L4: popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-L4],%ebx pushl %ebx MOVE_5 int $0x80 popl %ebx movl %eax,%edx test %edx,%edx jge Lexit negl %edx movl _errno@GOT(%ebx),%eax movl %edx,(%eax) movl $-1,%eax #else MOVE_5 int $0x80 test %eax,%eax jge Lexit negl %eax movl %eax,_errno movl $-1,%eax #endif Lexit: POP_5 ret ./libc-linux/sysdeps/linux/i386/libc_exit.c100644 1676 334 466 5536023535 16540 0ustar hjlisl#include #include void _exit(int exit_code) { #if defined(__PIC__) || defined(__pic__) __asm__("pushl %%ebx\n\t" "movl %%ecx,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" ::"a" (SYS_exit),"c" (exit_code)); #else __asm__("int $0x80" ::"a" (SYS_exit),"b" (exit_code)); #endif } ./libc-linux/sysdeps/linux/i386/math/ 40755 1676 334 0 5550065404 15275 5ustar hjlisl./libc-linux/sysdeps/linux/i386/math/Makefile100644 1676 334 1335 5542372521 17036 0ustar hjlisl# # This is Makefile of the math lib for Linux # MATH=true override DEBUG=false override PROFILE=false TOPDIR=../../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS = -I. MATHFLAGS=-ffast-math -mieee-fp BASE_CFLAGS := $(BASE_CFLAGS) $(MATHFLAGS) SRC1S= __copysign.c __infnan.c __isinf.c __isnan.c __rint.c \ acos.c acosh.c asin.c atanh.c ceil.c erf.c floor.c frexp.c \ j0.c j1.c jn.c lgamma.c log.c log10.c log1p.c pow.c sqrt.c \ cbrt.c SRC2S= __drem.S asinh.S atan.S atan2.S cos.S cosh.S exp.S \ expm1.S fabs.S fmod.S hypot.S sin.S sinh.S tan.S tanh.S DIRS:= SRCS=$(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.S=.s) OBJS= $(SRC1S:.c=.o) $(SRC2S:.S=.o) ALIASES:= include $(TOPDIR)/Maketargets ./libc-linux/sysdeps/linux/i386/math/cbrt.c100644 1676 334 4345 5542372355 16505 0ustar hjlisl/* @(#)s_cbrt.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== * * Prototype changed for linux libc by flebbe@tat.physik.uni-tuebingen.de * 15.3.94 */ #include #include /* cbrt(x) * Return cube root of x */ #ifdef __STDC__ static const unsigned #else static unsigned #endif B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */ B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */ #ifdef __STDC__ static const double #else static double #endif C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */ D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */ E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */ F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */ G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */ double DEFUN( cbrt, (x), double x) { double one = 1.0; int n0,hx; double r,s,t=0.0,w; unsigned *pt = (unsigned *) &t, sign; n0 = ((*(int*)&one)>>29)^1; /* index of high word */ hx = *( n0 + (int*)&x); /* high word of x */ sign=hx&0x80000000; /* sign= sign(x) */ hx ^=sign; if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */ if((hx|*(1-n0+(int*)&x))==0) return(x); /* cbrt(0) is itself */ *(n0+(int*)&x) = hx; /* x <- |x| */ /* rough cbrt to 5 bits */ if(hx<0x00100000) /* subnormal number */ {pt[n0]=0x43500000; /* set t= 2**54 */ t*=x; pt[n0]=pt[n0]/3+B2; } else pt[n0]=hx/3+B1; /* new cbrt to 23 bits, may be implemented in single precision */ r=t*t/x; s=C+r*t; t*=G+F/(s+E+D/s); /* chopped to 20 bits and make it larger than cbrt(x) */ pt[1-n0]=0; pt[n0]+=0x00000001; /* one step newton iteration to 53 bits with error less than 0.667 ulps */ s=t*t; /* t*t is exact */ r=x/s; w=t+t; r=(r-t)/(w+r); /* r-s is exact */ t=t+t*r; /* retore the sign bit */ pt[n0] |= sign; return(t); } ./libc-linux/sysdeps/linux/i386/math/atanh.c100644 1676 334 2041 5542371332 16627 0ustar hjlisl/* Copyright (C) 1993 Hongjiu Lu This file is part of the Linux C Library. The Linux 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 Linux 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. */ #include #include #include double DEFUN(atanh, (x), double x) { if (x <= -1.0 ) { if (x == -1.0) { return __infnan( -ERANGE); } return __infnan( EDOM); } if (x >= 1.0 ) { if (x == 1.0) { return __infnan( ERANGE); } return __infnan( EDOM); } x = (1.0 + x) / (1.0 - x); __asm__ __volatile__ ("fldln2\n\t" "fxch %%st(1)\n\t" "fyl2x" :"=t" (x) : "0" (x)); return x * 0.5; } ./libc-linux/sysdeps/linux/__ntpgttm.c100644 1676 334 540 5535725221 16071 0ustar hjlisl#include #include #include inline static _syscall1(int, adjtimex, struct timex *, ntx); int __ntp_gettime (struct ntptimeval * ntv) { struct timex tntx; int result; result = adjtimex(&tntx); ntv->time = tntx.time; ntv->maxerror = tntx.maxerror; ntv->esterror = tntx.esterror; return result; } ./libc-linux/sysdeps/linux/__adjtime.c100644 1676 334 5057 5535725404 16044 0ustar hjlisl#include #include #include #include inline static _syscall1(int, adjtimex, struct timex *, ntx); #define SIMPLE_ADJTIME int __adjtime(struct timeval * itv, struct timeval * otv) { struct timex tntx; #ifdef SIMPLE_ADJTIME if (itv) { /* This is too big. */ if (itv->tv_sec || itv->tv_usec <= -(1 << (31 - SHIFT_UPDATE)) || itv->tv_usec >= (1 << (31 - SHIFT_UPDATE))) { errno = EINVAL; return -1; } tntx.offset = itv->tv_usec; tntx.mode = ADJ_OFFSET_SINGLESHOT; } else { tntx.mode = 0; } if (adjtimex(&tntx) < 0) return -1; #else #define SLEEP_SEC 0 #define SLEEP_USEC 200000 if (itv) { int offset, i, step; struct timeval tmp = *itv, timeout; /* This is too big. */ if (tmp.tv_sec) { step = (tmp.tv_sec > 0) ? 1 : -1; offset = (step > 0) ? 100000 : -100000; do { for (i = 0; i < 10; i++) { tntx.mode = ADJ_OFFSET_SINGLESHOT; tntx.offset = offset; if (adjtimex(&tntx) < 0) return -1; do { /* We have to sleep for a while. */ timeout.tv_sec = SLEEP_SEC; timeout.tv_usec = SLEEP_USEC; printf ("Sleep: sec: %d usec: %d\n", timeout.tv_sec, timeout.tv_usec); select(1, NULL, NULL, NULL, &timeout); tntx.mode = 0; if (adjtimex(&tntx) < 0) return -1; printf ("After sleep: to do: usec: %d\n", tntx.offset); } while (tntx.offset != 0); } tmp.tv_sec -= step; } while (tmp.tv_sec); } /* This one is too. */ if (tmp.tv_usec <= -(1 << (31 - SHIFT_UPDATE)) || tmp.tv_usec >= (1 << (31 - SHIFT_UPDATE))) { offset = (tmp.tv_usec > 0) ? 100000 : -100000; do { tntx.mode = ADJ_OFFSET_SINGLESHOT; tntx.offset = offset; if (adjtimex(&tntx) < 0) return -1; do { /* We have to sleep for a while. */ timeout.tv_sec = SLEEP_SEC; timeout.tv_usec = SLEEP_USEC; printf ("Sleep: sec: %d usec: %d\n", timeout.tv_sec, timeout.tv_usec); select(1, NULL, NULL, NULL, &timeout); tntx.mode = 0; if (adjtimex(&tntx) < 0) return -1; printf ("After sleep: to do: usec: %d\n", tntx.offset); } while (tntx.offset != 0); tmp.tv_usec -= offset; } while (tmp.tv_usec <= -(1 << (31 - SHIFT_UPDATE)) || tmp.tv_usec >= (1 << (31 - SHIFT_UPDATE))); } /* Well, we can handle that. */ tntx.mode = ADJ_OFFSET_SINGLESHOT; tntx.offset = tmp.tv_usec; } else { tntx.mode = 0; } if (adjtimex(&tntx) < 0) return -1; #endif if (otv) { otv->tv_usec = tntx.offset; otv->tv_sec = 0; } return 0; } ./libc-linux/sysdeps/linux/m68k/ 40755 1676 334 0 5550065404 14440 5ustar hjlisl./libc-linux/sysdeps/linux/m68k/Makefile100644 1676 334 2346 5544117323 16203 0ustar hjlisl# # Makefile of Linux specific functions for m68k # TOPDIR=../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I$(TOPDIR) -I. ifeq ($(MATH),true) lib all: ($(MAKE) -C math $@) else DIRS:=math crt SRC1S = __brk.c __sbrk.c __select.c __sigact.c getprio.c \ ptrace.c readdir.c sigsuspend.c syscall.c libc_exit.c \ __setfpucw.c __fpu_control.c # __load.c __adjtime.c __ntpgttm.c __wait.c __wait3.c __waitpid.c # accept.c bind.c msgget.c msgrcv.c msgsnd.c msgctl.c semget.c # semop.c semctl.c listen.c mmap.c socket.c socketpair.c tell.c # ulimit.c recv.c revcfrom.c send.c sendto.c setpgrp.c setsockopt.c # shutdown.c connect.c getpeernam.c getsocknam.c getsockopt.c # shmget.c shmat.c shmdt.c shmctl.c #SRC2S = __vfork.c vfork.c SRC3S = ____sig.S # __adjtimex.S SRCS= $(SRC1S) $(SRC2S) $(SRC3S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) $(SRC3S:.S=.s) OBJS= $(SRC1S:.c=.o) $(SRC3S:.S=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ifeq ($(STATIC),true) LIBIEEE=$(STATIC_DIR)/libieee.a lib:: $(LIBIEEE) $(STATIC_DIR)/$(SUBDIR)/ieee.o: ieee.c $(CC) $(CFLAGS) -c $< -o $@ $(LIBIEEE): $(STATIC_DIR)/$(SUBDIR)/ieee.o $(RM) -f $(LIBIEEE) $(AR) $(AR_FLAGS) $(LIBIEEE) $? $(REALRANLIB) $(LIBIEEE) endif endif ./libc-linux/sysdeps/linux/m68k/sysdep.h100644 1676 334 4524 5542403265 16224 0ustar hjlisl/* Copyright (C) 1992 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #define ENTRY(name) \ .globl _##name##; \ .align 4; \ _##name##: #define PSEUDO(name, syscall_name, args) \ .text; \ ENTRY (name) \ PUSH_##args \ moveq \#SYS_##syscall_name, d0; \ MOVE_##args \ trap \#0; \ tstl d0; \ bpl Lexit; \ negl d0; \ movel d0,_errno; \ moveq \#-1,d0; \ Lexit: \ POP_##args /* Linux takes system call arguments in registers: 1: d1 2: d2 3: d3 4: d4 5: d5 */ #define PUSH_0 /* No arguments to push. */ #define PUSH_1 /* no need to restore d1 */ #define PUSH_2 movel d2,sp@-; #define PUSH_3 movml d2-d3,sp@-; #define PUSH_4 movml d2-d4,sp@-; #define PUSH_5 movml d2-d5,sp@-; #define MOVE_0 /* No arguments to move. */ #define MOVE_1 movl sp@(4),d1; #define MOVE_2 movml sp@(8),d1-d2; #define MOVE_3 movml sp@(12),d1-d3; #define MOVE_4 movml sp@(16),d1-d4; #define MOVE_5 movml sp@(20),d1-d5; #define POP_0 /* No arguments to pop. */ #define POP_1 /* didn't save d1 */ #define POP_2 movel sp@+,d2; #define POP_3 movml sp@+,d2-d3; #define POP_4 movml sp@+,d2-d4; #define POP_5 movml sp@+,d2-d5; #define ret rts /* Linux doesn't use it. */ #if 0 #define r0 d0 #define r1 d1 #define MOVE(x,y) movel x , y #endif ./libc-linux/sysdeps/Makefile100644 1676 334 462 5540142172 14230 0ustar hjlisl# # Makefile for Linux specific functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules DIRS=$(TARGET_OS) ifneq ($(MATH),true) DIRS := $(DIRS) $(TARGET_ARCH) endif lib depend realclean clean: @for i in $(DIRS); \ do \ echo making $@ in $$i; \ ($(MAKE) -C $$i $@); \ done ./libc-linux/Makeconfig100644 1676 334 13201 5550051156 13121 0ustar hjlisl# # Makefile for the Linux C library # #.EXPORT_ALL_VARIABLES: export JUMP_DIR JUMP_LIB # # include a configuration file if one exists and ignore all the # setup stuff. # # This hack so subdirectories may include toplevel config.in include $(TOPDIR)/config.in # That is for new ld.so. Please make sure they are the same as # the one used in ld.so package. LDSO_ADDR = 62f00000 LDSO_ENTRY = "(0x$(LDSO_ADDR)+32)" ifeq ($(WHICH),) ifeq ($(PIC),true) SHARED=false DEBUG=false PROFILE=false CHECKER=false STATIC_SHARED=false WHICH=PIC PIC_AS=$(PICASDIR)/as PIC_LD=$(PICASDIR)/ld PIC_CFLAGS=-B$(PICASDIR)/ -Wa,-k -fPIC endif ifeq ($(STATIC),true) SHARED=false DEBUG=false PROFILE=false CHECKER=false STATIC_SHARED=false WHICH=STATIC endif ifeq ($(LITE),true) SHARED=true # Where we get those dll files. ifeq ($(SHLIB),) SHLIB:=libc.lite endif endif ifeq ($(SHARED),true) STATIC=false DEBUG=false PROFILE=false CHECKER=false STATIC_SHARED=false JUMP_CFLAGS=-B$(JUMPASDIR)/ ifeq ($(WHICH),) WHICH=SHARED endif endif ifeq ($(STATIC_SHARED),true) STATIC=true SHARED=true DEBUG=false PROFILE=false CHECKER=false WHICH=STATIC_SHARED endif ifeq ($(DEBUG),true) STATIC=false SHARED=false PROFILE=false CHECKER=false STATIC_SHARED=false WHICH=DEBUG endif ifeq ($(PROFILE),true) STATIC=false SHARED=false DEBUG=false CHECKER=false STATIC_SHARED=false WHICH=PROFILE endif ifeq ($(CHECKER),true) STATIC=false SHARED=false PROFILE=false DEBUG=false STATIC_SHARED=false WHICH=CHECKER endif ifeq ($(WHICH),) ifeq ($(STATIC),) STATIC=true endif ifeq ($(SHARED),) SHARED=true endif ifeq ($(PROFILE),) PROFILE=true endif ifeq ($(DEBUG),) DEBUG=true endif ifeq ($(STATIC_SHARED),) STATIC_SHARED=true endif WHICH=ALL endif endif ifeq ($(SHLIB),) # Where we get those dll files. SHLIB:=libc endif ifeq ($(JUMP_LIB),) JUMP_LIB:=libc endif ifeq ($(TARGET_ROOTDIR),/) TARGET_LIB_DIR=$(TARGET_ROOTDIR)usr/lib TARGET_SBIN_DIR=$(TARGET_ROOTDIR)sbin TARGET_SO_DIR=$(TARGET_ROOTDIR)lib TARGET_LIBM_SO_DIR=$(TARGET_ROOTDIR)lib CROSS_ROOTDIR=$(HOST_ROOTDIR) TARGET_LIBEXTRA_DIR=$(TARGET_ROOTDIR)usr/lib LDCONFIG=ldconfig else TARGET_LIB_DIR=$(TARGET_ROOTDIR)/usr/lib TARGET_SBIN_DIR=$(TARGET_ROOTDIR)/sbin TARGET_SO_DIR=$(TARGET_ROOTDIR)/lib TARGET_LIBM_SO_DIR=$(TARGET_ROOTDIR)/lib CROSS_ROOTDIR=$(HOST_ROOTDIR)/$(TARGET_MACHINE) TARGET_LIBEXTRA_DIR=$(TARGET_ROOTDIR)/extra/usr/lib LDCONFIG=true endif CROSS_INCDIR=$(CROSS_ROOTDIR)/include CROSS_BINDIR=$(CROSS_ROOTDIR)/bin DLLDIR=$(CROSS_ROOTDIR)/dll/bin JUMPASDIR=$(CROSS_ROOTDIR)/dll/jump PICASDIR=$(CROSS_ROOTDIR)/pic/bin # # Don't change anything below unless you know what you are doing. # # Pic `ld' doesn't use these options at the moment ifeq ($(PIC),) ifeq ($(TARGET_ARCH_486),true) TARGET_ARCH=i386 IX86FLAGS=-m486 IX86LDFLAGS=-m486 else ifeq ($(TARGET_ARCH),i386) IX86FLAGS=-m386 IX86LDFLAGS= endif endif endif MKDIR=mkdir -p ifneq ($(LD),true) LD=$(CROSS_BINDIR)/ld LDFLAGS=-r -x $(IX86LDFLAGS) endif ifneq ($(MV),true) MV =mv endif AR =$(CROSS_BINDIR)/ar ARFLAGS=ucv AR_FLAGS=$(ARFLAGS) AS =$(CROSS_BINDIR)/as NM =$(CROSS_BINDIR)/nm STRIP =$(CROSS_BINDIR)/strip REALRANLIB=$(CROSS_BINDIR)/ranlib RANLIB =true NEWSTDIOFLAGS=-I$(TOPDIR)/libio -I$(TOPDIR)/libio/stdio GNU_MAKE=gmake PIC_DIR=$(TOPDIR)/pic SHARED_LITE_DIR=$(TOPDIR)/shared.lite STATIC_DIR=$(TOPDIR)/static ifeq ($(LITE),true) SHARED_DIR=$(SHARED_LITE_DIR) else SHARED_DIR=$(TOPDIR)/shared endif DEBUG_DIR=$(TOPDIR)/debug PROFILE_DIR=$(TOPDIR)/profile CHECKER_DIR=$(TOPDIR)/checker # It is used for cleaning up. OBJS_DIRS=$(STATIC_DIR) $(SHARED_DIR) $(DEBUG_DIR) $(PROFILE_DIR) \ $(SHARED_LITE_DIR) $(PIC_DIR) # It is used for installation INSTALL_DIRS=$(STATIC_DIR) $(DEBUG_DIR) $(PROFILE_DIR) jump ifeq ($(MATH),true) PIC_LIB=$(PIC_DIR)/libm.a STATIC_LIB=$(STATIC_DIR)/libm.a SHARED_LIB=$(SHARED_DIR)/libm.a LIBALIAS=$(TOPDIR)/libmalias.a # Overiwrite the default values. SHLIB=libm JUMP_LIB=libm else ifeq ($(PIC_LIB),) PIC_LIB=$(PIC_DIR)/libc.a endif ifeq ($(STATIC_LIB),) STATIC_LIB=$(STATIC_DIR)/libc.a endif ifeq ($(SHARED_LIB),) SHARED_LIB=$(SHARED_DIR)/libc.a endif ifeq ($(LIBALIAS),) LIBALIAS=$(TOPDIR)/libalias.a endif endif ifneq ($(DEBUG_LIB),false) DEBUG_LIB=$(DEBUG_DIR)/libg.a endif ifneq ($(PROFILE_LIB),false) PROFILE_LIB=$(PROFILE_DIR)/libc_p.a endif JUMP_DIR:=$(TOPDIR)/jump/$(SHLIB) # The relative directory from the TOPDIR. SUBDIR=$(JUMP_LIB) #SUBDIR=$(subst $(shell cd $(TOPDIR); pwd)/,,$(shell pwd)) MKIMAGE=$(DLLDIR)/mkimage VERIFY=$(DLLDIR)/verify-shlib MKSTUBS=$(DLLDIR)/mkstubs ifneq ($(LITE),true) YP=true YPFLAGS=-DYP YPDIR=yp NLS=true NLSFLAGS=-DNLS -I$(TOPDIR)/nls NLSDIR=nls endif ifneq ($(SHADOW_COMPAT),true) SHADOWFLAGS=-DNO_SHADOW endif WFLAGS=-Wall -Wstrict-prototypes -Wmissing-prototypes CC =$(HOST_BINDIR)/gcc -V $(GCCVERSION) -b $(TARGET_MACHINE) \ $(IX86FLAGS) XCFLAGS = -D_GNU_SOURCE -DSTDC_HEADERS -DUSG -DDIRENT -DSYSV \ -DUSE_BSD_REGEX -D_LIBC # -D__USE_BSD_SIGNAL ifeq ($(PIC),) XCFLAGS+= -DHAVE_GNU_LD else XCFLAGS+= -D__PIC__ -D__pic__ endif CHARFLAGS=-funsigned-char BASE_CFLAGS= $(JUMP_CFLAGS) $(PIC_CFLAGS) $(YPFLAGS) \ $(NLSFLAGS) $(NEWSTDIOFLAGS) $(SHADOWFLAGS) \ $(SHFLAGS) $(XCFLAGS) $(WFLAGS) $(INC_CFLAGS) \ $(CHARFLAGS) ifeq ($(OPT_CFLAGS),) OPT_CFLAGS= -O6 -fomit-frame-pointer endif ifeq ($(DEBUG_OPT_CFLAGS),) DEBUG_OPT_CFLAGS=-O -g endif ifeq ($(PROFILE_OPT_CFLAGS),) PROFILE_OPT_CFLAGS=-O -pg endif ifeq ($(CHECKER_OPT_CFLAGS),) CHECKER_OPT_CFLAGS=-O -checker endif CFLAGS= $(OPT_CFLAGS) $(BASE_CFLAGS) DEBUG_CFLAGS= $(DEBUG_OPT_CFLAGS) $(BASE_CFLAGS) PROFILE_CFLAGS= $(PROFILE_OPT_CFLAGS) $(BASE_CFLAGS) CHECKER_CFLAGS= $(CHECKER_OPT_CFLAGS) $(BASE_CFLAGS) CPP =$(CC) -E $(INC_CFLAGS) # $(XCFLAGS) RM =/bin/rm ./libc-linux/Makefile100644 1676 334 5637 5544116520 12571 0ustar hjlisl# # Makefile for the Linux C library # TOPDIR=. include $(TOPDIR)/Makeconfig CLEAN_DIRS= bsd cvt ctype curses dirent gdbm grp inet io \ libio locale login malloc math misc mntent posix pwd regex \ rpc setjmp signal stdlib string sysdeps termcap time ufc \ compat gcc libbsd malloc-930716 yp $(NLSDIR) sbin jump ifeq ($(LITE),true) # for light C library without curses, gdbm DIRS = bsd cvt ctype dirent grp inet io libio locale login \ malloc-930716 misc mntent posix pwd regex rpc setjmp signal \ stdlib string sysdeps termcap time ufc compat gcc # yp else ifeq ($(CHECKER),true) DIRS= bsd cvt ctype dirent grp inet io \ libio locale login math misc mntent posix pwd regex \ rpc setjmp signal stdlib string sysdeps termcap time ufc \ gcc libbsd yp $(NLSDIR) gdbm curses else ifeq ($(PIC),true) DIRS= bsd cvt ctype dirent grp inet io \ libio locale login misc mntent posix pwd regex \ rpc setjmp signal stdlib string sysdeps time ufc \ malloc-930716 yp $(NLSDIR) else ifeq ($(MATH),true) DIRS= math sysdeps else DIRS= bsd cvt ctype curses dirent gdbm grp inet io \ libio locale login malloc math misc mntent posix pwd regex \ rpc setjmp signal stdlib string sysdeps termcap time ufc \ compat gcc libbsd malloc-930716 yp $(NLSDIR) endif endif endif endif ifeq ($(SHARED),true) DIRS:= $(DIRS) jump endif lib depend: for i in $(DIRS); do \ echo making $@ in $$i; \ (cd $$i; $(MAKE) $@); \ done ifeq ($(PIC),true) libc_pic.so: cd $(PIC_DIR) ;\ $(MKDIR) libalias ; cd libalias ;\ $(AR) x ../../libalias.a ; cd .. ;\ $(PIC_LD) -Bshareable -Bsymbolic -assert nosymbolic -o $@.1.1 libc/*.o libalias/*.o endif clean realclean: $(RM) -f core *.o *.s *.sa *.so.* *.a verify.out $(RM) -rf $(OBJS_DIRS) for i in $(CLEAN_DIRS); do \ echo making $@ in $$i; \ (cd $$i; $(MAKE) $@); \ done install: install.shared install.static install.debug install.profile install.lite: (cd jump; $(MAKE) install LITE=true) install.shared: (cd jump; $(MAKE) install) install.static: -$(AR) -d static/libc.a __.SYMDEF (cd static; $(RM) -rf tmpcopy; $(MKDIR) tmpcopy; \ cd tmpcopy; \ $(AR) -x ../../libalias.a; \ $(AR) ucv ../libc.a *.o; \ $(RM) *; \ $(AR) -x ../../libmalias.a; \ $(AR) ucv ../libm.a *.o; \ cd ..; $(RM) -rf tmpcopy; \ $(REALRANLIB) *.a; cp *.a crt0.o $(TARGET_LIB_DIR)) install.debug: -$(AR) -d debug/libg.a __.SYMDEF (cd debug; $(RM) -rf tmpcopy; $(MKDIR) tmpcopy; \ cd tmpcopy; \ $(AR) -x ../../libalias.a; \ $(AR) ucv ../libg.a *.o; \ cd ..; $(RM) -rf tmpcopy; \ $(REALRANLIB) *.a; \ cp *.a $(TARGET_LIBEXTRA_DIR); \ cp libc/mcheck-init.o $(TARGET_LIBEXTRA_DIR)/libmcheck.a) install.profile: -$(AR) -d profile/libc_p.a __.SYMDEF (cd profile; $(RM) -rf tmpcopy; $(MKDIR) tmpcopy; \ cd tmpcopy; \ $(AR) -x ../../libalias.a; \ $(AR) ucv ../libc_p.a *.o; \ cd ..; $(RM) -rf tmpcopy; \ $(REALRANLIB) *.a; cp *.a gcrt0.o $(TARGET_LIBEXTRA_DIR)) install.checker: (cd checker; $(MAKE) install) ./libc-linux/Makerules100644 1676 334 10027 5540146425 13014 0ustar hjlisl.SUFFIXES: .SUFFIXES: .S .o .c .s .i .C .cc .s.o: $(CC) $(CFLAGS) -c $< .S.o: $(CC) $(CFLAGS) -c $< .c.o: ifeq ($(PIC),true) $(CC) $(CFLAGS) -c $< else ifeq ($(SHARED),true) $(CC) $(CFLAGS) -c $< else ifeq ($(STATIC),true) $(CC) $(CFLAGS) -c $< else ifeq ($(DEBUG),true) $(CC) $(DEBUG_CFLAGS) -c $< else ifeq ($(PROFILE),true) $(CC) $(PROFILE_CFLAGS) -c $< else ifeq ($(CHECKER),true) $(CC) $(CHECKER_CFLAGS) -c $< else $(CC) $(CFLAGS) -c $< endif endif endif endif endif endif .cc.o: ifeq ($(PIC),true) $(CC) $(CFLAGS) -c $< else ifeq ($(SHARED),true) $(CC) $(CFLAGS) -c $< else ifeq ($(STATIC),true) $(CC) $(CFLAGS) -c $< else ifeq ($(DEBUG),true) $(CC) $(DEBUG_CFLAGS) -c $< else ifeq ($(PROFILE),true) $(CC) $(PROFILE_CFLAGS) -c $< else ifeq ($(CHECKER),true) $(CC) $(CHECKER_CFLAGS) -c $< else $(CC) $(CFLAGS) -c $< endif endif endif endif endif endif .S.s: $(CC) $(CFLAGS) -E $< -o $*.s .c.s: ifeq ($(PIC),true) $(CC) $(CFLAGS) -S $< else ifeq ($(SHARED),true) $(CC) $(CFLAGS) -S $< else ifeq ($(STATIC),true) $(CC) $(CFLAGS) -S $< else ifeq ($(DEBUG),true) $(CC) $(DEBUG_CFLAGS) -S $< else ifeq ($(PROFILE),true) $(CC) $(PROFILE_CFLAGS) -S $< else ifeq ($(CHECKER),true) $(CC) $(CHECKER_CFLAGS) -S $< else $(CC) $(CFLAGS) -S $< endif endif endif endif endif endif .cc.s: ifeq ($(PIC),true) $(CC) $(CFLAGS) -S $< else ifeq ($(SHARED),true) $(CC) $(CFLAGS) -S $< else ifeq ($(STATIC),true) $(CC) $(CFLAGS) -S $< else ifeq ($(DEBUG),true) $(CC) $(DEBUG_CFLAGS) -S $< else ifeq ($(PROFILE),true) $(CC) $(PROFILE_CFLAGS) -S $< else ifeq ($(CHECKER),true) $(CC) $(CHECKER_CFLAGS) -S $< else $(CC) $(CFLAGS) -S $< endif endif endif endif endif endif .c.i .cc.i: $(CC) $(CFLAGS) -E $< -o $*.i .C.o: $(CC) $(CFLAGS) $(NOSTDINC) -I../iostream -I../../iostream $(WRAP_C_INCLUDES) -c $(XTRAFLAGS) $< ifeq ($(STATIC_SHARED),true) # We don't want the default archive rule. (%): % $(AR) $(ARFLAGS) $@ $^ $(RM) $^ $(STATIC_DIR)/$(SUBDIR)/%.o $(SHARED_DIR)/$(SUBDIR)/%.o: %.c $(CC) $(CFLAGS) -S $< $(JUMPASDIR)/as -o $(SHARED_DIR)/$(SUBDIR)/$*.o $*.s ifneq ($(LD),true) $(LD) -o $(SHARED_DIR)/$(SUBDIR)/a.out $(LDFLAGS) \ $(SHARED_DIR)/$(SUBDIR)/$*.o endif ifneq ($(MV),true) $(MV) $(SHARED_DIR)/$(SUBDIR)/a.out \ $(SHARED_DIR)/$(SUBDIR)/$*.o endif $(AS) -o $(STATIC_DIR)/$(SUBDIR)/$*.o $*.s ifneq ($(LD),true) $(LD) -o $(STATIC_DIR)/$(SUBDIR)/a.out $(LDFLAGS) \ $(STATIC_DIR)/$(SUBDIR)/$*.o endif ifneq ($(MV),true) $(MV) $(STATIC_DIR)/$(SUBDIR)/a.out \ $(STATIC_DIR)/$(SUBDIR)/$*.o endif @$(RM) $*.s $(STATIC_DIR)/$(SUBDIR)/%.o $(SHARED_DIR)/$(SUBDIR)/%.o \ $(DEBUG_DIR)/$(SUBDIR)/%.o $(PROFILE_DIR)/$(SUBDIR)/%.o: %.S $(CC) $(CFLAGS) -E $< -o $*.s $(JUMPASDIR)/as -o $(SHARED_DIR)/$(SUBDIR)/$*.o $*.s $(AS) -o $(STATIC_DIR)/$(SUBDIR)/$*.o $*.s ifeq ($(DEBUG),true) cp $(STATIC_DIR)/$(SUBDIR)/$*.o $(DEBUG_DIR)/$(SUBDIR) endif ifeq ($(PROFILE),true) cp $(STATIC_DIR)/$(SUBDIR)/$*.o $(PROFILE_DIR)/$(SUBDIR) endif @$(RM) $*.s else $(STATIC_DIR)/$(SUBDIR)/%.o $(SHARED_DIR)/$(SUBDIR)/%.o \ $(STATIC_DIR)/%.o $(PROFILE_DIR)/%.o \ $(DEBUG_DIR)/$(SUBDIR)/%.o $(PROFILE_DIR)/$(SUBDIR)/%.o: %.S $(CC) $(CFLAGS) -c $< -o $@ $(STATIC_DIR)/$(SUBDIR)/%.o $(SHARED_DIR)/$(SUBDIR)/%.o: %.c $(CC) $(CFLAGS) -c $< -o $@ ifneq ($(LD),true) $(LD) -o $(@D)a.out $(LDFLAGS) $@ endif ifneq ($(MV),true) $(MV) $(@D)a.out $@ endif endif ifeq ($(PIC), true) $(PIC_DIR)/$(SUBDIR)/%.o: %.c $(CC) $(CFLAGS) -c $< -o $@ ifneq ($(LD),true) $(PIC_LD) -o $(PIC_DIR)/$(SUBDIR)/a.out $(LDFLAGS) \ $(PIC_DIR)/$(SUBDIR)/$*.o endif ifneq ($(MV),true) $(MV) $(PIC_DIR)/$(SUBDIR)/a.out \ $(PIC_DIR)/$(SUBDIR)/$*.o endif $(PIC_DIR)/$(SUBDIR)/%.o: %.S $(CC) $(CFLAGS) -c $< -o $@ endif ifeq ($(DEBUG),true) $(DEBUG_DIR)/$(SUBDIR)/%.o: %.c $(CC) $(DEBUG_CFLAGS) -c $< -o $@ endif ifeq ($(PROFILE),true) $(PROFILE_DIR)/$(SUBDIR)/%.o: %.c $(CC) $(PROFILE_CFLAGS) -c $< -o $@ endif ifeq ($(CHECKER),true) $(CHECKER_DIR)/$(SUBDIR)/%.o: %.c $(CC) $(CHECKER_CFLAGS) -c $< -o $@ $(CHECKER_DIR)/$(SUBDIR)/%.o $(CHECKER_DIR)/%.o: %.S $(CC) $(CHECKER_CFLAGS) -c $< -o $@ endif ./libc-linux/Maketargets100644 1676 334 10332 5540141756 13334 0ustar hjlisl# # common targets # STATIC_OBJS= SHARED_OBJS= DEBUG_OBJS= PROFILE_OBJS= #ifeq ($(SPEED),fast) #.PHONY: $(STATIC_LIB) $(SHARED_LIB) $(DEBUG_LIB) $(PROFILE_LIB) \ # $(LIBALIAS) #endif ifeq (true,false) lib:: ifeq ($(PIC),true) @if [ -d $(PIC_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(PIC_DIR)/$(SUBDIR); \ $(MKDIR) $(PIC_DIR)/$(SUBDIR); \ fi endif ifeq ($(STATIC),true) @if [ -d $(STATIC_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(STATIC_DIR)/$(SUBDIR); \ $(MKDIR) $(STATIC_DIR)/$(SUBDIR); \ fi endif ifeq ($(SHARED),true) @if [ -d $(SHARED_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(SHARED_DIR)/$(SUBDIR); \ $(MKDIR) $(SHARED_DIR)/$(SUBDIR); \ fi endif ifeq ($(DEBUG),true) @if [ -d $(DEBUG_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(DEBUG_DIR)/$(SUBDIR); \ $(MKDIR) $(DEBUG_DIR)/$(SUBDIR); \ fi endif ifeq ($(PROFILE),true) @if [ -d $(PROFILE_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(PROFILE_DIR)/$(SUBDIR); \ $(MKDIR) $(PROFILE_DIR)/$(SUBDIR); \ fi endif else lib:: @if [ -d $(PIC_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(PIC_DIR)/$(SUBDIR); \ $(MKDIR) $(PIC_DIR)/$(SUBDIR); \ fi @if [ -d $(STATIC_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(STATIC_DIR)/$(SUBDIR); \ $(MKDIR) $(STATIC_DIR)/$(SUBDIR); \ fi @if [ -d $(SHARED_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(SHARED_DIR)/$(SUBDIR); \ $(MKDIR) $(SHARED_DIR)/$(SUBDIR); \ fi @if [ -d $(DEBUG_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(DEBUG_DIR)/$(SUBDIR); \ $(MKDIR) $(DEBUG_DIR)/$(SUBDIR); \ fi @if [ -d $(PROFILE_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(PROFILE_DIR)/$(SUBDIR); \ $(MKDIR) $(PROFILE_DIR)/$(SUBDIR); \ fi endif ifeq ($(PIC),true) PIC_OBJS:= $(addprefix $(PIC_DIR)/$(SUBDIR)/, $(OBJS)) ifeq ($(SPEED),fast) .PHONY: $(STATIC_LIB) lib:: $(PIC_OBJS) $(PIC_LIB) $(PIC_LIB): $(PIC_OBJS) $(AR) $(ARFLAGS) $@ $^ else lib:: $(PIC_LIB)($(PIC_OBJS)) endif endif ifeq ($(STATIC),true) STATIC_OBJS:= $(addprefix $(STATIC_DIR)/$(SUBDIR)/, $(OBJS)) ifeq ($(SPEED),fast) .PHONY: $(STATIC_LIB) lib:: $(STATIC_OBJS) $(STATIC_LIB) $(STATIC_LIB): $(STATIC_OBJS) $(AR) $(ARFLAGS) $@ $^ else lib:: $(STATIC_LIB)($(STATIC_OBJS)) endif endif ifeq ($(SHARED),true) SHARED_OBJS:= $(addprefix $(SHARED_DIR)/$(SUBDIR)/, $(OBJS)) ifeq ($(SPEED),fast) .PHONY: $(SHARED_LIB) lib:: $(SHARED_OBJS) $(SHARED_LIB) $(SHARED_LIB): $(SHARED_OBJS) $(AR) $(ARFLAGS) $@ $^ else lib:: $(SHARED_LIB)($(SHARED_OBJS)) endif endif ifeq ($(DEBUG),true) DEBUG_OBJS:= $(addprefix $(DEBUG_DIR)/$(SUBDIR)/, $(OBJS)) ifeq ($(SPEED),fast) .PHONY: $(DEBUG_LIB) lib:: $(DEBUG_OBJS) $(DEBUG_LIB) $(DEBUG_LIB): $(DEBUG_OBJS) $(AR) $(ARFLAGS) $@ $^ else lib:: $(DEBUG_LIB)($(DEBUG_OBJS)) endif endif ifeq ($(PROFILE),true) .PHONY: $(PROFILE_LIB) PROFILE_OBJS:= $(addprefix $(PROFILE_DIR)/$(SUBDIR)/, $(OBJS)) ifeq ($(SPEED),fast) lib:: $(PROFILE_OBJS) $(PROFILE_LIB) $(PROFILE_LIB): $(PROFILE_OBJS) $(AR) $(ARFLAGS) $@ $^ else lib:: $(PROFILE_LIB)($(PROFILE_OBJS)) endif endif ifeq ($(CHECKER),true) .PHONY: $(CHECKER_LIB) CHECKER_OBJS:= $(addprefix $(CHECKER_DIR)/$(SUBDIR)/, $(OBJS)) ifeq ($(SPEED),fast) lib:: $(CHECKER_OBJS) $(CHECKER_LIB) $(CHECKER_LIB): $(CHECKER_OBJS) $(AR) $(ARFLAGS) $@ $^ else lib:: $(CHECKER_LIB)($(CHECKER_OBJS)) endif endif ifneq ($(ALIASES),) ifeq ($(SPEED),fast) .PHONY: $(LIBALIAS) lib:: $(ALIASES) $(LIBALIAS) $(LIBALIAS): $(ALIASES) $(AR) $(ARFLAGS) $@ $^ else lib:: $(LIBALIAS)($(ALIASES)) endif endif obj: $(OBJS) asm: $(ASMS) realclean:: $(RM) -f .depend core *.o *.a *.s *.i tmp_make foo # $(MAKE) subdir TARGET=realclean clean:: $(RM) -f core *.o *.a *.s *.i tmp_make foo # $(MAKE) subdir TARGET=clean depend:: $(CC) $(CFLAGS) -M $(SRCS) | \ sed -e 's,^[ ]*\(.*.o\)[ ]*:,$(STATIC_DIR)/$(SUBDIR)/\1 $(SHARED_DIR)/$(SUBDIR)/\1 $(SHARED_LITE_DIR)/$(SUBDIR)/\1 $(DEBUG_DIR)/$(SUBDIR)/\1 $(PROFILE_DIR)/$(SUBDIR)/\1 $(CHECKER_DIR)/$(SUBDIR)/\1:,' > .depend # $(MAKE) subdir TARGET=depend ifneq ($(DIRS),) lib realclean clean depend:: @for i in $(DIRS); do \ echo making $@ in $$i; \ ($(MAKE) -C $$i $@); \ done; endif # # include a dependency file if one exists # ifeq (.depend,$(wildcard .depend)) include .depend endif ./libc-linux/inet/ 40755 1676 334 0 5567152204 11764 5ustar hjlisl./libc-linux/inet/res_send.c100644 1676 334 23606 5534714565 14066 0ustar hjlisl/* * Copyright (c) 1985, 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that: (1) source distributions retain this entire copyright * notice and comment, and (2) distributions including binaries display * the following acknowledgement: ``This product includes software * developed by the University of California, Berkeley and its contributors'' * in the documentation or other materials provided with the distribution * and in all advertising materials mentioning features or use of this * software. Neither the name of the University nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_send.c 6.25 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ /* * Send query to name server and wait for reply. */ #include "inetprivate.h" extern int errno; static int s = -1; /* socket used for communications */ static int restarting = 0; static struct sockaddr no_addr; #ifndef FD_SET #define NFDBITS 32 #define FD_SETSIZE 32 #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) #endif int res_send(buf, buflen, answer, anslen) const char *buf; int buflen; char *answer; int anslen; { register int n; int try, v_circuit, resplen, ns; int gotsomewhere = 0, connected = 0; int connreset = 0; u_short id, len; char *cp; fd_set dsmask; struct timeval timeout; HEADER *hp = (HEADER *) buf; HEADER *anhp = (HEADER *) answer; struct iovec iov[2]; int terrno = ETIMEDOUT; char junk[512]; #ifdef DEBUG if (_res.options & RES_DEBUG) { printf("res_send()\n"); p_query(buf); } #endif DEBUG if (!(_res.options & RES_INIT)) if (res_init() == -1) { return(-1); } v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ; id = hp->id; /* * Send request, RETRY times, or until successful */ for (try = 0; try < _res.retry; try++) { for (ns = 0; ns < _res.nscount; ns++) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("Querying server (# %d) address = %s\n", ns+1, inet_ntoa(_res.nsaddr_list[ns].sin_addr)); #endif DEBUG usevc: if (v_circuit) { int truncated = 0; /* * Use virtual circuit; * at most one attempt per server. */ try = _res.retry; if(restarting && s >= 0) { (void)close (s); s = -1; restarting = 0; } if (s < 0) { s = socket(AF_INET, SOCK_STREAM, 0); if (s < 0) { terrno = errno; #ifdef DEBUG if (_res.options & RES_DEBUG) perror("socket (vc) failed"); #endif DEBUG continue; } if (connect(s, (struct sockaddr *)&(_res.nsaddr_list[ns]), sizeof(struct sockaddr)) < 0) { terrno = errno; #ifdef DEBUG if (_res.options & RES_DEBUG) perror("connect failed"); #endif DEBUG (void) close(s); s = -1; continue; } } /* * Send length & message */ restarting = 1; len = htons((u_short)buflen); iov[0].iov_base = (caddr_t)&len; iov[0].iov_len = sizeof(len); iov[1].iov_base = buf; iov[1].iov_len = buflen; if (writev(s, iov, 2) != sizeof(len) + buflen) { terrno = errno; #ifdef DEBUG if (_res.options & RES_DEBUG) perror("write failed"); #endif DEBUG (void) close(s); s = -1; restarting = 0; continue; } /* * Receive length & response */ cp = answer; len = sizeof(short); while (len != 0 && (n = read(s, (char *)cp, (int)len)) > 0) { cp += n; len -= n; } if (n <= 0) { terrno = errno; #ifdef DEBUG if (_res.options & RES_DEBUG) perror("read failed"); #endif DEBUG (void) close(s); s = -1; restarting = 0; /* * A long running process might get its TCP * connection reset if the remote server was * restarted. Requery the server instead of * trying a new one. When there is only one * server, this means that a query might work * instead of failing. We only allow one reset * per query to prevent looping. */ if (terrno == ECONNRESET && !connreset) { connreset = 1; ns--; } continue; } cp = answer; if ((resplen = ntohs(*(u_short *)cp)) > anslen) { #ifdef DEBUG if (_res.options & RES_DEBUG) fprintf(stderr, "response truncated\n"); #endif DEBUG len = anslen; truncated = 1; } else len = resplen; while (len != 0 && (n = read(s, (char *)cp, (int)len)) > 0) { cp += n; len -= n; } if (n <= 0) { terrno = errno; #ifdef DEBUG if (_res.options & RES_DEBUG) perror("read failed"); #endif DEBUG (void) close(s); s = -1; restarting = 0; continue; } if (truncated) { /* * Flush rest of answer * so connection stays in synch. */ anhp->tc = 1; len = resplen - anslen; while (len != 0) { n = (len > sizeof(junk) ? sizeof(junk) : len); if ((n = read(s, junk, n)) > 0) len -= n; else break; } } restarting = 0; } else { /* * Use datagrams. */ if (s < 0) { s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) { terrno = errno; #ifdef DEBUG if (_res.options & RES_DEBUG) perror("socket (dg) failed"); #endif DEBUG continue; } } #if BSD >= 43 /* * I'm tired of answering this question, so: * On a 4.3BSD+ machine (client and server, * actually), sending to a nameserver datagram * port with no nameserver will cause an * ICMP port unreachable message to be returned. * If our datagram socket is "connected" to the * server, we get an ECONNREFUSED error on the next * socket operation, and select returns if the * error message is received. We can thus detect * the absence of a nameserver without timing out. * If we have sent queries to at least two servers, * however, we don't want to remain connected, * as we wish to receive answers from the first * server to respond. */ if (_res.nscount == 1 || (try == 0 && ns == 0)) { /* * Don't use connect if we might * still receive a response * from another server. */ if (connected == 0) { if (connect(s, &_res.nsaddr_list[ns], sizeof(struct sockaddr)) < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) perror("connect"); #endif DEBUG continue; } connected = 1; } if (send(s, buf, buflen, 0) != buflen) { #ifdef DEBUG if (_res.options & RES_DEBUG) perror("send"); #endif DEBUG continue; } } else { /* * Disconnect if we want to listen * for responses from more than one server. */ if (connected) { (void) connect(s, &no_addr, sizeof(no_addr)); connected = 0; } #endif BSD if (sendto(s, buf, buflen, 0, (struct sockaddr *)&_res.nsaddr_list[ns], sizeof(struct sockaddr)) != buflen) { #ifdef DEBUG if (_res.options & RES_DEBUG) perror("sendto"); #endif DEBUG continue; } #if BSD >= 43 } #endif /* * Wait for reply */ timeout.tv_sec = (_res.retrans << try); if (try > 0) timeout.tv_sec /= _res.nscount; if (timeout.tv_sec <= 0) timeout.tv_sec = 1; timeout.tv_usec = 0; wait: FD_ZERO(&dsmask); FD_SET(s, &dsmask); n = select(s+1, &dsmask, (fd_set *)NULL, (fd_set *)NULL, &timeout); if (n < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) perror("select"); #endif DEBUG continue; } if (n == 0) { /* * timeout */ #ifdef DEBUG if (_res.options & RES_DEBUG) printf("timeout\n"); #endif DEBUG #if BSD >= 43 gotsomewhere = 1; #endif continue; } if ((resplen = recv(s, answer, anslen, 0)) <= 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) perror("recvfrom"); #endif DEBUG continue; } gotsomewhere = 1; if (id != anhp->id) { /* * response from old query, ignore it */ #ifdef DEBUG if (_res.options & RES_DEBUG) { printf("old answer:\n"); p_query(answer); } #endif DEBUG goto wait; } if (!(_res.options & RES_IGNTC) && anhp->tc) { /* * get rest of answer; * use TCP with same server. */ #ifdef DEBUG if (_res.options & RES_DEBUG) printf("truncated answer\n"); #endif DEBUG (void) close(s); s = -1; v_circuit = 1; goto usevc; } } #ifdef DEBUG if (_res.options & RES_DEBUG) { printf("got answer:\n"); p_query(answer); } #endif DEBUG /* * If using virtual circuits, we assume that the first server * is preferred * over the rest (i.e. it is on the local * machine) and only keep that one open. * If we have temporarily opened a virtual circuit, * or if we haven't been asked to keep a socket open, * close the socket. */ if ((v_circuit && ((_res.options & RES_USEVC) == 0 || ns != 0)) || (_res.options & RES_STAYOPEN) == 0) { (void) close(s); s = -1; } return (resplen); } } if (s >= 0) { (void) close(s); s = -1; } if (v_circuit == 0) if (gotsomewhere == 0) errno = ECONNREFUSED; /* no nameservers found */ else errno = ETIMEDOUT; /* no answer obtained */ else errno = terrno; return (-1); } /* * This routine is for closing the socket if a virtual circuit is used and * the program wants to close it. This provides support for endhostent() * which expects to close the socket. * * This routine is not expected to be user visible. */ void _res_close() { if (s != -1) { (void) close(s); s = -1; } } ./libc-linux/inet/gethstnmad.c100644 1676 334 77653 5547117740 14431 0ustar hjlisl/* * Copyright (c) 1985, 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)gethostnamadr.c 6.39 (Berkeley) 1/4/90"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" #include #define MAXALIASES 35 #define MAXADDRS 35 #define MAXTRIMDOMAINS 4 #define _PATH_HOSTCONF __PATH_ETC_INET"/host.conf" /* Strict but flexible checking in _PATH_HOSTCONF file. * (+) Keywords need not start at the begining of the line. * (+) Invalid keywords are warned. * (+) Invalid booleans (other than "on" or "off") are warned. * Mitch DSouza - 30th October 1993 */ #define STRICT #define SERVICE_NONE 0 #define SERVICE_BIND 1 #define SERVICE_HOSTS 2 #define SERVICE_NIS 3 #define SERVICE_MAX 3 #define CMD_ORDER "order" #define CMD_TRIMDOMAIN "trim" #define CMD_HMA "multi" #define CMD_SPOOF "nospoof" #define CMD_SPOOFALERT "alert" #define CMD_REORDER "reorder" #define CMD_ON "on" #define CMD_OFF "off" #define CMD_WARN "warn" #define CMD_NOWARN "warn off" #define ORD_BIND "bind" #define ORD_HOSTS "hosts" #define ORD_NIS "nis" #define ENV_HOSTCONF "RESOLV_HOST_CONF" #define ENV_SERVORDER "RESOLV_SERV_ORDER" #define ENV_SPOOF "RESOLV_SPOOF_CHECK" #define ENV_TRIM_OVERR "RESOLV_OVERRIDE_TRIM_DOMAINS" #define ENV_TRIM_ADD "RESOLV_ADD_TRIM_DOMAINS" #define ENV_HMA "RESOLV_MULTI" #define ENV_REORDER "RESOLV_REORDER" #define TOKEN_SEPARATORS " ,;:" static int service_order[SERVICE_MAX + 1]; static int service_done = 0; static char *h_addr_ptrs[MAXADDRS + 1]; static struct hostent host; static char *host_aliases[MAXALIASES]; static char hostbuf[BUFSIZ+1]; static struct in_addr host_addr; static char HOSTDB[] = _PATH_HOSTS; static FILE *hostf = NULL; static char hostaddr[MAXADDRS]; static char *host_addrs[2]; static int stayopen = 0; static int hosts_multiple_addrs = 0; static int spoof = 0; static int spoofalert = 0; static int reorder = 0; static char *trimdomain[MAXTRIMDOMAINS]; static char trimdomainbuf[BUFSIZ]; static int numtrimdomains = 0; #ifdef NIS static struct hostent *_getnishost(); #endif #if PACKETSZ > 1024 #define MAXPACKET PACKETSZ #else #define MAXPACKET 1024 #endif typedef union { HEADER hdr; u_char buf[MAXPACKET]; } querybuf; typedef union { long al; char ac; } align; #ifdef SHLIB extern int h_errno; #else extern int h_errno; #endif extern int errno; #if NLS #include "nl_types.h" #endif static void dotrimdomain(c) char *c; { /* assume c points to the start of a host name; trim off any domain name matching any of the trimdomains */ int d,l1,l2; for(d=0;dl1 && !strcasecmp(c+l2-l1,trimdomain[d])) *(c+(strlen(c)-l1))='\0'; } } static struct hostent * trim_domains(h) struct hostent *h; { if(numtrimdomains){ int i; dotrimdomain(h->h_name); for(i=0;h->h_aliases[i];i++) dotrimdomain(h->h_aliases[i]); } return(h); } #if NLS #define bad_config_format(cmd) \ fprintf(stderr, catgets(_libc_cat, NetMiscSet, \ NetMiscResolvIncorrectFormat, \ "resolv+: %s: \"%s\" command incorrectly formatted.\n"), \ hostconf, cmd); #else #define bad_config_format(cmd) \ fprintf(stderr, "resolv+: %s: \"%s\" command incorrectly formatted.\n", hostconf, cmd); #endif /* static void debug_breakout(x) long x; { register int a, b, c, d; d = x & 255; x >>= 8; c = x & 255; x >>= 8; b = x & 255; x >>= 8; a = x & 255; x >>= 8; fprintf(stderr, "resolv+: %d.%d.%d.%d", a,b,c,d ); return; } */ /* reorder_addrs -- by Tom Limoncelli Optimize order of an address list. gethostbyaddr() usually returns a list of addresses in some arbitrary order. Most programs use the first one and throw the rest away. This routine attempts to find a "best" address and swap it into the first position in the list. "Best" is defined as "an address that is on a local subnet". The search ends after one "best" address is found. If no "best" address is found, nothing is changed. On first execution, a table is built of interfaces, netmasks, and mask'ed addresses. This is to speed up future queries but may require you to reboot after changing internet addresses. (doesn't everyone reboot after changing internet addresses?) This routine should not be called if gethostbyaddr() is about to return only one address. */ /* Hal Stern (June 1992) of Sun claimed that more than 4 ethernets in a Sun 4/690 would not work. This variable is set to 10 to accomodate our version of reality */ #define MAXINTERFACES (10) static void reorder_addrs(h) struct hostent *h; { static struct { char iname[16]; u_long address, netmask; } itab[MAXINTERFACES], *itp; static numitab = -1; /* number of used entries in itab */ register struct in_addr **r; /* pointer to entry in address list */ struct in_addr tmp; /* pointer to entry in address list */ register int cnt; /*** itab[] contains masked addresses and netmask of each interface. numitab is -1 : table is empty. numitab is 0 : should never happen. numitab is 1,2,3,... : number of valid entries in the table. ***/ if (!numitab || h==NULL) return; /* no entries in table */ if (numitab==-1) { /* build the table */ int fd, err; struct ifconf ifs; struct ifreq ifbuf[MAXINTERFACES], *p; register struct sockaddr_in *q; u_long address, netmask; int endp; /* open a socket */ fd = socket(PF_INET, SOCK_STREAM, 0); if (fd==-1) return; /**** get information about the first MAXINTERFACES interfaces ****/ /* set up the ifconf structure */ ifs.ifc_len = MAXINTERFACES * sizeof(struct ifreq); ifs.ifc_buf = (caddr_t) ifbuf; /* get a list of interfaces */ err = ioctl(fd, SIOCGIFCONF, &ifs); if (err == -1) return; /**** cycle through each interface & get netmask & address ****/ endp = ifs.ifc_len / sizeof(struct ifreq); itp = itab; for (p = ifs.ifc_req; endp; p++, endp--) { strcpy( itp->iname , p->ifr_name); /* copy interface name */ err = ioctl(fd, SIOCGIFNETMASK, p); /* get netmask */ if (err == -1) continue; /* error? skip this interface */ q = (struct sockaddr_in *) &(p->ifr_addr); if (q->sin_family == AF_INET) netmask=q->sin_addr.s_addr; else continue; /* not internet protocol? skip this interface */ err = ioctl(fd, SIOCGIFADDR, p); /* get address */ if (err == -1) continue; /* error? skip this interface */ q = (struct sockaddr_in *) &(p->ifr_addr); if (q->sin_family == AF_INET) address=q->sin_addr.s_addr; else continue; /* not internet protocol? skip this interface */ /* store the masked address and netmask in the table */ address = address & netmask; /* pre-mask the address */ if (!address) continue; /* funny address? skip this interface */ itp->address = address; itp->netmask = netmask; if (numitab == -1) numitab = 0; /* first time through */ itp++; numitab++; } /**** clean up ****/ close(fd); /**** if we still don't have a table, leave */ if (!numitab) return; } /**** loop through table for each (address,interface) combo ****/ for ( r = (struct in_addr **) (h->h_addr_list); r && *r; r++) { /* loop through the addresses */ for ( itp = itab, cnt=numitab; cnt; itp++,cnt--) { /* loop though the interfaces */ if (( (*r)->s_addr & itp->netmask) == itp->address) { /* compare */ /* We found a match. Swap it into [0] */ bcopy( ((struct in_addr **) (h->h_addr_list))[0], &tmp, sizeof(tmp)); bcopy( (*r), ((struct in_addr **) (h->h_addr_list))[0], sizeof(tmp)); bcopy( &tmp, (*r), sizeof(tmp)); return; /* found one, don't need to continue */ } } /* interfaces */ } /* addresses */ } static void init_services() { char *cp, *dp, buf[BUFSIZ]; register int cc = 0; FILE *fd; char *tdp = trimdomainbuf; char *hostconf; #if NLS libc_nls_init(); #endif if(NULL==(hostconf=getenv(ENV_HOSTCONF))){ hostconf=_PATH_HOSTCONF; } if ((fd = (FILE *)fopen(hostconf, "r")) == NULL) { /* make some assumptions */ service_order[0] = SERVICE_BIND; service_order[1] = SERVICE_NONE; } else { while (fgets(buf, BUFSIZ, fd) != NULL) { if ((cp = rindex(buf, '\n')) != NULL) *cp = '\0'; if (buf[0] == '#') continue; #ifdef STRICT #define checkbuf(b, cmd) (!strncasecmp(b, cmd, strlen(cmd)) && \ (!b[strlen(cmd)] || isspace(b[strlen(cmd)]))) #else #define checkbuf(b, cmd) (!strncasecmp(b, cmd, strlen(cmd))) #endif for (cp=buf; cp && *cp && isspace(*cp); cp++); if (cp && *cp) { strcpy(buf,cp); if (checkbuf(buf, CMD_ORDER)) { cp = strpbrk(buf, " \t"); if (!cp #ifdef STRICT || !*(cp+1) #endif ) { bad_config_format(CMD_ORDER); } else { do { while (*cp == ' ' || *cp == '\t') cp++; dp = strpbrk(cp, TOKEN_SEPARATORS); if (dp) *dp = '\0'; if (checkbuf(cp, ORD_BIND)) service_order[cc++] = SERVICE_BIND; else if (checkbuf(cp, ORD_HOSTS)) service_order[cc++] = SERVICE_HOSTS; else if (checkbuf(cp, ORD_NIS)) service_order[cc++] = SERVICE_NIS; else { bad_config_format(CMD_ORDER); #if NLS fprintf(stderr, catgets(_libc_cat, NetMiscSet, NetMiscResolvInvalid, "resolv+: \"%s\" is an invalid keyword\n"), cp); fprintf(stderr, catgets(_libc_cat, NetMiscSet, NetMiscResolvValid, "resolv+: valid keywords are: %s, %s and %s\n"), #else fprintf(stderr, "resolv+: \"%s\" is an invalid keyword\n", cp); fprintf(stderr, "resolv+: valid keywords are: %s, %s and %s\n", #endif ORD_BIND, ORD_HOSTS, ORD_NIS); } if (dp) cp = ++dp; } while (dp != NULL); if (cc == 0) { bad_config_format(CMD_ORDER); #if NLS fprintf(stderr,catgets(_libc_cat, NetMiscSet, NetMiscUnrecognized, "resolv+: search order not specified or unrecognized keyword, host resolution will fail.\n")); #else fprintf(stderr,"resolv+: search order not specified or unrecognized keyword, host resolution will fail.\n"); #endif } } } else if (checkbuf(buf, CMD_HMA)) { #ifdef STRICT #if NLS #define check_legal(key,val) { \ for (cp=strpbrk(buf, " \t"); \ cp && *cp && isspace(*cp); cp++); \ if (cp && *cp) {\ if (strlen(CMD_ON) == strlen(cp) && \ checkbuf(cp,CMD_ON)) val = 1; \ else if (strlen(CMD_OFF) == strlen(cp) && \ checkbuf(cp,CMD_OFF)) val = 0; \ else { bad_config_format(key); \ fprintf(stderr, catgets(_libc_cat, NetMiscSet, \ NetMiscResolvInvalid, \ "resolv+: \"%s\" is an invalid keyword\n"), cp); }\ } else bad_config_format(key); } #else #define check_legal(key,val) { \ for (cp=strpbrk(buf, " \t"); \ cp && *cp && isspace(*cp); cp++); \ if (cp && *cp) {\ if (strlen(CMD_ON) == strlen(cp) && \ checkbuf(cp,CMD_ON)) val = 1; \ else if (strlen(CMD_OFF) == strlen(cp) && \ checkbuf(cp,CMD_OFF)) val = 0; \ else { bad_config_format(key); \ fprintf(stderr, "resolv+: \"%s\" is an invalid keyword\n", cp); } \ } else bad_config_format(key); } #endif /* NLS */ check_legal(CMD_HMA,hosts_multiple_addrs); #else /* !STRICT */ if ( cp = strpbrk(buf, " \t") ) { while (*cp == ' ' || *cp == '\t') cp++; if (checkbuf(cp, CMD_ON)) hosts_multiple_addrs = 1; } else bad_config_format(CMD_HMA); #endif /* STRICT */ } else if (checkbuf(buf, CMD_SPOOF)) { #ifdef STRICT check_legal(CMD_SPOOF,spoof); #else if ( cp = strpbrk(buf, " \t") ) { while (*cp == ' ' || *cp == '\t') cp++; if (checkbuf(cp, CMD_ON)) spoof = 1; } else bad_config_format(CMD_SPOOF); #endif } else if (checkbuf(buf, CMD_SPOOFALERT)) { #ifdef STRICT check_legal(CMD_SPOOFALERT,spoofalert); #else if ( cp = strpbrk(buf, " \t") ) { while (*cp == ' ' || *cp == '\t') cp++; if (checkbuf(cp, CMD_ON)) spoofalert = 1; } else bad_config_format(CMD_SPOOFALERT); #endif } else if (checkbuf(buf, CMD_REORDER)) { #ifdef STRICT check_legal(CMD_REORDER,reorder); #else if (cp = strpbrk(buf, " \t")) { while (*cp == ' ' || *cp == '\t') cp++; if (checkbuf(cp, CMD_ON)) reorder = 1; } else bad_config_format(CMD_REORDER); #endif } else if (checkbuf(buf, CMD_TRIMDOMAIN)) { if(numtrimdomainsbuf + anslen; /* * find first satisfactory answer */ hp = &answer->hdr; ancount = ntohs(hp->ancount); qdcount = ntohs(hp->qdcount); bp = hostbuf; buflen = sizeof(hostbuf); cp = answer->buf + sizeof(HEADER); if (qdcount) { if (iquery) { if ((n = dn_expand((char *)answer->buf, eom, cp, bp, buflen)) < 0) { h_errno = NO_RECOVERY; return ((struct hostent *) NULL); } cp += n + QFIXEDSZ; host.h_name = bp; n = strlen(bp) + 1; bp += n; buflen -= n; } else cp += dn_skipname(cp, eom) + QFIXEDSZ; while (--qdcount > 0) cp += dn_skipname(cp, eom) + QFIXEDSZ; } else if (iquery) { if (hp->aa) h_errno = HOST_NOT_FOUND; else h_errno = TRY_AGAIN; return ((struct hostent *) NULL); } ap = host_aliases; *ap = NULL; host.h_aliases = host_aliases; hap = h_addr_ptrs; *hap = NULL; #if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ host.h_addr_list = h_addr_ptrs; #endif haveanswer = 0; while (--ancount >= 0 && cp < eom) { if ((n = dn_expand((char *)answer->buf, eom, cp, bp, buflen)) < 0) break; cp += n; type = _getshort(cp); cp += sizeof(u_short); class = _getshort(cp); cp += sizeof(u_short) + sizeof(u_long); n = _getshort(cp); cp += sizeof(u_short); if (type == T_CNAME) { cp += n; if (ap >= &host_aliases[MAXALIASES-1]) continue; *ap++ = bp; n = strlen(bp) + 1; bp += n; buflen -= n; continue; } if (iquery && type == T_PTR) { if ((n = dn_expand((char *)answer->buf, eom, cp, bp, buflen)) < 0) { cp += n; continue; } cp += n; host.h_name = bp; return(&host); } if (iquery || type != T_A) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("unexpected answer type %d, size %d\n", type, n); #endif cp += n; continue; } if (haveanswer) { if (n != host.h_length) { cp += n; continue; } if (class != getclass) { cp += n; continue; } } else { host.h_length = n; getclass = class; host.h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC; if (!iquery) { host.h_name = bp; bp += strlen(bp) + 1; } } bp += sizeof(align) - ((u_long)bp % sizeof(align)); if (bp + n >= &hostbuf[sizeof(hostbuf)]) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("size (%d) too big\n", n); #endif break; } bcopy((char *)cp, *hap++ = bp, n); bp +=n; cp += n; haveanswer++; } if (haveanswer) { *ap = NULL; #if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ *hap = NULL; #else host.h_addr = h_addr_ptrs[0]; #endif return (&host); } else { h_errno = TRY_AGAIN; return ((struct hostent *) NULL); } } struct hostent * gethostbyname(const char *name) { querybuf buf; register char *cp; register int cc; int n; struct hostent *hp; extern struct hostent *_gethtbyname(); /* * disallow names consisting only of digits/dots, unless * they end in a dot. */ if (isdigit(name[0])) for (cp = name;; ++cp) { if (!*cp) { if (*--cp == '.') break; /* * All-numeric, no dot at the end. * Fake up a hostent as if we'd actually * done a lookup. What if someone types * 255.255.255.255? The test below will * succeed spuriously... ??? */ if ((host_addr.s_addr = inet_addr(name)) == -1) { h_errno = HOST_NOT_FOUND; return((struct hostent *) NULL); } host.h_name = name; host.h_aliases = host_aliases; host_aliases[0] = NULL; host.h_addrtype = AF_INET; host.h_length = sizeof(u_long); h_addr_ptrs[0] = (char *)&host_addr; h_addr_ptrs[1] = (char *)0; #if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ host.h_addr_list = h_addr_ptrs; #else host.h_addr = h_addr_ptrs[0]; #endif return (&host); } if (!isdigit(*cp) && *cp != '.') break; } if (!service_done) init_services(); for (cc = 0; service_order[cc] != SERVICE_NONE && cc <= SERVICE_MAX; cc++) { switch (service_order[cc]) { case SERVICE_BIND: if ((n = res_search(name, C_IN, T_A, buf.buf, sizeof(buf))) < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_search failed\n"); #endif } hp = getanswer(&buf, n, 0); if (h_addr_ptrs[1] && reorder) reorder_addrs(hp); if (hp) return trim_domains(hp); break; case SERVICE_HOSTS: hp = _gethtbyname(name); if (h_addr_ptrs[1] && reorder) reorder_addrs(hp); if (hp) return hp; h_errno = HOST_NOT_FOUND; break; #ifdef NIS case SERVICE_NIS: hp = _getnishost(name, "hosts.byname"); if (h_addr_ptrs[1] && reorder) reorder_addrs(hp); if (hp) return hp; h_errno = HOST_NOT_FOUND; break; #endif /* NIS */ } } return ((struct hostent *) NULL); } struct hostent * gethostbyaddr(const char *addr, int len, int type) { int n; querybuf buf; register int cc; register struct hostent *hp; char qbuf[MAXDNAME]; extern struct hostent *_gethtbyaddr(); if (type != AF_INET) return ((struct hostent *) NULL); if (!service_done) init_services(); #if NLS libc_nls_init(); #endif cc = 0; while (service_order[cc] != SERVICE_NONE) { switch (service_order[cc]) { case SERVICE_BIND: (void)sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa", ((unsigned)addr[3] & 0xff), ((unsigned)addr[2] & 0xff), ((unsigned)addr[1] & 0xff), ((unsigned)addr[0] & 0xff)); n = res_query(qbuf, C_IN, T_PTR, (char *)&buf, sizeof(buf)); if (n < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_query failed\n"); #endif break; } hp = getanswer(&buf, n, 1); if (hp) { if(spoof){ /* Spoofing check code by * Caspar Dik */ char nambuf[MAXDNAME+1]; int ntd, namelen = strlen(hp->h_name); char **addrs; if (namelen >= MAXDNAME) return (struct hostent *)NULL; (void) strcpy(nambuf,hp->h_name); nambuf[namelen] = '.'; nambuf[namelen+1] = '\0'; /* * turn off domain trimming, * call gethostbyname(), then turn * it back on, if applicable. This * prevents domain trimming from * making the name comparison fail. */ ntd=numtrimdomains; numtrimdomains=0; hp=gethostbyname(nambuf); numtrimdomains=ntd; nambuf[namelen] = 0; /* * the name must exist and the name * returned by gethostbyaddr must be * the canonical name and therefore * identical to the name returned by * gethostbyname() */ if (!hp || strcmp(nambuf, hp->h_name)){ h_errno = HOST_NOT_FOUND; return (struct hostent *)NULL; } /* * now check the addresses */ #if defined(h_addr) || BSD >= 43 for (addrs = hp->h_addr_list; *addrs; addrs++){ if (!bcmp(addrs[0], addr, len)) return trim_domains(hp); } #else if (!bcmp(hp->h_addr, addr, len))) return trim_domains(hp); #endif /* We've been spoofed */ h_errno = HOST_NOT_FOUND; if(spoofalert){ openlog("resolv", LOG_PID, LOG_AUTH); syslog(LOG_NOTICE, #if NLS catgets(_libc_cat, NetMiscSet, NetMiscPossibleSpoof, "gethostbyaddr: %s != %u.%u.%u.%u, possible spoof attempt"), #else "gethostbyaddr: %s != %u.%u.%u.%u, possible spoof attempt", #endif hp->h_name, ((unsigned)addr[0]&0xff), ((unsigned)addr[1]&0xff), ((unsigned)addr[2]&0xff), ((unsigned)addr[3]&0xff)); } return (struct hostent *)NULL; } hp->h_addrtype = type; hp->h_length = len; h_addr_ptrs[0] = (char *)&host_addr; h_addr_ptrs[1] = (char *)0; host_addr = *(struct in_addr *)addr; #if BSD < 43 && !defined(h_addr) /* new-style hostent structure */ hp->h_addr = h_addr_ptrs[0]; #endif return trim_domains(hp); } h_errno = HOST_NOT_FOUND; break; case SERVICE_HOSTS: hp = _gethtbyaddr(addr, len, type); if (hp) return hp; h_errno = HOST_NOT_FOUND; break; #ifdef NIS case SERVICE_NIS: (void)sprintf(qbuf, "%u.%u.%u.%u", ((unsigned)addr[0] & 0xff), ((unsigned)addr[1] & 0xff), ((unsigned)addr[2] & 0xff), ((unsigned)addr[3] & 0xff)); hp = _getnishost(qbuf, "hosts.byaddr"); if (hp) return hp; h_errno = HOST_NOT_FOUND; break; #endif /* NIS */ } cc++; } return ((struct hostent *)NULL); } void _sethtent(f) int f; { if (hostf == NULL) hostf = fopen(HOSTDB, "r" ); else rewind(hostf); stayopen |= f; } void _endhtent() { if (hostf && !stayopen) { (void) fclose(hostf); hostf = NULL; } } struct hostent * _gethtent() { char *p; register char *cp, **q; if (hostf == NULL && (hostf = fopen(HOSTDB, "r" )) == NULL) return (NULL); again: if ((p = fgets(hostbuf, BUFSIZ, hostf)) == NULL) return (NULL); if (*p == '#') goto again; cp = strpbrk(p, "#\n"); if (cp == NULL) goto again; *cp = '\0'; cp = strpbrk(p, " \t"); if (cp == NULL) goto again; *cp++ = '\0'; /* THIS STUFF IS INTERNET SPECIFIC */ #if BSD >= 43 || defined(h_addr) /* new-style hostent structure */ host.h_addr_list = host_addrs; #endif host.h_addr = hostaddr; *((u_long *)host.h_addr) = inet_addr(p); host.h_length = sizeof (u_long); host.h_addrtype = AF_INET; while (*cp == ' ' || *cp == '\t') cp++; host.h_name = cp; q = host.h_aliases = host_aliases; cp = strpbrk(cp, " \t"); if (cp != NULL) *cp++ = '\0'; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &host_aliases[MAXALIASES - 1]) *q++ = cp; cp = strpbrk(cp, " \t"); if (cp != NULL) *cp++ = '\0'; } *q = NULL; return (&host); } /* if hosts_multiple_addrs set, then gethtbyname behaves as follows: * - for hosts with multiple addresses, return all addresses, such that * the first address is most likely to be one on the same net as the * host we're running on, if one exists. * - like the dns version of gethostsbyname, the alias field is empty * unless the name being looked up is an alias itself, at which point the * alias field contains that name, and the name field contains the primary * name of the host. Unlike dns, however, this behavior will still take place * even if the alias applies only to one of the interfaces. * - determining a "local" address to put first is dependant on the netmask * being such that the least significant network bit is more significant * than any host bit. Only strange netmasks will violate this. * - we assume addresses fit into u_longs. That's quite internet specific. * - if the host we're running on is not in the host file, the address * shuffling will not take place. * - John DiMarco */ struct hostent * _gethtbyname(const char *name) { register struct hostent *p; register char **cp; char **hap, **lhap, *bp, *lbp; int htbuflen, locbuflen; int found=0, localfound=0; char localname[MAXHOSTNAMELEN]; static char htbuf[BUFSIZ+1]; /* buffer for host addresses */ static char locbuf[BUFSIZ+1]; /* buffer for local hosts's addresses */ static char *ht_addr_ptrs[MAXADDRS+1]; static char *loc_addr_ptrs[MAXADDRS+1]; static struct hostent ht; static char *aliases[MAXALIASES]; static char namebuf[MAXHOSTNAMELEN]; hap = ht_addr_ptrs; lhap = loc_addr_ptrs; *hap = NULL; *lhap = NULL; bp=htbuf; lbp=locbuf; htbuflen = sizeof(htbuf); locbuflen = sizeof(locbuf); aliases[0]=NULL; aliases[1]=NULL; (void) strcpy(namebuf, name); (void)gethostname(localname, sizeof(localname)); _sethtent(0); while (p = _gethtent()) { if (strcasecmp(p->h_name, name) == 0) found++; else for (cp = p->h_aliases; *cp != 0; cp++) if (strcasecmp(*cp, name) == 0){ found++; aliases[0]=name; (void) strcpy(namebuf, p->h_name); } if (strcasecmp(p->h_name, localname) == 0) localfound++; else for (cp=p->h_aliases; *cp != 0; cp++) if (strcasecmp(*cp, localname) == 0) localfound++; if(found){ int n; if(!hosts_multiple_addrs){ /* original behaviour requested */ _endhtent(); return(p); } n = p->h_length; ht.h_addrtype = p->h_addrtype; ht.h_length = p->h_length; if(n<=htbuflen){ /* add the found address to the list */ bcopy(p->h_addr_list[0], bp, n); *hap++=bp; *hap=NULL; bp+=n; htbuflen-=n; } found=0; } if(localfound){ int n = p->h_length; if(n<=locbuflen){ /* add the found local address to the list */ bcopy(p->h_addr_list[0], lbp, n); *lhap++=lbp; *lhap=NULL; lbp+=n; locbuflen-=n; } localfound=0; } } _endhtent(); if(NULL==ht_addr_ptrs[0]){ return((struct hostent *)NULL); } ht.h_aliases = aliases; ht.h_name = namebuf; /* shuffle addresses around to ensure one on same net as local host is first, if exists */ { /* "best" address is assumed to be the one with the greatest number of leftmost bits matching any of the addresses of the local host. This assumes a netmask in which all net bits precede host bits. Usually but not always a fair assumption. */ /* portability alert: assumption: iaddr fits in u_long. This is really internet specific. */ int i,j, best=0; u_long bestval = (u_long)~0; for(i=0;loc_addr_ptrs[i];i++){ for(j=0;ht_addr_ptrs[j];j++){ u_long t, l, h; /* assert(sizeof(u_long)>=ht.h_length); */ bcopy(loc_addr_ptrs[i], (char *)&t, ht.h_length); l=ntohl(t); bcopy(ht_addr_ptrs[j], (char *)&t, ht.h_length); t=l^h; if(t= 43 || defined(h_addr) /* new-style hostent structure */ h.h_addr_list = host_addrs; #endif h.h_addr = hostaddr; *((u_long *)h.h_addr) = inet_addr(result); h.h_length = sizeof(u_long); h.h_addrtype = AF_INET; while (*cp == ' ' || *cp == '\t') cp++; h.h_name = cp; q = h.h_aliases = host_aliases; cp = strpbrk(cp, " \t"); if (cp != NULL) *cp++ = '\0'; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &host_aliases[MAXALIASES - 1]) *q++ = cp; cp = strpbrk(cp, " \t"); if (cp != NULL) *cp++ = '\0'; } *q = NULL; return (&h); } #endif /* NIS */ struct hostent * _gethtbyaddr(const char *addr, int len, int type) { register struct hostent *p; _sethtent(0); while (p = _gethtent()) if (p->h_addrtype == type && !bcmp(p->h_addr, addr, len)) break; _endhtent(); return (p); } ./libc-linux/inet/herror.c100644 1676 334 4743 5547117740 13542 0ustar hjlisl/* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that: (1) source distributions retain this entire copyright * notice and comment, and (2) distributions including binaries display * the following acknowledgement: ``This product includes software * developed by the University of California, Berkeley and its contributors'' * in the documentation or other materials provided with the distribution * and in all advertising materials mentioning features or use of this * software. Neither the name of the University nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)herror.c 6.5 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" #if NLS #include "nl_types.h" #endif const char *const h_errlist[] = { "Error 0", "Unknown host", /* 1 HOST_NOT_FOUND */ "Host name lookup failure", /* 2 TRY_AGAIN */ "Unknown server error", /* 3 NO_RECOVERY */ "No address associated with name", /* 4 NO_ADDRESS */ }; int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) }; int h_errno; /* * herror -- * print the error indicated by the h_errno value. */ void herror(s) const char *s; { struct iovec iov[4]; register struct iovec *v = iov; #if NLS libc_nls_init(); #endif if (s && *s) { v->iov_base = s; v->iov_len = strlen(s); v++; v->iov_base = ": "; v->iov_len = 2; v++; } v->iov_base = (u_int)h_errno < h_nerr ? h_errlist[h_errno] : "Unknown error"; v->iov_len = strlen(v->iov_base); v++; v->iov_base = "\n"; v->iov_len = 1; #if NLS if ((u_int)h_errno < h_nerr) fprintf(stderr, (s && *s) ? "%s: %s\n":"%s\n", (s && *s) ? s: catgets(_libc_cat, HerrorListSet, h_errno+1, (char *) h_errlist[h_errno]), (s && *s) ? catgets(_libc_cat, HerrorListSet, h_errno+1, (char *) h_errlist[h_errno]): NULL); else fprintf(stderr, (s && *s) ? "%s: %s\n":"%s\n", (s && *s) ? s: catgets(_libc_cat, ErrorListSet, 1, "Unknown error"), (s && *s) ? catgets(_libc_cat, ErrorListSet, 1, "Unknown error"): NULL); #else writev(2, iov, (v - iov) + 1); #endif } ./libc-linux/inet/rcmd.c100644 1676 334 21155 5547117740 13202 0ustar hjlisl/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)rcmd.c 5.17 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" #include #include #include #include #if NLS #include "nl_types.h" #endif int rcmd(ahost, rport, locuser, remuser, cmd, fd2p) char **ahost; unsigned short rport; const char *locuser, *remuser, *cmd; int *fd2p; { int s, timo = 1; #ifdef F_SETOWN pid_t pid; #endif #ifdef _POSIX_SOURCE sigset_t set, oset; #else long oldmask; #endif struct sockaddr_in sin, from; char c; int lport = IPPORT_RESERVED - 1; struct hostent *hp; #if NLS libc_nls_init(); #endif #ifdef F_SETOWN pid = getpid(); #endif hp = gethostbyname(*ahost); if (hp == 0) { #if NLS fprintf(stderr, "%s: %s\n", *ahost, catgets(_libc_cat, HerrorListSet, 2, "unknown host")); #else fprintf(stderr, "%s: unknown host\n", *ahost); #endif return (-1); } *ahost = hp->h_name; #ifdef SIGURG #ifdef _POSIX_SOURCE sigemptyset (&set); sigaddset (&set, SIGURG); sigprocmask (SIG_BLOCK, &set, &oset); #else oldmask = sigblock(sigmask(SIGURG)); #endif #endif for (;;) { s = rresvport(&lport); if (s < 0) { if (errno == EAGAIN) #if NLS fprintf(stderr, "socket: %s\n", catgets(_libc_cat, NetMiscSet, NetMiscAllPortsInUse, "All ports in use")); #else fprintf(stderr, "socket: All ports in use\n"); #endif else #if NLS perror(catgets(_libc_cat, NetMiscSet, NetMiscRcmdSocket, "rcmd: socket")); #else perror("rcmd: socket"); #endif #ifdef SIGURG #ifdef _POSIX_SOURCE sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); #else sigsetmask(oldmask); #endif #endif return (-1); } #ifdef F_SETOWN fcntl(s, F_SETOWN, pid); #endif sin.sin_family = hp->h_addrtype; bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, hp->h_length); sin.sin_port = rport; if (connect(s, (struct sockaddr *)&sin, sizeof (sin)) >= 0) break; (void) close(s); if (errno == EADDRINUSE) { lport--; continue; } if (errno == ECONNREFUSED && timo <= 16) { sleep(timo); timo *= 2; continue; } if (hp->h_addr_list[1] != NULL) { int oerrno = errno; fprintf(stderr, #if NLS "%s %s: ", catgets(_libc_cat, NetMiscSet, NetMiscAllPortsInUse, "connect to address"), inet_ntoa(sin.sin_addr)); #else "connect to address %s: ", inet_ntoa(sin.sin_addr)); #endif errno = oerrno; perror(0); hp->h_addr_list++; bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, hp->h_length); #if NLS fprintf(stderr, catgets(_libc_cat, NetMiscSet, NetMiscTrying, "Trying %s...\n"), #else fprintf(stderr, "Trying %s...\n", #endif inet_ntoa(sin.sin_addr)); continue; } perror(hp->h_name); #ifdef SIGURG #ifdef _POSIX_SOURCE sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); #else sigsetmask(oldmask); #endif #endif return (-1); } lport--; if (fd2p == 0) { write(s, "", 1); lport = 0; } else { char num[8]; int s2 = rresvport(&lport), s3; int len = sizeof (from); if (s2 < 0) goto bad; listen(s2, 1); (void) sprintf(num, "%d", lport); if (write(s, num, strlen(num)+1) != strlen(num)+1) { #if NLS perror(catgets(_libc_cat, NetMiscSet, NetMiscSettingUpStderr, "write: setting up stderr")); #else perror("write: setting up stderr"); #endif (void) close(s2); goto bad; } s3 = accept(s2, (struct sockaddr *)&from, &len); (void) close(s2); if (s3 < 0) { #if NLS perror(catgets(_libc_cat, NetMiscSet, NetMiscAccept, "accept")); #else perror("accept"); #endif lport = 0; goto bad; } *fd2p = s3; from.sin_port = ntohs((u_short)from.sin_port); if (from.sin_family != AF_INET || from.sin_port >= IPPORT_RESERVED) { fprintf(stderr, #if NLS "%s\n", catgets(_libc_cat, NetMiscSet, NetMiscProtocolFailure, "socket: protocol failure in circuit setup.")); #else "socket: protocol failure in circuit setup.\n"); #endif goto bad2; } } (void) write(s, locuser, strlen(locuser)+1); (void) write(s, remuser, strlen(remuser)+1); (void) write(s, cmd, strlen(cmd)+1); if (read(s, &c, 1) != 1) { perror(*ahost); goto bad2; } if (c != 0) { while (read(s, &c, 1) == 1) { (void) write(2, &c, 1); if (c == '\n') break; } goto bad2; } #ifdef SIGURG #ifdef _POSIX_SOURCE sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); #else sigsetmask(oldmask); #endif #endif return (s); bad2: if (lport) (void) close(*fd2p); bad: (void) close(s); #ifdef SIGURG #ifdef _POSIX_SOURCE sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); #else sigsetmask(oldmask); #endif #endif return (-1); } int rresvport(alport) int *alport; { struct sockaddr_in sin; int s; sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; s = socket(AF_INET, SOCK_STREAM, 0); if (s < 0) return (-1); for (;;) { sin.sin_port = htons((u_short)*alport); if (bind(s, (struct sockaddr *)&sin, sizeof (sin)) >= 0) return (s); if (errno != EADDRINUSE) { (void) close(s); return (-1); } (*alport)--; if (*alport == IPPORT_RESERVED/2) { (void) close(s); errno = EAGAIN; /* close */ return (-1); } } } int ruserok(const char *rhost, int superuser, const char *ruser, const char *luser) { FILE *hostf; char fhost[MAXHOSTNAMELEN]; int first = 1; register const char *sp; register char *p; int baselen = -1; uid_t saveuid; saveuid = geteuid(); sp = rhost; p = fhost; while (*sp) { if (*sp == '.') { if (baselen == -1) baselen = sp - rhost; *p++ = *sp++; } else { *p++ = isupper(*sp) ? tolower(*sp++) : *sp++; } } *p = '\0'; hostf = superuser ? (FILE *)0 : fopen(_PATH_HEQUIV, "r"); again: if (hostf) { if (!_validuser(hostf, fhost, luser, ruser, baselen)) { (void) fclose(hostf); seteuid(saveuid); return(0); } (void) fclose(hostf); } if (first == 1) { struct stat sbuf; struct passwd *pwd; char pbuf[MAXPATHLEN]; first = 0; if ((pwd = getpwnam(luser)) == NULL) return(-1); (void)strcpy(pbuf, pwd->pw_dir); (void)strcat(pbuf, "/.rhosts"); (void)seteuid(pwd->pw_uid); if ((hostf = fopen(pbuf, "r")) == NULL) { seteuid(saveuid); return(-1); } (void)fstat(fileno(hostf), &sbuf); if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) { fclose(hostf); seteuid(saveuid); return(-1); } goto again; } seteuid(saveuid); return (-1); } int _validuser(FILE *hostf, const char *rhost, const char *luser, const char *ruser, int baselen) { char *user; char ahost[MAXHOSTNAMELEN]; register char *p; while (fgets(ahost, sizeof (ahost), hostf)) { p = ahost; while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') { *p = isupper(*p) ? tolower(*p) : *p; p++; } if (*p == ' ' || *p == '\t') { *p++ = '\0'; while (*p == ' ' || *p == '\t') p++; user = p; while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') p++; } else user = p; *p = '\0'; if (_checkhost(rhost, ahost, baselen) && !strcmp(ruser, *user ? user : luser)) { return (0); } } return (-1); } int _checkhost(const char *rhost, const char *lhost, int len) { static char ldomain[MAXHOSTNAMELEN + 1]; static char *domainp = NULL; static int nodomain = 0; register char *cp; if (len == -1) return(!strcmp(rhost, lhost)); if (strncmp(rhost, lhost, len)) return(0); if (!strcmp(rhost, lhost)) return(1); if (*(lhost + len) != '\0') return(0); if (nodomain) return(0); if (!domainp) { if (gethostname(ldomain, sizeof(ldomain)) == -1) { nodomain = 1; return(0); } ldomain[MAXHOSTNAMELEN] = (char) 0; if ((domainp = index(ldomain, '.')) == (char *)NULL) { nodomain = 1; return(0); } for (cp = ++domainp; *cp; ++cp) if (isupper(*cp)) *cp = tolower(*cp); } return(!strcmp(domainp, rhost + len +1)); } ./libc-linux/inet/rexec.c100644 1676 334 6751 5547117740 13350 0ustar hjlisl/* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)rexec.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" #if NLS #include "nl_types.h" #endif int rexecoptions; int rexec(ahost, rport, name, pass, cmd, fd2p) char **ahost; int rport; const char *name, *pass, *cmd; int *fd2p; { int s, timo = 1, s3; struct sockaddr_in sin, sin2, from; char c; short port; struct hostent *hp; #if NLS libc_nls_init(); #endif hp = gethostbyname(*ahost); if (hp == 0) { #if NLS fprintf(stderr, "%s: %s\n", *ahost, catgets(_libc_cat, HerrorListSet, 2, "unknown host")); #else fprintf(stderr, "%s: unknown host\n", *ahost); #endif return (-1); } *ahost = hp->h_name; ruserpass(hp->h_name, &name, &pass); retry: s = socket(AF_INET, SOCK_STREAM, 0); if (s < 0) { #if NLS perror(catgets(_libc_cat, NetMiscSet, NetMiscRexecSocket, "rcmd: socket")); #else perror("rexec: socket"); #endif return (-1); } sin.sin_family = hp->h_addrtype; sin.sin_port = rport; bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length); if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) { if (errno == ECONNREFUSED && timo <= 16) { (void) close(s); sleep(timo); timo *= 2; goto retry; } perror(hp->h_name); return (-1); } if (fd2p == 0) { (void) write(s, "", 1); port = 0; } else { char num[8]; int s2, sin2len; s2 = socket(AF_INET, SOCK_STREAM, 0); if (s2 < 0) { (void) close(s); return (-1); } listen(s2, 1); sin2len = sizeof (sin2); if (getsockname(s2, (struct sockaddr *)&sin2, &sin2len) < 0 || sin2len != sizeof (sin2)) { #if NLS perror(catgets(_libc_cat, NetMiscSet, NetMiscGetsockname, "getsockname")); #else perror("getsockname"); #endif (void) close(s2); goto bad; } port = ntohs((u_short)sin2.sin_port); (void) sprintf(num, "%d", port); (void) write(s, num, strlen(num)+1); { int len = sizeof (from); s3 = accept(s2, (struct sockaddr *)&from, &len); close(s2); if (s3 < 0) { #if NLS perror(catgets(_libc_cat, NetMiscSet, NetMiscAccept, "accept")); #else perror("accept"); #endif port = 0; goto bad; } } *fd2p = s3; } (void) write(s, name, strlen(name) + 1); /* should public key encypt the password here */ (void) write(s, pass, strlen(pass) + 1); (void) write(s, cmd, strlen(cmd) + 1); if (read(s, &c, 1) != 1) { perror(*ahost); goto bad; } if (c != 0) { while (read(s, &c, 1) == 1) { (void) write(2, &c, 1); if (c == '\n') break; } goto bad; } return (s); bad: if (port) (void) close(*fd2p); (void) close(s); return (-1); } ./libc-linux/inet/ruserpass.c100644 1676 334 42672 5547117741 14314 0ustar hjlisl/* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)ruserpass.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" #include #include #include #include static void renv(const char *host, char **aname, char **apass); static char * renvlook(const char *host); static struct utmp *getutmp(char *sttyname); static FILE *cfile; static void rnetrc(const char *host, char **aname, char **apass); static void mkpwclear(char *spasswd, char mch, char *sencpasswd); static int token(); void ruserpass(const char *host, char **aname, char **apass) { static char namebuf [256]; struct hostent *hp; char name[256]; /* a temp name buffer to avoid overlayyed */ if (hp = gethostbyname (host)) strncpy(name,hp->h_name, sizeof(name) - 1); else strncpy(name,host, sizeof(name) - 1); renv(name, aname, apass); if (*aname == 0 || *apass == 0) rnetrc(name, aname, apass); /*rnetrc would call gethostbyname */ if (*aname == 0) { *aname = getlogin(); if (*aname == NULL) { struct passwd *pp = getpwuid(getuid()); if (pp != NULL) *aname = pp->pw_name; } printf("Name (%s:%s): ", host, *aname); fflush(stdout); if (read(2, namebuf, sizeof (namebuf)) <= 0) { perror ("read"); exit(1); } if (namebuf [0] != '\n') { char *ptr; *aname = namebuf; namebuf [sizeof (namebuf) - 1] = '0'; if (ptr = index(namebuf, '\n')) *ptr = 0; } } if (*aname && *apass == 0) { printf("Password (%s:%s): ", host, *aname); fflush(stdout); *apass = getpass(""); } } static void renv(const char *host, char **aname, char **apass) { register char *cp; char *comma; cp = renvlook(host); if (cp == NULL) return; if (!isalpha(cp[0])) return; comma = index(cp, ','); if (comma == 0) return; if (*aname == 0) { *aname = malloc(comma - cp + 1); strncpy(*aname, cp, comma - cp); } else if (strncmp(*aname, cp, comma - cp)) return; comma++; cp = malloc(strlen(comma)+1); strcpy(cp, comma); *apass = malloc(16); mkpwclear(cp, host[0], *apass); } static char * renvlook(const char *host) { register char *cp, **env; extern char **environ; env = environ; for (env = environ; *env != NULL; env++) if (!strncmp(*env, "MACH", 4)) { cp = index(*env, '='); if (cp == 0) continue; if (strncmp(*env+4, host, cp-(*env+4))) continue; return (cp+1); } return (NULL); } #define DEFAULT 1 #define LOGIN 2 #define PASSWD 3 #define NOTIFY 4 #define WRITE 5 #define YES 6 #define NO 7 #define COMMAND 8 #define FORCE 9 #define ID 10 #define MACHINE 11 static char tokval[100]; static struct toktab { char *tokstr; int tval; } toktab[]= { "default", DEFAULT, "login", LOGIN, "password", PASSWD, "notify", NOTIFY, "write", WRITE, "yes", YES, "y", YES, "no", NO, "n", NO, "command", COMMAND, "force", FORCE, "machine", MACHINE, 0, 0 }; #if NLS #include "nl_types.h" #endif static void rnetrc(const char *host, char **aname, char **apass) { char *hdir, buf[BUFSIZ]; int t; struct stat stb; extern int errno; struct hostent *hp; #if NLS libc_nls_init(); #endif hdir = getenv("HOME"); if (hdir == NULL) hdir = "."; (void)sprintf(buf, "%s/.netrc", hdir); cfile = fopen(buf, "r"); if (cfile == NULL) { if (errno != ENOENT) perror(buf); return; } next: while ((t = token())) switch(t) { case DEFAULT: (void) token(); continue; case MACHINE: if (token() != ID) continue; if(hp = gethostbyname (tokval)) if (strcmp(host, hp->h_name)) continue; else if (strcmp(host, tokval)) continue; while ((t = token()) && t != MACHINE) switch(t) { case LOGIN: if (token()) if (*aname == 0) { *aname = malloc(strlen(tokval) + 1); strcpy(*aname, tokval); } else { if (strcmp(*aname, tokval)) goto next; } break; case PASSWD: if (fstat(fileno(cfile), &stb) >= 0 && (stb.st_mode & 077) != 0) { #if NLS fprintf(stderr, "%s\n", catgets(_libc_cat, NetMiscSet, NetMiscNetrcWrongPasswordMode, "Error - .netrc file not correct mode.\n\ Remove password or correct mode.")); #else fprintf(stderr, "Error - .netrc file not correct mode.\n"); fprintf(stderr, "Remove password or correct mode.\n"); #endif exit(1); } if (token() && *apass == 0) { *apass = malloc(strlen(tokval) + 1); strcpy(*apass, tokval); } break; case COMMAND: case NOTIFY: case WRITE: case FORCE: (void) token(); break; default: #if NLS fprintf(stderr, "%s %s\n", catgets(_libc_cat, NetMiscSet, NetMiscUnknownNetrcOption, "Unknown .netrc option"), tokval); #else fprintf(stderr, "Unknown .netrc option %s\n", tokval); #endif break; } goto done; } done: fclose(cfile); } static int token() { char *cp; int c; struct toktab *t; if (feof(cfile)) return (0); while ((c = getc(cfile)) != EOF && (c == '\n' || c == '\t' || c == ' ' || c == ',')) continue; if (c == EOF) return (0); cp = tokval; if (c == '"') { while ((c = getc(cfile)) != EOF && c != '"') { if (c == '\\') c = getc(cfile); *cp++ = c; } } else { *cp++ = c; while ((c = getc(cfile)) != EOF && c != '\n' && c != '\t' && c != ' ' && c != ',') { if (c == '\\') c = getc(cfile); *cp++ = c; } } *cp = 0; if (tokval[0] == 0) return (0); for (t = toktab; t->tokstr; t++) if (!strcmp(t->tokstr, tokval)) return (t->tval); return (ID); } /* rest is nbs.c stolen from berknet */ #if 0 static char *nbsencrypt(char *str, char *key, char *result); static char *nbs8encrypt(char *str, char *key); static char *deblknot(char *blk); #endif static char *nbsdecrypt(char *cpt, char *key, char *result); static char *nbs8decrypt(char *crp, char *key); static void enblkclr(char *blk, char *str); static char *deblkclr(char *blk); static void enblknot(char *blk, char *crp); static void nbssetkey(char *key); static void blkencrypt(char *block, int edflag); static char E[48]; /* * The E bit-selection table. */ static char e[] = { 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9,10,11,12,13, 12,13,14,15,16,17, 16,17,18,19,20,21, 20,21,22,23,24,25, 24,25,26,27,28,29, 28,29,30,31,32, 1, }; #if 0 static char *nbsencrypt(str,key,result) char *str, *key; char *result; { static char buf[20],oldbuf[20]; register int j; result[0] = 0; strcpy(oldbuf,key); while(*str){ for(j=0;j<10;j++)buf[j] = 0; for(j=0;j<8 && *str;j++)buf[j] = *str++; strcat(result,nbs8encrypt(buf,oldbuf)); strcat(result,"$"); strcpy(oldbuf,buf); } return(result); } #endif static char *nbsdecrypt(cpt,key,result) char *cpt,*key; char *result; { char *s; char c,oldbuf[20]; result[0] = 0; strcpy(oldbuf,key); while(*cpt){ for(s = cpt;*s && *s != '$';s++); c = *s; *s = 0; strcpy(oldbuf,nbs8decrypt(cpt,oldbuf)); strcat(result,oldbuf); if(c == 0)break; cpt = s + 1; } return(result); } #if 0 static char *nbs8encrypt(str,key) char *str, *key; { static char keyblk[100], blk[100]; register int i; enblkclr(keyblk,key); nbssetkey(keyblk); for(i=0;i<48;i++) E[i] = e[i]; enblkclr(blk,str); blkencrypt(blk,0); /* forward dir */ return(deblknot(blk)); } #endif static char *nbs8decrypt(crp,key) char *crp, *key; { static char keyblk[100], blk[100]; register int i; enblkclr(keyblk,key); nbssetkey(keyblk); for(i=0;i<48;i++) E[i] = e[i]; enblknot(blk,crp); blkencrypt(blk,1); /* backward dir */ return(deblkclr(blk)); } static void enblkclr(blk,str) /* ignores top bit of chars in string str */ char *blk,*str; { register int i,j; char c; for(i=0;i<70;i++)blk[i] = 0; for(i=0; (c= *str) && i<64; str++){ for(j=0; j<7; j++, i++) blk[i] = (c>>(6-j)) & 01; i++; } } static char *deblkclr(blk) char *blk; { register int i,j; char c; static char iobuf[30]; for(i=0; i<10; i++){ c = 0; for(j=0; j<7; j++){ c <<= 1; c |= blk[8*i+j]; } iobuf[i] = c; } iobuf[i] = 0; return(iobuf); } static void enblknot(blk,crp) char *blk; char *crp; { register int i,j; char c; for(i=0;i<70;i++)blk[i] = 0; for(i=0; (c= *crp) && i<64; crp++){ if(c>'Z') c -= 6; if(c>'9') c -= 7; c -= '.'; for(j=0; j<6; j++, i++) blk[i] = (c>>(5-j)) & 01; } } #if 0 static char *deblknot(blk) char *blk; { register int i,j; char c; static char iobuf[30]; for(i=0; i<11; i++){ c = 0; for(j=0; j<6; j++){ c <<= 1; c |= blk[6*i+j]; } c += '.'; if(c > '9')c += 7; if(c > 'Z')c += 6; iobuf[i] = c; } iobuf[i] = 0; return(iobuf); } #endif /* * This program implements the * Proposed Federal Information Processing * Data Encryption Standard. * See Federal Register, March 17, 1975 (40FR12134) */ /* * Initial permutation, */ static char IP[] = { 58,50,42,34,26,18,10, 2, 60,52,44,36,28,20,12, 4, 62,54,46,38,30,22,14, 6, 64,56,48,40,32,24,16, 8, 57,49,41,33,25,17, 9, 1, 59,51,43,35,27,19,11, 3, 61,53,45,37,29,21,13, 5, 63,55,47,39,31,23,15, 7, }; /* * Final permutation, FP = IP^(-1) */ static char FP[] = { 40, 8,48,16,56,24,64,32, 39, 7,47,15,55,23,63,31, 38, 6,46,14,54,22,62,30, 37, 5,45,13,53,21,61,29, 36, 4,44,12,52,20,60,28, 35, 3,43,11,51,19,59,27, 34, 2,42,10,50,18,58,26, 33, 1,41, 9,49,17,57,25, }; /* * Permuted-choice 1 from the key bits * to yield C and D. * Note that bits 8,16... are left out: * They are intended for a parity check. */ static char PC1_C[] = { 57,49,41,33,25,17, 9, 1,58,50,42,34,26,18, 10, 2,59,51,43,35,27, 19,11, 3,60,52,44,36, }; static char PC1_D[] = { 63,55,47,39,31,23,15, 7,62,54,46,38,30,22, 14, 6,61,53,45,37,29, 21,13, 5,28,20,12, 4, }; /* * Sequence of shifts used for the key schedule. */ static char shifts[] = { 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1, }; /* * Permuted-choice 2, to pick out the bits from * the CD array that generate the key schedule. */ static char PC2_C[] = { 14,17,11,24, 1, 5, 3,28,15, 6,21,10, 23,19,12, 4,26, 8, 16, 7,27,20,13, 2, }; static char PC2_D[] = { 41,52,31,37,47,55, 30,40,51,45,33,48, 44,49,39,56,34,53, 46,42,50,36,29,32, }; /* * The C and D arrays used to calculate the key schedule. */ static char C[28]; static char D[28]; /* * The key schedule. * Generated from the key. */ static char KS[16][48]; /* * Set up the key schedule from the key. */ static void nbssetkey(key) char *key; { register i, j, k; int t; /* * First, generate C and D by permuting * the key. The low order bit of each * 8-bit char is not used, so C and D are only 28 * bits apiece. */ for (i=0; i<28; i++) { C[i] = key[PC1_C[i]-1]; D[i] = key[PC1_D[i]-1]; } /* * To generate Ki, rotate C and D according * to schedule and pick up a permutation * using PC2. */ for (i=0; i<16; i++) { /* * rotate. */ for (k=0; k>3)&01; f[t+1] = (k>>2)&01; f[t+2] = (k>>1)&01; f[t+3] = (k>>0)&01; } /* * The new R is L ^ f(R, K). * The f here has to be permuted first, though. */ for (j=0; j<32; j++) R[j] = L[j] ^ f[P[j]-1]; /* * Finally, the new L (the original R) * is copied back. */ for (j=0; j<32; j++) L[j] = tempL[j]; } /* * The output L and R are reversed. */ for (j=0; j<32; j++) { t = L[j]; L[j] = R[j]; R[j] = t; } /* * The final output * gets the inverse permutation of the very original. */ for (j=0; j<64; j++) block[j] = L[FP[j]-1]; } /* getutmp() return a pointer to the system utmp structure associated with terminal sttyname, e.g. "/dev/tty3" Is version independent-- will work on v6 systems return NULL if error */ static struct utmp *getutmp(char *sttyname) { static struct utmp utmpstr; FILE *fdutmp; if(sttyname == NULL || sttyname[0] == 0)return(NULL); fdutmp = fopen("/etc/utmp","r"); if(fdutmp == NULL)return(NULL); while(fread(&utmpstr,1,sizeof utmpstr,fdutmp) == sizeof utmpstr) if(strcmp(utmpstr.ut_line,sttyname+5) == 0){ fclose(fdutmp); return(&utmpstr); } fclose(fdutmp); return(NULL); } static void sreverse(sto, sfrom) register char *sto, *sfrom; { register int i; i = strlen(sfrom); while (i >= 0) *sto++ = sfrom[i--]; } static char *mkenvkey(char mch) { static char skey[40]; register struct utmp *putmp; char stemp[40], stemp1[40], sttyname[30]; register char *sk,*p; if (isatty(2)) strcpy(sttyname,ttyname(2)); else if (isatty(0)) strcpy(sttyname,ttyname(0)); else if (isatty(1)) strcpy(sttyname,ttyname(1)); else return (NULL); putmp = getutmp(sttyname); if (putmp == NULL) return (NULL); sk = skey; p = putmp->ut_line; while (*p) *sk++ = *p++; *sk++ = mch; (void)sprintf(stemp, "%ld", putmp->ut_time); sreverse(stemp1, stemp); p = stemp1; while (*p) *sk++ = *p++; *sk = 0; return (skey); } #if 0 static void mkpwunclear(spasswd,mch,sencpasswd) char *spasswd, mch, *sencpasswd; { register char *skey; if (spasswd[0] == 0) { sencpasswd[0] = 0; return; } skey = mkenvkey(mch); if (skey == NULL) { fprintf(stderr, "Can't make key\n"); exit(1); } nbsencrypt(spasswd, skey, sencpasswd); } #endif static void mkpwclear(sencpasswd,mch,spasswd) char *spasswd, mch, *sencpasswd; { register char *skey; if (sencpasswd[0] == 0) { spasswd[0] = 0; return; } skey = mkenvkey(mch); if (skey == NULL) { fprintf(stderr, "Can't make key\n"); exit(1); } nbsdecrypt(sencpasswd, skey, spasswd); } ./libc-linux/stdlib/ 40755 1676 334 0 5536202235 12302 5ustar hjlisl./libc-linux/stdlib/exit.c100644 1676 334 4144 5536202156 13521 0ustar hjlisl/* Copyright (C) 1991 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include "exit.h" #if defined(HAVE_GNU_LD) && !defined(__linux__) CONST struct { size_t n; void EXFUN((*fn[1]), (NOARGS)); } __libc_atexit; #endif /* Call all functions registered with `atexit' and `on_exit', in the reverse of the order in which they were registered perform stdio cleanup, and terminate program execution with STATUS. */ void DEFUN(exit, (status), int status) { register CONST struct exit_function_list *l; for (l = __exit_funcs; l != NULL; l = l->next) { register size_t i = l->idx; while (i-- > 0) { CONST struct exit_function *CONST f = &l->fns[i]; switch (f->flavor) { case ef_free: break; case ef_on: (*f->func.on.fn)(status, f->func.on.arg); break; case ef_at: (*f->func.at)(); break; } } } #if defined(HAVE_GNU_LD) && !defined(__linux__) { void EXFUN((*CONST *fn), (NOARGS)); for (fn = __libc_atexit.fn; *fn != NULL; ++fn) (**fn) (); } #else { #if defined(__linux__) && (defined(__PIC__) || defined(__pic__)) extern void EXFUN(_IO_flush_all, (NOARGS)); _IO_flush_all (); #else extern void EXFUN(_cleanup, (NOARGS)); _cleanup(); #endif } #endif _exit(status); } ./libc-linux/rpc/ 40755 1676 334 0 5567152203 11610 5ustar hjlisl./libc-linux/rpc/get_myaddr.c100644 1676 334 7470 5547117733 14207 0ustar hjlisl/* @(#)get_myaddress.c 2.1 88/07/29 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro"; #endif /* * get_myaddress.c * * Get client's IP address via ioctl. This avoids using the yellowpages. * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include #include #include #include #include #include #include #if NLS #include "nl_types.h" #endif /* #ifdef linux */ #if 0 /* #ifndef USE_GETHOSTNAME #define USE_GETHOSTNAME #endif */ /* DO use gethostbyname because it's portable */ void get_myaddress(addr) struct sockaddr_in *addr; { #ifdef USE_GETHOSTNAME char localhost[256 + 1]; struct hostent *hp; #if NLS libc_nls_init(); #endif gethostname(localhost, 256); if ((hp = gethostbyname(localhost)) == NULL) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscHostname, "get_myaddress: gethostbyname")); #else perror("get_myaddress: gethostbyname"); #endif exit(1); } bcopy((char *) hp->h_addr, (char *) &addr->sin_addr, hp->h_length); #else addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK); #endif addr->sin_family = AF_INET; addr->sin_port = htons(PMAPPORT); } #else /* * don't use gethostbyname, which would invoke yellow pages */ void get_myaddress(addr) struct sockaddr_in *addr; { int s; char buf[BUFSIZ]; struct ifconf ifc; struct ifreq ifreq, *ifr; int len; #if NLS libc_nls_init(); #endif if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscSocket, "get_myaddress: socket")); #else perror("get_myaddress: socket"); #endif exit(1); } ifc.ifc_len = sizeof (buf); ifc.ifc_buf = buf; if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscIface, "get_myaddress: ioctl (get interface configuration)")); #else perror("get_myaddress: ioctl (get interface configuration)"); #endif exit(1); } ifr = ifc.ifc_req; for (len = ifc.ifc_len; len; len -= sizeof ifreq) { ifreq = *ifr; if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscIoctl, "get_myaddress: ioctl")); #else perror("get_myaddress: ioctl"); #endif exit(1); } if ((ifreq.ifr_flags & IFF_UP) && ifr->ifr_addr.sa_family == AF_INET) { *addr = *((struct sockaddr_in *)&ifr->ifr_addr); addr->sin_port = htons(PMAPPORT); break; } ifr++; } (void) close(s); } #endif ./libc-linux/rpc/svc_au_ux.c100644 1676 334 10560 5547117733 14076 0ustar hjlisl/* @(#)svc_auth_unix.c 2.3 88/08/01 4.0 RPCSRC; from 1.28 88/02/08 SMI */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro"; #endif /* * svc_auth_unix.c * Handles UNIX flavor authentication parameters on the service side of rpc. * There are two svc auth implementations here: AUTH_UNIX and AUTH_SHORT. * _svcauth_unix does full blown unix style uid,gid+gids auth, * _svcauth_short uses a shorthand auth to index into a cache of longhand auths. * Note: the shorthand has been gutted for efficiency. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #if NLS #include "nl_types.h" #endif /* * Unix longhand authenticator */ enum auth_stat _svcauth_unix(rqst, msg) register struct svc_req *rqst; register struct rpc_msg *msg; { register enum auth_stat stat; XDR xdrs; register struct authunix_parms *aup; register long *buf; struct area { struct authunix_parms area_aup; char area_machname[MAX_MACHINE_NAME+1]; #ifdef linux gid_t area_gids[NGRPS]; #else int area_gids[NGRPS]; #endif } *area; u_int auth_len; int str_len, gid_len; register int i; #if NLS libc_nls_init(); #endif area = (struct area *) rqst->rq_clntcred; aup = &area->area_aup; aup->aup_machname = area->area_machname; aup->aup_gids = area->area_gids; auth_len = (u_int)msg->rm_call.cb_cred.oa_length; xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,XDR_DECODE); buf = XDR_INLINE(&xdrs, auth_len); if (buf != NULL) { aup->aup_time = IXDR_GET_LONG(buf); str_len = IXDR_GET_U_LONG(buf); if (str_len > MAX_MACHINE_NAME) { stat = AUTH_BADCRED; goto done; } bcopy((caddr_t)buf, aup->aup_machname, (u_int)str_len); aup->aup_machname[str_len] = 0; str_len = RNDUP(str_len); buf += str_len / sizeof (long); aup->aup_uid = IXDR_GET_LONG(buf); aup->aup_gid = IXDR_GET_LONG(buf); gid_len = IXDR_GET_U_LONG(buf); if (gid_len > NGRPS) { stat = AUTH_BADCRED; goto done; } aup->aup_len = gid_len; for (i = 0; i < gid_len; i++) { aup->aup_gids[i] = IXDR_GET_LONG(buf); } /* * five is the smallest unix credentials structure - * timestamp, hostname len (0), uid, gid, and gids len (0). */ if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) { #if NLS (void) printf(catgets(_libc_cat, RpcMiscSet, RpcMiscBadAuthLen, "bad auth_len gid %d str %d auth %d\n"), gid_len, str_len, auth_len); #else (void) printf("bad auth_len gid %d str %d auth %d\n", gid_len, str_len, auth_len); #endif stat = AUTH_BADCRED; goto done; } } else if (! xdr_authunix_parms(&xdrs, aup)) { xdrs.x_op = XDR_FREE; (void)xdr_authunix_parms(&xdrs, aup); stat = AUTH_BADCRED; goto done; } rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL; rqst->rq_xprt->xp_verf.oa_length = 0; stat = AUTH_OK; done: XDR_DESTROY(&xdrs); return (stat); } /* * Shorthand unix authenticator * Looks up longhand in a cache. */ /*ARGSUSED*/ enum auth_stat _svcauth_short(rqst, msg) struct svc_req *rqst; struct rpc_msg *msg; { return (AUTH_REJECTEDCRED); } ./libc-linux/rpc/pmap_getmaps.c100644 1676 334 5514 5547117733 14542 0ustar hjlisl/* @(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro"; #endif /* * pmap_getmap.c * Client interface to pmap rpc service. * contains pmap_getmaps, which is only tcp service involved * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include #include #include #include #include #include #define NAMELEN 255 #define MAX_BROADCAST_SIZE 1400 extern int errno; #if NLS #include "nl_types.h" #endif /* * Get a copy of the current port maps. * Calls the pmap service remotely to do get the maps. */ struct pmaplist * pmap_getmaps(address) struct sockaddr_in *address; { struct pmaplist *head = (struct pmaplist *)NULL; int socket = -1; struct timeval minutetimeout; register CLIENT *client; #if NLS libc_nls_init(); #endif minutetimeout.tv_sec = 60; minutetimeout.tv_usec = 0; address->sin_port = htons(PMAPPORT); client = clnttcp_create(address, PMAPPROG, PMAPVERS, &socket, 50, 500); if (client != (CLIENT *)NULL) { if (CLNT_CALL(client, PMAPPROC_DUMP, xdr_void, NULL, xdr_pmaplist, &head, minutetimeout) != RPC_SUCCESS) { #if NLS clnt_perror(client, catgets(_libc_cat, RpcMiscSet, RpcMiscGetmaps, "pmap_getmaps rpc problem")); #else clnt_perror(client, "pmap_getmaps rpc problem"); #endif } CLNT_DESTROY(client); } (void)close(socket); address->sin_port = 0; return (head); } ./libc-linux/rpc/svc_run.c100644 1676 334 4527 5547117734 13550 0ustar hjlisl/* @(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro"; #endif /* * 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. * * 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 */ /* * This is the rpc server side idle loop * Wait for input, call server program. */ #include #include #if NLS #include "nl_types.h" #endif static int svc_stop = 0; void svc_exit (void) { svc_stop = 1; } void svc_run() { #ifdef FD_SETSIZE fd_set readfds; #else int readfds; #endif /* def FD_SETSIZE */ extern int errno; #if NLS libc_nls_init(); #endif svc_stop = 0; for (;;) { if (svc_stop) return; #ifdef FD_SETSIZE readfds = svc_fdset; #else readfds = svc_fds; #endif /* def FD_SETSIZE */ switch (select(_rpc_dtablesize(), &readfds, (void *)0, (void *)0, (struct timeval *)0)) { case -1: if (errno == EINTR) { continue; } #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscSelectFailed, "svc_run: - select failed")); #else perror("svc_run: - select failed"); #endif return; case 0: continue; default: svc_getreqset(&readfds); } } } ./libc-linux/rpc/pmap_clnt.c100644 1676 334 7006 5547117734 14041 0ustar hjlisl/* @(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro"; #endif /* * pmap_clnt.c * Client interface to pmap rpc service. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include #if NLS #include "nl_types.h" #endif static struct timeval timeout = { 5, 0 }; static struct timeval tottimeout = { 60, 0 }; void clnt_perror(); /* * Set a mapping between program,version and port. * Calls the pmap service remotely to do the mapping. */ bool_t pmap_set(program, version, protocol, port) u_long program; u_long version; u_long protocol; u_short port; { struct sockaddr_in myaddress; int socket = -1; register CLIENT *client; struct pmap parms; bool_t rslt; #if NLS libc_nls_init(); #endif get_myaddress(&myaddress); client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); if (client == (CLIENT *)NULL) return (FALSE); parms.pm_prog = program; parms.pm_vers = version; parms.pm_prot = protocol; parms.pm_port = port; if (CLNT_CALL(client, PMAPPROC_SET, xdr_pmap, &parms, xdr_bool, &rslt, tottimeout) != RPC_SUCCESS) { #if NLS clnt_perror(client, catgets(_libc_cat, RpcMiscSet, RpcMiscCannotRegister, "Cannot register service")); #else clnt_perror(client, "Cannot register service"); #endif return (FALSE); } CLNT_DESTROY(client); (void)close(socket); return (rslt); } /* * Remove the mapping between program,version and port. * Calls the pmap service remotely to do the un-mapping. */ bool_t pmap_unset(program, version) u_long program; u_long version; { struct sockaddr_in myaddress; int socket = -1; register CLIENT *client; struct pmap parms; bool_t rslt; get_myaddress(&myaddress); client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); if (client == (CLIENT *)NULL) return (FALSE); parms.pm_prog = program; parms.pm_vers = version; parms.pm_port = parms.pm_prot = 0; CLNT_CALL(client, PMAPPROC_UNSET, xdr_pmap, &parms, xdr_bool, &rslt, tottimeout); CLNT_DESTROY(client); (void)close(socket); return (rslt); } ./libc-linux/rpc/xdr_ref.c100644 1676 334 7566 5547117734 13530 0ustar hjlisl/* @(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI"; #endif /* * xdr_reference.c, Generic XDR routines impelmentation. * * Copyright (C) 1987, Sun Microsystems, Inc. * * These are the "non-trivial" xdr primitives used to serialize and de-serialize * "pointers". See xdr.h for more info on the interface to xdr. */ #include #include #include #include #ifdef __STDC__ #include #endif #if NLS #include "nl_types.h" #endif #define LASTUNSIGNED ((u_int)0-1) /* * XDR an indirect pointer * xdr_reference is for recursively translating a structure that is * referenced by a pointer inside the structure that is currently being * translated. pp references a pointer to storage. If *pp is null * the necessary storage is allocated. * size is the sizeof the referneced structure. * proc is the routine to handle the referenced structure. */ bool_t xdr_reference(xdrs, pp, size, proc) register XDR *xdrs; caddr_t *pp; /* the pointer to work on */ u_int size; /* size of the object pointed to */ xdrproc_t proc; /* xdr routine to handle the object */ { register caddr_t loc = *pp; register bool_t stat; #if NLS libc_nls_init(); #endif if (loc == NULL) switch (xdrs->x_op) { case XDR_FREE: return (TRUE); case XDR_DECODE: *pp = loc = (caddr_t) mem_alloc(size); if (loc == NULL) { (void) fprintf(stderr, #if NLS "xdr_reference: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else "xdr_reference: out of memory\n"); #endif return (FALSE); } bzero(loc, (int)size); break; } stat = (*proc)(xdrs, loc, LASTUNSIGNED); if (xdrs->x_op == XDR_FREE) { mem_free(loc, size); *pp = NULL; } return (stat); } /* * xdr_pointer(): * * XDR a pointer to a possibly recursive data structure. This * differs with xdr_reference in that it can serialize/deserialiaze * trees correctly. * * What's sent is actually a union: * * union object_pointer switch (boolean b) { * case TRUE: object_data data; * case FALSE: void nothing; * } * * > objpp: Pointer to the pointer to the object. * > obj_size: size of the object. * > xdr_obj: routine to XDR an object. * */ bool_t xdr_pointer(xdrs,objpp,obj_size,xdr_obj) register XDR *xdrs; char **objpp; u_int obj_size; xdrproc_t xdr_obj; { bool_t more_data; more_data = (*objpp != NULL); if (! xdr_bool(xdrs,&more_data)) { return (FALSE); } if (! more_data) { *objpp = NULL; return (TRUE); } return (xdr_reference(xdrs,objpp,obj_size,xdr_obj)); } ./libc-linux/rpc/svc_simple.c100644 1676 334 12373 5547117734 14253 0ustar hjlisl/* @(#)svc_simple.c 2.2 88/08/01 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro"; #endif /* * svc_simple.c * Simplified front end to rpc. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include #include #include #ifdef __STDC__ #include #endif #if NLS #include "nl_types.h" #endif static struct proglst { char *(*p_progname)(); int p_prognum; int p_procnum; xdrproc_t p_inproc, p_outproc; struct proglst *p_nxt; } *proglst; static void universal(); static SVCXPRT *transp; int registerrpc(prognum, versnum, procnum, progname, inproc, outproc) u_long prognum; u_long versnum; u_long procnum; char *(*progname)(); xdrproc_t inproc, outproc; { struct proglst *pl; #if NLS libc_nls_init(); #endif if (procnum == NULLPROC) { #if NLS (void) fprintf(stderr, catgets(_libc_cat, RpcMiscSet, RpcMiscCantReassignProc, "can't reassign procedure number %d\n"), NULLPROC); #else (void) fprintf(stderr, "can't reassign procedure number %d\n", NULLPROC); #endif return (-1); } if (transp == 0) { transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { #if NLS (void) fprintf(stderr, "%s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscCantCreateServer, "couldn't create an rpc server")); #else (void) fprintf(stderr, "couldn't create an rpc server\n"); #endif return (-1); } } (void) pmap_unset((u_long)prognum, (u_long)versnum); if (!svc_register(transp, (u_long)prognum, (u_long)versnum, universal, IPPROTO_UDP)) { #if NLS (void) fprintf(stderr, catgets(_libc_cat, RpcMiscSet, RpcMiscCantRegisterProg, "couldn't register prog %d vers %d\n"), prognum, versnum); #else (void) fprintf(stderr, "couldn't register prog %d vers %d\n", prognum, versnum); #endif return (-1); } pl = (struct proglst *)malloc(sizeof(struct proglst)); if (pl == NULL) { #if NLS (void) fprintf(stderr, "registerrpc: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void) fprintf(stderr, "registerrpc: out of memory\n"); #endif return (-1); } pl->p_progname = progname; pl->p_prognum = prognum; pl->p_procnum = procnum; pl->p_inproc = inproc; pl->p_outproc = outproc; pl->p_nxt = proglst; proglst = pl; return (0); } static void universal(rqstp, transp) struct svc_req *rqstp; SVCXPRT *transp; { int prog, proc; char *outdata; char xdrbuf[UDPMSGSIZE]; struct proglst *pl; #if NLS libc_nls_init(); #endif /* * enforce "procnum 0 is echo" convention */ if (rqstp->rq_proc == NULLPROC) { if (svc_sendreply(transp, xdr_void, (char *)NULL) == FALSE) { (void) fprintf(stderr, "xxx\n"); exit(1); } return; } prog = rqstp->rq_prog; proc = rqstp->rq_proc; for (pl = proglst; pl != NULL; pl = pl->p_nxt) if (pl->p_prognum == prog && pl->p_procnum == proc) { /* decode arguments into a CLEAN buffer */ bzero(xdrbuf, sizeof(xdrbuf)); /* required ! */ if (!svc_getargs(transp, pl->p_inproc, xdrbuf)) { svcerr_decode(transp); return; } outdata = (*(pl->p_progname))(xdrbuf); if (outdata == NULL && pl->p_outproc != xdr_void) /* there was an error */ return; if (!svc_sendreply(transp, pl->p_outproc, outdata)) { (void) fprintf(stderr, #if NLS catgets(_libc_cat, RpcMiscSet, RpcMiscTroubleReplying, "trouble replying to prog %d\n"), #else "trouble replying to prog %d\n", #endif pl->p_prognum); exit(1); } /* free the decoded arguments */ (void)svc_freeargs(transp, pl->p_inproc, xdrbuf); return; } #if NLS (void) fprintf(stderr, catgets(_libc_cat, RpcMiscSet, RpcMiscNeverRegisteredProg, "never registered prog %d\n"), prog); #else (void) fprintf(stderr, "never registered prog %d\n", prog); #endif exit(1); } ./libc-linux/rpc/xdr_array.c100644 1676 334 10672 5547117735 14103 0ustar hjlisl/* @(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro"; #endif /* * xdr_array.c, Generic XDR routines impelmentation. * * Copyright (C) 1984, Sun Microsystems, Inc. * * These are the "non-trivial" xdr primitives used to serialize and de-serialize * arrays. See xdr.h for more info on the interface to xdr. */ #include #include #include #include #ifdef __STDC__ #include #endif #define LASTUNSIGNED ((u_int)0-1) #if NLS #include "nl_types.h" #endif /* * XDR an array of arbitrary elements * *addrp is a pointer to the array, *sizep is the number of elements. * If addrp is NULL (*sizep * elsize) bytes are allocated. * elsize is the size (in bytes) of each element, and elproc is the * xdr procedure to call to handle each element of the array. */ bool_t xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) register XDR *xdrs; caddr_t *addrp; /* array pointer */ u_int *sizep; /* number of elements */ u_int maxsize; /* max numberof elements */ u_int elsize; /* size in bytes of each element */ xdrproc_t elproc; /* xdr routine to handle each element */ { register u_int i; register caddr_t target = *addrp; register u_int c; /* the actual element count */ register bool_t stat = TRUE; register u_int nodesize; /* like strings, arrays are really counted arrays */ if (! xdr_u_int(xdrs, sizep)) { return (FALSE); } c = *sizep; if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) { return (FALSE); } nodesize = c * elsize; /* * if we are deserializing, we may need to allocate an array. * We also save time by checking for a null array if we are freeing. */ #if NLS libc_nls_init(); #endif if (target == NULL) switch (xdrs->x_op) { case XDR_DECODE: if (c == 0) return (TRUE); *addrp = target = mem_alloc(nodesize); if (target == NULL) { (void) fprintf(stderr, #if NLS "xdr_array: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else "xdr_array: out of memory\n"); #endif return (FALSE); } bzero(target, nodesize); break; case XDR_FREE: return (TRUE); } /* * now we xdr each element of array */ for (i = 0; (i < c) && stat; i++) { stat = (*elproc)(xdrs, target, LASTUNSIGNED); target += elsize; } /* * the array may need freeing */ if (xdrs->x_op == XDR_FREE) { mem_free(*addrp, nodesize); *addrp = NULL; } return (stat); } /* * xdr_vector(): * * XDR a fixed length array. Unlike variable-length arrays, * the storage of fixed length arrays is static and unfreeable. * > basep: base of the array * > size: size of the array * > elemsize: size of each element * > xdr_elem: routine to XDR each element */ bool_t xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem) register XDR *xdrs; register char *basep; register u_int nelem; register u_int elemsize; register xdrproc_t xdr_elem; { register u_int i; register char *elptr; elptr = basep; for (i = 0; i < nelem; i++) { if (! (*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) { return(FALSE); } elptr += elemsize; } return(TRUE); } ./libc-linux/rpc/clnt_perror.c100644 1676 334 17704 5547117735 14444 0ustar hjlisl/* @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro"; #endif /* * clnt_perror.c * * Copyright (C) 1984, Sun Microsystems, Inc. * */ #include #include #include #ifdef __STDC__ #include #endif #ifdef linux #include #else extern char *sys_errlist[]; extern char *sprintf(); extern char *strcpy(); #endif static char *auth_errmsg(); #if NLS #include "nl_types.h" #endif static char *buf; static char * _buf() { if (buf == 0) buf = (char *)malloc(256); return (buf); } /* * Print reply error info */ char * clnt_sperror(rpch, s) CLIENT *rpch; char *s; { struct rpc_err e; void clnt_perrno(); char *err; char *str = _buf(); char *strstart = str; if (str == 0) return (0); CLNT_GETERR(rpch, &e); (void) sprintf(str, "%s: ", s); str += strlen(str); (void) strcpy(str, clnt_sperrno(e.re_status)); str += strlen(str); #if NLS libc_nls_init(); #endif switch (e.re_status) { case RPC_SUCCESS: case RPC_CANTENCODEARGS: case RPC_CANTDECODERES: case RPC_TIMEDOUT: case RPC_PROGUNAVAIL: case RPC_PROCUNAVAIL: case RPC_CANTDECODEARGS: case RPC_SYSTEMERROR: case RPC_UNKNOWNHOST: case RPC_UNKNOWNPROTO: case RPC_PMAPFAILURE: case RPC_PROGNOTREGISTERED: case RPC_FAILED: break; case RPC_CANTSEND: case RPC_CANTRECV: (void) sprintf(str, #if NLS catgets(_libc_cat, ClntMiscSet, ClntMiscErrno, "; errno = %s"), #else "; errno = %s", #endif #if NLS catgets(_libc_cat, ErrorListSet, e.re_errno+1, sys_errlist[e.re_errno])); #else sys_errlist[e.re_errno]); #endif str += strlen(str); break; case RPC_VERSMISMATCH: (void) sprintf(str, #if NLS catgets(_libc_cat, ClntMiscSet, ClntMiscLowHigh, "; low version = %lu, high version = %lu"), #else "; low version = %lu, high version = %lu", #endif e.re_vers.low, e.re_vers.high); str += strlen(str); break; case RPC_AUTHERROR: err = auth_errmsg(e.re_why); (void) sprintf(str, #if NLS catgets(_libc_cat, ClntMiscSet, ClntMiscWhy, "; why = ")); #else "; why = "); #endif str += strlen(str); if (err != NULL) { (void) sprintf(str, "%s",err); } else { (void) sprintf(str, #if NLS catgets (_libc_cat, ClntMiscSet, ClntMiscUnknownAuth, "(unknown authentication error - %d)"), #else "(unknown authentication error - %d)", #endif (int) e.re_why); } str += strlen(str); break; case RPC_PROGVERSMISMATCH: (void) sprintf(str, #if NLS catgets(_libc_cat, ClntMiscSet, ClntMiscLowHigh, "; low version = %lu, high version = %lu"), #else "; low version = %lu, high version = %lu", #endif e.re_vers.low, e.re_vers.high); str += strlen(str); break; default: /* unknown */ (void) sprintf(str, "; s1 = %lu, s2 = %lu", e.re_lb.s1, e.re_lb.s2); str += strlen(str); break; } (void) sprintf(str, "\n"); return(strstart) ; } void clnt_perror(rpch, s) CLIENT *rpch; char *s; { (void) fprintf(stderr,"%s",clnt_sperror(rpch,s)); } struct rpc_errtab { enum clnt_stat status; char *message; }; static struct rpc_errtab rpc_errlist[] = { { RPC_SUCCESS, "RPC: Success" }, { RPC_CANTENCODEARGS, "RPC: Can't encode arguments" }, { RPC_CANTDECODERES, "RPC: Can't decode result" }, { RPC_CANTSEND, "RPC: Unable to send" }, { RPC_CANTRECV, "RPC: Unable to receive" }, { RPC_TIMEDOUT, "RPC: Timed out" }, { RPC_VERSMISMATCH, "RPC: Incompatible versions of RPC" }, { RPC_AUTHERROR, "RPC: Authentication error" }, { RPC_PROGUNAVAIL, "RPC: Program unavailable" }, { RPC_PROGVERSMISMATCH, "RPC: Program/version mismatch" }, { RPC_PROCUNAVAIL, "RPC: Procedure unavailable" }, { RPC_CANTDECODEARGS, "RPC: Server can't decode arguments" }, { RPC_SYSTEMERROR, "RPC: Remote system error" }, { RPC_UNKNOWNHOST, "RPC: Unknown host" }, { RPC_UNKNOWNPROTO, "RPC: Unknown protocol" }, { RPC_PMAPFAILURE, "RPC: Port mapper failure" }, { RPC_PROGNOTREGISTERED, "RPC: Program not registered"}, { RPC_FAILED, "RPC: Failed (unspecified error)"} }; /* * This interface for use by clntrpc */ char * clnt_sperrno(stat) enum clnt_stat stat; { int i; #if NLS libc_nls_init(); #endif for (i = 0; i < sizeof(rpc_errlist)/sizeof(struct rpc_errtab); i++) { if (rpc_errlist[i].status == stat) { #if NLS return catgets(_libc_cat, RpcErrListSet, stat+1, rpc_errlist[i].message); #else return (rpc_errlist[i].message); #endif } } #if NLS return catgets(_libc_cat, RpcErrListSet, RpcErrListUnknown, "RPC: (unknown error code)"); #else return ("RPC: (unknown error code)"); #endif } void clnt_perrno(num) enum clnt_stat num; { (void) fprintf(stderr,"%s",clnt_sperrno(num)); } char * clnt_spcreateerror(s) char *s; { #ifndef linux extern int sys_nerr; extern char *sys_errlist[]; #endif char *str = _buf(); if (str == 0) return(0); #if NLS libc_nls_init(); #endif (void) sprintf(str, "%s: ", s); (void) strcat(str, clnt_sperrno(rpc_createerr.cf_stat)); switch (rpc_createerr.cf_stat) { case RPC_PMAPFAILURE: (void) strcat(str, " - "); (void) strcat(str, clnt_sperrno(rpc_createerr.cf_error.re_status)); break; case RPC_SYSTEMERROR: (void) strcat(str, " - "); if (rpc_createerr.cf_error.re_errno > 0 && rpc_createerr.cf_error.re_errno < sys_nerr) (void) strcat(str, #if NLS catgets(_libc_cat, ErrorListSet, rpc_createerr.cf_error.re_errno+1, sys_errlist[rpc_createerr.cf_error.re_errno])); #else sys_errlist[rpc_createerr.cf_error.re_errno]); #endif else (void) sprintf(&str[strlen(str)], "Error %d", rpc_createerr.cf_error.re_errno); break; } (void) strcat(str, "\n"); return (str); } void clnt_pcreateerror(s) char *s; { (void) fprintf(stderr,"%s",clnt_spcreateerror(s)); } struct auth_errtab { enum auth_stat status; char *message; }; static struct auth_errtab auth_errlist[] = { { AUTH_OK, "Authentication OK" }, { AUTH_BADCRED, "Invalid client credential" }, { AUTH_REJECTEDCRED, "Server rejected credential" }, { AUTH_BADVERF, "Invalid client verifier" }, { AUTH_REJECTEDVERF, "Server rejected verifier" }, { AUTH_TOOWEAK, "Client credential too weak" }, { AUTH_INVALIDRESP, "Invalid server verifier" }, { AUTH_FAILED, "Failed (unspecified error)" }, }; static char * auth_errmsg(stat) enum auth_stat stat; { int i; #if NLS libc_nls_init(); #endif for (i = 0; i < sizeof(auth_errlist)/sizeof(struct auth_errtab); i++) { if (auth_errlist[i].status == stat) { #if NLS return catgets(_libc_cat, AuthListSet, i+1, auth_errlist[i].message); #else return(auth_errlist[i].message); #endif } } return(NULL); } ./libc-linux/rpc/clnt_raw.c100644 1676 334 13677 5547117735 13731 0ustar hjlisl/* @(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro"; #endif /* * clnt_raw.c * * Copyright (C) 1984, Sun Microsystems, Inc. * * Memory based rpc for simple testing and timing. * Interface to create an rpc client and server in the same process. * This lets us similate rpc and get round trip overhead, without * any interference from the kernal. */ #include #ifdef __STDC__ #include #endif #define MCALL_MSG_SIZE 24 #if NLS #include "nl_types.h" #endif /* * This is the "network" we will be moving stuff over. */ static struct clntraw_private { CLIENT client_object; XDR xdr_stream; char _raw_buf[UDPMSGSIZE]; char mashl_callmsg[MCALL_MSG_SIZE]; u_int mcnt; } *clntraw_private; static enum clnt_stat clntraw_call(); static void clntraw_abort(); static void clntraw_geterr(); static bool_t clntraw_freeres(); static bool_t clntraw_control(); static void clntraw_destroy(); static struct clnt_ops client_ops = { clntraw_call, clntraw_abort, clntraw_geterr, clntraw_freeres, clntraw_destroy, clntraw_control }; void svc_getreq(); /* * Create a client handle for memory based rpc. */ CLIENT * clntraw_create(prog, vers) u_long prog; u_long vers; { register struct clntraw_private *clp = clntraw_private; struct rpc_msg call_msg; XDR *xdrs = &clp->xdr_stream; CLIENT *client = &clp->client_object; #if NLS libc_nls_init(); #endif if (clp == 0) { clp = (struct clntraw_private *)calloc(1, sizeof (*clp)); if (clp == 0) return (0); clntraw_private = clp; } /* * pre-serialize the staic part of the call msg and stash it away */ call_msg.rm_direction = CALL; call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; call_msg.rm_call.cb_prog = prog; call_msg.rm_call.cb_vers = vers; xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE); if (! xdr_callhdr(xdrs, &call_msg)) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscFatalHeader, "clnt_raw.c - Fatal header serialization error.")); #else perror("clnt_raw.c - Fatal header serialization error."); #endif } clp->mcnt = XDR_GETPOS(xdrs); XDR_DESTROY(xdrs); /* * Set xdrmem for client/server shared buffer */ xdrmem_create(xdrs, clp->_raw_buf, UDPMSGSIZE, XDR_FREE); /* * create client handle */ client->cl_ops = &client_ops; client->cl_auth = authnone_create(); return (client); } static enum clnt_stat clntraw_call(h, proc, xargs, argsp, xresults, resultsp, timeout) CLIENT *h; u_long proc; xdrproc_t xargs; caddr_t argsp; xdrproc_t xresults; caddr_t resultsp; struct timeval timeout; { register struct clntraw_private *clp = clntraw_private; register XDR *xdrs = &clp->xdr_stream; struct rpc_msg msg; enum clnt_stat status; struct rpc_err error; if (clp == 0) return (RPC_FAILED); call_again: /* * send request */ xdrs->x_op = XDR_ENCODE; XDR_SETPOS(xdrs, 0); ((struct rpc_msg *)clp->mashl_callmsg)->rm_xid ++ ; if ((! XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) || (! XDR_PUTLONG(xdrs, (long *)&proc)) || (! AUTH_MARSHALL(h->cl_auth, xdrs)) || (! (*xargs)(xdrs, argsp))) { return (RPC_CANTENCODEARGS); } (void)XDR_GETPOS(xdrs); /* called just to cause overhead */ /* * We have to call server input routine here because this is * all going on in one process. Yuk. */ svc_getreq(1); /* * get results */ xdrs->x_op = XDR_DECODE; XDR_SETPOS(xdrs, 0); msg.acpted_rply.ar_verf = _null_auth; msg.acpted_rply.ar_results.where = resultsp; msg.acpted_rply.ar_results.proc = xresults; if (! xdr_replymsg(xdrs, &msg)) return (RPC_CANTDECODERES); _seterr_reply(&msg, &error); status = error.re_status; if (status == RPC_SUCCESS) { if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { status = RPC_AUTHERROR; } } /* end successful completion */ else { if (AUTH_REFRESH(h->cl_auth)) goto call_again; } /* end of unsuccessful completion */ if (status == RPC_SUCCESS) { if (! AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) { status = RPC_AUTHERROR; } if (msg.acpted_rply.ar_verf.oa_base != NULL) { xdrs->x_op = XDR_FREE; (void)xdr_opaque_auth(xdrs, &(msg.acpted_rply.ar_verf)); } } return (status); } static void clntraw_geterr() { } static bool_t clntraw_freeres(cl, xdr_res, res_ptr) CLIENT *cl; xdrproc_t xdr_res; caddr_t res_ptr; { register struct clntraw_private *clp = clntraw_private; register XDR *xdrs = &clp->xdr_stream; bool_t rval; if (clp == 0) { rval = (bool_t) RPC_FAILED; return (rval); } xdrs->x_op = XDR_FREE; return ((*xdr_res)(xdrs, res_ptr)); } static void clntraw_abort() { } static bool_t clntraw_control() { return (FALSE); } static void clntraw_destroy() { } ./libc-linux/rpc/auth_unix.c100644 1676 334 22011 5547117735 14102 0ustar hjlisl/* @(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; #endif /* * auth_unix.c, Implements UNIX style authentication parameters. * * Copyright (C) 1984, Sun Microsystems, Inc. * * The system is very weak. The client uses no encryption for it's * credentials and only sends null verifiers. The server sends backs * null verifiers or optionally a verifier that suggests a new short hand * for the credentials. * */ #include #include #include #include #include #ifdef __STDC__ #include #endif #include #include #include #ifdef _POSIX_SOURCE #include #endif #if NLS #include "nl_types.h" #endif /* * Unix authenticator operations vector */ static void authunix_nextverf(); static bool_t authunix_marshal(); static bool_t authunix_validate(); static bool_t authunix_refresh(); static void authunix_destroy(); static struct auth_ops auth_unix_ops = { authunix_nextverf, authunix_marshal, authunix_validate, authunix_refresh, authunix_destroy }; /* * This struct is pointed to by the ah_private field of an auth_handle. */ struct audata { struct opaque_auth au_origcred; /* original credentials */ struct opaque_auth au_shcred; /* short hand cred */ u_long au_shfaults; /* short hand cache faults */ char au_marshed[MAX_AUTH_BYTES]; u_int au_mpos; /* xdr pos at end of marshed */ }; #define AUTH_PRIVATE(auth) ((struct audata *)auth->ah_private) static void marshal_new_auth(); /* * Create a unix style authenticator. * Returns an auth handle with the given stuff in it. */ AUTH * authunix_create(machname, uid, gid, len, aup_gids) char *machname; uid_t uid; gid_t gid; register int len; gid_t *aup_gids; { struct authunix_parms aup; char mymem[MAX_AUTH_BYTES]; struct timeval now; XDR xdrs; register AUTH *auth; register struct audata *au; #if NLS libc_nls_init(); #endif /* * Allocate and set up auth handle */ auth = (AUTH *)mem_alloc(sizeof(*auth)); #ifndef KERNEL if (auth == NULL) { #if NLS (void)fprintf(stderr, "authunix_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void)fprintf(stderr, "authunix_create: out of memory\n"); #endif return (NULL); } #endif au = (struct audata *)mem_alloc(sizeof(*au)); #ifndef KERNEL if (au == NULL) { #if NLS (void)fprintf(stderr, "authunix_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void)fprintf(stderr, "authunix_create: out of memory\n"); #endif return (NULL); } #endif auth->ah_ops = &auth_unix_ops; auth->ah_private = (caddr_t)au; auth->ah_verf = au->au_shcred = _null_auth; au->au_shfaults = 0; /* * fill in param struct from the given params */ (void)gettimeofday(&now, (struct timezone *)0); aup.aup_time = now.tv_sec; aup.aup_machname = machname; aup.aup_uid = uid; aup.aup_gid = gid; aup.aup_len = (u_int)len; aup.aup_gids = aup_gids; /* * Serialize the parameters into origcred */ xdrmem_create(&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE); if (! xdr_authunix_parms(&xdrs, &aup)) abort(); au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs); au->au_origcred.oa_flavor = AUTH_UNIX; #ifdef KERNEL au->au_origcred.oa_base = mem_alloc((u_int) len); #else if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) { (void)fprintf(stderr, "authunix_create: out of memory\n"); return (NULL); } #endif bcopy(mymem, au->au_origcred.oa_base, (u_int)len); /* * set auth handle to reflect new cred. */ auth->ah_cred = au->au_origcred; marshal_new_auth(auth); return (auth); } /* * Returns an auth handle with parameters determined by doing lots of * syscalls. */ AUTH * authunix_create_default() { register int len; char machname[MAX_MACHINE_NAME + 1]; register int uid; register int gid; #ifdef _POSIX_SOURCE gid_t *gids; /* NGROUPS_MAX may not be a constant */ #else int gids[NGROUPS]; #endif AUTH *result; if (gethostname(machname, MAX_MACHINE_NAME) == -1) abort(); machname[MAX_MACHINE_NAME] = 0; uid = geteuid(); gid = getegid(); #ifdef _POSIX_SOURCE gids = (gid_t *) mem_alloc(sizeof(gid_t)*NGROUPS_MAX); if ((len = getgroups(NGROUPS_MAX, gids)) < 0) abort(); #else if ((len = getgroups(NGROUPS, gids)) < 0) abort(); #endif if (len > NGRPS) len = NGRPS; /* quietly truncate to RPC max size */ result = authunix_create(machname, uid, gid, len, gids); #ifdef _POSIX_SOURCE mem_free(gids, sizeof(gid_t)*NGROUPS_MAX); #endif return result; } /* * authunix operations */ static void authunix_nextverf(auth) AUTH *auth; { /* no action necessary */ } static bool_t authunix_marshal(auth, xdrs) AUTH *auth; XDR *xdrs; { register struct audata *au = AUTH_PRIVATE(auth); return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos)); } static bool_t authunix_validate(auth, verf) register AUTH *auth; struct opaque_auth verf; { register struct audata *au; XDR xdrs; if (verf.oa_flavor == AUTH_SHORT) { au = AUTH_PRIVATE(auth); xdrmem_create(&xdrs, verf.oa_base, verf.oa_length, XDR_DECODE); if (au->au_shcred.oa_base != NULL) { mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length); au->au_shcred.oa_base = NULL; } if (xdr_opaque_auth(&xdrs, &au->au_shcred)) { auth->ah_cred = au->au_shcred; } else { xdrs.x_op = XDR_FREE; (void)xdr_opaque_auth(&xdrs, &au->au_shcred); au->au_shcred.oa_base = NULL; auth->ah_cred = au->au_origcred; } marshal_new_auth(auth); } return (TRUE); } static bool_t authunix_refresh(auth) register AUTH *auth; { register struct audata *au = AUTH_PRIVATE(auth); struct authunix_parms aup; struct timeval now; XDR xdrs; register int stat; if (auth->ah_cred.oa_base == au->au_origcred.oa_base) { /* there is no hope. Punt */ return (FALSE); } au->au_shfaults ++; /* first deserialize the creds back into a struct authunix_parms */ aup.aup_machname = NULL; aup.aup_gids = NULL; xdrmem_create(&xdrs, au->au_origcred.oa_base, au->au_origcred.oa_length, XDR_DECODE); stat = xdr_authunix_parms(&xdrs, &aup); if (! stat) goto done; /* update the time and serialize in place */ (void)gettimeofday(&now, (struct timezone *)0); aup.aup_time = now.tv_sec; xdrs.x_op = XDR_ENCODE; XDR_SETPOS(&xdrs, 0); stat = xdr_authunix_parms(&xdrs, &aup); if (! stat) goto done; auth->ah_cred = au->au_origcred; marshal_new_auth(auth); done: /* free the struct authunix_parms created by deserializing */ xdrs.x_op = XDR_FREE; (void)xdr_authunix_parms(&xdrs, &aup); XDR_DESTROY(&xdrs); return (stat); } static void authunix_destroy(auth) register AUTH *auth; { register struct audata *au = AUTH_PRIVATE(auth); mem_free(au->au_origcred.oa_base, au->au_origcred.oa_length); if (au->au_shcred.oa_base != NULL) mem_free(au->au_shcred.oa_base, au->au_shcred.oa_length); mem_free(auth->ah_private, sizeof(struct audata)); if (auth->ah_verf.oa_base != NULL) mem_free(auth->ah_verf.oa_base, auth->ah_verf.oa_length); mem_free((caddr_t)auth, sizeof(*auth)); } /* * Marshals (pre-serializes) an auth struct. * sets private data, au_marshed and au_mpos */ static void marshal_new_auth(auth) register AUTH *auth; { XDR xdr_stream; register XDR *xdrs = &xdr_stream; register struct audata *au = AUTH_PRIVATE(auth); #if NLS libc_nls_init(); #endif xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE); if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) || (! xdr_opaque_auth(xdrs, &(auth->ah_verf)))) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscFatalMarshall, "auth_none.c - Fatal marshalling problem")); #else perror("auth_none.c - Fatal marshalling problem"); #endif } else { au->au_mpos = XDR_GETPOS(xdrs); } XDR_DESTROY(xdrs); } ./libc-linux/rpc/svc_tcp.c100644 1676 334 27122 5547117736 13550 0ustar hjlisl/* @(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro"; #endif /* * svc_tcp.c, Server side for TCP/IP based RPC. * * Copyright (C) 1984, Sun Microsystems, Inc. * * Actually implements two flavors of transporter - * a tcp rendezvouser (a listner and connection establisher) * and a record/tcp stream. */ #include #include #include #include #ifndef linux extern bool_t abort(); extern errno; #endif #include #ifdef __STDC__ #include #endif #if NLS #include "nl_types.h" #endif /* * Ops vector for TCP/IP based rpc service handle */ static bool_t svctcp_recv(); static enum xprt_stat svctcp_stat(); static bool_t svctcp_getargs(); static bool_t svctcp_reply(); static bool_t svctcp_freeargs(); static void svctcp_destroy(); static struct xp_ops svctcp_op = { svctcp_recv, svctcp_stat, svctcp_getargs, svctcp_reply, svctcp_freeargs, svctcp_destroy }; /* * Ops vector for TCP/IP rendezvous handler */ static bool_t rendezvous_request(); static enum xprt_stat rendezvous_stat(); static struct xp_ops svctcp_rendezvous_op = { rendezvous_request, rendezvous_stat, (bool_t (*)()) abort, (bool_t (*)()) abort, (bool_t (*)()) abort, svctcp_destroy }; static int readtcp(), writetcp(); static SVCXPRT *makefd_xprt(); struct tcp_rendezvous { /* kept in xprt->xp_p1 */ u_int sendsize; u_int recvsize; }; struct tcp_conn { /* kept in xprt->xp_p1 */ enum xprt_stat strm_stat; u_long x_id; XDR xdrs; char verf_body[MAX_AUTH_BYTES]; }; /* * Usage: * xprt = svctcp_create(sock, send_buf_size, recv_buf_size); * * Creates, registers, and returns a (rpc) tcp based transporter. * Once *xprt is initialized, it is registered as a transporter * see (svc.h, xprt_register). This routine returns * a NULL if a problem occurred. * * If sock<0 then a socket is created, else sock is used. * If the socket, sock is not bound to a port then svctcp_create * binds it to an arbitrary port. The routine then starts a tcp * listener on the socket's associated port. In any (successful) case, * xprt->xp_sock is the registered socket number and xprt->xp_port is the * associated port number. * * Since tcp streams do buffered io similar to stdio, the caller can specify * how big the send and receive buffers are via the second and third parms; * 0 => use the system default. */ SVCXPRT * svctcp_create(sock, sendsize, recvsize) register int sock; u_int sendsize; u_int recvsize; { bool_t madesock = FALSE; register SVCXPRT *xprt; register struct tcp_rendezvous *r; struct sockaddr_in addr; int len = sizeof(struct sockaddr_in); #if NLS libc_nls_init(); #endif if (sock == RPC_ANYSOCK) { if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscTcpSocketCreateProblem, "svc_tcp.c - tcp socket creation problem")); #else perror("svc_tcp.c - tcp socket creation problem"); #endif return ((SVCXPRT *)NULL); } madesock = TRUE; } bzero((char *)&addr, sizeof (addr)); addr.sin_family = AF_INET; if (bindresvport(sock, &addr)) { addr.sin_port = 0; (void)bind(sock, (struct sockaddr *)&addr, len); } if ((getsockname(sock, (struct sockaddr *)&addr, &len) != 0) || (listen(sock, 2) != 0)) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscCantGetNameListen, "svctcp_.c - cannot getsockname or listen")); #else perror("svctcp_.c - cannot getsockname or listen"); #endif if (madesock) (void)close(sock); return ((SVCXPRT *)NULL); } r = (struct tcp_rendezvous *)mem_alloc(sizeof(*r)); if (r == NULL) { #if NLS (void) fprintf(stderr, "svctcp_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void) fprintf(stderr, "svctcp_create: out of memory\n"); #endif return (NULL); } r->sendsize = sendsize; r->recvsize = recvsize; xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); if (xprt == NULL) { #if NLS (void) fprintf(stderr, "svctcp_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void) fprintf(stderr, "svctcp_create: out of memory\n"); #endif return (NULL); } xprt->xp_p2 = NULL; xprt->xp_p1 = (caddr_t)r; xprt->xp_verf = _null_auth; xprt->xp_ops = &svctcp_rendezvous_op; xprt->xp_port = ntohs(addr.sin_port); xprt->xp_sock = sock; xprt_register(xprt); return (xprt); } /* * Like svtcp_create(), except the routine takes any *open* UNIX file * descriptor as its first input. */ SVCXPRT * svcfd_create(fd, sendsize, recvsize) int fd; u_int sendsize; u_int recvsize; { return (makefd_xprt(fd, sendsize, recvsize)); } static SVCXPRT * makefd_xprt(fd, sendsize, recvsize) int fd; u_int sendsize; u_int recvsize; { register SVCXPRT *xprt; register struct tcp_conn *cd; xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); if (xprt == (SVCXPRT *)NULL) { #if NLS libc_nls_init(); #endif #if NLS (void) fprintf(stderr, "svc_tcp: makefd_xprt: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n"); #endif goto done; } cd = (struct tcp_conn *)mem_alloc(sizeof(struct tcp_conn)); if (cd == (struct tcp_conn *)NULL) { #if NLS (void) fprintf(stderr, "svc_tcp: makefd_xprt: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void) fprintf(stderr, "svc_tcp: makefd_xprt: out of memory\n"); #endif mem_free((char *) xprt, sizeof(SVCXPRT)); xprt = (SVCXPRT *)NULL; goto done; } cd->strm_stat = XPRT_IDLE; xdrrec_create(&(cd->xdrs), sendsize, recvsize, (caddr_t)xprt, readtcp, writetcp); xprt->xp_p2 = NULL; xprt->xp_p1 = (caddr_t)cd; xprt->xp_verf.oa_base = cd->verf_body; xprt->xp_addrlen = 0; xprt->xp_ops = &svctcp_op; /* truely deals with calls */ xprt->xp_port = 0; /* this is a connection, not a rendezvouser */ xprt->xp_sock = fd; xprt_register(xprt); done: return (xprt); } static bool_t rendezvous_request(xprt) register SVCXPRT *xprt; { int sock; struct tcp_rendezvous *r; struct sockaddr_in addr; int len; r = (struct tcp_rendezvous *)xprt->xp_p1; again: len = sizeof(struct sockaddr_in); if ((sock = accept(xprt->xp_sock, (struct sockaddr *)&addr, &len)) < 0) { if (errno == EINTR) goto again; return (FALSE); } /* * make a new transporter (re-uses xprt) */ xprt = makefd_xprt(sock, r->sendsize, r->recvsize); xprt->xp_raddr = addr; xprt->xp_addrlen = len; return (FALSE); /* there is never an rpc msg to be processed */ } static enum xprt_stat rendezvous_stat() { return (XPRT_IDLE); } static void svctcp_destroy(xprt) register SVCXPRT *xprt; { register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1; xprt_unregister(xprt); (void)close(xprt->xp_sock); if (xprt->xp_port != 0) { /* a rendezvouser socket */ xprt->xp_port = 0; } else { /* an actual connection socket */ XDR_DESTROY(&(cd->xdrs)); } mem_free((caddr_t)cd, sizeof(struct tcp_conn)); mem_free((caddr_t)xprt, sizeof(SVCXPRT)); } /* * All read operations timeout after 35 seconds. * A timeout is fatal for the connection. */ static struct timeval wait_per_try = { 35, 0 }; /* * reads data from the tcp conection. * any error is fatal and the connection is closed. * (And a read of zero bytes is a half closed stream => error.) */ static int readtcp(xprt, buf, len) register SVCXPRT *xprt; caddr_t buf; register int len; { register int sock = xprt->xp_sock; #ifdef FD_SETSIZE fd_set mask; fd_set readfds; FD_ZERO(&mask); FD_SET(sock, &mask); #else register int mask = 1 << sock; int readfds; #endif /* def FD_SETSIZE */ do { #ifdef linux struct timeval timeout; readfds = mask; timeout = wait_per_try; if (select(_rpc_dtablesize(), &readfds, (void*)NULL, (void*)NULL, &timeout) <= 0) { #else readfds = mask; if (select(_rpc_dtablesize(), &readfds, (void*)NULL, (void*)NULL, &wait_per_try) <= 0) { #endif if (errno == EINTR) { continue; } goto fatal_err; } #ifdef FD_SETSIZE } while (!FD_ISSET(sock, &readfds)); #else } while (readfds != mask); #endif /* def FD_SETSIZE */ if ((len = read(sock, buf, len)) > 0) { return (len); } fatal_err: ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED; return (-1); } /* * writes data to the tcp connection. * Any error is fatal and the connection is closed. */ static int writetcp(xprt, buf, len) register SVCXPRT *xprt; caddr_t buf; int len; { register int i, cnt; for (cnt = len; cnt > 0; cnt -= i, buf += i) { if ((i = write(xprt->xp_sock, buf, cnt)) < 0) { ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED; return (-1); } } return (len); } static enum xprt_stat svctcp_stat(xprt) SVCXPRT *xprt; { register struct tcp_conn *cd = (struct tcp_conn *)(xprt->xp_p1); if (cd->strm_stat == XPRT_DIED) return (XPRT_DIED); if (! xdrrec_eof(&(cd->xdrs))) return (XPRT_MOREREQS); return (XPRT_IDLE); } static bool_t svctcp_recv(xprt, msg) SVCXPRT *xprt; register struct rpc_msg *msg; { register struct tcp_conn *cd = (struct tcp_conn *)(xprt->xp_p1); register XDR *xdrs = &(cd->xdrs); xdrs->x_op = XDR_DECODE; (void)xdrrec_skiprecord(xdrs); if (xdr_callmsg(xdrs, msg)) { cd->x_id = msg->rm_xid; return (TRUE); } return (FALSE); } static bool_t svctcp_getargs(xprt, xdr_args, args_ptr) SVCXPRT *xprt; xdrproc_t xdr_args; caddr_t args_ptr; { return ((*xdr_args)(&(((struct tcp_conn *)(xprt->xp_p1))->xdrs), args_ptr)); } static bool_t svctcp_freeargs(xprt, xdr_args, args_ptr) SVCXPRT *xprt; xdrproc_t xdr_args; caddr_t args_ptr; { register XDR *xdrs = &(((struct tcp_conn *)(xprt->xp_p1))->xdrs); xdrs->x_op = XDR_FREE; return ((*xdr_args)(xdrs, args_ptr)); } static bool_t svctcp_reply(xprt, msg) SVCXPRT *xprt; register struct rpc_msg *msg; { register struct tcp_conn *cd = (struct tcp_conn *)(xprt->xp_p1); register XDR *xdrs = &(cd->xdrs); register bool_t stat; xdrs->x_op = XDR_ENCODE; msg->rm_xid = cd->x_id; stat = xdr_replymsg(xdrs, msg); (void)xdrrec_endofrecord(xdrs, TRUE); return (stat); } ./libc-linux/rpc/pmap_rmt.c100644 1676 334 32203 5547117736 13722 0ustar hjlisl/* @(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro"; #endif /* * pmap_rmt.c * Client interface to pmap rpc service. * remote call and broadcast service * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include #include #include #include #include #include #include #ifdef linux #include #endif #include #define MAX_BROADCAST_SIZE 1400 #if NLS #include "nl_types.h" #endif extern int errno; static struct timeval timeout = { 3, 0 }; /* * pmapper remote-call-service interface. * This routine is used to call the pmapper remote call service * which will look up a service program in the port maps, and then * remotely call that routine with the given parameters. This allows * programs to do a lookup and call in one step. */ enum clnt_stat pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_ptr) struct sockaddr_in *addr; u_long prog, vers, proc; xdrproc_t xdrargs, xdrres; caddr_t argsp, resp; struct timeval tout; u_long *port_ptr; { int socket = -1; register CLIENT *client; struct rmtcallargs a; struct rmtcallres r; enum clnt_stat stat; addr->sin_port = htons(PMAPPORT); client = clntudp_create(addr, PMAPPROG, PMAPVERS, timeout, &socket); if (client != (CLIENT *)NULL) { a.prog = prog; a.vers = vers; a.proc = proc; a.args_ptr = argsp; a.xdr_args = xdrargs; r.port_ptr = port_ptr; r.results_ptr = resp; r.xdr_results = xdrres; stat = CLNT_CALL(client, PMAPPROC_CALLIT, xdr_rmtcall_args, &a, xdr_rmtcallres, &r, tout); CLNT_DESTROY(client); } else { stat = RPC_FAILED; } (void)close(socket); addr->sin_port = 0; return (stat); } /* * XDR remote call arguments * written for XDR_ENCODE direction only */ bool_t xdr_rmtcall_args(xdrs, cap) register XDR *xdrs; register struct rmtcallargs *cap; { u_int lenposition, argposition, position; if (xdr_u_long(xdrs, &(cap->prog)) && xdr_u_long(xdrs, &(cap->vers)) && xdr_u_long(xdrs, &(cap->proc))) { lenposition = XDR_GETPOS(xdrs); if (! xdr_u_long(xdrs, &(cap->arglen))) return (FALSE); argposition = XDR_GETPOS(xdrs); if (! (*(cap->xdr_args))(xdrs, cap->args_ptr)) return (FALSE); position = XDR_GETPOS(xdrs); cap->arglen = (u_long)position - (u_long)argposition; XDR_SETPOS(xdrs, lenposition); if (! xdr_u_long(xdrs, &(cap->arglen))) return (FALSE); XDR_SETPOS(xdrs, position); return (TRUE); } return (FALSE); } /* * XDR remote call results * written for XDR_DECODE direction only */ bool_t xdr_rmtcallres(xdrs, crp) register XDR *xdrs; register struct rmtcallres *crp; { caddr_t port_ptr; port_ptr = (caddr_t)crp->port_ptr; if (xdr_reference(xdrs, &port_ptr, sizeof (u_long), xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) { crp->port_ptr = (u_long *)port_ptr; return ((*(crp->xdr_results))(xdrs, crp->results_ptr)); } return (FALSE); } /* * The following is kludged-up support for simple rpc broadcasts. * Someday a large, complicated system will replace these trivial * routines which only support udp/ip . */ #ifdef linux static struct in_addr bc_addr(struct in_addr addr) { /* could use /etc/networks but I'm too lazy */ return inet_makeaddr(inet_netof(addr), INADDR_BROADCAST); } #endif static int getbroadcastnets(addrs, sock, buf) struct in_addr *addrs; int sock; /* any valid socket will do */ char *buf; /* why allocxate more when we can use existing... */ { #if 0 char localhost[256 + 1]; struct hostent *hp; int i; #if NLS libc_nls_init(); #endif gethostname(localhost, 256); if ((hp = gethostbyname(localhost)) == NULL) { #if NLS herror(catgets(_libc_cat, RpcMiscSet, RpcMiscHostname, "get_myaddress: gethostbyname")); #else herror("get_myaddress: gethostbyname"); #endif exit(1); } for (i = 0; hp->h_addr_list[i]; i++) { addrs[i] = bc_addr(*((struct in_addr *) hp->h_addr_list[i])); #if 0 printf("broadcast_addr[%d] = %s\n", i, inet_ntoa(addrs[i])); #endif } return i; #else struct ifconf ifc; struct ifreq ifreq, *ifr; struct sockaddr_in *sin; int n, i; #if NLS libc_nls_init(); #endif ifc.ifc_len = UDPMSGSIZE; ifc.ifc_buf = buf; if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscBConfig, "broadcast: ioctl (get interface configuration)")); #else perror("broadcast: ioctl (get interface configuration)"); #endif return (0); } ifr = ifc.ifc_req; for (i = 0, n = ifc.ifc_len/sizeof (struct ifreq); n > 0; n--, ifr++) { ifreq = *ifr; if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreq) < 0) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscBFlags, "broadcast: ioctl (get interface flags)")); #else perror("broadcast: ioctl (get interface flags)"); #endif continue; } if ((ifreq.ifr_flags & IFF_BROADCAST) && (ifreq.ifr_flags & IFF_UP) && ifr->ifr_addr.sa_family == AF_INET) { sin = (struct sockaddr_in *)&ifr->ifr_addr; #ifdef SIOCGIFBRDADDR /* 4.3BSD */ if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { addrs[i++] = inet_makeaddr((int)inet_netof (sin->sin_addr), INADDR_ANY); } else { addrs[i++] = ((struct sockaddr_in*) &ifreq.ifr_addr)->sin_addr; } #else /* 4.2 BSD */ addrs[i++] = inet_makeaddr(inet_netof (sin->sin_addr.s_addr), INADDR_ANY); #endif } } return (i); #endif } #ifndef linux typedef bool_t (*resultproc_t)(); #endif enum clnt_stat clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) u_long prog; /* program number */ u_long vers; /* version number */ u_long proc; /* procedure number */ xdrproc_t xargs; /* xdr routine for args */ caddr_t argsp; /* pointer to args */ xdrproc_t xresults; /* xdr routine for results */ caddr_t resultsp; /* pointer to results */ resultproc_t eachresult; /* call with each result obtained */ { enum clnt_stat stat; AUTH *unix_auth = authunix_create_default(); XDR xdr_stream; register XDR *xdrs = &xdr_stream; int outlen, inlen, fromlen, nets; register int sock; int on = 1; #ifdef FD_SETSIZE fd_set mask; fd_set readfds; #else int readfds; register int mask; #endif /* def FD_SETSIZE */ register int i; bool_t done = FALSE; register u_long xid; u_long port; struct in_addr addrs[20]; struct sockaddr_in baddr, raddr; /* broadcast and response addresses */ struct rmtcallargs a; struct rmtcallres r; struct rpc_msg msg; struct timeval t; #ifdef linux struct timeval timeout; #endif char outbuf[MAX_BROADCAST_SIZE], inbuf[UDPMSGSIZE]; #if NLS libc_nls_init(); #endif /* * initialization: create a socket, a broadcast address, and * preserialize the arguments into a send buffer. */ if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { #if NLS perror(catgets(_libc_cat, RpcMiscSet,RpcMiscCantCreateBSocket, "Cannot create socket for broadcast rpc")); #else perror("Cannot create socket for broadcast rpc"); #endif stat = RPC_CANTSEND; goto done_broad; } #ifdef SO_BROADCAST if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { #if NLS perror(catgets(_libc_cat, RpcMiscSet,RpcMiscCantSetBOption, "Cannot set socket option SO_BROADCAST")); #else perror("Cannot set socket option SO_BROADCAST"); #endif stat = RPC_CANTSEND; goto done_broad; } #endif /* def SO_BROADCAST */ #ifdef FD_SETSIZE FD_ZERO(&mask); FD_SET(sock, &mask); #else mask = (1 << sock); #endif /* def FD_SETSIZE */ nets = getbroadcastnets(addrs, sock, inbuf); bzero((char *)&baddr, sizeof (baddr)); baddr.sin_family = AF_INET; baddr.sin_port = htons(PMAPPORT); baddr.sin_addr.s_addr = htonl(INADDR_ANY); /* baddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY); */ (void)gettimeofday(&t, (struct timezone *)0); msg.rm_xid = xid = getpid() ^ t.tv_sec ^ t.tv_usec; t.tv_usec = 0; msg.rm_direction = CALL; msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; msg.rm_call.cb_prog = PMAPPROG; msg.rm_call.cb_vers = PMAPVERS; msg.rm_call.cb_proc = PMAPPROC_CALLIT; msg.rm_call.cb_cred = unix_auth->ah_cred; msg.rm_call.cb_verf = unix_auth->ah_verf; a.prog = prog; a.vers = vers; a.proc = proc; a.xdr_args = xargs; a.args_ptr = argsp; r.port_ptr = &port; r.xdr_results = xresults; r.results_ptr = resultsp; xdrmem_create(xdrs, outbuf, MAX_BROADCAST_SIZE, XDR_ENCODE); if ((! xdr_callmsg(xdrs, &msg)) || (! xdr_rmtcall_args(xdrs, &a))) { stat = RPC_CANTENCODEARGS; goto done_broad; } outlen = (int)xdr_getpos(xdrs); xdr_destroy(xdrs); /* * Basic loop: broadcast a packet and wait a while for response(s). * The response timeout grows larger per iteration. */ for (t.tv_sec = 4; t.tv_sec <= 14; t.tv_sec += 2) { for (i = 0; i < nets; i++) { baddr.sin_addr = addrs[i]; if (sendto(sock, outbuf, outlen, 0, (struct sockaddr *)&baddr, sizeof (struct sockaddr)) != outlen) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscCantSendBPacket, "Cannot send broadcast packet")); #else perror("Cannot send broadcast packet"); #endif stat = RPC_CANTSEND; goto done_broad; } } if (eachresult == NULL) { stat = RPC_SUCCESS; goto done_broad; } recv_again: msg.acpted_rply.ar_verf = _null_auth; msg.acpted_rply.ar_results.where = (caddr_t)&r; msg.acpted_rply.ar_results.proc = xdr_rmtcallres; readfds = mask; #ifdef linux timeout = t; switch (select(_rpc_dtablesize(), &readfds, (void *)NULL, (void *)NULL, &timeout)) { #else switch (select(_rpc_dtablesize(), &readfds, (void *)NULL, (void *)NULL, &t)) { #endif case 0: /* timed out */ stat = RPC_TIMEDOUT; continue; case -1: /* some kind of error */ if (errno == EINTR) goto recv_again; #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscBSelectProblem, "Broadcast select problem")); #else perror("Broadcast select problem"); #endif stat = RPC_CANTRECV; goto done_broad; } /* end of select results switch */ try_again: fromlen = sizeof(struct sockaddr); inlen = recvfrom(sock, inbuf, UDPMSGSIZE, 0, (struct sockaddr *)&raddr, &fromlen); if (inlen < 0) { if (errno == EINTR) goto try_again; #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscCantReceiveBReply, "Cannot receive reply to broadcast")); #else perror("Cannot receive reply to broadcast"); #endif stat = RPC_CANTRECV; goto done_broad; } if (inlen < sizeof(u_long)) goto recv_again; /* * see if reply transaction id matches sent id. * If so, decode the results. */ xdrmem_create(xdrs, inbuf, (u_int)inlen, XDR_DECODE); if (xdr_replymsg(xdrs, &msg)) { if ((msg.rm_xid == xid) && (msg.rm_reply.rp_stat == MSG_ACCEPTED) && (msg.acpted_rply.ar_stat == SUCCESS)) { raddr.sin_port = htons((u_short)port); done = (*eachresult)(resultsp, &raddr); } /* otherwise, we just ignore the errors ... */ } else { #ifdef notdef /* some kind of deserialization problem ... */ if (msg.rm_xid == xid) #if NLS fprintf(stderr,catgets(_libc_cat, RpcMiscSet, RpcMiscBDesProblem, "Broadcast deserialization problem")); #else fprintf(stderr, "Broadcast deserialization problem"); #endif /* otherwise, just random garbage */ #endif } xdrs->x_op = XDR_FREE; msg.acpted_rply.ar_results.proc = xdr_void; (void)xdr_replymsg(xdrs, &msg); (void)(*xresults)(xdrs, resultsp); xdr_destroy(xdrs); if (done) { stat = RPC_SUCCESS; goto done_broad; } else { goto recv_again; } } done_broad: (void)close(sock); AUTH_DESTROY(unix_auth); return (stat); } ./libc-linux/rpc/xdr.c100644 1676 334 26543 5547117736 12712 0ustar hjlisl/* @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)xdr.c 1.35 87/08/12"; #endif /* * xdr.c, Generic XDR routines implementation. * * Copyright (C) 1986, Sun Microsystems, Inc. * * These are the "generic" xdr routines used to serialize and de-serialize * most common data items. See xdr.h for more info on the interface to * xdr. */ #include #ifdef __STDC__ #include #else char *malloc(); #endif #include #include #if NLS #include "nl_types.h" #endif /* * constants specific to the xdr "protocol" */ #define XDR_FALSE ((long) 0) #define XDR_TRUE ((long) 1) #define LASTUNSIGNED ((u_int) 0-1) /* * for unit alignment */ static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; /* * Free a data structure using XDR * Not a filter, but a convenient utility nonetheless */ void xdr_free(proc, objp) xdrproc_t proc; char *objp; { XDR x; x.x_op = XDR_FREE; (*proc)(&x, objp); } /* * XDR nothing */ bool_t xdr_void(/* xdrs, addr */) /* XDR *xdrs; */ /* caddr_t addr; */ { return (TRUE); } /* * XDR integers */ bool_t xdr_int(xdrs, ip) XDR *xdrs; int *ip; { #ifdef lint (void) (xdr_short(xdrs, (short *)ip)); return (xdr_long(xdrs, (long *)ip)); #else if (sizeof (int) == sizeof (long)) { return (xdr_long(xdrs, (long *)ip)); } else { return (xdr_short(xdrs, (short *)ip)); } #endif } /* * XDR unsigned integers */ bool_t xdr_u_int(xdrs, up) XDR *xdrs; u_int *up; { #ifdef lint (void) (xdr_short(xdrs, (short *)up)); return (xdr_u_long(xdrs, (u_long *)up)); #else if (sizeof (u_int) == sizeof (u_long)) { return (xdr_u_long(xdrs, (u_long *)up)); } else { return (xdr_short(xdrs, (short *)up)); } #endif } /* * XDR long integers * same as xdr_u_long - open coded to save a proc call! */ bool_t xdr_long(xdrs, lp) register XDR *xdrs; long *lp; { if (xdrs->x_op == XDR_ENCODE) return (XDR_PUTLONG(xdrs, lp)); if (xdrs->x_op == XDR_DECODE) return (XDR_GETLONG(xdrs, lp)); if (xdrs->x_op == XDR_FREE) return (TRUE); return (FALSE); } /* * XDR unsigned long integers * same as xdr_long - open coded to save a proc call! */ bool_t xdr_u_long(xdrs, ulp) register XDR *xdrs; u_long *ulp; { if (xdrs->x_op == XDR_DECODE) return (XDR_GETLONG(xdrs, (long *)ulp)); if (xdrs->x_op == XDR_ENCODE) return (XDR_PUTLONG(xdrs, (long *)ulp)); if (xdrs->x_op == XDR_FREE) return (TRUE); return (FALSE); } /* * XDR short integers */ bool_t xdr_short(xdrs, sp) register XDR *xdrs; short *sp; { long l; switch (xdrs->x_op) { case XDR_ENCODE: l = (long) *sp; return (XDR_PUTLONG(xdrs, &l)); case XDR_DECODE: if (!XDR_GETLONG(xdrs, &l)) { return (FALSE); } *sp = (short) l; return (TRUE); case XDR_FREE: return (TRUE); } return (FALSE); } /* * XDR unsigned short integers */ bool_t xdr_u_short(xdrs, usp) register XDR *xdrs; u_short *usp; { u_long l; switch (xdrs->x_op) { case XDR_ENCODE: l = (u_long) *usp; return (XDR_PUTLONG(xdrs, &l)); case XDR_DECODE: if (!XDR_GETLONG(xdrs, &l)) { return (FALSE); } *usp = (u_short) l; return (TRUE); case XDR_FREE: return (TRUE); } return (FALSE); } /* * XDR a char */ bool_t xdr_char(xdrs, cp) XDR *xdrs; char *cp; { int i; i = (*cp); if (!xdr_int(xdrs, &i)) { return (FALSE); } *cp = i; return (TRUE); } /* * XDR an unsigned char */ bool_t xdr_u_char(xdrs, ucp) XDR *xdrs; u_char *ucp; { u_int u; u = (*ucp); if (!xdr_u_int(xdrs, &u)) { return (FALSE); } *ucp = u; return (TRUE); } /* * XDR booleans */ bool_t xdr_bool(xdrs, bp) register XDR *xdrs; bool_t *bp; { long lb; switch (xdrs->x_op) { case XDR_ENCODE: lb = *bp ? XDR_TRUE : XDR_FALSE; return (XDR_PUTLONG(xdrs, &lb)); case XDR_DECODE: if (!XDR_GETLONG(xdrs, &lb)) { return (FALSE); } *bp = (lb == XDR_FALSE) ? FALSE : TRUE; return (TRUE); case XDR_FREE: return (TRUE); } return (FALSE); } /* * XDR enumerations */ bool_t xdr_enum(xdrs, ep) XDR *xdrs; enum_t *ep; { #ifndef lint enum sizecheck { SIZEVAL }; /* used to find the size of an enum */ /* * enums are treated as ints */ if (sizeof (enum sizecheck) == sizeof (long)) { return (xdr_long(xdrs, (long *)ep)); } else if (sizeof (enum sizecheck) == sizeof (short)) { return (xdr_short(xdrs, (short *)ep)); } else { return (FALSE); } #else (void) (xdr_short(xdrs, (short *)ep)); return (xdr_long(xdrs, (long *)ep)); #endif } /* * XDR opaque data * Allows the specification of a fixed size sequence of opaque bytes. * cp points to the opaque object and cnt gives the byte length. */ bool_t xdr_opaque(xdrs, cp, cnt) register XDR *xdrs; caddr_t cp; register u_int cnt; { register u_int rndup; static crud[BYTES_PER_XDR_UNIT]; /* * if no data we are done */ if (cnt == 0) return (TRUE); /* * round byte count to full xdr units */ rndup = cnt % BYTES_PER_XDR_UNIT; if (rndup > 0) rndup = BYTES_PER_XDR_UNIT - rndup; if (xdrs->x_op == XDR_DECODE) { if (!XDR_GETBYTES(xdrs, cp, cnt)) { return (FALSE); } if (rndup == 0) return (TRUE); return (XDR_GETBYTES(xdrs, crud, rndup)); } if (xdrs->x_op == XDR_ENCODE) { if (!XDR_PUTBYTES(xdrs, cp, cnt)) { return (FALSE); } if (rndup == 0) return (TRUE); return (XDR_PUTBYTES(xdrs, xdr_zero, rndup)); } if (xdrs->x_op == XDR_FREE) { return (TRUE); } return (FALSE); } /* * XDR counted bytes * *cpp is a pointer to the bytes, *sizep is the count. * If *cpp is NULL maxsize bytes are allocated */ bool_t xdr_bytes(xdrs, cpp, sizep, maxsize) register XDR *xdrs; char **cpp; register u_int *sizep; u_int maxsize; { register char *sp = *cpp; /* sp is the actual string pointer */ register u_int nodesize; #if NLS libc_nls_init(); #endif /* * first deal with the length since xdr bytes are counted */ if (! xdr_u_int(xdrs, sizep)) { return (FALSE); } nodesize = *sizep; if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) { return (FALSE); } /* * now deal with the actual bytes */ switch (xdrs->x_op) { case XDR_DECODE: if (nodesize == 0) { return (TRUE); } if (sp == NULL) { *cpp = sp = (char *)mem_alloc(nodesize); } if (sp == NULL) { #if NLS (void) fprintf(stderr, "xdr_bytes: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void) fprintf(stderr, "xdr_bytes: out of memory\n"); #endif return (FALSE); } /* fall into ... */ case XDR_ENCODE: return (xdr_opaque(xdrs, sp, nodesize)); case XDR_FREE: if (sp != NULL) { mem_free(sp, nodesize); *cpp = NULL; } return (TRUE); } return (FALSE); } /* * Implemented here due to commonality of the object. */ bool_t xdr_netobj(xdrs, np) XDR *xdrs; struct netobj *np; { return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ)); } /* * XDR a descriminated union * Support routine for discriminated unions. * You create an array of xdrdiscrim structures, terminated with * an entry with a null procedure pointer. The routine gets * the discriminant value and then searches the array of xdrdiscrims * looking for that value. It calls the procedure given in the xdrdiscrim * to handle the discriminant. If there is no specific routine a default * routine may be called. * If there is no specific or default routine an error is returned. */ bool_t xdr_union(xdrs, dscmp, unp, choices, dfault) register XDR *xdrs; enum_t *dscmp; /* enum to decide which arm to work on */ char *unp; /* the union itself */ struct xdr_discrim *choices; /* [value, xdr proc] for each arm */ xdrproc_t dfault; /* default xdr routine */ { register enum_t dscm; /* * we deal with the discriminator; it's an enum */ if (! xdr_enum(xdrs, dscmp)) { return (FALSE); } dscm = *dscmp; /* * search choices for a value that matches the discriminator. * if we find one, execute the xdr routine for that value. */ for (; choices->proc != NULL_xdrproc_t; choices++) { if (choices->value == dscm) return ((*(choices->proc))(xdrs, unp, LASTUNSIGNED)); } /* * no match - execute the default xdr routine if there is one */ return ((dfault == NULL_xdrproc_t) ? FALSE : (*dfault)(xdrs, unp, LASTUNSIGNED)); } /* * Non-portable xdr primitives. * Care should be taken when moving these routines to new architectures. */ /* * XDR null terminated ASCII strings * xdr_string deals with "C strings" - arrays of bytes that are * terminated by a NULL character. The parameter cpp references a * pointer to storage; If the pointer is null, then the necessary * storage is allocated. The last parameter is the max allowed length * of the string as specified by a protocol. */ bool_t xdr_string(xdrs, cpp, maxsize) register XDR *xdrs; char **cpp; u_int maxsize; { register char *sp = *cpp; /* sp is the actual string pointer */ u_int size; u_int nodesize; #if NLS libc_nls_init(); #endif /* * first deal with the length since xdr strings are counted-strings */ switch (xdrs->x_op) { case XDR_FREE: if (sp == NULL) { return(TRUE); /* already free */ } /* fall through... */ case XDR_ENCODE: size = strlen(sp); break; } if (! xdr_u_int(xdrs, &size)) { return (FALSE); } if (size > maxsize) { return (FALSE); } nodesize = size + 1; /* * now deal with the actual bytes */ switch (xdrs->x_op) { case XDR_DECODE: if (nodesize == 0) { return (TRUE); } if (sp == NULL) *cpp = sp = (char *)mem_alloc(nodesize); if (sp == NULL) { #if NLS (void) fprintf(stderr, "xdr_string: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void) fprintf(stderr, "xdr_string: out of memory\n"); #endif return (FALSE); } sp[size] = 0; /* fall into ... */ case XDR_ENCODE: return (xdr_opaque(xdrs, sp, size)); case XDR_FREE: mem_free(sp, nodesize); *cpp = NULL; return (TRUE); } return (FALSE); } /* * Wrapper for xdr_string that can be called directly from * routines like clnt_call */ bool_t xdr_wrapstring(xdrs, cpp) XDR *xdrs; char **cpp; { if (xdr_string(xdrs, cpp, LASTUNSIGNED)) { return (TRUE); } return (FALSE); } ./libc-linux/rpc/clnt_tcp.c100644 1676 334 30750 5547117737 13717 0ustar hjlisl/* @(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; #endif /* * clnt_tcp.c, Implements a TCP/IP based, client side RPC. * * Copyright (C) 1984, Sun Microsystems, Inc. * * TCP based RPC supports 'batched calls'. * A sequence of calls may be batched-up in a send buffer. The rpc call * return immediately to the client even though the call was not necessarily * sent. The batching occurs if the results' xdr routine is NULL (0) AND * the rpc timeout value is zero (see clnt.h, rpc). * * Clients should NOT casually batch calls that in fact return results; that is, * the server side should be aware that a call is batched and not produce any * return message. Batched calls that produce many result messages can * deadlock (netlock) the client and the server.... * * Now go hang yourself. */ #include #include #include #include #include #include #include #ifdef __STDC__ #include #endif #define MCALL_MSG_SIZE 24 #if NLS #include "nl_types.h" #endif extern int errno; static int readtcp(); static int writetcp(); static enum clnt_stat clnttcp_call(); static void clnttcp_abort(); static void clnttcp_geterr(); static bool_t clnttcp_freeres(); static bool_t clnttcp_control(); static void clnttcp_destroy(); static struct clnt_ops tcp_ops = { clnttcp_call, clnttcp_abort, clnttcp_geterr, clnttcp_freeres, clnttcp_destroy, clnttcp_control }; struct ct_data { int ct_sock; bool_t ct_closeit; struct timeval ct_wait; bool_t ct_waitset; /* wait set by clnt_control? */ struct sockaddr_in ct_addr; struct rpc_err ct_error; char ct_mcall[MCALL_MSG_SIZE]; /* marshalled callmsg */ u_int ct_mpos; /* pos after marshal */ XDR ct_xdrs; }; /* * Create a client handle for a tcp/ip connection. * If *sockp<0, *sockp is set to a newly created TCP socket and it is * connected to raddr. If *sockp non-negative then * raddr is ignored. The rpc/tcp package does buffering * similar to stdio, so the client must pick send and receive buffer sizes,]; * 0 => use the default. * If raddr->sin_port is 0, then a binder on the remote machine is * consulted for the right port number. * NB: *sockp is copied into a private area. * NB: It is the clients responsibility to close *sockp. * NB: The rpch->cl_auth is set null authentication. Caller may wish to set this * something more useful. */ CLIENT * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) struct sockaddr_in *raddr; u_long prog; u_long vers; register int *sockp; u_int sendsz; u_int recvsz; { CLIENT *h; register struct ct_data *ct = NULL; struct timeval now; struct rpc_msg call_msg; #if NLS libc_nls_init(); #endif h = (CLIENT *)mem_alloc(sizeof(*h)); if (h == NULL) { #if NLS (void)fprintf(stderr, "clnttcp_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void)fprintf(stderr, "clnttcp_create: out of memory\n"); #endif rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; goto fooy; } ct = (struct ct_data *)mem_alloc(sizeof(*ct)); if (ct == NULL) { #if NLS (void)fprintf(stderr, "clnttcp_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void)fprintf(stderr, "clnttcp_create: out of memory\n"); #endif rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; goto fooy; } /* * If no port number given ask the pmap for one */ if (raddr->sin_port == 0) { u_short port; if ((port = pmap_getport(raddr, prog, vers, IPPROTO_TCP)) == 0) { mem_free((caddr_t)ct, sizeof(struct ct_data)); mem_free((caddr_t)h, sizeof(CLIENT)); return ((CLIENT *)NULL); } raddr->sin_port = htons(port); } /* * If no socket given, open one */ if (*sockp < 0) { *sockp = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); (void)bindresvport(*sockp, (struct sockaddr_in *)0); if ((*sockp < 0) || (connect(*sockp, (struct sockaddr *)raddr, sizeof(*raddr)) < 0)) { rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; (void)close(*sockp); goto fooy; } ct->ct_closeit = TRUE; } else { ct->ct_closeit = FALSE; } /* * Set up private data struct */ ct->ct_sock = *sockp; ct->ct_wait.tv_usec = 0; ct->ct_waitset = FALSE; ct->ct_addr = *raddr; /* * Initialize call message */ (void)gettimeofday(&now, (struct timezone *)0); call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec; call_msg.rm_direction = CALL; call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; call_msg.rm_call.cb_prog = prog; call_msg.rm_call.cb_vers = vers; /* * pre-serialize the staic part of the call msg and stash it away */ xdrmem_create(&(ct->ct_xdrs), ct->ct_mcall, MCALL_MSG_SIZE, XDR_ENCODE); if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { if (ct->ct_closeit) { (void)close(*sockp); } goto fooy; } ct->ct_mpos = XDR_GETPOS(&(ct->ct_xdrs)); XDR_DESTROY(&(ct->ct_xdrs)); /* * Create a client handle which uses xdrrec for serialization * and authnone for authentication. */ xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, (caddr_t)ct, readtcp, writetcp); h->cl_ops = &tcp_ops; h->cl_private = (caddr_t) ct; h->cl_auth = authnone_create(); return (h); fooy: /* * Something goofed, free stuff and barf */ mem_free((caddr_t)ct, sizeof(struct ct_data)); mem_free((caddr_t)h, sizeof(CLIENT)); return ((CLIENT *)NULL); } static enum clnt_stat clnttcp_call(h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) register CLIENT *h; u_long proc; xdrproc_t xdr_args; caddr_t args_ptr; xdrproc_t xdr_results; caddr_t results_ptr; struct timeval timeout; { register struct ct_data *ct = (struct ct_data *) h->cl_private; register XDR *xdrs = &(ct->ct_xdrs); struct rpc_msg reply_msg; u_long x_id; u_long *msg_x_id = (u_long *)(ct->ct_mcall); /* yuk */ register bool_t shipnow; int refreshes = 2; if (!ct->ct_waitset) { ct->ct_wait = timeout; } shipnow = (xdr_results == (xdrproc_t)0 && timeout.tv_sec == 0 && timeout.tv_usec == 0) ? FALSE : TRUE; call_again: xdrs->x_op = XDR_ENCODE; ct->ct_error.re_status = RPC_SUCCESS; x_id = ntohl(--(*msg_x_id)); if ((! XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) || (! XDR_PUTLONG(xdrs, (long *)&proc)) || (! AUTH_MARSHALL(h->cl_auth, xdrs)) || (! (*xdr_args)(xdrs, args_ptr))) { if (ct->ct_error.re_status == RPC_SUCCESS) ct->ct_error.re_status = RPC_CANTENCODEARGS; (void)xdrrec_endofrecord(xdrs, TRUE); return (ct->ct_error.re_status); } if (! xdrrec_endofrecord(xdrs, shipnow)) return (ct->ct_error.re_status = RPC_CANTSEND); if (! shipnow) return (RPC_SUCCESS); /* * Hack to provide rpc-based message passing */ if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { return(ct->ct_error.re_status = RPC_TIMEDOUT); } /* * Keep receiving until we get a valid transaction id */ xdrs->x_op = XDR_DECODE; while (TRUE) { reply_msg.acpted_rply.ar_verf = _null_auth; reply_msg.acpted_rply.ar_results.where = NULL; reply_msg.acpted_rply.ar_results.proc = xdr_void; if (! xdrrec_skiprecord(xdrs)) return (ct->ct_error.re_status); /* now decode and validate the response header */ if (! xdr_replymsg(xdrs, &reply_msg)) { if (ct->ct_error.re_status == RPC_SUCCESS) continue; return (ct->ct_error.re_status); } if (reply_msg.rm_xid == x_id) break; } /* * process header */ _seterr_reply(&reply_msg, &(ct->ct_error)); if (ct->ct_error.re_status == RPC_SUCCESS) { if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) { ct->ct_error.re_status = RPC_AUTHERROR; ct->ct_error.re_why = AUTH_INVALIDRESP; } else if (! (*xdr_results)(xdrs, results_ptr)) { if (ct->ct_error.re_status == RPC_SUCCESS) ct->ct_error.re_status = RPC_CANTDECODERES; } /* free verifier ... */ if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { xdrs->x_op = XDR_FREE; (void)xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf)); } } /* end successful completion */ else { /* maybe our credentials need to be refreshed ... */ if (refreshes-- && AUTH_REFRESH(h->cl_auth)) goto call_again; } /* end of unsuccessful completion */ return (ct->ct_error.re_status); } static void clnttcp_geterr(h, errp) CLIENT *h; struct rpc_err *errp; { register struct ct_data *ct = (struct ct_data *) h->cl_private; *errp = ct->ct_error; } static bool_t clnttcp_freeres(cl, xdr_res, res_ptr) CLIENT *cl; xdrproc_t xdr_res; caddr_t res_ptr; { register struct ct_data *ct = (struct ct_data *)cl->cl_private; register XDR *xdrs = &(ct->ct_xdrs); xdrs->x_op = XDR_FREE; return ((*xdr_res)(xdrs, res_ptr)); } static void clnttcp_abort() { } static bool_t clnttcp_control(cl, request, info) CLIENT *cl; int request; char *info; { register struct ct_data *ct = (struct ct_data *)cl->cl_private; switch (request) { case CLSET_TIMEOUT: ct->ct_wait = *(struct timeval *)info; ct->ct_waitset = TRUE; break; case CLGET_TIMEOUT: *(struct timeval *)info = ct->ct_wait; break; case CLGET_SERVER_ADDR: *(struct sockaddr_in *)info = ct->ct_addr; break; default: return (FALSE); } return (TRUE); } static void clnttcp_destroy(h) CLIENT *h; { register struct ct_data *ct = (struct ct_data *) h->cl_private; if (ct->ct_closeit) { (void)close(ct->ct_sock); } XDR_DESTROY(&(ct->ct_xdrs)); mem_free((caddr_t)ct, sizeof(struct ct_data)); mem_free((caddr_t)h, sizeof(CLIENT)); } /* * Interface between xdr serializer and tcp connection. * Behaves like the system calls, read & write, but keeps some error state * around for the rpc level. */ static int readtcp(ct, buf, len) register struct ct_data *ct; caddr_t buf; register int len; { #ifdef FD_SETSIZE fd_set mask; fd_set readfds; if (len == 0) return (0); FD_ZERO(&mask); FD_SET(ct->ct_sock, &mask); #else register int mask = 1 << (ct->ct_sock); int readfds; if (len == 0) return (0); #endif /* def FD_SETSIZE */ while (TRUE) { #ifdef linux struct timeval timeout; readfds = mask; timeout = ct->ct_wait; switch (select(_rpc_dtablesize(), &readfds, (void*)NULL, (void*)NULL, &timeout)) { #else readfds = mask; switch (select(_rpc_dtablesize(), &readfds, (void*)NULL, (void*)NULL, &(ct->ct_wait))) { #endif case 0: ct->ct_error.re_status = RPC_TIMEDOUT; return (-1); case -1: if (errno == EINTR) continue; ct->ct_error.re_status = RPC_CANTRECV; ct->ct_error.re_errno = errno; return (-1); } break; } switch (len = read(ct->ct_sock, buf, len)) { case 0: /* premature eof */ ct->ct_error.re_errno = ECONNRESET; ct->ct_error.re_status = RPC_CANTRECV; len = -1; /* it's really an error */ break; case -1: ct->ct_error.re_errno = errno; ct->ct_error.re_status = RPC_CANTRECV; break; } return (len); } static int writetcp(ct, buf, len) struct ct_data *ct; caddr_t buf; int len; { register int i, cnt; for (cnt = len; cnt > 0; cnt -= i, buf += i) { if ((i = write(ct->ct_sock, buf, cnt)) == -1) { ct->ct_error.re_errno = errno; ct->ct_error.re_status = RPC_CANTSEND; return (-1); } } return (len); } ./libc-linux/rpc/svc_udp.c100644 1676 334 34316 5547117737 13556 0ustar hjlisl/* @(#)svc_udp.c 2.2 88/07/29 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro"; #endif /* * svc_udp.c, * Server side for UDP/IP based RPC. (Does some caching in the hopes of * achieving execute-at-most-once semantics.) * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include #include #include #ifdef __STDC__ #include #endif #define rpc_buffer(xprt) ((xprt)->xp_p1) #define MAX(a, b) ((a > b) ? a : b) static bool_t svcudp_recv(); static bool_t svcudp_reply(); static enum xprt_stat svcudp_stat(); static bool_t svcudp_getargs(); static bool_t svcudp_freeargs(); static void svcudp_destroy(); static struct xp_ops svcudp_op = { svcudp_recv, svcudp_stat, svcudp_getargs, svcudp_reply, svcudp_freeargs, svcudp_destroy }; extern int errno; #if NLS #include "nl_types.h" #endif /* * kept in xprt->xp_p2 */ struct svcudp_data { u_int su_iosz; /* byte size of send.recv buffer */ u_long su_xid; /* transaction id */ XDR su_xdrs; /* XDR handle */ char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */ char * su_cache; /* cached data, NULL if no cache */ }; #define su_data(xprt) ((struct svcudp_data *)(xprt->xp_p2)) static void cache_set(SVCXPRT *, u_long); static int cache_get (SVCXPRT *, struct rpc_msg *, char **, u_long *); /* * Usage: * xprt = svcudp_create(sock); * * If sock<0 then a socket is created, else sock is used. * If the socket, sock is not bound to a port then svcudp_create * binds it to an arbitrary port. In any (successful) case, * xprt->xp_sock is the registered socket number and xprt->xp_port is the * associated port number. * Once *xprt is initialized, it is registered as a transporter; * see (svc.h, xprt_register). * The routines returns NULL if a problem occurred. */ SVCXPRT * svcudp_bufcreate(sock, sendsz, recvsz) register int sock; u_int sendsz, recvsz; { bool_t madesock = FALSE; register SVCXPRT *xprt; register struct svcudp_data *su; struct sockaddr_in addr; int len = sizeof(struct sockaddr_in); #if NLS libc_nls_init(); #endif if (sock == RPC_ANYSOCK) { if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscUdpSocketCreateProblem, "svcudp_create: socket creation problem")); #else perror("svcudp_create: socket creation problem"); #endif return ((SVCXPRT *)NULL); } madesock = TRUE; } bzero((char *)&addr, sizeof (addr)); addr.sin_family = AF_INET; if (bindresvport(sock, &addr)) { addr.sin_port = 0; (void)bind(sock, (struct sockaddr *)&addr, len); } if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) { #if NLS perror(catgets(_libc_cat, RpcMiscSet, RpcMiscUdpCantGetName, "svcudp_create - cannot getsockname")); #else perror("svcudp_create - cannot getsockname"); #endif if (madesock) (void)close(sock); return ((SVCXPRT *)NULL); } xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); if (xprt == NULL) { #if NLS (void)fprintf(stderr, "svcudp_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void)fprintf(stderr, "svcudp_create: out of memory\n"); #endif return (NULL); } su = (struct svcudp_data *)mem_alloc(sizeof(*su)); if (su == NULL) { #if NLS (void)fprintf(stderr, "svcudp_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void)fprintf(stderr, "svcudp_create: out of memory\n"); #endif return (NULL); } su->su_iosz = ((MAX(sendsz, recvsz) + 3) / 4) * 4; if ((rpc_buffer(xprt) = mem_alloc(su->su_iosz)) == NULL) { #if NLS (void)fprintf(stderr, "svcudp_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void)fprintf(stderr, "svcudp_create: out of memory\n"); #endif return (NULL); } xdrmem_create( &(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_DECODE); su->su_cache = NULL; xprt->xp_p2 = (caddr_t)su; xprt->xp_verf.oa_base = su->su_verfbody; xprt->xp_ops = &svcudp_op; xprt->xp_port = ntohs(addr.sin_port); xprt->xp_sock = sock; xprt_register(xprt); return (xprt); } SVCXPRT * svcudp_create(sock) int sock; { return(svcudp_bufcreate(sock, UDPMSGSIZE, UDPMSGSIZE)); } static enum xprt_stat svcudp_stat(xprt) SVCXPRT *xprt; { return (XPRT_IDLE); } static bool_t svcudp_recv(xprt, msg) register SVCXPRT *xprt; struct rpc_msg *msg; { register struct svcudp_data *su = su_data(xprt); register XDR *xdrs = &(su->su_xdrs); register int rlen; char *reply; u_long replylen; again: xprt->xp_addrlen = sizeof(struct sockaddr_in); rlen = recvfrom(xprt->xp_sock, rpc_buffer(xprt), (int) su->su_iosz, 0, (struct sockaddr *)&(xprt->xp_raddr), &(xprt->xp_addrlen)); if (rlen == -1 && errno == EINTR) goto again; if (rlen < 4*sizeof(u_long)) return (FALSE); xdrs->x_op = XDR_DECODE; XDR_SETPOS(xdrs, 0); if (! xdr_callmsg(xdrs, msg)) return (FALSE); su->su_xid = msg->rm_xid; if (su->su_cache != NULL) { if (cache_get(xprt, msg, &reply, &replylen)) { (void) sendto(xprt->xp_sock, reply, (int) replylen, 0, (struct sockaddr *) &xprt->xp_raddr, xprt->xp_addrlen); return (TRUE); } } return (TRUE); } static bool_t svcudp_reply(xprt, msg) register SVCXPRT *xprt; struct rpc_msg *msg; { register struct svcudp_data *su = su_data(xprt); register XDR *xdrs = &(su->su_xdrs); register int slen; register bool_t stat = FALSE; xdrs->x_op = XDR_ENCODE; XDR_SETPOS(xdrs, 0); msg->rm_xid = su->su_xid; if (xdr_replymsg(xdrs, msg)) { slen = (int)XDR_GETPOS(xdrs); if (sendto(xprt->xp_sock, rpc_buffer(xprt), slen, 0, (struct sockaddr *)&(xprt->xp_raddr), xprt->xp_addrlen) == slen) { stat = TRUE; if (su->su_cache && slen >= 0) { cache_set(xprt, (u_long) slen); } } } return (stat); } static bool_t svcudp_getargs(xprt, xdr_args, args_ptr) SVCXPRT *xprt; xdrproc_t xdr_args; caddr_t args_ptr; { return ((*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr)); } static bool_t svcudp_freeargs(xprt, xdr_args, args_ptr) SVCXPRT *xprt; xdrproc_t xdr_args; caddr_t args_ptr; { register XDR *xdrs = &(su_data(xprt)->su_xdrs); xdrs->x_op = XDR_FREE; return ((*xdr_args)(xdrs, args_ptr)); } static void svcudp_destroy(xprt) register SVCXPRT *xprt; { register struct svcudp_data *su = su_data(xprt); xprt_unregister(xprt); (void)close(xprt->xp_sock); XDR_DESTROY(&(su->su_xdrs)); mem_free(rpc_buffer(xprt), su->su_iosz); mem_free((caddr_t)su, sizeof(struct svcudp_data)); mem_free((caddr_t)xprt, sizeof(SVCXPRT)); } /***********this could be a separate file*********************/ /* * Fifo cache for udp server * Copies pointers to reply buffers into fifo cache * Buffers are sent again if retransmissions are detected. */ #define SPARSENESS 4 /* 75% sparse */ #define CACHE_PERROR(msg) \ (void) fprintf(stderr,"%s\n", msg) #define ALLOC(type, size) \ (type *) mem_alloc((unsigned) (sizeof(type) * (size))) #define BZERO(addr, type, size) \ bzero((char *) addr, sizeof(type) * (int) (size)) /* * An entry in the cache */ typedef struct cache_node *cache_ptr; struct cache_node { /* * Index into cache is xid, proc, vers, prog and address */ u_long cache_xid; u_long cache_proc; u_long cache_vers; u_long cache_prog; struct sockaddr_in cache_addr; /* * The cached reply and length */ char * cache_reply; u_long cache_replylen; /* * Next node on the list, if there is a collision */ cache_ptr cache_next; }; /* * The entire cache */ struct udp_cache { u_long uc_size; /* size of cache */ cache_ptr *uc_entries; /* hash table of entries in cache */ cache_ptr *uc_fifo; /* fifo list of entries in cache */ u_long uc_nextvictim; /* points to next victim in fifo list */ u_long uc_prog; /* saved program number */ u_long uc_vers; /* saved version number */ u_long uc_proc; /* saved procedure number */ struct sockaddr_in uc_addr; /* saved caller's address */ }; /* * the hashing function */ #define CACHE_LOC(transp, xid) \ (xid % (SPARSENESS*((struct udp_cache *) su_data(transp)->su_cache)->uc_size)) /* * Enable use of the cache. * Note: there is no disable. */ int svcudp_enablecache(transp, size) SVCXPRT *transp; u_long size; { struct svcudp_data *su = su_data(transp); struct udp_cache *uc; #if NLS libc_nls_init(); #endif if (su->su_cache != NULL) { #if NLS CACHE_PERROR(catgets(_libc_cat, RpcMiscSet, RpcMiscCacheAlreadyEnabled, "enablecache: cache already enabled")); #else CACHE_PERROR("enablecache: cache already enabled"); #endif return(0); } uc = ALLOC(struct udp_cache, 1); if (uc == NULL) { #if NLS CACHE_PERROR(catgets(_libc_cat, RpcMiscSet, RpcMiscCantAllocateCache, "enablecache: could not allocate cache")); #else CACHE_PERROR("enablecache: could not allocate cache"); #endif return(0); } uc->uc_size = size; uc->uc_nextvictim = 0; uc->uc_entries = ALLOC(cache_ptr, size * SPARSENESS); if (uc->uc_entries == NULL) { #if NLS CACHE_PERROR(catgets(_libc_cat, RpcMiscSet, RpcMiscCantAllocateCacheData, "enablecache: could not allocate cache data")); #else CACHE_PERROR("enablecache: could not allocate cache data"); #endif return(0); } BZERO(uc->uc_entries, cache_ptr, size * SPARSENESS); uc->uc_fifo = ALLOC(cache_ptr, size); if (uc->uc_fifo == NULL) { #if NLS CACHE_PERROR(catgets(_libc_cat, RpcMiscSet, RpcMiscCantAllocateCacheFifo, "enablecache: could not allocate cache fifo")); #else CACHE_PERROR("enablecache: could not allocate cache fifo"); #endif return(0); } BZERO(uc->uc_fifo, cache_ptr, size); su->su_cache = (char *) uc; return(1); } /* * Set an entry in the cache */ static void cache_set(xprt, replylen) SVCXPRT *xprt; u_long replylen; { register cache_ptr victim; register cache_ptr *vicp; register struct svcudp_data *su = su_data(xprt); struct udp_cache *uc = (struct udp_cache *) su->su_cache; u_int loc; char *newbuf; #if NLS libc_nls_init(); #endif /* * Find space for the new entry, either by * reusing an old entry, or by mallocing a new one */ victim = uc->uc_fifo[uc->uc_nextvictim]; if (victim != NULL) { loc = CACHE_LOC(xprt, victim->cache_xid); for (vicp = &uc->uc_entries[loc]; *vicp != NULL && *vicp != victim; vicp = &(*vicp)->cache_next) ; if (*vicp == NULL) { #if NLS CACHE_PERROR(catgets(_libc_cat, RpcMiscSet, RpcMiscVictimNotFound, "cache_set: victim not found")); #else CACHE_PERROR("cache_set: victim not found"); #endif return; } *vicp = victim->cache_next; /* remote from cache */ newbuf = victim->cache_reply; } else { victim = ALLOC(struct cache_node, 1); if (victim == NULL) { #if NLS CACHE_PERROR(catgets(_libc_cat, RpcMiscSet, RpcMiscVictimAllocFailed, "cache_set: victim alloc failed")); #else CACHE_PERROR("cache_set: victim alloc failed"); #endif return; } newbuf = mem_alloc(su->su_iosz); if (newbuf == NULL) { #if NLS CACHE_PERROR(catgets(_libc_cat, RpcMiscSet, RpcMiscCantAllocateRpcBuffer, "cache_set: could not allocate new rpc_buffer")); #else CACHE_PERROR("cache_set: could not allocate new rpc_buffer"); #endif return; } } /* * Store it away */ victim->cache_replylen = replylen; victim->cache_reply = rpc_buffer(xprt); rpc_buffer(xprt) = newbuf; xdrmem_create(&(su->su_xdrs), rpc_buffer(xprt), su->su_iosz, XDR_ENCODE); victim->cache_xid = su->su_xid; victim->cache_proc = uc->uc_proc; victim->cache_vers = uc->uc_vers; victim->cache_prog = uc->uc_prog; victim->cache_addr = uc->uc_addr; loc = CACHE_LOC(xprt, victim->cache_xid); victim->cache_next = uc->uc_entries[loc]; uc->uc_entries[loc] = victim; uc->uc_fifo[uc->uc_nextvictim++] = victim; uc->uc_nextvictim %= uc->uc_size; } /* * Try to get an entry from the cache * return 1 if found, 0 if not found */ static int cache_get(xprt, msg, replyp, replylenp) SVCXPRT *xprt; struct rpc_msg *msg; char **replyp; u_long *replylenp; { u_int loc; register cache_ptr ent; register struct svcudp_data *su = su_data(xprt); register struct udp_cache *uc = (struct udp_cache *) su->su_cache; # define EQADDR(a1, a2) (bcmp((char*)&a1, (char*)&a2, sizeof(a1)) == 0) loc = CACHE_LOC(xprt, su->su_xid); for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) { if (ent->cache_xid == su->su_xid && ent->cache_proc == uc->uc_proc && ent->cache_vers == uc->uc_vers && ent->cache_prog == uc->uc_prog && EQADDR(ent->cache_addr, uc->uc_addr)) { *replyp = ent->cache_reply; *replylenp = ent->cache_replylen; return(1); } } /* * Failed to find entry * Remember a few things so we can do a set later */ uc->uc_proc = msg->rm_call.cb_proc; uc->uc_vers = msg->rm_call.cb_vers; uc->uc_prog = msg->rm_call.cb_prog; uc->uc_addr = xprt->xp_raddr; return(0); } ./libc-linux/rpc/xdr_rec.c100644 1676 334 37121 5547117737 13536 0ustar hjlisl/* @(#)xdr_rec.c 2.2 88/08/01 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro"; #endif /* * xdr_rec.c, Implements TCP/IP based XDR streams with a "record marking" * layer above tcp (for rpc's use). * * Copyright (C) 1984, Sun Microsystems, Inc. * * These routines interface XDRSTREAMS to a tcp/ip connection. * There is a record marking layer between the xdr stream * and the tcp transport level. A record is composed on one or more * record fragments. A record fragment is a thirty-two bit header followed * by n bytes of data, where n is contained in the header. The header * is represented as a htonl(u_long). Thegh order bit encodes * whether or not the fragment is the last fragment of the record * (1 => fragment is last, 0 => more fragments to follow. * The other 31 bits encode the byte length of the fragment. */ #include #include #include #include #include #include #ifdef __STDC__ #include #endif #ifndef linux extern long lseek(); #endif #if NLS #include "nl_types.h" #endif static u_int fix_buf_size(); static bool_t xdrrec_getlong(); static bool_t xdrrec_putlong(); static bool_t xdrrec_getbytes(); static bool_t xdrrec_putbytes(); static u_int xdrrec_getpos(); static bool_t xdrrec_setpos(); static long * xdrrec_inline(); static void xdrrec_destroy(); static struct xdr_ops xdrrec_ops = { xdrrec_getlong, xdrrec_putlong, xdrrec_getbytes, xdrrec_putbytes, xdrrec_getpos, xdrrec_setpos, xdrrec_inline, xdrrec_destroy }; /* * A record is composed of one or more record fragments. * A record fragment is a two-byte header followed by zero to * 2**32-1 bytes. The header is treated as a long unsigned and is * encode/decoded to the network via htonl/ntohl. The low order 31 bits * are a byte count of the fragment. The highest order bit is a boolean: * 1 => this fragment is the last fragment of the record, * 0 => this fragment is followed by more fragment(s). * * The fragment/record machinery is not general; it is constructed to * meet the needs of xdr and rpc based on tcp. */ #define LAST_FRAG ((u_long)(1 << 31)) typedef struct rec_strm { caddr_t tcp_handle; caddr_t the_buffer; /* * out-goung bits */ int (*writeit)(); caddr_t out_base; /* output buffer (points to frag header) */ caddr_t out_finger; /* next output position */ caddr_t out_boundry; /* data cannot up to this address */ u_long *frag_header; /* beginning of curren fragment */ bool_t frag_sent; /* true if buffer sent in middle of record */ /* * in-coming bits */ int (*readit)(); u_long in_size; /* fixed size of the input buffer */ caddr_t in_base; caddr_t in_finger; /* location of next byte to be had */ caddr_t in_boundry; /* can read up to this location */ long fbtbc; /* fragment bytes to be consumed */ bool_t last_frag; u_int sendsize; u_int recvsize; } RECSTREAM; /* * Internal useful routines */ static bool_t flush_out(rstrm, eor) register RECSTREAM *rstrm; bool_t eor; { register u_long eormask = (eor == TRUE) ? LAST_FRAG : 0; register u_long len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->frag_header) - sizeof(u_long); *(rstrm->frag_header) = htonl(len | eormask); len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->out_base); if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len) != (int)len) return (FALSE); rstrm->frag_header = (u_long *)rstrm->out_base; rstrm->out_finger = (caddr_t)rstrm->out_base + sizeof(u_long); return (TRUE); } static bool_t /* knows nothing about records! Only about input buffers */ fill_input_buf(rstrm) register RECSTREAM *rstrm; { register caddr_t where; u_int i; register int len; where = rstrm->in_base; i = (u_int)rstrm->in_boundry % BYTES_PER_XDR_UNIT; where += i; len = rstrm->in_size - i; if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1) return (FALSE); rstrm->in_finger = where; where += len; rstrm->in_boundry = where; return (TRUE); } static bool_t /* knows nothing about records! Only about input buffers */ get_input_bytes(rstrm, addr, len) register RECSTREAM *rstrm; register caddr_t addr; register int len; { register int current; while (len > 0) { current = (int)rstrm->in_boundry - (int)rstrm->in_finger; if (current == 0) { if (! fill_input_buf(rstrm)) return (FALSE); continue; } current = (len < current) ? len : current; bcopy(rstrm->in_finger, addr, current); rstrm->in_finger += current; addr += current; len -= current; } return (TRUE); } static bool_t /* next two bytes of the input stream are treated as a header */ set_input_fragment(rstrm) register RECSTREAM *rstrm; { u_long header; if (! get_input_bytes(rstrm, (caddr_t)&header, sizeof(header))) return (FALSE); header = (long)ntohl(header); rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE; rstrm->fbtbc = header & (~LAST_FRAG); return (TRUE); } static bool_t /* consumes input bytes; knows nothing about records! */ skip_input_bytes(rstrm, cnt) register RECSTREAM *rstrm; long cnt; { register int current; while (cnt > 0) { current = (int)rstrm->in_boundry - (int)rstrm->in_finger; if (current == 0) { if (! fill_input_buf(rstrm)) return (FALSE); continue; } current = (cnt < current) ? cnt : current; rstrm->in_finger += current; cnt -= current; } return (TRUE); } static u_int fix_buf_size(s) register u_int s; { if (s < 100) s = 4000; return (RNDUP(s)); } /* * Create an xdr handle for xdrrec * xdrrec_create fills in xdrs. Sendsize and recvsize are * send and recv buffer sizes (0 => use default). * tcp_handle is an opaque handle that is passed as the first parameter to * the procedures readit and writeit. Readit and writeit are read and * write respectively. They are like the system * calls expect that they take an opaque handle rather than an fd. */ void xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit) register XDR *xdrs; register u_int sendsize; register u_int recvsize; caddr_t tcp_handle; int (*readit)(); /* like read, but pass it a tcp_handle, not sock */ int (*writeit)(); /* like write, but pass it a tcp_handle, not sock */ { register RECSTREAM *rstrm = (RECSTREAM *)mem_alloc(sizeof(RECSTREAM)); #if NLS libc_nls_init(); #endif if (rstrm == NULL) { #if NLS (void)fprintf(stderr, "xdrrec_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void)fprintf(stderr, "xdrrec_create: out of memory\n"); #endif /* * This is bad. Should rework xdrrec_create to * return a handle, and in this case return NULL */ return; } /* * adjust sizes and allocate buffer quad byte aligned */ rstrm->sendsize = sendsize = fix_buf_size(sendsize); rstrm->recvsize = recvsize = fix_buf_size(recvsize); rstrm->the_buffer = mem_alloc(sendsize + recvsize + BYTES_PER_XDR_UNIT); if (rstrm->the_buffer == NULL) { #if NLS (void)fprintf(stderr, "xdrrec_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void)fprintf(stderr, "xdrrec_create: out of memory\n"); #endif return; } for (rstrm->out_base = rstrm->the_buffer; (u_int)rstrm->out_base % BYTES_PER_XDR_UNIT != 0; rstrm->out_base++); rstrm->in_base = rstrm->out_base + sendsize; /* * now the rest ... */ xdrs->x_ops = &xdrrec_ops; xdrs->x_private = (caddr_t)rstrm; rstrm->tcp_handle = tcp_handle; rstrm->readit = readit; rstrm->writeit = writeit; rstrm->out_finger = rstrm->out_boundry = rstrm->out_base; rstrm->frag_header = (u_long *)rstrm->out_base; rstrm->out_finger += sizeof(u_long); rstrm->out_boundry += sendsize; rstrm->frag_sent = FALSE; rstrm->in_size = recvsize; rstrm->in_boundry = rstrm->in_base; rstrm->in_finger = (rstrm->in_boundry += recvsize); rstrm->fbtbc = 0; rstrm->last_frag = TRUE; } /* * The reoutines defined below are the xdr ops which will go into the * xdr handle filled in by xdrrec_create. */ static bool_t xdrrec_getlong(xdrs, lp) XDR *xdrs; long *lp; { register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); register long *buflp = (long *)(rstrm->in_finger); long mylong; /* first try the inline, fast case */ if ((rstrm->fbtbc >= sizeof(long)) && (((int)rstrm->in_boundry - (int)buflp) >= sizeof(long))) { *lp = (long)ntohl((u_long)(*buflp)); rstrm->fbtbc -= sizeof(long); rstrm->in_finger += sizeof(long); } else { if (! xdrrec_getbytes(xdrs, (caddr_t)&mylong, sizeof(long))) return (FALSE); *lp = (long)ntohl((u_long)mylong); } return (TRUE); } static bool_t xdrrec_putlong(xdrs, lp) XDR *xdrs; long *lp; { register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); register long *dest_lp = ((long *)(rstrm->out_finger)); if ((rstrm->out_finger += sizeof(long)) > rstrm->out_boundry) { /* * this case should almost never happen so the code is * inefficient */ rstrm->out_finger -= sizeof(long); rstrm->frag_sent = TRUE; if (! flush_out(rstrm, FALSE)) return (FALSE); dest_lp = ((long *)(rstrm->out_finger)); rstrm->out_finger += sizeof(long); } *dest_lp = (long)htonl((u_long)(*lp)); return (TRUE); } static bool_t /* must manage buffers, fragments, and records */ xdrrec_getbytes(xdrs, addr, len) XDR *xdrs; register caddr_t addr; register u_int len; { register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); register int current; while (len > 0) { current = rstrm->fbtbc; if (current == 0) { if (rstrm->last_frag) return (FALSE); if (! set_input_fragment(rstrm)) return (FALSE); continue; } current = (len < current) ? len : current; if (! get_input_bytes(rstrm, addr, current)) return (FALSE); addr += current; rstrm->fbtbc -= current; len -= current; } return (TRUE); } static bool_t xdrrec_putbytes(xdrs, addr, len) XDR *xdrs; register caddr_t addr; register u_int len; { register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); register int current; while (len > 0) { current = (u_int)rstrm->out_boundry - (u_int)rstrm->out_finger; current = (len < current) ? len : current; bcopy(addr, rstrm->out_finger, current); rstrm->out_finger += current; addr += current; len -= current; if (rstrm->out_finger == rstrm->out_boundry) { rstrm->frag_sent = TRUE; if (! flush_out(rstrm, FALSE)) return (FALSE); } } return (TRUE); } static u_int xdrrec_getpos(xdrs) register XDR *xdrs; { register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; register long pos; pos = lseek((int)rstrm->tcp_handle, (long) 0, 1); if (pos != -1) switch (xdrs->x_op) { case XDR_ENCODE: pos += rstrm->out_finger - rstrm->out_base; break; case XDR_DECODE: pos -= rstrm->in_boundry - rstrm->in_finger; break; default: pos = (u_int) -1; break; } return ((u_int) pos); } static bool_t xdrrec_setpos(xdrs, pos) register XDR *xdrs; u_int pos; { register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; u_int currpos = xdrrec_getpos(xdrs); int delta = currpos - pos; caddr_t newpos; if ((int)currpos != -1) switch (xdrs->x_op) { case XDR_ENCODE: newpos = rstrm->out_finger - delta; if ((newpos > (caddr_t)(rstrm->frag_header)) && (newpos < rstrm->out_boundry)) { rstrm->out_finger = newpos; return (TRUE); } break; case XDR_DECODE: newpos = rstrm->in_finger - delta; if ((delta < (int)(rstrm->fbtbc)) && (newpos <= rstrm->in_boundry) && (newpos >= rstrm->in_base)) { rstrm->in_finger = newpos; rstrm->fbtbc -= delta; return (TRUE); } break; } return (FALSE); } static long * xdrrec_inline(xdrs, len) register XDR *xdrs; int len; { register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; long * buf = NULL; switch (xdrs->x_op) { case XDR_ENCODE: if ((rstrm->out_finger + len) <= rstrm->out_boundry) { buf = (long *) rstrm->out_finger; rstrm->out_finger += len; } break; case XDR_DECODE: if ((len <= rstrm->fbtbc) && ((rstrm->in_finger + len) <= rstrm->in_boundry)) { buf = (long *) rstrm->in_finger; rstrm->fbtbc -= len; rstrm->in_finger += len; } break; } return (buf); } static void xdrrec_destroy(xdrs) register XDR *xdrs; { register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; mem_free(rstrm->the_buffer, rstrm->sendsize + rstrm->recvsize + BYTES_PER_XDR_UNIT); mem_free((caddr_t)rstrm, sizeof(RECSTREAM)); } /* * Exported routines to manage xdr records */ /* * Before reading (deserializing from the stream, one should always call * this procedure to guarantee proper record alignment. */ bool_t xdrrec_skiprecord(xdrs) XDR *xdrs; { register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { if (! skip_input_bytes(rstrm, rstrm->fbtbc)) return (FALSE); rstrm->fbtbc = 0; if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) return (FALSE); } rstrm->last_frag = FALSE; return (TRUE); } /* * Look ahead fuction. * Returns TRUE iff there is no more input in the buffer * after consuming the rest of the current record. */ bool_t xdrrec_eof(xdrs) XDR *xdrs; { register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { if (! skip_input_bytes(rstrm, rstrm->fbtbc)) return (TRUE); rstrm->fbtbc = 0; if ((! rstrm->last_frag) && (! set_input_fragment(rstrm))) return (TRUE); } if (rstrm->in_finger == rstrm->in_boundry) return (TRUE); return (FALSE); } /* * The client must tell the package when an end-of-record has occurred. * The second paraemters tells whether the record should be flushed to the * (output) tcp stream. (This let's the package support batched or * pipelined procedure calls.) TRUE => immmediate flush to tcp connection. */ bool_t xdrrec_endofrecord(xdrs, sendnow) XDR *xdrs; bool_t sendnow; { register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); register u_long len; /* fragment length */ if (sendnow || rstrm->frag_sent || ((u_long)rstrm->out_finger + sizeof(u_long) >= (u_long)rstrm->out_boundry)) { rstrm->frag_sent = FALSE; return (flush_out(rstrm, TRUE)); } len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->frag_header) - sizeof(u_long); *(rstrm->frag_header) = htonl((u_long)len | LAST_FRAG); rstrm->frag_header = (u_long *)rstrm->out_finger; rstrm->out_finger += sizeof(u_long); return (TRUE); } ./libc-linux/rpc/clnt_udp.c100644 1676 334 31106 5547117737 13715 0ustar hjlisl/* @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC */ /* * 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. * * 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 */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; #endif /* * clnt_udp.c, Implements a UDP/IP based, client side RPC. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include #include #include #include #ifdef __STDC__ #include #endif #if NLS #include "nl_types.h" #endif extern int errno; /* * UDP bases client side rpc operations */ static enum clnt_stat clntudp_call(); static void clntudp_abort(); static void clntudp_geterr(); static bool_t clntudp_freeres(); static bool_t clntudp_control(); static void clntudp_destroy(); static struct clnt_ops udp_ops = { clntudp_call, clntudp_abort, clntudp_geterr, clntudp_freeres, clntudp_destroy, clntudp_control }; /* * Private data kept per client handle */ struct cu_data { int cu_sock; bool_t cu_closeit; struct sockaddr_in cu_raddr; int cu_rlen; struct timeval cu_wait; struct timeval cu_total; struct rpc_err cu_error; XDR cu_outxdrs; u_int cu_xdrpos; u_int cu_sendsz; char *cu_outbuf; u_int cu_recvsz; char cu_inbuf[1]; }; /* * Create a UDP based client handle. * If *sockp<0, *sockp is set to a newly created UPD socket. * If raddr->sin_port is 0 a binder on the remote machine * is consulted for the correct port number. * NB: It is the clients responsibility to close *sockp. * NB: The rpch->cl_auth is initialized to null authentication. * Caller may wish to set this something more useful. * * wait is the amount of time used between retransmitting a call if * no response has been heard; retransmition occurs until the actual * rpc call times out. * * sendsz and recvsz are the maximum allowable packet sizes that can be * sent and received. */ CLIENT * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) struct sockaddr_in *raddr; u_long program; u_long version; struct timeval wait; register int *sockp; u_int sendsz; u_int recvsz; { CLIENT *cl; register struct cu_data *cu = NULL; struct timeval now; struct rpc_msg call_msg; #if NLS libc_nls_init(); #endif cl = (CLIENT *)mem_alloc(sizeof(CLIENT)); if (cl == NULL) { #if NLS (void) fprintf(stderr, "clntudp_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void) fprintf(stderr, "clntudp_create: out of memory\n"); #endif rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; goto fooy; } sendsz = ((sendsz + 3) / 4) * 4; recvsz = ((recvsz + 3) / 4) * 4; cu = (struct cu_data *)mem_alloc(sizeof(*cu) + sendsz + recvsz); if (cu == NULL) { #if NLS (void) fprintf(stderr, "clntudp_create: %s\n", catgets(_libc_cat, RpcMiscSet, RpcMiscOutOfMemory, "out of memory")); #else (void) fprintf(stderr, "clntudp_create: out of memory\n"); #endif rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; goto fooy; } cu->cu_outbuf = &cu->cu_inbuf[recvsz]; (void)gettimeofday(&now, (struct timezone *)0); if (raddr->sin_port == 0) { u_short port; if ((port = pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) { goto fooy; } raddr->sin_port = htons(port); } cl->cl_ops = &udp_ops; cl->cl_private = (caddr_t)cu; cu->cu_raddr = *raddr; cu->cu_rlen = sizeof (cu->cu_raddr); cu->cu_wait = wait; cu->cu_total.tv_sec = -1; cu->cu_total.tv_usec = -1; cu->cu_sendsz = sendsz; cu->cu_recvsz = recvsz; call_msg.rm_xid = getpid() ^ now.tv_sec ^ now.tv_usec; call_msg.rm_direction = CALL; call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; call_msg.rm_call.cb_prog = program; call_msg.rm_call.cb_vers = version; xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE); if (! xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) { goto fooy; } cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs)); if (*sockp < 0) { int dontblock = 1; *sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (*sockp < 0) { rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; goto fooy; } /* attempt to bind to prov port */ (void)bindresvport(*sockp, (struct sockaddr_in *)0); /* the sockets rpc controls are non-blocking */ (void)ioctl(*sockp, FIONBIO, (char *) &dontblock); cu->cu_closeit = TRUE; } else { cu->cu_closeit = FALSE; } cu->cu_sock = *sockp; cl->cl_auth = authnone_create(); return (cl); fooy: if (cu) mem_free((caddr_t)cu, sizeof(*cu) + sendsz + recvsz); if (cl) mem_free((caddr_t)cl, sizeof(CLIENT)); return ((CLIENT *)NULL); } CLIENT * clntudp_create(raddr, program, version, wait, sockp) struct sockaddr_in *raddr; u_long program; u_long version; struct timeval wait; register int *sockp; { return(clntudp_bufcreate(raddr, program, version, wait, sockp, UDPMSGSIZE, UDPMSGSIZE)); } static enum clnt_stat clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) register CLIENT *cl; /* client handle */ u_long proc; /* procedure number */ xdrproc_t xargs; /* xdr routine for args */ caddr_t argsp; /* pointer to args */ xdrproc_t xresults; /* xdr routine for results */ caddr_t resultsp; /* pointer to results */ struct timeval utimeout; /* seconds to wait before giving up */ { register struct cu_data *cu = (struct cu_data *)cl->cl_private; register XDR *xdrs; register int outlen; register int inlen; int fromlen; #ifdef FD_SETSIZE fd_set readfds; fd_set mask; #else int readfds; register int mask; #endif /* def FD_SETSIZE */ struct sockaddr_in from; struct rpc_msg reply_msg; XDR reply_xdrs; struct timeval time_waited; bool_t ok; int nrefreshes = 2; /* number of times to refresh cred */ struct timeval timeout; if (cu->cu_total.tv_usec == -1) { timeout = utimeout; /* use supplied timeout */ } else { timeout = cu->cu_total; /* use default timeout */ } time_waited.tv_sec = 0; time_waited.tv_usec = 0; call_again: xdrs = &(cu->cu_outxdrs); xdrs->x_op = XDR_ENCODE; XDR_SETPOS(xdrs, cu->cu_xdrpos); /* * the transaction is the first thing in the out buffer */ (*(u_short *)(cu->cu_outbuf))++; if ((! XDR_PUTLONG(xdrs, (long *)&proc)) || (! AUTH_MARSHALL(cl->cl_auth, xdrs)) || (! (*xargs)(xdrs, argsp))) return (cu->cu_error.re_status = RPC_CANTENCODEARGS); outlen = (int)XDR_GETPOS(xdrs); send_again: if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0, (struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen) != outlen) { cu->cu_error.re_errno = errno; return (cu->cu_error.re_status = RPC_CANTSEND); } /* * Hack to provide rpc-based message passing */ if (timeout.tv_sec == 0 && timeout.tv_usec == 0) { return (cu->cu_error.re_status = RPC_TIMEDOUT); } /* * sub-optimal code appears here because we have * some clock time to spare while the packets are in flight. * (We assume that this is actually only executed once.) */ reply_msg.acpted_rply.ar_verf = _null_auth; reply_msg.acpted_rply.ar_results.where = resultsp; reply_msg.acpted_rply.ar_results.proc = xresults; #ifdef FD_SETSIZE FD_ZERO(&mask); FD_SET(cu->cu_sock, &mask); #else mask = 1 << cu->cu_sock; #endif /* def FD_SETSIZE */ for (;;) { #ifdef linux struct timeval oneshot_timeout; readfds = mask; oneshot_timeout = cu->cu_wait; switch (select(_rpc_dtablesize(), &readfds, (void *)NULL, (void *)NULL, &oneshot_timeout)) { #else readfds = mask; switch (select(_rpc_dtablesize(), &readfds, (void *)NULL, (void *)NULL, &(cu->cu_wait))) { #endif case 0: time_waited.tv_sec += cu->cu_wait.tv_sec; time_waited.tv_usec += cu->cu_wait.tv_usec; while (time_waited.tv_usec >= 1000000) { time_waited.tv_sec++; time_waited.tv_usec -= 1000000; } if ((time_waited.tv_sec < timeout.tv_sec) || ((time_waited.tv_sec == timeout.tv_sec) && (time_waited.tv_usec < timeout.tv_usec))) goto send_again; return (cu->cu_error.re_status = RPC_TIMEDOUT); /* * buggy in other cases because time_waited is not being * updated. */ case -1: if (errno == EINTR) continue; cu->cu_error.re_errno = errno; return (cu->cu_error.re_status = RPC_CANTRECV); } do { fromlen = sizeof(struct sockaddr); inlen = recvfrom(cu->cu_sock, cu->cu_inbuf, (int) cu->cu_recvsz, 0, (struct sockaddr *)&from, &fromlen); } while (inlen < 0 && errno == EINTR); if (inlen < 0) { #ifdef linux if (errno == EWOULDBLOCK || errno == EAGAIN) #else if (errno == EWOULDBLOCK) #endif continue; cu->cu_error.re_errno = errno; return (cu->cu_error.re_status = RPC_CANTRECV); } if (inlen < sizeof(u_long)) continue; /* see if reply transaction id matches sent id */ if (*((u_long *)(cu->cu_inbuf)) != *((u_long *)(cu->cu_outbuf))) continue; /* we now assume we have the proper reply */ break; } /* * now decode and validate the response */ xdrmem_create(&reply_xdrs, cu->cu_inbuf, (u_int)inlen, XDR_DECODE); ok = xdr_replymsg(&reply_xdrs, &reply_msg); /* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */ if (ok) { _seterr_reply(&reply_msg, &(cu->cu_error)); if (cu->cu_error.re_status == RPC_SUCCESS) { if (! AUTH_VALIDATE(cl->cl_auth, &reply_msg.acpted_rply.ar_verf)) { cu->cu_error.re_status = RPC_AUTHERROR; cu->cu_error.re_why = AUTH_INVALIDRESP; } if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) { xdrs->x_op = XDR_FREE; (void)xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf)); } } /* end successful completion */ else { /* maybe our credentials need to be refreshed ... */ if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth)) { nrefreshes--; goto call_again; } } /* end of unsuccessful completion */ } /* end of valid reply message */ else { cu->cu_error.re_status = RPC_CANTDECODERES; } return (cu->cu_error.re_status); } static void clntudp_geterr(cl, errp) CLIENT *cl; struct rpc_err *errp; { register struct cu_data *cu = (struct cu_data *)cl->cl_private; *errp = cu->cu_error; } static bool_t clntudp_freeres(cl, xdr_res, res_ptr) CLIENT *cl; xdrproc_t xdr_res; caddr_t res_ptr; { register struct cu_data *cu = (struct cu_data *)cl->cl_private; register XDR *xdrs = &(cu->cu_outxdrs); xdrs->x_op = XDR_FREE; return ((*xdr_res)(xdrs, res_ptr)); } static void clntudp_abort(/*h*/) /*CLIENT *h;*/ { } static bool_t clntudp_control(cl, request, info) CLIENT *cl; int request; char *info; { register struct cu_data *cu = (struct cu_data *)cl->cl_private; switch (request) { case CLSET_TIMEOUT: cu->cu_total = *(struct timeval *)info; break; case CLGET_TIMEOUT: *(struct timeval *)info = cu->cu_total; break; case CLSET_RETRY_TIMEOUT: cu->cu_wait = *(struct timeval *)info; break; case CLGET_RETRY_TIMEOUT: *(struct timeval *)info = cu->cu_wait; break; case CLGET_SERVER_ADDR: *(struct sockaddr_in *)info = cu->cu_raddr; break; default: return (FALSE); } return (TRUE); } static void clntudp_destroy(cl) CLIENT *cl; { register struct cu_data *cu = (struct cu_data *)cl->cl_private; if (cu->cu_closeit) { (void)close(cu->cu_sock); } XDR_DESTROY(&(cu->cu_outxdrs)); mem_free((caddr_t)cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz)); mem_free((caddr_t)cl, sizeof(CLIENT)); } ./libc-linux/login/ 40755 1676 334 0 5550065755 12143 5ustar hjlisl./libc-linux/login/getlogin.c100644 1676 334 2065 5550027723 14210 0ustar hjlisl/* getlogin.c - poe@daimi.aau.dk */ #include #include #include #include #include #include #if 0 #include "pathnames.h" #endif static char name[UT_NAMESIZE + 1]; char *ttyname(int); /* return logname of the user of "this" tty */ char *getlogin(void) { char *ttyn; struct utmp ut; int fd; if(!(ttyn = ttyname(0)) && !(ttyn = ttyname(1)) && !(ttyn = ttyname(2))) return (char *)0; /* we cannot use the getutline() function, 'cause that would prohibit interleavig of getlogin() and getut...() functions, eg. in write(1) */ if((fd = open(_PATH_UTMP, O_RDONLY)) >= 0) { while(read(fd, (char *)&ut, sizeof(ut)) == sizeof(ut)) { if(!strncmp(ttyn + 5, ut.ut_line, sizeof(ut.ut_line)) && ut.ut_type == USER_PROCESS) { strncpy(name, ut.ut_user, UT_NAMESIZE); name [UT_NAMESIZE] = '\0'; close(fd); #if 0 if (getpwnam(name)) return name; #else return name; #endif } } close(fd); } return (char *)0; } #ifdef DEBUGGING main() { puts(getlogin()); } #endif ./libc-linux/sbin/ 40755 1676 334 0 5545104420 11751 5ustar hjlisl./libc-linux/sbin/Makefile100644 1676 334 2006 5540142157 13510 0ustar hjlisl# # Makefile for Linux specific functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules .PHONY: lib DIRS=lib LIBS=$(TOPDIR)/libalias.a lib/libc.a CRT0=./lib/$(TARGET_ARCH)/crt/crt0.o PROGS=sln all: lib $(PROGS) sln: sln.o $(LD) -N -dll-verbose -static -o $@ $(CRT0) $? $(LIBS) \ `gcc -b $(TARGET_MACHINE) --print` install: $(PROGS) @if [ -d $(TARGET_SBIN_DIR) ]; then \ echo installing $(PROGS) to $(TARGET_SBIN_DIR)/; \ cp $(PROGS) $(TARGET_SBIN_DIR)/; \ else \ echo \"$(TARGET_SBIN_DIR)\" is not a directory!; \ exit 1; \ fi asm: $(ASMS) clean:: $(RM) -f core *.i *.s *.o *.a tmp_make foo $(PROGS) realclean:: $(RM) -f core *.i *.s *.o *.a tmp_make foo $(PROGS) .depend depend:: $(CC) $(CFLAGS) -M *.c > .depend ifneq ($(DIRS),) lib realclean clean depend:: @for i in $(DIRS); \ do \ echo making $@ in $$i; \ ($(MAKE) -C $$i $@); \ done else lib:: @true endif # # include a dependency file if one exists # ifeq (.depend,$(wildcard .depend)) include .depend endif ./libc-linux/sbin/lib/ 40755 1676 334 0 5545104421 12520 5ustar hjlisl./libc-linux/sbin/lib/Makefile100644 1676 334 1437 5540142240 14256 0ustar hjlisl# # Makefile for Linux specific functions # TOPDIR=../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules LIB:=libc.a DIRS=$(TARGET_ARCH) INC_CFLAGS= -I$(TOPDIR)/sysdeps/linux/$(TARGET_ARCH) -I$(TOPDIR) SRCS=__stat.c __lstat.c __symlink.c __link.c __main.c \ __environ.c errno.c __unlink.c OBJS= $(SRCS:.c=.o) ASMS= $(SRCS:.c=.s) lib:: $(LIB) $(LIB): $(OBJS) $(AR) uvc $(LIB) $? -$(AR) -d $(LIB) __.SYMDEF $(REALRANLIB) $(LIB) asm: $(ASMS) obj: $(OBJS) clean realclean:: $(RM) -f core *.o *.a *.s *.i tmp_make foo depend:: $(CC) -M $(CFLAGS) $(SRCS) > .depend ifneq ($(DIRS),) lib clean realclean depend:: for d in $(DIRS); do \ ($(MAKE) -C $$d $@); \ done endif # # include a dependency file if one exists # ifeq (.depend,$(wildcard .depend)) include .depend endif ./libc-linux/sbin/lib/i386/ 40755 1676 334 0 5545104420 13210 5ustar hjlisl./libc-linux/sbin/lib/i386/Makefile100644 1676 334 543 5540143064 14731 0ustar hjlisl# # Makefile for Linux specific functions # TOPDIR=../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules DIRS=crt lib clean realclean depend:: ifneq ($(DIRS),) @for d in $(DIRS); do \ ($(MAKE) -C $$d $@); \ done else @true endif # # include a dependency file if one exists # ifeq (.depend,$(wildcard .depend)) include .depend endif ./libc-linux/sbin/lib/m68k/ 40755 1676 334 0 5545104421 13305 5ustar hjlisl./libc-linux/sbin/lib/m68k/Makefile100644 1676 334 543 5540143074 15026 0ustar hjlisl# # Makefile for Linux specific functions # TOPDIR=../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules DIRS=crt lib clean realclean depend:: ifneq ($(DIRS),) @for d in $(DIRS); do \ ($(MAKE) -C $$d $@); \ done else @true endif # # include a dependency file if one exists # ifeq (.depend,$(wildcard .depend)) include .depend endif ./libc-linux/libbsd/ 40755 1676 334 0 5550065403 12260 5ustar hjlisl./libc-linux/libbsd/logout.c100644 1676 334 5160 5545076143 14043 0ustar hjlisl/* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)logout.c 5.5 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include #include typedef struct utmp UTMP; logout(line) register char *line; { register int fd; UTMP ut; int rval; off_t lseek(); time_t time(); if ((fd = open(_PATH_UTMP, O_RDWR)) < 0) return(0); rval = 0; while (read(fd, (char *)&ut, sizeof(UTMP)) == sizeof(UTMP)) { if (!ut.ut_name[0] || strncmp(ut.ut_line, line, UT_LINESIZE)) continue; bzero(ut.ut_name, UT_NAMESIZE); bzero(ut.ut_host, UT_HOSTSIZE); (void)time(&ut.ut_time); (void)lseek(fd, -(long)sizeof(UTMP), L_INCR); (void)write(fd, (char *)&ut, sizeof(UTMP)); rval = 1; } (void)close(fd); return(rval); } ./libc-linux/libbsd/logwtmp.c100644 1676 334 5145 5545076165 14232 0ustar hjlisl/* * Copyright (c) 1988 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)logwtmp.c 5.5 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include #include logwtmp(line, name, host) char *line, *name, *host; { struct utmp ut; struct stat buf; int fd; time_t time(); char *strncpy(); if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0) return; if (fstat(fd, &buf) == 0) { (void) strncpy(ut.ut_line, line, sizeof(ut.ut_line)); (void) strncpy(ut.ut_name, name, sizeof(ut.ut_name)); (void) strncpy(ut.ut_host, host, sizeof(ut.ut_host)); (void) time(&ut.ut_time); if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp)) (void) ftruncate(fd, buf.st_size); } (void) close(fd); } ./libc-linux/time/ 40755 1676 334 0 5550065403 11757 5ustar hjlisl./libc-linux/time/strftime.c100644 1676 334 17407 5544660551 14116 0ustar hjlisl/* Extensions for GNU date that are still missing here: - _ */ /* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include #include #include #ifndef HAVE_GNU_LD #define __tzname tzname #define __daylight daylight #define __timezone timezone #endif #define add(n, f) \ do \ { \ i += (n); \ if (i >= maxsize) \ return 0; \ else \ if (p != NULL) \ { \ f; \ p += (n); \ } \ } while (0) #define cpy(n, s) add((n), memcpy((PTR) p, (PTR) (s), (n))) #define fmt(n, args) add((n), if (sprintf args != (n)) return 0) /* Return the week in the year specified by TP, with weeks starting on STARTING_DAY. */ #ifdef __GNUC__ inline #endif static unsigned int DEFUN(week, (tp, starting_day), CONST struct tm *CONST tp AND int starting_day) { int wday, dl; wday = tp->tm_wday - starting_day; if (wday < 0) wday += 7; /* Set DL to the day in the year of the last day of the week previous to the one containing the day specified in TP. If DL is negative or zero, the day specified in TP is in the first week of the year. Otherwise, calculate the number of complete weeks before our week (DL / 7) and add any partial week at the start of the year (DL % 7). */ dl = tp->tm_yday - wday; return dl <= 0 ? 0 : ((dl / 7) + ((dl % 7) == 0 ? 0 : 1)); } /* Write information from TP into S according to the format string FORMAT, writing no more that MAXSIZE characters (including the terminating '\0') and returning number of characters written. If S is NULL, nothing will be written anywhere, so to determine how many characters would be written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ size_t DEFUN(strftime, (s, maxsize, format, tp), char *s AND size_t maxsize AND CONST char *format AND register CONST struct tm *tp) { #if 0 CONST char *CONST a_wkday = _time_info->abbrev_wkday[tp->tm_wday]; CONST char *CONST f_wkday = _time_info->full_wkday[tp->tm_wday]; CONST char *CONST a_month = _time_info->abbrev_month[tp->tm_mon]; CONST char *CONST f_month = _time_info->full_month[tp->tm_mon]; size_t aw_len = strlen(a_wkday); size_t am_len = strlen(a_month); size_t wkday_len = strlen(f_wkday); size_t month_len = strlen(f_month); CONST char *CONST ampm = _time_info->ampm[hour12 >= 12]; size_t ap_len = strlen(ampm); CONST unsigned int y_week0 = week(tp, 0); CONST unsigned int y_week1 = week(tp, 1); CONST char *zone; size_t zonelen; #else #define SET_AWEEK if (a_wkday == NULL) { \ a_wkday = _time_info->abbrev_wkday[tp->tm_wday]; \ aw_len = strlen(a_wkday); \ } #define SET_AMONTH if (a_month == NULL) { \ a_month = _time_info->abbrev_month[tp->tm_mon]; \ am_len = strlen(a_month); \ } #define SET_FWEEK if (f_wkday == NULL) { \ f_wkday = _time_info->full_wkday[tp->tm_wday]; \ wkday_len = strlen(f_wkday); \ } #define SET_FMONTH if (f_month == NULL) { \ f_month = _time_info->full_month[tp->tm_mon]; \ month_len = strlen(f_month); \ } #define SET_AMPM if (ampm == NULL) { \ ampm = _time_info->ampm[hour12 >= 12]; \ ap_len = strlen(ampm); \ } #define SET_Y_WEEK0 if (y_week0 == -1) { y_week0 = week(tp, 0); } #define SET_Y_WEEK1 if (y_week1 == -1) { y_week1 = week(tp, 1); } #define SET_ZONE if (tp->tm_isdst < 0) \ { zone = ""; zonelen = 0; } \ else { \ zone = __tzname[tp->tm_isdst]; \ zonelen = strlen(zone); \ } CONST char *a_wkday = NULL; CONST char *f_wkday = NULL; CONST char *a_month = NULL; CONST char *f_month = NULL; size_t aw_len = 0; size_t am_len = 0; size_t wkday_len = 0; size_t month_len = 0; CONST char *ampm = NULL; size_t ap_len = 0; unsigned int y_week0 = -1; unsigned int y_week1 = -1; CONST char *zone = NULL; size_t zonelen = 0; #endif int hour12 = tp->tm_hour; register size_t i = 0; register char *p = s; register CONST char *f; #if 0 if (tp->tm_isdst < 0) { zone = ""; zonelen = 0; } else { zone = __tzname[tp->tm_isdst]; zonelen = strlen(zone); } #endif if (hour12 > 12) hour12 -= 12; else if (hour12 == 0) hour12 = 12; for (f = format; *f != '\0'; ++f) { CONST char *subfmt; if (!isascii(*f)) { /* Non-ASCII, may be a multibyte. */ int len = mblen(f, strlen(f)); if (len > 0) { cpy(len, f); continue; } } if (*f != '%') { add(1, *p = *f); continue; } ++f; switch (*f) { case '\0': case '%': add(1, *p = *f); break; case 'a': SET_AWEEK; cpy(aw_len, a_wkday); break; case 'A': SET_FWEEK; cpy(wkday_len, f_wkday); break; case 'b': case 'h': /* GNU extension. */ SET_AMONTH; cpy(am_len, a_month); break; case 'B': SET_FMONTH; cpy(month_len, f_month); break; case 'c': subfmt = _time_info->date_time; subformat: { size_t len = strftime (p, maxsize - i, subfmt, tp); add(len, ); } break; case 'C': fmt (2, (p, "%.2d", (1900 + tp->tm_year) / 100)); break; case 'D': /* GNU extension. */ subfmt = "%m/%d/%y"; goto subformat; case 'd': fmt(2, (p, "%.2d", tp->tm_mday)); break; case 'e': /* GNU extension: %d, but blank-padded. */ fmt(2, (p, "%2d", tp->tm_mday)); break; case 'H': fmt(2, (p, "%.2d", tp->tm_hour)); break; case 'I': fmt(2, (p, "%.2d", hour12)); break; case 'k': /* GNU extension. */ fmt(2, (p, "%2d", tp->tm_hour)); break; case 'l': /* GNU extension. */ fmt(2, (p, "%2d", hour12)); break; case 'j': fmt(3, (p, "%.3d", tp->tm_yday + 1)); break; case 'M': fmt(2, (p, "%.2d", tp->tm_min)); break; case 'm': fmt(2, (p, "%.2d", tp->tm_mon + 1)); break; case 'n': /* GNU extension. */ add (1, *p = '\n'); break; case 'p': SET_AMPM; cpy(ap_len, ampm); break; case 'R': /* GNU extension. */ subfmt = "%H:%M"; goto subformat; case 'r': /* GNU extension. */ subfmt = "%I:%M:%S %p"; goto subformat; case 'S': fmt(2, (p, "%.2d", tp->tm_sec)); break; case 'T': /* GNU extenstion. */ subfmt = "%H:%M:%S"; goto subformat; case 't': /* GNU extenstion. */ add (1, *p = '\t'); break; case 'U': SET_Y_WEEK0; fmt(2, (p, "%.2u", y_week0)); break; case 'W': SET_Y_WEEK1; fmt(2, (p, "%.2u", y_week1)); break; case 'w': fmt(2, (p, "%.2d", tp->tm_wday)); break; case 'X': subfmt = _time_info->time; goto subformat; case 'x': subfmt = _time_info->date; goto subformat; case 'Y': fmt(4, (p, "%.4d", 1900 + tp->tm_year)); break; case 'y': fmt(2, (p, "%.2d", tp->tm_year)); break; case 'Z': SET_ZONE; cpy(zonelen, zone); break; default: /* Bad format. */ break; } } if (p != NULL) *p = '\0'; return i; } ./libc-linux/misc/ 40755 1676 334 0 5550065403 11754 5ustar hjlisl./libc-linux/misc/syslog.c100644 1676 334 13335 5544323565 13573 0ustar hjlisl/* * Copyright (c) 1983, 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted provided * that: (1) source distributions retain this entire copyright notice and * comment, and (2) distributions including binaries display the following * acknowledgement: ``This product includes software developed by the * University of California, Berkeley and its contributors'' in the * documentation or other materials provided with the distribution and in * all advertising materials mentioning features or use of this software. * Neither the name of the University nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)syslog.c 5.28 (Berkeley) 6/27/90"; #endif /* LIBC_SCCS and not lint */ /* * SYSLOG -- print message on log file * * This routine looks a lot like printf, except that it outputs to the * log file instead of the standard output. Also: * adds a timestamp, * prints the module name in front of the message, * has some other formatting types (or will sometime), * adds a newline on the end of the message. * * The output of this routine is intended to be read by syslogd(8). * * Author: Eric Allman * Modified to use UNIX domain IPC by Ralph Campbell */ #include #include #include #include #include #if 0 #include "syslog.h" #include "pathnames.h" #endif #include #include #include #include #include #include #include #include #include #include #define _PATH_LOGNAME "/dev/log" static int LogFile = -1; /* fd for log */ static int connected; /* have done connect */ static int LogStat = 0; /* status bits, set by openlog() */ static const char *LogTag = "syslog"; /* string to tag the entry with */ static int LogFacility = LOG_USER; /* default facility code */ void syslog(int pri, const char *fmt, ...) { va_list ap; va_start(ap, fmt); vsyslog(pri, fmt, ap); va_end(ap); } void vsyslog(pri, fmt, ap) int pri; const char *fmt; va_list ap; { register int cnt; register char *p; time_t now; int fd, saved_errno; char tbuf[2048], fmt_cpy[1024], *stdp; saved_errno = errno; /* see if we should just throw out this message */ if (!LOG_MASK(LOG_PRI(pri)) || (pri &~ (LOG_PRIMASK|LOG_FACMASK))) return; if (LogFile < 0 || !connected) openlog(LogTag, LogStat | LOG_NDELAY, 0); /* set default facility if none specified */ if ((pri & LOG_FACMASK) == 0) pri |= LogFacility; /* build the message */ (void)time(&now); (void)sprintf(tbuf, "<%d>%.15s ", pri, ctime(&now) + 4); for (p = tbuf; *p; ++p); if (LogStat & LOG_PERROR) stdp = p; if (LogTag) { (void)strcpy(p, LogTag); for (; *p; ++p); } if (LogStat & LOG_PID) { (void)sprintf(p, "[%d]", getpid()); for (; *p; ++p); } if (LogTag) { *p++ = ':'; *p++ = ' '; } /* substitute error message for %m */ { register char ch, *t1, *t2; char *strerror(); for (t1 = fmt_cpy; ch = *fmt; ++fmt) if (ch == '%' && fmt[1] == 'm') { ++fmt; for (t2 = strerror(saved_errno); *t1 = *t2++; ++t1); } else *t1++ = ch; *t1 = '\0'; } (void)vsprintf(p, fmt_cpy, ap); cnt = strlen(tbuf); /* output to stderr if requested */ if (LogStat & LOG_PERROR) { struct iovec iov[2]; register struct iovec *v = iov; v->iov_base = stdp; v->iov_len = cnt - (stdp - tbuf); ++v; v->iov_base = "\n"; v->iov_len = 1; (void)writev(2, iov, 2); } /* output the message to the local logger */ #if 1 /* Use NUL as a message delimiter. */ if (write(LogFile, tbuf, cnt + 1) >= 1) { return; } else { /* If the write fails, we try to reconect it next * time. */ closelog (); } if (!(LogStat&LOG_CONS)) return; #else if (write(LogFile, tbuf, cnt) >= 0 || !(LogStat&LOG_CONS)) return; #endif /* * output the message to the console; don't worry about * blocking, if console blocks everything will. */ if ((fd = open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY, 0)) < 0) return; (void)strcat(tbuf, "\r\n"); cnt += 2; p = index(tbuf, '>') + 1; (void)write(fd, p, cnt - (p - tbuf)); (void)close(fd); } static struct sockaddr SyslogAddr; /* AF_UNIX address of local logger */ /* * OPENLOG -- open system log */ void openlog(ident, logstat, logfac) const char *ident; int logstat, logfac; { if (ident != NULL) LogTag = ident; LogStat = logstat; if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0) LogFacility = logfac; if (LogFile == -1) { SyslogAddr.sa_family = AF_UNIX; strncpy(SyslogAddr.sa_data, _PATH_LOGNAME, sizeof(SyslogAddr.sa_data)); if (LogStat & LOG_NDELAY) { LogFile = socket(AF_UNIX, SOCK_STREAM, 0); /* fcntl(LogFile, F_SETFD, 1); */ } } if (LogFile != -1 && !connected && #if 0 connect(LogFile, &SyslogAddr, sizeof(SyslogAddr.sa_family)+ strlen(SyslogAddr.sa_data)) != -1) #else connect(LogFile, &SyslogAddr, sizeof(SyslogAddr) - sizeof(SyslogAddr.sa_data) + strlen(SyslogAddr.sa_data)) != -1) #endif connected = 1; } /* * CLOSELOG -- close the system log */ void closelog() { (void) close(LogFile); LogFile = -1; connected = 0; } static int LogMask = 0xff; /* mask of priorities to be logged */ /* * SETLOGMASK -- set the log mask level */ int setlogmask(pmask) int pmask; { int omask; omask = LogMask; if (pmask != 0) LogMask = pmask; return (omask); } ./libc-linux/nls/ 40755 1676 334 0 5567152204 11621 5ustar hjlisl./libc-linux/nls/msgcat.c100644 1676 334 31343 5544104776 13372 0ustar hjlisl#if 0 static char rcsid[] = "@(#)$Id: msgcat.c,v 5.2 1993/06/10 03:12:10 syd Exp $"; #endif /* -*- c++ -*- */ /*********************************************************** Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that Alfalfa's name not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. ALPHALPHA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ALPHALPHA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. If you make any modifications, bugfixes or other changes to this software we'd appreciate it if you could send a copy to us so we can keep things up-to-date. Many thanks. Kee Hinckley Alfalfa Software, Inc. 267 Allston St., #3 Cambridge, MA 02139 USA nazgul@alfalfa.com ******************************************************************/ /* Edit History 11/07/93 1 mitch fast mmap() support. (m.dsouza@mrc-apu.cam.ac.uk) 03/06/91 4 schulert remove working directory from nlspath 01/18/91 2 hamilton #if not rescanned 01/12/91 3 schulert conditionally use prototypes 11/03/90 1 hamilton Alphalpha->Alfalfa & OmegaMail->Poste 10/15/90 2 schulert > #include if MIPS 08/13/90 1 schulert move from ua to omu */ /* * We need a better way of handling errors than printing text. I need * to add an error handling routine. */ #include "nl_types.h" #include "msgcat.h" #include #ifdef BSD #include #include #endif #include #include #include #ifdef MIPS #include #endif #ifndef True # define True ~0 # define False 0 #endif /* take care of sysv diffs */ #ifndef MAXPATHLEN #define MAXPATHLEN 1024 #endif #ifndef FD_CLOEXEC #define FD_CLOEXEC 1 #endif #define NLERR ((nl_catd) -1) char *MCAppPath = NULL; #ifndef __linux__ static nl_catd loadCat(); static nl_catd loadSet(); extern char *malloc(), *getenv(); #else /* Strict prototypes makes better programmers */ #ifdef HAVE_MMAP /* * We need to find the size of the file if we are mmap()'ing, but we have * already filled in the stat structure in the catopen() routine, so we * just pass this structure back to loadCat() to save an extra stat() call. * */ static nl_catd loadCat(char *, int, struct stat *); #else static nl_catd loadCat(char *, int); #endif static nl_catd loadSet(MCCatT *, MCSetT *); #include #include #include #include #endif #ifdef HAVE_MMAP #include #include #endif nl_catd catopen( name, type) char *name; int type; { char path[MAXPATHLEN], *catpath = NULL; char *nlspath, *tmppath = NULL; char *lang; long len; char *base, *cptr, *pathP; struct stat sbuf; if (!name || !*name) return(NLERR); if (*name == '/') { catpath = name; if (stat(catpath, &sbuf)) return(NLERR); } else { #if BROKEN_SETLOCALE if ((lang = (char *) getenv("LANG")) == NULL) lang = "C"; #else /* Query the locale from the previous setlocale call in msgcat-libc.c*/ if ((lang = (char *) setlocale(LC_MESSAGES,(char *) NULL)) == NULL) lang="C"; #endif if ((nlspath = (char *) getenv("NLSPATH")) == NULL) { #if OLD_NLS_PATHS nlspath = "/nlslib/%L/%N.cat:/nlslib/%N/%L"; #else nlspath = "/etc/locale/%L/%N.cat:/usr/lib/locale/%L/%N.cat:/usr/lib/locale/%N/%L"; #endif } if (MCAppPath) { tmppath = (char *) malloc(strlen(nlspath) + strlen(MCAppPath) + 3); if (!tmppath) return(NLERR); strcpy(tmppath, nlspath); if (tmppath[strlen(tmppath)-1] != ':' && *MCAppPath != ':') strcat(tmppath, ":"); strcat(tmppath, MCAppPath); nlspath = tmppath; } len = strlen(nlspath); base = cptr = (char *) malloc(len + 2); if (!base) return(NLERR); strcpy(cptr, nlspath); cptr[len] = ':'; cptr[len+1] = '\0'; for (nlspath = cptr; *cptr; ++cptr) { if (*cptr == ':') { *cptr = '\0'; for (pathP = path; *nlspath; ++nlspath) { if (*nlspath == '%') { if (*(nlspath + 1) == 'L') { ++nlspath; strcpy(pathP, lang); pathP += strlen(lang); } else if (*(nlspath + 1) == 'N') { ++nlspath; strcpy(pathP, name); pathP += strlen(name); } else *(pathP++) = *nlspath; } else *(pathP++) = *nlspath; } *pathP = '\0'; if (stat(path, &sbuf) == 0) { catpath = path; break; } nlspath = cptr+1; } } free(base); if (tmppath) free(tmppath); if (!catpath) return(NLERR); } #ifdef HAVE_MMAP return(loadCat(catpath, type, &sbuf)); #else return(loadCat(catpath, type)); #endif } /* * We've got an odd situation here. The odds are real good that the * number we are looking for is almost the same as the index. We could * use the index, check the difference and do something intelligent, but * I haven't quite figured out what's intelligent. * * Here's a start. * Take an id N. If there are > N items in the list, then N cannot * be more than N items from the start, since otherwise there would * have to be duplicate items. So we can safely set the top to N+1 * (after taking into account that ids start at 1, and arrays at 0) * * Let's say we are at position P, and we are looking for N, but have * V. If N > V, then the furthest away that N could be is * P + (N-V). So we can safely set hi to P+(N-V)+1. For example: * We are looking for 10, but have 8 * 8 ? ? ? ? * >=9 >=10 >=11 * */ MCSetT *MCGetSet( cat, setId) MCCatT *cat; int setId; { MCSetT *set; long lo, hi, cur, dir; if (cat==(MCCatT *)NLERR || !cat || setId <= 0) return(NULL); lo = 0; if (setId - 1 < cat->numSets) { cur = setId - 1; hi = setId; } else { hi = cat->numSets; cur = (hi - lo) / 2; } while (True) { set = cat->sets + cur; if (set->setId == setId) break; if (set->setId < setId) { lo = cur+1; if (hi > cur + (setId - set->setId) + 1) hi = cur+(setId-set->setId)+1; dir = 1; } else { hi = cur; dir = -1; } if (lo >= hi) return(NULL); if (hi - lo == 1) cur += dir; else cur += ((hi - lo) / 2) * dir; } if (set->invalid) loadSet(cat, set); return(set); } MCMsgT *MCGetMsg( set, msgId) MCSetT *set; int msgId; { MCMsgT *msg; long lo, hi, cur, dir; if (!set || set->invalid || msgId <= 0) return(NULL); lo = 0; if (msgId - 1 < set->numMsgs) { cur = msgId - 1; hi = msgId; } else { hi = set->numMsgs; cur = (hi - lo) / 2; } while (True) { msg = set->u.msgs + cur; if (msg->msgId == msgId) break; if (msg->msgId < msgId) { lo = cur+1; if (hi > cur + (msgId - msg->msgId) + 1) hi = cur+(msgId-msg->msgId)+1; dir = 1; } else { hi = cur; dir = -1; } if (lo >= hi) return(NULL); if (hi - lo == 1) cur += dir; else cur += ((hi - lo) / 2) * dir; } return(msg); } char *catgets( catd, setId, msgId, dflt) nl_catd catd; int setId; int msgId; char *dflt; { MCMsgT *msg; MCCatT *cat = (MCCatT *) catd; char *cptr; msg = MCGetMsg(MCGetSet(cat, setId), msgId); if (msg) cptr = msg->msg.str; else cptr = dflt; return(cptr); } int catclose (catd) nl_catd catd; { MCCatT *cat = (MCCatT *) catd; MCSetT *set; MCMsgT *msg; int i, j; if (cat==(MCCatT *)NLERR || !cat) return -1; if (cat->loadType != MCLoadAll) #ifndef HAVE_MMAP close(cat->fd); #else munmap(cat->u.addr,cat->size); #endif for (i = 0; i < cat->numSets; ++i) { set = cat->sets + i; if (!set->invalid) { #if 0 free(set->data); #endif free(set->data.str); free(set->u.msgs); } } free(cat->sets); free(cat); return 0; } /* * Internal routines */ /* Note that only malloc failures are allowed to return an error */ #define ERRNAME "Message Catalog System" #define CORRUPT() {fprintf(stderr, "%s: corrupt file.\n", ERRNAME); return(0);} #define NOSPACE() {fprintf(stderr, "%s: no more memory.\n", ERRNAME); return(NLERR);} #ifdef HAVE_MMAP static nl_catd loadCat( catpath, type, st) #else static nl_catd loadCat( catpath, type) #endif char *catpath; int type; #ifdef HAVE_MMAP struct stat *st; { #else { MCHeaderT header; #endif MCCatT *cat; MCSetT *set; MCMsgT *msg; long i, j; off_t nextSet; #ifdef HAVE_MMAP caddr_t a; #endif cat = (MCCatT *) malloc(sizeof(MCCatT)); if (!cat) return(NLERR); cat->loadType = type; #ifdef HAVE_MMAP if ((cat->u.fd = open(catpath, O_RDONLY)) < 0) { #else if ((cat->fd = open(catpath, O_RDONLY)) < 0) { #endif return(0); } #ifdef HAVE_MMAP if ((a=mmap(0,cat->size=st->st_size, PROT_READ,MAP_SHARED,cat->u.fd,0))==(caddr_t)-1) return(0); close(cat->u.fd); if(cat->size < sizeof(MCHeaderT) || strncmp((cat->u.addr=a), MCMagic, MCMagicLen)!=0) CORRUPT(); #else fcntl(cat->fd, F_SETFD, FD_CLOEXEC); if (read(cat->fd, &header, sizeof(header)) != sizeof(header)) CORRUPT(); if (strncmp(header.magic, MCMagic, MCMagicLen) != 0) CORRUPT(); #endif #ifdef HAVE_MMAP if (((MCHeaderT *)(cat->u.addr))->majorVer !=MCMajorVer) { #else if (header.majorVer != MCMajorVer) { #endif fprintf(stderr, "%s: %s is version %d, we need %d.\n", ERRNAME, catpath, #ifdef HAVE_MMAP ((MCHeaderT *)(cat->u.addr))->majorVer, MCMajorVer); #else header.majorVer, MCMajorVer); #endif return(0); } #ifdef HAVE_MMAP if (((MCHeaderT *)(cat->u.addr))->numSets <= 0) { #else if (header.numSets <= 0) { #endif fprintf(stderr, "%s: %s has %d sets!\n", ERRNAME, catpath, #ifdef HAVE_MMAP ((MCHeaderT *)(cat->u.addr))->numSets); #else header.numSets); #endif return(0); } #ifdef HAVE_MMAP cat->numSets = ((MCHeaderT *)(cat->u.addr))->numSets; cat->sets = (MCSetT *) malloc(sizeof(MCSetT) * ((MCHeaderT *)(cat->u.addr))->numSets); #else cat->numSets = header.numSets; cat->sets = (MCSetT *) malloc(sizeof(MCSetT) * header.numSets); #endif if (!cat->sets) NOSPACE(); #ifdef HAVE_MMAP nextSet = ((MCHeaderT *)(cat->u.addr))->firstSet; #else nextSet = header.firstSet; #endif for (i = 0; i < cat->numSets; ++i) { #ifndef HAVE_MMAP if (lseek(cat->fd, nextSet, 0) == -1) CORRUPT(); #else if (nextSet > cat->size) CORRUPT(); #endif /* read in the set header */ set = cat->sets + i; #ifdef HAVE_MMAP if (nextSet+sizeof(*set) > cat->size) CORRUPT(); bcopy(cat->u.addr+nextSet,set,sizeof(*set)); #else if (read(cat->fd, set, sizeof(*set)) != sizeof(*set)) CORRUPT(); #endif /* if it's invalid, skip over it (and backup 'i') */ if (set->invalid) { --i; nextSet = set->nextSet; continue; } if (cat->loadType == MCLoadAll) { nl_catd res; if ((res = loadSet(cat, set)) <= 0) { if (res == -1) NOSPACE(); CORRUPT(); } } else set->invalid = True; nextSet = set->nextSet; } if (cat->loadType == MCLoadAll) { #ifndef HAVE_MMAP close(cat->fd); cat->fd = -1; #else munmap(cat->u.addr,cat->size); #endif } return((nl_catd) cat); } static nl_catd loadSet( cat, set) MCCatT *cat; MCSetT *set; { MCMsgT *msg; int i; #ifdef HAVE_MMAP long offset; #endif /* Get the data */ #ifndef HAVE_MMAP if (lseek(cat->fd,set->data.off, 0) == -1) return(0); #else if ((offset=set->data.off) > cat->size) return(0); #endif if ((set->data.str = (char *) malloc(set->dataLen)) == NULL) return(-1); #ifndef HAVE_MMAP if (read(cat->fd, set->data.str, set->dataLen) != set->dataLen) return(0); #else if (offset+set->dataLen > cat->size) return(0); bcopy(cat->u.addr+offset, set->data.str,set->dataLen); #endif /* Get the messages */ #ifndef HAVE_MMAP if (lseek(cat->fd, set->u.firstMsg, 0) == -1) return(0); #else if ((offset=set->u.firstMsg) > cat->size) return(0); #endif if ((set->u.msgs = (MCMsgT *) malloc(sizeof(MCMsgT) * set->numMsgs)) == NULL) return(-1); for (i = 0; i < set->numMsgs; ++i) { msg = set->u.msgs + i; #ifndef HAVE_MMAP if (read(cat->fd, msg, sizeof(*msg)) != sizeof(*msg)) return(0); #else if (offset+sizeof(*msg) > cat->size) return(0); bcopy(cat->u.addr+offset+i*sizeof(*msg), msg,sizeof(*msg)); #endif if (msg->invalid) { --i; continue; } msg->msg.str = (char *) (set->data.str + msg->msg.off); } set->invalid = False; return(1); } ./libc-linux/nls/mcprtlib.c100644 1676 334 35323 5462220522 13715 0ustar hjlisl /*********************************************************** Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that Alfalfa's name not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. ALPHALPHA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ALPHALPHA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. If you make any modifications, bugfixes or other changes to this software we'd appreciate it if you could send a copy to us so we can keep things up-to-date. Many thanks. Kee Hinckley Alfalfa Software, Inc. 267 Allston St., #3 Cambridge, MA 02139 USA nazgul@alfalfa.com ******************************************************************/ /* Edit History 04/15/92 2 nazgul Avoid data overruns on allocated strings. 03/25/91 4 hamilton Handle null data in MCPrintFree 01/18/91 3 hamilton #if not rescanned 01/12/91 2 schulert conditionally use prototypes 01/06/91 1 schulert check for NULL char* before calling strlen() 11/03/90 2 hamilton Alphalpha->Alfalfa & OmegaMail->Poste 08/13/90 1 hamilton Add for sco 08/10/90 2 nazgul Added support for %S and %M 08/10/90 1 nazgul Supports %d and %s */ #define CATGETS #include #include #include "mcprtlib.h" #ifdef CATGETS # include "nl_types.h" #ifndef MCMakeId # define MCuint unsigned int # define MCushort unsigned short # define MCulong unsigned long # define MCMakeId(s,m) (MCulong)(((MCushort)s<<(sizeof(short)*8))\ |(MCushort)m) # define MCSetId(id) (MCuint) ((MCuint)id >> (MCuint)(sizeof(short) * 8)) # define MCMsgId(id) (MCuint) (((MCuint)id << (MCuint)(sizeof(short) * 8))\ >> (MCuint)(sizeof(short) * 8)) #endif #endif #ifndef True # define True ~0 # define False 0 #endif #define MCShortMod 0x01 #define MCLongMod 0x02 #define MCLongFMod 0x04 #define GETNUM(x) x = 0; \ while (isdigit(*fptr)) x = (x * 10) + *fptr++ - '0'; \ if (!*fptr) goto err; MCRockT *MCPrintInit( #if defined(__STDC__) || defined(__cplusplus) char *fmt) #else fmt) char *fmt; #endif { int argCnt, curPos, typeCnt, done, mod, replyCnt, i, pos; char *fptr, *cptr; MCArgumentT *argList, arg; MCRockT *rock; MCTypesT *typeList; /* This can count too many, but that's okay */ for (argCnt = 0, fptr = fmt; *fptr; ++fptr) { if (*fptr == '%') ++argCnt; } ++argCnt; /* One for the end */ rock = (MCRockT *) malloc(sizeof(MCRockT)); bzero(rock, sizeof(*rock)); rock->argList = argList = (MCArgumentT *) malloc(sizeof(MCArgumentT) * argCnt); bzero(&arg, sizeof(arg)); arg.data = fmt; arg.dataLen = 0; argCnt = 0; curPos = 1; typeCnt = 0; for (fptr = fmt; *fptr; ++fptr) { if (*fptr == '%') { arg.dataLen = fptr - arg.data; arg.pos = 0; ++fptr; /* Check for position */ if (isdigit(*fptr)) { for (cptr = fptr; isdigit(*cptr); ++cptr); if (*cptr == '$') { GETNUM(arg.pos); ++fptr; } } /* Check for flags (% + - # 0) */ arg.flag = 0; done = False; while (!done) { switch (*fptr) { case ' ': arg.flag |= MCSpaceFlag; break; case '+': arg.flag |= MCPlusFlag; break; case '-': arg.flag |= MCMinusFlag; break; case '#': arg.flag |= MCAltFlag; break; case '0': arg.flag |= MCZeroFlag; break; default: done = True; break; } ++fptr; } --fptr; /* Check the width argument */ arg.hasWidth = False; arg.widthPos = 0; if (isdigit(*fptr)) { /* width */ arg.hasWidth = True; GETNUM(arg.width); } else if (*fptr == '*') { arg.hasWidth = True; ++fptr; if (isdigit(*fptr)) { /* reference to width pos */ GETNUM(arg.widthPos); ++fptr; } else { arg.widthPos = curPos++; } } /* Check for precision argument */ arg.hasPrec = False; arg.precPos = 0; if (*fptr == '.') { ++fptr; if (isdigit(*fptr)) { /* precision */ arg.hasPrec = True; GETNUM(arg.prec); } else if (*fptr == '*') { arg.hasPrec = True; ++fptr; if (isdigit(*fptr)) { /* reference to prec pos */ GETNUM(arg.precPos); ++fptr; } else { arg.precPos = curPos++; } } } /* Check for size modifier */ for (mod = 0, done = False; !done; ++fptr) { switch (*fptr) { case 'h': mod |= MCShortMod; break; case 'l': mod |= MCLongMod; break; case 'L': mod |= MCLongFMod; break; default: done = True; --fptr; break; } } /* Check for the real thing */ arg.c = *fptr; arg.type = 0; switch (*fptr) { #ifdef CATGETS case 'M': case 'S': #endif case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': case 'c': if (mod & MCShortMod) arg.type = MCShortType; else if (mod & MCLongMod) arg.type = MCLongType; else arg.type = MCIntType; break; case 'f': case 'e': case 'E': case 'g': case 'G': if (mod & MCLongFMod) arg.type = MCLongFloatType; else arg.type = MCFloatType; break; case 's': arg.type = MCStringType; break; #ifdef CATGETS case 'C': #endif case 'p': arg.type = MCVoidPType; break; case 'n': if (mod & MCShortMod) arg.type = MCShortPType; else if (mod & MCLongMod) arg.type = MCLongPType; else arg.type = MCIntPType; break; case '%': ++arg.dataLen; /* An empty arg with a data element including % */ break; default: goto err; break; } /* They should never mix with and without positions, but be nice */ if (!arg.pos) arg.pos = curPos++; else curPos = arg.pos+1; /* Keep track of how many type elements we'll need */ if (arg.pos > typeCnt) typeCnt = arg.pos; if (arg.precPos > typeCnt) typeCnt = arg.precPos; if (arg.widthPos > typeCnt) typeCnt = arg.widthPos; argList[argCnt++] = arg; bzero(&arg, sizeof(arg)); arg.data = fptr+1; } else { /* Otherwise things will just end up in arg.data */ } } /* Catch any trailing text */ arg.dataLen = fptr - arg.data; argList[argCnt++] = arg; /* * We now have an array which precisely describes all of the arguments. * Now we allocate space for each of the arguments. * Then we loop through that array and fill it in with the correct arguments. * Finally we loop through the arglist and print out each of the arguments. * Simple, no? */ /* Allocate the type list */ rock->typeList = typeList = (MCTypesT *) malloc(sizeof(MCTypesT) * typeCnt); /* Go through and set the types */ /* * I was going to check here and see if, when a type was referenced twice, * they typed it differently, and return an error when they did. But then * it occured to me that doing that could be useful. Consider passing a * pointer and wanting to see it in both string and hex form. If they think * they know what they're doing we might as well let them do it. */ /* * Set the correct types and figure out how many data segments we are going * to have. */ for (replyCnt = i = 0; i < argCnt; ++i) { if (argList[i].type) { pos = argList[i].pos-1; typeList[pos].type = argList[i].type; ++replyCnt; if (argList[i].precPos) typeList[argList[i].precPos-1].type = MCIntType; if (argList[i].widthPos) typeList[argList[i].widthPos-1].type = MCIntType; } if (argList[i].dataLen) ++replyCnt; } ++replyCnt; /* with NULLs */ rock->replyCnt = replyCnt; rock->argCnt = argCnt; rock->typeCnt = typeCnt; rock->replyList = NULL; return(rock); err: MCPrintFree(rock); return(NULL); } int MCPrintParse( #if defined(__STDC__) || defined(__cplusplus) MCRockT *rock) #else rock) MCRockT *rock; #endif { MCArgumentT *argList = rock->argList, arg; int argCnt = rock->argCnt; MCTypesT *typeList = rock->typeList, type; int typeCnt = rock->typeCnt; MCReplyT *replyList; int replyCnt = rock->replyCnt; int i, pos, ri, j, base, isSigned, isNeg, len, alen, retlen = 0; char *index, *cptr, buf[BUFSIZ], *fptr; #ifdef CATGETS int setId = 0, msgId = 0; nl_catd catd; #endif /* Allocate the reply structure */ rock->replyList = replyList = (MCReplyT *) malloc(sizeof(MCReplyT) * replyCnt); /* Now we do the dirty work of actually formatting the stuff */ for (ri = i = 0; i < argCnt; ++i) { pos = argList[i].pos-1; /* Handle the data from the format string */ if (argList[i].dataLen) { replyList[ri].argType = MCFmtArg; replyList[ri].data = argList[i].data; retlen += replyList[ri].dataLen = argList[i].dataLen; ++ri; } /* Fill in the indirect width and precision stuff */ if (argList[i].hasPrec && argList[i].precPos) { argList[i].prec = typeList[argList[i].precPos-1].u.intV; } if (argList[i].hasWidth && argList[i].widthPos) { argList[i].width = typeList[argList[i].widthPos-1].u.intV; } if (argList[i].type) { type = typeList[pos]; arg = argList[i]; if (arg.type == MCShortType || arg.type == MCLongType || arg.type == MCIntType) { intType: index = "0123456789abcdef"; switch (arg.c) { case 'd': case 'i': base = 10; isSigned = True; break; case 'u': base = 10; isSigned = False; break; case 'o': base = 8; isSigned = False; break; case 'X': index = "0123456789ABCDEF"; case 'x': base = 16; isSigned = False; break; #ifdef CATGETS case 'S': setId = type.u.intV; goto nextArg; case 'M': if (arg.type == MCLongType) { setId = MCSetId(type.u.longV); msgId = MCMsgId(type.u.longV); } else msgId = type.u.intV; type.u.charPV = catgets(catd, setId, msgId, ""); goto strType; #endif default: goto err; } if (base == -1) { } cptr = buf; isNeg = False; switch (arg.type) { case MCShortType: if (isSigned && type.u.shortV < 0) { isNeg = True; type.u.shortV = -type.u.shortV; } if (!type.u.shortV) break; while (type.u.shortV) { *cptr++ = index[type.u.shortV % base]; type.u.shortV /= 10; } break; case MCLongType: if (isSigned && type.u.longV < 0) { isNeg = True; type.u.longV = -type.u.longV; } if (!type.u.longV) break; while (type.u.longV) { *cptr++ = index[type.u.longV % base]; type.u.longV /= 10; } break; case MCIntType: if (isSigned && type.u.intV < 0) { isNeg = True; type.u.intV = -type.u.intV; } if (!type.u.intV) break; while (type.u.intV) { *cptr++ = index[type.u.intV % base]; type.u.intV /= 10; } break; } /* precision */ if (cptr == buf && !arg.hasPrec) *cptr++ = '0'; if (arg.hasPrec && cptr-buf < arg.prec) { for (j = cptr-buf; j < arg.prec; ++j) *cptr++ = '0'; } /* zero width padding */ if ((arg.flag & MCZeroFlag) && arg.hasWidth && !(arg.flag & MCMinusFlag)) { for (j = cptr-buf; j < arg.width; ++j) *cptr++ = '0'; if (isNeg || (arg.flag & MCPlusFlag) || (arg.flag & MCSpaceFlag)) --cptr; } /* signs */ if (isNeg) *cptr++ = '-'; else if (arg.flag & MCPlusFlag) *cptr++ = '+'; else if (arg.flag & MCSpaceFlag) *cptr++ = ' '; /* alternate forms */ if (arg.flag & MCAltFlag) { if (arg.c == 'x') *cptr++ = 'x'; else if (arg.c == 'X') *cptr++ = 'X'; else if (arg.c != 'o') *cptr++ = '#'; /* Undefined */ *cptr++ = '0'; } /* get the storage space */ if (arg.hasWidth && arg.width > cptr-buf) len = arg.width; else len = cptr-buf; replyList[ri].argType = MCDataArg; fptr = replyList[ri].data = (char *) malloc(len+1); replyList[ri].dataLen = len; fptr[len] = NULL; if (arg.hasWidth && arg.width > cptr-buf) { if (arg.flag & MCMinusFlag) { /* pad the end */ fptr += len; for (j = cptr-buf; j < arg.width; ++j) *--fptr = ' '; fptr = replyList[ri].data; } else { /* pad the beginning */ for (j = cptr-buf; j < arg.width; ++j) *fptr++ = ' '; } } for (j = cptr-buf; j > 0; --j) { *fptr++ = *--cptr; } ++ri; } else if (arg.type == MCStringType) { strType: if (arg.hasPrec) len = arg.prec; else len = type.u.charPV?strlen(type.u.charPV):0; if (arg.hasWidth && arg.width > len) alen = arg.width; else alen = len; replyList[ri].argType = MCUserArg; fptr = replyList[ri].data = (char *) malloc(alen+1); replyList[ri].dataLen = alen; fptr[alen] = NULL; if (len < alen) { if (arg.flag & MCMinusFlag) { fptr += alen; for (j = len; j < alen; ++j) *--fptr = ' '; fptr = replyList[ri].data; } else { /* pad the beginning */ for (j = len; j < alen; ++j) *fptr++ = ' '; } } bcopy(type.u.charPV, fptr, len); ++ri; } else if (arg.type == MCVoidPType) { #ifdef CATGETS if (arg.c == 'C') { catd = (nl_catd) type.u.voidPV; goto nextArg; } #endif arg.c = 'X'; arg.flag |= MCAltFlag; goto intType; } else { /* MCLongFloatType MCFloatType */ /* MCShortPType MCLongPType MCIntPType */ goto err; } retlen += replyList[ri-1].dataLen; } nextArg:; /* Used for arguments with no output */ } replyList[ri].argType = 0; replyList[ri].data = NULL; replyList[ri].dataLen = 0; rock->replyCnt = ri; return(retlen); err: MCPrintFree(rock); return(-1); } void MCPrintFree( #if defined(__STDC__) || defined(__cplusplus) MCRockT *rock) #else rock) MCRockT *rock; #endif { int i; if (!rock) return; if (rock->argList) free(rock->argList); if (rock->typeList) free(rock->typeList); if (rock->replyList) { for (i = 0; i < rock->argCnt; ++i) { if ((rock->replyList[i].argType & MCFree) && rock->replyList[i].data) free(rock->replyList[i].data); } free(rock->replyList); } free(rock); } ./libc-linux/nls/msgcat-libc.c100644 1676 334 1156 5501740502 14242 0ustar hjlisl/* Some routines for Linux libc (and probably others). * Covered by GNU LIBC LICENCE. * * Mitch D'Souza. (m.dsouza@mrc-apu.cam.ac.uk) */ #ifdef __linux__ #include #include #include "nl_types.h" #define CATALOGUE "libc" nl_catd _libc_cat = 0; void libc_nls_init(void) { extern nl_catd _libc_cat; if (_libc_cat != 0) /* * Either a previous catopen() failed * or the libc catalog is already open */ return; /* This is the first time we try. */ /* Get the environment setting for LC_MESSAGES */ setlocale(LC_MESSAGES,""); _libc_cat=catopen(CATALOGUE,0); } #endif ./libc-linux/README100644 1676 334 1461 5550064517 12005 0ustar hjlislYou shoul do configure first to generate the "config.in." make clean make depend Then you can do make # compile everything. make STATIC=true # for static library make SHARED=true # for shared image and stub libraries. make STATIC_SHARED=true # for static and shared libraries. make LITE=true # for light version shared library. no libm.a. # no stub libraries are built. make DEBUG=true # for libg.a make PROFILE=true # for libc_p.a make MATH=true # for static libm.a only make MATH=true SHARED=true # for shared image and stub for libm.a You can add SHADOW_COMPAT=true to turn on the shadow password support, which may slow down your applications. Due to the copyright complications, I suggest you compile the shadow stuff from the source code yourself. Thanks. H.J. hjl@nynexst.com 01/19/94 ./libc-linux/locale/ 40755 1676 334 0 5567152200 12260 5ustar hjlisl./libc-linux/locale/setlocale.c100644 1676 334 37610 5550051005 14514 0ustar hjlisl/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #if defined(__linux__) && defined(USE_ISO_8859_1) #include #include #include #include extern CONST unsigned short int __ctype_b_C[]; extern CONST unsigned char __ctype_tolower_C[]; extern CONST unsigned char __ctype_toupper_C[]; extern CONST struct ctype_info __ctype_C; extern CONST struct collate_info __collate_C; extern CONST struct monetary_info __monetary_C; extern CONST struct numeric_info __numeric_C; extern CONST struct response_info __response_C; extern CONST struct time_info __time_C; extern CONST unsigned short int __ctype_b_ISO_8859_1[]; extern CONST unsigned char __ctype_tolower_ISO_8859_1[]; extern CONST unsigned char __ctype_toupper_ISO_8859_1[]; extern CONST struct ctype_info __ctype_ISO_8859_1; static int loc_open __P ((CONST unsigned char *, CONST unsigned char *)); static int guard_check __P ((CONST int, CONST unsigned char *)); static int loc_rdline __P ((CONST int, unsigned char *, CONST int, unsigned char **[])); static int loc_collate __P ((CONST int, CONST unsigned char *)); static int loc_ctype __P ((CONST int, CONST unsigned char *)); static int loc_monetary __P ((CONST int, CONST unsigned char *)); static int loc_numeric __P ((CONST int, CONST unsigned char *)); static int loc_time __P ((CONST int, CONST unsigned char *)); static int loc_response __P ((CONST int, CONST unsigned char *)); #endif /* __linux__ && USE_ISO_8859_1 */ /* Switch to the locale called NAME in CATEGORY. Return a string describing the locale. This string can be used as the NAME argument in a later call. If NAME is NULL, don't switch locales, but return the current one. If NAME is "", switch to a locale based on the environment variables, as per POSIX. Return NULL on error. */ char * DEFUN (setlocale, (category, name), int category AND CONST char *name) { #if defined(__linux__) && defined(USE_ISO_8859_1) /* Don't ask me why I did this. H.J. */ /* Fixed up setlocale() by Mitch (m.dsouza@mrc-apu.cam.ac.uk) */ /* Nickolay Saukh was here */ static struct message_struct { int category; CONST char *name; CONST char *locale; char *saved_locale; } ms[] = { { LC_COLLATE, "LC_COLLATE", "C" } , { LC_CTYPE, "LC_CTYPE", "C" } , { LC_MONETARY, "LC_MONETARY", "C" } , { LC_NUMERIC, "LC_NUMERIC", "C" } , { LC_TIME, "LC_TIME", "C" } , { LC_RESPONSE, "LC_RESPONSE", "C" } , { LC_MESSAGES, "LC_MESSAGES", "C" } , /* * New categories go in between here. */ { LC_ALL, "LC_ALL", "C" } }; int i; char *ptr; if (name == NULL) /* We just asking for current settings */ { for (i = 0; i < sizeof (ms) / sizeof (struct message_struct); i++) { if (category == ms[i].category) return (char *) ms[i].locale; } errno = EINVAL; return NULL; /* Not a valid category */ } /* * What the category asked (excluding LC_ALL)? */ if (category != LC_ALL) { for (i = 0; i < sizeof (ms) / sizeof (struct message_struct) - 1; i++) { if (category != ms[i].category) continue; /* If "" is given as the locale then we check environment vars */ if (*name == '\0') { if ((ptr = getenv (ms[i].name)) == NULL && (ptr = getenv ("LANG")) == NULL) { errno = ENOENT; return NULL; /* What the locale you asked? */ } } else ptr = (char *) name; if (!strcmp (ptr, "POSIX") || !strcmp (ptr, ms[i].locale)) return (char *) ms[i].locale; switch (category) { int fd; case LC_COLLATE: if (!strcmp (ptr, "C")) { _collate_info = &__collate_C; ms[i].locale = "C"; return (char *) ms[i].locale; } else if ((fd = loc_open (ptr, ms[i].name)) >= 0 && loc_collate (fd, ptr)) { ms[i].locale = ptr; return (char *) ms[i].locale; } errno = ENOENT; return NULL; /* Unknown locale */ case LC_CTYPE: if (!strcmp (ptr, "C")) { __ctype_b = __ctype_b_C + 1; __ctype_tolower = __ctype_tolower_C + 1; __ctype_toupper = __ctype_toupper_C + 1; _ctype_info = &__ctype_C; ms[i].locale = "C"; return (char *) ms[i].locale; } else if (!strcmp (ptr, "ISO-8859-1")) { __ctype_b = __ctype_b_ISO_8859_1 + 1; __ctype_tolower = __ctype_tolower_ISO_8859_1 + 1; __ctype_toupper = __ctype_toupper_ISO_8859_1 + 1; _ctype_info = &__ctype_ISO_8859_1; ms[i].locale = "ISO-8859-1"; return (char *) ms[i].locale; } else if ((fd = loc_open (ptr, ms[i].name)) >= 0 && loc_ctype (fd, ptr)) { ms[i].locale = ptr; return (char *) ms[i].locale; } errno = ENOENT; return NULL; /* Unknown locale */ case LC_MONETARY: if (!strcmp (ptr, "C")) { _monetary_info = &__monetary_C; ms[i].locale = "C"; return (char *) ms[i].locale; } else if ((fd = loc_open (ptr, ms[i].name)) >= 0 && loc_monetary (fd, ptr)) { ms[i].locale = ptr; return (char *) ms[i].locale; } errno = ENOENT; return NULL; /* Unknown locale */ case LC_NUMERIC: if (!strcmp (ptr, "C")) { _numeric_info = &__numeric_C; ms[i].locale = "C"; return (char *) ms[i].locale; } else if ((fd = loc_open (ptr, ms[i].name)) >= 0 && loc_numeric (fd, ptr)) { ms[i].locale = ptr; return (char *) ms[i].locale; } errno = ENOENT; return NULL; /* Unknown locale */ case LC_TIME: if (!strcmp (ptr, "C")) { _time_info = &__time_C; ms[i].locale = "C"; return (char *) ms[i].locale; } else if ((fd = loc_open (ptr, ms[i].name)) >= 0 && loc_time (fd, ptr)) { ms[i].locale = ptr; return (char *) ms[i].locale; } errno = ENOENT; return NULL; /* Unknown locale */ case LC_RESPONSE: if (!strcmp (ptr, "C")) { _response_info = &__response_C; ms[i].locale = "C"; return (char *) ms[i].locale; } else if ((fd = loc_open (ptr, ms[i].name)) >= 0 && loc_response (fd, ptr)) { ms[i].locale = ptr; return (char *) ms[i].locale; } errno = ENOENT; return NULL; /* Unknown locale */ case LC_MESSAGES: if (ptr == NULL) { errno = ENOENT; return NULL; /* Unknown locale */ } /* Some interaction with nls required to * ensure correct settings */ ms[i].locale = ptr; return (char *) ms[i].locale; } } /* * Invalid category requested */ errno = EINVAL; return NULL; } /* * If we here, then LC_ALL was requested */ for (i = 0; i < sizeof (ms) / sizeof (struct message_struct) - 1; i++) { /* Save current setting */ ms[i].saved_locale = setlocale (ms[i].category, NULL); if (setlocale (ms[i].category, name) == NULL) { /* Oops! Recover original state */ int j; int se = errno; for (j = 0; j < i; j++) (void) setlocale (ms[j].category, ms[j].saved_locale); errno = se; return NULL; } } /* if we here, then all individual locales were installed */ ms[i].locale = *name == '\0' ? getenv("LANG") : name; return (char *) ms[i].locale; #else /* Braindead implementation until I finish the fancy one. */ if (name == NULL || name[0] == '\0') return (char *) "C"; if (!strcmp (name, "C") || !strcmp (name, "POSIX")) return (char *) name; errno = EINVAL; return NULL; #endif } #if defined(__linux__) && defined(USE_ISO_8859_1) static int DEFUN (loc_open, (loc_name, cat_name), CONST unsigned char *loc_name AND CONST unsigned char *cat_name) { unsigned char buffer[128]; (void) strcpy (buffer, _PATH_LOCALE); (void) strcat (buffer, "/"); (void) strcat (buffer, loc_name); (void) strcat (buffer, "/"); (void) strcat (buffer, cat_name); return open (buffer, O_RDONLY); } static int DEFUN (guard_check, (fd, cname), CONST int fd AND CONST unsigned char *cname) { #ifndef NOGUARD unsigned char fcname[256]; /* * Guard check (overkill?) */ fcname[sizeof (fcname) - 1] = '\0'; if (read (fd, fcname, sizeof (fcname) - 1) < strlen (cname) + 1) { (void) close (fd); return 0; } else if (strcmp (cname, fcname)) { (void) close (fd); return 0; } #endif return 1; } static int DEFUN (loc_collate, (fd, cname), CONST int fd AND CONST unsigned char *cname) { static unsigned char values[UCHAR_MAX + 1]; static unsigned char offsets[UCHAR_MAX + 1]; static struct collate_info cinfo = { 0, NULL, values, offsets }; if (read (fd, values, sizeof (values)) != sizeof (values)) { (void) close (fd); return 0; } if (read (fd, offsets, sizeof (offsets)) != sizeof (offsets)) { (void) close (fd); return 0; } if (read (fd, &cinfo.nsubsts, sizeof (cinfo.nsubsts)) != sizeof (cinfo.nsubsts)) { (void) close (fd); return 0; } /* * XXX: for a while a did not like substitutions */ if (cinfo.nsubsts) { (void) close (fd); return 0; } if (!guard_check (fd, cname)) return 0; (void) close (fd); _collate_info = &cinfo; return 1; } static int DEFUN (loc_ctype, (fd, cname), CONST int fd AND CONST unsigned char *cname) { /* * There is no urgent need for multibytes */ extern CONST struct ctype_mbchar_info __ctype_mbchar_C; static struct ctables { unsigned short int xtype[UCHAR_MAX + 2]; unsigned char xlower[UCHAR_MAX + 2]; unsigned char xupper[UCHAR_MAX + 2]; } ctables; static struct ctype_ctype_info c2info = { ctables.xtype, ctables.xlower, ctables.xupper }; static CONST struct ctype_info cinfo = { &c2info, (struct ctype_mbchar_info *) &__ctype_mbchar_C /* No multibytes!!! */ }; if (read (fd, &ctables, sizeof (ctables)) != sizeof (ctables)) { (void) close (fd); return 0; } if (!guard_check (fd, cname)) return 0; (void) close (fd); __ctype_b = ctables.xtype + 1; __ctype_tolower = ctables.xlower + 1; __ctype_toupper = ctables.xupper + 1; _ctype_info = &cinfo; return 1; } static int DEFUN (loc_rdline, (fd, buf, buflen, target), CONST int fd AND unsigned char *buf AND CONST int buflen AND unsigned char **target[]) { int i; short len; unsigned char *cp = buf; for (i = 0; target[i] != NULL; i++) { if (read (fd, &len, sizeof (len)) != sizeof (len) || len > buflen - (cp - buf) || read (fd, cp, len) != len || *(cp + len - 1) != '\0') { (void) close (fd); return 0; } *target[i] = cp; cp += len; } return 1; } static int DEFUN (loc_monetary, (fd, cname), CONST int fd AND CONST unsigned char *cname) { static struct monetary_info minfo; static unsigned char **lines[] = { (unsigned char **) &minfo.int_curr_symbol, (unsigned char **) &minfo.currency_symbol, (unsigned char **) &minfo.mon_decimal_point, (unsigned char **) &minfo.mon_thousands_sep, (unsigned char **) &minfo.mon_grouping, (unsigned char **) &minfo.positive_sign, (unsigned char **) &minfo.negative_sign, NULL }; static unsigned char mbuffer[128]; /* Hope it long enough */ if (!loc_rdline (fd, mbuffer, sizeof (mbuffer), lines)) return 0; #define fclen (((&minfo.n_sign_posn) - (&minfo.int_frac_digits)) + sizeof (minfo.n_sign_posn)) if (read (fd, &minfo.int_frac_digits, fclen) != fclen) { (void) close (fd); return 0; } #undef fclen if (!guard_check (fd, cname)) return 0; (void) close (fd); _monetary_info = &minfo; return 1; } static int DEFUN (loc_numeric, (fd, cname), CONST int fd AND CONST unsigned char *cname) { static struct numeric_info ninfo; static unsigned char **lines[] = { (unsigned char **) &ninfo.decimal_point, (unsigned char **) &ninfo.thousands_sep, (unsigned char **) &ninfo.grouping, NULL }; static unsigned char nbuffer[64]; /* Hope it long enough */ if (!loc_rdline (fd, nbuffer, sizeof (nbuffer), lines)) return 0; if (!guard_check (fd, cname)) return 0; (void) close (fd); _numeric_info = &ninfo; return 1; } static int DEFUN (loc_time, (fd, cname), CONST int fd AND CONST unsigned char *cname) { static struct time_info tinfo; static unsigned char **lines[] = { (unsigned char **) &tinfo.abbrev_wkday[0], (unsigned char **) &tinfo.abbrev_wkday[1], (unsigned char **) &tinfo.abbrev_wkday[2], (unsigned char **) &tinfo.abbrev_wkday[3], (unsigned char **) &tinfo.abbrev_wkday[4], (unsigned char **) &tinfo.abbrev_wkday[5], (unsigned char **) &tinfo.abbrev_wkday[6], (unsigned char **) &tinfo.full_wkday[0], (unsigned char **) &tinfo.full_wkday[1], (unsigned char **) &tinfo.full_wkday[2], (unsigned char **) &tinfo.full_wkday[3], (unsigned char **) &tinfo.full_wkday[4], (unsigned char **) &tinfo.full_wkday[5], (unsigned char **) &tinfo.full_wkday[6], (unsigned char **) &tinfo.abbrev_month[0], (unsigned char **) &tinfo.abbrev_month[1], (unsigned char **) &tinfo.abbrev_month[2], (unsigned char **) &tinfo.abbrev_month[3], (unsigned char **) &tinfo.abbrev_month[4], (unsigned char **) &tinfo.abbrev_month[5], (unsigned char **) &tinfo.abbrev_month[6], (unsigned char **) &tinfo.abbrev_month[7], (unsigned char **) &tinfo.abbrev_month[8], (unsigned char **) &tinfo.abbrev_month[9], (unsigned char **) &tinfo.abbrev_month[10], (unsigned char **) &tinfo.abbrev_month[11], (unsigned char **) &tinfo.full_month[0], (unsigned char **) &tinfo.full_month[1], (unsigned char **) &tinfo.full_month[2], (unsigned char **) &tinfo.full_month[3], (unsigned char **) &tinfo.full_month[4], (unsigned char **) &tinfo.full_month[5], (unsigned char **) &tinfo.full_month[6], (unsigned char **) &tinfo.full_month[7], (unsigned char **) &tinfo.full_month[8], (unsigned char **) &tinfo.full_month[9], (unsigned char **) &tinfo.full_month[10], (unsigned char **) &tinfo.full_month[11], (unsigned char **) &tinfo.ampm[0], (unsigned char **) &tinfo.ampm[1], (unsigned char **) &tinfo.date_time, (unsigned char **) &tinfo.date, (unsigned char **) &tinfo.time, (unsigned char **) &tinfo.ut0, (unsigned char **) &tinfo.tz, NULL }; static unsigned char tbuffer[1024]; /* Hope it long enough */ if (!loc_rdline (fd, tbuffer, sizeof (tbuffer), lines)) return 0; if (!guard_check (fd, cname)) return 0; (void) close (fd); _time_info = &tinfo; return 1; } static int DEFUN (loc_response, (fd, cname), CONST int fd AND CONST unsigned char *cname) { static struct response_info rinfo; static unsigned char **lines[] = { (unsigned char **) &rinfo.yesexpr, (unsigned char **) &rinfo.noexpr, NULL }; static unsigned char rbuffer[64]; /* Hope it long enough */ if (!loc_rdline (fd, rbuffer, sizeof (rbuffer), lines)) return 0; if (!guard_check (fd, cname)) return 0; (void) close (fd); _response_info = &rinfo; return 1; } #endif ./libc-linux/locale/collate/ 40755 1676 334 0 5567152175 13716 5ustar hjlisl./libc-linux/locale/collate/mkcollate.c100644 1676 334 7443 5542326534 16135 0ustar hjlisl#include #include #include #include #include #include #include "mkcollate.h" extern int yyparse (void); int check_order (mkorder_t *, int); int write_out (unsigned char *); void grok_order (void); unsigned char cvalues[UCHAR_MAX + 1]; unsigned char coffsets[UCHAR_MAX + 1]; struct collate_info cinfo = { 0, NULL, cvalues, coffsets }; mksub_t *substitutions = NULL; mksub_t *last_sub = NULL; int nsubs = 0; mkorder_t *order = NULL; unsigned char *codename; int main (int argc, char *argv[]) { int i; unsigned char *outname = "LC_COLLATE"; while ((i = getopt (argc, argv, "o:")) != EOF) { switch (i) { case 'o': outname = optarg; break; } } if (argc - optind > 1) { (void) fprintf (stderr, "Usage: %s [-o out_file_name] [file]\n", argv[0]); return 3; } else if ((argc - optind) == 1) { if (freopen (argv[optind], "r", stdin) == NULL) { perror (argv[optind]); return 2; } } if (yyparse ()) return 1; if (nsubs) (void) fprintf (stderr, "Warning: substitutions ignored\n"); for (i = 0; i <= UCHAR_MAX; i++) { cvalues[i] = UCHAR_MAX; coffsets[i] = '\0'; } if (!check_order (order, 0)) return 1; grok_order (); return !write_out (outname); } int check_order (mkorder_t * node, int dep) { int res = 1; while (node != NULL) { switch (node->node_type) { case range: if (strlen (node->low) != 1 || strlen (node->top) != 1) { (void) fprintf (stderr, "Can't handle multibytes (%s;...;%s)\n", node->low, node->top); res = 0; } if (*(node->low) > *(node->top)) { (void) fprintf (stderr, "Invalid range (%s;...;%s)\n", node->low, node->top); res = 0; } break; case primary_only: case secondary: if (dep) { (void) fprintf (stderr, "Overnested order list\n"); res = 0; } else if (!check_order (node->extra, !dep)) res = 0; break; } node = node->next; } return res; } void grok_order () { mkorder_t *node = order; unsigned char p_order = 1; while (node != NULL) { switch (node->node_type) { case range: { unsigned int i = *node->low; for (; i <= *node->top; i++) { cvalues[i] = p_order++; coffsets[i] = 0; } } break; case primary_only: { mkorder_t *node2 = node->extra; while (node2 != NULL) { switch (node2->node_type) { case range: { unsigned int i2 = *node2->low; for (; i2 <= *node2->top; i2++) { cvalues[i2] = p_order; coffsets[i2] = 0; } } break; default: (void) fprintf (stderr, "Should not happens\n"); exit (4); } node2 = node2->next; } } p_order++; break; case secondary: { unsigned char s_order = 1; mkorder_t *node3 = node->extra; while (node3 != NULL) { switch (node3->node_type) { case range: { unsigned int i3 = *node3->low; for (; i3 <= *node3->top; i3++) { cvalues[i3] = p_order; coffsets[i3] = s_order++; } } break; default: (void) fprintf (stderr, "Should not happens\n"); exit (4); } node3 = node3->next; } } p_order++; break; } node = node->next; } } int write_out (outname) unsigned char *outname; { FILE *ofp = fopen (outname, "w"); if (ofp == NULL) return 0; (void) fwrite (cvalues, sizeof (cvalues), 1, ofp); (void) fwrite (coffsets, sizeof (coffsets), 1, ofp); (void) fwrite (&cinfo.nsubsts, sizeof (cinfo.nsubsts), 1, ofp); #ifndef NOGUARD (void) fwrite (codename, sizeof (unsigned char), strlen (codename) + 1, ofp); #endif (void) fclose (ofp); return 1; } ./libc-linux/locale/collate/koi8-r100644 1676 334 430 5542312370 15010 0ustar hjlislcodeset koi8-r order is А;а;Б;б;В;в;Г;г;Д;д;Е;е;Ё;ё;Ж;ж;З;з;И;и;Й;й;К;к;\ Л;л;М;м;Н;н;О;о;П;п;Р;р;С;с;Т;т;У;у;Ф;ф;Х;х;Ц;ц;\ Ч;ч;Ш;ш;Щ;щ;Ъ;ъ;Ы;ы;Ь;ь;Э;э;Ю;ю;Я;я;\ A;a;B;b;C;c;D;d;E;e;F;f;G;g;H;h;I;i;J;j;K;k;L;l;\ M;m;N;n;O;o;P;p;Q;q;R;r;S;s;T;t;U;u;V;v;W;w;X;x;\ Y;y;Z;z ./libc-linux/locale/collate/Makefile100644 1676 334 573 5542313146 15426 0ustar hjlislSHELL = /bin/sh CFLAGS = -O LFLAGS = -8 YFLAGS = -d OBJS = mkcollate.o parse.o lexer.o LIBS = -lfl mkcollate: ${OBJS} ${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS} lexer.o: lexer.l parse.o clean: rm -f *.output *.tab.c *.tab.h *.o core nohup.out LC_* run: mkcollate example install: mkcollate install -c -m 555 mkcollate /usr/bin install -c -m 444 mkcollate.1 /usr/man/man1 ./libc-linux/locale/collate/parse.y100644 1676 334 3570 5542327203 15311 0ustar hjlisl%{ #include #include #include "mkcollate.h" extern unsigned char *codename; %} %union { unsigned short usval; unsigned char *str; mksub_t *sub; mkorder_t *ord; }; %token CODESET %token ORDER %token RANGE %token STRING %token SUBSTITUTE %token SYMBOL %token WITH %type lit %type subst %type item items %% statements : codeset order substs ; codeset : CODESET lit { codename = $2; } ; order : ORDER items { order = $2; } ; substs : /* */ | substs subst { nsubs++; if(last_sub == NULL) { last_sub = $2; substitutions = $2; } else { last_sub->next = $2; last_sub = $2; } } ; items : item { $$ = $1; } | items ';' item { { mkorder_t *wk = $1; while(wk->next != NULL) wk = wk->next; wk->next = $3; $$ = $1; } } ; subst : SUBSTITUTE STRING WITH STRING { $$ = (mksub_t *) malloc(sizeof(mksub_t)); $$->next = NULL; $$->repl = $2; $$->with = $4; } ; item : lit { $$ = (mkorder_t *) malloc(sizeof(mkorder_t)); $$->next = NULL; $$->node_type = range; $$->low = $1; $$->top = $1; } | lit RANGE lit { $$ = (mkorder_t *) malloc(sizeof(mkorder_t)); $$->next = NULL; $$->node_type = range; $$->low = $1; $$->top = $3; } | '(' items ')' { $$ = (mkorder_t *) malloc(sizeof(mkorder_t)); $$->next = NULL; $$->node_type = secondary; $$->extra = $2; } | '{' items '}' { $$ = (mkorder_t *) malloc(sizeof(mkorder_t)); $$->next = NULL; $$->node_type = primary_only; $$->extra = $2; } ; lit : SYMBOL { $$ = (unsigned char *)malloc(128); *($$) = $1; *($$ + 1) = '\0'; } | lit SYMBOL { { unsigned char *sbp; sbp = $1 + strlen($1); *sbp++ = $2; *sbp = '\0'; $$ = $1; } } ; ./libc-linux/locale/collate/mkcollate.h100644 1676 334 707 5542325330 16107 0ustar hjlisltypedef enum { range, primary_only, secondary } order_t; typedef struct mkorder { struct mkorder *next; order_t node_type; unsigned char *low; unsigned char *top; struct mkorder *extra; } mkorder_t; extern mkorder_t *order; typedef struct mksub { struct mksub *next; unsigned char *repl; unsigned char *with; } mksub_t; extern mksub_t *substitutions; extern mksub_t *last_sub; extern int nsubs; ./libc-linux/locale/collate/lexer.l100644 1676 334 5054 5540654070 15303 0ustar hjlisl%{ #include #include "mkcollate.h" #include "y.tab.h" void yyerror(unsigned char *); int lineno = 1; unsigned char string_buf[512]; unsigned char *string_buf_ptr; %} white [ \t] %x StrinG %% ^#[^\n]*\n lineno++; \n lineno++; \\\n lineno++; \\[0-3][0-7][0-7] { int result; (void) sscanf(yytext + 1, "%o", &result); yylval.usval = result; return SYMBOL; } 0[0-3][0-7][0-7] { int result; (void) sscanf(yytext, "%o", &result); yylval.usval = result; return SYMBOL; } \\[Xx][0-9a-fA-F][0-9a-fA-F] { int result; (void) sscanf(yytext + 2, "%x", &result); yylval.usval = result; return SYMBOL; } 0[Xx][0-9a-fA-F][0-9a-fA-F] { int result; (void) sscanf(yytext + 2, "%x", &result); yylval.usval = result; return SYMBOL; } ^{white}*codeset{white}+ return CODESET; ^{white}*order{white}+is{white}+ return ORDER; ^{white}*substitute{white}+ return SUBSTITUTE; \;{white}*\.\.\.{white}*\; return RANGE; {white}+with{white}+ return WITH; \; return ';'; \( return '('; \) return ')'; \{ return '{'; \} return '}'; \" { BEGIN(StrinG); string_buf_ptr = string_buf; } \" { /* saw closing quote - all done */ BEGIN(INITIAL); *string_buf_ptr = '\0'; yylval.str = strdup(string_buf); return STRING; } \n { (void) fprintf(stderr, "Unterminated string at line %d\n", lineno); exit(1); } \\[0-7]{1,3} { int result; (void)sscanf(yytext + 1, "%o", &result); if (result > 0xff) { yyerror("Invalid octal code"); exit(1); } *string_buf_ptr++ = result; } \\[0-9]+ { yyerror("Invalid backslash escape"); exit(1); } \\[Xx][0-9a-fA-F][0-9a-fA-F] { int result; (void)sscanf(yytext + 2, "%x", &result); *string_buf_ptr++ = result; } \\[Xx].. { yyerror("Invalid backslash escape"); exit(1); } \\n *string_buf_ptr++ = '\n'; \\t *string_buf_ptr++ = '\t'; \\r *string_buf_ptr++ = '\r'; \\b *string_buf_ptr++ = '\b'; \\f *string_buf_ptr++ = '\f'; \\(.|\n) *string_buf_ptr++ = yytext[1]; [^\\\n\"]+ { unsigned char *text_ptr = yytext; while(*text_ptr) *string_buf_ptr++ = *text_ptr++; } {white}+ . { yylval.usval = (unsigned char) yytext[0]; return SYMBOL; } %% void yyerror(unsigned char *txt) { (void) fprintf(stderr, "Line %d: %s\n", lineno, txt); } ./libc-linux/locale/collate/example100644 1676 334 207 5542312422 15332 0ustar hjlislcodeset ascii order is A;a;B;b;C;c;D;d;E;e;F;f;G;g;H;h;I;i;J;j;K;k;L;l;\ M;m;N;n;O;o;P;p;Q;q;R;r;S;s;T;t;U;u;V;v;W;w;X;x;\ Y;y;Z;z ./libc-linux/locale/collate/mkcollate.1100644 1676 334 5063 5542276477 16061 0ustar hjlisl.TH MKCOLLATE 1 "15 March 1994" "Version 1.0" .SH NAME .B mkcollate \- create collate information file .SH SYNOPSIS .B mkcollate [ .B \-o .I output_file_name ] [ .I filename ] .SH DESCRIPTION .B mkcollate is used to create binary file, describing collate information for .BR setlocale (3). .I filename is the name of input file. If none given, .I stdin used. .SH OPTIONS .TP .RI \-o\ output_file_name Write the output on .IR output_file_name ; otherwise, write the output on a file named LC_COLLATE. .SH INPUT FILE FORMAT Empty lines and lines beginning with # are ignored. The backslash character, \\, is used for continuation. No characters are permitted after it. Three statements are recognized: .sp .B codeset .I codename .sp .RS .I Codename is the name of codeset. This statement is required. .RE .sp .B "order is" .I order_list .sp .RS .I order_list is a list of symbols, separated by semicolons, that defines the collating sequence. The special symbol, .BR .\|.\|. , denotes short\-hand for range of symbols. For example, .sp .nf order is a;...;z .fi .sp would specify the list of lower case letters. .sp A symbol can be represented in the following ways: .RS .TP \(bu the symbol itself, .TP \(bu in octal representation (e.g., \fB\\101\fR or .B 0101 for letter .BR A ), .TP \(bu in hexadecimal representation (e.g., \fB\\x41\fR or .B 0x41 for letter .BR A ). .RE .sp Symbols enclosed in parenthesis are assigned the same primary ordering but different secondary ordering. Symbols enclosed in curly brackets are assigned only the same primary ordering. For example, .sp .nf order is a;...;z;{1;...;9};A;...;Z .fi .sp digits 1 through 9 are assigned the same primary ordering and no secondary. .sp If character is not included in the .B "order is" statement it is excluded from the ordering. .RE .sp .B substitute .I string .B with .I repl .sp .RS This statement is optional. .RE .SH EXAMPLE .nf codeset ascii .sp order is A;a;B;b;C;c;D;d;E;e;F;f;G;g;H;h;I;i;\\ J;j;K;k;L;l;M;m;N;n;O;o;P;p;Q;q;R;r;S;s;\\ T;t;U;u;V;v;W;w;X;x;Y;y;Z;z .sp substitute "0" with "zero" .fi .SH LIMITATIONS Accepts .BR substitute.\|.\|. , check for syntax and ignore it. .SH BUGS None are know at the moment. If you find any, feel free to fix. .SH AUTHOR Nickolay Saukh - .SH ACKNOWLEDGEMENTS Input language of .B mkcollate is based on manual pages of SVR4.0. .SH FILES /usr/lib/locale/\fIlocale\fR/LC_COLLATE \- LC_COLLATE database for .I locale .SH SEE ALSO .BR setlocale (3), .BR strcoll (3), .BR strxfrm (3), .BR mkctype (1), .BR mkmonetary (1), .BR mknumeric (1), .BR mkresponse (1), .BR mktime (1) ./libc-linux/locale/ctype/ 40755 1676 334 0 5567152176 13420 5ustar hjlisl./libc-linux/locale/ctype/mkctype.h100644 1676 334 561 5540633632 15314 0ustar hjlisltypedef struct mk_pair { struct mk_pair *next; unsigned char upper; unsigned char lower; } mk_pair_t; extern mk_pair_t *blanks; extern mk_pair_t *cntrls; extern mk_pair_t *digits; extern mk_pair_t *hexs; extern mk_pair_t *lowers; extern mk_pair_t *nographs; extern mk_pair_t *puncts; extern mk_pair_t *spaces; extern mk_pair_t *uppers; extern mk_pair_t *ul_pairs; ./libc-linux/locale/ctype/mkctype.c100644 1676 334 10766 5542313364 15356 0ustar hjlisl#include #include #include #include #include #include #include #include "mkctype.h" extern int yyparse (void); mk_pair_t *blanks; mk_pair_t *cntrls; mk_pair_t *digits; mk_pair_t *hexs; mk_pair_t *lowers; mk_pair_t *nographs; mk_pair_t *puncts; mk_pair_t *spaces; mk_pair_t *uppers; mk_pair_t *ul_pairs; unsigned char *codename; unsigned char *ctab_filename = NULL; unsigned short int x2type[UCHAR_MAX + 2] = { 0 }; unsigned char x2upper[UCHAR_MAX + 2] = { '\xff' }; unsigned char x2lower[UCHAR_MAX + 2] = { '\xff' }; void plant (unsigned int pattern, mk_pair_t * node) { unsigned int i; while (node != NULL) { for (i = node->lower; i <= node->upper; i++) x2type[i + 1] |= (unsigned short) pattern; node = node->next; } } void mkxtab (mk_pair_t * node) { unsigned int i; while (node != NULL) { if (!(x2type[node->lower + 1] & _ISlower)) (void) fprintf (stderr, "warning: 0x%02x is not marked as lower (ul <0x%02x 0x%02x>)\n", node->lower, node->upper, node->lower); if (!(x2type[node->upper + 1] & _ISupper)) (void) fprintf (stderr, "warning: 0x%02x is not marked as upper (ul <0x%02x 0x%02x>)\n", node->upper, node->upper, node->lower); x2upper[node->lower + 1] = node->upper; x2lower[node->upper + 1] = node->lower; node = node->next; } } typedef struct bbits_ { unsigned short int bbits; unsigned char *bb_name; } bbits_t; bbits_t basic_bits[] = { {_ISupper, "_ISupper"}, {_ISlower, "_ISlower"}, {_IScntrl, "_IScntrl"}, {_ISdigit, "_ISdigit"}, {_ISspace, "_ISspace"}, {_IShex, "_IShex"}, {_ISpunct, "_ISpunct"}, {_NOgraph, "_NOgraph"}, {_ISblank, "_ISblank"}, {0, NULL} }; void ctab_out (void) { unsigned short int i; FILE *fout = fopen (ctab_filename, "w"); if (fout == NULL) { perror (ctab_filename); return; } fputs ("const unsigned short int __ctype_b[] = {\n", fout); fputs ("\t/* EOF */\t\t0", fout); for (i = 1; i <= UCHAR_MAX + 1; i++) { (void) fprintf (fout, ",\n\t/* 0x%02x, %d, 0%o */\t", i - 1, i - 1, i - 1); if (x2type[i]) { int dirty = 0; bbits_t *tb = basic_bits; while (tb->bbits) { if (x2type[i] & tb->bbits) { if (dirty) fputs ("|", fout); fputs (tb->bb_name, fout); dirty = 1; } tb++; } } else fputs ("0", fout); } fputs ("\n};\n", fout); fputs ("const unsigned char __ctype_tolower[] = {\n", fout); (void) fprintf (fout, "\t/* EOF */\t\t0x%02x", x2lower[0]); for (i = 1; i <= UCHAR_MAX + 1; i++) { (void) fprintf (fout, ",\n\t/* 0x%02x, %d, 0%o */\t0x%02x", i - 1, i - 1, i - 1, x2lower[i]); } fputs ("\n};\n", fout); fputs ("const unsigned char __ctype_toupper[] = {\n", fout); (void) fprintf (fout, "\t/* EOF */\t\t0x%02x", x2upper[0]); for (i = 1; i <= UCHAR_MAX + 1; i++) { (void) fprintf (fout, ",\n\t/* 0x%02x, %d, 0%o */\t0x%02x", i - 1, i - 1, i - 1, x2upper[i]); } fputs ("\n};\n", fout); (void) fclose (fout); } int main (int argc, char *argv[]) { int i; unsigned char *outname = "LC_CTYPE"; while ((i = getopt (argc, argv, "c:o:")) != EOF) { switch (i) { case 'c': ctab_filename = optarg; break; case 'o': outname = optarg; break; } } if (argc - optind > 1) { (void) fprintf (stderr, "Usage: %s [-o out_file_name] [file]\n", argv[0]); return 3; } else if ((argc - optind) == 1) { if (freopen (argv[optind], "r", stdin) == NULL) { perror (argv[optind]); return 2; } } if (yyparse ()) return 1; for (i = 0; i <= UCHAR_MAX; i++) { x2upper[i + 1] = x2lower[i + 1] = i; x2type[i + 1] = 0; } plant (_ISblank, blanks); plant (_IScntrl, cntrls); plant (_ISdigit, digits); plant (_IShex, hexs); plant (_ISlower, lowers); plant (_ISpunct, puncts); plant (_ISspace, spaces); plant (_ISupper, uppers); plant (_NOgraph, nographs); mkxtab (ul_pairs); if (ctab_filename) ctab_out (); return !write_out (outname); } int write_out (outname) unsigned char *outname; { FILE *ofp = fopen (outname, "w"); if (ofp == NULL) return 0; (void) fwrite (x2type, sizeof (x2type), 1, ofp); (void) fwrite (x2lower, sizeof (x2lower), 1, ofp); (void) fwrite (x2upper, sizeof (x2upper), 1, ofp); #ifndef NOGUARD (void) fwrite (codename, sizeof (unsigned char), strlen (codename) + 1, ofp); #endif (void) fclose (ofp); return 1; } ./libc-linux/locale/ctype/Makefile100644 1676 334 557 5542313171 15127 0ustar hjlislSHELL = /bin/sh CFLAGS = -O LFLAGS = -8 YFLAGS = -d OBJS = mkctype.o parse.o lexer.o LIBS = -lfl mkctype: ${OBJS} ${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS} lexer.o: lexer.l parse.o clean: rm -f *.output *.tab.c *.tab.h *.o core nohup.out LC_* run: mkctype example install: mkctype install -c -m 555 mkctype /usr/bin install -c -m 444 mkctype.1 /usr/man/man1 ./libc-linux/locale/ctype/lexer.l100644 1676 334 2315 5540654230 14777 0ustar hjlisl%{ #include #include "mkctype.h" #include "y.tab.h" int lineno = 1; %} white [ \t] xcode 0[Xx][0-9a-fA-F][0-9a-fA-F] ocode 0[0-3][0-7][0-7] %% ^#[^\n]*\n lineno++; \n lineno++; \\\n lineno++; {ocode} { int result; (void) sscanf(yytext, "%o", &result); yylval.ucode = result; return CODE; } {xcode} { int result; (void)sscanf(yytext + 2, "%x", &result); yylval.ucode = result; return CODE; } ^{white}*codeset{white}+ { return CODESET; } \< return '<'; \> return '>'; \- return '-'; ^{white}*isblank{white}+ return ISBLANK; ^{white}*iscntrl{white}+ return ISCNTRL; ^{white}*isdigit{white}+ return ISDIGIT; ^{white}*islower{white}+ return ISLOWER; ^{white}*isnograph{white}+ return ISNOGRAPH; ^{white}*ispunct{white}+ return ISPUNCT; ^{white}*isspace{white}+ return ISSPACE; ^{white}*isupper{white}+ return ISUPPER; ^{white}*isxdigit{white}+ return ISXDIGIT; ^{white}*ul{white}+ return UL; [a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9] { yylval.str = strdup(yytext); return CODENAME; } . /* Ignore anything else */ %% void yyerror(char *txt) { (void) fprintf(stderr, "Line %d: %s\n", lineno, txt); } ./libc-linux/locale/ctype/example100644 1676 334 2214 5540643361 15062 0ustar hjlislcodeset koi8-r # Lower half of table: ASCII iscntrl 0x00-0x1f 0x7f isspace 0x09-0x0d 0x20 isblank 0x09 0x20 isnograph 0x20 ispunct 0x21-0x2f 0x3a-0x40 0x5b-0x60 0x7b-0x7e isdigit 0x30-0x39 isxdigit 0x30-0x39 0x41-0x46 0x61-0x66 isupper 0x41-0x5a islower 0x61-0x7a ul <0x41 0x61> <0x42 0x62> <0x43 0x63> <0x44 0x64> \ <0x45 0x65> <0x46 0x66> <0x47 0x67> <0x48 0x68> \ <0x49 0x69> <0x4a 0x6a> <0x4b 0x6b> <0x4c 0x6c> \ <0x4d 0x6d> <0x4e 0x6e> <0x4f 0x6f> <0x50 0x70> \ <0x51 0x71> <0x52 0x72> <0x53 0x73> <0x54 0x74> \ <0x55 0x75> <0x56 0x76> <0x57 0x77> <0x58 0x78> \ <0x59 0x79> <0x5a 0x7a> # Upper half of table: KOI8-R ispunct 0x80-0xa2 0xa4-0xb2 0xb4-0xbf isupper 0xb3 0xe0-0xff islower 0xa3 0xc0-0xdf ul <0xe0 0xc0> <0xe1 0xc1> <0xe2 0xc2> <0xe3 0xc3> \ <0xe4 0xc4> <0xe5 0xc5> <0xe6 0xc6> <0xe7 0xc7> \ <0xe8 0xc8> <0xe9 0xc9> <0xea 0xca> <0xeb 0xcb> \ <0xec 0xcc> <0xed 0xcd> <0xee 0xce> <0xef 0xcf> \ <0xf0 0xd0> <0xf1 0xd1> <0xf2 0xd2> <0xf3 0xd3> \ <0xf4 0xd4> <0xf5 0xd5> <0xf6 0xd6> <0xf7 0xd7> \ <0xf8 0xd8> <0xf9 0xd9> <0xfa 0xda> <0xfb 0xdb> \ <0xfc 0xdc> <0xfd 0xdd> <0xfe 0xde> <0xff 0xdf> \ <0xb3 0xa3> ./libc-linux/locale/ctype/parse.y100644 1676 334 4446 5540637433 15024 0ustar hjlisl%{ #include #include #include "mkctype.h" extern unsigned char *codename; void add_chain(mk_pair_t **ptr, mk_pair_t *new_ent) { mk_pair_t *node = new_ent; if(*ptr == NULL) { *ptr = new_ent; return; } while(node->next != NULL) node = node->next; node->next = *ptr; *ptr = new_ent; } %} %union { unsigned char ucode; unsigned char *str; mk_pair_t *cpair; }; %token CODESET %token CODENAME %token ISBLANK %token ISCNTRL %token ISDIGIT %token ISLOWER %token ISNOGRAPH %token ISPUNCT %token ISSPACE %token ISUPPER %token ISXDIGIT %token CODE %token UL %type code codes pair pairs %% statements : codeset descriptions ; descriptions : classes | descriptions classes | conv | descriptions conv ; codeset : CODESET CODENAME { codename = $2; } ; classes : ISUPPER codes { add_chain(&uppers, $2); } | ISLOWER codes { add_chain(&lowers, $2); } | ISDIGIT codes { add_chain(&digits, $2); } | ISSPACE codes { add_chain(&spaces, $2); } | ISPUNCT codes { add_chain(&puncts, $2); } | ISCNTRL codes { add_chain(&cntrls, $2); } | ISBLANK codes { add_chain(&blanks, $2); } | ISXDIGIT codes { add_chain(&hexs, $2); } | ISNOGRAPH codes { add_chain(&nographs, $2); } ; conv : UL pairs { add_chain(&ul_pairs, $2); } ; codes : code { $$ = $1; } | codes code { $2->next = $1; $$ = $2; } ; code : CODE { $$ = (mk_pair_t *) malloc(sizeof(mk_pair_t)); ($$)->next = NULL; ($$)->lower = $1; ($$)->upper = $1; } | CODE '-' CODE { if($1 > $3) { char buffer[128]; (void) sprintf(buffer, "invalid code range (0x%02x-0x%02x)", $1, $3); yyerror(buffer); YYERROR; } $$ = (mk_pair_t *) malloc(sizeof(mk_pair_t)); ($$)->next = NULL; ($$)->lower = $1; ($$)->upper = $3; } ; pairs : pair { $$ = $1; } | pairs pair { $2->next = $1; $$ = $2; } ; pair : '<' CODE CODE '>' { if($2 == $3) { char buffer[128]; (void) sprintf(buffer, "same code (0x%02x) for upper and lower letter", $2); yyerror(buffer); YYERROR; } $$ = (mk_pair_t *) malloc(sizeof(mk_pair_t)); $$->next = NULL; $$->lower = $3; $$->upper = $2; } ; ./libc-linux/locale/ctype/mkctype.1100644 1676 334 6716 5542304563 15255 0ustar hjlisl.TH MKCTYPE 1 "15 March 1994" "Version 1.0" .SH NAME .B mkctype \- create character classification file .SH SYNOPSIS .B mkctype [ .B \-o .I output_file_name ] [ .B \-c .I ctype_file ] [ .I filename ] .SH DESCRIPTION .B mkctype is used to create binary file, describing character classification for .BR setlocale (3). .I filename is the name of input file. If none given, .I stdin used. .SH OPTIONS .TP .RI \-o\ output_file_name Write the output on .IR output_file_name ; otherwise, write the output on a file named LC_CTYPE. .TP .RI \-c\ ctype_file Write .B C language source of the tables on .IR ctype_file . .SH INPUT FILE FORMAT Empty lines and lines beginning with # are ignored. The backslash character, \\, is used for continuation. No characters are permitted after it. The following statements are recognized: .sp .B codeset .I codename .sp .RS .I Codename is the name of codeset. This statement is required. .RE .sp .B iscntrl .I character_codes .br .B isspace .I character_codes .br .B isblank .I character_codes .br .B isnograph .I character_codes .br .B ispunct .I character_codes .br .B isdigit .I character_codes .br .B isxdigit .I character_codes .br .B isupper .I character_codes .br .B islower .I character_codes .sp .RS .I Character_codes for .BR iscntrl , .BR isspace , .BR isblank , .BR isnograph , .BR ispunct , .BR isdigit , .BR isxdigit , .BR isupper , .B islower shell be represented as list of the hexadecimal or octal constants separated by white space. For example, letter .B A can be represented as .B 0101 or .BR 0x41 . .sp The dash character (\-) with optional white space around it may be used to indicate a range of codes. .RE .sp .B ul .I code_pairs .sp .RS The relationship between upper and lower case letters is expressed as list of pairs of octal or hexadecimal constants: .sp .nf <\fIupper\-case lower\-case\fR> .fi .sp .RE .SH EXAMPLE .nf codeset koi8-r # Lower half of table: ASCII iscntrl 0x00-0x1f 0x7f isspace 0x09-0x0d 0x20 isblank 0x09 0x20 isnograph 0x20 ispunct 0x21-0x2f 0x3a-0x40 0x5b-0x60 0x7b-0x7e isdigit 0x30-0x39 isxdigit 0x30-0x39 0x41-0x46 0x61-0x66 isupper 0x41-0x5a islower 0x61-0x7a ul <0x41 0x61> <0x42 0x62> <0x43 0x63> <0x44 0x64> \\ <0x45 0x65> <0x46 0x66> <0x47 0x67> <0x48 0x68> \\ <0x49 0x69> <0x4a 0x6a> <0x4b 0x6b> <0x4c 0x6c> \\ <0x4d 0x6d> <0x4e 0x6e> <0x4f 0x6f> <0x50 0x70> \\ <0x51 0x71> <0x52 0x72> <0x53 0x73> <0x54 0x74> \\ <0x55 0x75> <0x56 0x76> <0x57 0x77> <0x58 0x78> \\ <0x59 0x79> <0x5a 0x7a> # Upper half of table: KOI8-R ispunct 0x80-0xa2 0xa4-0xb2 0xb4-0xbf isupper 0xb3 0xe0-0xff islower 0xa3 0xc0-0xdf ul <0xe0 0xc0> <0xe1 0xc1> <0xe2 0xc2> <0xe3 0xc3> \\ <0xe4 0xc4> <0xe5 0xc5> <0xe6 0xc6> <0xe7 0xc7> \\ <0xe8 0xc8> <0xe9 0xc9> <0xea 0xca> <0xeb 0xcb> \\ <0xec 0xcc> <0xed 0xcd> <0xee 0xce> <0xef 0xcf> \\ <0xf0 0xd0> <0xf1 0xd1> <0xf2 0xd2> <0xf3 0xd3> \\ <0xf4 0xd4> <0xf5 0xd5> <0xf6 0xd6> <0xf7 0xd7> \\ <0xf8 0xd8> <0xf9 0xd9> <0xfa 0xda> <0xfb 0xdb> \\ <0xfc 0xdc> <0xfd 0xdd> <0xfe 0xde> <0xff 0xdf> \\ <0xb3 0xa3> .fi .SH LIMITATIONS No support for multibytes. .SH BUGS None are know at the moment. If you find any, feel free to fix. .SH AUTHOR Nickolay Saukh - .SH ACKNOWLEDGEMENTS Input language of .B mkctype is based on manual pages of SVR4.0. .SH FILES /usr/lib/locale/\fIlocale\fR/LC_CTYPE \- LC_CTYPE database for .I locale .SH SEE ALSO .BR setlocale (3), .BR ctype (3), .BR mkcollate (1), .BR mkmonetary (1), .BR mknumeric (1), .BR mkresponse (1), .BR mktime (1) ./libc-linux/locale/monetary/ 40755 1676 334 0 5567152177 14133 5ustar hjlisl./libc-linux/locale/monetary/Makefile100644 1676 334 601 5542313213 15624 0ustar hjlislSHELL = /bin/sh CFLAGS = -O LFLAGS = -8 YFLAGS = -d OBJS = mkmonetary.o parse.o lexer.o LIBS = -lfl mkmonetary: ${OBJS} ${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS} lexer.o: lexer.l parse.o clean: rm -f *.output *.tab.c *.tab.h *.o core nohup.out LC_* run: mkmonetary example install: mkmonetary install -c -m 555 mkmonetary /usr/bin install -c -m 444 mkmonetary.1 /usr/man/man1 ./libc-linux/locale/monetary/lexer.l100644 1676 334 5107 5540653074 15520 0ustar hjlisl%{ #include #include "mkmonetary.h" #include "y.tab.h" void yyerror(char *); int lineno = 1; %} white [ \t] %x String %% unsigned char string_buf[512]; unsigned char *string_buf_ptr; ^#[^\n]*\n lineno++; \n lineno++; \\\n lineno++; ^{white}*codeset{white}+ return CODESET; ^{white}*currency_symbol{white}+ return CURRENCY_SYMBOL; ^{white}*frac_digits{white}+ return FRAC_DIGITS; ^{white}*int_curr_symbol{white}+ return INT_CURR_SYMBOL; ^{white}*int_frac_digits{white}+ return INT_FRAC_DIGITS; ^{white}*mon_decimal_point{white}+ return MON_DECIMAL_POINT; ^{white}*mon_grouping{white}+ return MON_GROUPING; ^{white}*mon_thousands_sep{white}+ return MON_THOUSANDS_SEP; ^{white}*n_cs_precedes{white}+ return N_CS_PRECEDES; ^{white}*n_sep_by_space{white}+ return N_SEP_BY_SPACE; ^{white}*n_sign_posn{white}+ return N_SIGN_POSN; ^{white}*negative_sign{white}+ return NEGATIVE_SIGN; ^{white}*p_cs_precedes{white}+ return P_CS_PRECEDES; ^{white}*p_sep_by_space{white}+ return P_SEP_BY_SPACE; ^{white}*p_sign_posn{white}+ return P_SIGN_POSN; ^{white}*positive_sign{white}+ return POSITIVE_SIGN; [0-9]+ { yylval.number = atoi(yytext); return NUMBER; } [a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9] { yylval.str = strdup(yytext); return CODENAME; } \" { BEGIN(String); string_buf_ptr = string_buf; } \" { /* saw closing quote - all done */ BEGIN(INITIAL); *string_buf_ptr = '\0'; yylval.str = strdup(string_buf); return STRING; } \n { yyerror("Unterminated string"); exit(1); } \\[0-7]{1,3} { int result; (void)sscanf(yytext + 1, "%o", &result); if (result > 0xff) { yyerror("Invalid octal code"); exit(1); } *string_buf_ptr++ = result; } \\[0-9]+ { yyerror("Invalid backslash escape"); exit(1); } \\[Xx][0-9a-fA-F][0-9a-fA-F] { int result; (void)sscanf(yytext + 2, "%x", &result); *string_buf_ptr++ = result; } \\[Xx].. { yyerror("Invalid backslash escape"); exit(1); } \\n *string_buf_ptr++ = '\n'; \\t *string_buf_ptr++ = '\t'; \\r *string_buf_ptr++ = '\r'; \\b *string_buf_ptr++ = '\b'; \\f *string_buf_ptr++ = '\f'; \\(.|\n) *string_buf_ptr++ = yytext[1]; [^\\\n\"]+ { unsigned char *text_ptr = yytext; while(*text_ptr) *string_buf_ptr++ = *text_ptr++; } . %% void yyerror(char *txt) { (void) fprintf(stderr, "Line %d: %s\n", lineno, txt); } ./libc-linux/locale/monetary/example100644 1676 334 460 5542306524 15554 0ustar hjlislcodeset fictional int_curr_symbol "rbl." currency_symbol "\xd2\xd5\xc2" mon_decimal_point "" mon_thousands_sep "" mon_grouping "" positive_sign "" negative_sign "" int_frac_digits 2 frac_digits 2 p_cs_precedes 0 p_sep_by_space 0 n_cs_precedes 0 n_sep_by_space 0 p_sign_posn 0 n_sign_posn 0 ./libc-linux/locale/monetary/mkmonetary.c100644 1676 334 4336 5542313405 16552 0ustar hjlisl#include #include #include #include #include #include #include #include "mkmonetary.h" extern int yyparse (void); unsigned char *codename; struct monetary_info minfo = { "", /* char *int_curr_symbol */ "", /* char *currency_symbol */ "", /* char *mon_decimal_point */ "", /* char *mon_thousands_sep */ "", /* char *mon_grouping */ "", /* char *positive_sign */ "", /* char *negative_sign */ CHAR_MAX, /* char int_frac_digits */ CHAR_MAX, /* char frac_digits */ CHAR_MAX, /* char p_cs_precedes */ CHAR_MAX, /* char p_sep_by_space */ CHAR_MAX, /* char n_cs_precedes */ CHAR_MAX, /* char n_sep_by_space */ CHAR_MAX, /* char p_sign_posn */ CHAR_MAX /* char n_sign_posn */ }; int main (int argc, char *argv[]) { int i; unsigned char *outname = "LC_MONETARY"; while ((i = getopt (argc, argv, "o:")) != EOF) { switch (i) { case 'o': outname = optarg; break; } } if (argc - optind > 1) { (void) fprintf (stderr, "Usage: %s [-o out_file_name] [file]\n", argv[0]); return 3; } else if ((argc - optind) == 1) { if (freopen (argv[optind], "r", stdin) == NULL) { perror (argv[optind]); return 2; } } if (yyparse ()) return 1; return !write_out (outname); } void write_str (char *str, FILE * ofp) { short int slen = strlen (str) + 1; (void) fwrite (&slen, sizeof (slen), 1, ofp); (void) fwrite (str, sizeof (char), slen, ofp); } int write_out (outname) unsigned char *outname; { FILE *ofp = fopen (outname, "w"); if (ofp == NULL) return 0; write_str (minfo.int_curr_symbol, ofp); write_str (minfo.currency_symbol, ofp); write_str (minfo.mon_decimal_point, ofp); write_str (minfo.mon_thousands_sep, ofp); write_str (minfo.mon_grouping, ofp); write_str (minfo.positive_sign, ofp); write_str (minfo.negative_sign, ofp); (void) fwrite (&minfo.int_frac_digits, sizeof (unsigned char), ((&minfo.n_sign_posn) - (&minfo.int_frac_digits)) + sizeof (minfo.n_sign_posn), ofp); #ifndef NOGUARD (void) fwrite (codename, sizeof (unsigned char), strlen (codename) + 1, ofp); #endif (void) fclose (ofp); return 1; } ./libc-linux/locale/monetary/mkmonetary.h100644 1676 334 43 5540410371 16504 0ustar hjlislextern struct monetary_info minfo; ./libc-linux/locale/monetary/parse.y100644 1676 334 5070 5540415250 15517 0ustar hjlisl%{ #include #include #include #include #include "mkmonetary.h" extern unsigned char *codename; %} %union { int number; unsigned char *str; }; %token CODESET %token CODENAME %token STRING %token NUMBER %token CURRENCY_SYMBOL %token FRAC_DIGITS %token INT_CURR_SYMBOL %token INT_FRAC_DIGITS %token MON_DECIMAL_POINT %token MON_GROUPING %token MON_THOUSANDS_SEP %token NEGATIVE_SIGN %token N_CS_PRECEDES %token N_SEP_BY_SPACE %token N_SIGN_POSN %token POSITIVE_SIGN %token P_CS_PRECEDES %token P_SEP_BY_SPACE %token P_SIGN_POSN %% statements : codeset descriptions ; descriptions : desc | descriptions desc ; codeset : CODESET CODENAME { codename = $2; } ; desc : INT_CURR_SYMBOL STRING { if(strlen($2) != 4) { yyerror("length of int_curr_symbol != 4"); YYERROR; } minfo.int_curr_symbol = $2; } | CURRENCY_SYMBOL STRING { minfo.currency_symbol = $2; } | MON_DECIMAL_POINT STRING { minfo.mon_decimal_point = $2; } | MON_THOUSANDS_SEP STRING { minfo.mon_thousands_sep = $2; } | MON_GROUPING STRING { minfo.mon_grouping = $2; } | POSITIVE_SIGN STRING { minfo.positive_sign = $2; } | NEGATIVE_SIGN STRING { minfo.negative_sign = $2; } | INT_FRAC_DIGITS NUMBER { if($2 < 0 || $2 > CHAR_MAX) { yyerror("int_frac_digits out of bounds"); YYERROR; } minfo.int_frac_digits = $2; } | FRAC_DIGITS NUMBER { if($2 < 0 || $2 > CHAR_MAX) { yyerror("frac_digits out of bounds"); YYERROR; } minfo.frac_digits = $2; } | P_CS_PRECEDES NUMBER { if($2 < 0 || $2 > 1) { yyerror("invalid p_cs_precedes (0 or 1 only)"); YYERROR; } minfo.p_cs_precedes = $2; } | P_SEP_BY_SPACE NUMBER { if($2 < 0 || $2 > 1) { yyerror("invalid p_sep_by_space (0 or 1 only)"); YYERROR; } minfo.p_sep_by_space = $2; } | N_CS_PRECEDES NUMBER { if($2 < 0 || $2 > 1) { yyerror("invalid n_cs_precedes (0 or 1 only)"); YYERROR; } minfo.n_cs_precedes = $2; } | N_SEP_BY_SPACE NUMBER { if($2 < 0 || $2 > 1) { yyerror("invalid n_sep_by_space (0 or 1 only)"); YYERROR; } minfo.n_sep_by_space = $2; } | P_SIGN_POSN NUMBER { if($2 < 0 || $2 > 4) { yyerror("invalid p_sign_posn (0..4 only)"); YYERROR; } minfo.p_sign_posn = $2; } | N_SIGN_POSN NUMBER { if($2 < 0 || $2 > 4) { yyerror("invalid n_sign_posn (0..4 only)"); YYERROR; } minfo.n_sign_posn = $2; } ; ./libc-linux/locale/monetary/mkmonetary.1100644 1676 334 3201 5542307137 16463 0ustar hjlisl.TH MKMONETARY 1 "15 March 1994" "Version 1.0" .SH NAME .B mkmonetary \- create monetary information file .SH SYNOPSIS .B mkmonetary [ .B \-o .I output_file_name ] [ .I filename ] .SH DESCRIPTION .B mkmonetary is used to create binary file, describing monetary information for .BR setlocale (3). .I filename is the name of input file. If none given, .I stdin used. .SH OPTIONS .TP .RI \-o\ output_file_name Write the output on .IR output_file_name ; otherwise, write the output on a file named LC_MONETARY. .SH INPUT FILE FORMAT Empty lines and lines beginning with # are ignored. The backslash character, \\, is used for continuation. No characters are permitted after it. The following statements are recognized: .sp .B codeset .I codename .sp .RS .I Codename is the name of codeset. This statement is required. .RE .sp The rest of statements is just the field names of structure .IR monetary_info . .SH EXAMPLE .nf codeset dummy int_curr_symbol "rbl." currency_symbol "\\xd2\\xd5\\xc2" mon_decimal_point "" mon_thousands_sep "" mon_grouping "" positive_sign "" negative_sign "" int_frac_digits 2 frac_digits 2 p_cs_precedes 0 p_sep_by_space 0 n_cs_precedes 0 n_sep_by_space 0 p_sign_posn 0 n_sign_posn 0 .fi .SH BUGS None are know at the moment. If you find any, feel free to fix. .SH AUTHOR Nickolay Saukh - .SH ACKNOWLEDGEMENTS Input language of .B mkmonetary is based on manual pages of SVR4.0. .SH FILES /usr/lib/locale/\fIlocale\fR/LC_MONETARY \- LC_MONETARY database for .I locale .SH SEE ALSO .BR setlocale (3), .BR localeconv (3), .BR mkcollate (1), .BR mkctype (1), .BR mknumeric (1), .BR mkresponse (1), .BR mktime (1) ./libc-linux/locale/numeric/ 40755 1676 334 0 5567152200 13722 5ustar hjlisl./libc-linux/locale/numeric/Makefile100644 1676 334 573 5542313233 15442 0ustar hjlislSHELL = /bin/sh CFLAGS = -O LFLAGS = -8 YFLAGS = -d OBJS = mknumeric.o parse.o lexer.o LIBS = -lfl mknumeric: ${OBJS} ${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS} lexer.o: lexer.l parse.o clean: rm -f *.output *.tab.c *.tab.h *.o core nohup.out LC_* run: mknumeric example install: mknumeric install -c -m 555 mknumeric /usr/bin install -c -m 444 mknumeric.1 /usr/man/man1 ./libc-linux/locale/numeric/lexer.l100644 1676 334 3514 5540654543 15326 0ustar hjlisl%{ #include #include "mknumeric.h" #include "y.tab.h" void yyerror(char *); int lineno = 1; %} white [ \t] %x String %% unsigned char string_buf[512]; unsigned char *string_buf_ptr; ^#[^\n]*\n lineno++; \n lineno++; \\\n lineno++; ^{white}*codeset{white}+ return CODESET; ^{white}*decimal_point{white}+ return DECIMAL_POINT; ^{white}*thousands_sep{white}+ return THOUSANDS_SEP; ^{white}*grouping{white}+ return GROUPING; [a-zA-Z][a-zA-Z0-9_-]*[a-zA-Z0-9] { yylval.str = strdup(yytext); return CODENAME; } \" { BEGIN(String); string_buf_ptr = string_buf; } \" { /* saw closing quote - all done */ BEGIN(INITIAL); *string_buf_ptr = '\0'; yylval.str = strdup(string_buf); return STRING; } \n { yyerror("Unterminated string"); exit(1); } \\[0-7]{1,3} { int result; (void)sscanf(yytext + 1, "%o", &result); if (result > 0xff) { yyerror("Invalid octal code"); exit(1); } *string_buf_ptr++ = result; } \\[0-9]+ { yyerror("Invalid backslash escape"); exit(1); } \\[Xx][0-9a-fA-F][0-9a-fA-F] { int result; (void)sscanf(yytext + 2, "%x", &result); *string_buf_ptr++ = result; } \\[Xx].. { yyerror("Invalid backslash escape"); exit(1); } \\n *string_buf_ptr++ = '\n'; \\t *string_buf_ptr++ = '\t'; \\r *string_buf_ptr++ = '\r'; \\b *string_buf_ptr++ = '\b'; \\f *string_buf_ptr++ = '\f'; \\(.|\n) *string_buf_ptr++ = yytext[1]; [^\\\n\"]+ { unsigned char *text_ptr = yytext; while(*text_ptr) *string_buf_ptr++ = *text_ptr++; } . %% void yyerror(char *txt) { (void) fprintf(stderr, "Line %d: %s\n", lineno, txt); } ./libc-linux/locale/numeric/mknumeric.c100644 1676 334 2702 5542313416 16157 0ustar hjlisl#include #include #include #include #include #include #include #include "mknumeric.h" extern int yyparse (void); unsigned char *codename; struct numeric_info ninfo = { "", /* char *decimal_point */ "", /* char *thousands_sep */ "" /* char *grouping */ }; int main (int argc, char *argv[]) { int i; unsigned char *outname = "LC_NUMERIC"; while ((i = getopt (argc, argv, "o:")) != EOF) { switch (i) { case 'o': outname = optarg; break; } } if (argc - optind > 1) { (void) fprintf (stderr, "Usage: %s [-o out_file_name] [file]\n", argv[0]); return 3; } else if ((argc - optind) == 1) { if (freopen (argv[optind], "r", stdin) == NULL) { perror (argv[optind]); return 2; } } if (yyparse ()) return 1; return !write_out (outname); } void write_str (char *str, FILE * ofp) { short int slen = strlen (str) + 1; (void) fwrite (&slen, sizeof (slen), 1, ofp); (void) fwrite (str, sizeof (char), slen, ofp); } int write_out (outname) unsigned char *outname; { FILE *ofp = fopen (outname, "w"); if (ofp == NULL) return 0; write_str (ninfo.decimal_point, ofp); write_str (ninfo.thousands_sep, ofp); write_str (ninfo.grouping, ofp); #ifndef NOGUARD (void) fwrite (codename, sizeof (unsigned char), strlen (codename) + 1, ofp); #endif (void) fclose (ofp); return 1; } ./libc-linux/locale/numeric/mknumeric.h100644 1676 334 42 5540435526 16124 0ustar hjlislextern struct numeric_info ninfo; ./libc-linux/locale/numeric/parse.y100644 1676 334 1350 5540436327 15330 0ustar hjlisl%{ #include #include #include #include #include "mknumeric.h" extern unsigned char *codename; %} %union { int number; unsigned char *str; }; %token CODESET %token CODENAME %token STRING %token DECIMAL_POINT %token GROUPING %token THOUSANDS_SEP %% statements : codeset descriptions ; descriptions : desc | descriptions desc ; codeset : CODESET CODENAME { codename = $2; } ; desc : DECIMAL_POINT STRING { if(strlen($2) == 0) { yyerror("zero length decimal_point"); YYERROR; } ninfo.decimal_point = $2; } | THOUSANDS_SEP STRING { ninfo.thousands_sep = $2; } | GROUPING STRING { ninfo.grouping = $2; } ; ./libc-linux/locale/numeric/example100644 1676 334 102 5540655771 15362 0ustar hjlislcodeset koi8-r decimal_point "." thousands_sep "" grouping "" ./libc-linux/locale/numeric/mknumeric.1100644 1676 334 2647 5542310243 16100 0ustar hjlisl.TH MKNUMERIC 1 "15 March 1994" "Version 1.0" .SH NAME .B mknumeric \- create numeric information file .SH SYNOPSIS .B mknumeric [ .B \-o .I output_file_name ] [ .I filename ] .SH DESCRIPTION .B mknumeric is used to create binary file, describing numeric information for .BR setlocale (3). .I filename is the name of input file. If none given, .I stdin used. .SH OPTIONS .TP .RI \-o\ output_file_name Write the output on .IR output_file_name ; otherwise, write the output on a file named LC_NUMERIC. .SH INPUT FILE FORMAT Empty lines and lines beginning with # are ignored. The backslash character, \\, is used for continuation. No characters are permitted after it. The following statements are recognized: .sp .B codeset .I codename .sp .RS .I Codename is the name of codeset. This statement is required. .RE .sp The rest of statements is just the field names of structure .IR numeric_info . .SH EXAMPLE .nf codeset dummy decimal_point "." thousands_sep "" grouping "" .fi .SH BUGS None are know at the moment. If you find any, feel free to fix. .SH AUTHOR Nickolay Saukh - .SH ACKNOWLEDGEMENTS Input language of .B mknumeric is based on manual pages of SVR4.0. .SH FILES /usr/lib/locale/\fIlocale\fR/LC_NUMERIC \- LC_NUMERIC database for .br /usr/include/localeinfo.h .I locale .SH SEE ALSO .BR setlocale (3), .BR localeconv (3), .BR mkcollate (1), .BR mkctype (1), .BR mkmonetary (1), .BR mkresponse (1), .BR mktime (1) ./libc-linux/locale/response/ 40755 1676 334 0 5567152200 14116 5ustar hjlisl./libc-linux/locale/response/Makefile100644 1676 334 462 5542313307 15635 0ustar hjlislSHELL = /bin/sh CFLAGS = -O OBJS = mkresponse.o mkresponse: ${OBJS} ${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS} clean: rm -f *.output *.tab.c *.tab.h *.o core nohup.out LC_* run: mkresponse example install: mkresponse install -c -m 555 mkresponse /usr/bin install -c -m 444 mkresponse.1 /usr/man/man1 ./libc-linux/locale/response/mkresponse.c100644 1676 334 4610 5542313436 16551 0ustar hjlisl#include #include #include #include #include #include #include unsigned char *codename; struct response_info rinfo; unsigned char **lines[] = { (unsigned char **) &rinfo.yesexpr, (unsigned char **) &rinfo.noexpr, NULL }; int parse (void); int main (int argc, char *argv[]) { int i; unsigned char *outname = "LC_RESPONSE"; while ((i = getopt (argc, argv, "o:")) != EOF) { switch (i) { case 'o': outname = optarg; break; } } if (argc - optind > 1) { (void) fprintf (stderr, "Usage: %s [-o out_file_name] [file]\n", argv[0]); return 3; } else if ((argc - optind) == 1) { if (freopen (argv[optind], "r", stdin) == NULL) { perror (argv[optind]); return 2; } } if (!parse ()) return 1; return !write_out (outname); } void write_str (char *str, FILE * ofp) { short int slen = strlen (str) + 1; (void) fwrite (&slen, sizeof (slen), 1, ofp); (void) fwrite (str, sizeof (char), slen, ofp); } int write_out (outname) unsigned char *outname; { FILE *ofp = fopen (outname, "w"); if (ofp == NULL) return 0; write_str (rinfo.yesexpr, ofp); write_str (rinfo.noexpr, ofp); #ifndef NOGUARD (void) fwrite (codename, sizeof (unsigned char), strlen (codename) + 1, ofp); #endif (void) fclose (ofp); return 1; } unsigned char iline[1024]; int parse () { int codename_seen = 0; int lineno = 0; unsigned char ***target = lines; unsigned char *cp; while (fgets (iline, sizeof (iline), stdin) != NULL) { lineno++; if (iline[0] == '#') continue; if ((cp = strchr (iline, '\n')) == NULL) { (void) fprintf (stderr, "Line %d: buffer overflow\n", lineno); return 0; } *cp = '\0'; if (strlen (iline) == 0) continue; if (!codename_seen) { if (grok_codename ()) { codename_seen = 1; continue; } else return 0; } **target++ = strdup (iline); if (*target == NULL) return 1; } return 0; } int grok_codename () { unsigned char *cp = iline; while (*cp && *cp == ' ' && *cp == '\t') cp++; if (*cp == '\0') return 0; if (strncmp (cp, "codeset ", 8) && strncmp (cp, "codeset\t", 8)) return 0; cp += 8; while (*cp && *cp == ' ' && *cp == '\t') cp++; if (*cp == '\0') return 0; codename = strdup (cp); return 1; } ./libc-linux/locale/response/example100644 1676 334 27 5540656273 15542 0ustar hjlislcodeset koi8-r yes no ./libc-linux/locale/response/mkresponse.1100644 1676 334 2545 5542310665 16475 0ustar hjlisl.TH MKRESPONSE 1 "15 March 1994" "Version 1.0" .SH NAME .B mkresponse \- create response information file .SH SYNOPSIS .B mkresponse [ .B \-o .I output_file_name ] [ .I filename ] .SH DESCRIPTION .B mkresponse is used to create binary file, describing response information for .BR setlocale (3) and .BR localeinfo (3). .I filename is the name of input file. If none given, .I stdin used. .SH OPTIONS .TP .RI \-o\ output_file_name Write the output on .IR output_file_name ; otherwise, write the output on a file named LC_RESPONSE. .SH INPUT FILE FORMAT Empty lines and lines beginning with # are ignored. The backslash character, \\, is used for continuation. No characters are permitted after it. The following statements are recognized: .sp .B codeset .I codename .sp .RS .I Codename is the name of codeset. This statement is required. .RE .sp Next not ignored line taken as affirmative answer string. Next not ignored line taken as negative answer string. .SH EXAMPLE .nf codeset dummy yes no .fi .SH BUGS None are know at the moment. If you find any, feel free to fix. .SH AUTHOR Nickolay Saukh - .SH FILES /usr/lib/locale/\fIlocale\fR/LC_RESPONSE \- LC_RESPONSE database for .br /usr/include/localeinfo.h .I locale .SH SEE ALSO .BR setlocale (3), .BR localeconv (3), .BR mkcollate (1), .BR mkctype (1), .BR mkmonetary (1), .BR mknumeric (1), .BR mktime (1) ./libc-linux/locale/time/ 40755 1676 334 0 5567152201 13217 5ustar hjlisl./libc-linux/locale/time/Makefile100644 1676 334 432 5542313104 14725 0ustar hjlislSHELL = /bin/sh CFLAGS = -O OBJS = mktime.o mktime: ${OBJS} ${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS} clean: rm -f *.output *.tab.c *.tab.h *.o core nohup.out LC_* run: mktime example install: mktime install -c -m 555 mktime /usr/bin install -c -m 444 mktime.1 /usr/man/man1 ./libc-linux/locale/time/mktime.c100644 1676 334 10360 5542313451 14765 0ustar hjlisl#include #include #include #include #include #include #include unsigned char *codename; struct time_info tinfo; unsigned char **lines[] = { (unsigned char **) &tinfo.abbrev_wkday[0], (unsigned char **) &tinfo.abbrev_wkday[1], (unsigned char **) &tinfo.abbrev_wkday[2], (unsigned char **) &tinfo.abbrev_wkday[3], (unsigned char **) &tinfo.abbrev_wkday[4], (unsigned char **) &tinfo.abbrev_wkday[5], (unsigned char **) &tinfo.abbrev_wkday[6], (unsigned char **) &tinfo.full_wkday[0], (unsigned char **) &tinfo.full_wkday[1], (unsigned char **) &tinfo.full_wkday[2], (unsigned char **) &tinfo.full_wkday[3], (unsigned char **) &tinfo.full_wkday[4], (unsigned char **) &tinfo.full_wkday[5], (unsigned char **) &tinfo.full_wkday[6], (unsigned char **) &tinfo.abbrev_month[0], (unsigned char **) &tinfo.abbrev_month[1], (unsigned char **) &tinfo.abbrev_month[2], (unsigned char **) &tinfo.abbrev_month[3], (unsigned char **) &tinfo.abbrev_month[4], (unsigned char **) &tinfo.abbrev_month[5], (unsigned char **) &tinfo.abbrev_month[6], (unsigned char **) &tinfo.abbrev_month[7], (unsigned char **) &tinfo.abbrev_month[8], (unsigned char **) &tinfo.abbrev_month[9], (unsigned char **) &tinfo.abbrev_month[10], (unsigned char **) &tinfo.abbrev_month[11], (unsigned char **) &tinfo.full_month[0], (unsigned char **) &tinfo.full_month[1], (unsigned char **) &tinfo.full_month[2], (unsigned char **) &tinfo.full_month[3], (unsigned char **) &tinfo.full_month[4], (unsigned char **) &tinfo.full_month[5], (unsigned char **) &tinfo.full_month[6], (unsigned char **) &tinfo.full_month[7], (unsigned char **) &tinfo.full_month[8], (unsigned char **) &tinfo.full_month[9], (unsigned char **) &tinfo.full_month[10], (unsigned char **) &tinfo.full_month[11], (unsigned char **) &tinfo.ampm[0], (unsigned char **) &tinfo.ampm[1], (unsigned char **) &tinfo.date_time, (unsigned char **) &tinfo.date, (unsigned char **) &tinfo.time, (unsigned char **) &tinfo.ut0, (unsigned char **) &tinfo.tz, NULL }; int parse (void); int main (int argc, char *argv[]) { int i; unsigned char *outname = "LC_TIME"; while ((i = getopt (argc, argv, "o:")) != EOF) { switch (i) { case 'o': outname = optarg; break; } } if (argc - optind > 1) { (void) fprintf (stderr, "Usage: %s [-o out_file_name] [file]\n", argv[0]); return 3; } else if ((argc - optind) == 1) { if (freopen (argv[optind], "r", stdin) == NULL) { perror (argv[optind]); return 2; } } if (!parse ()) return 1; return !write_out (outname); } void write_str (char *str, FILE * ofp) { short int slen = strlen (str) + 1; (void) fwrite (&slen, sizeof (slen), 1, ofp); (void) fwrite (str, sizeof (char), slen, ofp); } int write_out (outname) unsigned char *outname; { unsigned char ***target = lines; FILE *ofp = fopen (outname, "w"); if (ofp == NULL) return 0; while (*target != NULL) { write_str (**target, ofp); target++; } #ifndef NOGUARD (void) fwrite (codename, sizeof (unsigned char), strlen (codename) + 1, ofp); #endif (void) fclose (ofp); return 1; } unsigned char iline[1024]; int parse () { int codename_seen = 0; int lineno = 0; unsigned char ***target = lines; unsigned char *cp; while (fgets (iline, sizeof (iline), stdin) != NULL) { lineno++; if (iline[0] == '#') continue; if ((cp = strchr (iline, '\n')) == NULL) { (void) fprintf (stderr, "Line %d: buffer overflow\n", lineno); return 0; } *cp = '\0'; if (strlen (iline) == 0) continue; if (!codename_seen) { if (grok_codename ()) { codename_seen = 1; continue; } else return 0; } **target++ = strdup (iline); if (*target == NULL) return 1; } return 0; } int grok_codename () { unsigned char *cp = iline; while (*cp && *cp == ' ' && *cp == '\t') cp++; if (*cp == '\0') return 0; if (strncmp (cp, "codeset ", 8) && strncmp (cp, "codeset\t", 8)) return 0; cp += 8; while (*cp && *cp == ' ' && *cp == '\t') cp++; if (*cp == '\0') return 0; codename = strdup (cp); return 1; } ./libc-linux/locale/time/example100644 1676 334 447 5540660053 14657 0ustar hjlislcodeset koi8-r вос пон вто сре чет пят суб воскресенье понедельник вторник среда четверг пятница суббота янв фев мар апр май июн июл авг сен окт ноя дек январь февраль март апрель май июнь июль август сентябрь октябрь ноябрь декабрь ПП ДП %a %b %d %H:%M:%S %Y %d/%m/%y %H:%M:%S GMT +0300 ./libc-linux/locale/time/mktime.1100644 1676 334 3056 5542312026 14664 0ustar hjlisl.TH MKTIME 1 "15 March 1994" "Version 1.0" .SH NAME .B mktime \- create time information file .SH SYNOPSIS .B mktime [ .B \-o .I output_file_name ] [ .I filename ] .SH DESCRIPTION .B mktime is used to create binary file, describing time information for .BR setlocale (3) and .BR localeinfo (3). .I filename is the name of input file. If none given, .I stdin used. .SH OPTIONS .TP .RI \-o\ output_file_name Write the output on .IR output_file_name ; otherwise, write the output on a file named LC_TIME. .SH INPUT FILE FORMAT Empty lines and lines beginning with # are ignored. The backslash character, \\, is used for continuation. No characters are permitted after it. The following statements are recognized: .sp .B codeset .I codename .sp .RS .I Codename is the name of codeset. This statement is required. .RE .sp Rest of the lines taken as contents of structure .IR time_info . .SH EXAMPLE .RS .nf codeset dummy Sun Mon Tue Wed Thu Fri Sat Sunday Monday Tuesday Wednesday Thursday Friday Saturday Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec January February March April May June July August September October November December AM PM %a %b %d %H:%M:%S %Y %d/%m/%y %H:%M:%S GMT +0000 .fi .RE .SH BUGS None are know at the moment. If you find any, feel free to fix. .SH AUTHOR Nickolay Saukh - .SH FILES /usr/lib/locale/\fIlocale\fR/LC_TIME \- LC_TIME database for .br /usr/include/localeinfo.h .I locale .SH SEE ALSO .BR setlocale (3), .BR localeconv (3), .BR mkcollate (1), .BR mkctype (1), .BR mkmonetary (1), .BR mknumeric (1), .BR mkresponse (1) ./libc-linux/posix/ 40755 1676 334 0 5567152201 12164 5ustar hjlisl./libc-linux/posix/ctermid.c100644 1676 334 2505 5550022463 14054 0ustar hjlisl/* Copyright (C) 1991 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include /* Return the name of the controlling terminal. If S is not NULL, the name is copied into it (it should be at least L_ctermid bytes long), otherwise a static buffer is used. */ char * DEFUN(ctermid, (s), char *s) { #ifdef linux static char name[] = "/dev/tty"; #else static char name[L_ctermid]; if (name[0] == '\0') (void) strcpy(name, "/dev/tty"); #endif if (s == NULL) return(name); return(strcpy(s, name)); } ./libc-linux/posix/cuserid.c100644 1676 334 3541 5550046761 14073 0ustar hjlisl/* Copyright (C) 1991, 1994 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include /* Return the username of the caller. If S is not NULL, it points to a buffer of at least L_cuserid bytes into which the name is copied; otherwise, a static buffer is used. */ char * DEFUN(cuserid, (s), char *s) { static char name[L_cuserid]; char user_name [L_cuserid]; char *login_name = getlogin (); uid_t user_uid; /* We need that for POSIX. */ struct passwd *pwent = getpwuid(geteuid()); /* We should not do anything. */ if (pwent == NULL) { if (s != NULL) s[0] = '\0'; return NULL; } /* We get effective user name and ID. */ strcpy (user_name, pwent->pw_name); user_uid = pwent->pw_uid; /* It is tricky here. We don't want to use getlogin () if * user_uid != getpwnam(login_name)->pw_uid. */ if (login_name == NULL || (pwent = getpwnam(login_name)) == NULL || user_uid != pwent->pw_uid) { login_name = user_name; } if (s == NULL) s = name; return strcpy(s, login_name); } ./libc-linux/posix/getopt.c100644 1676 334 54351 5547117732 13767 0ustar hjlisl/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #if !__STDC__ && !defined(const) && IN_GCC #define const #endif /* This tells Alpha OSF/1 not to define a getopt prototype in . */ #ifndef _NO_PROTO #define _NO_PROTO #endif #include /* 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 Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #if defined (_LIBC) || !defined (__GNU_LIBRARY__) /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ #include #endif /* GNU C library. */ /* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a long-named option. Because this is not POSIX.2 compliant, it is being phased out. */ /* #define GETOPT_COMPAT */ /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg = 0; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* XXX 1003.2 says this must be 1 before any call. */ int optind = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return EOF with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ #include #define my_index strchr #else /* Avoid depending on library functions or files whose names are inconsistent. */ char *getenv (); static char * my_index (str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ #ifdef IN_GCC #include "gstddef.h" #else #include #endif extern size_t strlen (const char *); #endif #endif /* GNU C library. */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns `EOF'. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ #if NLS #include "nl_types.h" #endif int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { int option_index; optarg = 0; #if NLS libc_nls_init(); #endif /* Initialize the internal data when the first call is made. Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ if (optind == 0) { first_nonopt = last_nonopt = optind = 1; nextchar = NULL; /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (getenv ("POSIXLY_CORRECT") != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; } if (nextchar == NULL || *nextchar == '\0') { if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Now skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && (argv[optind][0] != '-' || argv[optind][1] == '\0') #ifdef GETOPT_COMPAT && (longopts == NULL || argv[optind][0] != '+' || argv[optind][1] == '\0') #endif /* GETOPT_COMPAT */ ) optind++; last_nonopt = optind; } /* Special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return EOF; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if ((argv[optind][0] != '-' || argv[optind][1] == '\0') #ifdef GETOPT_COMPAT && (longopts == NULL || argv[optind][0] != '+' || argv[optind][1] == '\0') #endif /* GETOPT_COMPAT */ ) { if (ordering == REQUIRE_ORDER) return EOF; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Start decoding its characters. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } if (longopts != NULL && ((argv[optind][0] == '-' && (argv[optind][1] == '-' || long_only)) #ifdef GETOPT_COMPAT || argv[optind][0] == '+' #endif /* GETOPT_COMPAT */ )) { const struct option *p; char *s = nextchar; int exact = 0; int ambig = 0; const struct option *pfound = NULL; int indfound; while (*s && *s != '=') s++; /* Test all options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, s - nextchar)) { if (s - nextchar == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) #if NLS fprintf (stderr, catgets(_libc_cat, GetoptSet, GetoptAmbiguous, "%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); #else fprintf (stderr, "%s: option `%s' is ambiguous\n", argv[0], argv[optind]); #endif nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*s) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = s + 1; else { if (opterr) { if (argv[optind - 1][1] == '-') /* --option */ #if NLS fprintf (stderr, catgets(_libc_cat, GetoptSet, GetoptNoArgumentsAllowed1, "%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); #else fprintf (stderr, "%s: option `--%s' doesn't allow an argument\n", argv[0], pfound->name); #endif else /* +option or -option */ #if NLS fprintf (stderr, catgets(_libc_cat, GetoptSet, GetoptNoArgumentsAllowed2, "%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); #else fprintf (stderr, "%s: option `%c%s' doesn't allow an argument\n", argv[0], argv[optind - 1][0], pfound->name); #endif } nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) #if NLS fprintf (stderr, catgets(_libc_cat, GetoptSet, GetoptRequiresArgument1, "%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); #else fprintf (stderr, "%s: option `%s' requires an argument\n", argv[0], argv[optind - 1]); #endif nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' #ifdef GETOPT_COMPAT || argv[optind][0] == '+' #endif /* GETOPT_COMPAT */ || my_index (optstring, *nextchar) == NULL) { if (opterr) { if (argv[optind][1] == '-') /* --option */ #if NLS fprintf (stderr, catgets(_libc_cat, GetoptSet, GetoptUnrecognized1, "%s: unrecognized option `--%s'\n"), argv[0], nextchar); #else fprintf (stderr, "%s: unrecognized option `--%s'\n", argv[0], nextchar); #endif else /* +option or -option */ #if NLS fprintf (stderr, catgets(_libc_cat, GetoptSet, GetoptUnrecognized2, "%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); #else fprintf (stderr, "%s: unrecognized option `%c%s'\n", argv[0], argv[optind][0], nextchar); #endif } nextchar = (char *) ""; optind++; return '?'; } } /* Look at and handle the next option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (opterr) { #if 0 if (c < 040 || c >= 0177) fprintf (stderr, "%s: unrecognized option, character code 0%o\n", argv[0], c); else fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); #else /* 1003.2 specifies the format of this message. */ #if NLS fprintf (stderr, catgets(_libc_cat, GetoptSet, GetoptIllegal, "%s: illegal option -- %c\n"), argv[0], c); #else fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); #endif #endif } optopt = c; return '?'; } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = 0; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { #if 0 fprintf (stderr, "%s: option `-%c' requires an argument\n", argv[0], c); #else /* 1003.2 specifies the format of this message. */ #if NLS fprintf (stderr, catgets(_libc_cat, GetoptSet, GetoptRequiresArgument2, "%s: option requires an argument -- %c\n"), argv[0], c); #else fprintf (stderr, "%s: option requires an argument -- %c\n", argv[0], c); #endif #endif } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* _LIBC or not __GNU_LIBRARY__. */ #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == EOF) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ ./libc-linux/bsd/ 40755 1676 334 0 5567152201 11572 5ustar hjlisl./libc-linux/bsd/psignal.c100644 1676 334 3673 5547117732 13511 0ustar hjlisl/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #ifndef HAVE_GNU_LD #define _sys_siglist sys_siglist #endif #if NLS #include "nl_types.h" #endif #ifndef linux /* Defined in sys_siglist.c. */ extern CONST char *CONST _sys_siglist[]; #endif /* Print out on stderr a line consisting of the test in S, a colon, a space, a message describing the meaning of the signal number SIG and a newline. If S is NULL or "", the colon and space are omitted. */ void DEFUN(psignal, (sig, s), int sig AND register CONST char *s) { CONST char *colon; #if NLS libc_nls_init(); #endif if (s == NULL || s == '\0') s = colon = ""; else colon = ": "; if (sig >= 0 && sig < NSIG) #if NLS (void) fprintf(stderr, "%s%s%s\n", s, colon, catgets(_libc_cat, SignalListSet, sig +1, (char *) _sys_siglist[sig])); #else (void) fprintf(stderr, "%s%s%s\n", s, colon, _sys_siglist[sig]); #endif else #if NLS (void) fprintf(stderr, "%s%s%s %d\n", s, colon, catgets(_libc_cat, SignalListSet, 1, "Unknown signal"), sig); #else (void) fprintf(stderr, "%s%s%s %d\n", s, colon, "Unknown signal", sig); #endif } ./libc-linux/string/ 40755 1676 334 0 5567152202 12331 5ustar hjlisl./libc-linux/string/strerror.c100644 1676 334 3457 5547117732 14474 0ustar hjlisl/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #ifndef HAVE_GNU_LD #define _sys_errlist sys_errlist #define _sys_nerr sys_nerr #endif #if NLS #include "nl_types.h" #endif /* Return a string descibing the errno code in ERRNUM. The storage is good only until the next call to strerror. Writing to the storage causes undefined behavior. */ char * DEFUN(strerror, (errnum), int errnum) { #if NLS libc_nls_init(); #endif if (errnum < 0 || errnum >= _sys_nerr) { static char unknown_error[] = "Unknown error 000000000000000000000"; static char fmt[] = "Unknown error %d"; #ifdef __linux__ sprintf(unknown_error, fmt, errnum); #else size_t len = sprintf(unknown_error, fmt, errnum); if (len < sizeof(fmt) - 2) return NULL; unknown_error[len] = '\0'; #endif return unknown_error; } #if NLS return catgets(_libc_cat, ErrorListSet, errnum +1, (char *) _sys_errlist[errnum]); #else return (char *) _sys_errlist[errnum]; #endif } ./libc-linux/string/strsignal.c100644 1676 334 3415 5547117733 14613 0ustar hjlisl/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #ifndef HAVE_GNU_LD #define _sys_siglist sys_siglist #endif #if NLS #include "nl_types.h" #endif /* Defined in _siglist.c. */ extern CONST char *CONST _sys_siglist[]; /* Return a string describing the meaning of the signal number SIGNUM. */ char * DEFUN(strsignal, (signum), int signum) { #if NLS libc_nls_init(); #endif if (signum < 0 || signum >= NSIG) { static char unknown_signal[] = "Unknown signal 000000000000000000000"; static char fmt[] = "Unknown signal %d"; #ifdef __linux__ sprintf(unknown_signal, fmt, signum); #else size_t len = sprintf(unknown_signal, fmt, signum); if (len < sizeof(fmt) - 2) return NULL; unknown_signal[len] = '\0'; #endif return unknown_signal; } #if NLS return catgets(_libc_cat, SignalListSet, signum +1, (char *) _sys_siglist[signum]); #else return (char *) _sys_siglist[signum]; #endif }