./libc-linux/ 40755 1676 334 0 5550061520 11015 5ustar hjlisl./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/signal/ 40755 1676 334 0 5550054423 12276 5ustar hjlisl./libc-linux/signal/Makefile100644 1676 334 654 5515544500 14021 0ustar hjlisl# # Makefile for signal functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules DIRS:= SRC1S= sigaddset.c sigdelset.c sigempty.c sigfillset.c \ sigismem.c SRC2S= gsignal.c kill.c sigaction.c sigblock.c siggetmask.c \ sigpause.c sigproc.c sigsetmask.c ssignal.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/signal/sigsetmask.c100644 1676 334 1761 5266215147 14724 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 #undef sigsetmask function_alias(sigsetmask, __sigsetmask, int, (mask), DEFUN(sigsetmask, (mask), int mask)) ./libc-linux/signal/gsignal.c100644 1676 334 1736 5266215147 14200 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 #undef gsignal function_alias(gsignal, raise, int, (sig), DEFUN(gsignal, (sig), int sig)) ./libc-linux/signal/sigaddset.c100644 1676 334 2067 5266215147 14521 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 "sigsetops.h" /* Add SIGNO to SET. */ int DEFUN(sigaddset, (set, signo), sigset_t *set AND int signo) { if (set == NULL || signo <= 0 || signo >= NSIG) { errno = EINVAL; return -1; } return __sigaddset (set, signo); } ./libc-linux/signal/sigdelset.c100644 1676 334 2067 5266215147 14535 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 "sigsetops.h" /* Add SIGNO to SET. */ int DEFUN(sigdelset, (set, signo), sigset_t *set AND int signo) { if (set == NULL || signo <= 0 || signo >= NSIG) { errno = EINVAL; return -1; } return __sigdelset (set, signo); } ./libc-linux/signal/sigempty.c100644 1676 334 2012 5266215147 14401 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 "sigsetops.h" /* Clear all signals from SET. */ int DEFUN(sigemptyset, (set), sigset_t *set) { if (set == NULL) { errno = EINVAL; return -1; } return __sigemptyset (set); } ./libc-linux/signal/sigfillset.c100644 1676 334 2004 5266215147 14706 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 "sigsetops.h" /* Set all signals in SET. */ int DEFUN(sigfillset, (set), sigset_t *set) { if (set == NULL) { errno = EINVAL; return -1; } return __sigfillset (set); } ./libc-linux/signal/sigismem.c100644 1676 334 2126 5266215147 14363 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 "sigsetops.h" /* Return 1 if SIGNO is in SET, 0 if not. */ int DEFUN(sigismember, (set, signo), CONST sigset_t *set AND int signo) { if (set == NULL || signo <= 0 || signo >= NSIG) { errno = EINVAL; return -1; } return __sigismember (set, signo); } ./libc-linux/signal/kill.c100644 1676 334 1766 5266215147 13512 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 #undef kill function_alias(kill, __kill, int, (pid, sig), DEFUN(kill, (pid, sig), __pid_t pid AND int sig)) ./libc-linux/signal/sigsetops.h100644 1676 334 2273 5266215150 14570 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. */ /* Definitions relevant to functions that operate on `sigset_t's. */ #include #include #include #include #define BITS (_NSIG - 1) #define ELT(signo) (((signo) - 1) / BITS) #define MASK(signo) (1 << (((signo) - 1) % BITS)) #undef sigemptyset #undef sigfillset #undef sigaddset #undef sigdelset #undef sigismember #include ./libc-linux/signal/siggetmask.c100644 1676 334 1742 5270563514 14706 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 #undef siggetmask function_alias_void (siggetmask, __siggetmask, int, DEFUN_VOID(siggetmask)) ./libc-linux/signal/sigaction.c100644 1676 334 2123 5266215147 14523 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 #undef sigaction function_alias(sigaction, __sigaction, int, (sig, act, oact), DEFUN(sigaction, (sig, act, oact), int sig AND CONST struct __sigaction *act AND struct __sigaction *oact)) ./libc-linux/signal/sigblock.c100644 1676 334 1751 5266215147 14346 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 #undef sigblock function_alias(sigblock, __sigblock, int, (mask), DEFUN(sigblock, (mask), int mask)) ./libc-linux/signal/sigpause.c100644 1676 334 1751 5266215147 14371 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 #undef sigpause function_alias(sigpause, __sigpause, int, (mask), DEFUN(sigpause, (mask), int mask)) ./libc-linux/signal/sigproc.c100644 1676 334 2064 5266215147 14215 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 #undef sigprocmask function_alias(sigprocmask, __sigprocmask, int, (how, set, oset), DEFUN(sigprocmask, (how, set, oset), int how AND sigset_t *set AND sigset_t *oset)) ./libc-linux/signal/ssignal.c100644 1676 334 2027 5266215147 14206 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 #undef ssignal function_alias(ssignal, signal, __sighandler_t, (sig, func), DEFUN(ssignal, (sig, handler), int sig AND __sighandler_t func)) ./libc-linux/signal/tst-signal.c100644 1676 334 1327 5266215147 14635 0ustar hjlisl#include #include #include #include #include int win = 0; void DEFUN(handler, (sig), int sig) { printf("Received signal %d (%s).\n", sig, strsignal(sig)); win = 1; } int DEFUN_VOID(main) { if (signal(SIGTERM, handler) == SIG_ERR) { perror("signal: SIGTERM"); exit(EXIT_FAILURE); } puts("Set handler."); printf("Sending myself signal %d.\n", SIGTERM); fflush(stdout); if (raise(SIGTERM) < 0) { perror("raise: SIGTERM"); exit(EXIT_FAILURE); } if (!win) { puts("Didn't get any signal. Test FAILED!"); exit(EXIT_FAILURE); } puts("Got a signal. Test succeeded."); exit(EXIT_SUCCESS); } ./libc-linux/libio/ 40755 1676 334 0 5550052650 12117 5ustar hjlisl./libc-linux/libio/config/ 40755 1676 334 0 5504466500 13366 5ustar hjlisl./libc-linux/libio/config/hpux.mt100644 1676 334 221 5477564511 14776 0ustar hjlisl# Flags to pass to gen-params when building _G_config.h. # For example: G_CONFIG_ARGS = size_t="unsigned long" G_CONFIG_ARGS = DOLLAR_IN_LABEL=1 ./libc-linux/libio/config/isc.mt100644 1676 334 310 5472252022 14551 0ustar hjlisl# Flags to pass to gen-params when building _G_config.h. # For example: G_CONFIG_ARGS = size_t="unsigned long" G_CONFIG_ARGS = pid_t="unsigned short" \ gid_t="unsigned short" uid_t="unsigned short" ./libc-linux/libio/config/sco4.mt100644 1676 334 220 5436742160 14652 0ustar hjlisl# Flags to pass to gen-params when building _G_config.h. # For example: G_CONFIG_ARGS = size_t="unsigned long" G_CONFIG_ARGS = MATH_H_INLINES=1 ./libc-linux/libio/config/linux.h100644 1676 334 1275 5477731536 15015 0ustar hjlisl#ifndef _CONFIG_LINUX_H #define _CONFIG_LINUX_H #undef _STDIO_USES_IOSTREAM #define _STDIO_USES_IOSTREAM 1 #undef _IO_HAVE_ST_BLKSIZE #define _IO_HAVE_ST_BLKSIZE 1 #define _IO_open __open #define _IO_close __close #define _IO_fork __fork #define _IO_fcntl __fcntl #define _IO__exit _exit #define _IO_read __read #define _IO_write __write #define _IO_lseek __lseek #define _IO_getdtablesize __getdtablesize #define _IO_pipe __pipe #define _IO_dup2 __dup2 #define _IO_execl execl #define _IO_waitpid __waitpid #define _IO_stat __stat #define _IO_getpid __getpid #define _IO_geteuid __geteuid #define _IO_getegid __getegid #define _IO_fstat __fstat #endif /* _CONFIG_LINUX_H */ ./libc-linux/libio/config/linux.mt100644 1676 334 212 5477731537 15155 0ustar hjlisl# Linux defines those system dependent macros in libio/config/linux.h. LIBIO_CONFIG_FLAGS=-D_LIBIO_CONFIG_H=\"config/linux.h\" -I./stdio ./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/Makefile.in100644 1676 334 7331 5505474514 14274 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. srcdir = . VERSION = 0.63 INSTALLDIR = $(libdir) IO_OBJECTS = filedoalloc.o floatconv.o genops.o fileops.o \ iovfprintf.o \ iovfscanf.o ioignore.o iopadn.o \ iofgetpos.o iofread.o iofscanf.o \ iofsetpos.o iogetline.o \ ioprintf.o ioseekoff.o ioseekpos.o iotempname.o \ outfloat.o stdfiles.o strops.o iofclose.o iopopen.o ioungetc.o # These emulate stdio functionality, but with a different name (_IO_ungetc # instead of ungetc), and using _IO_FILE instead of FILE. # They are not needed for C++ iostream, nor stdio, though some stdio # files are build using the same source files (see stdio/configure.in). # They are needed for iostdio.h. # iofclose.o is not here, because it is needed for stdio (by pclose). STDIO_WRAP_OBJECTS = iofdopen.o iofflush.o iofgets.o iofopen.o iofprintf.o iofputs.o iofwrite.o iogets.o ioperror.o ioputs.o ioscanf.o iosetbuffer.o iosetvbuf.o iosprintf.o iosscanf.o ioftell.o iovsprintf.o iovsscanf.o IOSTREAM_OBJECTS = builtinbuf.o filebuf.o fstream.o \ indstream.o isgetline.o isgetsb.o isscan.o ioextend.o iomanip.o iostream.o \ osform.o procbuf.o sbform.o sbgetline.o sbscan.o \ stdiostream.o stdstreams.o stream.o streambuf.o strstream.o \ PlotFile.o SFile.o parsestream.o pfstream.o editbuf.o # These files define _IO_read etc, which are just wrappers for read(2) etc. # They need to be changed to use name-space-clean (e.g. __read) versions # for each specific libc. OSPRIM_OBJECTS = ioprims.o iostrerror.o cleanup.o #### package, host, target, and site dependent Makefile fragments come in here. ## LIBIOSTREAM_OBJECTS = $(IO_OBJECTS) $(IOSTREAM_OBJECTS) $(OSPRIM_OBJECTS) LIBIO_OBJECTS = $(IO_OBJECTS) $(STDIO_WRAP_OBJECTS) $(OSPRIM_OBJECTS) libio.a: _G_config.h $(LIBIO_OBJECTS) -rm -rf libio.a $(AR) $(AR_FLAGS) libio.a $(LIBIO_OBJECTS) $(RANLIB) libio.a libiostream.a: _G_config.h $(LIBIOSTREAM_OBJECTS) -rm -rf libiostream.a $(AR) $(AR_FLAGS) libiostream.a $(LIBIOSTREAM_OBJECTS) $(RANLIB) libiostream.a test: test.o libio.a $(CC) -o test test.o libio.a tpipe: tpipe.o libio.a $(CC) -o tpipe tpipe.o libio.a iostream.list: _G_config.h $(LIBIOSTREAM_OBJECTS) @echo "$(LIBIOSTREAM_OBJECTS)"> iostream.list # The CC=$(CXX) is a kludge to force use of gcc. _G_config.h: ${srcdir}/gen-params rootme=`pwd`/ ; export rootme; \ CC="$(CXX) $(XTRAFLAGS)"; export CC; \ CXX="$(CXX) $(XTRAFLAGS) $(NOSTDINC)"; export CXX; \ CONFIG_NM="$(NM)"; export CONFIG_NM; \ $(SHELL) ${srcdir}/gen-params LIB_VERSION=$(VERSION) $(G_CONFIG_ARGS) >tmp-params.h mv tmp-params.h _G_config.h USER_INCLUDES = *.h install: rm -f $(tooldir)/include/_G_config.h ; \ $(INSTALL_DATA) _G_config.h $(tooldir)/include/_G_config.h || exit 1; cd $(srcdir); \ for FILE in $(USER_INCLUDES) ; do \ rm -f $(gxx_includedir)/$$FILE ; \ $(INSTALL_DATA) $$FILE $(gxx_includedir)/$$FILE ; \ chmod a-x $(gxx_includedir)/$$FILE ; \ done $(INSTALL_DATA) libiostream.a $(INSTALLDIR)/libiostream.a $(RANLIB) $(INSTALLDIR)/libiostream.a chmod a-x $(INSTALLDIR)/libiostream.a ./libc-linux/libio/Makefile100644 1676 334 1504 5515544064 13662 0ustar hjlisl# # Makefile for libio # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I. -I./stdio -D_LIBIO_CONFIG_H=\"config/linux.h\" DIRS=stdio SRC1S= filedoalloc.c fileops.c floatconv.c \ genops.c iofclose.c iofdopen.c iofflush.c iofgetpos.c \ iofgets.c iofopen.c iofprintf.c iofputs.c iofread.c \ iofscanf.c iofsetpos.c ioftell.c iofwrite.c iogetline.c \ iogets.c ioignore.c iopadn.c ioperror.c iopopen.c ioprims.c \ ioprintf.c ioputs.c ioscanf.c ioseekoff.c ioseekpos.c \ iosetbuffer.c iosetvbuf.c iosprintf.c iosscanf.c \ iostrerror.c iotempname.c ioungetc.c iovfprintf.c \ iovfscanf.c iovsprintf.c iovsscanf.c outfloat.c \ stdfiles.c strops.c SRC2S= cleanup.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SCR2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/libio/_G_config.h100644 1676 334 2277 5505501567 14255 0ustar hjlisl/* AUTOMATICALLY GENERATED; DO NOT EDIT! */ #ifndef _G_config_h #define _G_config_h #define _G_LIB_VERSION "0.63" #define _G_NAMES_HAVE_UNDERSCORE 1 #define _G_HAVE_ST_BLKSIZE 1 typedef long _G_clock_t; typedef unsigned short _G_dev_t; typedef long int _G_fpos_t; typedef unsigned short _G_gid_t; typedef unsigned long _G_ino_t; typedef unsigned short _G_mode_t; typedef unsigned short _G_nlink_t; typedef long _G_off_t; typedef int _G_pid_t; typedef int _G_ptrdiff_t; typedef unsigned int _G_sigset_t; typedef unsigned int _G_size_t; typedef long _G_time_t; typedef unsigned short _G_uid_t; typedef long int _G_wchar_t; typedef int /* default */ _G_int32_t; typedef unsigned int /* default */ _G_uint32_t; typedef int _G_ssize_t; typedef void * _G_va_list; #define _G_signal_return_type void #define _G_sprintf_return_type int #define _G_BUFSIZ 1024 #define _G_FOPEN_MAX 256 #define _G_FILENAME_MAX 1024 #define _G_NULL 0 /* default */ #define _G_ARGS(ARGLIST) (...) #define _G_HAVE_ATEXIT 1 #define _G_HAVE_SYS_RESOURCE 1 #define _G_HAVE_SYS_SOCKET 1 #define _G_HAVE_SYS_WAIT 1 #define _G_HAVE_UNISTD 1 #define _G_HAVE_DIRENT 1 #define _G_HAVE_CURSES 1 #define _G_MATH_H_INLINES 0 #endif /* !_G_config_h */ ./libc-linux/libio/README100644 1676 334 2417 5456372152 13107 0ustar hjlislThis is libio, the GNU C/C++ input/output library. By default, the library is configured to build the C++ iostream facility (in $libdir/libiostream.a). The library can be configured to build the C stdio facility that is part of a C run-time library. This library is distributed with libg++; see ../libg++/README for installation instructions, and where to send bug reports and questions. * Copyright restrictions The files in this directory are generally covered by the GNU Public License (which is in the file ../COPYING), but modified with the following: 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. A few source files and subroutines other other (but less restrictive) copyright conditions. E.g. some code (such as iovfprintf.c) is base on software that was developed by the University of California, Berkeley, for the Berkeley Software Distribution (BSD-4.4), and bears their copyright; and one file (floatconv.c) is derived from ("free") code copyrighted AT&T. ./libc-linux/libio/Makefile.libg++100644 1676 334 22422 5470354553 14750 0ustar hjlisl# This file was generated automatically by configure. Do not edit. VPATH = . links = host_alias = i486-linux host_cpu = i486 host_vendor = unknown host_os = linux host_canonical = i486-unknown-linux target_alias = i486-linux target_cpu = i486 target_vendor = unknown target_os = linux target_canonical = i486-unknown-linux package_makefile_frag = Make.pack target_makefile_frag = config/linux.mt # 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. srcdir = . VERSION = 0.61 #### package, host, target, and site dependent Makefile fragments come in here. # Start of package fragment generated by ./config.shared. # TOPDIR=$${rootme}../ invsubdir= subdir= srcdir = . SUBDIRS = tests dbz stdio prefix = /usr exec_prefix = $(prefix) bindir = $(exec_prefix)/bin libdir = $(exec_prefix)/lib datadir = $(prefix)/lib mandir = $(prefix)/man man1dir = $(mandir)/man1 man2dir = $(mandir)/man2 man3dir = $(mandir)/man3 man4dir = $(mandir)/man4 man5dir = $(mandir)/man5 man6dir = $(mandir)/man6 man7dir = $(mandir)/man7 man8dir = $(mandir)/man8 man9dir = $(mandir)/man9 infodir = $(prefix)/info includedir = $(prefix)/include gxx_includedir = $(libdir)/g++-include docdir = $(datadir)/doc SHELL = /bin/sh INSTALL = ${rootme}$(srcdir)/../install.sh -c INSTALL_PROGRAM = $(INSTALL) INSTALL_DATA = $(INSTALL) AR = `if [ -f $${rootme}../binutils/ar ] ; \ then echo $${rootme}../binutils/ar ; \ else echo ar ; fi` AR_FLAGS = rc RANLIB = `if [ -f $${rootme}../binutils/ranlib ] ; \ then echo $${rootme}../binutils/ranlib ; \ else echo ranlib ; fi` NM = `if [ -f $${rootme}../binutils/nm ] ; \ then echo $${rootme}../binutils/nm ; \ else echo nm ; fi` MAKEINFO = `if [ -f $${rootme}../texinfo/C/makeinfo ] ; \ then echo $${rootme}../texinfo/C/makeinfo ; \ else echo makeinfo ; fi` TEXIDIR=${srcdir}/..//texinfo TEXI2DVI = TEXINPUTS=${TEXIDIR}:$$TEXINPUTS texi2dvi CC = `if [ -f $${rootme}../gcc/xgcc ] ; \ then echo $${rootme}../gcc/xgcc -B$${rootme}../gcc/ ; \ else echo cc ; fi` CXX = `if [ -f $${rootme}../gcc/xgcc ] ; \ then echo $${rootme}../gcc/xgcc -B$${rootme}../gcc/ ; \ else echo gcc ; fi` XTRAFLAGS = `if [ -f $${rootme}../gcc/xgcc ] ;\ then echo -I$${rootme}../gcc/include;\ else echo ; fi` WRAP_C_INCLUDES = CFLAGS = -g CXXFLAGS = -g -O .PHONY: all all: _G_config.h libio.a libiostream.a $(OSPRIM_OBJECTS) @rootme=`pwd`/; export rootme; \ $(MAKE) "DODIRS=$(SUBDIRS)" DO=all $(FLAGS_TO_PASS) subdir_do .PHONY: subdir_do subdir_do: force @rootme=`pwd`/; export rootme; \ for i in $(DODIRS); do \ if [ -f ./$$i/Makefile ] ; then \ echo "cd $$i; make $(DO) ..." ; \ (cd $$i ; $(MAKE) $(FLAGS_TO_PASS) $(DO)) || exit 1 ; \ else true ; fi ; \ done # List of variables to pass to sub-makes. This should not be needed # by GNU make or Sun make (both of which pass command-line variable # overrides thouh $(MAKE)) but may be needed by older versions. FLAGS_TO_PASS= \ "INSTALL=$(INSTALL)" \ "INSTALL_DATA=$(INSTALL_DATA)" \ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ "prefix=$(prefix)" \ "exec_prefix=$(exec_prefix)" \ "tooldir=$(tooldir)" \ "AR=$(AR)" \ "AR_FLAGS=$(AR_FLAGS)" \ "CC=$(CC)" \ "CXX=$(CXX)" \ "CFLAGS=$(CFLAGS)" \ "CXXFLAGS=$(CXXFLAGS)" \ "RANLIB=$(RANLIB)" \ "LOADLIBES=$(LOADLIBES)" \ "LDFLAGS=$(LDFLAGS)" \ "MAKEINFO=$(MAKEINFO)" \ "XTRAFLAGS=$(XTRAFLAGS)" CXXINCLUDES = -I. -I$(srcdir) $(XTRAFLAGS) CINCLUDES = -I. -I$(srcdir) $(XTRAFLAGS) .SUFFIXES: .o .C .cc .c.o: $(CC) -c $(LIBIO_CONFIG_FLAGS) $(CFLAGS) $(CINCLUDES) $< .C.o: $(CXX) -c $(LIBIO_CONFIG_FLAGS) $(CXXFLAGS) $(CXXINCLUDES) $< .cc.o: $(CXX) -c $(LIBIO_CONFIG_FLAGS) $(CXXFLAGS) $(CXXINCLUDES) $< .PHONY: install install: .PHONY: check check: _G_config.h libio.a libiostream.a $(OSPRIM_OBJECTS) @rootme=`pwd`/; export rootme; \ $(MAKE) "DODIRS=$(SUBDIRS)" DO=check $(FLAGS_TO_PASS) subdir_do .PHONY: info dvi install-info clean-info info: iostream.info dvi: iostream.dvi iostream.info: $(srcdir)/iostream.texi $(MAKEINFO) -I$(srcdir) -I$(TEXIDIR) $(srcdir)/iostream.texi -o iostream.info iostream.dvi: $(srcdir)/iostream.texi $(TEXI2DVI) $(srcdir)/iostream.texi iostream.ps: iostream.dvi dvips iostream -o install-info: -parent=`echo $(infodir)|sed -e 's@/[^/]*$$@@'`; \ if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi -if [ -d $(infodir) ] ; then true ; else mkdir $(infodir) ; fi for i in *.info* ; do \ $(INSTALL_DATA) $$i $(infodir)/$$i ; \ done .PHONY: do-clean-info clean-info do-clean-dvi clean-dvi do-clean-info: rm -f *.info* do-clean-dvi: rm -f *.dvi *.aux *.cp *.fn* *.ky *.log *.pg *.toc *.tp *.vr clean-info: do-clean-info clean-dvi: do-clean-dvi .PHONY: boltcc boltcc: rootme=`pwd`/ ; export rootme ; $(MAKE) $(FLAGS_TO_PASS) # clean rules .PHONY: mostlyclean clean distclean realclean .PHONY: do-clean subdir_distclean subdir_realclean mostlyclean: do-clean-dvi rm -rf *.o core iostream.list @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=mostlyclean subdir_do do-clean: do-clean-dvi rm -rf *.o core iostream.list _G_config.h *.a clean: do-clean @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=clean subdir_do subdir_distclean: @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=distclean subdir_do distclean: do-clean subdir_distclean rm -rf config.status Makefile *~ Make.pack subdir_realclean: @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=realclean subdir_do realclean: do-clean subdir_realclean do-clean-info rm -rf config.status Makefile *~ Make.pack depend *.info* .PHONY: force force: # with the gnu make, this is done automatically. Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) $(SHELL) ./config.status .NOEXPORT: MAKEOVERRIDES= # End of package fragment generated by ./config.shared. # Linux defines those system dependent macros in libio/config/linux.h. LIBIO_CONFIG_FLAGS=-D_LIBIO_CONFIG_H=\"config/linux.h\" -I./stdio ## INSTALLDIR = $(libdir) IO_OBJECTS = filedoalloc.o floatconv.o genops.o fileops.o \ iovfprintf.o \ iovfscanf.o ioignore.o iopadn.o \ iofgetpos.o iofread.o iofscanf.o \ iofsetpos.o iogetline.o \ ioprintf.o ioseekoff.o ioseekpos.o iotempname.o \ outfloat.o stdfiles.o strops.o iofclose.o iopopen.o ioungetc.o # These emulate stdio functionality, but with a different name (_IO_ungetc # instead of ungetc), and using _IO_FILE instead of FILE. # They are not needed for C++ iostream, nor stdio, though some stdio # files are build using the same source files (see stdio/configure.in). # They are needed for iostdio.h. # iofclose.o is not here, because it is needed for stdio (by pclose). STDIO_WRAP_OBJECTS = iofdopen.o iofflush.o iofgets.o iofopen.o iofprintf.o iofputs.o iofwrite.o iogets.o ioperror.o ioputs.o ioscanf.o iosetbuffer.o iosetvbuf.o iosprintf.o iosscanf.o ioftell.o iovsprintf.o iovsscanf.o IOSTREAM_OBJECTS = builtinbuf.o filebuf.o fstream.o \ indstream.o isgetline.o isgetsb.o isscan.o ioextend.o iomanip.o iostream.o \ osform.o procbuf.o sbform.o sbgetline.o sbscan.o \ stdiostream.o stdstreams.o stream.o streambuf.o strstream.o \ PlotFile.o SFile.o parsestream.o pfstream.o editbuf.o # These files define _IO_read etc, which are just wrappers for read(2) etc. # They need to be changed to use name-space-clean (e.g. __read) versions # for each specific libc. OSPRIM_OBJECTS = ioprims.o iostrerror.o cleanup.o LIBIOSTREAM_OBJECTS = $(IO_OBJECTS) $(IOSTREAM_OBJECTS) $(OSPRIM_OBJECTS) LIBIO_OBJECTS = $(IO_OBJECTS) $(STDIO_WRAP_OBJECTS) $(OSPRIM_OBJECTS) libio.a: _G_config.h $(LIBIO_OBJECTS) -rm -rf libio.a $(AR) $(AR_FLAGS) libio.a $(LIBIO_OBJECTS) $(RANLIB) libio.a libiostream.a: _G_config.h $(LIBIOSTREAM_OBJECTS) -rm -rf libiostream.a $(AR) $(AR_FLAGS) libiostream.a $(LIBIOSTREAM_OBJECTS) $(RANLIB) libiostream.a test: test.o libio.a $(CC) -o test test.o libio.a tpipe: tpipe.o libio.a $(CC) -o tpipe tpipe.o libio.a iostream.list: _G_config.h $(LIBIOSTREAM_OBJECTS) @echo "$(LIBIOSTREAM_OBJECTS)"> iostream.list # The CC=$(CXX) is a kludge to force use of gcc. _G_config.h: ${srcdir}/gen-params rootme=`pwd`/ ; export rootme; \ CC="$(CXX) $(XTRAFLAGS)"; export CC; \ CXX="$(CXX) $(XTRAFLAGS) $(NOSTDINC)"; export CXX; \ CONFIG_NM="$(NM)"; export CONFIG_NM; \ ${srcdir}/gen-params LIB_VERSION=$(VERSION) $(G_CONFIG_ARGS) >tmp-params.h mv tmp-params.h _G_config.h USER_INCLUDES = *.h install: rm -f $(tooldir)/include/_G_config.h ; \ $(INSTALL_DATA) _G_config.h $(tooldir)/include/_G_config.h || exit 1; cd $(srcdir); \ for FILE in $(USER_INCLUDES) ; do \ rm -f $(gxx_includedir)/$$FILE ; \ $(INSTALL_DATA) $$FILE $(gxx_includedir)/$$FILE ; \ chmod a-x $(gxx_includedir)/$$FILE ; \ done $(INSTALL_DATA) libiostream.a $(INSTALLDIR)/libiostream.a $(RANLIB) $(INSTALLDIR)/libiostream.a chmod a-x $(INSTALLDIR)/libiostream.a ./libc-linux/libio/libio.h100644 1676 334 16703 5532175103 13511 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. */ /* This is part of the iostream library. Copyright (C) 1991, 1992 Per Bothner. */ #ifndef _IO_STDIO_H #define _IO_STDIO_H #ifdef __GNUG__ #pragma interface #endif #if 1 #include <_G_config.h> #define _IO_pos_t _G_fpos_t /* obsolete */ #define _IO_fpos_t _G_fpos_t #define _IO_size_t _G_size_t #define _IO_ssize_t _G_ssize_t #define _IO_off_t _G_off_t #define _IO_pid_t _G_pid_t #define _IO_uid_t _G_uid_t #define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT #define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE #define _IO_BUFSIZ _G_BUFSIZ #define _IO_va_list _G_va_list #ifdef _G_NEED_STDARG_H /* This define avoids name pollution if we're using GNU stdarg.h */ #define __need___va_list #include #ifdef __GNUC_VA_LIST #undef _IO_va_list #define _IO_va_list __gnuc_va_list #endif /* __GNUC_VA_LIST */ #endif #else #include <_IO_config.h> typedef _IO_fpos_t _IO_pos_t; #endif #include #define USE_DTOA #if 0 #ifdef _IO_NEED_STDARG_H #include #endif #endif #ifndef EOF #define EOF (-1) #endif #ifndef NULL #if !defined(__cplusplus) || defined(__GNUC__) #define NULL ((void*)0) #else #define NULL (0) #endif #endif #define _IOS_INPUT 1 #define _IOS_OUTPUT 2 #define _IOS_ATEND 4 #define _IOS_APPEND 8 #define _IOS_TRUNC 16 #define _IOS_NOCREATE 32 #define _IOS_NOREPLACE 64 #define _IOS_BIN 128 /* Magic numbers and bits for the _flags field. The magic numbers use the high-order bits of _flags; the remaining bits are abailable for variable flags. Note: The magic numbers must all be negative if stdio emulation is desired. */ #define _IO_MAGIC 0xFBAD0000 /* Magic number */ #define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */ #define _IO_MAGIC_MASK 0xFFFF0000 #define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */ #define _IO_UNBUFFERED 2 #define _IO_NO_READS 4 /* Reading not allowed */ #define _IO_NO_WRITES 8 /* Writing not allowd */ #define _IO_EOF_SEEN 0x10 #define _IO_ERR_SEEN 0x20 #define _IO_DELETE_DONT_CLOSE 0x40 #define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/ #define _IO_IN_BACKUP 0x100 #define _IO_LINE_BUF 0x200 #define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */ #define _IO_CURRENTLY_PUTTING 0x800 #define _IO_IS_APPENDING 0x1000 #define _IO_IS_FILEBUF 0x2000 /* These are "formatting flags" matching the iostream fmtflags enum values. */ #define _IO_SKIPWS 01 #define _IO_LEFT 02 #define _IO_RIGHT 04 #define _IO_INTERNAL 010 #define _IO_DEC 020 #define _IO_OCT 040 #define _IO_HEX 0100 #define _IO_SHOWBASE 0200 #define _IO_SHOWPOINT 0400 #define _IO_UPPERCASE 01000 #define _IO_SHOWPOS 02000 #define _IO_SCIENTIFIC 04000 #define _IO_FIXED 010000 #define _IO_UNITBUF 020000 #define _IO_STDIO 040000 #define _IO_DONT_CLOSE 0100000 /* A streammarker remembers a position in a buffer. */ struct _IO_jump_t; struct _IO_FILE; struct _IO_marker { struct _IO_marker *_next; struct _IO_FILE *_sbuf; /* If _pos >= 0 it points to _buf->Gbase()+_pos. FIXME comment */ /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */ int _pos; #if 0 void set_streampos(streampos sp) { _spos = sp; } void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); } public: streammarker(streambuf *sb); ~streammarker(); int saving() { return _spos == -2; } int delta(streammarker&); int delta(); #endif }; struct _IO_FILE { int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ #define _IO_file_flags _flags /* The following pointers correspond to the C++ streambuf protocol. */ char* _IO_read_ptr; /* Current read pointer */ char* _IO_read_end; /* End of get area. */ char* _IO_read_base; /* Start of putback+get area. */ char* _IO_write_base; /* Start of put area. */ char* _IO_write_ptr; /* Current put pointer. */ char* _IO_write_end; /* End of put area. */ char* _IO_buf_base; /* Start of reserve area. */ char* _IO_buf_end; /* End of reserve area. */ /* The following fields are used to support backing up and undo. */ char *_IO_save_base; /* Pointer to start of non-current get area. */ char *_IO_backup_base; /* Pointer to first valid character of backup area */ char *_IO_save_end; /* Pointer to end of non-current get area. */ /* These names are temporary aliases. TODO */ #define _other_gbase _IO_save_base #define _aux_limit _IO_backup_base #define _other_egptr _IO_save_end struct _IO_marker *_markers; struct _IO_FILE *_chain; struct _IO_jump_t *_jumps; /* Jump table */ int _fileno; int _blksize; _IO_off_t _offset; #define __HAVE_COLUMN /* temporary */ /* 1+column number of pbase(); 0 is unknown. */ unsigned short _cur_column; char _unused; char _shortbuf[1]; /* char* _save_gptr; char* _save_egptr; */ }; #ifndef __cplusplus typedef struct _IO_FILE _IO_FILE; #endif /* We always allocate an extra word following an _IO_FILE. This is for compatibility with C++ streambuf; the word can be used to smash to a pointer to a virtual function table. */ struct _IO_FILE_plus { _IO_FILE _file; __const void *_vtable; }; extern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_; #define _IO_stdin (&_IO_stdin_._file) #define _IO_stdout (&_IO_stdout_._file) #define _IO_stderr (&_IO_stderr_._file) #ifdef __cplusplus extern "C" { #endif extern int __underflow __P((_IO_FILE*)); extern int __overflow __P((_IO_FILE*, int)); extern unsigned __adjust_column __P((unsigned start, __const char *line, int count)); #define _IO_getc(_fp) \ ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \ && __underflow(_fp) == EOF ? EOF \ : *(unsigned char*)(_fp)->_IO_read_ptr++) #define _IO_peekc(_fp) \ ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \ && __underflow(_fp) == EOF ? EOF \ : *(unsigned char*)(_fp)->_IO_read_ptr) #define _IO_putc(_ch, _fp) \ (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \ ? __overflow(_fp, (unsigned char)(_ch)) \ : (unsigned char)(*(_fp)->_IO_write_ptr++ = (_ch))) /* This one is for Emacs. */ #define _IO_PENDING_OUTPUT_COUNT(_fp) \ ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base) extern int _IO_vfscanf __P((_IO_FILE*, __const char*, _IO_va_list, int*)); extern int _IO_vfprintf __P((_IO_FILE*, __const char*, _IO_va_list)); extern _IO_ssize_t _IO_padn __P((_IO_FILE *, int, _IO_ssize_t)); extern _IO_size_t _IO_sgetn __P((_IO_FILE *, void*, _IO_size_t)); extern void _IO_free_backup_area __P((_IO_FILE*)); #ifdef __cplusplus } #endif #endif /* _IO_STDIO_H */ ./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/config.shared100644 1676 334 26123 5505474742 14707 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. # Significant variables: test -z "${TO_TOPDIR}" && TO_TOPDIR=${TOLIBGXX}../ DOING_LIBGXX=${DOING_LIBGXX-false} THIS_FILE="${srcdir}/${TOLIBGXX}config.shared" echo "# Start of package fragment generated by ${THIS_FILE}." # TOLIBGXX # MOSTLYCLEAN # CLEAN # DISTCLEAN # REALCLEAN # SUBDIRS [defaults to (configdirs)] # INFO_FILES List of (basenames of) texinfo files # INFO_SUBDIRS [default: empty] sub-directories containing documentation rootme=${rootme-`pwd`} TOPDIR=${TOPDIR='$${rootme}'${TO_TOPDIR}} echo '#' TOPDIR="${TOPDIR} invsubdir=${invsubdir} subdir=${subdir}" SUBDIRS=${SUBDIRS-${configdirs}} echo "srcdir = ${srcdir}" echo "SUBDIRS = ${SUBDIRS}" echo "prefix = ${prefix-/usr/local}" echo "exec_prefix = ${exec_prefix-'${prefix}'}" echo 'bindir = $(exec_prefix)/bin' echo 'libdir = $(exec_prefix)/lib' echo 'datadir = $(prefix)/lib' echo 'mandir = $(prefix)/man' echo 'man1dir = $(mandir)/man1' echo 'man2dir = $(mandir)/man2' echo 'man3dir = $(mandir)/man3' echo 'man4dir = $(mandir)/man4' echo 'man5dir = $(mandir)/man5' echo 'man6dir = $(mandir)/man6' echo 'man7dir = $(mandir)/man7' echo 'man8dir = $(mandir)/man8' echo 'man9dir = $(mandir)/man9' echo 'infodir = $(prefix)/info' echo 'includedir = $(prefix)/include' echo 'gxx_includedir = $(libdir)/g++-include' echo 'docdir = $(datadir)/doc' echo '' echo 'SHELL = /bin/sh' echo '' case "$srcdir" in /*) echo 'INSTALL = $(srcdir)'/"${TO_TOPDIR}install.sh -c" ;; *) echo 'INSTALL = ${rootme}$(srcdir)'/"${TO_TOPDIR}install.sh -c" ;; esac echo 'INSTALL_PROGRAM = $(INSTALL)' echo 'INSTALL_DATA = $(INSTALL)' echo '' echo 'AR = `if [ -f' ${TOPDIR}'binutils/ar ] ; \' echo " then echo ${TOPDIR}binutils/ar ; "'\' echo ' else echo ar ; fi`' echo 'AR_FLAGS = rc' echo 'RANLIB = `if [ -f' ${TOPDIR}'binutils/ranlib ] ; \' echo ' then echo '${TOPDIR}'binutils/ranlib ; \' echo ' else echo ranlib ; fi`' echo 'NM = `if [ -f' ${TOPDIR}'binutils/nm ] ; \' echo ' then echo '${TOPDIR}'binutils/nm ; \' echo ' else echo nm ; fi`' echo '' echo 'MAKEINFO = `if [ -f '${TOPDIR}'texinfo/C/makeinfo ] ; \' echo ' then echo '${TOPDIR}'texinfo/C/makeinfo ; \' echo ' else echo makeinfo ; fi`' echo 'TEXIDIR=${srcdir}/'"${TO_TOPDIR}/texinfo" echo 'TEXI2DVI = TEXINPUTS=${TEXIDIR}:$$TEXINPUTS texi2dvi' echo '' echo 'CC = `if [ -f '${TOPDIR}'gcc/xgcc ] ; \' echo ' then echo '${TOPDIR}'gcc/xgcc -B'${TOPDIR}'gcc/ ; \' echo ' else echo cc ; fi`' echo 'CXX = `if [ -f '${TOPDIR}'gcc/xgcc ] ; \' echo ' then echo '${TOPDIR}'gcc/xgcc -B'${TOPDIR}'gcc/ ; \' echo ' else echo gcc ; fi`' echo '' echo 'XTRAFLAGS = `if [ -f '${TOPDIR}'gcc/xgcc ] ;\' echo ' then echo -I'${TOPDIR}'gcc/include;\' echo ' else echo ; fi`' # FIXME!!! if true ; then echo 'WRAP_C_INCLUDES =' else echo 'WRAP_C_INCLUDES = -I$(srcdir)'/${TOLIBGXX}g++-include fi echo 'CFLAGS = -g' echo 'CXXFLAGS = -g -O' if test "${DOING_LIBGXX}" = "true" ; then echo 'PROTODIR = $(srcdir)'/${TOLIBGXX}src/gen echo "LIBS = ${TOLIBGXX}libg++.a" # You can override iostream (e.g. in a site- or host-Makefile fragment) to: # iostream (Normal iostream library) # old-stream (Old stream library; no longer supported) # no-stream (If you don't want iostream to be part of libg++) echo 'IO_DIR = ../libio' echo '# IO_DIR = no-stream' fi if [ -z "${ALL}" ] ; then if [ -n "${TARGETLIB}" ] ; then ALL='$(TARGETLIB)' echo "TARGETLIB = ${TARGETLIB}" elif [ -n "${TARGETPROG}" ] ; then ALL='${TARGETPROG}' echo "TARGETPROG = ${TARGETPROG}" else echo "config error: neither ALL, TARGETLIB or TARGETPROG is defined" 1>&2 fi fi echo '.PHONY: all' echo "all: ${ALL}" if [ "${SUBDIRS}" != "" ] ; then echo ' @rootme=`pwd`/; export rootme; \' echo ' $(MAKE) "DODIRS=$(SUBDIRS)" DO=all $(FLAGS_TO_PASS) subdir_do' fi echo '' echo if [ "${SUBDIRS}" != "" ] ; then echo '.PHONY: subdir_do' echo 'subdir_do: force' echo ' @rootme=`pwd`/; export rootme; \' echo ' for i in $(DODIRS); do \' echo ' if [ -f ./$$i/Makefile ] ; then \' echo ' echo "cd $$i; make $(DO) ..." ; \' echo ' (cd $$i ; $(MAKE) $(FLAGS_TO_PASS) $(DO)) || exit 1 ; \' echo ' else true ; fi ; \' echo ' done' echo '' echo '# List of variables to pass to sub-makes. This should not be needed' echo '# by GNU make or Sun make (both of which pass command-line variable' echo '# overrides thouh $(MAKE)) but may be needed by older versions.' echo '' echo 'FLAGS_TO_PASS= \' echo ' "INSTALL=$(INSTALL)" \' echo ' "INSTALL_DATA=$(INSTALL_DATA)" \' echo ' "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \' echo ' "prefix=$(prefix)" \' echo ' "exec_prefix=$(exec_prefix)" \' echo ' "tooldir=$(tooldir)" \' echo ' "AR=$(AR)" \' echo ' "AR_FLAGS=$(AR_FLAGS)" \' echo ' "CC=$(CC)" \' echo ' "CXX=$(CXX)" \' echo ' "CFLAGS=$(CFLAGS)" \' echo ' "CXXFLAGS=$(CXXFLAGS)" \' echo ' "RANLIB=$(RANLIB)" \' echo ' "LOADLIBES=$(LOADLIBES)" \' echo ' "LDFLAGS=$(LDFLAGS)" \' echo ' "MAKEINFO=$(MAKEINFO)" \' echo ' "XTRAFLAGS=$(XTRAFLAGS)"' fi if test -n "${CXXINCLUDES}" ; then echo "CXXINCLUDES = ${CXXINCLUDES}" '$(XTRAFLAGS)' elif test "${DOING_LIBGXX}" = "true" ; then echo 'CXXINCLUDES = $(NOSTDINC)'" -I. -I${TO_TOPDIR}libio"' -I$(srcdir) -I$(srcdir)/'"${TOLIBGXX}"'$(IO_DIR) -I$(srcdir)/'"${TOLIBGXX}src"' $(WRAP_C_INCLUDES) $(XTRAFLAGS)' fi if test -n "${CINCLUDES}" ; then echo "CINCLUDES = ${CINCLUDES}" '$(XTRAFLAGS)' elif test "${DOING_LIBGXX}" = "true" ; then echo 'CINCLUDES = $(XTRAFLAGS)' fi echo '.SUFFIXES: .o .C .cc' echo '.c.o:' echo ' $(CC) -c $(CFLAGS) $(CINCLUDES) $<' [ "${TOUCH_ON_COMPILE}" = "yes" ] && echo ' @touch stamp' echo '.C.o:' echo ' $(CXX) -c $(CXXFLAGS) $(CXXINCLUDES) $<' [ "${TOUCH_ON_COMPILE}" = "yes" ] && echo ' @touch stamp' echo '.cc.o:' echo ' $(CXX) -c $(CXXFLAGS) $(CXXINCLUDES) $<' [ "${TOUCH_ON_COMPILE}" = "yes" ] && echo ' @touch stamp' echo '' if [ -n "${TARGETLIB}" ] ; then echo TARGETLIB = ${TARGETLIB} fi if [ -n "${TARGETPROG}" ] ; then echo TARGETPROG = ${TARGETPROG} fi echo '' echo '.PHONY: install' echo 'install:' echo '.PHONY: check' if [ "${CHECK}" != "check" ] ; then echo "check: ${ALL} ${CHECK}" if [ "${SUBDIRS}" != "" ] ; then echo ' @rootme=`pwd`/; export rootme; \' echo ' $(MAKE) "DODIRS=$(SUBDIRS)" DO=check $(FLAGS_TO_PASS) subdir_do' fi fi # Generate rules for documentation (depending on INFO_FILES and INFO_SUBDIRS). echo '.PHONY: info dvi install-info clean-info' # emit the rule for 'info' if [ -z "${INFO_FILES}" ] ; then echo 'info:' else echo info: `for file in ${INFO_FILES} ; do echo $file.info ; done` fi if [ "${INFO_SUBDIRS}" != "" ] ; then echo ' @rootme=`pwd`/; export rootme; \ $(MAKE) "DODIRS='${INFO_SUBDIRS}'" DO=info $(FLAGS_TO_PASS) subdir_do' fi # emit the rule for 'dvi' if [ -z "${INFO_FILES}" ] ; then echo 'dvi:' else echo dvi: `for file in ${INFO_FILES} ; do echo $file.dvi ; done` fi if [ "${INFO_SUBDIRS}" != "" ] ; then echo ' @rootme=`pwd`/; export rootme; \ $(MAKE) "DODIRS='${INFO_SUBDIRS}'" DO=dvi $(FLAGS_TO_PASS) subdir_do' fi # Emit rules for each *.info and *.dvi file for file in ${INFO_FILES} ; do echo ${file}.info: '$(srcdir)'/${file}.texi echo ' $(MAKEINFO) -I$(srcdir) -I$(TEXIDIR) $(srcdir)/'${file}.texi -o ${file}.info echo ${file}.dvi: '$(srcdir)'/${file}.texi echo ' $(TEXI2DVI) $(srcdir)'/${file}.texi echo "${file}.ps: ${file}.dvi" echo " dvips ${file} -o" done # emit the rule for install-info echo 'install-info:' if [ -n "${INFO_FILES}" ] ; then echo ' -parent=`echo $(infodir)|sed -e' "'"'s@/[^/]*$$@@'"'"'`; \' echo ' if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi' echo ' -if [ -d $(infodir) ] ; then true ; else mkdir $(infodir) ; fi' echo ' for i in *.info* ; do \' echo ' $(INSTALL_DATA) $$i $(infodir)/$$i ; \' echo ' done' fi if [ "${INFO_SUBDIRS}" != "" ] ; then echo ' @rootme=`pwd`/; export rootme; \ $(MAKE) "DODIRS='${INFO_SUBDIRS}'" DO=install-info $(FLAGS_TO_PASS) subdir_do' fi # emit clean-info and clean-dvi rules echo '.PHONY: do-clean-info clean-info do-clean-dvi clean-dvi' echo do-clean-info: if [ -n "${INFO_FILES}" ] ; then echo ' rm -f *.info*' fi echo 'do-clean-dvi:' if [ -n "${INFO_FILES}" ] ; then echo ' rm -f *.dvi *.aux *.cp *.fn* *.ky *.log *.pg *.toc *.tp *.vr' fi for type in info dvi ; do echo clean-${type}: do-clean-${type} if [ "${INFO_SUBDIRS}" != "" ] ; then echo ' @rootme=`pwd`/; export rootme; \ $(MAKE) "DODIRS='${NFO_SUBDIRS}'" DO=clean-'${type} '$(FLAGS_TO_PASS) subdir_do' fi done echo '' echo '.PHONY: boltcc' echo 'boltcc:' echo ' rootme=`pwd`/ ; export rootme ; $(MAKE) $(FLAGS_TO_PASS)' echo '' # Emit clean rules echo '' echo '# clean rules' MOSTLYCLEAN="${MOSTLYCLEAN-*.o core} `if test -n "${TOUCH_ON_COMPILE}"; then echo stamp; else true; fi`" CLEAN="${CLEAN-${TARGETPROG} ${TARGETLIB}}" DISTCLEAN="${DISTCLEAN-config.status Makefile *~ Make.pack}" REALCLEAN="${REALCLEAN-depend *.info*}" echo '.PHONY: mostlyclean clean distclean realclean' if test -z "${SUBDIRS}" ; then echo "mostlyclean: clean-dvi" echo " rm -rf ${MOSTLYCLEAN}" echo "clean: clean-dvi" echo " rm -rf ${MOSTLYCLEAN} ${CLEAN}" echo "distclean: clean" echo " rm -rf ${DISTCLEAN}" echo "realclean: clean clean-info" echo " rm -rf ${DISTCLEAN} ${REALCLEAN}" else echo '.PHONY: do-clean subdir_distclean subdir_realclean' echo "mostlyclean: do-clean-dvi" echo " rm -rf ${MOSTLYCLEAN}" echo ' @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=mostlyclean subdir_do' echo "do-clean: do-clean-dvi" echo " rm -rf ${MOSTLYCLEAN} ${CLEAN}" echo "clean: do-clean" echo ' @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=clean subdir_do' # distclean and realclean are tricky because they remove the Makefile. echo "subdir_distclean:" echo ' @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=distclean subdir_do' echo "distclean: do-clean subdir_distclean" echo " rm -rf ${DISTCLEAN}" echo "subdir_realclean:" echo ' @$(MAKE) $(FLAGS_TO_PASS) "DODIRS=$(SUBDIRS)" DO=realclean subdir_do' echo "realclean: do-clean subdir_realclean do-clean-info" echo " rm -rf ${DISTCLEAN} ${REALCLEAN}" fi echo '' echo '.PHONY: force' echo 'force:' echo '' echo '# with the gnu make, this is done automatically.' echo '' echo 'Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)' echo ' $(SHELL) ./config.status' echo '' echo '.NOEXPORT:' echo 'MAKEOVERRIDES=' if [ -f ${srcdir}/${subdir}/depend ] ; then cat ${srcdir}/${subdir}/depend fi echo "# End of package fragment generated by ${THIS_FILE}." ./libc-linux/libio/configure.in100644 1676 334 3004 5505474762 14536 0ustar hjlisl# This file is a shell script fragment that supplies the information # necessary for a configure script to process the program in # this directory. For more information, look at ../configure. configdirs="tests dbz stdio" srctrigger=libioP.h srcname="input/output library" package_makefile_frag=Make.pack # per-host: # per-target: : >${package_makefile_frag} case "${target}" in *-*-hpux*) my_target=hpux ;; *linux*) my_target=linux cat > ${package_makefile_frag} <>${package_makefile_frag} # post-target: # If cross-compiling, don't build gperf or the utils. They # will get built by the target compiler, which is confusing. # We cannot test the installation. We install in $(tooldir). if [ ${host} != ${target} ] ; then sed \ -e 's|INSTALLDIR.*=.*$|INSTALLDIR = $(tooldir)/lib|' \ Makefile >Makefile.tem mv -f Makefile.tem Makefile fi ./libc-linux/libio/iovfscanf.c100644 1676 334 45417 5501527025 14370 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. */ /* * Copyright (c) 1990 The 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* Extensively hacked for GNU iostream by Per Bothner 1991, 1992, 1993. Changes copyright Free Software Foundation 1992, 1993. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #include #include #ifdef __STDC__ #include #else #include #endif #ifndef NO_FLOATING_POINT #define FLOATING_POINT #endif #ifdef FLOATING_POINT #include "floatio.h" #define BUF (MAXEXP+MAXFRACT+3) /* 3 = sign + decimal point + NUL */ #else #define BUF 40 #endif /* * Flags used during conversion. */ #define LONG 0x01 /* l: long or double */ #define LONGDBL 0x02 /* L: long double; unimplemented */ #define SHORT 0x04 /* h: short */ #define SUPPRESS 0x08 /* suppress assignment */ #define POINTER 0x10 /* weird %p pointer (`fake hex') */ #define NOSKIP 0x20 /* do not skip blanks */ #define WIDTH 0x40 /* width */ /* * The following are used in numeric conversions only: * SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point; * SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral. */ #define SIGNOK 0x40 /* +/- is (still) legal */ #define NDIGITS 0x80 /* no digits detected */ #define DPTOK 0x100 /* (float) decimal point is still legal */ #define EXPOK 0x200 /* (float) exponent (e+3, etc) still legal */ #define PFXOK 0x100 /* 0x prefix is (still) legal */ #define NZDIGITS 0x200 /* no zero digits detected */ /* * Conversion types. */ #define CT_CHAR 0 /* %c conversion */ #define CT_CCL 1 /* %[...] conversion */ #define CT_STRING 2 /* %s conversion */ #define CT_INT 3 /* integer, i.e., strtol or strtoul */ #define CT_FLOAT 4 /* floating, i.e., strtod */ #define u_char unsigned char #define u_long unsigned long extern u_long strtoul __P((const char*, char**, int)); extern long strtol __P((const char*, char**, int)); static const u_char *__sccl __P((char *tab, const u_char *fmt)); #ifndef USE_DTOA extern double atof(); #endif /* If errp != NULL, *errp|=1 if we see a premature EOF; *errp|=2 if we an invalid character. */ int _IO_vfscanf(fp, fmt0, ap, errp) register _IO_FILE *fp; char const *fmt0; _IO_va_list ap; int *errp; { register const u_char *fmt = (const u_char *)fmt0; register int c; /* character from format, or conversion */ register _IO_ssize_t width; /* field width, or 0 */ register char *p; /* points into all kinds of strings */ register int n; /* handy integer */ register int flags = 0; /* flags as defined above */ register char *p0; /* saves original value of p when necessary */ int nassigned; /* number of fields assigned */ int nread; /* number of characters consumed from fp */ /* Assignments to base and ccfn are just to suppress warnings from gcc.*/ int base = 0; /* base argument to strtol/strtoul */ typedef u_long (*strtoulfn) __P((const char*, char**, int)); strtoulfn ccfn = 0; /* conversion function (strtol/strtoul) */ char ccltab[256]; /* character class table for %[...] */ char buf[BUF]; /* buffer for numeric conversions */ int seen_eof = 0; /* `basefix' is used to avoid `if' tests in the integer scanner */ static short basefix[17] = { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; nassigned = 0; nread = 0; for (;;) { c = *fmt++; if (c == 0) goto done; if (isspace(c)) { for (;;) { c = _IO_getc(fp); if (c == EOF) { seen_eof++; break; } if (!isspace(c)) { _IO_ungetc (c, fp); break; } nread++; } continue; } if (c != '%') goto literal; width = 0; flags = 0; /* * switch on the format. continue if done; * break once format type is derived. */ again: c = *fmt++; switch (c) { case '%': literal: n = _IO_getc(fp); if (n == EOF) goto eof_failure; if (n != c) { _IO_ungetc (n, fp); goto match_failure; } nread++; continue; case '*': if (flags) goto control_failure; flags = SUPPRESS; goto again; case 'l': if (flags & ~(SUPPRESS | WIDTH)) goto control_failure; flags |= LONG; goto again; case 'L': if (flags & ~(SUPPRESS | WIDTH)) goto control_failure; flags |= LONGDBL; goto again; case 'h': if (flags & ~(SUPPRESS | WIDTH)) goto control_failure; flags |= SHORT; goto again; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (flags & ~(SUPPRESS | WIDTH)) goto control_failure; flags |= WIDTH; width = width * 10 + c - '0'; goto again; /* * Conversions. * Those marked `compat' are for 4.[123]BSD compatibility. * * (According to ANSI, E and X formats are supposed * to the same as e and x. Sorry about that.) */ case 'D': /* compat */ flags |= LONG; /* FALLTHROUGH */ case 'd': c = CT_INT; ccfn = (strtoulfn)strtol; base = 10; break; case 'i': c = CT_INT; ccfn = (strtoulfn)strtol; base = 0; break; case 'O': /* compat */ flags |= LONG; /* FALLTHROUGH */ case 'o': c = CT_INT; ccfn = strtoul; base = 8; break; case 'u': c = CT_INT; ccfn = strtoul; base = 10; break; case 'X': case 'x': flags |= PFXOK; /* enable 0x prefixing */ c = CT_INT; ccfn = strtoul; base = 16; break; #ifdef FLOATING_POINT case 'E': case 'F': case 'e': case 'f': case 'g': c = CT_FLOAT; break; #endif case 's': c = CT_STRING; break; case '[': fmt = __sccl(ccltab, fmt); flags |= NOSKIP; c = CT_CCL; break; case 'c': flags |= NOSKIP; c = CT_CHAR; break; case 'p': /* pointer format is like hex */ flags |= POINTER | PFXOK; c = CT_INT; ccfn = strtoul; base = 16; break; case 'n': if (flags & SUPPRESS) /* ??? */ continue; if (flags & SHORT) *va_arg(ap, short *) = nread; else if (flags & LONG) *va_arg(ap, long *) = nread; else *va_arg(ap, int *) = nread; continue; /* * Disgusting backwards compatibility hacks. XXX */ case '\0': /* compat */ nassigned = EOF; goto done; default: /* compat */ if (isupper(c)) flags |= LONG; c = CT_INT; ccfn = (strtoulfn)strtol; base = 10; break; } /* * We have a conversion that requires input. */ if (_IO_peekc(fp) == EOF) goto eof_failure; /* * Consume leading white space, except for formats * that suppress this. */ if ((flags & NOSKIP) == 0) { n = (unsigned char)*fp->_IO_read_ptr; while (isspace(n)) { fp->_IO_read_ptr++; nread++; n = _IO_peekc(fp); if (n == EOF) goto eof_failure; } /* Note that there is at least one character in the buffer, so conversions that do not set NOSKIP can no longer result in an input failure. */ } /* * Do the conversion. */ switch (c) { case CT_CHAR: /* scan arbitrary characters (sets NOSKIP) */ if (width == 0) /* FIXME! */ width = 1; if (flags & SUPPRESS) { _IO_size_t sum = 0; for (;;) { n = fp->_IO_read_end - fp->_IO_read_ptr; if (n < (int)width) { sum += n; width -= n; fp->_IO_read_ptr += n; if (__underflow(fp) == EOF) if (sum == 0) goto eof_failure; else { seen_eof++; break; } } else { sum += width; fp->_IO_read_ptr += width; break; } } nread += sum; } else { _IO_size_t r = (*fp->_jumps->__xsgetn)(fp, (char*)va_arg(ap, char*), width); if (r != width) goto eof_failure; nread += r; nassigned++; } break; case CT_CCL: /* scan a (nonempty) character class (sets NOSKIP) */ if (width == 0) width = ~0; /* `infinity' */ /* take only those things in the class */ if (flags & SUPPRESS) { n = 0; while (ccltab[(unsigned char)*fp->_IO_read_ptr]) { n++, fp->_IO_read_ptr++; if (--width == 0) break; if (_IO_peekc(fp) == EOF) { if (n == 0) goto eof_failure; seen_eof++; break; } } if (n == 0) goto match_failure; } else { p0 = p = va_arg(ap, char *); while (ccltab[(unsigned char)*fp->_IO_read_ptr]) { *p++ = *fp->_IO_read_ptr++; if (--width == 0) break; if (_IO_peekc(fp) == EOF) { if (p == p0) goto eof_failure; seen_eof++; break; } } n = p - p0; if (n == 0) goto match_failure; *p = 0; nassigned++; } nread += n; break; case CT_STRING: /* like CCL, but zero-length string OK, & no NOSKIP */ if (width == 0) width = ~0; if (flags & SUPPRESS) { n = 0; while (!isspace((unsigned char)*fp->_IO_read_ptr)) { n++, fp->_IO_read_ptr++; if (--width == 0) break; if (_IO_peekc(fp) == EOF) { seen_eof++; break; } } nread += n; } else { p0 = p = va_arg(ap, char *); while (!isspace((unsigned char)*fp->_IO_read_ptr)) { *p++ = *fp->_IO_read_ptr++; if (--width == 0) break; if (_IO_peekc(fp) == EOF) { seen_eof++; break; } } *p = 0; nread += p - p0; nassigned++; } continue; case CT_INT: /* scan an integer as if by strtol/strtoul */ if (width == 0 || width > sizeof(buf) - 1) width = sizeof(buf) - 1; flags |= SIGNOK | NDIGITS | NZDIGITS; for (p = buf; width; width--) { c = (unsigned char)*fp->_IO_read_ptr; /* * Switch on the character; `goto ok' * if we accept it as a part of number. */ switch (c) { /* * The digit 0 is always legal, but is * special. For %i conversions, if no * digits (zero or nonzero) have been * scanned (only signs), we will have * base==0. In that case, we should set * it to 8 and enable 0x prefixing. * Also, if we have not scanned zero digits * before this, do not turn off prefixing * (someone else will turn it off if we * have scanned any nonzero digits). */ case '0': if (base == 0) { base = 8; flags |= PFXOK; } if (flags & NZDIGITS) flags &= ~(SIGNOK|NZDIGITS|NDIGITS); else flags &= ~(SIGNOK|PFXOK|NDIGITS); goto ok; /* 1 through 7 always legal */ case '1': case '2': case '3': case '4': case '5': case '6': case '7': base = basefix[base]; flags &= ~(SIGNOK | PFXOK | NDIGITS); goto ok; /* digits 8 and 9 ok iff decimal or hex */ case '8': case '9': base = basefix[base]; if (base <= 8) break; /* not legal here */ flags &= ~(SIGNOK | PFXOK | NDIGITS); goto ok; /* letters ok iff hex */ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': /* no need to fix base here */ if (base <= 10) break; /* not legal here */ flags &= ~(SIGNOK | PFXOK | NDIGITS); goto ok; /* sign ok only as first character */ case '+': case '-': if (flags & SIGNOK) { flags &= ~SIGNOK; goto ok; } break; /* x ok iff flag still set & 2nd char */ case 'x': case 'X': if (flags & PFXOK && p == buf + 1) { base = 16; /* if %i */ flags &= ~PFXOK; goto ok; } break; } /* * If we got here, c is not a legal character * for a number. Stop accumulating digits. */ break; ok: /* * c is legal: store it and look at the next. */ *p++ = c; fp->_IO_read_ptr++; if (_IO_peekc(fp) == EOF) { seen_eof++; break; /* EOF */ } } /* * If we had only a sign, it is no good; push * back the sign. If the number ends in `x', * it was [sign] '0' 'x', so push back the x * and treat it as [sign] '0'. */ if (flags & NDIGITS) { if (p > buf) (void) _IO_ungetc(*(u_char *)--p, fp); goto match_failure; } c = ((u_char *)p)[-1]; if (c == 'x' || c == 'X') { --p; (void) _IO_ungetc (c, fp); } if ((flags & SUPPRESS) == 0) { u_long res; *p = 0; res = (*ccfn)(buf, (char **)NULL, base); if (flags & POINTER) *va_arg(ap, void **) = (void *)res; else if (flags & SHORT) *va_arg(ap, short *) = res; else if (flags & LONG) *va_arg(ap, long *) = res; else *va_arg(ap, int *) = res; nassigned++; } nread += p - buf; break; #ifdef FLOATING_POINT case CT_FLOAT: /* scan a floating point number as if by strtod */ if (width == 0 || width > sizeof(buf) - 1) width = sizeof(buf) - 1; flags |= SIGNOK | NDIGITS | DPTOK | EXPOK; for (p = buf; width; width--) { c = (unsigned char)*fp->_IO_read_ptr; /* * This code mimicks the integer conversion * code, but is much simpler. */ switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': flags &= ~(SIGNOK | NDIGITS); goto fok; case '+': case '-': if (flags & SIGNOK) { flags &= ~SIGNOK; goto fok; } break; case '.': if (flags & DPTOK) { flags &= ~(SIGNOK | DPTOK); goto fok; } break; case 'e': case 'E': /* no exponent without some digits */ if ((flags&(NDIGITS|EXPOK)) == EXPOK) { flags = (flags & ~(EXPOK|DPTOK)) | SIGNOK | NDIGITS; goto fok; } break; } break; fok: *p++ = c; fp->_IO_read_ptr++; if (_IO_peekc(fp) == EOF) { seen_eof++; break; /* EOF */ } } /* * If no digits, might be missing exponent digits * (just give back the exponent) or might be missing * regular digits, but had sign and/or decimal point. */ if (flags & NDIGITS) { if (flags & EXPOK) { /* no digits at all */ while (p > buf) _IO_ungetc (*(u_char *)--p, fp); goto match_failure; } /* just a bad exponent (e and maybe sign) */ c = *(u_char *)--p; if (c != 'e' && c != 'E') { (void) _IO_ungetc (c, fp);/* sign */ c = *(u_char *)--p; } (void) _IO_ungetc (c, fp); } if ((flags & SUPPRESS) == 0) { double res; *p = 0; #ifdef USE_DTOA res = _IO_strtod(buf, NULL); #else res = atof(buf); #endif if (flags & LONG) *va_arg(ap, double *) = res; else *va_arg(ap, float *) = res; nassigned++; } nread += p - buf; break; #endif /* FLOATING_POINT */ } } eof_failure: seen_eof++; control_failure: input_failure: if (nassigned == 0) nassigned = -1; match_failure: if (errp) *errp |= 2; done: if (errp && seen_eof) *errp |= 1; return (nassigned); } /* * Fill in the given table from the scanset at the given format * (just after `['). Return a pointer to the character past the * closing `]'. The table has a 1 wherever characters should be * considered part of the scanset. */ static const u_char *__sccl(tab, fmt) register char *tab; register const u_char *fmt; { register int c, n, v; /* first `clear' the whole table */ c = *fmt++; /* first char hat => negated scanset */ if (c == '^') { v = 1; /* default => accept */ c = *fmt++; /* get new first char */ } else v = 0; /* default => reject */ /* should probably use memset here */ for (n = 0; n < 256; n++) tab[n] = v; if (c == 0) return (fmt - 1);/* format ended before closing ] */ /* * Now set the entries corresponding to the actual scanset * to the opposite of the above. * * The first character may be ']' (or '-') without being special; * the last character may be '-'. */ v = 1 - v; for (;;) { tab[c] = v; /* take character c */ doswitch: n = *fmt++; /* and examine the next */ switch (n) { case 0: /* format ended too soon */ return (fmt - 1); case '-': /* * A scanset of the form * [01+-] * is defined as `the digit 0, the digit 1, * the character +, the character -', but * the effect of a scanset such as * [a-zA-Z0-9] * is implementation defined. The V7 Unix * scanf treats `a-z' as `the letters a through * z', but treats `a-a' as `the letter a, the * character -, and the letter a'. * * For compatibility, the `-' is not considerd * to define a range if the character following * it is either a close bracket (required by ANSI) * or is not numerically greater than the character * we just stored in the table (c). */ n = *fmt; if (n == ']' || n < c) { c = '-'; break; /* resume the for(;;) */ } fmt++; do { /* fill in the range */ tab[++c] = v; } while (c < n); #if 1 /* XXX another disgusting compatibility hack */ /* * Alas, the V7 Unix scanf also treats formats * such as [a-c-e] as `the letters a through e'. * This too is permitted by the standard.... */ goto doswitch; #else c = *fmt++; if (c == 0) return (fmt - 1); if (c == ']') return (fmt); #endif break; case ']': /* end of scanset */ return (fmt); default: /* just another character */ c = n; break; } } /* NOTREACHED */ } ./libc-linux/libio/filedoalloc.c100644 1676 334 7112 5505476216 14646 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. */ /* * Copyright (c) 1990 The 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* Modified for GNU iostream by Per Bothner 1991, 1992. */ #define _POSIX_SOURCE #include "libioP.h" #include #include #include #ifndef __linux__ /* If this function pointer is non-zero, we should call it. It's supposed to make sure _IO_flush_all gets called on exit. We call it from _IO_file_doallocate, since that is likely to get called by any program that does buffered I/O. */ void (*_IO_cleanup_registration_needed)(); #endif /* * Allocate a file buffer, or switch to unbuffered I/O. * Per the ANSI C standard, ALL tty devices default to line buffered. * * As a side effect, we set __SOPT or __SNPT (en/dis-able fseek * optimisation) right after the _fstat() that finds the buffer size. */ int _IO_file_doallocate(fp) register _IO_FILE *fp; { register _IO_size_t size; int couldbetty; register char *p; struct stat st; #ifndef __linux__ if (_IO_cleanup_registration_needed) (*_IO_cleanup_registration_needed)(); #endif if (fp->_fileno < 0 || fp->_jumps->__stat(fp, &st) < 0) { couldbetty = 0; size = _IO_BUFSIZ; #if 0 /* do not try to optimise fseek() */ fp->_flags |= __SNPT; #endif } else { couldbetty = S_ISCHR(st.st_mode); #if _IO_HAVE_ST_BLKSIZE size = st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize; #else size = _IO_BUFSIZ; #endif } #ifdef USE_MALLOC_BUF if ((p = malloc(size)) == NULL) { unbuffered(1); /* FIXME */ /* fp->_bf._IO_buf_base = fp->_p = fp->_nbuf; */ /* fp->_bf._size = 1; */ return EOF; } #else p = ALLOC_BUF(size); #endif _IO_setb(fp, p, p+size, 1); if (couldbetty && isatty(fp->_fileno)) fp->_flags |= _IO_LINE_BUF; return 1; } ./libc-linux/libio/fileops.c100644 1676 334 44574 5523212401 14047 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. */ /* written by Per Bothner (bothner@cygnus.com) */ #define _POSIX_SOURCE #include "libioP.h" #include #include #include #include #include #ifndef errno extern int errno; #endif /* An fstream can be in at most one of put mode, get mode, or putback mode. Putback mode is a variant of get mode. In a filebuf, there is only one current position, instead of two separate get and put pointers. In get mode, the current posistion is that of gptr(); in put mode that of pptr(). The position in the buffer that corresponds to the position in external file system is file_ptr(). This is normally egptr(), except in putback mode, when it is _save_egptr. If the field _fb._offset is >= 0, it gives the offset in the file as a whole corresponding to eGptr(). (???) PUT MODE: If a filebuf is in put mode, pbase() is non-NULL and equal to base(). Also, epptr() == ebuf(). Also, eback() == gptr() && gptr() == egptr(). The un-flushed character are those between pbase() and pptr(). GET MODE: If a filebuf is in get or putback mode, eback() != egptr(). In get mode, the unread characters are between gptr() and egptr(). The OS file position corresponds to that of egptr(). PUTBACK MODE: Putback mode is used to remember "excess" characters that have been sputbackc'd in a separate putback buffer. In putback mode, the get buffer points to the special putback buffer. The unread characters are the characters between gptr() and egptr() in the putback buffer, as well as the area between save_gptr() and save_egptr(), which point into the original reserve buffer. (The pointers save_gptr() and save_egptr() are the values of gptr() and egptr() at the time putback mode was entered.) The OS position corresponds to that of save_egptr(). LINE BUFFERED OUTPUT: During line buffered output, pbase()==base() && epptr()==base(). However, ptr() may be anywhere between base() and ebuf(). This forces a call to filebuf::overflow(int C) on every put. If there is more space in the buffer, and C is not a '\n', then C is inserted, and pptr() incremented. UNBUFFERED STREAMS: If a filebuf is unbuffered(), the _shortbuf[1] is used as the buffer. */ void _IO_file_init(fp) register _IO_FILE *fp; { fp->_offset = _IO_pos_0; _IO_link_in(fp); fp->_fileno = -1; } int _IO_file_close_it(fp) register _IO_FILE* fp; { int status; if (!_IO_file_is_open(fp)) return EOF; /* This flushes as well as switching mode. */ if (fp->_IO_write_ptr > fp->_IO_write_base || _IO_in_put_mode(fp)) if (_IO_switch_to_get_mode(fp)) return EOF; _IO_unsave_markers(fp); status = fp->_jumps->__close(fp); /* Free buffer. */ _IO_setb(fp, NULL, NULL, 0); _IO_setg(fp, NULL, NULL, NULL); _IO_setp(fp, NULL, NULL); _IO_un_link(fp); fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS; fp->_fileno = EOF; fp->_offset = _IO_pos_0; return status; } void _IO_file_finish(fp) register _IO_FILE* fp; { if (!(fp->_flags & _IO_DELETE_DONT_CLOSE)) _IO_file_close_it(fp); _IO_default_finish(fp); } _IO_FILE * _IO_file_fopen(fp, filename, mode) register _IO_FILE *fp; const char *filename; const char *mode; { int oflags = 0, omode; int read_write, fdesc; int oprot = 0666; if (_IO_file_is_open (fp)) return 0; switch (*mode++) { case 'r': omode = O_RDONLY; read_write = _IO_NO_WRITES; break; case 'w': omode = O_WRONLY; oflags = O_CREAT|O_TRUNC; read_write = _IO_NO_READS; break; case 'a': omode = O_WRONLY; oflags = O_CREAT|O_APPEND; read_write = _IO_NO_READS|_IO_IS_APPENDING; break; default: errno = EINVAL; return NULL; } if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) { omode = O_RDWR; read_write &= _IO_IS_APPENDING; } fdesc = open(filename, omode|oflags, oprot); if (fdesc < 0) return NULL; fp->_fileno = fdesc; fp->_IO_file_flags |= CLOSED_FILEBUF_FLAGS; fp->_IO_file_flags = _IO_mask_flags(fp, read_write,_IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); if (read_write & _IO_IS_APPENDING) if (fp->_jumps->__seekoff(fp, (_IO_off_t)0, _IO_seek_end) == _IO_pos_BAD && errno != ESPIPE) return NULL; _IO_link_in(fp); return fp; } _IO_FILE* _IO_file_attach(fp, fd) _IO_FILE *fp; int fd; { #if 1 struct stat st; #endif if (_IO_file_is_open(fp)) return NULL; fp->_fileno = fd; fp->_flags &= ~(_IO_NO_READS+_IO_NO_WRITES); #if 1 /* Get the current position of the file. */ if (fp->_jumps->__stat(fp, &st) == 0 && S_ISREG(st.st_mode)) { fp->_offset = _IO_pos_BAD; if (fp->_jumps->__seekoff(fp, (_IO_off_t) 0, _IO_seek_cur) == _IO_pos_BAD && errno != ESPIPE) return NULL; } #else fp->_offset = _IO_pos_BAD; #endif return fp; } int _IO_file_setbuf(fp, p, len) register _IO_FILE *fp; char* p; _IO_ssize_t len; { if (_IO_default_setbuf(fp, p, len) == EOF) return EOF; fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = fp->_IO_buf_base; _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); return 0; } int _IO_do_write(fp, data, to_do) register _IO_FILE *fp; const char* data; _IO_size_t to_do; { _IO_ssize_t count; if (to_do == 0) return 0; if (fp->_flags & _IO_IS_APPENDING) /* On a system without a proper O_APPEND implementation, you would need to sys_seek(0, SEEK_END) here, but is is not needed nor desirable for Unix- or Posix-like systems. Instead, just indicate that offset (before and after) is unpredictable. */ fp->_offset = _IO_pos_BAD; else if (fp->_IO_read_end != fp->_IO_write_base) { _IO_pos_t new_pos = fp->_jumps->__seek(fp, fp->_IO_write_base - fp->_IO_read_end, 1); if (new_pos == _IO_pos_BAD) return EOF; fp->_offset = new_pos; } count = fp->_jumps->__write(fp, data, to_do); if (fp->_cur_column) fp->_cur_column = _IO_adjust_column(fp->_cur_column - 1, data, to_do) + 1; _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base; fp->_IO_write_end = (fp->_flags & _IO_LINE_BUF+_IO_UNBUFFERED) ? fp->_IO_buf_base : fp->_IO_buf_end; return count != to_do ? EOF : 0; } int _IO_file_underflow(fp) register _IO_FILE *fp; { _IO_ssize_t count; #if 0 /* SysV does not make this test; take it out for compatibility */ if (fp->_flags & _IO_EOF_SEEN) return (EOF); #endif if (fp->_flags & _IO_NO_READS) return EOF; if (fp->_IO_read_ptr < fp->_IO_read_end) return *(unsigned char*)fp->_IO_read_ptr; if (fp->_IO_buf_base == NULL) _IO_doallocbuf(fp); /* Flush all line buffered files before reading. */ /* FIXME This can/should be moved to genops ?? */ if (fp->_flags & (_IO_LINE_BUF|_IO_UNBUFFERED)) _IO_flush_all_linebuffered(); _IO_switch_to_get_mode(fp); count = fp->_jumps->__read(fp, fp->_IO_buf_base, fp->_IO_buf_end - fp->_IO_buf_base); if (count <= 0) { #if 1 /* errno may be changed by the signal handler. when we see * errno == 0, we assume the signal is benign :-(. * * We don't need it any more. H.J. */ #if 1 #define CHECK_ZERO_ERRNO #else #define CHECK_ZERO_ERRNO || errno == 0 #endif #ifdef EAGAIN #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN if (count == 0 CHECK_ZERO_ERRNO || errno == EAGAIN || errno == EWOULDBLOCK) #else if (count == 0 CHECK_ZERO_ERRNO || errno == EAGAIN) #endif #else #ifdef EWOULDBLOCK if (count == 0 CHECK_ZERO_ERRNO || errno == EWOULDBLOCK) #else if (count == 0 CHECK_ZERO_ERRNO) #endif #endif fp->_flags |= _IO_EOF_SEEN; else fp->_flags |= _IO_ERR_SEEN; count = 0; #else if (count == 0) fp->_flags |= _IO_EOF_SEEN; else fp->_flags |= _IO_ERR_SEEN, count = 0; #endif } fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_buf_base; fp->_IO_read_end = fp->_IO_buf_base + count; fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = fp->_IO_buf_base; if (count == 0) return EOF; if (fp->_offset != _IO_pos_BAD) _IO_pos_adjust(fp->_offset, count); return *(unsigned char*)fp->_IO_read_ptr; } int _IO_file_overflow (f, ch) register _IO_FILE* f; int ch; { if (f->_flags & _IO_NO_WRITES) /* SET ERROR */ return EOF; /* If current reading or no buffer allocated. */ if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0) { /* Allocate a buffer if needed. */ if (f->_IO_buf_base == 0) { _IO_doallocbuf(f); f->_IO_read_end = f->_IO_buf_base; f->_IO_write_ptr = f->_IO_buf_base; } else /* Must be currently reading. */ f->_IO_write_ptr = f->_IO_read_ptr; f->_IO_write_base = f->_IO_write_ptr; f->_IO_write_end = f->_IO_buf_end; f->_IO_read_base = f->_IO_read_ptr = f->_IO_read_end; if (f->_flags & _IO_LINE_BUF+_IO_UNBUFFERED) f->_IO_write_end = f->_IO_write_ptr; f->_flags |= _IO_CURRENTLY_PUTTING; } if (ch == EOF) return _IO_do_flush(f); if (f->_IO_write_ptr == f->_IO_buf_end ) /* Buffer is really full */ if (_IO_do_flush(f) == EOF) return EOF; *f->_IO_write_ptr++ = ch; if ((f->_flags & _IO_UNBUFFERED) || ((f->_flags & _IO_LINE_BUF) && ch == '\n')) if (_IO_do_flush(f) == EOF) return EOF; return (unsigned char)ch; } int _IO_file_sync(fp) register _IO_FILE* fp; { _IO_size_t delta; /* char* ptr = cur_ptr(); */ if (fp->_IO_write_ptr > fp->_IO_write_base) if (_IO_do_flush(fp)) return EOF; delta = fp->_IO_read_ptr - fp->_IO_read_end; if (delta != 0) { #ifdef TODO if (_IO_in_backup(fp)) delta -= eGptr() - Gbase(); #endif _IO_off_t new_pos = fp->_jumps->__seek(fp, delta, 1); if (new_pos == (_IO_off_t)EOF) return EOF; fp->_offset = new_pos; fp->_IO_read_end = fp->_IO_read_ptr; } /* FIXME: Cleanup - can this be shared? */ /* setg(base(), ptr, ptr); */ return 0; } _IO_pos_t _IO_file_seekoff(fp, offset, mode) register _IO_FILE *fp; _IO_off_t offset; _IO_seekflags mode; { _IO_pos_t result; _IO_off_t delta, new_offset; long count; int dir = mode & 3; if ((mode & _IO_seek_not_in) && (mode & _IO_seek_not_out)) dir = _IO_seek_cur, offset = 0; /* Don't move any pointers. */ /* Flush unwritten characters. (This may do an unneeded write if we seek within the buffer. But to be able to switch to reading, we would need to set egptr to ptr. That can't be done in the current design, which assumes file_ptr() is eGptr. Anyway, since we probably end up flushing when we close(), it doesn't make much difference.) FIXME: simulate mem-papped files. */ if (fp->_IO_write_ptr > fp->_IO_write_base || _IO_in_put_mode(fp)) if (_IO_switch_to_get_mode(fp)) return EOF; if (fp->_IO_buf_base == NULL) { _IO_doallocbuf(fp); _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base); _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); } switch (dir) { case _IO_seek_cur: if (fp->_offset == _IO_pos_BAD) goto dumb; /* Adjust for read-ahead (bytes is buffer). */ offset -= fp->_IO_read_end - fp->_IO_read_ptr; /* Make offset absolute, assuming current pointer is file_ptr(). */ offset += _IO_pos_as_off(fp->_offset); dir = _IO_seek_set; break; case _IO_seek_set: break; case _IO_seek_end: { struct stat st; if (fp->_jumps->__stat(fp, &st) == 0 && S_ISREG(st.st_mode)) { offset += st.st_size; dir = _IO_seek_set; } else goto dumb; } } /* At this point, dir==_IO_seek_set. */ #ifdef TODO /* If destination is within current buffer, optimize: */ if (fp->_offset != IO_pos_BAD && fp->_IO_read_base != NULL) { /* Offset relative to start of main get area. */ _IO_pos_t rel_offset = offset - _fb._offset + (eGptr()-Gbase()); if (rel_offset >= 0) { if (_IO_in_backup(fp)) _IO_switch_to_main_get_area(fp); if (rel_offset <= _IO_read_end - _IO_read_base) { _IO_setg(fp->_IO_buf_base, fp->_IO_buf_base + rel_offset, fp->_IO_read_end); _IO_setp(fp->_IO_buf_base, fp->_IO_buf_base); return offset; } /* If we have streammarkers, seek forward by reading ahead. */ if (_IO_have_markers(fp)) { int to_skip = rel_offset - (fp->_IO_read_ptr - fp->_IO_read_base); if (ignore(to_skip) != to_skip) goto dumb; return offset; } } if (rel_offset < 0 && rel_offset >= Bbase() - Bptr()) { if (!_IO_in_backup(fp)) _IO_switch_to_backup_area(fp); gbump(fp->_IO_read_end + rel_offset - fp->_IO_read_ptr); return offset; } } _IO_unsave_markers(fp); #endif /* Try to seek to a block boundary, to improve kernel page management. */ new_offset = offset & ~(fp->_IO_buf_end - fp->_IO_buf_base - 1); delta = offset - new_offset; if (delta > fp->_IO_buf_end - fp->_IO_buf_base) { new_offset = offset; delta = 0; } result = fp->_jumps->__seek(fp, new_offset, 0); if (result < 0) return EOF; if (delta == 0) count = 0; else { count = fp->_jumps->__read(fp, fp->_IO_buf_base, fp->_IO_buf_end - fp->_IO_buf_base); if (count < delta) { /* We weren't allowed to read, but try to seek the remainder. */ offset = count == EOF ? delta : delta-count; dir = _IO_seek_cur; goto dumb; } } _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base+delta, fp->_IO_buf_base+count); _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base); fp->_offset = result + count; _IO_mask_flags(fp, 0, _IO_EOF_SEEN); return offset; dumb: _IO_unsave_markers(fp); result = fp->_jumps->__seek(fp, offset, dir); if (result != EOF) _IO_mask_flags(fp, 0, _IO_EOF_SEEN); fp->_offset = result; _IO_setg(fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); _IO_setp(fp, fp->_IO_buf_base, fp->_IO_buf_base); return result; } _IO_ssize_t _IO_file_read(fp, buf, size) register _IO_FILE* fp; void* buf; _IO_ssize_t size; { for (;;) { _IO_ssize_t count = _IO_read(fp->_fileno, buf, size); #ifdef EINTR if (errno == EINTR && count == -1) continue; #endif return count; } } _IO_pos_t _IO_file_seek(fp, offset, dir) _IO_FILE *fp; _IO_off_t offset; int dir; { return _IO_lseek(fp->_fileno, offset, dir); } int _IO_file_stat(fp, st) _IO_FILE *fp; void* st; { return _IO_fstat(fp->_fileno, (struct stat*)st); } int _IO_file_close(fp) _IO_FILE* fp; { return _IO_close(fp->_fileno); } _IO_ssize_t _IO_file_write(f, data, n) register _IO_FILE* f; const void* data; _IO_ssize_t n; { _IO_ssize_t to_do = n; while (to_do > 0) { _IO_ssize_t count = _IO_write(f->_fileno, data, to_do); if (count == EOF) { #ifdef EINTR if (errno == EINTR) continue; else #endif { f->_flags |= _IO_ERR_SEEN; break; } } to_do -= count; data = (void*)((char*)data + count); } n -= to_do; if (f->_offset >= 0) f->_offset += n; return n; } _IO_size_t _IO_file_xsputn(f, data, n) _IO_FILE *f; const void *data; _IO_size_t n; { register const char *s = data; _IO_size_t to_do = n; int must_flush = 0; _IO_ssize_t count; if (n <= 0) return 0; /* This is an optimized implementation. If the amount to be written straddles a block boundary (or the filebuf is unbuffered), use sys_write directly. */ /* First figure out how much space is available in the buffer. */ count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ if ((f->_flags & _IO_LINE_BUF) && (f->_flags & _IO_CURRENTLY_PUTTING)) { count = f->_IO_buf_end - f->_IO_write_ptr; if (count >= n) { register const char *p; for (p = s + n; p > s; ) { if (*--p == '\n') { count = p - s + 1; must_flush = 1; break; } } } } /* Then fill the buffer. */ if (count > 0) { if (count > to_do) count = to_do; if (count > 20) { memcpy(f->_IO_write_ptr, s, count); s += count; } else { register char *p = f->_IO_write_ptr; register int i = (int)count; while (--i >= 0) *p++ = *s++; } f->_IO_write_ptr += count; to_do -= count; } if (to_do + must_flush > 0) { _IO_size_t block_size, dont_write; /* Next flush the (full) buffer. */ if (__overflow(f, EOF) == EOF) return n - to_do; /* Try to maintain alignment: write a whole number of blocks. dont_write is what gets left over. */ block_size = f->_IO_buf_end - f->_IO_buf_base; dont_write = block_size >= 128 ? to_do % block_size : 0; count = to_do - dont_write; if (_IO_do_write(f, s, count) == EOF) return n - to_do; to_do = dont_write; /* Now write out the remainder. Normally, this will fit in the buffer, but it's somewhat messier for line-buffered files, so we let _IO_xsputn handle the general case. */ if (dont_write) to_do -= _IO_default_xsputn(f, s+count, dont_write); } return n - to_do; } struct _IO_jump_t _IO_file_jumps = { _IO_file_overflow, _IO_file_underflow, _IO_file_xsputn, _IO_default_xsgetn, _IO_file_read, _IO_file_write, _IO_file_doallocate, _IO_default_pbackfail, _IO_file_setbuf, _IO_file_sync, _IO_file_finish, _IO_file_close, _IO_file_stat, _IO_file_seek, _IO_file_seekoff, _IO_default_seekpos, }; ./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/floatio.h100644 1676 334 4227 5434302403 14022 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. */ /* * Copyright (c) 1990 The 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * %W% (Berkeley) %G% */ /* * Floating point scanf/printf (input/output) definitions. */ /* 11-bit exponent (VAX G floating point) is 308 decimal digits */ #define MAXEXP 308 /* 128 bit fraction takes up 39 decimal digits; max reasonable precision */ #define MAXFRACT 39 ./libc-linux/libio/genops.c100644 1676 334 42416 5512206721 13700 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. */ /* Generic or default I/O operations. */ #include "libioP.h" #include void _IO_un_link(fp) _IO_FILE *fp; { if (fp->_flags & _IO_LINKED) { _IO_FILE **f; for (f = &_IO_list_all; *f != NULL; f = &(*f)->_chain) { if (*f == fp) { *f = fp->_chain; break; } } fp->_flags &= ~_IO_LINKED; } } void _IO_link_in(fp) _IO_FILE *fp; { if ((fp->_flags & _IO_LINKED) == 0) { fp->_flags |= _IO_LINKED; fp->_chain = _IO_list_all; _IO_list_all = fp; } } /* Return minimum _pos markers Assumes the current get area is the main get area. */ _IO_size_t _IO_least_marker(fp) register _IO_FILE *fp; { _IO_ssize_t least_so_far = fp->_IO_read_end - fp->_IO_read_base; register struct _IO_marker *mark; for (mark = fp->_markers; mark != NULL; mark = mark->_next) if (mark->_pos < least_so_far) least_so_far = mark->_pos; return least_so_far; } /* Switch current get area from backup buffer to (start of) main get area. */ void _IO_switch_to_main_get_area(fp) _IO_FILE *fp; { char *tmp; fp->_flags &= ~_IO_IN_BACKUP; /* Swap _IO_read_end and _IO_save_end. */ tmp = fp->_IO_read_end; fp->_IO_read_end= fp->_IO_save_end; fp->_IO_save_end= tmp; /* Swap _IO_read_base and _IO_save_base. */ tmp = fp->_IO_read_base; fp->_IO_read_base = fp->_IO_save_base; fp->_IO_save_base = tmp; fp->_IO_read_ptr = fp->_IO_read_base; } /* Switch current get area from main get area to (end of) backup area. */ void _IO_switch_to_backup_area(fp) register _IO_FILE *fp; { char *tmp; fp->_flags |= _IO_IN_BACKUP; /* Swap _IO_read_end and _IO_save_end. */ tmp = fp->_IO_read_end; fp->_IO_read_end = fp->_IO_save_end; fp->_IO_save_end = tmp; /* Swap _gbase and _IO_save_base. */ tmp = fp->_IO_read_base; fp->_IO_read_base = fp->_IO_save_base; fp->_IO_save_base = tmp; fp->_IO_read_ptr = fp->_IO_read_end; } int _IO_switch_to_get_mode(fp) register _IO_FILE *fp; { if (fp->_IO_write_ptr > fp->_IO_write_base) if (fp->_jumps->__overflow(fp, EOF) == EOF) return EOF; if (_IO_in_backup(fp)) fp->_IO_read_base = fp->_aux_limit; else { fp->_IO_read_base = fp->_IO_buf_base; if (fp->_IO_write_ptr > fp->_IO_read_end) fp->_IO_read_end = fp->_IO_write_ptr; } fp->_IO_read_ptr = fp->_IO_write_ptr; fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = fp->_IO_read_ptr; fp->_flags &= ~_IO_CURRENTLY_PUTTING; return 0; } void _IO_free_backup_area(fp) register _IO_FILE *fp; { if (_IO_in_backup (fp)) _IO_switch_to_main_get_area(fp); /* Just in case. */ free (fp->_IO_save_base); fp->_IO_save_base = NULL; fp->_IO_save_end = NULL; fp->_aux_limit = NULL; } #if 0 int _IO_switch_to_put_mode(fp) register _IO_FILE *fp; { fp->_IO_write_base = fp->_IO_read_ptr; fp->_IO_write_ptr = fp->_IO_read_ptr; /* Following is wrong if line- or un-buffered? */ fp->_IO_write_end = fp->_flags & _IO_IN_BACKUP ? fp->_IO_read_end : fp->_IO_buf_end; fp->_IO_read_ptr = fp->_IO_read_end; fp->_IO_read_base = fp->_IO_read_end; fp->_flags |= _IO_CURRENTLY_PUTTING; return 0; } #endif int __overflow(f, ch) _IO_FILE *f; int ch; { return f->_jumps->__overflow(f, ch); } int __underflow(fp) _IO_FILE *fp; { if (_IO_in_put_mode(fp)) if (_IO_switch_to_get_mode(fp) == EOF) return EOF; if (fp->_IO_read_ptr < fp->_IO_read_end) return *(unsigned char*)fp->_IO_read_ptr; if (_IO_in_backup(fp)) { _IO_switch_to_main_get_area(fp); if (fp->_IO_read_ptr < fp->_IO_read_end) return *fp->_IO_read_ptr; } if (_IO_have_markers(fp)) { /* Append [_gbase.._IO_read_end] to backup area. */ int least_mark = _IO_least_marker(fp); /* needed_size is how much space we need in the backup area. */ int needed_size = (fp->_IO_read_end - fp->_IO_read_base) - least_mark; int current_Bsize = fp->_IO_save_end - fp->_IO_save_base; int avail; /* Extra space available for future expansion. */ int delta; struct _IO_marker *mark; if (needed_size > current_Bsize) { char *new_buffer; avail = 100; new_buffer = (char*)malloc(avail+needed_size); if (new_buffer == NULL) return EOF; /* FIXME */ if (least_mark < 0) { memcpy(new_buffer + avail, fp->_IO_save_end + least_mark, -least_mark); memcpy(new_buffer +avail - least_mark, fp->_IO_read_base, fp->_IO_read_end - fp->_IO_read_base); } else memcpy(new_buffer + avail, fp->_IO_read_base + least_mark, needed_size); free (fp->_IO_save_base); fp->_IO_save_base = new_buffer; fp->_IO_save_end = new_buffer + avail + needed_size; } else { avail = current_Bsize - needed_size; if (least_mark < 0) { memmove(fp->_IO_save_base + avail, fp->_IO_save_end + least_mark, -least_mark); memcpy(fp->_IO_save_base + avail - least_mark, fp->_IO_read_base, fp->_IO_read_end - fp->_IO_read_base); } else if (needed_size > 0) memcpy(fp->_IO_save_base + avail, fp->_IO_read_base + least_mark, needed_size); } /* FIXME: Dubious arithmetic if pointers are NULL */ fp->_aux_limit = fp->_IO_save_base + avail; /* Adjust all the streammarkers. */ delta = fp->_IO_read_end - fp->_IO_read_base; for (mark = fp->_markers; mark != NULL; mark = mark->_next) mark->_pos -= delta; } else if (_IO_have_backup(fp)) _IO_free_backup_area(fp); return fp->_jumps->__underflow(fp); } void _IO_setb(f, b, eb, a) _IO_FILE *f; char *b; char *eb; int a; { if (f->_IO_buf_base && !(f->_flags & _IO_USER_BUF)) FREE_BUF(f->_IO_buf_base); f->_IO_buf_base = b; f->_IO_buf_end = eb; if (a) f->_flags &= ~_IO_USER_BUF; else f->_flags |= _IO_USER_BUF; } void _IO_doallocbuf(fp) register _IO_FILE *fp; { if (fp->_IO_buf_base) return; if (!(fp->_flags & _IO_UNBUFFERED)) if (fp->_jumps->__doallocate(fp) != EOF) return; _IO_setb(fp, fp->_shortbuf, fp->_shortbuf+1, 0); } int _IO_default_underflow (fp) _IO_FILE *fp; { return EOF; } _IO_size_t _IO_default_xsputn(f, data, n) register _IO_FILE *f; const void *data; _IO_size_t n; { register const char *s = data; register _IO_size_t more = n; if (more <= 0) return 0; for (;;) { _IO_ssize_t count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ if (count > 0) { if (count > more) count = more; if (count > 20) { memcpy(f->_IO_write_ptr, s, count); s += count; f->_IO_write_ptr += count; } else if (count <= 0) count = 0; else { register char *p = f->_IO_write_ptr; register _IO_ssize_t i; for (i = count; --i >= 0; ) *p++ = *s++; f->_IO_write_ptr = p; } more -= count; } if (more == 0 || __overflow(f, (unsigned char)*s++) == EOF) break; more--; } return n - more; } _IO_size_t _IO_sgetn(fp, data, n) _IO_FILE *fp; void *data; _IO_size_t n; { /* FIXME handle putback buffer here! */ return fp->_jumps->__xsgetn(fp, data, n); } _IO_size_t _IO_default_xsgetn(fp, data, n) _IO_FILE *fp; void *data; _IO_size_t n; { register _IO_size_t more = n; register char *s = data; for (;;) { _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr; /* Data available. */ if (count > 0) { if (count > more) count = more; if (count > 20) { memcpy(s, fp->_IO_read_ptr, count); s += count; fp->_IO_read_ptr += count; } else if (count <= 0) count = 0; else { register char *p = fp->_IO_read_ptr; register int i = (int)count; while (--i >= 0) *s++ = *p++; fp->_IO_read_ptr = p; } more -= count; } if (more == 0 || __underflow(fp) == EOF) break; } return n - more; } int _IO_sync(fp) register _IO_FILE *fp; { if (fp->_IO_read_ptr == fp->_IO_read_end && fp->_IO_write_ptr == fp->_IO_write_base) return 0; return EOF; } int _IO_default_setbuf(fp, p, len) register _IO_FILE *fp; char* p; _IO_ssize_t len; { if (fp->_jumps->__sync(fp) == EOF) return EOF; if (p == NULL || len == 0) { fp->_flags |= _IO_UNBUFFERED; _IO_setb(fp, fp->_shortbuf, fp->_shortbuf+1, 0); } else { fp->_flags &= ~_IO_UNBUFFERED; _IO_setb(fp, p, p+len, 0); } fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = 0; fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_read_end = 0; return 0; } _IO_pos_t _IO_default_seekpos(fp, pos, mode) _IO_FILE *fp; _IO_pos_t pos; _IO_seekflags mode; { return fp->_jumps->__seekoff(fp, _IO_pos_as_off(pos), mode); } int _IO_default_doallocate(fp) _IO_FILE *fp; { char *buf = ALLOC_BUF(_IO_BUFSIZ); if (buf == NULL) return EOF; _IO_setb(fp, buf, buf+_IO_BUFSIZ, 1); return 1; } void _IO_init(fp, flags) register _IO_FILE *fp; int flags; { fp->_flags = _IO_MAGIC|flags; fp->_IO_buf_base = NULL; fp->_IO_buf_end = NULL; fp->_IO_read_base = NULL; fp->_IO_read_ptr = NULL; fp->_IO_read_end = NULL; fp->_IO_write_base = NULL; fp->_IO_write_ptr = NULL; fp->_IO_write_end = NULL; fp->_chain = NULL; /* Not necessary. */ fp->_IO_save_base = NULL; fp->_aux_limit = NULL; fp->_IO_save_end = NULL; fp->_markers = NULL; fp->_cur_column = 0; } int _IO_default_sync (fp) _IO_FILE *fp; { return 0; } void _IO_default_finish (fp) _IO_FILE *fp; { struct _IO_marker *mark; if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF)) FREE_BUF(fp->_IO_buf_base); for (mark = fp->_markers; mark != NULL; mark = mark->_next) mark->_sbuf = NULL; free (fp->_IO_save_base); _IO_un_link(fp); } _IO_pos_t _IO_default_seekoff(fp, offset, mode) register _IO_FILE *fp; _IO_off_t offset; _IO_seekflags mode; { return _IO_pos_BAD; } int _IO_sputbackc(fp, c) /* ungetc(c, fp) */ register _IO_FILE *fp; int c; { if (fp->_IO_read_ptr > fp->_IO_read_base && (unsigned char)fp->_IO_read_ptr[-1] == (unsigned char)c) { fp->_IO_read_ptr--; return (unsigned char)c; } return fp->_jumps->__pbackfail(fp, c); } int _IO_sungetc(fp) register _IO_FILE *fp; { if (fp->_IO_read_ptr > fp->_IO_read_base) { fp->_IO_read_ptr--; return (unsigned char)*fp->_IO_read_ptr; } else return fp->_jumps->__pbackfail(fp, EOF); } #if 0 /* Work in progress */ void _IO_set_column(fp, c) register _IO_FILE *fp; int c; { if (c == -1) fp->_collumn = -1; else fp->_collumn = c - (fp->_IO_write_ptr - fp->_IO_write_base); } #else int _IO_set_column(fp, i) register _IO_FILE *fp; int i; { fp->_cur_column = i+1; return 0; } #endif unsigned _IO_adjust_column(start, line, count) unsigned start; const char *line; int count; { register const char *ptr = line + count; while (ptr > line) if (*--ptr == '\n') return line + count - ptr - 1; return start + count; } int _IO_get_column(fp) register _IO_FILE *fp; { if (fp->_cur_column) return _IO_adjust_column(fp->_cur_column - 1, fp->_IO_write_base, fp->_IO_write_ptr - fp->_IO_write_base); return -1; } int _IO_flush_all() { int result = 0; _IO_FILE *fp; for (fp = _IO_list_all; fp != NULL; fp = fp->_chain) if (fp->_jumps->__overflow(fp, EOF) == EOF) result = EOF; return result; } void _IO_flush_all_linebuffered() { _IO_FILE *fp; for (fp = _IO_list_all; fp != NULL; fp = fp->_chain) if (fp->_flags & _IO_LINE_BUF) fp->_jumps->__overflow(fp, EOF); } void _IO_init_marker(marker, fp) struct _IO_marker *marker; _IO_FILE *fp; { marker->_sbuf = fp; if (_IO_in_put_mode(fp)) _IO_switch_to_get_mode(fp); if (_IO_in_backup(fp)) marker->_pos = fp->_IO_read_ptr - fp->_IO_read_end; else marker->_pos = fp->_IO_read_ptr - fp->_IO_read_base; /* Should perhaps sort the chain? */ marker->_next = fp->_markers; fp->_markers = marker; } void _IO_remove_marker (marker) register struct _IO_marker * marker; { /* Unlink from sb's chain. */ register struct _IO_marker **ptr = &marker->_sbuf->_markers; for (; ; ptr = &(*ptr)->_next) { if (*ptr == NULL) break; else if (*ptr == marker) { *ptr = marker->_next; return; } } #if 0 if _sbuf has a backup area that is no longer needed, should we delete it now, or wait until the next underflow? #endif } #define BAD_DELTA EOF int _IO_marker_difference(mark1, mark2) struct _IO_marker *mark1; struct _IO_marker *mark2; { return mark1->_pos - mark2->_pos; } /* Return difference between MARK and current posistion of MARK's stream. */ int _IO_marker_delta(mark) struct _IO_marker *mark; { int cur_pos; if (mark->_sbuf == NULL) return BAD_DELTA; if (_IO_in_backup(mark->_sbuf)) cur_pos = mark->_sbuf->_IO_read_ptr - mark->_sbuf->_IO_read_end; else cur_pos = mark->_sbuf->_IO_read_ptr - mark->_sbuf->_IO_read_base; return mark->_pos - cur_pos; } int _IO_seekmark(fp, mark, delta) _IO_FILE *fp; struct _IO_marker *mark; int delta; { if (mark->_sbuf != fp) return EOF; if (mark->_pos >= 0) { if (_IO_in_backup(fp)) _IO_switch_to_main_get_area(fp); fp->_IO_read_ptr = fp->_IO_read_base + mark->_pos; } else { if (!_IO_in_backup(fp)) _IO_switch_to_backup_area(fp); fp->_IO_read_ptr = fp->_IO_read_end + mark->_pos; } return 0; } void _IO_unsave_markers(fp) register _IO_FILE *fp; { register struct _IO_marker *mark = fp->_markers; if (mark) { #ifdef TODO streampos offset = seekoff(0, ios::cur, ios::in); if (offset != EOF) { offset += eGptr() - Gbase(); for ( ; mark != NULL; mark = mark->_next) mark->set_streampos(mark->_pos + offset); } else { for ( ; mark != NULL; mark = mark->_next) mark->set_streampos(EOF); } #endif fp->_markers = 0; } _IO_free_backup_area(fp); } int _IO_nobackup_pbackfail(fp, c) register _IO_FILE *fp; int c; { if (fp->_IO_read_ptr > fp->_IO_read_base) fp->_IO_read_ptr--; if (c != EOF && *fp->_IO_read_ptr != c) *fp->_IO_read_ptr = c; return (unsigned char)c; } int _IO_default_pbackfail(fp, c) register _IO_FILE *fp; int c; { if (fp->_IO_read_ptr <= fp->_IO_read_base) { /* Need to handle a filebuf in write mode (switch to read mode). FIXME!*/ if (_IO_have_backup(fp) && !_IO_in_backup(fp)) _IO_switch_to_backup_area(fp); if (!_IO_have_backup(fp)) { /* No backup buffer: allocate one. */ /* Use nshort buffer, if unused? (probably not) FIXME */ int backup_size = 128; char *bbuf = (char*)malloc(backup_size); if (bbuf == NULL) return EOF; fp->_IO_save_base = bbuf; fp->_IO_save_end = fp->_IO_save_base + backup_size; fp->_aux_limit = fp->_IO_save_end; _IO_switch_to_backup_area(fp); } else if (fp->_IO_read_ptr <= fp->_IO_read_base) { /* Increase size of existing backup buffer. */ _IO_size_t new_size; _IO_size_t old_size = fp->_IO_read_end - fp->_IO_read_base; char *new_buf; new_size = 2 * old_size; new_buf = (char*)malloc(new_size); if (new_buf == NULL) return EOF; memcpy(new_buf+(new_size-old_size), fp->_IO_read_base, old_size); free (fp->_IO_read_base); _IO_setg(fp, new_buf, new_buf+(new_size-old_size), new_buf+new_size); fp->_aux_limit = fp->_IO_read_ptr; } } fp->_IO_read_ptr--; if (c != EOF && *fp->_IO_read_ptr != c) *fp->_IO_read_ptr = c; return (unsigned char)*fp->_IO_read_ptr; } _IO_pos_t _IO_default_seek(fp, offset, dir) _IO_FILE *fp; _IO_off_t offset; int dir; { return _IO_pos_BAD; } int _IO_default_stat(fp, st) _IO_FILE *fp; void* st; { return EOF; } _IO_ssize_t _IO_default_read(fp, data, n) register _IO_FILE* fp; void* data; _IO_ssize_t n; { return -1; } _IO_ssize_t _IO_default_write(fp, data, n) register _IO_FILE* fp; const void* data; _IO_ssize_t n; { return 0; } #ifdef TODO #if defined(linux) #define IO_CLEANUP ; #endif #ifdef IO_CLEANUP IO_CLEANUP #else struct __io_defs { __io_defs() { } ~__io_defs() { _IO_flush_all(); } }; __io_defs io_defs__; #endif #endif /* TODO */ ./libc-linux/libio/gen-params100755 1676 334 33101 5477556437 14236 0ustar hjlisl#!/bin/sh # Copyright (C) 1992, 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. # Written by Per Bothner (bothner@cygnus.com) # This is a shell-script that figures out various things about a # system, and writes (to stdout) a C-style include files with # suitable definitions, including all the standard Posix types. # It works by compiling various test programs -- some are run through # the C pre-processor, and the output examined. # The test programs are only compiled, not executed, so the script # should even if you're cross-compiling. # It uses $CC (which defaults to cc) to compile C programs (extension .c), # and $CXX (which defaults to gcc) to compile C++ programs (extension .C). # The shell-script is written for libg++.a. # Usage: gen-params [NAME1=name1 ...] # - where an assignment (such as size_t="unsigned int" means to # use that value, instead of trying to figure it out. # Uncomment following line for debugging # set -x SED=sed # Evaluate the arguments (which should be assignments): for arg in "$@"; do # Quote arg (i.e. FOO=bar => FOO='bar'), then eval it. eval `echo "$arg" | ${SED} -e "s|^\(.*\)=\(.*\)|\1='\2'|"` done macro_prefix=${macro_prefix-"_G_"} rootdir=`pwd`/.. gccdir=${gccdir-${rootdir}/gcc} binutilsdir=${binutilsdir-${rootdir}/binutils} CC=${CC-`if [ -f ${gccdir}/xgcc ] ; \ then echo ${gccdir}/xgcc -B${gccdir}/ -I${gccdir}/include ; \ else echo cc ; fi`} CXX=${CXX-`if [ -f ${gccdir}/xgcc ] ; \ then echo ${gccdir}/xgcc -B${gccdir}/ -I${gccdir}/include ; \ else echo gcc ; fi`} CPP=${CPP-`echo ${CC} -E`} CONFIG_NM=${CONFIG_NM-`if [ -f ${binutilsdir}/nm ] ; \ then echo ${binutilsdir}/nm ; \ else echo nm ; fi`} cat <dummy.C <&2; exit -1; fi # if test -n "${DOLLAR_IN_LABEL}" ; then # echo "#define ${macro_prefix}DOLLAR_IN_LABEL ${DOLLAR_IN_LABEL}" # elif test "`${CONFIG_NM} dummy.o | grep 'vt[$$]7filebuf'`" != ""; then # echo "#define ${macro_prefix}DOLLAR_IN_LABEL 1" # elif test "`${CONFIG_NM} dummy.o | grep 'vt[.]7filebuf'`" != ""; then # echo "#define ${macro_prefix}DOLLAR_IN_LABEL 0" # elif test "`${CONFIG_NM} dummy.o | grep 'vtbl__7filebuf'`" != ""; then # echo "#define ${macro_prefix}DOLLAR_IN_LABEL 0" # else # echo "gen-params: ${CONFIG_NM} failed to find vt[.\$]filebuf in dummy.o!" 1>&2; exit 1 # fi else # The compile failed for some reason (no C++?) echo "gen-params: could not compile dummy.C with ${CXX}" 1>&2; exit 1; fi fi # A little test program to check if struct stat has st_blksize. cat >dummy.c < #include int BLKSIZE(struct stat *st) { return st->st_blksize; } !EOF! if ${CC} -c dummy.c >/dev/null 2>&1 ; then echo "#define ${macro_prefix}HAVE_ST_BLKSIZE 1" else echo "#define ${macro_prefix}HAVE_ST_BLKSIZE 0" fi # Next, generate definitions for the standard types (such as mode_t) # compatible with those in the standard C header files. # It works by a dummy program through the C pre-processor, and then # using sed to search for typedefs in the output. cat >dummy.c < #include #include #include #include #include #ifdef size_t typedef size_t Xsize_t; #elif defined(__SIZE_TYPE__) typedef __SIZE_TYPE__ Xsize_t; #endif #ifdef ptrdiff_t typedef ptrdiff_t Xptrdiff_t; #elif defined(__PTRDIFF_TYPE__) typedef __PTRDIFF_TYPE__ Xptrdiff_t; #endif #ifdef wchar_t typedef wchar_t Xwchar_t; #elif defined(__WCHAR_TYPE__) typedef __WCHAR_TYPE__ Xwchar_t; #endif #ifdef va_list typedef va_list XXXva_list; #endif #ifdef BUFSIZ int XBUFSIZ=BUFSIZ; #endif #ifdef FOPEN_MAX int XFOPEN_MAX=FOPEN_MAX; #endif #ifdef FILENAME_MAX int XFILENAME_MAX=FILENAME_MAX; #endif !EOF! if ${CPP} dummy.c >TMP ; then true else echo "gen-params: could not invoke ${CPP} on dummy.c" 1>&2 ; exit 1 fi tr ' ' ' ' dummy.out for TYPE in dev_t clock_t fpos_t gid_t ino_t mode_t nlink_t off_t pid_t ptrdiff_t sigset_t size_t ssize_t time_t uid_t va_list wchar_t int32_t uint_32_t ; do IMPORTED=`eval 'echo $'"$TYPE"` if [ -n "${IMPORTED}" ] ; then eval "$TYPE='$IMPORTED" else # Search dummy.out for a typedef for $TYPE, and write it out # to TMP in #define syntax. rm -f TMP ${SED} -n -e "s|.*typedef *\(.*\) X*$TYPE *;.*|\1|w TMP" \ /dev/null # Now select the first definition. if [ -s TMP ]; then # VALUE is now the typedef'd definition of $TYPE. eval "VALUE='`${SED} -e 's| *$||' -e '2,$d' /dev/null ; then true else rm -f TMP ${SED} -n -e "s|.*typedef[ ][ ]*\(.*[^a-zA-Z0-9_]\)${VALUE}[ ]*;.*|\1|w TMP" /dev/null if [ -s TMP ]; then eval "VALUE='`${SED} -e '2,$d' -e 's|[ ]*$||' echo "#include extern $tmp read();" >dummy.c ${CC} -c dummy.c >/dev/null 2>&1 || tmp=int fi echo "typedef $tmp /* default */ ${macro_prefix}ssize_t;" fi # va_list can cause problems (e.g. some systems have va_list as a struct). # Check to see if ${va_list-char*} really is compatible with stdarg.h. cat >dummy.C < } long foo(X_va_list ap) { return va_arg(ap, long); } long bar(int i, ...) { va_list ap; long j; va_start(ap, i); j = foo(ap); va_end(ap); return j; } !EOF! if ${CXX} -c dummy.C >/dev/null 2>&1 ; then # Ok: We have something that works. echo "typedef ${va_list-char* /* default */} ${macro_prefix}va_list;" else # No, it breaks. Indicate that must be included. echo "#define ${macro_prefix}NEED_STDARG_H #define ${macro_prefix}va_list va_list" fi cat >dummy.c < extern int (*signal())(); extern int dummy (int); main() { int (*oldsig)(int) = signal (1, dummy); (void) signal (2, oldsig); return 0; } !EOF! if ${CC} -c dummy.c >/dev/null 2>&1 ; then echo "#define ${macro_prefix}signal_return_type int" else echo "#define ${macro_prefix}signal_return_type void" fi # check sprintf return type cat >dummy.c < extern int sprintf(); char buf[100]; int main() { return sprintf(buf, "%d", 34); } !EOF! if ${CC} -c dummy.c >/dev/null 2>&1 ; then echo "#define ${macro_prefix}sprintf_return_type int" else echo "#define ${macro_prefix}sprintf_return_type char*" fi # Look for some standard macros for NAME in BUFSIZ FOPEN_MAX FILENAME_MAX NULL ; do IMPORTED=`eval 'echo $'"$NAME"` if [ -n "${IMPORTED}" ] ; then eval "$NAME='$IMPORTED /* specified */" else rm -f TMP ${SED} -n -e "s|int X${NAME}=\(.*\);|\1|w TMP" /dev/null # Now select the first definition. if [ -s TMP ]; then eval "$NAME='"`${SED} -e '2,$d' dummy.c < int main() { atexit (0); } !EOF! if ${CC} dummy.c >/dev/null 2>&1 ; then echo "#define ${macro_prefix}HAVE_ATEXIT 1" else echo "#define ${macro_prefix}HAVE_ATEXIT 0" fi fi # *** Check for presence of certain include files *** # check for sys/resource.h if test -n "${HAVE_SYS_RESOURCE}" ; then echo "#define ${macro_prefix}HAVE_SYS_RESOURCE ${HAVE_SYS_RESOURCE}" else cat >dummy.c < #include int main() { struct rusage res; getrusage(RUSAGE_SELF, &res); return (int)(res.ru_utime.tv_sec + (res.ru_utime.tv_usec / 1000000.0)); } !EOF! # Note: We link because some systems have sys/resource, but not getrusage(). if ${CC} dummy.c >/dev/null 2>&1 ; then echo "#define ${macro_prefix}HAVE_SYS_RESOURCE 1" else echo "#define ${macro_prefix}HAVE_SYS_RESOURCE 0" fi fi # check for sys/socket.h if test -n "${HAVE_SYS_SOCKET}" ; then echo "#define ${macro_prefix}HAVE_SYS_SOCKET ${HAVE_SYS_SOCKET}" else echo '#include ' >dummy.c echo '#include ' >>dummy.c if ${CC} -c dummy.c >/dev/null 2>&1 ; then echo "#define ${macro_prefix}HAVE_SYS_SOCKET 1" else echo "#define ${macro_prefix}HAVE_SYS_SOCKET 0" fi fi # Check for a (Posix-compatible) sys/wait.h */ if test -n "${HAVE_SYS_WAIT}" ; then echo "#define ${macro_prefix}HAVE_SYS_WAIT ${HAVE_SYS_WAIT}" else cat >dummy.C < #include } int f() { int i; wait(&i); return i; } !EOF! #define ${macro_prefix}HAVE_UNION_WAIT 1" if ${CXX} -c dummy.C >/dev/null 2>&1 ; then echo "#define ${macro_prefix}HAVE_SYS_WAIT 1" else echo "#define ${macro_prefix}HAVE_SYS_WAIT 0" fi fi if test -n "${HAVE_UNISTD}" ; then echo "#define ${macro_prefix}HAVE_UNISTD ${HAVE_UNISTD}" else echo '#include ' >dummy.c if ${CC} -c dummy.c >/dev/null 2>&1 ; then echo "#define ${macro_prefix}HAVE_UNISTD 1" else echo "#define ${macro_prefix}HAVE_UNISTD 0" fi fi if test -n "${HAVE_DIRENT}" ; then echo "#define ${macro_prefix}HAVE_DIRENT ${HAVE_DIRENT}" else echo '#include #include ' >dummy.c if ${CC} -c dummy.c >/dev/null 2>&1 ; then echo "#define ${macro_prefix}HAVE_DIRENT 1" else echo "#define ${macro_prefix}HAVE_DIRENT 0" fi fi if test -n "${HAVE_CURSES}" ; then echo "#define ${macro_prefix}HAVE_CURSES ${HAVE_CURSES}" else echo '#include ' >dummy.c if ${CC} -c dummy.c >/dev/null 2>&1 ; then echo "#define ${macro_prefix}HAVE_CURSES 1" else echo "#define ${macro_prefix}HAVE_CURSES 0" fi fi # There is no test for this at the moment; it is just set by the # configuration files. if test -n "${MATH_H_INLINES}" ; then echo "#define ${macro_prefix}MATH_H_INLINES ${MATH_H_INLINES}" else echo "#define ${macro_prefix}MATH_H_INLINES 0" fi # Uncomment the following line if you don't have working templates. # echo "#define ${macro_prefix}NO_TEMPLATES" rm -f dummy.C dummy.o dummy.c dummy.out TMP core a.out echo "#endif /* !${macro_prefix}config_h */" ./libc-linux/libio/iovfprintf.c100644 1676 334 52123 5527715257 14606 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. */ /* * Copyright (c) 1990 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ /* * Actual printf innards. * * This code is large and complicated... */ #include #include "libioP.h" #include #ifdef __STDC__ #include #else #include #endif /* * Define FLOATING_POINT to get floating point. */ #ifndef NO_FLOATING_POINT #define FLOATING_POINT #endif /* end of configuration stuff */ /* * Helper "class" for `fprintf to unbuffered': creates a * temporary buffer. */ struct helper_file { struct _IO_FILE_plus _f; _IO_FILE *_put_stream; }; static int _IO_helper_overflow (fp, c) _IO_FILE *fp; int c; { _IO_FILE *target = ((struct helper_file*)fp)->_put_stream; int used = fp->_IO_write_ptr - fp->_IO_write_base; if (used) { _IO_sputn(target, fp->_IO_write_base, used); fp->_IO_write_ptr -= used; } return _IO_putc (c, fp); } static struct _IO_jump_t _IO_helper_jumps = { _IO_helper_overflow, _IO_default_underflow, _IO_default_xsputn, _IO_default_xsgetn, _IO_default_read, _IO_default_write, _IO_default_doallocate, _IO_default_pbackfail, _IO_default_setbuf, _IO_default_sync, _IO_default_finish, _IO_default_close, _IO_default_stat, _IO_default_seek, _IO_default_seekoff, _IO_default_seekpos, }; static int helper_vfprintf(fp, fmt0, ap) register _IO_FILE* fp; char const *fmt0; _IO_va_list ap; { char buf[_IO_BUFSIZ]; struct helper_file helper; register _IO_FILE *hp = (_IO_FILE*)&helper; int result, to_flush; /* initialize helper */ helper._put_stream = fp; hp->_IO_write_base = buf; hp->_IO_write_ptr = buf; hp->_IO_write_end = buf+_IO_BUFSIZ; /* TG: add because of Checker */ hp->_IO_file_flags = _IO_MAGIC|(_IO_IS_FILEBUF+_IO_NO_READS); hp->_jumps = &_IO_helper_jumps; /* Now print to helper instead. */ result = _IO_vfprintf(hp, fmt0, ap); /* Now flush anything from the helper to the fp. */ if ((to_flush = hp->_IO_write_ptr - hp->_IO_write_base) > 0) { if (_IO_sputn(fp, hp->_IO_write_base, to_flush) != to_flush) return EOF; } return result; } #ifdef FLOATING_POINT #include "floatio.h" #define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */ #define DEFPREC 6 extern double modf __P((double, double*)); #else /* no FLOATING_POINT */ #define BUF 40 #endif /* FLOATING_POINT */ /* * Macros for converting digits to letters and vice versa */ #define to_digit(c) ((c) - '0') #define is_digit(c) ((unsigned)to_digit(c) <= 9) #define to_char(n) ((n) + '0') /* * Flags used during conversion. */ #define LONGINT 0x01 /* long integer */ #define LONGDBL 0x02 /* long double; unimplemented */ #define SHORTINT 0x04 /* short integer */ #define ALT 0x08 /* alternate form */ #define LADJUST 0x10 /* left adjustment */ #define ZEROPAD 0x20 /* zero (as opposed to blank) pad */ #define HEXPREFIX 0x40 /* add 0x or 0X prefix */ int _IO_vfprintf(fp, fmt0, ap) register _IO_FILE* fp; char const *fmt0; _IO_va_list ap; { register const char *fmt; /* format string */ register int ch; /* character from fmt */ register int n; /* handy integer (short term usage) */ register char *cp; /* handy char pointer (short term usage) */ const char *fmark; /* for remembering a place in fmt */ register int flags; /* flags as above */ int ret; /* return value accumulator */ int width; /* width from format (%8d), or 0 */ int prec; /* precision from format (%.3d), or -1 */ char sign; /* sign prefix (' ', '+', '-', or \0) */ #ifdef FLOATING_POINT int softsign; /* temporary negative sign for floats */ double _double; /* double precision arguments %[eEfgG] */ #ifndef USE_DTOA int fpprec; /* `extra' floating precision in [eEfgG] */ #endif #endif unsigned long _ulong; /* integer arguments %[diouxX] */ enum { OCT, DEC, HEX } base;/* base for [diouxX] conversion */ int dprec; /* a copy of prec if [diouxX], 0 otherwise */ int dpad; /* extra 0 padding needed for integers */ int fieldsz; /* field size expanded by sign, dpad etc */ /* The initialization of 'size' is to suppress a warning that 'size' might be used unitialized. It seems gcc can't quite grok this spaghetti code ... */ int size = 0; /* size of converted field or string */ char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ char ox[2]; /* space for 0x hex-prefix */ /* * BEWARE, these `goto error' on error, and PAD uses `n'. */ #define PRINT(ptr, len) \ do { if (_IO_sputn(fp,ptr, len) != len) goto error; } while (0) #define PAD_SP(howmany) if (_IO_padn(fp, ' ', howmany) < (howmany)) goto error; #define PAD_0(howmany) if (_IO_padn(fp, '0', howmany) < (howmany)) goto error; /* * To extend shorts properly, we need both signed and unsigned * argument extraction methods. */ #define SARG() \ (flags&LONGINT ? va_arg(ap, long) : \ flags&SHORTINT ? (long)(short)va_arg(ap, int) : \ (long)va_arg(ap, int)) #define UARG() \ (flags&LONGINT ? va_arg(ap, unsigned long) : \ flags&SHORTINT ? (unsigned long)(unsigned short)va_arg(ap, int) : \ (unsigned long)va_arg(ap, unsigned int)) /* optimise stderr (and other unbuffered Unix files) */ if (fp->_IO_file_flags & _IO_UNBUFFERED) return helper_vfprintf(fp, fmt0, ap); fmt = fmt0; ret = 0; /* * Scan the format for conversions (`%' character). */ for (;;) { for (fmark = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++) /* void */; if ((n = fmt - fmark) != 0) { PRINT(fmark, n); ret += n; } if (ch == '\0') goto done; fmt++; /* skip over '%' */ flags = 0; dprec = 0; #if defined(FLOATING_POINT) && !defined (USE_DTOA) fpprec = 0; #endif width = 0; prec = -1; sign = '\0'; rflag: ch = *fmt++; reswitch: switch (ch) { case ' ': /* * ``If the space and + flags both appear, the space * flag will be ignored.'' * -- ANSI X3J11 */ if (!sign) sign = ' '; goto rflag; case '#': flags |= ALT; goto rflag; case '*': /* * ``A negative field width argument is taken as a * - flag followed by a positive field width.'' * -- ANSI X3J11 * They don't exclude field widths read from args. */ if ((width = va_arg(ap, int)) >= 0) goto rflag; width = -width; /* FALLTHROUGH */ case '-': flags |= LADJUST; flags &= ~ZEROPAD; /* '-' disables '0' */ goto rflag; case '+': sign = '+'; goto rflag; case '.': if ((ch = *fmt++) == '*') { n = va_arg(ap, int); prec = n < 0 ? -1 : n; goto rflag; } n = 0; while (is_digit(ch)) { n = 10 * n + to_digit(ch); ch = *fmt++; } prec = n < 0 ? -1 : n; goto reswitch; case '0': /* * ``Note that 0 is taken as a flag, not as the * beginning of a field width.'' * -- ANSI X3J11 */ if (!(flags & LADJUST)) flags |= ZEROPAD; /* '-' disables '0' */ goto rflag; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': n = 0; do { n = 10 * n + to_digit(ch); ch = *fmt++; } while (is_digit(ch)); width = n; goto reswitch; #ifdef FLOATING_POINT case 'L': flags |= LONGDBL; goto rflag; #endif case 'h': flags |= SHORTINT; goto rflag; case 'l': flags |= LONGINT; goto rflag; case 'c': *(cp = buf) = va_arg(ap, int); size = 1; sign = '\0'; break; case 'D': flags |= LONGINT; /*FALLTHROUGH*/ case 'd': case 'i': _ulong = SARG(); if ((long)_ulong < 0) { _ulong = -_ulong; sign = '-'; } base = DEC; goto number; #ifdef FLOATING_POINT case 'e': case 'E': case 'f': case 'F': case 'g': case 'G': _double = va_arg(ap, double); #ifdef USE_DTOA { int fmt_flags = 0; int fill = ' '; if (flags & ALT) fmt_flags |= _IO_SHOWPOINT; if (flags & LADJUST) fmt_flags |= _IO_LEFT; else if (flags & ZEROPAD) fmt_flags |= _IO_INTERNAL, fill = '0'; n = _IO_outfloat(_double, fp, ch, width, prec < 0 ? DEFPREC : prec, fmt_flags, sign, fill); if (n < 0) goto error; ret += n; } /* CHECK ERROR! */ continue; #else /* * don't do unrealistic precision; just pad it with * zeroes later, so buffer size stays rational. */ if (prec > MAXFRACT) { if ((ch != 'g' && ch != 'G') || (flags&ALT)) fpprec = prec - MAXFRACT; prec = MAXFRACT; } else if (prec == -1) prec = DEFPREC; /* __cvt_double may have to round up before the "start" of its buffer, i.e. ``intf("%.2f", (double)9.999);''; if the first character is still NUL, it did. softsign avoids negative 0 if _double < 0 but no significant digits will be shown. */ cp = buf; *cp = '\0'; size = __cvt_double(_double, prec, flags, &softsign, ch, cp, buf + sizeof(buf)); if (softsign) sign = '-'; if (*cp == '\0') cp++; break; #endif #endif /* FLOATING_POINT */ case 'n': if (flags & LONGINT) *va_arg(ap, long *) = ret; else if (flags & SHORTINT) *va_arg(ap, short *) = ret; else *va_arg(ap, int *) = ret; continue; /* no output */ case 'O': flags |= LONGINT; /*FALLTHROUGH*/ case 'o': _ulong = UARG(); base = OCT; goto nosign; case 'p': /* * ``The argument shall be a pointer to void. The * value of the pointer is converted to a sequence * of printable characters, in an implementation- * defined manner.'' * -- ANSI X3J11 */ /* NOSTRICT */ _ulong = (unsigned long)va_arg(ap, void *); base = HEX; flags |= HEXPREFIX; ch = 'x'; goto nosign; case 's': if ((cp = va_arg(ap, char *)) == NULL) cp = "(null)"; if (prec >= 0) { /* * can't use strlen; can only look for the * NUL in the first `prec' characters, and * strlen() will go further. */ char *p = (char*)memchr(cp, 0, prec); if (p != NULL) { size = p - cp; if (size > prec) size = prec; } else size = prec; } else size = strlen(cp); sign = '\0'; break; case 'U': flags |= LONGINT; /*FALLTHROUGH*/ case 'u': _ulong = UARG(); base = DEC; goto nosign; case 'X': case 'x': _ulong = UARG(); base = HEX; /* leading 0x/X only if non-zero */ if (flags & ALT && _ulong != 0) flags |= HEXPREFIX; /* unsigned conversions */ nosign: sign = '\0'; /* * ``... diouXx conversions ... if a precision is * specified, the 0 flag will be ignored.'' * -- ANSI X3J11 */ number: if ((dprec = prec) >= 0) flags &= ~ZEROPAD; /* * ``The result of converting a zero value with an * explicit precision of zero is no characters.'' * -- ANSI X3J11 */ cp = buf + BUF; if (_ulong != 0 || prec != 0) { char *xdigs; /* digits for [xX] conversion */ /* * unsigned mod is hard, and unsigned mod * by a constant is easier than that by * a variable; hence this switch. */ switch (base) { case OCT: do { *--cp = to_char(_ulong & 7); _ulong >>= 3; } while (_ulong); /* handle octal leading 0 */ if (flags & ALT && *cp != '0') *--cp = '0'; break; case DEC: /* many numbers are 1 digit */ while (_ulong >= 10) { *--cp = to_char(_ulong % 10); _ulong /= 10; } *--cp = to_char(_ulong); break; case HEX: if (ch == 'X') xdigs = "0123456789ABCDEF"; else /* ch == 'x' || ch == 'p' */ xdigs = "0123456789abcdef"; do { *--cp = xdigs[_ulong & 15]; _ulong >>= 4; } while (_ulong); break; default: cp = "bug in vform: bad base"; goto skipsize; } } size = buf + BUF - cp; skipsize: break; default: /* "%?" prints ?, unless ? is NUL */ if (ch == '\0') goto done; /* pretend it was %c with argument ch */ cp = buf; *cp = ch; size = 1; sign = '\0'; break; } /* * All reasonable formats wind up here. At this point, * `cp' points to a string which (if not flags&LADJUST) * should be padded out to `width' places. If * flags&ZEROPAD, it should first be prefixed by any * sign or other prefix; otherwise, it should be blank * padded before the prefix is emitted. After any * left-hand padding and prefixing, emit zeroes * required by a decimal [diouxX] precision, then print * the string proper, then emit zeroes required by any * leftover floating precision; finally, if LADJUST, * pad with blanks. */ /* * compute actual size, so we know how much to pad. */ #if defined(FLOATING_POINT) && !defined (USE_DTOA) fieldsz = size + fpprec; #else fieldsz = size; #endif dpad = dprec - size; if (dpad < 0) dpad = 0; if (sign) fieldsz++; else if (flags & HEXPREFIX) fieldsz += 2; fieldsz += dpad; /* right-adjusting blank padding */ if ((flags & (LADJUST|ZEROPAD)) == 0) PAD_SP(width - fieldsz); /* prefix */ if (sign) { PRINT(&sign, 1); } else if (flags & HEXPREFIX) { ox[0] = '0'; ox[1] = ch; PRINT(ox, 2); } /* right-adjusting zero padding */ if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) PAD_0(width - fieldsz); /* leading zeroes from decimal precision */ PAD_0(dpad); /* the string or number proper */ PRINT(cp, size); #if defined(FLOATING_POINT) && !defined (USE_DTOA) /* trailing f.p. zeroes */ PAD_0(fpprec); #endif /* left-adjusting padding (always blank) */ if (flags & LADJUST) PAD_SP(width - fieldsz); /* finally, adjust ret */ ret += width > fieldsz ? width : fieldsz; } done: return ret; error: return EOF; /* NOTREACHED */ } #if defined(FLOATING_POINT) && !defined(USE_DTOA) static char *exponent(register char *p, register int exp, int fmtch) { register char *t; char expbuf[MAXEXP]; *p++ = fmtch; if (exp < 0) { exp = -exp; *p++ = '-'; } else *p++ = '+'; t = expbuf + MAXEXP; if (exp > 9) { do { *--t = to_char(exp % 10); } while ((exp /= 10) > 9); *--t = to_char(exp); for (; t < expbuf + MAXEXP; *p++ = *t++); } else { *p++ = '0'; *p++ = to_char(exp); } return (p); } static char * round(double fract, int *exp, register char *start, register char *end, char ch, int *signp) { double tmp; if (fract) (void)modf(fract * 10, &tmp); else tmp = to_digit(ch); if (tmp > 4) for (;; --end) { if (*end == '.') --end; if (++*end <= '9') break; *end = '0'; if (end == start) { if (exp) { /* e/E; increment exponent */ *end = '1'; ++*exp; } else { /* f; add extra digit */ *--end = '1'; --start; } break; } } /* ``"%.3f", (double)-0.0004'' gives you a negative 0. */ else if (*signp == '-') for (;; --end) { if (*end == '.') --end; if (*end != '0') break; if (end == start) *signp = 0; } return (start); } int __cvt_double(double number, register int prec, int flags, int *signp, int fmtch, char *startp, char *endp) { register char *p, *t; register double fract; int dotrim = 0, expcnt, gformat = 0; double integer, tmp; expcnt = 0; if (number < 0) { number = -number; *signp = '-'; } else *signp = 0; fract = modf(number, &integer); /* get an extra slot for rounding. */ t = ++startp; /* * get integer portion of number; put into the end of the buffer; the * .01 is added for modf(356.0 / 10, &integer) returning .59999999... */ for (p = endp - 1; integer; ++expcnt) { tmp = modf(integer / 10, &integer); *p-- = to_char((int)((tmp + .01) * 10)); } switch (fmtch) { case 'f': case 'F': /* reverse integer into beginning of buffer */ if (expcnt) for (; ++p < endp; *t++ = *p); else *t++ = '0'; /* * if precision required or alternate flag set, add in a * decimal point. */ if (prec || flags&ALT) *t++ = '.'; /* if requires more precision and some fraction left */ if (fract) { if (prec) do { fract = modf(fract * 10, &tmp); *t++ = to_char((int)tmp); } while (--prec && fract); if (fract) startp = round(fract, (int *)NULL, startp, t - 1, (char)0, signp); } for (; prec--; *t++ = '0'); break; case 'e': case 'E': eformat: if (expcnt) { *t++ = *++p; if (prec || flags&ALT) *t++ = '.'; /* if requires more precision and some integer left */ for (; prec && ++p < endp; --prec) *t++ = *p; /* * if done precision and more of the integer component, * round using it; adjust fract so we don't re-round * later. */ if (!prec && ++p < endp) { fract = 0; startp = round((double)0, &expcnt, startp, t - 1, *p, signp); } /* adjust expcnt for digit in front of decimal */ --expcnt; } /* until first fractional digit, decrement exponent */ else if (fract) { /* adjust expcnt for digit in front of decimal */ for (expcnt = -1;; --expcnt) { fract = modf(fract * 10, &tmp); if (tmp) break; } *t++ = to_char((int)tmp); if (prec || flags&ALT) *t++ = '.'; } else { *t++ = '0'; if (prec || flags&ALT) *t++ = '.'; } /* if requires more precision and some fraction left */ if (fract) { if (prec) do { fract = modf(fract * 10, &tmp); *t++ = to_char((int)tmp); } while (--prec && fract); if (fract) startp = round(fract, &expcnt, startp, t - 1, (char)0, signp); } /* if requires more precision */ for (; prec--; *t++ = '0'); /* unless alternate flag, trim any g/G format trailing 0's */ if (gformat && !(flags&ALT)) { while (t > startp && *--t == '0'); if (*t == '.') --t; ++t; } t = exponent(t, expcnt, fmtch); break; case 'g': case 'G': /* a precision of 0 is treated as a precision of 1. */ if (!prec) ++prec; /* * ``The style used depends on the value converted; style e * will be used only if the exponent resulting from the * conversion is less than -4 or greater than the precision.'' * -- ANSI X3J11 */ if (expcnt > prec || (!expcnt && fract && fract < .0001)) { /* * g/G format counts "significant digits, not digits of * precision; for the e/E format, this just causes an * off-by-one problem, i.e. g/G considers the digit * before the decimal point significant and e/E doesn't * count it as precision. */ --prec; fmtch -= 2; /* G->E, g->e */ gformat = 1; goto eformat; } /* * reverse integer into beginning of buffer, * note, decrement precision */ if (expcnt) for (; ++p < endp; *t++ = *p, --prec); else *t++ = '0'; /* * if precision required or alternate flag set, add in a * decimal point. If no digits yet, add in leading 0. */ if (prec || flags&ALT) { dotrim = 1; *t++ = '.'; } else dotrim = 0; /* if requires more precision and some fraction left */ if (fract) { if (prec) { /* If no integer part, don't count initial * zeros as significant digits. */ do { fract = modf(fract * 10, &tmp); *t++ = to_char((int)tmp); } while(!tmp && !expcnt); while (--prec && fract) { fract = modf(fract * 10, &tmp); *t++ = to_char((int)tmp); } } if (fract) startp = round(fract, (int *)NULL, startp, t - 1, (char)0, signp); } /* alternate format, adds 0's for precision, else trim 0's */ if (flags&ALT) for (; prec--; *t++ = '0'); else if (dotrim) { while (t > startp && *--t == '0'); if (*t != '.') ++t; } } return (t - startp); } #endif /* defined(FLOATING_POINT) && !defined(USE_DTOA) */ ./libc-linux/libio/libioP.h100644 1676 334 27635 5517010324 13633 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 #ifndef errno extern int errno; #endif #include "iolibio.h" /* Include those system dependent file. */ #ifdef _LIBIO_CONFIG_H #include _LIBIO_CONFIG_H #endif #ifdef __STDC__ #include #endif #ifdef __cplusplus extern "C" { #endif typedef enum _IO_seekflags_ { _IO_seek_set = 0, _IO_seek_cur = 1, _IO_seek_end = 2, /* These bits are ignored unless the _IO_FILE has independent read and write positions. */ _IO_seek_not_in = 4, /* Don't move read posistion. */ _IO_seek_not_out = 8, /* Don't move write posistion. */ _IO_seek_pos_ignored = 16, /* Result is ignored (except EOF) */ } _IO_seekflags; typedef int (*_IO_overflow_t) __P((_IO_FILE*, int)); typedef int (*_IO_underflow_t) __P((_IO_FILE*)); typedef _IO_size_t (*_IO_xsputn_t) __P((_IO_FILE*,const void*,_IO_size_t)); typedef _IO_size_t (*_IO_xsgetn_t) __P((_IO_FILE*, void*, _IO_size_t)); typedef _IO_ssize_t (*_IO_read_t) __P((_IO_FILE*, void*, _IO_ssize_t)); typedef _IO_ssize_t (*_IO_write_t) __P((_IO_FILE*,const void*,_IO_ssize_t)); typedef int (*_IO_stat_t) __P((_IO_FILE*, void*)); typedef _IO_fpos_t (*_IO_seek_t) __P((_IO_FILE*, _IO_off_t, int)); typedef int (*_IO_doallocate_t) __P((_IO_FILE*)); typedef int (*_IO_pbackfail_t) __P((_IO_FILE*, int)); typedef int (*_IO_setbuf_t) __P((_IO_FILE*, char *, _IO_ssize_t)); typedef int (*_IO_sync_t) __P((_IO_FILE*)); typedef void (*_IO_finish_t) __P((_IO_FILE*)); /* finalize */ typedef int (*_IO_close_t) __P((_IO_FILE*)); /* finalize */ typedef _IO_fpos_t (*_IO_seekoff_t) __P((_IO_FILE*, _IO_off_t, _IO_seekflags)); /* The _IO_seek_cur and _IO_seek_end options are not allowed. */ typedef _IO_fpos_t (*_IO_seekpos_t) __P((_IO_FILE*, _IO_fpos_t, _IO_seekflags)); struct _IO_jump_t { _IO_overflow_t __overflow; _IO_underflow_t __underflow; _IO_xsputn_t __xsputn; _IO_xsgetn_t __xsgetn; _IO_read_t __read; _IO_write_t __write; _IO_doallocate_t __doallocate; _IO_pbackfail_t __pbackfail; _IO_setbuf_t __setbuf; _IO_sync_t __sync; _IO_finish_t __finish; _IO_close_t __close; _IO_stat_t __stat; _IO_seek_t __seek; _IO_seekoff_t __seekoff; _IO_seekpos_t __seekpos; #if 0 get_column; set_column; #endif }; /* Generic functions */ extern _IO_fpos_t _IO_seekoff __P((_IO_FILE*, _IO_off_t, _IO_seekflags)); extern _IO_fpos_t _IO_seekpos __P((_IO_FILE*, _IO_fpos_t, _IO_seekflags)); extern int _IO_switch_to_get_mode __P((_IO_FILE*)); extern void _IO_init __P((_IO_FILE*, int)); extern int _IO_sputbackc __P((_IO_FILE*, int)); extern int _IO_sungetc __P((_IO_FILE*)); extern void _IO_un_link __P((_IO_FILE*)); extern void _IO_link_in __P((_IO_FILE *)); extern void _IO_doallocbuf __P((_IO_FILE*)); extern void _IO_unsave_markers __P((_IO_FILE*)); extern void _IO_setb __P((_IO_FILE*, char*, char*, int)); extern unsigned _IO_adjust_column __P((unsigned, const char *, int)); #define _IO_sputn(__fp, __s, __n) (__fp->_jumps->__xsputn(__fp, __s, __n)) extern int _IO_ignore __P((_IO_FILE *, _IO_size_t)); extern void _IO_switch_to_main_get_area __P((_IO_FILE *)); extern void _IO_switch_to_backup_area __P((_IO_FILE *)); extern int _IO_sync __P((_IO_FILE *)); extern int _IO_get_column __P((_IO_FILE *)); extern int _IO_set_column __P((_IO_FILE *, int)); extern int _IO_nobackup_pbackfail __P((_IO_FILE *, int)); /* Marker-related function. */ extern void _IO_init_marker __P((struct _IO_marker *, _IO_FILE *)); extern void _IO_remove_marker __P((struct _IO_marker*)); extern int _IO_marker_difference __P((struct _IO_marker *, struct _IO_marker *)); extern int _IO_marker_delta __P((struct _IO_marker *)); extern int _IO_seekmark __P((_IO_FILE *, struct _IO_marker *, int)); extern _IO_size_t _IO_least_marker __P((_IO_FILE *)); /* Default jumptable functions. */ extern int _IO_default_underflow __P((_IO_FILE*)); extern int _IO_default_doallocate __P((_IO_FILE*)); extern void _IO_default_finish __P((_IO_FILE *)); extern int _IO_default_pbackfail __P((_IO_FILE*, int)); extern int _IO_default_setbuf __P((_IO_FILE *, char*, _IO_ssize_t)); extern _IO_size_t _IO_default_xsputn __P((_IO_FILE *, const void*, _IO_size_t)); extern _IO_size_t _IO_default_xsgetn __P((_IO_FILE *, void*, _IO_size_t)); extern _IO_fpos_t _IO_default_seekoff __P((_IO_FILE*, _IO_off_t, _IO_seekflags)); extern _IO_fpos_t _IO_default_seekpos __P((_IO_FILE*, _IO_fpos_t, _IO_seekflags)); extern _IO_ssize_t _IO_default_write __P((_IO_FILE*,const void*,_IO_ssize_t)); extern _IO_ssize_t _IO_default_read __P((_IO_FILE*, void*, _IO_ssize_t)); extern int _IO_default_stat __P((_IO_FILE*, void*)); extern _IO_fpos_t _IO_default_seek __P((_IO_FILE*, _IO_off_t, int)); extern int _IO_default_sync __P((_IO_FILE*)); #define _IO_default_close ((_IO_close_t)_IO_default_sync) extern struct _IO_jump_t _IO_file_jumps; extern struct _IO_jump_t _IO_proc_jumps; extern struct _IO_jump_t _IO_str_jumps; extern int _IO_do_write __P((_IO_FILE*, const char*, _IO_size_t)); extern int _IO_flush_all __P((void)); extern void _IO_flush_all_linebuffered __P((void)); #define _IO_do_flush(_f) \ _IO_do_write(_f, _f->_IO_write_base, _f->_IO_write_ptr-_f->_IO_write_base) #define _IO_in_put_mode(_fp) ((_fp)->_flags & _IO_CURRENTLY_PUTTING) #define _IO_mask_flags(fp, f, mask) \ ((fp)->_flags = ((fp)->_flags & ~(mask)) | ((f) & (mask))) #define _IO_setg(fp, eb, g, eg) ((fp)->_IO_read_base = (eb),\ (fp)->_IO_read_ptr = (g), (fp)->_IO_read_end = (eg)) #define _IO_setp(__fp, __p, __ep) \ ((__fp)->_IO_write_base = (__fp)->_IO_write_ptr = __p, (__fp)->_IO_write_end = (__ep)) #define _IO_have_backup(fp) ((fp)->_other_gbase != NULL) #define _IO_in_backup(fp) ((fp)->_flags & _IO_IN_BACKUP) #define _IO_have_markers(fp) ((fp)->_markers != NULL) #define _IO_blen(p) ((fp)->_IO_buf_end - (fp)->_IO_buf_base) /* Jumptable functions for files. */ extern int _IO_file_doallocate __P((_IO_FILE*)); extern int _IO_file_setbuf __P((_IO_FILE *, char*, _IO_ssize_t)); extern _IO_fpos_t _IO_file_seekoff __P((_IO_FILE*, _IO_off_t, _IO_seekflags)); extern _IO_size_t _IO_file_xsputn __P((_IO_FILE*,const void*,_IO_size_t)); extern int _IO_file_stat __P((_IO_FILE*, void*)); extern int _IO_file_close __P((_IO_FILE*)); extern int _IO_file_underflow __P((_IO_FILE *)); extern int _IO_file_overflow __P((_IO_FILE *, int)); #define _IO_file_is_open(__fp) ((__fp)->_fileno >= 0) extern void _IO_file_init __P((_IO_FILE*)); extern _IO_FILE* _IO_file_attach __P((_IO_FILE*, int)); extern _IO_FILE* _IO_file_fopen __P((_IO_FILE*, const char*, const char*)); extern _IO_ssize_t _IO_file_write __P((_IO_FILE*,const void*,_IO_ssize_t)); extern _IO_ssize_t _IO_file_read __P((_IO_FILE*, void*, _IO_ssize_t)); extern int _IO_file_sync __P((_IO_FILE*)); extern int _IO_file_close_it __P((_IO_FILE*)); extern _IO_fpos_t _IO_file_seek __P((_IO_FILE *, _IO_off_t, int)); extern void _IO_file_finish __P((_IO_FILE*)); /* Other file functions. */ extern _IO_FILE* _IO_file_attach __P((_IO_FILE *, int)); /* Jumptable functions for proc_files. */ extern _IO_FILE* _IO_proc_open __P((_IO_FILE*, const char*, const char *)); extern int _IO_proc_close __P((_IO_FILE*)); /* Jumptable functions for strfiles. */ extern int _IO_str_underflow __P((_IO_FILE*)); extern int _IO_str_overflow __P((_IO_FILE *, int)); extern int _IO_str_pbackfail __P((_IO_FILE*, int)); extern _IO_fpos_t _IO_str_seekoff __P((_IO_FILE*,_IO_off_t,_IO_seekflags)); /* Other strfile functions */ extern void _IO_str_init_static __P((_IO_FILE *, char*, int, char*)); extern void _IO_str_init_readonly __P((_IO_FILE *, const char*, int)); extern _IO_ssize_t _IO_str_count __P ((_IO_FILE*)); extern void _IO_str_finish __P((_IO_FILE *)); extern _IO_size_t _IO_getline __P((_IO_FILE*,char*,_IO_size_t,int,int)); extern double _IO_strtod __P((const char *, char **)); extern char * _IO_dtoa __P((double __d, int __mode, int __ndigits, int *__decpt, int *__sign, char **__rve)); extern int _IO_outfloat __P((double __value, _IO_FILE *__sb, int __type, int __width, int __precision, int __flags, int __sign_mode, int __fill)); extern char *_IO_gen_tempname __P ((const char *__dir, const char *__pfx, int __dir_search, _IO_size_t * __lenptr, _IO_FILE **__streamptr)); extern _IO_FILE *_IO_list_all; #ifndef __linux__ extern void (*_IO_cleanup_registration_needed)(); #endif #ifndef EOF #define EOF (-1) #endif #ifndef NULL #if !defined(__cplusplus) || defined(__GNUC__) #define NULL ((void*)0) #else #define NULL (0) #endif #endif #define FREE_BUF(_B) free(_B) #define ALLOC_BUF(_S) (char*)malloc(_S) #ifndef OS_FSTAT #define OS_FSTAT fstat #endif struct stat; extern _IO_ssize_t _IO_read __P((int, void*, _IO_size_t)); extern _IO_ssize_t _IO_write __P((int, const void*, _IO_size_t)); extern _IO_off_t _IO_lseek __P((int, _IO_off_t, int)); extern int _IO_close __P((int)); extern int _IO_fstat __P((int, struct stat *)); /* Operations on _IO_fpos_t. Normally, these are trivial, but we provide hooks for configurations where an _IO_fpos_t is a struct. Note that _IO_off_t must be an integral type. */ /* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */ #ifndef _IO_pos_BAD #define _IO_pos_BAD ((_IO_fpos_t)(-1)) #endif /* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */ #ifndef _IO_pos_as_off #define _IO_pos_as_off(__pos) ((_IO_off_t)(__pos)) #endif /* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */ #ifndef _IO_pos_adjust #define _IO_pos_adjust(__pos, __delta) ((__pos) += (__delta)) #endif /* _IO_pos_0 is an _IO_fpos_t value indicating beginning of file. */ #ifndef _IO_pos_0 #define _IO_pos_0 ((_IO_fpos_t)0) #endif #ifdef __cplusplus } #endif #if defined(__STDC__) || defined(__cplusplus) #define _IO_va_start(args, last) va_start(args, last) #else #define _IO_va_start(args, last) va_start(args) #endif /* Just do a sanity check. We assume no one uses old stdio. It * won't work all the time. */ #if 1 #ifdef EIO #define CHECK_FILE(FILE,RET) \ if ((FILE) == NULL || \ ((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \ { errno = EIO; return RET; } #else #define CHECK_FILE(FILE,RET) \ if ((FILE) == NULL || \ ((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \ { return RET; } #endif #else #ifdef EIO #define CHECK_FILE(FILE,RET) \ if ((FILE) == NULL || ( \ ((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \ && ((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _OLD_IO_MAGIC) \ { errno = EIO; return RET; } #else #define CHECK_FILE(FILE,RET) \ if ((FILE) == NULL || ( \ ((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \ && ((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _OLD_IO_MAGIC) \ { return RET; } #endif #endif #if 1 #define COERCE_FILE(FILE) /* Nothing */ #else /* This is part of the kludge for binary compatibility with old stdio. */ #define COERCE_FILE(FILE) \ (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \ && (FILE) = *(FILE**)&((int*)fp)[1]) #endif #define CLOSED_FILEBUF_FLAGS \ (_IO_IS_FILEBUF+_IO_NO_READS+_IO_NO_WRITES+_IO_TIED_PUT_GET) ./libc-linux/libio/iofclose.c100644 1676 334 2627 5516775507 14211 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 "libioP.h" int _IO_fclose(fp) register _IO_FILE *fp; { int status = 0; CHECK_FILE(fp, EOF); COERCE_FILE(fp); if (fp->_IO_file_flags & _IO_IS_FILEBUF) status = _IO_file_close_it(fp); fp->_jumps->__finish(fp); if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr) free(fp); return status; } ./libc-linux/libio/iofdopen.c100644 1676 334 5562 5477556437 14217 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 "libioP.h" #include #ifndef _IO_fcntl #define _IO_fcntl fcntl #endif _IO_FILE * _IO_fdopen (fd, mode) int fd; const char *mode; { int read_write; int posix_mode = 0; int status_flag; struct _IO_FILE_plus *fp; switch (*mode++) { case 'r': read_write = _IO_NO_WRITES; break; case 'w': read_write = _IO_NO_READS; break; case 'a': posix_mode = O_APPEND; read_write = _IO_NO_READS|_IO_IS_APPENDING; break; default: #ifdef EINVAL errno = EINVAL; #endif return NULL; } if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+')) read_write &= _IO_IS_APPENDING; fp = (struct _IO_FILE_plus*)malloc(sizeof(struct _IO_FILE_plus)); if (fp == NULL) return NULL; _IO_init(&fp->_file, 0); fp->_file._jumps = &_IO_file_jumps; _IO_file_init(&fp->_file); fp->_vtable = NULL; if (_IO_file_attach(&fp->_file, fd) == NULL) { _IO_un_link(&fp->_file); free (fp); return NULL; } fp->_file._flags |= CLOSED_FILEBUF_FLAGS; fp->_file._flags &= ~_IO_DELETE_DONT_CLOSE; fp->_file._IO_file_flags = _IO_mask_flags(&fp->_file, read_write, _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING); #ifdef F_GETFL status_flag = _IO_fcntl (fp->_file._fileno, F_GETFL); if (status_flag == -1) { _IO_un_link(&fp->_file); free (fp); return NULL; } /* check if we need to change the status flag. */ if ((status_flag & O_APPEND) != posix_mode) { /* Set new status flag. */ status_flag = (status_flag & ~O_APPEND) | posix_mode; if (_IO_fcntl (fp->_file._fileno, F_SETFL, status_flag) == -1) { _IO_un_link(&fp->_file); free (fp); return NULL; } } #else #error "I don't know what you have for F_GETFL." #endif return (_IO_FILE*)fp; } ./libc-linux/libio/iofflush.c100644 1676 334 2464 5511033741 14202 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 "libioP.h" int _IO_fflush(fp) register _IO_FILE *fp; { if (fp == NULL) return _IO_flush_all(); else { CHECK_FILE(fp, EOF); COERCE_FILE(fp); return fp->_jumps->__sync(fp) ? EOF : 0; } } ./libc-linux/libio/iofgetpos.c100644 1676 334 3026 5511033762 14360 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 "libioP.h" #include /* ANSI explicily requires setting errno to a positive value on failure. */ int _IO_fgetpos(fp, posp) _IO_FILE* fp; _IO_fpos_t *posp; { _IO_fpos_t pos; CHECK_FILE(fp, EOF); COERCE_FILE(fp); pos = _IO_seekoff(fp, 0, _IO_seek_cur|_IO_seek_not_in|_IO_seek_not_out); if (pos == _IO_pos_BAD) { #ifdef EIO if (errno == 0) errno = EIO; #endif return EOF; } *posp = pos; return 0; } ./libc-linux/libio/iofgets.c100644 1676 334 2646 5517654405 14041 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 "libioP.h" char* _IO_fgets(buf, n, fp) char* buf; int n; _IO_FILE* fp; { _IO_size_t count; CHECK_FILE(fp, NULL); COERCE_FILE(fp); if (n <= 0) return NULL; count = _IO_getline(fp, buf, n - 1, '\n', 1); if (count == 0 || (fp->_IO_file_flags & _IO_ERR_SEEN)) return NULL; buf[count] = 0; return buf; } ./libc-linux/libio/iofopen.c100644 1676 334 3077 5473734701 14036 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 "libioP.h" _IO_FILE * _IO_fopen (filename, mode) const char *filename; const char *mode; { struct _IO_FILE_plus *fp = (struct _IO_FILE_plus*)malloc(sizeof(struct _IO_FILE_plus)); if (fp == NULL) return NULL; _IO_init(&fp->_file, 0); fp->_file._jumps = &_IO_file_jumps; _IO_file_init(&fp->_file); fp->_vtable = NULL; if (_IO_file_fopen(&fp->_file, filename, mode) != NULL) return (_IO_FILE*)fp; _IO_un_link(&fp->_file); free (fp); return NULL; } ./libc-linux/libio/iofprintf.c100644 1676 334 2743 5511035546 14370 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 "libioP.h" #ifdef __STDC__ #include #else #include #endif int _IO_fprintf #ifdef __STDC__ (_IO_FILE *fp, const char* format, ...) #else (fp, format, va_alist) _IO_FILE *fp; char *format; va_dcl #endif { int ret; va_list args; CHECK_FILE(fp, -1); COERCE_FILE(fp); _IO_va_start(args, format); ret = _IO_vfprintf(fp, format, args); va_end(args); return ret; } ./libc-linux/libio/iofputs.c100644 1676 334 2503 5511034034 14042 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 "libioP.h" #include int _IO_fputs(str, fp) const char *str; _IO_FILE *fp; { _IO_size_t len = strlen(str); CHECK_FILE(fp, EOF); COERCE_FILE(fp); if (_IO_sputn(fp, str, len) != len) return EOF; return 1; } ./libc-linux/libio/iofread.c100644 1676 334 2764 5527712557 14017 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 "libioP.h" _IO_size_t _IO_fread(buf, size, count, fp) void *buf; _IO_size_t size; _IO_size_t count; _IO_FILE* fp; { _IO_size_t bytes_requested = size*count; _IO_size_t bytes_read; CHECK_FILE(fp, 0); COERCE_FILE(fp); if (bytes_requested == 0) return 0; bytes_read = _IO_sgetn(fp, (char *)buf, bytes_requested); return bytes_requested == bytes_read ? count : bytes_read / size; } ./libc-linux/libio/iofscanf.c100644 1676 334 2750 5511034307 14150 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 "libioP.h" #ifdef __STDC__ #include #else #include #endif int _IO_fscanf #ifdef __STDC__ (_IO_FILE *fp, const char* format, ...) #else (fp, format, va_alist) _IO_FILE *fp; char *format; va_dcl #endif { int ret; va_list args; CHECK_FILE(fp, EOF); COERCE_FILE(fp); _IO_va_start(args, format); ret = _IO_vfscanf(fp, format, args, NULL); va_end(args); return ret; } ./libc-linux/libio/iofsetpos.c100644 1676 334 2712 5511034330 14365 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 #include int _IO_fsetpos(fp, posp) _IO_FILE* fp; const _IO_fpos_t *posp; { CHECK_FILE(fp, EOF); COERCE_FILE(fp); if (_IO_seekpos(fp, *posp, 0) == _IO_pos_BAD) { /*ANSI explicily requires setting errno to a positive value on failure.*/ #ifdef EIO if (errno == 0) errno = EIO; #endif return EOF; } return 0; } ./libc-linux/libio/ioftell.c100644 1676 334 2776 5511036020 14020 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 "libioP.h" #include /* ANSI explicily requires setting errno to a positive value on failure. */ long int _IO_ftell(fp) _IO_FILE* fp; { _IO_pos_t pos; CHECK_FILE(fp, -1L); COERCE_FILE(fp); pos = _IO_seekoff(fp, 0, _IO_seek_cur|_IO_seek_not_in|_IO_seek_not_out); if (pos == _IO_pos_BAD) { #ifdef EIO if (errno == 0) errno = EIO; #endif return -1L; } return _IO_pos_as_off(pos); } ./libc-linux/libio/iofwrite.c100644 1676 334 3166 5527712560 14225 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 "libioP.h" _IO_size_t _IO_fwrite(buf, size, count, fp) const void* buf; _IO_size_t size; _IO_size_t count; _IO_FILE *fp; { _IO_size_t request = size*count; _IO_size_t written; CHECK_FILE(fp, 0); COERCE_FILE(fp); if (request == 0) return 0; written = _IO_sputn(fp, (const char *)buf, request); /* Many traditional implementations return 0 if size==0 && count > 0, but ANSI seems to require us to return count in this case. */ if (written == request) return count; else return written/size; } ./libc-linux/libio/iogetline.c100644 1676 334 4516 5520121122 14331 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 "libioP.h" #include /* Algorithm based on that used by Berkeley pre-4.4 fgets implementation. Read chars into buf (of size n), until delim is seen. Return number of chars read (at most n). Does not put a terminating '\0' in buf. If extract_delim < 0, leave delimiter unread. If extract_delim > 0, insert delim in output. */ _IO_size_t _IO_getline(fp, buf, n, delim, extract_delim) _IO_FILE *fp; char* buf; _IO_size_t n; int delim; int extract_delim; { register char *ptr = buf; do { _IO_ssize_t len = fp->_IO_read_end - fp->_IO_read_ptr; char *t; if (len <= 0) if (__underflow(fp) == EOF) break; else len = fp->_IO_read_end - fp->_IO_read_ptr; if (len >= n) len = n; t = (char*)memchr((void*)fp->_IO_read_ptr, delim, len); if (t != NULL) { _IO_size_t old_len = ptr-buf; len = t - fp->_IO_read_ptr; if (extract_delim >= 0) { t++; if (extract_delim > 0) len++; } memcpy((void*)ptr, (void*)fp->_IO_read_ptr, len); fp->_IO_read_ptr = t; return old_len + len; } memcpy((void*)ptr, (void*)fp->_IO_read_ptr, len); fp->_IO_read_ptr += len; ptr += len; n -= len; } while (n != 0); return ptr - buf; } ./libc-linux/libio/iogets.c100644 1676 334 2747 5520121040 13647 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 "libioP.h" #include char* _IO_gets(buf) char* buf; { _IO_size_t count; int ch = _IO_getc (_IO_stdin); if (ch == EOF) return NULL; if (ch == '\n') count = 0; else { buf[0] = (char)ch; count = _IO_getline(_IO_stdin, buf + 1, INT_MAX, '\n', 0) + 1; if (_IO_stdin->_IO_file_flags & _IO_ERR_SEEN) return NULL; } buf[count] = 0; return buf; } ./libc-linux/libio/ioignore.c100644 1676 334 2733 5512206722 14177 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 "libioP.h" int _IO_ignore(fp, n) register _IO_FILE *fp; _IO_size_t n; { register _IO_size_t more = n; for (;;) { _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr; if (count > 0) { if (count > more) count = more; fp->_IO_read_ptr += count; more -= count; } if (more == 0 || __underflow(fp) == EOF) break; } return n - more; } ./libc-linux/libio/iolibio.h100644 1676 334 5025 5477640504 14026 0ustar hjlisl#ifndef _IOLIBIO_H #define _IOLIBIO_H #include "libio.h" /* These emulate stdio functionality, but with a different name (_IO_ungetc instead of ungetc), and using _IO_FILE instead of FILE. */ extern int _IO_fclose __P((_IO_FILE*)); extern _IO_FILE *_IO_fdopen __P((int, const char*)); extern int _IO_fflush __P((_IO_FILE*)); extern int _IO_fgetpos __P((_IO_FILE*, _IO_fpos_t*)); extern char* _IO_fgets __P((char*, int, _IO_FILE*)); extern _IO_FILE *_IO_fopen __P((const char*, const char*)); extern int _IO_fprintf __P((_IO_FILE*, const char*, ...)); extern int _IO_fputs __P((const char*, _IO_FILE*)); extern _IO_size_t _IO_fread __P((void *, _IO_size_t, _IO_size_t, _IO_FILE*)); extern int _IO_fscanf __P((_IO_FILE *, const char *, ...)); extern int _IO_fsetpos __P((_IO_FILE*, const _IO_fpos_t *)); extern long int _IO_ftell __P((_IO_FILE*)); extern _IO_size_t _IO_fwrite __P((const void*, _IO_size_t, _IO_size_t, _IO_FILE*)); extern char* _IO_gets __P((char*)); extern void _IO_perror __P((const char*)); extern int _IO_printf __P((const char *, ...)); extern int _IO_puts __P((const char*)); extern int _IO_scanf __P((const char*, ...)); extern void _IO_setbuffer __P((_IO_FILE *, char*, _IO_size_t)); extern int _IO_setvbuf __P((_IO_FILE*, char*, int, _IO_size_t)); extern int _IO_sscanf __P((const char*, const char*, ...)); extern int _IO_sprintf __P((char *, const char*, ...)); extern int _IO_ungetc __P((int, _IO_FILE*)); extern int _IO_vfscanf __P((_IO_FILE *, const char *, _IO_va_list, int *__errp)); extern int _IO_vsscanf __P((const char *, const char *, _IO_va_list)); extern int _IO_vsprintf __P((char*, const char*, _IO_va_list)); #ifndef _IO_pos_BAD #define _IO_pos_BAD ((_IO_fpos_t)(-1)) #endif #define _IO_clearerr(FP) ((FP)->_flags &= ~(_IO_ERR_SEEN|_IO_EOF_SEEN)) #define _IO_feof(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0) #define _IO_ferror(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0) #define _IO_fseek(__fp, __offset, __whence) \ (_IO_seekoff(__fp, __offset, (_IO_off_t)(__whence)) == _IO_pos_BAD ? EOF : 0) #define _IO_rewind(FILE) (void)_IO_seekoff(FILE, 0, 0) #define _IO_vprintf(FORMAT, ARGS) _IO_vfprintf(_IO_stdout, FORMAT, ARGS) #define _IO_freopen(FILENAME, MODE, FP) \ (_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE)) #define _IO_fileno(FP) ((FP)->_fileno) extern _IO_FILE* _IO_popen __P((const char*, const char*)); #define _IO_pclose _IO_fclose #define _IO_setbuf(_FP, _BUF) _IO_setbuffer(_FP, _BUF, _IO_BUFSIZ) #define _IO_setlinebuf(_FP) _IO_setvbuf(_FP, NULL, 1, 0) #endif /* _IOLIBIO_H */ ./libc-linux/libio/iopadn.c100644 1676 334 3700 5437457261 13645 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 "libioP.h" #define PADSIZE 16 static char const blanks[PADSIZE] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}; static char const zeroes[PADSIZE] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; _IO_ssize_t _IO_padn(fp, pad, count) _IO_FILE *fp; int pad; _IO_ssize_t count; { char padbuf[PADSIZE]; const char *padptr; register int i; _IO_size_t written = 0, w; if (pad == ' ') padptr = blanks; else if (pad == '0') padptr = zeroes; else { for (i = PADSIZE; --i >= 0; ) padbuf[i] = pad; padptr = padbuf; } for (i = count; i >= PADSIZE; i -= PADSIZE) { w = _IO_sputn(fp, padptr, PADSIZE); written += w; if (w != PADSIZE) return written; } if (i > 0) { w = _IO_sputn(fp, padptr, i); written += w; } return written; } ./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/libio/iopopen.c100644 1676 334 12626 5477556435 14102 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. */ /* written by Per Bothner (bothner@cygnus.com) */ #include "libioP.h" #if _IO_HAVE_SYS_WAIT #include #include #include #ifndef errno extern int errno; #endif #include #ifndef _IO_fork #define _IO_fork vfork /* defined in libiberty, if needed */ _IO_pid_t _IO_fork(); #endif #endif /* _IO_HAVE_SYS_WAIT */ #ifndef _IO_pipe #define _IO_pipe pipe extern int _IO_pipe(); #endif #ifndef _IO_dup2 #define _IO_dup2 dup2 extern int _IO_dup2(); #endif #ifndef _IO_waitpid #define _IO_waitpid waitpid #endif #ifndef _IO_execl #define _IO_execl execl #endif #ifndef _IO__exit #define _IO__exit _exit #endif struct _IO_proc_file { struct _IO_FILE_plus _file; /* Following fields must match those in class procbuf (procbuf.h) */ _IO_pid_t _pid; struct _IO_proc_file *_next; }; typedef struct _IO_proc_file _IO_proc_file; static struct _IO_proc_file *proc_file_chain = NULL; _IO_FILE * _IO_proc_open(fp, command, mode) _IO_FILE* fp; const char *command; const char *mode; { #if _IO_HAVE_SYS_WAIT int read_or_write; int pipe_fds[2]; int parent_end, child_end; _IO_pid_t child_pid; if (_IO_file_is_open(fp)) return NULL; if (_IO_pipe(pipe_fds) < 0) return NULL; if (mode[0] == 'r') { parent_end = pipe_fds[0]; child_end = pipe_fds[1]; read_or_write = _IO_NO_WRITES; } else { parent_end = pipe_fds[1]; child_end = pipe_fds[0]; read_or_write = _IO_NO_READS; } ((_IO_proc_file*)fp)->_pid = child_pid = _IO_fork(); if (child_pid == 0) { int child_std_end = mode[0] == 'r' ? 1 : 0; _IO_close(parent_end); if (child_end != child_std_end) { _IO_dup2(child_end, child_std_end); _IO_close(child_end); } /* Posix.2: "popen() shall ensure that any streams from previous popen() calls that remain open in the parent process are closed in the new child process." */ while (proc_file_chain) { _IO_close (_IO_fileno ((_IO_FILE *) proc_file_chain)); proc_file_chain = proc_file_chain->_next; } _IO_execl("/bin/sh", "sh", "-c", command, NULL); _IO__exit(127); } _IO_close(child_end); if (child_pid < 0) { _IO_close(parent_end); return NULL; } _IO_fileno(fp) = parent_end; /* Link into proc_file_chain. */ ((_IO_proc_file*)fp)->_next = proc_file_chain; proc_file_chain = (_IO_proc_file*)fp; fp->_IO_file_flags |= CLOSED_FILEBUF_FLAGS; fp->_IO_file_flags = read_or_write | (fp->_IO_file_flags & ~(_IO_NO_READS|_IO_NO_WRITES)); return fp; #else /* !_IO_HAVE_SYS_WAIT */ return NULL; #endif } _IO_FILE * _IO_popen(command, mode) const char *command; const char *mode; { _IO_proc_file *fpx = (_IO_proc_file*)malloc(sizeof(_IO_proc_file)); _IO_FILE *fp = (_IO_FILE*)fpx; if (fp == NULL) return NULL; _IO_init(fp, 0); fp->_jumps = &_IO_proc_jumps; _IO_file_init(fp); ((struct _IO_FILE_plus*)fp)->_vtable = NULL; if (_IO_proc_open (fp, command, mode) != NULL) return fp; free (fpx); return NULL; } int _IO_proc_close(fp) _IO_FILE *fp; { /* This is not name-space clean. FIXME! */ #if _IO_HAVE_SYS_WAIT int wstatus; _IO_proc_file **ptr = &proc_file_chain; _IO_pid_t wait_pid; int status = -1; /* Unlink from proc_file_chain. */ for (; *ptr; ptr = &((*ptr)->_next)) { if (*ptr == (_IO_proc_file*)fp) { *ptr = (*ptr)->_next; status = 0; break; } } if (status < 0 || _IO_close(_IO_fileno(fp)) < 0) return -1; /* POSIX.2 Rationale: "Some historical implementations either block or ignore the signals SIGINT, SIGQUIT, and SIGHUP while waiting for the child process to terminate. Since this behavior is not described in POSIX.2, such implementations are not conforming." */ do { wait_pid = _IO_waitpid (((_IO_proc_file*)fp)->_pid, &wstatus, 0); } while (wait_pid == -1 && errno == EINTR); if (wait_pid == -1) return -1; return wstatus; #else /* !_IO_HAVE_SYS_WAIT */ return -1; #endif } struct _IO_jump_t _IO_proc_jumps = { _IO_file_overflow, _IO_file_underflow, _IO_file_xsputn, _IO_default_xsgetn, _IO_file_read, _IO_file_write, _IO_file_doallocate, _IO_default_pbackfail, _IO_file_setbuf, _IO_file_sync, _IO_file_finish, _IO_proc_close, _IO_file_stat, _IO_file_seek, _IO_file_seekoff, _IO_default_seekpos, }; ./libc-linux/libio/ioprims.c100644 1676 334 4047 5472200077 14050 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. */ /* I/O OS-level primitives. Needs to be replaced if not using Unix. Also needs to be replaced if avoiding name-space pollution (in which case read would be defined in terms of _IO_read, rather than vice versa). */ #ifndef __linux__ #include "libioP.h" #include #include #include #ifdef TODO /* Add open, isatty */ #endif _IO_ssize_t _IO_read (fildes, buf, nbyte) int fildes; void *buf; _IO_size_t nbyte; { return read (fildes, buf, nbyte); } _IO_ssize_t _IO_write (fildes, buf, nbyte) int fildes; const void *buf; _IO_size_t nbyte; { return write (fildes, buf, nbyte); } _IO_off_t _IO_lseek (fildes, offset, whence) int fildes; _IO_off_t offset; int whence; { return lseek (fildes, offset, whence); } int _IO_close (fildes) int fildes; { return close (fildes); } int _IO_fstat (fildes, buf) int fildes; struct stat *buf; { return fstat (fildes, buf); } #endif ./libc-linux/libio/ioprintf.c100644 1676 334 2641 5454330541 14216 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 "libioP.h" #ifdef __STDC__ #include #else #include #endif int _IO_printf #ifdef __STDC__ (const char* format, ...) #else (format, va_alist) char *format; va_dcl #endif { int ret; va_list args; _IO_va_start(args, format); ret = _IO_vfprintf(_IO_stdout, format, args); va_end(args); return ret; } ./libc-linux/libio/ioputs.c100644 1676 334 2462 5435105202 13701 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 "libioP.h" int _IO_puts(str) const char *str; { _IO_size_t len = strlen(str); if (_IO_sputn(_IO_stdout, str, len) != len) return EOF; if (_IO_putc('\n', _IO_stdout) == EOF) return EOF; return len+1; } ./libc-linux/libio/ioscanf.c100644 1676 334 2644 5466006672 14021 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 "libioP.h" #ifdef __STDC__ #include #else #include #endif int _IO_scanf #ifdef __STDC__ (const char* format, ...) #else (format, va_alist) char *format; va_dcl #endif { int ret; va_list args; _IO_va_start(args, format); ret = _IO_vfscanf(_IO_stdin, format, args, NULL); va_end(args); return ret; } ./libc-linux/libio/ioseekoff.c100644 1676 334 3204 5434302565 14335 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 _IO_pos_t _IO_seekoff(fp, offset, flags) _IO_FILE* fp; _IO_off_t offset; _IO_seekflags flags; { int dir = flags & 3; /* If we have a backup buffer, get rid of it, since the __seekoff callback may not know to do the right thing about it. This may be over-kill, but it'll do for now. TODO */ if (_IO_have_backup (fp)) { if (dir == _IO_seek_cur && _IO_in_backup (fp)) offset -= fp->_IO_read_end - fp->_IO_read_ptr; _IO_free_backup_area (fp); } return fp->_jumps->__seekoff(fp, offset, flags); } ./libc-linux/libio/ioseekpos.c100644 1676 334 2760 5434302570 14366 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 _IO_pos_t _IO_seekpos(fp, pos, flags) _IO_FILE* fp; _IO_pos_t pos; _IO_seekflags flags; { /* If we have a backup buffer, get rid of it, since the __seekoff callback may not know to do the right thing about it. This may be over-kill, but it'll do for now. TODO */ if (_IO_have_backup (fp)) _IO_free_backup_area (fp); return fp->_jumps->__seekpos(fp, pos, flags); } ./libc-linux/libio/iosetbuffer.c100644 1676 334 2562 5511034461 14677 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 "libioP.h" void _IO_setbuffer(fp, buf, size) _IO_FILE *fp; char *buf; _IO_size_t size; { CHECK_FILE(fp, ); COERCE_FILE(fp); fp->_flags &= ~_IO_LINE_BUF; if (buf) (void)fp->_jumps->__setbuf(fp, buf, size); else (void)fp->_jumps->__setbuf(fp, NULL, 0); } ./libc-linux/libio/iosetvbuf.c100644 1676 334 3410 5511034507 14362 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 "libioP.h" #define _IOFBF 0 /* Fully buffered. */ #define _IOLBF 1 /* Line buffered. */ #define _IONBF 2 /* No buffering. */ int _IO_setvbuf(fp, buf, mode, size) _IO_FILE* fp; char* buf; int mode; _IO_size_t size; { CHECK_FILE(fp, EOF); COERCE_FILE(fp); switch (mode) { case _IOFBF: fp->_IO_file_flags &= ~_IO_LINE_BUF; if (buf == NULL) return 0; return fp->_jumps->__setbuf(fp, buf, size); case _IOLBF: fp->_IO_file_flags |= _IO_LINE_BUF; if (buf == NULL) return 0; return fp->_jumps->__setbuf(fp, buf, size); case _IONBF: return fp->_jumps->__setbuf(fp, NULL, 0); default: return EOF; } } ./libc-linux/libio/iosprintf.c100644 1676 334 2702 5454330544 14402 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 "libioP.h" #ifdef __STDC__ #include #else #include #endif int _IO_sprintf #ifdef __STDC__ (char *string, const char* format, ...) #else (string, format, va_alist) char *string; char *format; va_dcl #endif { int ret; va_list args; _IO_va_start(args, format); ret = _IO_vsprintf(string, format, args); va_end(args); return ret; } ./libc-linux/libio/iosscanf.c100644 1676 334 2671 5454330545 14200 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 "libioP.h" #ifdef __STDC__ #include #else #include #endif int _IO_sscanf #ifdef __STDC__ (const char * string, const char* format, ...) #else (string, format, va_alist) char *format; va_dcl #endif { int ret; va_list args; _IO_va_start(args, format); ret = _IO_vsscanf(string, format, args); va_end(args); return ret; } ./libc-linux/libio/iostdio.h100644 1676 334 6336 5454137465 14062 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. */ /* This file defines a stdio-like environment, except that it avoid link-time name clashes with an existing stdio. It allows for testing the libio using stdio-using programs with an incompatible libc.a. It is not predantically correct - e.g. some macros are used that may evaluate a stream argument more than once. */ #include "iolibio.h" typedef _IO_FILE FILE; #ifndef EOF #define EOF (-1) #endif #ifndef BUFSIZ #define BUFSIZ 1024 #endif /* #define size_t, fpos_t L_tmpname TMP_MAX */ #define _IOFBF 0 /* Fully buffered. */ #define _IOLBF 1 /* Line buffered. */ #define _IONBF 2 /* No buffering. */ #define SEEK_SET 0 #define SEEK_CUR 1 #define SEEK_END 2 #define stdin _IO_stdin #define stdout _IO_stdout #define stderr _IO_stderr #define getc(_fp) _IO_getc(_fp) #define putc(_ch, _fp) _IO_putc(_ch, _fp) #define clearerr _IO_clearerr #define fclose _IO_fclose #define feof _IO_feof #define ferror _IO_ferror #define fflush _IO_fflush #define fgetc(__fp) _IO_getc(_fp) #define fgetpos _IO_fgetpos #define fgets _IO_fgets #define fopen _IO_fopen #define fprintf _IO_fprintf #define fputc(_ch, _fp) _IO_putc(_ch, _fp) #define fputs _IO_fputs #define fread _IO_fread #define freopen _IO_freopen #define fscanf _IO_fscanf #define fseek _IO_fseek #define fsetpos _IO_fsetpos #define ftell _IO_ftell #define fwrite _IO_fwrite #define gets _IO_gets #define perror _IO_perror #define printf _IO_printf #define puts _IO_puts #define remove ??? _ARGS((const char*)) #define rename ??? _ARGS((const char* _old, const char* _new)) #define rewind _IO_rewind #define scanf _IO_scanf #define setbuf _IO_setbuf #define setbuffer ??? _ARGS((FILE*, char*, int)) #define setvbuf _IO_setvbuf #define sprintf _IO_sprintf #define sscanf _IO_sscanf #define tmpfile ??? _ARGS((void)) #define tmpnam ??? _ARGS((char*)) #define ungetc _IO_ungetc #define vfprintf _IO_vfprintf #define vprintf(__fmt, __args) vfprintf(stdout, __fmt, __args) #define vsprintf _IO_vsprintf #if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE) #define fdopen _IO_fdopen #define fileno _IO_fileno #define popen _IO_popen #define pclose _IO_pclose #define setbuf _IO_setbuf #define setlinebuf _IO_setlinebuf #endif ./libc-linux/libio/iostrerror.c100644 1676 334 347 5470606402 14557 0ustar hjlisl#ifndef __linux__ /* This should be replaced by whatever namespace-clean version of strerror you have available. */ extern char *strerror(); char * _IO_strerror(errnum) int errnum; { return strerror(errnum); } #endif ./libc-linux/libio/ioungetc.c100644 1676 334 2420 5511034525 14171 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 "libioP.h" int _IO_ungetc(c, fp) int c; _IO_FILE *fp; { CHECK_FILE(fp, EOF); COERCE_FILE(fp); if (c == EOF) return EOF; return _IO_sputbackc(fp, (unsigned char)c); } ./libc-linux/libio/iovsprintf.c100644 1676 334 2754 5435104500 14565 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 "libioP.h" #include "strfile.h" int _IO_vsprintf (string, format, args) char *string; const char *format; _IO_va_list args; { _IO_strfile sf; int ret; _IO_init((_IO_FILE*)&sf, 0); ((_IO_FILE*)&sf)->_jumps = &_IO_str_jumps; _IO_str_init_static ((_IO_FILE*)&sf, string, -1, string); ret = _IO_vfprintf((_IO_FILE*)&sf, format, args); _IO_putc('\0', (_IO_FILE*)&sf); return ret; } ./libc-linux/libio/iovsscanf.c100644 1676 334 2700 5477556434 14373 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 "libioP.h" #include "strfile.h" int _IO_vsscanf (string, format, args) const char *string; const char *format; _IO_va_list args; { _IO_strfile sf; _IO_init((_IO_FILE*)&sf, 0); ((_IO_FILE*)&sf)->_jumps = &_IO_str_jumps; _IO_str_init_static ((_IO_FILE*)&sf, (char*)string, 0, NULL); return _IO_vfscanf((_IO_FILE*)&sf, format, args, NULL); } ./libc-linux/libio/outfloat.c100644 1676 334 13663 5437457263 14263 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 "libioP.h" /* Format floating-point number and print them. Return number of chars printed, or EOF on error. sign_mode == '+' : print "-" or "+" sign_mode == ' ' : print "-" or " " sign_mode == '\0' : print "-' or "" */ int _IO_outfloat(value, sb, type, width, precision, flags, sign_mode, fill) double value; _IO_FILE *sb; int type; int width; int precision; int flags; int sign_mode; int fill; { int count = 0; #define PUT(x) do {if (_IO_putc(x, sb) < 0) goto error; count++;} while (0) #define PUTN(p, n) \ do {int _n=n; count+=_n; if (_IO_sputn(sb, p,_n) != _n) goto error;} while(0) #define PADN(fill, n) \ do {int _n = n; count+=_n; if (_IO_padn(sb, fill, _n) != _n) goto error;} while (0) int pad_kind = flags & (_IO_LEFT|_IO_RIGHT|_IO_INTERNAL); int skip_zeroes = 0; int show_dot = (flags & _IO_SHOWPOINT) != 0; int decpt; int sign; int mode; int exponent_size; int print_sign; int trailing_zeroes, useful_digits; int padding, unpadded_width; char *p; char *exponent_start; register int i; #define EBUF_SIZE 12 #define EBUF_END &ebuf[EBUF_SIZE] char ebuf[EBUF_SIZE]; char *end; int exp = 0; switch (type) { case 'f': mode = 3; break; case 'e': case 'E': exp = type; mode = 2; if (precision != 999) precision++; /* Add one to include digit before decimal point. */ break; case 'g': case 'G': exp = type == 'g' ? 'e' : 'E'; if (precision == 0) precision = 1; if (!(flags & _IO_SHOWPOINT)) skip_zeroes = 1; type = 'g'; mode = 2; break; } /* Do the actual convension */ if (precision == 999 && mode != 3) mode = 0; p = _IO_dtoa(value, mode, precision, &decpt, &sign, &end); useful_digits = end-p; exponent_start = EBUF_END; if (mode == 0) precision = useful_digits; /* Check if we need to emit an exponent. */ if (mode != 3 && decpt != 9999) { i = decpt - 1; if ((type != 'g' && type != 'F') || i < -4 || i >= precision) { /* Print the exponent into ebuf. We write ebuf in reverse order (right-to-left). */ char sign; if (i >= 0) sign = '+'; else sign = '-', i = -i; /* Note: ANSI requires at least 2 exponent digits. */ do { *--exponent_start = (i % 10) + '0'; i /= 10; } while (i >= 10); *--exponent_start = i + '0'; *--exponent_start = sign; *--exponent_start = exp; } } exponent_size = EBUF_END - exponent_start; if (mode == 1) precision = 1; /* If we print an exponent, always show just one digit before point. */ if (exponent_size) decpt = 1; if (decpt == 9999) { /* Infinity or NaN */ decpt = useful_digits; precision = 0; show_dot = 0; } /* dtoa truncates trailing zeroes. Set the variable trailing_zeroes to the number of 0's we have to add (after the decimal point). */ if (skip_zeroes) trailing_zeroes = 0; else if (type == 'f') trailing_zeroes = useful_digits <= decpt ? precision : precision-(useful_digits-decpt); else if (exponent_size) /* 'e' 'E' or 'g' format using exponential notation*/ trailing_zeroes = precision - useful_digits; else /* 'g' format not using exponential notation. */ trailing_zeroes = useful_digits <= decpt ? precision - decpt : precision-useful_digits; if (trailing_zeroes < 0) trailing_zeroes = 0; if (trailing_zeroes != 0 || useful_digits > decpt) show_dot = 1; if (sign_mode == 0) print_sign = sign ? '-' : 0; else if (sign_mode == '+') print_sign = sign ? '-' : '+'; else /* if (sign_mode == ' ') */ print_sign = sign ? '-' : ' '; /* Calculate the width (before padding). */ unpadded_width = (print_sign != 0) + trailing_zeroes + exponent_size + show_dot + useful_digits + (decpt > useful_digits ? decpt - useful_digits : decpt > 0 ? 0 : 1 - decpt); padding = width > unpadded_width ? width - unpadded_width : 0; if (padding > 0 && pad_kind != _IO_LEFT && pad_kind != _IO_INTERNAL) PADN(fill, padding); /* Default (right) adjust */ if (print_sign) PUT(print_sign); if (pad_kind == _IO_INTERNAL && padding > 0) PADN(fill, padding); if (decpt > 0) { if (useful_digits >= decpt) PUTN(p, decpt); else { PUTN(p, useful_digits); PADN('0', decpt-useful_digits); } if (show_dot) { PUT('.'); /* Print digits after the decimal point. */ if (useful_digits > decpt) PUTN(p + decpt, useful_digits-decpt); } } else { PUT('0'); if (show_dot) { PUT('.'); PADN('0', -decpt); /* Print digits after the decimal point. */ PUTN(p, useful_digits); } } PADN('0', trailing_zeroes); if (exponent_size) PUTN(exponent_start, exponent_size); if (pad_kind == _IO_LEFT && padding > 0) /* Left adjustment*/ PADN(fill, padding); return count; error: return EOF; } ./libc-linux/libio/stdfiles.c100644 1676 334 3213 5477556436 14217 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 "libioP.h" /* check following! */ #define FILEBUF_LITERAL(CHAIN, FLAGS, FD) \ { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, CHAIN, &_IO_file_jumps, FD} #define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \ struct _IO_FILE_plus NAME = {FILEBUF_LITERAL(CHAIN, FLAGS, FD), 0} DEF_STDFILE(_IO_stdin_, 0, 0, _IO_NO_WRITES); DEF_STDFILE(_IO_stdout_, 1, &_IO_stdin_._file, _IO_NO_READS); DEF_STDFILE(_IO_stderr_, 2, &_IO_stdout_._file, _IO_NO_READS+_IO_UNBUFFERED); _IO_FILE *_IO_list_all = &_IO_stderr_._file; ./libc-linux/libio/strfile.h100644 1676 334 3002 5473734701 14040 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 TODO Merge into libio.h ? #endif typedef void *(*_IO_alloc_type) __P((_IO_size_t)); typedef void (*_IO_free_type) __P((void*)); struct _IO_str_fields { /* The current length is max(_len, _IO_write_ptr-_IO_write_base). */ _IO_size_t _len; _IO_alloc_type _allocate_buffer; _IO_free_type _free_buffer; }; typedef struct _IO_strfile_ { struct _IO_FILE_plus _f; struct _IO_str_fields _s; } _IO_strfile; ./libc-linux/libio/strops.c100644 1676 334 16730 5477556437 13765 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 "strfile.h" #include "libioP.h" #include #define LEN(fp) (((_IO_strfile*)(fp))->_s._len) #ifdef TODO /* An "unbounded buffer" is when a buffer is supplied, but with no specified length. An example is the buffer argument to sprintf. */ #endif void _IO_str_init_static (fp, ptr, size, pstart) _IO_FILE *fp; char *ptr; int size; char *pstart; { if (size == 0) size = strlen(ptr); else if (size < 0) { /* If size is negative 'the characters are assumed to continue indefinitely.' This is kind of messy ... */ #if 1 int s; size = 512; /* Try increasing powers of 2, as long as we don't wrap around. This can lose in pathological cases (ptr near the end of the address space). A better solution might be to adjust the size on underflow/overflow. FIXME. */ for (s; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; ) size = s; size = s; #else /* The following semi-portable kludge assumes that sizeof(unsigned long) == sizeof(char*). Hence, (unsigned long)(-1) should be the largest possible address. */ unsigned long highest = (unsigned long)(-1); /* Pointers are signed on some brain-damaged systems, in which case we divide by two to get the maximum signed address. */ if ((char*)highest < ptr) highest >>= 1; size = (char*)highest - ptr; #endif } _IO_setb(fp, ptr, ptr+size, 0); fp->_IO_write_base = ptr; fp->_IO_read_base = ptr; fp->_IO_read_ptr = ptr; if (pstart) { fp->_IO_write_ptr = pstart; fp->_IO_write_end = ptr+size; fp->_IO_read_end = pstart; } else { fp->_IO_write_ptr = ptr; fp->_IO_write_end = ptr; fp->_IO_read_end = ptr+size; } LEN(fp) = size; /* A null _allocate_buffer function flags the strfile as being static. */ (((_IO_strfile*)(fp))->_s._allocate_buffer) = (_IO_alloc_type)0; } void _IO_str_init_readonly (fp, ptr, size) _IO_FILE *fp; const char *ptr; int size; { _IO_str_init_static (fp, (char*)ptr, size, NULL); fp->_IO_file_flags |= _IO_NO_WRITES; } int _IO_str_overflow (fp, c) register _IO_FILE* fp; int c; { int flush_only = c == EOF; _IO_size_t pos = fp->_IO_write_ptr - fp->_IO_write_base; _IO_size_t get_pos = fp->_IO_read_ptr - fp->_IO_read_base; if (fp->_flags & _IO_NO_WRITES) return flush_only ? 0 : EOF; if (pos > LEN(fp)) LEN(fp) = pos; if ((fp->_flags & _IO_TIED_PUT_GET) && !(fp->_flags & _IO_CURRENTLY_PUTTING)) { pos = get_pos; fp->_flags |= _IO_CURRENTLY_PUTTING; get_pos = LEN(fp); } if (pos >= _IO_blen(fp) + flush_only) { if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */ { #ifdef TODO if (indefinite size) { fp->_IO_buf_end += 512; } else #endif return EOF; } else { char *new_buf; _IO_size_t new_size = 2 * _IO_blen(fp); new_buf = (char*)(*((_IO_strfile*)fp)->_s._allocate_buffer)(new_size); if (new_buf == NULL) { /* __ferror(fp) = 1; */ return EOF; } memcpy(new_buf, fp->_IO_buf_base, _IO_blen(fp)); #if 0 if (lenp == &LEN(fp)) /* use '\0'-filling */ memset(new_buf + pos, 0, blen() - pos); #endif if (fp->_IO_buf_base) { (*((_IO_strfile*)fp)->_s._free_buffer)(fp->_IO_buf_base); /* Make sure _IO_setb won't try to delete _IO_buf_base. */ fp->_IO_buf_base = NULL; } _IO_setb(fp, new_buf, new_buf + new_size, 1); fp->_IO_write_base = new_buf; } fp->_IO_write_end = fp->_IO_buf_end; } fp->_IO_write_ptr = fp->_IO_buf_base + pos; fp->_IO_read_base = fp->_IO_buf_base; fp->_IO_read_ptr = fp->_IO_buf_base + get_pos;; fp->_IO_read_end = fp->_IO_buf_base + LEN(fp);; if (!flush_only) *fp->_IO_write_ptr++ = (unsigned char) c; return c; } int _IO_str_underflow (fp) register _IO_FILE* fp; { _IO_size_t ppos = fp->_IO_write_ptr - fp->_IO_write_base; if (ppos > LEN(fp)) LEN(fp) = ppos; if ((fp->_flags & _IO_TIED_PUT_GET) && (fp->_flags & _IO_CURRENTLY_PUTTING)) { fp->_flags &= ~_IO_CURRENTLY_PUTTING; fp->_IO_write_ptr = fp->_IO_write_end; } fp->_IO_read_end = fp->_IO_read_base + LEN(fp); if (fp->_IO_read_ptr < fp->_IO_read_end) return *fp->_IO_read_ptr; else return EOF; } _IO_ssize_t _IO_str_count (fp) register _IO_FILE *fp; { _IO_ssize_t put_len = fp->_IO_write_ptr - fp->_IO_write_base; if (put_len < ((_IO_strfile*)fp)->_s._len) put_len = ((_IO_strfile*)fp)->_s._len; return put_len; } _IO_pos_t _IO_str_seekoff(fp, offset, mode) register _IO_FILE *fp; _IO_off_t offset; _IO_seekflags mode; { _IO_ssize_t cur_size = _IO_str_count(fp); _IO_pos_t new_pos = EOF; int dir = mode & 3; /* Move the get pointer, if requested. */ if (!(mode & _IO_seek_not_in)) { switch (dir) { case _IO_seek_end: offset += cur_size; break; case _IO_seek_cur: offset += fp->_IO_read_ptr - fp->_IO_read_base; break; default: /* case _IO_seek_set: */ break; } if (offset < 0 || (_IO_size_t)offset > cur_size) return EOF; fp->_IO_read_ptr = fp->_IO_read_base + offset; fp->_IO_read_end = fp->_IO_read_base + cur_size; new_pos = offset; } /* Move the put pointer, if requested. */ if (!(mode & _IO_seek_not_out)) { switch (dir) { case _IO_seek_end: offset += cur_size; break; case _IO_seek_cur: offset += fp->_IO_write_ptr - fp->_IO_write_base; break; default: /* case _IO_seek_set: */ break; } if (offset < 0 || (_IO_size_t)offset > cur_size) return EOF; fp->_IO_write_ptr = fp->_IO_write_base + offset; new_pos = offset; } return new_pos; } int _IO_str_pbackfail(fp, c) register _IO_FILE *fp; int c; { if ((fp->_flags & _IO_NO_WRITES) && c != EOF) return EOF; return _IO_default_pbackfail(fp, c); } void _IO_str_finish(fp) register _IO_FILE* fp; { if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF)) (((_IO_strfile*)fp)->_s._free_buffer)(fp->_IO_buf_base); fp->_IO_buf_base = NULL; _IO_default_finish(fp); } struct _IO_jump_t _IO_str_jumps = { _IO_str_overflow, _IO_str_underflow, _IO_default_xsputn, _IO_default_xsgetn, _IO_default_read, _IO_default_write, _IO_default_doallocate, _IO_str_pbackfail, _IO_default_setbuf, _IO_default_sync, _IO_str_finish, _IO_default_close, _IO_default_stat, _IO_default_seek, _IO_str_seekoff, _IO_default_seekpos, }; ./libc-linux/libio/stdio/ 40755 1676 334 0 5550053054 13240 5ustar hjlisl./libc-linux/libio/stdio/ChangeLog100644 1676 334 6005 5511427256 15116 0ustar hjlislSat Jan 1 21:13:59 1993 H.J. Lu (hlu@nighthawk) * clearerr.c: * feof.c: * ferror.c: * fgetc.c: * fileno.c: * fputc.c: * freopen.c: * fseek.c: * getw.c: * putw.c: * rewind.c: * setfileno.c: * vfprintf.c: * vfscanf.c: check fp with CHECK_FILE(FILE,RET). Sun Dec 19 12:36:10 1993 H.J. Lu (hlu@nighthawk) * stdio.h: don't define __P since it is taken care of in libio.h. change const to __const. Thu Dec 2 22:25:31 1993 H.J. Lu (hlu@nighthawk) * Makefile.in (STDIO_OBJECTS): add stdio.o, remove.o, tmpfile.o and tmpnam.o. change popen.o to pclose.o. * stdio.h: include if __linux__ is defined. should be copied from glibc to help put libio into glibc. change _ARGS to __P. check if __P is already defined. declare psignal (), _sys_errlist, _sys_siglist if __GNU_LIBRARY__ is defined. add getw () and putw (). (getc, getchar, putc, putchar): new declaration. move macros after the declaration. (tempnam): new declaration. define TMP_MAX as 238328. see ../iotempname.c. * popen.c: removed. * pclose.c: renamed from popen.c. * stdio.c: new file for stdin, stdout and stderr. * vfprintf.c: * fdopen.c: add alias for Linux. * remove.c: new file for remove (). * tempnam.c: new file for tempnam (). * tmpfile.c: new file for tmpfile (). * tmpnam.c: new file for tmpnam (). * configure.in: Linux uses aliases instead of -D_IO_foo=foo. Move #define _HAVE_GNU_LD to the first line. remove the TODO list. rename () should be a system call. (stdio_renames): add popen if __linux__ is defined. Fri Nov 26 13:26:35 1993 Per Bothner (bothner@kalessin.cygnus.com) Bunch of little changes, many from H.J. Lu . * feof.c, setbuf.c, vprintf.c, vcanf.c: #include , for error checking. * fileno.c: #include libioP.h, not just libio.h. * fputc.c: Fix typo. * fseek.c, rewind.c: Use #include "...", not <...> ,for local files. * getc.c, getchar.c, putc.c, putchar.c: New files, providing non-macro versions of the standard macros. * getw.c, putw.c, setfileno.c, setlinebuf.c: New files. * Makefile.in (STDIO_OBJECTS): Add new files. * vfscanf.c: Add missing new 4th arg to _IO_vfscanf call. Thu Oct 14 16:12:07 1993 Karen Christiansen (karen@deneb.cygnus.com) * configure.in: changed mv to mv -f Mon Oct 4 17:29:23 1993 Per Bothner (bothner@kalessin.cygnus.com) * configure.in (stdio_renames): Add fgetpos, fsetpos, gets, perror, setbuffer, ungetc. * clearerr.c, ferror.c, fgetc.c, fileno.c, fputc.c, freopen.c, fseek.c, popen.c, rewind.c, setbuf.c: New files. * Makefile.in (STDIO_OBJECTS): Add new files. * stdio.h: Use _IO_XXX instead of _G_XXX many places. #include instead of <_stdio.h>, to get useful defs. Fri Aug 20 00:28:28 1993 Per Bothner (bothner@kalessin.cygnus.com) * feof.c, vprintf.c, vscanf.c: Converted stub functions. * configure.in (stdio_renamed): Removed feof. Added sprintf sscanf vsscanf. * ChangeLog.old: Copy of old libg++/iostream/stdio/ChangeLog. ./libc-linux/libio/stdio/ChangeLog.old100644 1676 334 11617 5435077202 15715 0ustar hjlislThu Jun 24 12:34:43 1993 Per Bothner (bothner@rtl.cygnus.com) * configure.in (TARGETLIB): Fix libio.a -> libstdio++.a. Fri May 28 16:05:20 1993 Per Bothner (bothner@rtl.cygnus.com) * stdio.h: Don't define NULL as (void*)0, if __cplusplus, unless g++. Mon Apr 26 12:47:43 1993 Ian Lance Taylor (ian@cygnus.com) * tmpnam.C: Don't include unnecessary header files. Fri Oct 16 17:27:39 1992 Per Bothner (bothner@rtl.cygnus.com) * fseek.C, stdio.h: fseek() returns int, not long. * stdio.h: Define size_t with typedef, not macro. * stdio.h: Use renamed __std_filebuf_0 etc instead of old names _cin_sbuf (etc). (See ../strstrbufs.C.) * stdio.h, fprintf.C, printf.C: Implement non-macro versions of stdin/stdout/stderr, for use by debuggers. Mon Aug 17 15:26:23 1992 Mike Stump (mrs@rtl.cygnus.com) * setbuf.C (setbuf), setvbuf.C (setvbuf): Fix typo. fp should be stream. Mon Aug 10 19:22:50 1992 Per Bothner (bothner@cygnus.com) * setbuf.C, setvbuf.C: Stylistic change: Use FILE_to_streambuf macro instead of __validfp + cast. * setbuf.C (setbuf): Turn off linebuffering. Mon Aug 10 11:40:22 1992 Ian Lance Taylor (ian@dumbest.cygnus.com) * Makefile.in: always create installation directories. Mon Jul 20 14:56:39 1992 Mike Stump (mrs@cygnus.com) * fread.c (fread), fwrite.C (fwrite), tmpnam.C (tempnam): Cast a void * to a char *, since it is not a standard conversion. Fri Jun 26 12:06:47 1992 Per Bothner (bothner@rtl.cygnus.com) * stdio.h: Declare Posix stuff even without _POSIX_SOURCE unless __STRICT_ANSI__ is defined. * fflush.C: Use streambuf::sync() rather than overflow(EOF), since that seems likely to be more consistent with Posix (though only your language lawyer can tell for sure). Wed Jun 17 17:02:30 1992 Per Bothner (bothner@rtl.cygnus.com) * Makefile.in: Fix *clean rules. * stdio.h: Protect prototypes for the sake of K&R compilers. Thu Jun 4 12:01:05 1992 Per Bothner (bothner@rtl.cygnus.com) * stdio.h: Fix typo: tmpname -> tmpnam. * remove.C, rename.C: Remove redundant prototypes for link() and unlink(). Wed Jun 3 17:00:15 1992 Per Bothner (bothner@rtl.cygnus.com) * fgetpos.C, fsetpos.C, gets.C, perror.C, puts.C, remove.C, rename.C, tmpfile.C, tmpnam.C: New files, adding the remaining pieces of ANSI functionality. * stdio.h: Add new functions and macros. * Makefile.in: Add new file. * fputs.C (fputs): Fix return value according to ANSI. * ftell.C (ftell): Make sure errno is set on an error (if not set by lower-level routines), as required by ANSI. Sun May 31 14:05:07 1992 Per Bothner (bothner@rtl.cygnus.com) * Makefile.in: Use CFLAGS, not MINUS_G. Thu May 28 13:52:27 1992 Per Bothner (bothner@rtl.cygnus.com) * stdio.h: #include if _G_config.h tells us we need to. * vfscanf.C, vscanf.C, vsscanf.C: Use _G_va_list instead of va_list, to be consistent. Thu May 14 12:43:35 1992 Per Bothner (bothner@rtl.cygnus.com) * Makefile.in: Define IO_DIR (needed by depend rules). Wed May 6 15:40:46 1992 Per Bothner (bothner@rtl.cygnus.com) * Makefile.in: Delete $(TARGETLIB) before runing ar. * fseek.C: fseek() should return 0 on success, not the new position. Mon Apr 20 14:33:09 1992 Per Bothner (bothner@cygnus.com) * popen.C: New file, defines popen() and pclose() using procbufs. * Makefile.in, stdio.h: Add popen. Fri Apr 17 09:13:04 1992 Per Bothner (bothner at PersSony) * configure.in: No longer needed. * stdio.C: Removed __underflow and __overflow; now in libio.a. * fflush.C: Add FILE*->streambuf* cast, for new __overflow. * stdio.h: Use __underflow and __overflow in libio.a. Wed Feb 26 11:56:04 1992 Per Bothner (bothner at cygnus.com) * freopen.C, sscanf.C, vfscanf.C, vsprintf.C: Removed redundant 'extern "C"' (or just plain 'extern') before function definitions. * stdio.h: Try to clean up some system-specific stuff by getting parameters from _G_config.h. * vprintf.C, vsprintf.C: Use _G_va_list, not _STDIO_VA Tue Feb 4 13:26:12 1992 Per Bothner (bothner at cygnus.com) * Makefile.in: Rename library to libstdio++.a, and add 'install' rule. * fread.C: Fix to return correct count. * fwrite.C: Pull out stuff from BSD; just use streambuf::sputn. * stdio.C, fflush.c: Use new streambuf::flush_all() method. * stdio.h, hvfprintf.C, vprintf.C, vsprintf.C: Define _STDIO_VA and use it instead of va_list. (Using va_list causes namespace problems.) Thu Jan 16 17:04:26 1992 Per Bothner (bothner at cygnus.com) * *printf.C: Change __vsbprintf(sb ...) to sb->vform(...). * *scanf.C: Change __vsbscanf(sb ...) to sb->vscan(...). * emulate.C: Removed unused function __stdio_check_offset. Fri Jan 3 16:12:18 1992 Per Bothner (bothner at cygnus.com) * Makefile.in: Make fit better with rest of libg++ Makefiles. Thu Jan 2 22:31:04 1992 John Gilmore (gnu at cygnus.com) * Makefile.in, configure.in: Create. * Makefile: Remove. * ChangeLog: Create. ./libc-linux/libio/stdio/Makefile.in100644 1676 334 1326 5477557162 15425 0ustar hjlislsrcdir = . #### package, host, target, and site dependent Makefile fragments come in here. ## # These are compiled from the corresponding ../ioFOO.c files. STDIO_RENAMED_OBJECTS = ... filled in by configure ... # These are the files that a libc would want. STDIO_OBJECTS = $(STDIO_RENAMED_OBJECTS) \ clearerr.o fdopen.o feof.o ferror.o fgetc.o fileno.o \ fputc.o freopen.o fseek.o getc.o getchar.o getw.o \ pclose.o putc.o putchar.o putw.o rewind.o \ setbuf.c setfileno.o setlinebuf.o \ vfprintf.o vfscanf.o vprintf.o vscanf.o \ remove.o tmpfile.o tmpnam.o stdio.o CC_FOR_STDIO=$(CC) CINCLUDES = -I. -I$(srcdir) -I.. -I$(srcdir)/.. nothing: stdio.list: $(STDIO_OBJECTS) @echo "$(STDIO_OBJECTS)" >stdio.list ./libc-linux/libio/stdio/clearerr.c100644 1676 334 210 5511034576 15256 0ustar hjlisl#include "libioP.h" #include "stdio.h" void clearerr(fp) FILE* fp; { CHECK_FILE(fp, ); COERCE_FILE(fp); _IO_clearerr(fp); } ./libc-linux/libio/stdio/configure.in100644 1676 334 3432 5472172264 15660 0ustar hjlisl# This file is a shell script fragment that supplies the information # necessary for a configure script to process the program in # this directory. For more information, look at ../configure. configdirs= srctrigger=stdio.h srcname="libio/stdio" package_makefile_frag=../Make.pack # per-host: # per-target: TO_TOPDIR=../../ ALL=nothing MOSTLYCLEAN='*.o core stdio.list' (. ${srcdir}/../config.shared) >${package_makefile_frag} # post-target: # Certain files that are used to build a C library (such as fprintf.o) # are compled from the same sources as the ioXXX versions (such as ioprintf.c). # These lines add the appropriate rules. # NOTE: We assume a C compiler that where -o with -c works. # But these files are not built by default anyway ... stdio_renames="fclose fflush fgetpos fgets fopen fprintf fputs fread \ fscanf fsetpos ftell fwrite gets perror printf puts \ scanf setbuffer setvbuf sprintf sscanf ungetc vsprintf vsscanf" stdio_objects="" case "${target}" in *linux*) # Linux uses aliases. stdio_renames="$stdio_renames popen" for file in $stdio_renames ; do cat >>Makefile < $file.c echo "#define HAVE_GNU_LD" >> $file.c echo "#include " >> $file.c echo "#undef $file" >> $file.c echo "symbol_alias (_IO_$file, $file);" >> $file.c \$(CC_FOR_STDIO) \$(CFLAGS) \$(CINCLUDES) -c $file.c /bin/rm -f $file.c EOF stdio_objects="$stdio_objects $file.o" done ;; *-*-*) for file in $stdio_renames ; do cat >>Makefile <tmp mv -f tmp Makefile ./libc-linux/libio/stdio/fdopen.c100644 1676 334 404 5472441370 14737 0ustar hjlisl#include "libioP.h" #ifdef __linux__ #undef HAVE_GNU_LD #define HAVE_GNU_LD #include symbol_alias (_IO_fdopen, fdopen); #else _IO_FILE * fdopen (fd, mode) int fd; const char *mode; { return _IO_fdopen (fd, mode); } #endif ./libc-linux/libio/stdio/feof.c100644 1676 334 2327 5511036256 14426 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 "libioP.h" #include "stdio.h" int feof(fp) _IO_FILE* fp; { CHECK_FILE(fp, EOF); COERCE_FILE(fp); return _IO_feof(fp); } ./libc-linux/libio/stdio/ferror.c100644 1676 334 215 5511036275 14761 0ustar hjlisl#include "libioP.h" #include "stdio.h" int ferror(fp) FILE* fp; { CHECK_FILE(fp, EOF); COERCE_FILE(fp); return _IO_ferror(fp); } ./libc-linux/libio/stdio/fgetc.c100644 1676 334 212 5511036316 14543 0ustar hjlisl#include "libioP.h" #include "stdio.h" int fgetc(fp) FILE *fp; { CHECK_FILE(fp, EOF); COERCE_FILE(fp); return _IO_getc(fp); } ./libc-linux/libio/stdio/fileno.c100644 1676 334 307 5511036331 14731 0ustar hjlisl#include "libioP.h" #include "stdio.h" int fileno(fp) _IO_FILE* fp; { CHECK_FILE(fp, EOF); COERCE_FILE(fp); if (!(fp->_flags & _IO_IS_FILEBUF)) return EOF; return _IO_fileno(fp); } ./libc-linux/libio/stdio/fputc.c100644 1676 334 234 5511036412 14575 0ustar hjlisl#include "libioP.h" #include "stdio.h" int fputc(c, fp) int c; FILE *fp; { CHECK_FILE(fp, EOF); COERCE_FILE(fp); return _IO_putc(c, fp); } ./libc-linux/libio/stdio/freopen.c100644 1676 334 433 5511036434 15117 0ustar hjlisl#include "libioP.h" #include "stdio.h" FILE* freopen(filename, mode, fp) const char* filename; const char* mode; FILE* fp; { CHECK_FILE(fp, NULL); COERCE_FILE(fp); if (!(fp->_flags & _IO_IS_FILEBUF)) return NULL; return _IO_freopen(filename, mode, fp); } ./libc-linux/libio/stdio/fseek.c100644 1676 334 325 5511036470 14556 0ustar hjlisl#include "stdio.h" #include "libioP.h" int fseek(fp, offset, whence) _IO_FILE* fp; long int offset; int whence; { CHECK_FILE(fp, -1); COERCE_FILE(fp); return _IO_fseek(fp, offset, whence); } ./libc-linux/libio/stdio/rewind.c100644 1676 334 210 5511036533 14742 0ustar hjlisl#include "stdio.h" #include "libioP.h" void rewind(fp) _IO_FILE* fp; { CHECK_FILE(fp, ); COERCE_FILE(fp); _IO_rewind(fp); } ./libc-linux/libio/stdio/setbuf.c100644 1676 334 203 5472441371 14752 0ustar hjlisl#include "libioP.h" #include "stdio.h" void setbuf (fp, buf) FILE *fp; char *buf; { _IO_setbuffer(fp, buf, _IO_BUFSIZ); } ./libc-linux/libio/stdio/stdio.h100644 1676 334 12570 5505110632 14651 0ustar hjlisl/* This is part of the iostream/stdio library, providing -*- C -*- I/O. Define ANSI C stdio on top of C++ iostreams. Copyright (C) 1991 Per Bothner. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _STDIO_H #define _STDIO_H #undef _STDIO_USES_IOSTREAM #define _STDIO_USES_IOSTREAM 1 #ifdef __linux__ #include #endif #include #ifndef NULL #ifdef __cplusplus #define NULL 0 #else #define NULL (void*)0 #endif #endif #ifndef EOF #define EOF (-1) #endif #ifndef BUFSIZ #define BUFSIZ 1024 #endif #define _IOFBF 0 /* Fully buffered. */ #define _IOLBF 1 /* Line buffered. */ #define _IONBF 2 /* No buffering. */ #define SEEK_SET 0 #define SEEK_CUR 1 #define SEEK_END 2 /* define size_t. Crud in case has defined it. */ #if !defined(_SIZE_T) && !defined(_T_SIZE_) && !defined(_T_SIZE) #if !defined(__SIZE_T) && !defined(_SIZE_T_) && !defined(___int_size_t_h) #if !defined(_GCC_SIZE_T) && !defined(_SIZET_) #define _SIZE_T #define _T_SIZE_ #define _T_SIZE #define __SIZE_T #define _SIZE_T_ #define ___int_size_t_h #define _GCC_SIZE_T #define _SIZET_ typedef _IO_size_t size_t; #endif #endif #endif typedef struct _IO_FILE FILE; typedef _IO_fpos_t fpos_t; #define FOPEN_MAX _G_FOPEN_MAX #define FILENAME_MAX _G_FILENAME_MAX /* limited by the number of possible unique combinations. see * libio/iotempname.c for details. */ #define TMP_MAX 238328 #define L_ctermid 9 #define L_cuserid 9 #define P_tmpdir "/tmp" #define L_tmpnam 20 /* For use by debuggers. These are linked in if printf or fprintf are used. */ extern FILE *stdin, *stdout, *stderr; /* TODO */ #define stdin _IO_stdin #define stdout _IO_stdout #define stderr _IO_stderr __BEGIN_DECLS extern void clearerr __P((FILE*)); extern int fclose __P((FILE*)); extern int feof __P((FILE*)); extern int ferror __P((FILE*)); extern int fflush __P((FILE*)); extern int fgetc __P((FILE *)); extern int fgetpos __P((FILE* fp, fpos_t *pos)); extern char* fgets __P((char*, int, FILE*)); extern FILE* fopen __P((__const char*, __const char*)); extern int fprintf __P((FILE*, __const char* format, ...)); extern int fputc __P((int, FILE*)); extern int fputs __P((__const char *str, FILE *fp)); extern size_t fread __P((void*, size_t, size_t, FILE*)); extern FILE* freopen __P((__const char*, __const char*, FILE*)); extern int fscanf __P((FILE *fp, __const char* format, ...)); extern int fseek __P((FILE* fp, long int offset, int whence)); extern int fsetpos __P((FILE* fp, __const fpos_t *pos)); extern long int ftell __P((FILE* fp)); extern size_t fwrite __P((__const void*, size_t, size_t, FILE*)); extern int getc __P((FILE *)); extern int getchar __P((void)); extern char* gets __P((char*)); extern void perror __P((__const char *)); extern int printf __P((__const char* format, ...)); extern int putc __P((int, FILE *)); extern int putchar __P((int)); extern int puts __P((__const char *str)); extern int remove __P((__const char*)); extern int rename __P((__const char* _old, __const char* _new)); extern void rewind __P((FILE*)); extern int scanf __P((__const char* format, ...)); extern void setbuf __P((FILE*, char*)); extern void setlinebuf __P((FILE*)); extern void setbuffer __P((FILE*, char*, int)); extern int setvbuf __P((FILE*, char*, int mode, size_t size)); extern int sprintf __P((char*, __const char* format, ...)); extern int sscanf __P((__const char* string, __const char* format, ...)); extern FILE* tmpfile __P((void)); extern char* tmpnam __P((char*)); extern int ungetc __P((int c, FILE* fp)); extern int vfprintf __P((FILE *fp, char __const *fmt0, _G_va_list)); extern int vprintf __P((char __const *fmt, _G_va_list)); extern int vsprintf __P((char* string, __const char* format, _G_va_list)); #if !defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE) extern FILE *fdopen __P((int, __const char *)); extern int fileno __P((FILE*)); extern FILE* popen __P((__const char*, __const char*)); extern int pclose __P((FILE*)); #endif #if !defined(__STRICT_ANSI__) extern int getw __P((FILE*)); extern int putw __P((int, FILE*)); extern char* tempnam __P((__const char *__dir, __const char *__pfx)); #ifdef __GNU_LIBRARY__ #ifdef __USE_BSD extern int sys_nerr; extern char *sys_errlist[]; #endif #ifdef __USE_GNU extern int _sys_nerr; extern char *_sys_errlist[]; #endif #ifdef __USE_MISC /* Print a message describing the meaning of the given signal number. */ extern void psignal __P ((int __sig, __const char *__s)); #endif /* Non strict ANSI and not POSIX only. */ #endif /* __GNU_LIBRARY__ */ #endif /* __STRICT_ANSI__ */ extern int __underflow __P((struct _IO_FILE*)); extern int __overflow __P((struct _IO_FILE*, int)); #define getc(fp) _IO_getc(fp) #define putc(c, fp) _IO_putc(c, fp) #define putchar(c) putc(c, stdout) #define getchar() getc(stdin) __END_DECLS #endif /*!_STDIO_H*/ ./libc-linux/libio/stdio/vfprintf.c100644 1676 334 2650 5511036621 15340 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. */ #ifdef __linux__ #undef HAVE_GNU_LD #define HAVE_GNU_LD #include symbol_alias (_IO_vfprintf, vfprintf); #else #include "libioP.h" int vfprintf(fp, format, args) register _IO_FILE* fp; char const *format; _IO_va_list args; { CHECK_FILE(fp, -1); COERCE_FILE(fp); return _IO_vfprintf(fp, format, args); } #endif ./libc-linux/libio/stdio/vfscanf.c100644 1676 334 2470 5511036702 15130 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 "libioP.h" #include "stdio.h" int vfscanf(fp, format, args) register _IO_FILE* fp; const char *format; _IO_va_list args; { CHECK_FILE(fp, EOF); COERCE_FILE(fp); return _IO_vfscanf(fp, format, args, NULL); } ./libc-linux/libio/stdio/vprintf.c100644 1676 334 2361 5472441372 15202 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 "libioP.h" #include "stdio.h" int vprintf(format, args) const char* format; _IO_va_list args; { return _IO_vfprintf(_IO_stdout, format, args); } ./libc-linux/libio/stdio/vscanf.c100644 1676 334 2364 5472441372 14775 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 "libioP.h" #include "stdio.h" int vscanf(format, args) const char *format; _IO_va_list args; { return _IO_vfscanf(_IO_stdin, format, args, NULL); } ./libc-linux/libio/stdio/setfileno.c100644 1676 334 666 5511036551 15461 0ustar hjlisl/* Some known programs (xterm, pdksh?) non-portably change the _file field of s struct _iobuf. This kludge allows the same "functionality". This code is an undocumented feature for iostream/stdio. Use it at your own risk. */ #include "libioP.h" #include "stdio.h" void setfileno(fp, fd) _IO_FILE* fp; int fd; { CHECK_FILE(fp, ); COERCE_FILE(fp); if ((fp->_flags & _IO_IS_FILEBUF) != 0) fp->_fileno = fd; } ./libc-linux/libio/stdio/getc.c100644 1676 334 166 5477557162 14427 0ustar hjlisl#include "libioP.h" #include "stdio.h" #undef getc int getc(stream) FILE *stream; { return _IO_getc (stream); } ./libc-linux/libio/stdio/getchar.c100644 1676 334 146 5477557162 15120 0ustar hjlisl#include "libioP.h" #include "stdio.h" #undef getchar int getchar () { return _IO_getc (stdin); } ./libc-linux/libio/stdio/putc.c100644 1676 334 212 5477557162 14450 0ustar hjlisl#include "libioP.h" #include "stdio.h" #undef putc int putc(c, stream) int c; FILE *stream; { return _IO_putc(c, stream); } ./libc-linux/libio/stdio/putchar.c100644 1676 334 164 5477557162 15151 0ustar hjlisl#include "libioP.h" #include "stdio.h" #undef putchar int putchar(c) int c; { return _IO_putc(c, stdout); } ./libc-linux/libio/stdio/remove.c100644 1676 334 2153 5472441371 15005 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 "libioP.h" #include "stdio.h" #include #ifdef __GNU_LIBRARY__ #include #include function_alias(remove, __unlink, int, (file), DEFUN(remove, (file), CONST char *file)) #else int remove (file) const char *file; { return unlink (file); } #endif ./libc-linux/libio/stdio/tmpfile.c100644 1676 334 2714 5473146377 15164 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 "stdio.h" #include "libioP.h" /* This returns a new stream opened on a temporary file (generated by tmpnam) The file is opened with mode "w+b" (binary read/write). If we couldn't generate a unique filename or the file couldn't be opened, NULL is returned. */ FILE * DEFUN_VOID(tmpfile) { char *filename; _IO_FILE *f; filename = _IO_gen_tempname((char *) NULL, "tmpf", 0, (_IO_size_t *) NULL, &f); if (filename == NULL) return NULL; /* Note that this relies on the Unix semantics that a file is not really removed until it is closed. */ (void) remove (filename); return f; } ./libc-linux/libio/stdio/tmpnam.c100644 1676 334 2442 5473146400 15001 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 #ifdef __STDC__ #include #endif #include "stdio.h" #include "libioP.h" #include /* Generate a unique filename in P_tmpdir. */ char * DEFUN(tmpnam, (s), register char *s) { register char *t = _IO_gen_tempname((CONST char *) NULL, (CONST char *) NULL, 0, (_IO_size_t *) NULL, (_IO_FILE **) NULL); if (t == NULL) return NULL; if (s != NULL) (void) strcpy(s, t); else s = t; return s; } ./libc-linux/libio/stdio/Makefile100644 1676 334 14706 5515545043 15032 0ustar hjlisl# # Makefile for stdio # TOPDIR=../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I. -I.. -D_LIBIO_CONFIG_H=\"config/linux.h\" DIRS:= SRC1S= clearerr.c feof.c ferror.c fgetc.c fileno.c \ fputc.c freopen.c fseek.c getc.c getchar.c pclose.c putc.c \ putchar.c rewind.c setbuf.c setfileno.c tempnam.c \ tmpfile.c tmpnam.c vfscanf.c vprintf.c vscanf.c getw.c \ putw.c stdio.c setlinebuf.c # These are compiled from the corresponding ../ioFOO.c files. IOSRCS= fclose.c fflush.c fgetpos.c fgets.c fopen.c \ fprintf.c fputs.c fread.c fscanf.c fsetpos.c ftell.c \ fwrite.c gets.c perror.c printf.c puts.c scanf.c \ setbuffer.c setvbuf.c sprintf.c sscanf.c ungetc.c \ vsprintf.c vsscanf.c popen.c SRC2S= remove.c vfprintf.c fdopen.c $(IOSRCS) SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets realclean clean:: $(RM) -f $(IOSRCS) fclose.c: @echo "#undef HAVE_GNU_LD" > fclose.c @echo "#define HAVE_GNU_LD" >> fclose.c @echo "#include " >> fclose.c @echo "#undef fclose" >> fclose.c @echo "symbol_alias (_IO_fclose, fclose);" >> fclose.c fflush.c: @echo "#undef HAVE_GNU_LD" > fflush.c @echo "#define HAVE_GNU_LD" >> fflush.c @echo "#include " >> fflush.c @echo "#undef fflush" >> fflush.c @echo "symbol_alias (_IO_fflush, fflush);" >> fflush.c fgetpos.c: @echo "#undef HAVE_GNU_LD" > fgetpos.c @echo "#define HAVE_GNU_LD" >> fgetpos.c @echo "#include " >> fgetpos.c @echo "#undef fgetpos" >> fgetpos.c @echo "symbol_alias (_IO_fgetpos, fgetpos);" >> fgetpos.c fgets.c: @echo "#undef HAVE_GNU_LD" > fgets.c @echo "#define HAVE_GNU_LD" >> fgets.c @echo "#include " >> fgets.c @echo "#undef fgets" >> fgets.c @echo "symbol_alias (_IO_fgets, fgets);" >> fgets.c fopen.c: @echo "#undef HAVE_GNU_LD" > fopen.c @echo "#define HAVE_GNU_LD" >> fopen.c @echo "#include " >> fopen.c @echo "#undef fopen" >> fopen.c @echo "symbol_alias (_IO_fopen, fopen);" >> fopen.c fprintf.c: @echo "#undef HAVE_GNU_LD" > fprintf.c @echo "#define HAVE_GNU_LD" >> fprintf.c @echo "#include " >> fprintf.c @echo "#undef fprintf" >> fprintf.c @echo "symbol_alias (_IO_fprintf, fprintf);" >> fprintf.c fputs.c: @echo "#undef HAVE_GNU_LD" > fputs.c @echo "#define HAVE_GNU_LD" >> fputs.c @echo "#include " >> fputs.c @echo "#undef fputs" >> fputs.c @echo "symbol_alias (_IO_fputs, fputs);" >> fputs.c fread.c: @echo "#undef HAVE_GNU_LD" > fread.c @echo "#define HAVE_GNU_LD" >> fread.c @echo "#include " >> fread.c @echo "#undef fread" >> fread.c @echo "symbol_alias (_IO_fread, fread);" >> fread.c fscanf.c: @echo "#undef HAVE_GNU_LD" > fscanf.c @echo "#define HAVE_GNU_LD" >> fscanf.c @echo "#include " >> fscanf.c @echo "#undef fscanf" >> fscanf.c @echo "symbol_alias (_IO_fscanf, fscanf);" >> fscanf.c fsetpos.c: @echo "#undef HAVE_GNU_LD" > fsetpos.c @echo "#define HAVE_GNU_LD" >> fsetpos.c @echo "#include " >> fsetpos.c @echo "#undef fsetpos" >> fsetpos.c @echo "symbol_alias (_IO_fsetpos, fsetpos);" >> fsetpos.c ftell.c: @echo "#undef HAVE_GNU_LD" > ftell.c @echo "#define HAVE_GNU_LD" >> ftell.c @echo "#include " >> ftell.c @echo "#undef ftell" >> ftell.c @echo "symbol_alias (_IO_ftell, ftell);" >> ftell.c fwrite.c: @echo "#undef HAVE_GNU_LD" > fwrite.c @echo "#define HAVE_GNU_LD" >> fwrite.c @echo "#include " >> fwrite.c @echo "#undef fwrite" >> fwrite.c @echo "symbol_alias (_IO_fwrite, fwrite);" >> fwrite.c gets.c: @echo "#undef HAVE_GNU_LD" > gets.c @echo "#define HAVE_GNU_LD" >> gets.c @echo "#include " >> gets.c @echo "#undef gets" >> gets.c @echo "symbol_alias (_IO_gets, gets);" >> gets.c perror.c: @echo "#undef HAVE_GNU_LD" > perror.c @echo "#define HAVE_GNU_LD" >> perror.c @echo "#include " >> perror.c @echo "#undef perror" >> perror.c @echo "symbol_alias (_IO_perror, perror);" >> perror.c printf.c: @echo "#undef HAVE_GNU_LD" > printf.c @echo "#define HAVE_GNU_LD" >> printf.c @echo "#include " >> printf.c @echo "#undef printf" >> printf.c @echo "symbol_alias (_IO_printf, printf);" >> printf.c puts.c: @echo "#undef HAVE_GNU_LD" > puts.c @echo "#define HAVE_GNU_LD" >> puts.c @echo "#include " >> puts.c @echo "#undef puts" >> puts.c @echo "symbol_alias (_IO_puts, puts);" >> puts.c scanf.c: @echo "#undef HAVE_GNU_LD" > scanf.c @echo "#define HAVE_GNU_LD" >> scanf.c @echo "#include " >> scanf.c @echo "#undef scanf" >> scanf.c @echo "symbol_alias (_IO_scanf, scanf);" >> scanf.c setbuffer.c: @echo "#undef HAVE_GNU_LD" > setbuffer.c @echo "#define HAVE_GNU_LD" >> setbuffer.c @echo "#include " >> setbuffer.c @echo "#undef setbuffer" >> setbuffer.c @echo "symbol_alias (_IO_setbuffer, setbuffer);" >> setbuffer.c setvbuf.c: @echo "#undef HAVE_GNU_LD" > setvbuf.c @echo "#define HAVE_GNU_LD" >> setvbuf.c @echo "#include " >> setvbuf.c @echo "#undef setvbuf" >> setvbuf.c @echo "symbol_alias (_IO_setvbuf, setvbuf);" >> setvbuf.c sprintf.c: @echo "#undef HAVE_GNU_LD" > sprintf.c @echo "#define HAVE_GNU_LD" >> sprintf.c @echo "#include " >> sprintf.c @echo "#undef sprintf" >> sprintf.c @echo "symbol_alias (_IO_sprintf, sprintf);" >> sprintf.c sscanf.c: @echo "#undef HAVE_GNU_LD" > sscanf.c @echo "#define HAVE_GNU_LD" >> sscanf.c @echo "#include " >> sscanf.c @echo "#undef sscanf" >> sscanf.c @echo "symbol_alias (_IO_sscanf, sscanf);" >> sscanf.c ungetc.c: @echo "#undef HAVE_GNU_LD" > ungetc.c @echo "#define HAVE_GNU_LD" >> ungetc.c @echo "#include " >> ungetc.c @echo "#undef ungetc" >> ungetc.c @echo "symbol_alias (_IO_ungetc, ungetc);" >> ungetc.c vsprintf.c: @echo "#undef HAVE_GNU_LD" > vsprintf.c @echo "#define HAVE_GNU_LD" >> vsprintf.c @echo "#include " >> vsprintf.c @echo "#undef vsprintf" >> vsprintf.c @echo "symbol_alias (_IO_vsprintf, vsprintf);" >> vsprintf.c vsscanf.c: @echo "#undef HAVE_GNU_LD" > vsscanf.c @echo "#define HAVE_GNU_LD" >> vsscanf.c @echo "#include " >> vsscanf.c @echo "#undef vsscanf" >> vsscanf.c @echo "symbol_alias (_IO_vsscanf, vsscanf);" >> vsscanf.c popen.c: @echo "#undef HAVE_GNU_LD" > popen.c @echo "#define HAVE_GNU_LD" >> popen.c @echo "#include " >> popen.c @echo "#undef popen" >> popen.c @echo "symbol_alias (_IO_popen, popen);" >> popen.c ./libc-linux/libio/stdio/tempnam.c100644 1676 334 3353 5473146377 15165 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 #include #include "libioP.h" #include "stdio.h" /* Generate a unique temporary filename using up to five characters of PFX if it is not NULL. The directory to put this file in is searched for as follows: First the environment variable "TMPDIR" is checked. If it contains the name of a writable directory, that directory is used. If not and if DIR is not NULL, that value is checked. If that fails, P_tmpdir is tried and finally "/tmp". The storage for the filename is allocated by `malloc'. */ char * DEFUN(tempnam, (dir, pfx), CONST char *dir AND CONST char *pfx) { _IO_size_t len; register char *s; register char *t = _IO_gen_tempname(dir, pfx, 1, &len, (_IO_FILE **) NULL); if (t == NULL) return NULL; s = (char *) malloc(len); if (s == NULL) return NULL; (void) memcpy(s, t, len); return s; } ./libc-linux/libio/stdio/Makefile.libg++100644 1676 334 23773 5470363125 16077 0ustar hjlisl# This file was generated automatically by configure. Do not edit. VPATH = . links = host_alias = i486-linux host_cpu = i486 host_vendor = unknown host_os = linux host_canonical = i486-unknown-linux target_alias = i486-linux target_cpu = i486 target_vendor = unknown target_os = linux target_canonical = i486-unknown-linux package_makefile_frag = ../Make.pack srcdir = . #### package, host, target, and site dependent Makefile fragments come in here. # Start of package fragment generated by ./config.shared. # TOPDIR=$${rootme}../../ invsubdir= subdir= srcdir = . SUBDIRS = prefix = /usr exec_prefix = $(prefix) bindir = $(exec_prefix)/bin libdir = $(exec_prefix)/lib datadir = $(prefix)/lib mandir = $(prefix)/man man1dir = $(mandir)/man1 man2dir = $(mandir)/man2 man3dir = $(mandir)/man3 man4dir = $(mandir)/man4 man5dir = $(mandir)/man5 man6dir = $(mandir)/man6 man7dir = $(mandir)/man7 man8dir = $(mandir)/man8 man9dir = $(mandir)/man9 infodir = $(prefix)/info includedir = $(prefix)/include gxx_includedir = $(libdir)/g++-include docdir = $(datadir)/doc SHELL = /bin/sh INSTALL = ${rootme}$(srcdir)/../../install.sh -c INSTALL_PROGRAM = $(INSTALL) INSTALL_DATA = $(INSTALL) AR = `if [ -f $${rootme}../../binutils/ar ] ; \ then echo $${rootme}../../binutils/ar ; \ else echo ar ; fi` AR_FLAGS = rc RANLIB = `if [ -f $${rootme}../../binutils/ranlib ] ; \ then echo $${rootme}../../binutils/ranlib ; \ else echo ranlib ; fi` NM = `if [ -f $${rootme}../../binutils/nm ] ; \ then echo $${rootme}../../binutils/nm ; \ else echo nm ; fi` MAKEINFO = `if [ -f $${rootme}../../texinfo/C/makeinfo ] ; \ then echo $${rootme}../../texinfo/C/makeinfo ; \ else echo makeinfo ; fi` TEXIDIR=${srcdir}/../..//texinfo TEXI2DVI = TEXINPUTS=${TEXIDIR}:$$TEXINPUTS texi2dvi CC = `if [ -f $${rootme}../../gcc/xgcc ] ; \ then echo $${rootme}../../gcc/xgcc -B$${rootme}../../gcc/ ; \ else echo cc ; fi` CXX = `if [ -f $${rootme}../../gcc/xgcc ] ; \ then echo $${rootme}../../gcc/xgcc -B$${rootme}../../gcc/ ; \ else echo gcc ; fi` XTRAFLAGS = `if [ -f $${rootme}../../gcc/xgcc ] ;\ then echo -I$${rootme}../../gcc/include;\ else echo ; fi` WRAP_C_INCLUDES = CFLAGS = -g CXXFLAGS = -g -O .PHONY: all all: nothing .SUFFIXES: .o .C .cc .c.o: $(CC) -c $(LIBIO_CONFIG_FLAGS) $(CFLAGS) $(CINCLUDES) $< .C.o: $(CXX) -c $(LIBIO_CONFIG_FLAGS) $(CXXFLAGS) $(CXXINCLUDES) $< .cc.o: $(CXX) -c $(LIBIO_CONFIG_FLAGS) $(CXXFLAGS) $(CXXINCLUDES) $< .PHONY: install install: .PHONY: check check: nothing .PHONY: info dvi install-info clean-info info: dvi: install-info: .PHONY: do-clean-info clean-info do-clean-dvi clean-dvi do-clean-info: do-clean-dvi: clean-info: do-clean-info clean-dvi: do-clean-dvi .PHONY: boltcc boltcc: rootme=`pwd`/ ; export rootme ; $(MAKE) $(FLAGS_TO_PASS) # clean rules .PHONY: mostlyclean clean distclean realclean mostlyclean: clean-dvi rm -rf *.o core stdio.list clean: clean-dvi rm -rf *.o core stdio.list distclean: clean rm -rf config.status Makefile *~ Make.pack realclean: clean clean-info rm -rf config.status Makefile *~ Make.pack depend *.info* .PHONY: force force: # with the gnu make, this is done automatically. Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) $(SHELL) ./config.status .NOEXPORT: MAKEOVERRIDES= # End of package fragment generated by ./config.shared. ## # These are compiled from the corresponding ../ioFOO.c files. STDIO_RENAMED_OBJECTS = fclose.o fflush.o fgetpos.o fgets.o fopen.o fprintf.o fputs.o fread.o fscanf.o fsetpos.o ftell.o fwrite.o gets.o perror.o printf.o puts.o scanf.o setbuffer.o setvbuf.o sprintf.o sscanf.o ungetc.o vsprintf.o vsscanf.o # These are the files that a libc would want. STDIO_OBJECTS = $(STDIO_RENAMED_OBJECTS) \ clearerr.o fdopen.o feof.o ferror.o fgetc.o fileno.o fputc.o freopen.o \ fseek.o popen.o rewind.o setbuf.c vfprintf.o vfscanf.o vprintf.o vscanf.o \ setfileno.o remove.o tmpfile.o tmpnam.o \ getc.o getchar.o putc.o putchar.o CC_FOR_STDIO=$(CC) CINCLUDES = -I. -I$(srcdir) -I.. -I$(srcdir)/.. nothing: stdio.list: $(STDIO_OBJECTS) @echo "$(STDIO_OBJECTS)" >stdio.list fclose.o: echo "#include " > fclose.c echo "#define HAVE_GNU_LD" >> fclose.c echo "#undef fclose" >> fclose.c echo "symbol_alias (_IO_fclose, fclose);" >> fclose.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c fclose.c /bin/rm -f fclose.c fflush.o: echo "#include " > fflush.c echo "#define HAVE_GNU_LD" >> fflush.c echo "#undef fflush" >> fflush.c echo "symbol_alias (_IO_fflush, fflush);" >> fflush.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c fflush.c /bin/rm -f fflush.c fgetpos.o: echo "#include " > fgetpos.c echo "#define HAVE_GNU_LD" >> fgetpos.c echo "#undef fgetpos" >> fgetpos.c echo "symbol_alias (_IO_fgetpos, fgetpos);" >> fgetpos.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c fgetpos.c /bin/rm -f fgetpos.c fgets.o: echo "#include " > fgets.c echo "#define HAVE_GNU_LD" >> fgets.c echo "#undef fgets" >> fgets.c echo "symbol_alias (_IO_fgets, fgets);" >> fgets.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c fgets.c /bin/rm -f fgets.c fopen.o: echo "#include " > fopen.c echo "#define HAVE_GNU_LD" >> fopen.c echo "#undef fopen" >> fopen.c echo "symbol_alias (_IO_fopen, fopen);" >> fopen.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c fopen.c /bin/rm -f fopen.c fprintf.o: echo "#include " > fprintf.c echo "#define HAVE_GNU_LD" >> fprintf.c echo "#undef fprintf" >> fprintf.c echo "symbol_alias (_IO_fprintf, fprintf);" >> fprintf.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c fprintf.c /bin/rm -f fprintf.c fputs.o: echo "#include " > fputs.c echo "#define HAVE_GNU_LD" >> fputs.c echo "#undef fputs" >> fputs.c echo "symbol_alias (_IO_fputs, fputs);" >> fputs.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c fputs.c /bin/rm -f fputs.c fread.o: echo "#include " > fread.c echo "#define HAVE_GNU_LD" >> fread.c echo "#undef fread" >> fread.c echo "symbol_alias (_IO_fread, fread);" >> fread.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c fread.c /bin/rm -f fread.c fscanf.o: echo "#include " > fscanf.c echo "#define HAVE_GNU_LD" >> fscanf.c echo "#undef fscanf" >> fscanf.c echo "symbol_alias (_IO_fscanf, fscanf);" >> fscanf.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c fscanf.c /bin/rm -f fscanf.c fsetpos.o: echo "#include " > fsetpos.c echo "#define HAVE_GNU_LD" >> fsetpos.c echo "#undef fsetpos" >> fsetpos.c echo "symbol_alias (_IO_fsetpos, fsetpos);" >> fsetpos.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c fsetpos.c /bin/rm -f fsetpos.c ftell.o: echo "#include " > ftell.c echo "#define HAVE_GNU_LD" >> ftell.c echo "#undef ftell" >> ftell.c echo "symbol_alias (_IO_ftell, ftell);" >> ftell.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c ftell.c /bin/rm -f ftell.c fwrite.o: echo "#include " > fwrite.c echo "#define HAVE_GNU_LD" >> fwrite.c echo "#undef fwrite" >> fwrite.c echo "symbol_alias (_IO_fwrite, fwrite);" >> fwrite.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c fwrite.c /bin/rm -f fwrite.c gets.o: echo "#include " > gets.c echo "#define HAVE_GNU_LD" >> gets.c echo "#undef gets" >> gets.c echo "symbol_alias (_IO_gets, gets);" >> gets.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c gets.c /bin/rm -f gets.c perror.o: echo "#include " > perror.c echo "#define HAVE_GNU_LD" >> perror.c echo "#undef perror" >> perror.c echo "symbol_alias (_IO_perror, perror);" >> perror.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c perror.c /bin/rm -f perror.c printf.o: echo "#include " > printf.c echo "#define HAVE_GNU_LD" >> printf.c echo "#undef printf" >> printf.c echo "symbol_alias (_IO_printf, printf);" >> printf.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c printf.c /bin/rm -f printf.c puts.o: echo "#include " > puts.c echo "#define HAVE_GNU_LD" >> puts.c echo "#undef puts" >> puts.c echo "symbol_alias (_IO_puts, puts);" >> puts.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c puts.c /bin/rm -f puts.c scanf.o: echo "#include " > scanf.c echo "#define HAVE_GNU_LD" >> scanf.c echo "#undef scanf" >> scanf.c echo "symbol_alias (_IO_scanf, scanf);" >> scanf.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c scanf.c /bin/rm -f scanf.c setbuffer.o: echo "#include " > setbuffer.c echo "#define HAVE_GNU_LD" >> setbuffer.c echo "#undef setbuffer" >> setbuffer.c echo "symbol_alias (_IO_setbuffer, setbuffer);" >> setbuffer.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c setbuffer.c /bin/rm -f setbuffer.c setvbuf.o: echo "#include " > setvbuf.c echo "#define HAVE_GNU_LD" >> setvbuf.c echo "#undef setvbuf" >> setvbuf.c echo "symbol_alias (_IO_setvbuf, setvbuf);" >> setvbuf.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c setvbuf.c /bin/rm -f setvbuf.c sprintf.o: echo "#include " > sprintf.c echo "#define HAVE_GNU_LD" >> sprintf.c echo "#undef sprintf" >> sprintf.c echo "symbol_alias (_IO_sprintf, sprintf);" >> sprintf.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c sprintf.c /bin/rm -f sprintf.c sscanf.o: echo "#include " > sscanf.c echo "#define HAVE_GNU_LD" >> sscanf.c echo "#undef sscanf" >> sscanf.c echo "symbol_alias (_IO_sscanf, sscanf);" >> sscanf.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c sscanf.c /bin/rm -f sscanf.c ungetc.o: echo "#include " > ungetc.c echo "#define HAVE_GNU_LD" >> ungetc.c echo "#undef ungetc" >> ungetc.c echo "symbol_alias (_IO_ungetc, ungetc);" >> ungetc.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c ungetc.c /bin/rm -f ungetc.c vsprintf.o: echo "#include " > vsprintf.c echo "#define HAVE_GNU_LD" >> vsprintf.c echo "#undef vsprintf" >> vsprintf.c echo "symbol_alias (_IO_vsprintf, vsprintf);" >> vsprintf.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c vsprintf.c /bin/rm -f vsprintf.c vsscanf.o: echo "#include " > vsscanf.c echo "#define HAVE_GNU_LD" >> vsscanf.c echo "#undef vsscanf" >> vsscanf.c echo "symbol_alias (_IO_vsscanf, vsscanf);" >> vsscanf.c $(CC_FOR_STDIO) $(CFLAGS) $(CINCLUDES) -c vsscanf.c /bin/rm -f vsscanf.c ./libc-linux/libio/stdio/getw.c100644 1676 334 365 5511036507 14434 0ustar hjlisl#include "libioP.h" #include "stdio.h" int getw(fp) FILE *fp; { int w; _IO_size_t bytes_read; CHECK_FILE(fp, EOF); COERCE_FILE(fp); bytes_read = _IO_sgetn (fp, (char*)&w, sizeof(w)); return sizeof(w) == bytes_read ? w : EOF; } ./libc-linux/libio/stdio/putw.c100644 1676 334 405 5511036521 14454 0ustar hjlisl#include "libioP.h" #include "stdio.h" #undef putw int putw(w, fp) int w; FILE *fp; { _IO_size_t written; CHECK_FILE(fp, EOF); COERCE_FILE(fp); written = _IO_sputn(fp, (const char *)&w, sizeof(w)); return written == sizeof(w) ? 0 : EOF; } ./libc-linux/libio/stdio/stdio.c100644 1676 334 412 5472441372 14607 0ustar hjlisl#include "libioP.h" #include "stdio.h" /* Define non-macro versions of stdin/stdout/stderr, * for use by debuggers. */ #undef stdin #undef stdout #undef stderr FILE* stdin = &_IO_stdin_._file; FILE* stdout = &_IO_stdout_._file; FILE* stderr = &_IO_stderr_._file; ./libc-linux/libio/stdio/pclose.c100644 1676 334 721 5477557162 14767 0ustar hjlisl#include "libioP.h" #include "stdio.h" #include #ifndef __linux__ FILE * popen(command, mode) const char *command; const char *mode; { return _IO_popen(command, mode); } #endif int pclose(fp) FILE *fp; { #if 0 /* Does not actually test that stream was created by popen(). Instead, it depends on the filebuf::sys_close() virtual to Do The Right Thing. */ if (fp is not a proc_file) return -1; #endif return _IO_fclose(fp); } ./libc-linux/libio/stdio/setlinebuf.c100644 1676 334 213 5474027157 15627 0ustar hjlisl#include "libioP.h" #include "stdio.h" #undef setlinebuf void setlinebuf (stream) FILE *stream; { _IO_setvbuf(stream, NULL, 1, 0); } ./libc-linux/libio/stdio/fclose.c100644 1676 334 157 5550053032 14733 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef fclose symbol_alias (_IO_fclose, fclose); ./libc-linux/libio/stdio/fflush.c100644 1676 334 157 5550053033 14750 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef fflush symbol_alias (_IO_fflush, fflush); ./libc-linux/libio/stdio/fgetpos.c100644 1676 334 162 5550053033 15124 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef fgetpos symbol_alias (_IO_fgetpos, fgetpos); ./libc-linux/libio/stdio/fgets.c100644 1676 334 154 5550053034 14567 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef fgets symbol_alias (_IO_fgets, fgets); ./libc-linux/libio/stdio/fopen.c100644 1676 334 154 5550053035 14567 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef fopen symbol_alias (_IO_fopen, fopen); ./libc-linux/libio/stdio/fprintf.c100644 1676 334 162 5550053035 15127 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef fprintf symbol_alias (_IO_fprintf, fprintf); ./libc-linux/libio/stdio/fputs.c100644 1676 334 154 5550053036 14622 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef fputs symbol_alias (_IO_fputs, fputs); ./libc-linux/libio/stdio/fread.c100644 1676 334 154 5550053036 14542 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef fread symbol_alias (_IO_fread, fread); ./libc-linux/libio/stdio/fscanf.c100644 1676 334 157 5550053037 14725 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef fscanf symbol_alias (_IO_fscanf, fscanf); ./libc-linux/libio/stdio/fsetpos.c100644 1676 334 162 5550053040 15136 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef fsetpos symbol_alias (_IO_fsetpos, fsetpos); ./libc-linux/libio/stdio/ftell.c100644 1676 334 154 5550053040 14562 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef ftell symbol_alias (_IO_ftell, ftell); ./libc-linux/libio/stdio/fwrite.c100644 1676 334 157 5550053041 14760 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef fwrite symbol_alias (_IO_fwrite, fwrite); ./libc-linux/libio/stdio/gets.c100644 1676 334 151 5550053042 14415 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef gets symbol_alias (_IO_gets, gets); ./libc-linux/libio/stdio/perror.c100644 1676 334 157 5550053043 14773 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef perror symbol_alias (_IO_perror, perror); ./libc-linux/libio/stdio/printf.c100644 1676 334 157 5550053043 14764 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef printf symbol_alias (_IO_printf, printf); ./libc-linux/libio/stdio/puts.c100644 1676 334 151 5550053044 14450 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef puts symbol_alias (_IO_puts, puts); ./libc-linux/libio/stdio/scanf.c100644 1676 334 154 5550053045 14553 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef scanf symbol_alias (_IO_scanf, scanf); ./libc-linux/libio/stdio/setbuffer.c100644 1676 334 170 5550053045 15444 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef setbuffer symbol_alias (_IO_setbuffer, setbuffer); ./libc-linux/libio/stdio/setvbuf.c100644 1676 334 162 5550053046 15137 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef setvbuf symbol_alias (_IO_setvbuf, setvbuf); ./libc-linux/libio/stdio/sprintf.c100644 1676 334 162 5550053046 15146 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef sprintf symbol_alias (_IO_sprintf, sprintf); ./libc-linux/libio/stdio/sscanf.c100644 1676 334 157 5550053050 14735 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef sscanf symbol_alias (_IO_sscanf, sscanf); ./libc-linux/libio/stdio/ungetc.c100644 1676 334 157 5550053051 14746 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef ungetc symbol_alias (_IO_ungetc, ungetc); ./libc-linux/libio/stdio/vsprintf.c100644 1676 334 165 5550053051 15333 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef vsprintf symbol_alias (_IO_vsprintf, vsprintf); ./libc-linux/libio/stdio/vsscanf.c100644 1676 334 162 5550053052 15121 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef vsscanf symbol_alias (_IO_vsscanf, vsscanf); ./libc-linux/libio/stdio/popen.c100644 1676 334 154 5550053052 14600 0ustar hjlisl#undef HAVE_GNU_LD #define HAVE_GNU_LD #include #undef popen symbol_alias (_IO_popen, popen); ./libc-linux/libio/iotempname.c100644 1676 334 14433 5473146476 14561 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 #ifdef __STDC__ #include #endif #include #include #include #include #include #include #include "libioP.h" #include "stdio.h" #ifndef _IO_open #define _IO_open open #endif #ifndef _IO_close #define _IO_close close #endif #ifndef _IO_stat #define _IO_stat stat #endif #ifndef _IO_getpid #define _IO_getpid getpid #endif #ifndef _IO_geteuid #define _IO_geteuid geteuid #endif /* Return nonzero if DIR is an existent directory. */ static int DEFUN(diraccess, (dir), CONST char *dir) { struct stat buf; _IO_uid_t euid; if (_IO_stat(dir, &buf) != 0 || !S_ISDIR(buf.st_mode)) return 0; /* That is going to be tough. */ euid = _IO_geteuid (); /* super user */ if (!euid) return 1; if (euid == buf.st_uid) return ((buf.st_mode & S_IWUSR) && (buf.st_mode & S_IXUSR)); if (_IO_getegid () == buf.st_gid) return ((buf.st_mode & S_IWGRP) && (buf.st_mode & S_IXGRP)); return ((buf.st_mode & S_IWOTH) && (buf.st_mode & S_IXOTH)); } /* Return nonzero if FILE exists. */ static int DEFUN(exists, (file), CONST char *file) { /* We can stat the file even if we can't read its data. */ struct stat st; int save = errno; if (_IO_stat (file, &st) == 0) return 1; else { /* We report that the file exists if stat failed for a reason other than nonexistence. In this case, it may or may not exist, and we don't know; but reporting that it does exist will never cause any trouble, while reporting that it doesn't exist when it does would violate the interface of __stdio_gen_tempname. */ int exists = errno != ENOENT; errno = save; return exists; } } /* These are the characters used in temporary filenames. */ static CONST char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; /* Generate a temporary filename and return it (in a static buffer). If STREAMPTR is not NULL, open a stream "w+b" on the file and set *STREAMPTR to it. If DIR_SEARCH is nonzero, DIR and PFX are used as described for tempnam. If not, a temporary filename in P_tmpdir with no special prefix is generated. If LENPTR is not NULL, *LENPTR is set the to length (including the terminating '\0') of the resultant filename, which is returned. This goes through a cyclic pattern of all possible filenames consisting of five decimal digits of the current pid and three of the characters in `letters'. Data for tempnam and tmpnam is kept separate, but when tempnam is using P_tmpdir and no prefix (i.e, it is identical to tmpnam), the same data is used. Each potential filename is tested for an already-existing file of the same name, and no name of an existing file will be returned. When the cycle reaches its end (12345ZZZ), NULL is returned. */ char * DEFUN(_IO_gen_tempname, (dir, pfx, dir_search, lenptr, streamptr), CONST char *dir AND CONST char *pfx AND int dir_search AND _IO_size_t *lenptr AND _IO_FILE **streamptr) { int saverrno = errno; static CONST char tmpdir[] = P_tmpdir; static struct { unsigned char digits [4]; } infos[2], *info; static char buf[FILENAME_MAX]; static _IO_pid_t oldpid = (pid_t) 0; _IO_pid_t pid = _IO_getpid(); register _IO_size_t len, plen, dlen; int i, carry; if (dir_search) { register CONST char *d = getenv("TMPDIR"); if (d != NULL && !diraccess(d)) d = NULL; if (d == NULL && dir != NULL && diraccess(dir)) d = dir; if (d == NULL && diraccess(tmpdir)) d = tmpdir; if (d == NULL && diraccess("/tmp")) d = "/tmp"; if (d == NULL) { errno = ENOENT; return NULL; } dir = d; } else dir = tmpdir; dlen = strlen (dir); /* Remove trailing slashes from the directory name. */ while (dlen > 1 && dir[dlen - 1] == '/') --dlen; if (pfx != NULL && *pfx != '\0') { plen = strlen(pfx); if (plen > 5) plen = 5; } else plen = 0; if (dir != tmpdir && !strcmp(dir, tmpdir)) dir = tmpdir; info = &infos[(plen == 0 && dir == tmpdir) ? 1 : 0]; if (pid != oldpid) { oldpid = pid; for (i = 0; i < sizeof (info->digits); i++) infos[0].digits[i] = infos[1].digits[i] = 0; } len = dlen + 1 + plen + 5; for (;;) { if (info->digits [sizeof (info->digits) - 1]) { errno = EEXIST; return NULL; } if ((sizeof (buf) - sizeof (info->digits)) < len || sprintf(buf, "%.*s/%.*s%.5d", (int) dlen, dir, (int) plen, pfx, pid % 100000) != (int) len) return NULL; /* Get the last part of string */ for (i = 0; i < sizeof (info->digits) - 1; i++) buf [len++] = letters [info->digits [i]]; buf [len] = '\0'; /* Always return a unique string. */ carry = ++info->digits [0] / (sizeof (letters) - 1); info->digits [0] %= (sizeof (letters) - 1); for (i = 1; i < sizeof (info->digits); i++) { info->digits [i] += carry; carry = info->digits [i] / (sizeof (letters) - 1); info->digits [i] %= (sizeof (letters) - 1); } if (streamptr != NULL) { int fd = _IO_open (buf, O_RDWR|O_CREAT|O_EXCL, 0666); if (fd >= 0) { *streamptr = _IO_fdopen (fd, "w+b"); if (*streamptr == NULL) { int save = errno; (void) _IO_close (fd); errno = save; return NULL; } break; } } else if (!exists (buf)) break; } errno = saverrno; if (lenptr != NULL) *lenptr = len + 1; return buf; } ./libc-linux/libio/NEWS100644 1676 334 1116 5517607255 12724 0ustar hjlisl* _IO_getline and streambuf::sgetline no longer write a '\0' at the end. *** Major changes in libio version 0.63 (released with libg++ 2.5.3): * There is a g++ bug that causes inconsistent name mangling for the assembler name of the virtual function table for the istream class. A work-around has been put into streambuf.h, which will make g++ always do the right thing. Note that this may require you to recompile programs that were incorrectly compiled by g++. * Functions that do printf-style formatting to the unbuffered streams have been optimized to write to a temporary buffer. ./libc-linux/bsd/ 40755 1676 334 0 5550051205 11564 5ustar hjlisl./libc-linux/bsd/setenv.c100644 1676 334 10714 5270345336 13366 0ustar hjlisl/* * Copyright (c) 1987 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[] = "@(#)setenv.c 5.6 (Berkeley) 6/4/91"; #endif /* LIBC_SCCS and not lint */ #include #include #include #define environ __environ /* * _findenv -- * Returns pointer to value associated with name, if any, else NULL. * Sets offset to be the offset of the name/value combination in the * environmental array, for use by setenv(3) and unsetenv(3). * Explicitly removes '=' in argument name. * * This routine *should* be a static; don't use it. */ static char * _findenv(name, offset) register const char *name; int *offset; { register int len; register char **P; register const char *C; for (C = name, len = 0; *C && *C != '='; ++C, ++len); for (P = environ; *P; ++P) if (!strncmp(*P, name, len)) if (*(C = *P + len) == '=') { *offset = P - environ; return(++C); } return(NULL); } /* * setenv -- * Set the value of the environmental variable "name" to be * "value". If rewrite is set, replace any current value. */ int setenv(name, value, rewrite) register const char *name; register const char *value; int rewrite; { static int alloced; /* if allocated space before */ register char *C; int l_value, offset; if (*value == '=') /* no `=' in value */ ++value; l_value = strlen(value); if ((C = _findenv(name, &offset))) { /* find if already exists */ if (!rewrite) return (0); if (strlen(C) >= l_value) { /* old larger; copy over */ while (*C++ = *value++); return (0); } } else { /* create new slot */ register int cnt; register char **P; for (P = environ, cnt = 0; *P; ++P, ++cnt); if (alloced) { /* just increase size */ environ = (char **)realloc((char *)environ, (size_t)(sizeof(char *) * (cnt + 2))); if (!environ) return (-1); } else { /* get new space */ alloced = 1; /* copy old entries into it */ P = (char **)malloc((size_t)(sizeof(char *) * (cnt + 2))); if (!P) return (-1); bcopy(environ, P, cnt * sizeof(char *)); environ = P; } environ[cnt + 1] = NULL; offset = cnt; } for (C = (char *)name; *C && *C != '='; ++C); /* no `=' in name */ if (!(environ[offset] = /* name + `=' + value */ malloc((size_t)((int)(C - name) + l_value + 2)))) return (-1); for (C = environ[offset]; (*C = *name++) && *C != '='; ++C) ; for (*C++ = '='; *C++ = *value++; ) ; return (0); } /* * unsetenv(name) -- * Delete environmental variable "name". */ void unsetenv(name) const char *name; { extern char **environ; register char **P; int offset; while (_findenv(name, &offset)) /* if set multiple times */ for (P = &environ[offset];; ++P) if (!(*P = *(P + 1))) break; } ./libc-linux/bsd/Makefile100644 1676 334 450 5516053720 13306 0ustar hjlisl# # This is Makefile of bsd lib for Linux. # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS= -I. -I$(TOPDIR) DIRS:= SRCS = setenv.c ftime.c psignal.c mkstemp.c sigint.c realpath.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./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/bsd/ftime.c100644 1676 334 1107 5514161774 13145 0ustar hjlisl/* Bezerkeley compatible ftime(3C). This call is deprecated, use gettimeofday(2) in new code. We use the Bezerkeley gettimeofday(2) call in the implementation, as there is no way to get millisecond resolution in POSIX (lose, lose). */ #include #include #include int ftime(struct timeb *tb) { struct timeval tv; struct timezone tz; if (__gettimeofday(&tv, &tz) < 0 ) return -1; tb->time = tv.tv_sec; tb->millitm = tv.tv_usec/1000; tb->timezone = tz.tz_minuteswest; tb->dstflag = tz.tz_dsttime; return 0; } ./libc-linux/bsd/mkstemp.c100644 1676 334 3610 5342764454 13525 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 #include /* Return a file descriptor with a unique temporary file name from TEMPLATE. The last six characters of TEMPLATE must be "XXXXXX"; they are replaced with a string that makes the filename unique. Return -1 if no suitable file could be created. */ int DEFUN(mkstemp, (template), char *template) { static CONST char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; CONST char *ptr = letters; pid_t pid = __getpid(); int fd; size_t len; len = strlen(template); if (len < 6 || strcmp(&template[len - 6], "XXXXXX")) { errno = EINVAL; return -1; } if (sprintf (&template[len - 5], "%.5u", (unsigned int) pid % 100000) != 5) return -1; while (*ptr != '\0') { template[len - 6] = *ptr++; /* Make sure `template' doesn't exist. */ fd = __open (template, O_RDWR | O_CREAT | O_EXCL, 0666); if (fd >= 0 || errno != EEXIST) return fd; } return -1; } ./libc-linux/bsd/sigint.c100644 1676 334 1753 5514161774 13345 0ustar hjlisl#include #include /* Set `sig' bit if we allow interrupt on it. */ sigset_t _sigintr = 0; int siginterrupt (int sig, int flag) { struct sigaction sa; if (sig < 1 || sig >= NSIG) { errno = EINVAL; return -1; } if (__sigaction (sig, (struct sigaction *)0, &sa)) return -1; if (flag) { __sigaddset (&_sigintr, sig); #ifdef SA_RESTART if (!(sa.sa_flags & SA_RESTART) && (sa.sa_flags & SA_INTERRUPT)) return 0; sa.sa_flags |= SA_INTERRUPT; sa.sa_flags &= ~ SA_RESTART; #else if (sa.sa_flags & SA_INTERRUPT) return 0; sa.sa_flags |= SA_INTERRUPT; #endif } else { __sigdelset (&_sigintr, sig); #ifdef SA_RESTART if ((sa.sa_flags & SA_RESTART) && !(sa.sa_flags & SA_INTERRUPT)) return 0; sa.sa_flags &= ~ SA_INTERRUPT; sa.sa_flags |= SA_RESTART; #else if (!(sa.sa_flags & SA_INTERRUPT)) return 0; sa.sa_flags &= ~ SA_INTERRUPT; #endif } return __sigaction (sig, &sa, (struct sigaction *)0); } ./libc-linux/bsd/realpath.c100644 1676 334 7556 5471466620 13657 0ustar hjlisl/* * realpath.c -- canonicalize pathname by removing symlinks * Copyright (C) 1993 Rick Sladkey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 Public License for more details. */ #ifdef HAVE_CONFIG_H #include #endif #include #if defined(HAVE_UNISTD_H) || defined(STDC_HEADERS) #include #endif #include #ifdef HAVE_STRING_H #include #else #include #endif #ifdef _POSIX_VERSION #include /* for PATH_MAX */ #else #include /* for MAXPATHLEN */ #endif #include #ifndef STDC_HEADERS extern int errno; #endif #include /* for S_IFLNK */ #ifndef PATH_MAX #ifdef _POSIX_VERSION #define PATH_MAX _POSIX_PATH_MAX #else #ifdef MAXPATHLEN #define PATH_MAX MAXPATHLEN #else #define PATH_MAX 1024 #endif #endif #endif #define MAX_READLINKS 32 #ifdef __STDC__ char *realpath(const char *path, char resolved_path []) #else char *realpath(path, resolved_path) const char *path; char resolved_path []; #endif { char copy_path[PATH_MAX]; char link_path[PATH_MAX]; char *new_path = resolved_path; char *max_path; int readlinks = 0; int n; /* Make a copy of the source path since we may need to modify it. */ strcpy(copy_path, path); path = copy_path; max_path = copy_path + PATH_MAX - 2; /* If it's a relative pathname use getwd for starters. */ if (*path != '/') { #ifdef HAVE_GETCWD getcwd(new_path, PATH_MAX - 1); #else getwd(new_path); #endif new_path += strlen(new_path); if (new_path[-1] != '/') *new_path++ = '/'; } else { *new_path++ = '/'; path++; } /* Expand each slash-separated pathname component. */ while (*path != '\0') { /* Ignore stray "/". */ if (*path == '/') { path++; continue; } if (*path == '.') { /* Ignore ".". */ if (path[1] == '\0' || path[1] == '/') { path++; continue; } if (path[1] == '.') { if (path[2] == '\0' || path[2] == '/') { path += 2; /* Ignore ".." at root. */ if (new_path == resolved_path + 1) continue; /* Handle ".." by backing up. */ while ((--new_path)[-1] != '/') ; continue; } } } /* Safely copy the next pathname component. */ while (*path != '\0' && *path != '/') { if (path > max_path) { errno = ENAMETOOLONG; return NULL; } *new_path++ = *path++; } #ifdef S_IFLNK /* Protect against infinite loops. */ if (readlinks++ > MAX_READLINKS) { errno = ELOOP; return NULL; } /* See if latest pathname component is a symlink. */ *new_path = '\0'; n = readlink(resolved_path, link_path, PATH_MAX - 1); if (n < 0) { /* EINVAL means the file exists but isn't a symlink. */ if (errno != EINVAL) return NULL; } else { /* Note: readlink doesn't add the null byte. */ link_path[n] = '\0'; if (*link_path == '/') /* Start over for an absolute symlink. */ new_path = resolved_path; else /* Otherwise back up over this component. */ while (*(--new_path) != '/') ; /* Safe sex check. */ if (strlen(path) + n >= PATH_MAX) { errno = ENAMETOOLONG; return NULL; } /* Insert symlink contents into path. */ strcat(link_path, path); strcpy(copy_path, link_path); path = copy_path; } #endif /* S_IFLNK */ *new_path++ = '/'; } /* Delete trailing slash but don't whomp a lone slash. */ if (new_path != resolved_path + 1 && new_path[-1] == '/') new_path--; /* Make sure it's null terminated. */ *new_path = '\0'; return resolved_path; } ./libc-linux/ctype/ 40755 1676 334 0 5550051243 12142 5ustar hjlisl./libc-linux/ctype/ctype-extn.c100644 1676 334 2340 5153261331 14502 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 #define __NO_CTYPE #include /* Real function versions of the non-ANSI ctype functions. */ int DEFUN(isblank, (c), int c) { return __isctype ((c), _ISblank); } int DEFUN(_tolower, (c), int c) { return __tolower(c); } int DEFUN(_toupper, (c), int c) { return __toupper(c); } int DEFUN(toascii, (c), int c) { return __toascii(c); } int DEFUN(isascii, (c), int c) { return __isascii(c); } ./libc-linux/ctype/ctype.c100644 1676 334 3002 5266726644 13544 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 #define __NO_CTYPE #include /* Provide real-function versions of all the ctype macros. */ #define func(name, type) \ int DEFUN(name, (c), int c) { return __isctype(c, type); } func(isalnum, _ISalnum) func(isalpha, _ISalpha) func(iscntrl, _IScntrl) func(isdigit, _ISdigit) func(islower, _ISlower) func(isgraph, _ISgraph) func(isprint, _ISprint) func(ispunct, _ISpunct) func(isspace, _ISspace) func(isupper, _ISupper) func(isxdigit, _ISxdigit) int DEFUN(tolower, (c), int c) { if ((unsigned char) c != c) return c; else return __tolower (c); } int DEFUN(toupper, (c), int c) { if ((unsigned char) c != c) return c; else return __toupper (c); } ./libc-linux/ctype/test_ctype.c100644 1676 334 4115 5153261332 14570 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 #ifdef __GNUC__ __inline #endif static void DEFUN(print_char, (c), unsigned char c) { printf("%d/", (int) c); if (isgraph(c)) printf("'%c'", c); else printf("'\\%.3o'", c); } int DEFUN(main, (argc, argv), int argc AND char **argv) { register unsigned short int c; for (c = 0; c <= UCHAR_MAX; ++c) { print_char(c); if (isascii(c)) fputs(" isascii", stdout); if (isalnum(c)) fputs(" isalnum", stdout); if (isalpha(c)) fputs(" isalpha", stdout); if (iscntrl(c)) fputs(" iscntrl", stdout); if (isdigit(c)) fputs(" isdigit", stdout); if (isgraph(c)) fputs(" isgraph", stdout); if (islower(c)) fputs(" islower", stdout); if (isprint(c)) fputs(" isprint", stdout); if (ispunct(c)) fputs(" ispunct", stdout); if (isspace(c)) fputs(" isspace", stdout); if (isupper(c)) fputs(" isupper", stdout); if (isxdigit(c)) fputs(" isxdigit", stdout); if (isblank(c)) fputs(" isblank", stdout); fputs("; lower = ", stdout); print_char(tolower(c)); fputs("; upper = ", stdout); print_char(toupper(c)); putchar('\n'); } exit(EXIT_SUCCESS); } ./libc-linux/ctype/Makefile100644 1676 334 374 5515540544 13673 0ustar hjlisl# # Makefile for ctype functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS= -I. DIRS:= SRCS = ctype-extn.c ctype.c ctype-info.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/ctype/ctype-info.c100644 1676 334 2351 5244010131 14450 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 /* Defined in locale/locale-C-ctype.c. */ extern CONST unsigned short int __ctype_b_C[]; extern CONST unsigned char __ctype_tolower_C[]; extern CONST unsigned char __ctype_toupper_C[]; CONST unsigned short int *__ctype_b = __ctype_b_C + 1; CONST unsigned char *__ctype_tolower = __ctype_tolower_C + 1; CONST unsigned char *__ctype_toupper = __ctype_toupper_C + 1; ./libc-linux/curses/ 40755 1676 334 0 5550051427 12326 5ustar hjlisl./libc-linux/curses/scanw.c100644 1676 334 5660 5200350452 13701 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)scanw.c 5.7 (Berkeley) 4/15/91"; #endif /* not lint */ /* * scanw and friends * */ #if __STDC__ #include #else #include #endif #include "curses.ext" /* * This routine actually executes the scanf from the window. * THIS SHOULD BE RENAMED vwscanw AND EXPORTED */ _sscans(win, fmt, ap) WINDOW *win; #if __STDC__ const char *fmt; #else char *fmt; #endif va_list ap; { char buf[100]; return wgetstr(win, buf) == OK ? vsscanf(buf, fmt, ap) : ERR; } /* * This routine implements a scanf on the standard screen. */ #if __STDC__ scanw(const char *fmt, ...) #else scanw(fmt, va_alist) char *fmt; va_dcl #endif { va_list ap; int ret; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = _sscans(stdscr, fmt, ap); va_end(ap); return ret; } /* * This routine implements a scanf on the given window. */ #if __STDC__ wscanw(WINDOW *win, const char *fmt, ...) #else wscanw(win, fmt, va_alist) WINDOW *win; char *fmt; va_dcl #endif { va_list ap; int ret; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = _sscans(win, fmt, ap); va_end(ap); return ret; } ./libc-linux/curses/cr_put.c100644 1676 334 23212 5244020674 14103 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)cr_put.c 5.5 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" # define HARDTABS 8 void fgoto (void); int tabcol(int, int); int plod (int); int plodput (int); /* * Terminal driving and line formatting routines. * Basic motion optimizations are done here as well * as formatting of lines (printing of control characters, * line numbering and the like). */ /* * Sync the position of the output cursor. * Most work here is rounding for terminal boundaries getting the * column position implied by wraparound or the lack thereof and * rolling up the screen to get destline on the screen. */ static int outcol, outline, destcol, destline; extern WINDOW *_win; mvcur(ly, lx, y, x) int ly, lx, y, x; { #ifdef DEBUG fprintf(outf, "MVCUR: moving cursor from (%d,%d) to (%d,%d)\n", ly, lx, y, x); #endif destcol = x; destline = y; outcol = lx; outline = ly; fgoto(); } void fgoto() { register char *cgp; register int l, c; if (destcol >= COLS) { destline += destcol / COLS; destcol %= COLS; } if (outcol >= COLS) { l = (outcol + 1) / COLS; outline += l; outcol %= COLS; if (AM == 0) { while (l > 0) { if (_pfast) if (CR) _puts(CR); else _putchar('\r'); if (NL) _puts(NL); else _putchar('\n'); l--; } outcol = 0; } if (outline > LINES - 1) { destline -= outline - (LINES - 1); outline = LINES - 1; } } if (destline >= LINES) { l = destline; destline = LINES - 1; if (outline < LINES - 1) { c = destcol; if (_pfast == 0 && !CA) destcol = 0; fgoto(); destcol = c; } while (l >= LINES) { /* * The following linefeed (or simulation thereof) * is supposed to scroll up the screen, since we * are on the bottom line. We make the assumption * that linefeed will scroll. If ns is in the * capability list this won't work. We should * probably have an sc capability but sf will * generally take the place if it works. * * Superbee glitch: in the middle of the screen we * have to use esc B (down) because linefeed screws up * in "Efficient Paging" (what a joke) mode (which is * essential in some SB's because CRLF mode puts garbage * in at end of memory), but you must use linefeed to * scroll since down arrow won't go past memory end. * I turned this off after recieving Paul Eggert's * Superbee description which wins better. */ if (NL /* && !XB */ && _pfast) _puts(NL); else _putchar('\n'); l--; if (_pfast == 0) outcol = 0; } } if (destline < outline && !(CA || UP)) destline = outline; if (CA) { cgp = tgoto(CM, destcol, destline); if (plod(strlen(cgp)) > 0) plod(0); else tputs(cgp, 0, _putchar); } else plod(0); outline = destline; outcol = destcol; } /* * Move (slowly) to destination. * Hard thing here is using home cursor on really deficient terminals. * Otherwise just use cursor motions, hacking use of tabs and overtabbing * and backspace. */ static int plodcnt, plodflg; int plodput(int c) { if (plodflg) plodcnt--; else _putchar(c); } int plod(int cnt) { register int i, j, k; register int soutcol, soutline; plodcnt = plodflg = cnt; soutcol = outcol; soutline = outline; /* * Consider homing and moving down/right from there, vs moving * directly with local motions to the right spot. */ if (HO) { /* * i is the cost to home and tab/space to the right to * get to the proper column. This assumes ND space costs * 1 char. So i+destcol is cost of motion with home. */ if (GT) i = (destcol / HARDTABS) + (destcol % HARDTABS); else i = destcol; /* * j is cost to move locally without homing */ if (destcol >= outcol) { /* if motion is to the right */ j = destcol / HARDTABS - outcol / HARDTABS; if (GT && j) j += destcol % HARDTABS; else j = destcol - outcol; } else /* leftward motion only works if we can backspace. */ if (outcol - destcol <= i && (BS || BC)) i = j = outcol - destcol; /* cheaper to backspace */ else j = i + 1; /* impossibly expensive */ /* k is the absolute value of vertical distance */ k = outline - destline; if (k < 0) k = -k; j += k; /* * Decision. We may not have a choice if no UP. */ if (i + destline < j || (!UP && destline < outline)) { /* * Cheaper to home. Do it now and pretend it's a * regular local motion. */ tputs(HO, 0, plodput); outcol = outline = 0; } else if (LL) { /* * Quickly consider homing down and moving from there. * Assume cost of LL is 2. */ k = (LINES - 1) - destline; if (i + k + 2 < j && (k<=0 || UP)) { tputs(LL, 0, plodput); outcol = 0; outline = LINES - 1; } } } else /* * No home and no up means it's impossible. */ if (!UP && destline < outline) return -1; if (GT) i = destcol % HARDTABS + destcol / HARDTABS; else i = destcol; /* if (BT && outcol > destcol && (j = (((outcol+7) & ~7) - destcol - 1) >> 3)) { j *= (k = strlen(BT)); if ((k += (destcol&7)) > 4) j += 8 - (destcol&7); else j += k; } else */ j = outcol - destcol; /* * If we will later need a \n which will turn into a \r\n by * the system or the terminal, then don't bother to try to \r. */ if ((NONL || !_pfast) && outline < destline) goto dontcr; /* * If the terminal will do a \r\n and there isn't room for it, * then we can't afford a \r. */ if (NC && outline >= destline) goto dontcr; /* * If it will be cheaper, or if we can't back up, then send * a return preliminarily. */ if (j > i + 1 || outcol > destcol && !BS && !BC) { /* * BUG: this doesn't take the (possibly long) length * of CR into account. */ if (CR) tputs(CR, 0, plodput); else plodput('\r'); if (NC) { if (NL) tputs(NL, 0, plodput); else plodput('\n'); outline++; } outcol = 0; } dontcr: while (outline < destline) { outline++; if (NL) tputs(NL, 0, plodput); else plodput('\n'); if (plodcnt < 0) goto out; if (NONL || _pfast == 0) outcol = 0; } if (BT) k = strlen(BT); while (outcol > destcol) { if (plodcnt < 0) goto out; /* if (BT && outcol - destcol > k + 4) { tputs(BT, 0, plodput); outcol--; outcol &= ~7; continue; } */ outcol--; if (BC) tputs(BC, 0, plodput); else plodput('\b'); } while (outline > destline) { outline--; tputs(UP, 0, plodput); if (plodcnt < 0) goto out; } if (GT && destcol - outcol > 1) { for (;;) { i = tabcol(outcol, HARDTABS); if (i > destcol) break; if (TA) tputs(TA, 0, plodput); else plodput('\t'); outcol = i; } if (destcol - outcol > 4 && i < COLS && (BC || BS)) { if (TA) tputs(TA, 0, plodput); else plodput('\t'); outcol = i; while (outcol > destcol) { outcol--; if (BC) tputs(BC, 0, plodput); else plodput('\b'); } } } while (outcol < destcol) { /* * move one char to the right. We don't use ND space * because it's better to just print the char we are * moving over. */ if (_win != NULL) if (plodflg) /* avoid a complex calculation */ plodcnt--; else { i = curscr->_y[outline][outcol]; if ((i&_STANDOUT) == (curscr->_flags&_STANDOUT)) _putchar(i & 0177); else goto nondes; } else nondes: if (ND) tputs(ND, 0, plodput); else plodput(' '); outcol++; if (plodcnt < 0) goto out; } out: if (plodflg) { outcol = soutcol; outline = soutline; } return(plodcnt); } /* * Return the column number that results from being in column col and * hitting a tab, where tabs are set every ts columns. Work right for * the case where col > COLS, even if ts does not divide COLS. */ tabcol(col, ts) int col, ts; { int offset, result; if (col >= COLS) { offset = COLS * (col / COLS); col -= offset; } else offset = 0; return col + ts - (col % ts) + offset; } ./libc-linux/curses/curses.3100644 1676 334 13561 5004127420 14030 0ustar hjlisl.\" Copyright (c) 1985, 1991 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. .\" .\" @(#)curses.3 6.6 (Berkeley) 4/19/91 .\" .Dd April 19, 1991 .Dt CURSES 3 .Os BSD 4 .Sh NAME .Nm curses .Nd screen functions with ``optimal'' cursor motion .Sh SYNOPSIS .Nm cc .Op Ar flags .Ar files .Fl lcurses ltermcap .Op Ar libraries .Sh DESCRIPTION These routines give the user a method of updating screens with reasonable optimization. They keep an image of the current screen, and the user sets up an image of a new one. Then the .Fn refresh tells the routines to make the current screen look like the new one. In order to initialize the routines, the routine .Fn initscr must be called before any of the other routines that deal with windows and screens are used. The routine .Fn endwin should be called before exiting. .Sh SEE ALSO .Xr ioctl 2 , .Xr getenv 3 , .Xr tty 4 , .Xr termcap 5 .Rs .%T Screen Updating and Cursor Movement Optimization: A Library Package .%A Ken Arnold .Re .Sh AUTHOR .An Ken Arnold .Sh FUNCTIONS .Bl -column "subwin(win,lines,cols,begin_y,begin_x) " .It addch(ch) add a character to .Em stdscr .It addstr(str) add a string to .Em stdscr .It box(win,vert,hor) draw a box around a window .It cbreak() set cbreak mode .It clear() clear .Em stdscr .It clearok(scr,boolf) set clear flag for .Em scr .It clrtobot() clear to bottom on .Em stdscr .It clrtoeol() clear to end of line on .Em stdscr .It delch() delete a character .It deleteln() delete a line .It delwin(win) delete .Em stdscr .It echo() set echo mode .It endwin() end window modes .It erase() erase .Em stdscr .It flusok(win,boolf) set flush-on-refresh flag for .Em win .It getch() get a char through .Em stdscr .It getcap(name) get terminal capability .Em name .It getstr(str) get a string through .Em stdscr .It gettmode() get tty modes .It getyx(win,y,x) get (y,x) co-ordinates .It inch() get char at current (y,x) co-ordinates .It initscr() initialize screens .It insch(c) insert a char .It insertln() insert a line .It leaveok(win,boolf) set leave flag for .Em stdscr .It longname(termbuf,name) get long name from .Em termbuf .It move(y,x) move to (y,x) on .Em stdscr .It mvcur(lasty,lastx,newy,newx) actually move cursor .It newwin(lines,cols,begin_y,begin_x)\ create a new window .It nl() set newline mapping .It nocbreak() unset cbreak mode .It noecho() unset echo mode .It nonl() unset newline mapping .It noraw() unset raw mode .It overlay(win1,win2) overlay win1 on win2 .It overwrite(win1,win2) overwrite win1 on top of win2 .It printw(fmt,arg1,arg2,...) printf on .Em stdscr .It raw() set raw mode .It refresh() make current screen look like .Em stdscr .It resetty() reset tty flags to stored value .It savetty() stored current tty flags .It scanw(fmt,arg1,arg2,...) scanf through .Em stdscr .It scroll(win) scroll .Em win one line .It scrollok(win,boolf) set scroll flag .It setterm(name) set term variables for name .It standend() end standout mode .It standout() start standout mode .It subwin(win,lines,cols,begin_y,begin_x)\ create a subwindow .It touchline(win,y,sx,ex) mark line .Em y .Em sx through .Em sy as changed .It touchoverlap(win1,win2) mark overlap of .Em win1 on .Em win2 as changed .It touchwin(win) \*(lqchange\*(rq all of .Em win .It unctrl(ch) printable version of .Em ch .It waddch(win,ch) add char to .Em win .It waddstr(win,str) add string to .Em win .It wclear(win) clear .Em win .It wclrtobot(win) clear to bottom of .Em win .It wclrtoeol(win) clear to end of line on .Em win .It wdelch(win,c) delete char from .Em win .It wdeleteln(win) delete line from .Em win .It werase(win) erase .Em win .It wgetch(win) get a char through .Em win .It wgetstr(win,str) get a string through .Em win .It winch(win) get char at current (y,x) in .Em win .It winsch(win,c) insert char into .Em win .It winsertln(win) insert line into .Em win .It wmove(win,y,x) set current (y,x) co-ordinates on .Em win .It wprintw(win,fmt,arg1,arg2,...)\ printf on .Em win .It wrefresh(win) make screen look like .Em win .It wscanw(win,fmt,arg1,arg2,...)\ scanf through .Em win .It wstandend(win) end standout mode on .Em win .It wstandout(win) start standout mode on .Em win .El .Sh HISTORY The .Nm package appeared in .Bx 4.0 . ./libc-linux/curses/initscr.c100644 1676 334 5557 5200350441 14244 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)initscr.c 5.6 (Berkeley) 3/3/91"; #endif /* not lint */ # include "curses.ext" # include extern char *getenv(); /* * This routine initializes the current and standard screen. * */ WINDOW * initscr() { register char *sp; void tstp(); # ifdef DEBUG fprintf(outf, "INITSCR()\n"); # endif if (My_term) setterm(Def_term); else { gettmode(); if ((sp = getenv("TERM")) == NULL) sp = Def_term; setterm(sp); # ifdef DEBUG fprintf(outf, "INITSCR: term = %s\n", sp); # endif } _puts(TI); _puts(VS); # ifdef SIGTSTP signal(SIGTSTP, tstp); # endif if (curscr != NULL) { # ifdef DEBUG fprintf(outf, "INITSCR: curscr = 0%o\n", curscr); # endif delwin(curscr); } # ifdef DEBUG fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS); # endif if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR) return ERR; clearok(curscr, TRUE); curscr->_flags &= ~_FULLLINE; if (stdscr != NULL) { # ifdef DEBUG fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr); # endif delwin(stdscr); } stdscr = newwin(LINES, COLS, 0, 0); return stdscr; } ./libc-linux/curses/Makefile100644 1676 334 1666 5527713746 14111 0ustar hjlisl# # This is Makefile of curses for Linux # override DEBUG=false override PROFILE=false #override CHECKER=false JUMP_LIB=libcurses TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules override STATIC_LIB=$(STATIC_DIR)/libcurses.a override SHARED_LIB=$(SHARED_DIR)/libcurses.a override CHECKER_LIB=$(CHECKER_DIR)/libcurses.a INC_CFLAGS= -I. CURSES_CFLAGS=-DPOSIX -D__USE_BSD_SIGNAL BASE_CFLAGS := $(BASE_CFLAGS) $(CURSES_CFLAGS) DIRS:= SRCS= addbytes.c addch.c addstr.c box.c clear.c clrtobot.c \ clrtoeol.c cr_put.c cr_tty.c delch.c deleteln.c \ delwin.c endwin.c erase.c fullname.c getch.c getstr.c \ idlok.c id_subwins.c initscr.c insch.c insertln.c \ longname.c move.c mvprintw.c mvscanw.c mvwin.c \ newwin.c overlay.c overwrite.c printw.c putchar.c \ refresh.c scanw.c scroll.c toucholap.c standout.c \ touchwin.c tstp.c curses.c unctrl.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/curses/printw.c100644 1676 334 6646 5200350450 14114 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)printw.c 5.8 (Berkeley) 4/15/91"; #endif /* not lint */ /* * printw and friends. * * These routines make nonportable assumptions about varargs if __STDC__ * is not in effect. */ #if __STDC__ #include #else #include #endif #include "curses.ext" /* * This routine implements a printf on the standard screen. */ #if __STDC__ printw(const char *fmt, ...) #else printw(fmt, va_alist) char *fmt; va_dcl #endif { va_list ap; int ret; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = _sprintw(stdscr, fmt, ap); va_end(ap); return (ret); } /* * This routine implements a printf on the given window. */ #if __STDC__ wprintw(WINDOW *win, const char *fmt, ...) #else wprintw(win, fmt, va_alist) WINDOW *win; char *fmt; va_dcl #endif { va_list ap; int ret; #ifdef __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = _sprintw(win, fmt, ap); va_end(ap); return (ret); } /* * Internal write-buffer-to-window function. */ static int _winwrite(cookie, buf, n) void *cookie; register char *buf; int n; { register WINDOW *win = (WINDOW *)cookie; register int c = n; while (--c >= 0) { if (waddch(win, *buf++) == ERR) return (-1); } return n; } /* * This routine actually executes the printf and adds it to the window. * It must not be declared static as it is used in mvprintw.c. * THIS SHOULD BE RENAMED vwprintw AND EXPORTED */ _sprintw(win, fmt, ap) WINDOW *win; #if __STDC__ const char *fmt; #else char *fmt; #endif va_list ap; { char buf[1024]; vsprintf(buf, fmt, ap); if (_winwrite(win, buf, strlen(buf))) return ERR; return OK; } ./libc-linux/curses/cr_tty.c100644 1676 334 15623 5200356531 14116 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)cr_tty.c 5.8 (Berkeley) 6/1/90"; #endif /* not lint */ void zap (); /* * Terminal initialization routines. * */ # include "curses.ext" static bool *sflags[] = { &AM, &BS, &DA, &DB, &EO, &HC, &HZ, &IN, &MI, &MS, &NC, &NS, &OS, &UL, &XB, &XN, &XT, &XS, &XX }; static char *_PC, **sstrs[] = { &AL, &BC, &BT, &CD, &CE, &CL, &CM, &CR, &CS, &DC, &DL, &DM, &DO, &ED, &EI, &K0, &K1, &K2, &K3, &K4, &K5, &K6, &K7, &K8, &K9, &HO, &IC, &IM, &IP, &KD, &KE, &KH, &KL, &KR, &KS, &KU, &LL, &MA, &ND, &NL, &_PC, &RC, &SC, &SE, &SF, &SO, &SR, &TA, &TE, &TI, &UC, &UE, &UP, &US, &VB, &VS, &VE, &AL_PARM, &DL_PARM, &UP_PARM, &DOWN_PARM, &LEFT_PARM, &RIGHT_PARM, }; extern char *tgoto(); char _tspace[2048]; /* Space for capability strings */ static char *aoftspace; /* Address of _tspace for relocation */ static int destcol, destline; /* * This routine does terminal type initialization routines, and * calculation of flags at entry. It is almost entirely stolen from * Bill Joy's ex version 2.6. */ #ifndef linux #ifdef POSIX speed_t ospeed = -1; #else short ospeed = -1; #endif #endif gettmode() { #ifdef POSIX if (tcgetattr(_tty_ch, &_tty) < 0) return; savetty(); if (tcsetattr(_tty_ch, 0, &_tty) < 0) { _tty.c_lflag = _res_lflg; _tty.c_iflag = _res_iflg; } ospeed = cfgetospeed(&_tty); _res_iflg = _tty.c_iflag; _res_lflg = _tty.c_lflag; #if defined(IUCLC) && defined(OLCUC) && defined(XCASE) UPPERCASE = ((_tty.c_iflag & IUCLC) || (_tty.c_oflag & OLCUC) || (_tty.c_lflag & XCASE)); #else UPPERCASE = 0; #endif GT = ((_tty.c_oflag & XTABS) == 0); NONL = ((_tty.c_iflag & ICRNL) == 0); _tty.c_oflag &= ~XTABS; tcsetattr(_tty_ch, 0, &_tty); #else if (ioctl(_tty_ch, TIOCGETP, &_tty) < 0) return; savetty(); if (ioctl(_tty_ch, TIOCSETP, &_tty) < 0) _tty.sg_flags = _res_flg; ospeed = _tty.sg_ospeed; _res_flg = _tty.sg_flags; UPPERCASE = (_tty.sg_flags & LCASE) != 0; GT = ((_tty.sg_flags & XTABS) == 0); NONL = ((_tty.sg_flags & CRMOD) == 0); _tty.sg_flags &= ~XTABS; ioctl(_tty_ch, TIOCSETP, &_tty); #endif # ifdef DEBUG fprintf(outf, "GETTMODE: UPPERCASE = %s\n", UPPERCASE ? "TRUE":"FALSE"); fprintf(outf, "GETTMODE: GT = %s\n", GT ? "TRUE" : "FALSE"); fprintf(outf, "GETTMODE: NONL = %s\n", NONL ? "TRUE" : "FALSE"); fprintf(outf, "GETTMODE: ospeed = %d\n", ospeed); # endif } setterm(type) register const char *type; { register int unknown; static char genbuf[1024]; # ifdef TIOCGWINSZ struct winsize win; # endif # ifdef DEBUG fprintf(outf, "SETTERM(\"%s\")\n", type); fprintf(outf, "SETTERM: LINES = %d, COLS = %d\n", LINES, COLS); # endif if (type[0] == '\0') type = "xx"; unknown = FALSE; if (tgetent(genbuf, type) != 1) { unknown++; strcpy(genbuf, "xx|dumb:"); } # ifdef DEBUG fprintf(outf, "SETTERM: tty = %s\n", type); # endif # ifdef TIOCGWINSZ if (ioctl(_tty_ch, TIOCGWINSZ, &win) >= 0) { if (LINES == 0) LINES = win.ws_row; if (COLS == 0) COLS = win.ws_col; } # endif if (LINES == 0) LINES = tgetnum("li"); if (LINES <= 5) LINES = 24; if (COLS == 0) COLS = tgetnum("co"); if (COLS <= 4) COLS = 80; # ifdef DEBUG fprintf(outf, "SETTERM: LINES = %d, COLS = %d\n", LINES, COLS); # endif aoftspace = _tspace; zap(); /* get terminal description */ /* * Handle funny termcap capabilities */ if (CS && SC && RC) AL=DL=""; if (AL_PARM && AL==NULL) AL=""; if (DL_PARM && DL==NULL) DL=""; if (IC && IM==NULL) IM=""; if (IC && EI==NULL) EI=""; if (!GT) BT=NULL; /* If we can't tab, we can't backtab either */ if (tgoto(CM, destcol, destline)[0] == 'O') CA = FALSE, CM = 0; else CA = TRUE; PC = _PC ? _PC[0] : FALSE; aoftspace = _tspace; { /* xtype should be the same size as genbuf for longname(). */ static char xtype[1024]; (void)strcpy(xtype,type); strncpy(ttytype, longname(genbuf, xtype), sizeof(ttytype) - 1); } ttytype[sizeof(ttytype) - 1] = '\0'; if (unknown) return ERR; return OK; } /* * This routine gets all the terminal flags from the termcap database */ void zap() { register char *namp; register bool **fp; register char ***sp; #ifdef DEBUG register char *cp; #endif #ifndef linux extern char *tgetstr(); #endif namp = "ambsdadbeohchzinmimsncnsosulxbxnxtxsxx"; fp = sflags; do { *(*fp++) = tgetflag(namp); #ifdef DEBUG fprintf(outf, "%2.2s = %s\n", namp, *fp[-1] ? "TRUE" : "FALSE"); #endif namp += 2; } while (*namp); namp = "albcbtcdceclcmcrcsdcdldmdoedeik0k1k2k3k4k5k6k7k8k9hoicimipkdkekhklkrkskullmandnlpcrcscsesfsosrtatetiucueupusvbvsveALDLUPDOLERI"; sp = sstrs; do { *(*sp++) = tgetstr(namp, &aoftspace); #ifdef DEBUG fprintf(outf, "%2.2s = %s", namp, *sp[-1] == NULL ? "NULL\n" : "\""); if (*sp[-1] != NULL) { for (cp = *sp[-1]; *cp; cp++) fprintf(outf, "%s", unctrl(*cp)); fprintf(outf, "\"\n"); } #endif namp += 2; } while (*namp); if (XS) SO = SE = NULL; else { if (tgetnum("sg") > 0) SO = NULL; if (tgetnum("ug") > 0) US = NULL; if (!SO && US) { SO = US; SE = UE; } } } /* * return a capability from termcap */ char * getcap(name) char *name; { char *tgetstr(); return tgetstr(name, &aoftspace); } ./libc-linux/curses/refresh.c100644 1676 334 17421 5244020730 14243 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)refresh.c 5.5 (Berkeley) 3/3/91"; #endif /* not lint */ /* * make the current screen look like "win" over the area coverd by * win. */ # include "curses.ext" # ifdef DEBUG # define STATIC # else # define STATIC static # endif STATIC short ly, lx; STATIC bool curwin; WINDOW *_win = NULL; STATIC int domvcur(), makech(); wrefresh(win) register WINDOW *win; { register short wy; register int retval; register WINDOW *orig; /* * make sure were in visual state */ if (_endwin) { _puts(VS); _puts(TI); _endwin = FALSE; } /* * initialize loop parameters */ ly = curscr->_cury; lx = curscr->_curx; wy = 0; _win = win; curwin = (win == curscr); if (win->_clear || curscr->_clear || curwin) { if ((win->_flags & _FULLWIN) || curscr->_clear) { _puts(CL); ly = 0; lx = 0; if (!curwin) { curscr->_clear = FALSE; curscr->_cury = 0; curscr->_curx = 0; werase(curscr); } touchwin(win); } win->_clear = FALSE; } if (!CA) { if (win->_curx != 0) _putchar('\n'); if (!curwin) werase(curscr); } # ifdef DEBUG fprintf(outf, "REFRESH(%0.2o): curwin = %d\n", win, curwin); fprintf(outf, "REFRESH:\n\tfirstch\tlastch\n"); # endif for (wy = 0; wy < win->_maxy; wy++) { # ifdef DEBUG fprintf(outf, "%d\t%d\t%d\n", wy, win->_firstch[wy], win->_lastch[wy]); # endif if (win->_firstch[wy] != _NOCHANGE) if (makech(win, wy) == ERR) return ERR; else { if (win->_firstch[wy] >= win->_ch_off) win->_firstch[wy] = win->_maxx + win->_ch_off; if (win->_lastch[wy] < win->_maxx + win->_ch_off) win->_lastch[wy] = win->_ch_off; if (win->_lastch[wy] < win->_firstch[wy]) win->_firstch[wy] = _NOCHANGE; } # ifdef DEBUG fprintf(outf, "\t%d\t%d\n", win->_firstch[wy], win->_lastch[wy]); # endif } if (win == curscr) domvcur(ly, lx, win->_cury, win->_curx); else { if (win->_leave) { curscr->_cury = ly; curscr->_curx = lx; ly -= win->_begy; lx -= win->_begx; if (ly >= 0 && ly < win->_maxy && lx >= 0 && lx < win->_maxx) { win->_cury = ly; win->_curx = lx; } else win->_cury = win->_curx = 0; } else { domvcur(ly, lx, win->_cury + win->_begy, win->_curx + win->_begx); curscr->_cury = win->_cury + win->_begy; curscr->_curx = win->_curx + win->_begx; } } retval = OK; ret: _win = NULL; fflush(stdout); return retval; } /* * make a change on the screen */ STATIC makech(win, wy) register WINDOW *win; short wy; { register char *nsp, *csp, *ce; register short wx, lch, y; register int nlsp, clsp; /* last space in lines */ wx = win->_firstch[wy] - win->_ch_off; if (wx >= win->_maxx) return OK; else if (wx < 0) wx = 0; lch = win->_lastch[wy] - win->_ch_off; if (lch < 0) return OK; else if (lch >= win->_maxx) lch = win->_maxx - 1;; y = wy + win->_begy; if (curwin) csp = " "; else csp = &curscr->_y[wy + win->_begy][wx + win->_begx]; nsp = &win->_y[wy][wx]; if (CE && !curwin) { for (ce = &win->_y[wy][win->_maxx - 1]; *ce == ' '; ce--) if (ce <= win->_y[wy]) break; nlsp = ce - win->_y[wy]; } if (!curwin) ce = CE; else ce = NULL; while (wx <= lch) { if (*nsp != *csp) { domvcur(ly, lx, y, wx + win->_begx); # ifdef DEBUG fprintf(outf, "MAKECH: 1: wx = %d, lx = %d\n", wx, lx); # endif ly = y; lx = wx + win->_begx; while (*nsp != *csp && wx <= lch) { if (ce != NULL && wx >= nlsp && *nsp == ' ') { /* * check for clear to end-of-line */ ce = &curscr->_y[ly][COLS - 1]; while (*ce == ' ') if (ce-- <= csp) break; clsp = ce - curscr->_y[ly] - win->_begx; # ifdef DEBUG fprintf(outf, "MAKECH: clsp = %d, nlsp = %d\n", clsp, nlsp); # endif if (clsp - nlsp >= strlen(CE) && clsp < win->_maxx) { # ifdef DEBUG fprintf(outf, "MAKECH: using CE\n"); # endif _puts(CE); lx = wx + win->_begx; while (wx++ <= clsp) *csp++ = ' '; return OK; } ce = NULL; } /* * enter/exit standout mode as appropriate */ if (SO && (*nsp&_STANDOUT) != (curscr->_flags&_STANDOUT)) { if (*nsp & _STANDOUT) { _puts(SO); curscr->_flags |= _STANDOUT; } else { _puts(SE); curscr->_flags &= ~_STANDOUT; } } wx++; if (wx >= win->_maxx && wy == win->_maxy - 1) if (win->_scroll) { if ((curscr->_flags&_STANDOUT) && (win->_flags & _ENDLINE)) if (!MS) { _puts(SE); curscr->_flags &= ~_STANDOUT; } if (!curwin) _putchar((*csp = *nsp) & 0177); else _putchar(*nsp & 0177); if (win->_flags&_FULLWIN && !curwin) scroll(curscr); ly = win->_begy+win->_cury; lx = win->_begx+win->_curx; return OK; } else if (win->_flags&_SCROLLWIN) { lx = --wx; return ERR; } if (!curwin) _putchar((*csp++ = *nsp) & 0177); else _putchar(*nsp & 0177); # ifdef FULLDEBUG fprintf(outf, "MAKECH:putchar(%c)\n", *nsp & 0177); # endif if (UC && (*nsp & _STANDOUT)) { _putchar('\b'); _puts(UC); } nsp++; } # ifdef DEBUG fprintf(outf, "MAKECH: 2: wx = %d, lx = %d\n", wx, lx); # endif if (lx == wx + win->_begx) /* if no change */ break; lx = wx + win->_begx; if (lx >= COLS && AM) { lx = 0; ly++; /* * xn glitch: chomps a newline after auto-wrap. * we just feed it now and forget about it. */ if (XN) { _putchar('\n'); _putchar('\r'); } } } else if (wx <= lch) while (*nsp == *csp && wx <= lch) { nsp++; if (!curwin) csp++; ++wx; } else break; # ifdef DEBUG fprintf(outf, "MAKECH: 3: wx = %d, lx = %d\n", wx, lx); # endif } return OK; } /* * perform a mvcur, leaving standout mode if necessary */ STATIC domvcur(oy, ox, ny, nx) int oy, ox, ny, nx; { if (curscr->_flags & _STANDOUT && !MS) { _puts(SE); curscr->_flags &= ~_STANDOUT; } mvcur(oy, ox, ny, nx); } ./libc-linux/curses/addbytes.c100644 1676 334 10221 5522720624 14403 0ustar hjlisl/* * Copyright (c) 1987 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. */ #ifndef lint static char sccsid[] = "@(#)addbytes.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine adds the character to the current position * waddbytes(register WINDOW *win, register const char *bytes, register int count) */ int waddbytes(WINDOW *win, const char *bytes, int count) { #define SYNCH_OUT() {win->_cury = y; win->_curx = x;} #define SYNCH_IN() {y = win->_cury; x = win->_curx;} register int x, y; register int newx; SYNCH_IN(); # ifdef FULLDEBUG fprintf(outf, "ADDBYTES('%c') at (%d, %d)\n", c, y, x); # endif while (count--) { register int c; static char blanks[] = " "; c = *bytes++; switch (c) { case '\t': if (waddbytes(win, blanks, 8-(x%8)) == ERR) { return ERR; } SYNCH_IN(); break; default: # ifdef FULLDEBUG fprintf(outf, "ADDBYTES: 1: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]); # endif if (win->_flags & _STANDOUT) c |= _STANDOUT; { # ifdef FULLDEBUG fprintf(outf, "ADDBYTES(%0.2o, %d, %d)\n", win, y, x); # endif if (win->_y[y][x] != c) { newx = x + win->_ch_off; if (win->_firstch[y] == _NOCHANGE) { win->_firstch[y] = win->_lastch[y] = newx; } else if (newx < win->_firstch[y]) win->_firstch[y] = newx; else if (newx > win->_lastch[y]) win->_lastch[y] = newx; # ifdef FULLDEBUG fprintf(outf, "ADDBYTES: change gives f/l: %d/%d [%d/%d]\n", win->_firstch[y], win->_lastch[y], win->_firstch[y] - win->_ch_off, win->_lastch[y] - win->_ch_off); # endif } } win->_y[y][x++] = c; if (x >= win->_maxx) { x = 0; newline: if (++y >= win->_maxy) if (win->_scroll) { --y; SYNCH_OUT(); scroll(win); SYNCH_IN(); } else return ERR; } # ifdef FULLDEBUG fprintf(outf, "ADDBYTES: 2: y = %d, x = %d, firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]); # endif break; case '\n': SYNCH_OUT(); wclrtoeol(win); SYNCH_IN(); if (!NONL) x = 0; goto newline; case '\r': x = 0; break; case '\b': if (--x < 0) x = 0; break; } } SYNCH_OUT(); return OK; } ./libc-linux/curses/addch.c100644 1676 334 4040 5200350425 13620 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)addch.c 5.5 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine adds the character to the current position * */ int waddch(WINDOW *win, char c) { return waddbytes(win, &c, 1); } ./libc-linux/curses/addstr.c100644 1676 334 4202 5200350426 14037 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)addstr.c 5.5 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine adds a string starting at (_cury,_curx) * */ int waddstr(register WINDOW *win, register const char *str) { # ifdef DEBUG fprintf(outf, "WADDSTR(\"%s\")\n", str); # endif return waddbytes(win, str, strlen(str)); } ./libc-linux/curses/box.c100644 1676 334 4750 5200351203 13350 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)box.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine draws a box around the given window with "vert" * as the vertical delimiting char, and "hor", as the horizontal one. * */ int box(register WINDOW *win, char vert, char hor) { register int i; register int endy, endx; register char *fp, *lp; endx = win->_maxx; endy = win->_maxy - 1; fp = win->_y[0]; lp = win->_y[endy]; for (i = 0; i < endx; i++) fp[i] = lp[i] = hor; endx--; for (i = 0; i <= endy; i++) win->_y[i][0] = (win->_y[i][endx] = vert); if (!win->_scroll && (win->_flags&_SCROLLWIN)) fp[0] = fp[endx] = lp[0] = lp[endx] = ' '; touchwin(win); } ./libc-linux/curses/clear.c100644 1676 334 4030 5200350427 13644 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)clear.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine clears the window. * */ wclear(win) register WINDOW *win; { werase(win); win->_clear = TRUE; return OK; } ./libc-linux/curses/clrtobot.c100644 1676 334 4704 5200350430 14410 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)clrtobot.c 5.5 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine erases everything on the window. * */ wclrtobot(win) register WINDOW *win; { register int y; register char *sp, *end, *maxx; register int startx, minx; startx = win->_curx; for (y = win->_cury; y < win->_maxy; y++) { minx = _NOCHANGE; end = &win->_y[y][win->_maxx]; for (sp = &win->_y[y][startx]; sp < end; sp++) if (*sp != ' ') { maxx = sp; if (minx == _NOCHANGE) minx = sp - win->_y[y]; *sp = ' '; } if (minx != _NOCHANGE) touchline(win, y, minx, maxx - &win->_y[y][0]); startx = 0; } } ./libc-linux/curses/clrtoeol.c100644 1676 334 5121 5200350430 14375 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)clrtoeol.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine clears up to the end of line * */ wclrtoeol(win) register WINDOW *win; { register char *sp, *end; register int y, x; register char *maxx; register int minx; y = win->_cury; x = win->_curx; end = &win->_y[y][win->_maxx]; minx = _NOCHANGE; maxx = &win->_y[y][x]; for (sp = maxx; sp < end; sp++) if (*sp != ' ') { maxx = sp; if (minx == _NOCHANGE) minx = sp - win->_y[y]; *sp = ' '; } /* * update firstch and lastch for the line */ touchline(win, y, win->_curx, win->_maxx - 1); # ifdef DEBUG fprintf(outf, "CLRTOEOL: minx = %d, maxx = %d, firstch = %d, lastch = %d\n", minx, maxx - win->_y[y], win->_firstch[y], win->_lastch[y]); # endif } ./libc-linux/curses/curses.ext100644 1676 334 5064 5247273044 14462 0ustar hjlisl/*- * Copyright (c) 1981 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. * * @(#)curses.ext 5.6 (Berkeley) 4/19/91 */ /* * External variables for the curses library */ /* LINTLIBRARY */ #include "curses.h" #ifdef linux #include "memory.h" #include "stdarg.h" #include "unistd.h" #include "stdlib.h" #undef HZ #if 0 #define bcopy(src,dest,size) memcpy(dest,src,size) #endif #endif extern bool _echoit, _rawmode, My_term, _endwin; extern char ttytype[50], *_unctrl[]; extern int _tty_ch, LINES, COLS; extern SGTTY _tty; extern int _putchar(int); extern int _set_subwin_(WINDOW *, WINDOW *win); extern int _id_subwins(WINDOW *); extern int _swflags_ (WINDOW *); extern int _sprintw(WINDOW *, const char *, va_list); extern int scanw(const char *fmt, ...); #define _puts(s) tputs(s, 0, _putchar) #ifdef DEBUG # define outf _outf FILE *outf; #endif ./libc-linux/curses/delch.c100644 1676 334 4524 5200350433 13642 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)delch.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine performs an insert-char on the line, leaving * (_cury,_curx) unchanged. * */ wdelch(win) register WINDOW *win; { register char *temp1, *temp2; register char *end; register int lch; end = &win->_y[win->_cury][win->_maxx - 1]; temp1 = &win->_y[win->_cury][win->_curx]; temp2 = temp1 + 1; while (temp1 < end) *temp1++ = *temp2++; *temp1 = ' '; touchline(win, win->_cury, win->_curx, win->_maxx - 1); return OK; } ./libc-linux/curses/deleteln.c100644 1676 334 5216 5200350433 14356 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)deleteln.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine deletes a line from the screen. It leaves * (_cury,_curx) unchanged. * */ wdeleteln(win) register WINDOW *win; { register char *temp; register int y; register char *end; register int x; # ifdef DEBUG fprintf(outf, "DELETELN(%0.2o)\n", win); # endif temp = win->_y[win->_cury]; for (y = win->_cury; y < win->_maxy - 1; y++) { if (win->_orig == NULL) win->_y[y] = win->_y[y + 1]; else bcopy(win->_y[y + 1], win->_y[y], win->_maxx); touchline(win, y, 0, win->_maxx - 1); } if (win->_orig == NULL) win->_y[y] = temp; else temp = win->_y[y]; for (end = &temp[win->_maxx]; temp < end; ) *temp++ = ' '; touchline(win, win->_cury, 0, win->_maxx - 1); if (win->_orig == NULL) _id_subwins(win); return OK; } ./libc-linux/curses/delwin.c100644 1676 334 5421 5200350434 14043 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)delwin.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine deletes a window and releases it back to the system. * */ delwin(win) register WINDOW *win; { register int i; register WINDOW *wp, *np; if (win->_orig == NULL) { /* * If we are the original window, delete the space for * all the subwindows, and the array of space as well. */ for (i = 0; i < win->_maxy && win->_y[i]; i++) free(win->_y[i]); free(win->_firstch); free(win->_lastch); wp = win->_nextp; while (wp != win) { np = wp->_nextp; delwin(wp); wp = np; } } else { /* * If we are a subwindow, take ourselves out of the * list. NOTE: if we are a subwindow, the minimum list * is orig followed by this subwindow, so there are * always at least two windows in the list. */ for (wp = win->_nextp; wp->_nextp != win; wp = wp->_nextp) continue; wp->_nextp = win->_nextp; } free(win->_y); free(win); } ./libc-linux/curses/endwin.c100644 1676 334 4157 5200350434 14052 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)endwin.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ /* * Clean things up before exiting * */ # include "curses.ext" endwin() { resetty(); _puts(VE); _puts(TE); if (curscr) { if (curscr->_flags & _STANDOUT) { _puts(SE); curscr->_flags &= ~_STANDOUT; } _endwin = TRUE; } } ./libc-linux/curses/erase.c100644 1676 334 4747 5200350435 13673 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)erase.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine erases everything on the window. * */ werase(win) register WINDOW *win; { register int y; register char *sp, *end, *start, *maxx; register int minx; # ifdef DEBUG fprintf(outf, "WERASE(%0.2o)\n", win); # endif for (y = 0; y < win->_maxy; y++) { minx = _NOCHANGE; start = win->_y[y]; end = &start[win->_maxx]; for (sp = start; sp < end; sp++) if (*sp != ' ') { maxx = sp; if (minx == _NOCHANGE) minx = sp - start; *sp = ' '; } if (minx != _NOCHANGE) touchline(win, y, minx, maxx - win->_y[y]); } win->_curx = win->_cury = 0; } ./libc-linux/curses/fullname.c100644 1676 334 4644 5200350435 14373 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)fullname.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # define reg register /* * This routine fills in "def" with the full name of the terminal. * This is assumed to be the last name in the list of aliases. * */ char * fullname(bp, def) register char *bp, *def; { register char *cp; *def = 0; /* in case no name */ while (*bp && *bp != ':') { cp = def; /* start of answer */ while (*bp && *bp != ':' && *bp != '|') { *cp++ = *bp++; /* copy name over */ } *cp = 0; /* zero end of name */ if (*bp == '|') { bp++; /* skip over '|' if that is case */ } } return(def); } ./libc-linux/curses/getch.c100644 1676 334 5125 5200350436 13656 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)getch.c 5.6 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine reads in a character from the window. * */ wgetch(win) register WINDOW *win; { register bool weset = FALSE; register char inp; if (!win->_scroll && (win->_flags&_FULLWIN) && win->_curx == win->_maxx - 1 && win->_cury == win->_maxy - 1) return ERR; # ifdef DEBUG fprintf(outf, "WGETCH: _echoit = %c, _rawmode = %c\n", _echoit ? 'T' : 'F', _rawmode ? 'T' : 'F'); # endif if (_echoit && !_rawmode) { cbreak(); weset++; } inp = getchar(); # ifdef DEBUG fprintf(outf,"WGETCH got '%s'\n",unctrl(inp)); # endif if (_echoit) { mvwaddch(curscr, win->_cury + win->_begy, win->_curx + win->_begx, inp); waddch(win, inp); } if (weset) nocbreak(); return inp; } ./libc-linux/curses/getstr.c100644 1676 334 4245 5200350437 14077 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)getstr.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine gets a string starting at (_cury,_curx) * */ wgetstr(win,str) register WINDOW *win; register char *str; { while ((*str = wgetch(win)) != ERR && *str != '\n') str++; if (*str == ERR) { *str = '\0'; return ERR; } *str = '\0'; return OK; } ./libc-linux/curses/id_subwins.c100644 1676 334 4720 5200350437 14733 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)id_subwins.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * _id_subwins: * Re-sync the pointers to _y for all the subwindows. * */ _id_subwins(orig) register WINDOW *orig; { register WINDOW *win; register int realy; register int y, oy, x; realy = orig->_begy + orig->_cury; for (win = orig->_nextp; win != orig; win = win->_nextp) { /* * If the window ends before our current position, * don't need to do anything. */ if (win->_begy + win->_maxy <= realy) continue; oy = orig->_cury; for (y = realy - win->_begy; y < win->_maxy; y++, oy++) win->_y[y] = &orig->_y[oy][win->_ch_off]; } } ./libc-linux/curses/idlok.c100644 1676 334 4161 5200357630 13670 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)idlok.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * idlok: * Turn on and off using insert/deleteln sequences for the given * window. * */ void idlok(win, bf) register WINDOW *win; bool bf; { if (bf) win->_flags |= _IDLINE; else win->_flags &= ~_IDLINE; } ./libc-linux/curses/mvprintw.c100644 1676 334 5477 5200350444 14463 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)mvprintw.c 5.8 (Berkeley) 6/19/91"; #endif /* not lint */ #if __STDC__ #include #else #include #endif #include "curses.ext" /* * implement the mvprintw commands. Due to the variable number of * arguments, they cannot be macros. Sigh.... */ #if __STDC__ mvprintw(register int y, register int x, const char *fmt, ...) #else mvprintw(y, x, fmt, va_alist) register int y, x; char *fmt; va_dcl #endif { va_list ap; int ret; if (move(y, x) != OK) return ERR; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = _sprintw(stdscr, fmt, ap); va_end(ap); return ret; } #if __STDC__ mvwprintw(register WINDOW *win, register int y, register int x, const char *fmt, ...) #else mvwprintw(win, y, x, fmt, va_alist) register WINDOW *win; register int y, x; char *fmt; va_dcl #endif { va_list ap; int ret; if (wmove(win, y, x) != OK) return ERR; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = _sprintw(win, fmt, ap); va_end(ap); return ret; } ./libc-linux/curses/insch.c100644 1676 334 4744 5200360074 13675 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)insch.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine performs an insert-char on the line, leaving * (_cury,_curx) unchanged. * */ winsch(register WINDOW *win, char c) { register char *temp1, *temp2; register char *end; end = &win->_y[win->_cury][win->_curx]; temp1 = &win->_y[win->_cury][win->_maxx - 1]; temp2 = temp1 - 1; while (temp1 > end) *temp1-- = *temp2--; *temp1 = c; touchline(win, win->_cury, win->_curx, win->_maxx - 1); if (win->_cury == LINES - 1 && win->_y[LINES-1][COLS-1] != ' ') if (win->_scroll) { wrefresh(win); scroll(win); win->_cury--; } else return ERR; return OK; } ./libc-linux/curses/insertln.c100644 1676 334 5232 5200350442 14416 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)insertln.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine performs an insert-line on the window, leaving * (_cury,_curx) unchanged. * */ winsertln(win) register WINDOW *win; { register char *temp; register int y; register char *end; register int x; #ifdef DEBUG fprintf(outf, "INSERTLN(%0.2o)\n", win); #endif if (win->_orig == NULL) temp = win->_y[win->_maxy - 1]; for (y = win->_maxy - 1; y > win->_cury; --y) { if (win->_orig == NULL) win->_y[y] = win->_y[y - 1]; else bcopy(win->_y[y - 1], win->_y[y], win->_maxx); touchline(win, y, 0, win->_maxx - 1); } if (win->_orig == NULL) win->_y[y] = temp; else temp = win->_y[y]; for (end = &temp[win->_maxx]; temp < end; ) *temp++ = ' '; touchline(win, y, 0, win->_maxx - 1); if (win->_orig == NULL) _id_subwins(win); } ./libc-linux/curses/longname.c100644 1676 334 4337 5200350443 14366 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)longname.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # define reg register /* * This routine fills in "def" with the long name of the terminal. * */ char * longname(bp, def) register char *bp, *def; { register char *cp; while (*bp && *bp != ':' && *bp != '|') bp++; if (*bp == '|') { bp++; cp = def; while (*bp && *bp != ':' && *bp != '|') *cp++ = *bp++; *cp = 0; } return def; } ./libc-linux/curses/move.c100644 1676 334 4334 5200350443 13531 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)move.c 5.5 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine moves the cursor to the given point * */ wmove(win, y, x) register WINDOW *win; register int y, x; { # ifdef DEBUG fprintf(outf, "MOVE to (%d, %d)\n", y, x); # endif if (x < 0 || y < 0) return ERR; if (x >= win->_maxx || y >= win->_maxy) return ERR; win->_curx = x; win->_cury = y; return OK; } ./libc-linux/curses/mvscanw.c100644 1676 334 5471 5200350445 14246 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)mvscanw.c 5.5 (Berkeley) 4/15/91"; #endif /* not lint */ #if __STDC__ #include #else #include #endif #include "curses.ext" /* * implement the mvscanw commands. Due to the variable number of * arguments, they cannot be macros. Another sigh.... */ #if __STDC__ mvscanw(register int y, register int x, const char *fmt, ...) #else mvscanw(y, x, fmt, va_alist) register int y, x; char *fmt; va_dcl #endif { va_list ap; int ret; if (move(y, x) != OK) return ERR; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = _sscans(stdscr, fmt, ap); va_end(ap); return ret; } #if __STDC__ mvwscanw(register WINDOW *win, register int y, register int x, const char *fmt, ...) #else mvwscanw(win, y, x, fmt, va_alist) register WINDOW *win; register int y, x; char *fmt; va_dcl #endif { va_list ap; int ret; if (move(y, x) != OK) return ERR; #if __STDC__ va_start(ap, fmt); #else va_start(ap); #endif ret = _sscans(win, fmt, ap); va_end(ap); return ret; } ./libc-linux/curses/mvwin.c100644 1676 334 5154 5200350446 13727 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)mvwin.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * relocate the starting position of a window * */ mvwin(win, by, bx) register WINDOW *win; register int by, bx; { register WINDOW *orig; register int dy, dx; if (by + win->_maxy > LINES || bx + win->_maxx > COLS) return ERR; dy = by - win->_begy; dx = bx - win->_begx; orig = win->_orig; if (orig == NULL) { orig = win; do { win->_begy += dy; win->_begx += dx; _swflags_(win); win = win->_nextp; } while (win != orig); } else { if (by < orig->_begy || win->_maxy + dy > orig->_maxy) return ERR; if (bx < orig->_begx || win->_maxx + dx > orig->_maxx) return ERR; win->_begy = by; win->_begx = bx; _swflags_(win); _set_subwin_(orig, win); } touchwin(win); return OK; } ./libc-linux/curses/newwin.c100644 1676 334 14472 5223277730 14132 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)newwin.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ /* * allocate space for and set up defaults for a new window * */ # include "curses.ext" #ifdef linux #include static WINDOW *makenew(int, int, int, int); #else char *malloc(); static WINDOW *makenew(); #endif # define SMALLOC (short *) malloc # undef nl /* don't need it here, and it interferes */ WINDOW * newwin(num_lines, num_cols, begy, begx) int num_lines, num_cols, begy, begx; { register WINDOW *win; register char *sp; register int i, by, bx, nl, nc; register int j; by = begy; bx = begx; nl = num_lines; nc = num_cols; if (nl == 0) nl = LINES - by; if (nc == 0) nc = COLS - bx; if ((win = makenew(nl, nc, by, bx)) == NULL) return ERR; if ((win->_firstch = SMALLOC(nl * sizeof win->_firstch[0])) == NULL) { free(win->_y); free(win); return NULL; } if ((win->_lastch = SMALLOC(nl * sizeof win->_lastch[0])) == NULL) { free(win->_y); free(win->_firstch); free(win); return NULL; } win->_nextp = win; for (i = 0; i < nl; i++) { win->_firstch[i] = _NOCHANGE; win->_lastch[i] = _NOCHANGE; } for (i = 0; i < nl; i++) if ((win->_y[i] = malloc(nc * sizeof win->_y[0])) == NULL) { for (j = 0; j < i; j++) free(win->_y[j]); free(win->_firstch); free(win->_lastch); free(win->_y); free(win); return ERR; } else for (sp = win->_y[i]; sp < win->_y[i] + nc; ) *sp++ = ' '; win->_ch_off = 0; # ifdef DEBUG fprintf(outf, "NEWWIN: win->_ch_off = %d\n", win->_ch_off); # endif return win; } WINDOW * subwin(orig, num_lines, num_cols, begy, begx) register WINDOW *orig; int num_lines, num_cols, begy, begx; { register int i; register WINDOW *win; register int by, bx, nl, nc; by = begy; bx = begx; nl = num_lines; nc = num_cols; /* * make sure window fits inside the original one */ # ifdef DEBUG fprintf(outf, "SUBWIN(%0.2o, %d, %d, %d, %d)\n", orig, nl, nc, by, bx); # endif if (by < orig->_begy || bx < orig->_begx || by + nl > orig->_maxy + orig->_begy || bx + nc > orig->_maxx + orig->_begx) return ERR; if (nl == 0) nl = orig->_maxy + orig->_begy - by; if (nc == 0) nc = orig->_maxx + orig->_begx - bx; if ((win = makenew(nl, nc, by, bx)) == NULL) return ERR; win->_nextp = orig->_nextp; orig->_nextp = win; win->_orig = orig; _set_subwin_(orig, win); return win; } /* * this code is shared with mvwin() */ _set_subwin_(orig, win) register WINDOW *orig, *win; { register int i, j, k; j = win->_begy - orig->_begy; k = win->_begx - orig->_begx; win->_ch_off = k; # ifdef DEBUG fprintf(outf, "_SET_SUBWIN_: win->_ch_off = %d\n", win->_ch_off); # endif win->_firstch = &orig->_firstch[j]; win->_lastch = &orig->_lastch[j]; for (i = 0; i < win->_maxy; i++, j++) win->_y[i] = &orig->_y[j][k]; } /* * This routine sets up a window buffer and returns a pointer to it. */ static WINDOW * makenew(num_lines, num_cols, begy, begx) int num_lines, num_cols, begy, begx; { register int i; register WINDOW *win; register int by, bx, nl, nc; by = begy; bx = begx; nl = num_lines; nc = num_cols; # ifdef DEBUG fprintf(outf, "MAKENEW(%d, %d, %d, %d)\n", nl, nc, by, bx); # endif if ((win = (WINDOW *) malloc(sizeof *win)) == NULL) return NULL; # ifdef DEBUG fprintf(outf, "MAKENEW: nl = %d\n", nl); # endif if ((win->_y = (char **) malloc(nl * sizeof win->_y[0])) == NULL) { free(win); return NULL; } # ifdef DEBUG fprintf(outf, "MAKENEW: nc = %d\n", nc); # endif win->_cury = win->_curx = 0; win->_clear = FALSE; win->_maxy = nl; win->_maxx = nc; win->_begy = by; win->_begx = bx; win->_flags = 0; win->_scroll = win->_leave = FALSE; _swflags_(win); # ifdef DEBUG fprintf(outf, "MAKENEW: win->_clear = %d\n", win->_clear); fprintf(outf, "MAKENEW: win->_leave = %d\n", win->_leave); fprintf(outf, "MAKENEW: win->_scroll = %d\n", win->_scroll); fprintf(outf, "MAKENEW: win->_flags = %0.2o\n", win->_flags); fprintf(outf, "MAKENEW: win->_maxy = %d\n", win->_maxy); fprintf(outf, "MAKENEW: win->_maxx = %d\n", win->_maxx); fprintf(outf, "MAKENEW: win->_begy = %d\n", win->_begy); fprintf(outf, "MAKENEW: win->_begx = %d\n", win->_begx); # endif return win; } _swflags_(win) register WINDOW *win; { win->_flags &= ~(_ENDLINE|_FULLLINE|_FULLWIN|_SCROLLWIN); if (win->_begx + win->_maxx == COLS) { win->_flags |= _ENDLINE; if (win->_begx == 0) { if (AL && DL) win->_flags |= _FULLLINE; if (win->_maxy == LINES && win->_begy == 0) win->_flags |= _FULLWIN; } if (win->_begy + win->_maxy == LINES) win->_flags |= _SCROLLWIN; } } ./libc-linux/curses/overlay.c100644 1676 334 5676 5200350447 14262 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)overlay.c 5.6 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" # include # define min(a,b) (a < b ? a : b) # define max(a,b) (a > b ? a : b) /* * This routine writes win1 on win2 non-destructively. * */ overlay(win1, win2) register WINDOW *win1, *win2; { register char *sp, *end; register int x, y, endy, endx, starty, startx; register int y1,y2; # ifdef DEBUG fprintf(outf, "OVERLAY(%0.2o, %0.2o);\n", win1, win2); # endif starty = max(win1->_begy, win2->_begy); startx = max(win1->_begx, win2->_begx); endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); # ifdef DEBUG fprintf(outf, "OVERLAY:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); # endif if (starty >= endy || startx >= endx) return; y1 = starty - win1->_begy; y2 = starty - win2->_begy; for (y = starty; y < endy; y++, y1++, y2++) { end = &win1->_y[y1][endx - win1->_begx]; x = startx - win2->_begx; for (sp = &win1->_y[y1][startx - win1->_begx]; sp < end; sp++) { if (!isspace(*sp)) mvwaddch(win2, y2, x, *sp); x++; } } } ./libc-linux/curses/overwrite.c100644 1676 334 5550 5200350450 14610 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)overwrite.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" # include # define min(a,b) (a < b ? a : b) # define max(a,b) (a > b ? a : b) /* * This routine writes win1 on win2 destructively. * */ overwrite(win1, win2) register WINDOW *win1, *win2; { register char *sp, *end; register int x, y, endy, endx, starty, startx; # ifdef DEBUG fprintf(outf, "OVERWRITE(%0.2o, %0.2o);\n", win1, win2); # endif starty = max(win1->_begy, win2->_begy); startx = max(win1->_begx, win2->_begx); endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); if (starty >= endy || startx >= endx) return; # ifdef DEBUG fprintf(outf, "OVERWRITE:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); # endif x = endx - startx; for (y = starty; y < endy; y++) { bcopy(&win1->_y[y - win1->_begy][startx - win1->_begx], &win2->_y[y - win2->_begy][startx - win2->_begx], x); touchline(win2, y, startx - win2->_begx, endx - win2->_begx); } } ./libc-linux/curses/putchar.c100644 1676 334 4012 5200354403 14222 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)putchar.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" int _putchar(c) register int c; { putchar(c); #ifdef DEBUG fprintf(outf, "_PUTCHAR(%s)\n", unctrl(c)); #endif } ./libc-linux/curses/tstp.c100644 1676 334 5410 5200350456 13555 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)tstp.c 5.6 (Berkeley) 3/3/91"; #endif /* not lint */ # include # include "curses.ext" /* * handle stop and start signals * * @(#)tstp.c 5.6 (Berkeley) 3/3/91 */ void tstp() { # ifdef SIGTSTP SGTTY tty; #ifdef POSIX sigset_t mask, omask; #else int omask; #endif # ifdef DEBUG if (outf) fflush(outf); # endif tty = _tty; mvcur(0, COLS - 1, LINES - 1, 0); endwin(); fflush(stdout); /* reset signal handler so kill below stops us */ signal(SIGTSTP, SIG_DFL); #ifdef POSIX sigemptyset(&mask); sigaddset(&mask, SIGTSTP); sigprocmask(SIG_SETMASK, &mask, &omask); kill(0, SIGTSTP); sigprocmask(SIG_SETMASK, &omask, 0); #else #define mask(s) (1 << ((s)-1)) omask = sigsetmask(sigblock(0) &~ mask(SIGTSTP)); kill(0, SIGTSTP); sigblock(mask(SIGTSTP)); #endif signal(SIGTSTP, tstp); _tty = tty; #ifdef POSIX tcsetattr(_tty_ch, TCSADRAIN, &_tty); #else ioctl(_tty_ch, TIOCSETP, &_tty); #endif wrefresh(curscr); # endif SIGTSTP } ./libc-linux/curses/scroll.c100644 1676 334 4512 5200350453 14060 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)scroll.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * This routine scrolls the window up a line. * */ scroll(win) register WINDOW *win; { register int oy, ox; # ifdef DEBUG fprintf(outf, "SCROLL(%0.2o)\n", win); # endif if (!win->_scroll) return ERR; getyx(win, oy, ox); wmove(win, 0, 0); wdeleteln(win); wmove(win, oy, ox); if (win == curscr) { _putchar('\n'); if (!NONL) win->_curx = 0; # ifdef DEBUG fprintf(outf, "SCROLL: win == curscr\n"); # endif } } ./libc-linux/curses/standout.c100644 1676 334 4446 5200350454 14432 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)standout.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ /* * routines dealing with entering and exiting standout mode * */ # include "curses.ext" /* * enter standout mode */ char * wstandout(win) register WINDOW *win; { if (!SO && !UC) return FALSE; win->_flags |= _STANDOUT; return (SO ? SO : UC); } /* * exit standout mode */ char * wstandend(win) register WINDOW *win; { if (!SO && !UC) return FALSE; win->_flags &= ~_STANDOUT; return (SE ? SE : UC); } ./libc-linux/curses/toucholap.c100644 1676 334 6021 5200350454 14556 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)toucholap.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" # define min(a,b) (a < b ? a : b) # define max(a,b) (a > b ? a : b) /* * Touch, on win2, the part that overlaps with win1. * */ touchoverlap(win1, win2) register WINDOW *win1, *win2; { register int x, y, endy, endx, starty, startx; # ifdef DEBUG fprintf(outf, "TOUCHOVERLAP(%0.2o, %0.2o);\n", win1, win2); # endif starty = max(win1->_begy, win2->_begy); startx = max(win1->_begx, win2->_begx); endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx); endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); # ifdef DEBUG fprintf(outf, "TOUCHOVERLAP:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx); fprintf(outf, "TOUCHOVERLAP:win1 (%d,%d) to (%d,%d)\n", win1->_begy, win1->_begx, win1->_begy + win1->_maxy, win1->_begx + win1->_maxx); fprintf(outf, "TOUCHOVERLAP:win2 (%d,%d) to (%d,%d)\n", win2->_begy, win2->_begx, win2->_begy + win2->_maxy, win2->_begx + win2->_maxx); # endif if (starty >= endy || startx >= endx) return; starty -= win2->_begy; startx -= win2->_begx; endy -= win2->_begy; endx -= win2->_begx; endx--; for (y = starty; y < endy; y++) touchline(win2, y, startx, endx); } ./libc-linux/curses/touchwin.c100644 1676 334 5500 5200351576 14427 0ustar hjlisl/* * Copyright (c) 1981 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. */ #ifndef lint static char sccsid[] = "@(#)touchwin.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ # include "curses.ext" /* * make it look like the whole window has been changed. * */ touchwin(win) register WINDOW *win; { register int y, maxy; # ifdef DEBUG fprintf(outf, "TOUCHWIN(%0.2o)\n", win); # endif maxy = win->_maxy; for (y = 0; y < maxy; y++) touchline(win, y, 0, win->_maxx - 1); } /* * touch a given line */ touchline(register WINDOW *win, register int y, register int sx, register int ex) { # ifdef DEBUG fprintf(outf, "TOUCHLINE(%0.2o, %d, %d, %d)\n", win, y, sx, ex); fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]); # endif sx += win->_ch_off; ex += win->_ch_off; if (win->_firstch[y] == _NOCHANGE) { win->_firstch[y] = sx; win->_lastch[y] = ex; } else { if (win->_firstch[y] > sx) win->_firstch[y] = sx; if (win->_lastch[y] < ex) win->_lastch[y] = ex; } # ifdef DEBUG fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]); # endif } ./libc-linux/curses/curspatch100644 1676 334 751 5163230166 14324 0ustar hjlisl*** printw.c.ORIG Sat Jan 25 06:19:45 1992 --- printw.c Sat Jan 25 06:26:19 1992 *************** *** 131,141 **** #endif va_list ap; { ! FILE *f; ! extern FILE *fwopen(); ! if ((f = fwopen((void *)win, _winwrite)) == NULL) return ERR; ! (void) vfprintf(f, fmt, ap); ! return fclose(f) ? ERR : OK; } --- 131,140 ---- #endif va_list ap; { ! char buf[1024]; ! vsprintf(buf, fmt, ap); ! if (_winwrite(win, buf, strlen(buf))) return ERR; ! return OK; } ./libc-linux/curses/Makebak100644 1676 334 1713 5163215144 13701 0ustar hjlisl# @(#)Makefile 5.10 (Berkeley) 6/24/90 LIB= curses SRCS= addbytes.c addch.c addstr.c box.c clear.c clrtobot.c clrtoeol.c \ cr_put.c cr_tty.c curses.c delch.c deleteln.c delwin.c endwin.c \ erase.c fullname.c getch.c getstr.c idlok.c id_subwins.c initscr.c \ insch.c insertln.c longname.c move.c mvprintw.c mvscanw.c mvwin.c \ newwin.c overlay.c overwrite.c printw.c putchar.c refresh.c scanw.c \ scroll.c toucholap.c standout.c touchwin.c tstp.c unctrl.c MAN3= curses.0 CFLAGS+=-DPOSIX OBJS+= ${SRCS:R:S/$/.o/g} all: libcurses.a # need to alter default rules in /usr/share/mk/bsd.lib.mk; we don't have # lorder or tsort. lib${LIB}.a:: ${OBJS} @echo building standard ${LIB} library @rm -f lib${LIB}.a @${AR} cTq lib${LIB}.a ${OBJS} ${LDADD} ranlib lib${LIB}.a beforeinstall: -cd ${.CURDIR}; cmp -s curses.h ${DESTDIR}/usr/include/curses.h || \ install -c -o ${BINOWN} -g ${BINGRP} -m 444 curses.h \ ${DESTDIR}/usr/include .include ./libc-linux/curses/curses.c100644 1676 334 7140 5321140267 14072 0ustar hjlisl/* * Copyright (c) 1981 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 0 #ifndef lint static char sccsid[] = "@(#)curses.c 5.7 (Berkeley) 6/1/90"; #endif /* not lint */ #endif /* * Define global variables * */ # include "curses.h" bool _echoit = TRUE, /* set if stty indicates ECHO */ _rawmode = FALSE,/* set if stty indicates RAW mode */ My_term = FALSE,/* set if user specifies terminal type */ _endwin = FALSE;/* set if endwin has been called */ char ttytype[50] = "", /* long name of tty */ *Def_term = "unknown"; /* default terminal type */ int _tty_ch = 0, /* file channel which is a tty */ /* let applications detect the values. */ LINES = 0, /* number of lines allowed on screen */ COLS = 0; /* number of columns allowed on screen */ tcflag_t _res_iflg = 0; tcflag_t _res_lflg = 0; WINDOW *stdscr = NULL, *curscr = NULL; # ifdef DEBUG FILE *outf = 0; /* debug output file */ # endif SGTTY _tty = {0, 0, 0, 0, 0, ""}; /* tty modes */ bool AM = 0, BS = 0, CA = 0, DA = 0, DB = 0, EO = 0, HC = 0, HZ = 0, IN = 0, MI = 0, MS = 0, NC = 0, NS = 0, OS = 0, UL = 0, XB = 0, XN = 0, XT = 0, XS = 0, XX = 0; char *AL = 0, *BC = 0, *BT = 0, *CD = 0, *CE = 0, *CL = 0, *CM = 0, *CR = 0, *CS = 0, *DC = 0, *DL = 0, *DM = 0, *DO = 0, *ED = 0, *EI = 0, *K0 = 0, *K1 = 0, *K2 = 0, *K3 = 0, *K4 = 0, *K5 = 0, *K6 = 0, *K7 = 0, *K8 = 0, *K9 = 0, *HO = 0, *IC = 0, *IM = 0, *IP = 0, *KD = 0, *KE = 0, *KH = 0, *KL = 0, *KR = 0, *KS = 0, *KU = 0, *LL = 0, *MA = 0, *ND = 0, *NL = 0, *RC = 0, *SC = 0, *SE = 0, *SF = 0, *SO = 0, *SR = 0, *TA = 0, *TE = 0, *TI = 0, *UC = 0, *UE = 0, *UP = 0, *US = 0, *VB = 0, *VS = 0, *VE = 0, *AL_PARM = 0, *DL_PARM = 0, *UP_PARM = 0, *DOWN_PARM = 0, *LEFT_PARM = 0, *RIGHT_PARM = 0; char PC = 0; /* * From the tty modes... */ bool GT = 0, NONL = 0, UPPERCASE = 0, normtty = 0, _pfast = 0; ./libc-linux/curses/unctrl.c100644 1676 334 5277 5244276562 14122 0ustar hjlisl/* * Copyright (c) 1981 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 0 #ifndef lint static char sccsid[] = "@(#)unctrl.c 5.4 (Berkeley) 6/1/90"; #endif /* not lint */ #endif /* * define unctrl codes for each character * */ /* LINTLIBRARY */ char *_unctrl[] = { /* unctrl codes for ttys */ "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "^I", "^J", "^K", "^L", "^M", "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W", "^X", "^Y", "^Z", "^[", "^\\", "^]", "^~", "^_", " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "^?" }; ./libc-linux/cvt/ 40755 1676 334 0 5550051226 11613 5ustar hjlisl./libc-linux/cvt/cvt.c100644 1676 334 4015 5341650332 12651 0ustar hjlisl#include #include #include #define IEEE 1 /* * ecvt converts to decimal * the number of digits is specified by ndigit * decpt is set to the position of the decimal point * sign is set to 0 for positive, 1 for negative */ #ifdef IEEE static inline int __isspecial(double f, char *bp) { union ieee754_double *ip = (union ieee754_double *) &f; if ((ip->ieee.exponent & 0x7ff) != 0x7ff) return(0); if (ip->ieee.mantissa0 || ip->ieee.mantissa1) strcpy(bp, "NaN"); else if (ip->ieee.negative) strcpy(bp, "-Infinity"); else strcpy(bp, "Infinity"); return(1); } #define NDIG 512 #else #define NDIG 80 #endif static char* cvt(double arg, size_t ndigits, int *decpt, int *sign, int eflag) { register int r2; double fi, fj; register char *p, *p1; static char buf[NDIG]; #ifdef IEEE /* XXX */ if (__isspecial(arg, buf)) return(buf); #endif if (ndigits>=NDIG-1) ndigits = NDIG-2; r2 = 0; *sign = 0; p = &buf[0]; if (arg<0) { *sign = 1; arg = -arg; } arg = modf(arg, &fi); p1 = &buf[NDIG]; /* * Do integer part */ if (fi != 0) { p1 = &buf[NDIG]; while (fi != 0) { fj = modf(fi/10, &fi); *--p1 = (int)((fj+.03)*10) + '0'; r2++; } while (p1 < &buf[NDIG]) *p++ = *p1++; } else if (arg > 0) { while ((fj = arg*10) < 1) { arg = fj; r2--; } } p1 = &buf[ndigits]; if (eflag==0) p1 += r2; *decpt = r2; if (p1 < &buf[0]) { buf[0] = '\0'; return(buf); } while (p<=p1 && p<&buf[NDIG]) { arg *= 10; arg = modf(arg, &fj); *p++ = (int)fj + '0'; } if (p1 >= &buf[NDIG]) { buf[NDIG-1] = '\0'; return(buf); } p = p1; *p1 += 5; while (*p1 > '9') { *p1 = '0'; if (p1>buf) ++*--p1; else { *p1 = '1'; (*decpt)++; if (eflag==0) { if (p>buf) *p = '0'; p++; } } } *p = '\0'; return(buf); } char* ecvt(double arg, size_t ndigits, int *decpt, int *sign) { return(cvt(arg, ndigits, decpt, sign, 1)); } char* fcvt(double arg, size_t ndigits, int *decpt, int *sign) { return(cvt(arg, ndigits, decpt, sign, 0)); } ./libc-linux/cvt/Makefile100644 1676 334 362 5515543511 13335 0ustar hjlisl# # Makefile for cvt functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS= -I$(TOPDIR)/misc DIRS:= SRCS = cvt.c gcvt.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/cvt/gcvt.c100644 1676 334 1766 5153334646 13042 0ustar hjlisl#include /* * gcvt - Floating output conversion to * minimal length string */ char * gcvt(double number, size_t ndigit, char *buf) { int sign, decpt; register char *p1, *p2; register i; p1 = ecvt(number, ndigit, &decpt, &sign); p2 = buf; if (sign) *p2++ = '-'; for (i=ndigit-1; i>0 && p1[i]=='0'; i--) ndigit--; if ((decpt >= 0 && decpt-ndigit > 4) || (decpt < 0 && decpt < -3)) { /* use E-style */ decpt--; *p2++ = *p1++; *p2++ = '.'; for (i=1; i #include #include #include #include static inline _syscall1(int,close,int,fd) int closedir(DIR * dir) { int fd; if (!dir) { errno = EBADF; return -1; } fd = dir->dd_fd; free(dir->dd_buf); free(dir); return close(fd); } ./libc-linux/dirent/opendir.c100644 1676 334 2335 5346567536 14233 0ustar hjlisl#include #include #include #include #include #include #include #include #undef close #undef stat(filename,stat_buf) static inline _syscall1(int,close,int,fd) static inline _syscall2(int,stat,const char *,filename,struct stat *,stat_buf) /* * opendir just makes an open() call - it return NULL if it fails * (open sets errno), otherwise it returns a DIR * pointer. */ DIR * opendir(const char * name) { int fd; struct stat statbuf; struct dirent *buf; DIR *ptr; if (stat(name,&statbuf)) return NULL; if (!S_ISDIR(statbuf.st_mode)) { errno = ENOTDIR; return NULL; } if ((fd = __open(name,O_RDONLY)) < 0) return NULL; /* According to POSIX, directory streams should be closed when * exec. From "Anna Pluzhnikov" . */ if (__fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) return NULL; if (!(ptr=malloc(sizeof(*ptr)))) { close(fd); errno = ENOMEM; return NULL; } if (!(buf=malloc(NUMENT*sizeof (struct dirent)))) { close(fd); free(ptr); errno = ENOMEM; return NULL; } ptr->dd_fd = fd; ptr->dd_loc = ptr->dd_size = 0; ptr->dd_buf = buf; return ptr; } ./libc-linux/dirent/rewinddir.c100644 1676 334 541 5270350545 14521 0ustar hjlisl#include #include #include #include #undef lseek static inline _syscall3(off_t,lseek,int,fildes,off_t,offset,int,origin) /* * rewinddir() just does an lseek(fd,0,0) - see close for comments */ void rewinddir(DIR * dir) { if (!dir) { errno = EBADF; return; } lseek(dir->dd_fd,0,SEEK_SET); } ./libc-linux/dirent/seekdir.c100644 1676 334 450 5270350633 14155 0ustar hjlisl#include #include #include #include #undef lseek static inline _syscall3(off_t,lseek,int,fildes,off_t,offset,int,origin) void seekdir(DIR * dir, off_t offset) { if (!dir) { errno = EBADF; return; } lseek(dir->dd_fd,offset,SEEK_SET); } ./libc-linux/dirent/telldir.c100644 1676 334 440 5270350571 14166 0ustar hjlisl#include #include #include #include #undef lseek static inline _syscall3(off_t,lseek,int,fildes,off_t,offset,int,origin) off_t telldir(DIR * dir) { if (!dir) { errno = EBADF; return -1; } return lseek(dir->dd_fd,0,SEEK_CUR); } ./libc-linux/dirent/alphasort.c100644 1676 334 2016 5344766133 14554 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 #include #include int DEFUN(alphasort, (a, b), CONST struct dirent * CONST * a AND CONST struct dirent * CONST * b) { return strcmp ((*a)->d_name, (*b)->d_name); } ./libc-linux/dirent/scandir.c100644 1676 334 4316 5344752104 14200 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 #include #include int #ifdef linux DEFUN(scandir, (dir, namelist, select, cmp), CONST char *dir AND struct dirent ***namelist AND __dir_select_fn_t select AND __dir_compar_fn_t cmp) #else DEFUN(scandir, (dir, namelist, select, cmp), CONST char *dir AND struct dirent ***namelist AND int EXFUN((*select), (struct dirent *)) AND int EXFUN((*cmp), ( CONST struct dirent * CONST *, CONST struct dirent * CONST *))) #endif { DIR *dp = opendir (dir); struct dirent **v = NULL; size_t vsize = 0, i; struct dirent *d; int save; if (dp == NULL) return -1; save = errno; errno = 0; i = 0; while ((d = readdir (dp)) != NULL) if (select == NULL || (*select) (d)) { if (i == vsize) { struct dirent **new; if (vsize == 0) vsize = 10; else vsize *= 2; new = (struct dirent **) realloc (v, vsize * sizeof (*v)); if (new == NULL) { lose: (void) closedir (dp); while (i > 0) free (v[--i]); free (v); errno = ENOMEM; return -1; } v = new; } v[i] = (struct dirent *) malloc (sizeof (**v)); if (v[i] == NULL) goto lose; *v[i++] = *d; } if (errno != 0) { (void) closedir (dp); return -1; } errno = save; if (cmp != NULL) qsort (v, i, sizeof (*v), cmp); *namelist = v; return i; } ./libc-linux/grp/ 40755 1676 334 0 5550051633 11611 5ustar hjlisl./libc-linux/grp/Makefile100644 1676 334 475 5515543720 13340 0ustar hjlisl# # Makefile for grp functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS= -I. -I$(TOPDIR) DIRS:= SRCS= fgetgrent.c getgrent.c getgrgid.c getgrnam.c grpopen.c \ grpread.c initgroups.c # gshadow.c SMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/grp/fgetgrent.c100644 1676 334 2305 5154331354 14040 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 #include #include /* Read a group entry from STREAM. */ struct group * DEFUN(fgetgrent, (stream), FILE *stream) { static PTR info = NULL; if (info == NULL) { info = __grpalloc(); if (info == NULL) return NULL; } return __grpread(stream, info); } ./libc-linux/grp/getgrent.c100644 1676 334 3272 5446306360 13701 0ustar hjlisl/* LAST EDIT: Wed Mar 31 06:47:16 1993 by Swen Thümmler (swen) */ /* 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 #ifdef YP extern void __yp_cleargrflag __P((void)); #endif static FILE *stream = NULL; /* Rewind the stream. */ void DEFUN_VOID(setgrent) { if (stream != NULL) rewind(stream); #ifdef YP __yp_cleargrflag(); #endif } /* Close the stream. */ void DEFUN_VOID(endgrent) { if (stream != NULL) { (void) fclose(stream); stream = NULL; } #ifdef YP __yp_cleargrflag(); #endif } /* Read an entry from the stream. */ struct group * DEFUN_VOID(getgrent) { static PTR info = NULL; if (info == NULL) { info = __grpalloc(); if (info == NULL) return(NULL); } if (stream == NULL) { stream = __grpopen(); if (stream == NULL) return(NULL); } return(__grpread(stream, info)); } ./libc-linux/grp/getgrgid.c100644 1676 334 5147 5446306363 13664 0ustar hjlisl/* LAST EDIT: Wed Mar 31 07:32:00 1993 by Swen Thümmler (swen) */ /* 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 #ifdef YP #include #include #include extern int __yp_check __P((char **)) ; extern char *__yp_getdomain __P((void)) ; extern int __ypparsegrp __P((struct group *, char *)) ; extern struct group * DEFUN(__grpread_noyp, (stream, p), FILE *stream AND PTR CONST p) ; typedef struct { char *buf; size_t buflen; size_t max_members; char **members; struct group g; } grpread_info; #endif /* Search for an entry with a matching group ID. */ struct group * DEFUN(getgrgid, (gid), register gid_t gid) { static PTR info = NULL; register FILE *stream; register struct group *g; if (info == NULL) { info = __grpalloc(); if (info == NULL) return NULL; } stream = __grpopen(); if (stream == NULL) return NULL; #ifdef YP while ((g = __grpread_noyp(stream, info)) != NULL) if (g->gr_gid == (gid_t) gid) break; (void) fclose(stream); if (g == NULL) { char *indomain ; char *outkey = NULL ; int r, outkeylen ; g = &((grpread_info *) info)->g ; indomain = __yp_getdomain() ; if (indomain) { char gidbuf[20] ; sprintf(gidbuf, "%d", gid) ; r = yp_match(indomain, "group.bygid", gidbuf, strlen(gidbuf), &outkey, &outkeylen) ; switch (r) { case 0: if (__ypparsegrp(g, outkey) != 0) g = NULL; break ; default: free(outkey) ; outkey = NULL ; g = NULL ; } } else g = NULL ; } #else while ((g = __grpread(stream, info)) != NULL) if (g->gr_gid == (gid_t) gid) break; (void) fclose(stream); #endif /* YP */ return g; } ./libc-linux/grp/getgrnam.c100644 1676 334 5065 5446306364 13674 0ustar hjlisl/* LAST EDIT: Wed Mar 31 07:39:35 1993 by Swen Thümmler (swen) */ /* 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 #ifdef YP #include #include #include extern int __yp_check __P((char **)) ; extern char *__yp_getdomain __P((void)) ; extern int __ypparsegrp __P((struct group *, char *)) ; extern struct group * DEFUN(__grpread_noyp, (stream, p), FILE *stream AND PTR CONST p) ; typedef struct { char *buf; size_t buflen; size_t max_members; char **members; struct group g; } grpread_info; #endif /* Search for an entry with a matching name. */ struct group * DEFUN(getgrnam, (name), register CONST char *name) { static PTR info = NULL; register FILE *stream; register struct group *g; if (info == NULL) { info = __grpalloc(); if (info == NULL) return NULL; } stream = __grpopen(); if (stream == NULL) return NULL; #ifdef YP while ((g = __grpread_noyp(stream, info)) != NULL) if (!strcmp(g->gr_name, name)) break; (void) fclose(stream); if (g == NULL) { char *indomain ; char *outkey = NULL; int r, outkeylen ; g = &((grpread_info *) info)->g ; indomain = __yp_getdomain() ; if (indomain) { r = yp_match(indomain, "group.byname", name, strlen(name), &outkey, &outkeylen) ; switch (r) { case 0: if (__ypparsegrp(g, outkey) != 0) g = NULL ; break ; default: free(outkey) ; outkey = NULL ; g = NULL ; } } else g = NULL ; } #else while ((g = __grpread(stream, info)) != NULL) if (!strcmp(g->gr_name, name)) break; (void) fclose(stream); #endif return(g); } ./libc-linux/grp/grpopen.c100644 1676 334 1753 5154331354 13533 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 /* Return a new stream open on the group file. */ FILE * DEFUN_VOID(__grpopen) { return fopen("/etc/group", "r"); } ./libc-linux/grp/grpread.c100644 1676 334 15543 5511750352 13527 0ustar hjlisl/* LAST EDIT: Wed Mar 31 07:39:35 1993 by Swen Thümmler (swen) */ /* 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 #include #include #include #include #include #ifdef YP #include #include #include extern int __yp_check __P((char **)) ; void __yp_setgrflag __P((void)) ; void __yp_cleargrflag __P((void)) ; int __yp_getgrmode __P((void)) ; int __ypparsegrp __P((struct group *, char *)) ; struct group * DEFUN(__grpread_noyp, (stream, p), FILE *stream AND PTR CONST g) ; static char *__ypcurrent = NULL ; static char *__ypdomain = NULL ; static int __ypcurrentlen = 0 ; static int __ypmode = 0 ; static int __noyp = 0 ; static char line[1024] ; void __yp_setgrflag(void) { __ypmode = 1 ; } void __yp_cleargrflag(void) { __ypmode = 0 ; __ypcurrent = NULL ; } int __yp_getgrmode(void) { return(__ypmode) ; } int __ypparsegrp(struct group *gr, char *s) { char *start, *end ; char **members ; int i, max_members = 5 ; start = s; end = strchr(start, ':'); if (end == NULL) return (-1) ; *end = 0 ; gr->gr_name = start ; start = end + 1 ; end = strchr(start, ':'); if (end == NULL) return (-1) ; *end = 0 ; gr->gr_passwd = start ; start = end + 1 ; end = strchr(start, ':'); if (end == NULL) return (-1) ; *end = 0 ; gr->gr_gid = atoi(start); start = end + 1 ; members = (char **) malloc (max_members * sizeof(char *)) ; if (members == NULL) return (-1) ; i = 0 ; do { start = end + 1; end = strchr (start, ','); if (end == NULL) { end = strchr (start, '\n'); if (end == start) break; if (NULL != end) { *end = '\0'; end = NULL; } } else *end = '\0'; if (i == max_members - 2) { max_members += 5; members = (char **) realloc ((PTR) members, max_members * sizeof (char *)); if (members == NULL) return (-1); } members[i++] = start; } while (end != NULL); members[i] = NULL; gr->gr_mem = members; return 0; } static int DEFUN(__yp_getline, (buf, buflen), char **buf AND size_t *buflen) { char *key, *data; int keylen, datalen; int r; if(!__ypdomain) { if( __yp_check(&__ypdomain) == 0) return(-1); } if(__ypcurrent) { r = yp_next(__ypdomain, "group.byname", __ypcurrent, __ypcurrentlen, &key, &keylen, &data, &datalen); free(__ypcurrent); __ypcurrent = NULL; /*printf("yp_next %d\n", r);*/ switch(r) { case 0: break; default: __ypcurrent = NULL; __ypmode = 0; free(data); data = NULL; return(-1); } __ypcurrent = key; __ypcurrentlen = keylen; bcopy(data, line, datalen); free(data); data = NULL; } else { r = yp_first(__ypdomain, "group.byname", &__ypcurrent, &__ypcurrentlen, &data, &datalen); /*printf("yp_first %d\n", r);*/ switch(r) { case 0: break; default: __ypmode = 0; free(data); return(-1); } bcopy(data, line, datalen); free(data); data = NULL; } line[datalen] = '\0'; /*printf("line = %s\n", line);*/ *buf = line; *buflen = datalen; return(0); } #endif /* YP */ /* This is the function that all the others are based on. The format of the group file is known only here. */ /* Structure containing info kept by each __grpread caller. */ typedef struct { char *buf; size_t buflen; size_t max_members; char **members; struct group g; } grpread_info; /* Return a chunk of memory containing a pre-initialized `grpread_info'. */ PTR DEFUN_VOID(__grpalloc) { grpread_info *info = (PTR) malloc (sizeof(grpread_info)); if (info == NULL) return NULL; info->buf = NULL; info->buflen = 0; info->max_members = 5; info->members = (char **) malloc (5 * sizeof(char *)); if (info->members == NULL) { free ((PTR) info); return NULL; } return info; } /* Read a group entry from STREAM, filling in G. */ struct group * DEFUN(__grpread, (stream, g), FILE *stream AND PTR CONST g) { register grpread_info *CONST info = (grpread_info *) g; char *start, *end; register size_t i; /* Idiocy checks. */ if (stream == NULL) { errno = EINVAL; return NULL; } again: do #ifdef YP if (__ypmode) { if (__yp_getline (&info->buf, &info->buflen) == -1) return NULL; } else #endif /* YP */ if (__getline (&info->buf, &info->buflen, stream) == -1) return NULL; while (info->buf[0] == '#'); start = info->buf; end = strchr (start, ':'); if (end == NULL) return NULL; *end = '\0'; info->g.gr_name = start; start = end + 1; end = strchr (start, ':'); if (end == NULL) return NULL; *end = '\0'; info->g.gr_passwd = start; info->g.gr_gid = (gid_t) strtol (end + 1, &end, 10); if (*end != ':') return NULL; #ifdef YP if ((__noyp != 1) && (strcmp(info->g.gr_name,"+") == 0)) { __ypmode = 1; goto again; } #endif /* YP */ i = 0; do { start = end + 1; end = strchr (start, ','); if (end == NULL) { #ifdef YP if(! __ypmode) { end = strchr (start, '\n'); if (end == start) break; if (end == NULL) return NULL; *end = '\0'; end = NULL; } #else end = strchr (start, '\n'); if (end == start) break; if (end == NULL) return NULL; *end = '\0'; end = NULL; #endif /* YP */ } else *end = '\0'; if (i == info->max_members - 2) { info->max_members += 5; info->members = (char **) realloc ((PTR) info->members, info->max_members * sizeof (char *)); if (info->members == NULL) return NULL; } info->members[i++] = start; } while (end != NULL); info->members[i] = NULL; info->g.gr_mem = info->members; return &info->g; } #ifdef YP struct group * DEFUN(__grpread_noyp, (stream, p), FILE *stream AND PTR CONST g) { struct group *grptr ; __noyp = 1 ; __ypmode = 0 ; grptr = __grpread(stream, g); __noyp = 0 ; return(grptr) ; } #endif ./libc-linux/grp/initgroups.c100644 1676 334 3573 5420342324 14261 0ustar hjlisl/* Copyright (C) 1989, 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 #include #include #include /* Initialize the group set for the current user by reading the group database and using all groups of which USER is a member. Also include GROUP. */ int DEFUN(initgroups, (user, group), CONST char *user AND gid_t group) { #ifdef NGROUPS_MAX #if NGROUPS_MAX == 0 return 0; #else static PTR info = NULL; register FILE *stream; register struct group *g; gid_t groups[NGROUPS_MAX]; register size_t n; if (info == NULL) { info = __grpalloc(); if (info == NULL) return -1; } stream = __grpopen(); if (stream == NULL) return -1; n = 0; groups[n++] = group; while (n < NGROUPS_MAX && (g = __grpread(stream, info)) != NULL) if (g->gr_gid != group) { register char **m; for (m = g->gr_mem; *m != NULL; ++m) if (!strcmp(*m, user)) groups[n++] = g->gr_gid; } (void) fclose (stream); return setgroups(n, groups); #endif #else return 0; #endif } ./libc-linux/grp/gshadow.c100644 1676 334 10057 5475455334 13545 0ustar hjlisl/* * Copyright 1990, 1991, John F. Haugh II * All rights reserved. * * Permission is granted to copy and create derivative works for any * non-commercial purpose, provided this copyright notice is preserved * in all copies of source code, or included in human readable form * and conspicuously displayed on all copies of object code or * distribution media. */ #include #include #include #include #include #if 0 static char sccsid[] = "@(#)gshadow.c 3.7 08:45:58 9/12/91"; #endif #define MAXMEM 1024 #define MAXBUF (BUFSIZ + MAXMEM * 9 + 1) static FILE *shadow; static char *sgrbuf = NULL; static char **members; static char **admins; static struct sgrp sgroup; #define FIELDS 4 static void DEFUN_VOID(initmem) { if (sgrbuf) return; sgrbuf = (char *) malloc (MAXBUF); members = (char **) malloc (sizeof(char *) * (MAXMEM + 1)); admins = (char **) malloc (sizeof(char *) * (MAXMEM + 1)); } static char * DEFUN(fgetsx, (buf, cnt, f), char *buf AND int cnt AND FILE *f) { char *cp = buf; char *ep; while (cnt > 0) { if (!fgets (cp, cnt, f)) if (cp == buf) return NULL; else break; if ((ep = strrchr (cp, '\\')) && *(ep + 1) == '\n') { if ((cnt -= ep - cp) > 0) *(cp = ep) = '\0'; } else break; } return buf; } static int DEFUN(fputsx, (s, stream), char *s AND FILE *stream) { int i; for (i = 0; *s; i++, s++) { if (putc (*s, stream) == EOF) return EOF; if (i > BUFSIZ / 2) { if (putc ('\\', stream) == EOF || putc ('\n', stream) == EOF) return EOF; i = 0; } } return 0; } static char ** DEFUN(list, (s, l), char *s AND char **l) { int nmembers = 0; while (s && *s) { l[nmembers++] = s; if ((s = strchr (s, ','))) *s++ = '\0'; } l[nmembers] = (char *) 0; return l; } void DEFUN_VOID(setsgent) { if (shadow) rewind (shadow); else shadow = fopen (GSHADOW, "r"); } void DEFUN_VOID(endsgent) { if (shadow) fclose (shadow); else shadow = NULL; } struct sgrp * DEFUN(sgetsgent, (string), CONST char *string) { char *fields[FIELDS]; char *cp; int i; initmem(); strncpy (sgrbuf, string, MAXBUF); sgrbuf[MAXBUF] = '\0'; if ((cp = strrchr (sgrbuf, '\n'))) *cp = '\0'; for (cp = sgrbuf, i = 0; i < FIELDS && cp; i++) { fields[i] = cp; if ((cp = strchr (cp, ':'))) *cp++ = '\0'; } if ((cp && *cp) || i != FIELDS) return NULL; sgroup.sg_name = fields[0]; sgroup.sg_passwd = fields[1]; sgroup.sg_adm = list (fields[2], admins); sgroup.sg_mem = list (fields[3], members); return &sgroup; } struct sgrp * DEFUN(fgetsgent, (fp), FILE *fp) { char buf[sizeof sgrbuf]; if (!fp) return NULL; if (fgetsx (buf, sizeof buf, fp)) return NULL; return sgetsgent (buf); } struct sgrp * DEFUN_VOID(getsgent) { if (!shadow) setsgent (); return fgetsgent (shadow); } struct sgrp * DEFUN(getsgnam, (name), CONST char *name) { struct sgrp *sgrp; setsgent (); while ((sgrp = getsgent ())) { if (strcmp (name, sgrp->sg_name) == 0) return (sgrp); } return NULL; } int DEFUN(putsgent, (sgrp, fp), CONST struct sgrp *sgrp AND FILE *fp) { char buf[sizeof sgrbuf]; char *cp = buf; int i; if (!fp || !sgrp) return -1; /* * Copy the group name and passwd. */ strcpy (cp, sgrp->sg_name); cp += strlen (cp); *cp++ = ':'; strcpy (cp, sgrp->sg_passwd); cp += strlen (cp); *cp++ = ':'; /* * Copy the administrators, separating each from the other * with a ",". */ for (i = 0; sgrp->sg_adm[i]; i++) { if (i > 0) *cp++ = ','; strcpy (cp, sgrp->sg_adm[i]); cp += strlen (cp); } *cp++ = ':'; /* * Now do likewise with the group members. */ for (i = 0; sgrp->sg_mem[i]; i++) { if (i > 0) *cp++ = ','; strcpy (cp, sgrp->sg_mem[i]); cp += strlen (cp); } *cp++ = '\n'; *cp = '\0'; /* * Output using the function which understands the line * continuation conventions. */ return fputsx (buf, fp); } ./libc-linux/setjmp/ 40755 1676 334 0 5550054367 12332 5ustar hjlisl./libc-linux/setjmp/Makefile100644 1676 334 503 5515544452 14045 0ustar hjlisl# # Makefile for some misc functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules DIRS:= SRC1S= siglongjmp.c sigjmp.c _setjmp.c SRC2S= _longjmp.c longjmp.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/setjmp/_longjmp.c100644 1676 334 2037 5362365342 14401 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. */ #define _BSD_SOURCE #include #include #include #undef _longjmp function_alias_void(_longjmp, siglongjmp, (env, val), DEFUN(_longjmp, (env, val), CONST jmp_buf env AND int val)) ./libc-linux/setjmp/_setjmp.c100644 1676 334 1756 5362365342 14244 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. */ #define _BSD_SOURCE #include #include #include #undef _setjmp int DEFUN(_setjmp, (env), jmp_buf env) { return sigsetjmp (env, 0); } ./libc-linux/setjmp/longjmp.c100644 1676 334 2006 5362365342 14236 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 #undef longjmp function_alias_void(longjmp, __longjmp, (env, val), DEFUN(longjmp, (env, val), CONST jmp_buf env AND int val)) ./libc-linux/setjmp/__sj_save.c100644 1676 334 2163 5465534243 14526 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 #include #include #include void DEFUN(__sigjmp_save, (env, savemask), sigjmp_buf env AND int savemask) { if (savemask) env[0].__savemask = sigprocmask (SIG_BLOCK, (sigset_t *) NULL, &env[0].__sigmask) == 0; else env[0].__savemask = 0; } ./libc-linux/setjmp/siglongjmp.c100644 1676 334 2430 5465555200 14740 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 #include /* Set the signal mask to the one specified in ENV, and jump to the position specified in ENV, causing the sigsetjmp call there to return VAL, or 1 if VAL is 0. */ void DEFUN(siglongjmp, (env, val), CONST sigjmp_buf env AND int val) { if (env[0].__mask_was_saved) (void) sigprocmask (SIG_SETMASK, &env[0].__saved_mask, (sigset_t *) NULL); longjmp (env[0].__jmpbuf, val); } ./libc-linux/setjmp/tst-setjmp.c100644 1676 334 2773 5362365344 14717 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 #include static jmp_buf env; static int last_value = -1, lose = 0; void DEFUN(jump, (val), int val) { longjmp(env, val); } int DEFUN_VOID(main) { int value; value = setjmp(env); if (value != last_value + 1) { fputs("Shouldn't have ", stdout); lose = 1; } last_value = value; switch (value) { case 0: puts("Saved environment."); jump(0); default: printf("Jumped to %d.\n", value); if (value < 10) jump(value + 1); } if (lose || value != 10) puts("Test FAILED!"); else puts("Test succeeded!"); exit(lose ? EXIT_FAILURE : EXIT_SUCCESS); } ./libc-linux/setjmp/sigjmp.c100644 1676 334 2306 5424361255 14062 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 #include #include #include /* This function is called by the `sigsetjmp' macro before doing a `__setjmp' on ENV[0].__jmpbuf. */ void DEFUN(__sigjmp_save, (env, savemask), sigjmp_buf env AND int savemask) { env[0].__mask_was_saved = (savemask && sigprocmask (SIG_BLOCK, (sigset_t *) NULL, &env[0].__saved_mask) == 0); } ./libc-linux/locale/ 40755 1676 334 0 5550053107 12256 5ustar hjlisl./libc-linux/locale/Makefile100644 1676 334 711 5516307135 13777 0ustar hjlisl# # Makefile for locale functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules VSCFLAGS= -DUSE_ISO_8859_1 INC_CLAGS= -I. BASE_CFLAGS := $(BASE_CFLAGS) $(VSCFLAGS) DIRS:= SRCS = C-collate.c C-ctype.c C-ctype_ct.c C-ctype_mb.c \ C-monetary.c C-numeric.c C-response.c C-time.c setlocale.c \ localeconv.c ISO88591-ctype.c ISO88591_ct.c ISO88591_mb.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/locale/C-collate.c100644 1676 334 276 5266732372 14323 0ustar hjlisl#include #include #include CONST struct collate_info __collate_C = { 0, NULL, NULL, NULL }; CONST struct collate_info *_collate_info = &__collate_C; ./libc-linux/locale/C-ctype.c100644 1676 334 565 5266732372 14025 0ustar hjlisl#include #include #include extern CONST struct ctype_ctype_info __ctype_ctype_C; extern CONST struct ctype_mbchar_info __ctype_mbchar_C; CONST struct ctype_info __ctype_C = { (struct ctype_ctype_info*)&__ctype_ctype_C, (struct ctype_mbchar_info*) &__ctype_mbchar_C }; CONST struct ctype_info *_ctype_info = &__ctype_C; ./libc-linux/locale/C-ctype_ct.c100644 1676 334 23163 5475451774 14560 0ustar hjlisl#include #include #include #include CONST unsigned short int __ctype_b_C[] = { 0, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl|_ISspace|_ISblank, _IScntrl|_ISspace, _IScntrl|_ISspace, _IScntrl|_ISspace, _IScntrl|_ISspace, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _ISspace|_NOgraph|_ISblank, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISupper|_IShex, _ISupper|_IShex, _ISupper|_IShex, _ISupper|_IShex, _ISupper|_IShex, _ISupper|_IShex, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISlower|_IShex, _ISlower|_IShex, _ISlower|_IShex, _ISlower|_IShex, _ISlower|_IShex, _ISlower|_IShex, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, }; CONST unsigned char __ctype_tolower_C[] = { '\377', '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', '\040', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '\177', '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', }; CONST unsigned char __ctype_toupper_C[] = { '\377', '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', '\040', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', '\177', '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', }; CONST struct ctype_ctype_info __ctype_ctype_C = { (unsigned short int *) __ctype_b_C, (unsigned char *) __ctype_tolower_C, (unsigned char *) __ctype_toupper_C }; ./libc-linux/locale/C-ctype_mb.c100644 1676 334 213 5266732372 14471 0ustar hjlisl#include #include #include CONST struct ctype_mbchar_info __ctype_mbchar_C = { 0, NULL }; ./libc-linux/locale/C-monetary.c100644 1676 334 616 5266732372 14534 0ustar hjlisl#include #include #include CONST struct monetary_info __monetary_C = { (char *) "", (char *) "", (char *) "", (char *) "", (char *) "", (char *) "", (char *) "", CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX }; CONST struct monetary_info *_monetary_info = &__monetary_C; ./libc-linux/locale/C-numeric.c100644 1676 334 336 5266732372 14337 0ustar hjlisl#include #include #include CONST struct numeric_info __numeric_C = { (char *) ".", (char *) "", (char *) "" }; CONST struct numeric_info *_numeric_info = &__numeric_C; ./libc-linux/locale/C-response.c100644 1676 334 363 5266732372 14533 0ustar hjlisl#include #include #include CONST struct response_info __response_C = { (char *) "[yY][[:alpha:]]", (char *) "[nN][[:alpha:]]" }; CONST struct response_info *_response_info = &__response_C; ./libc-linux/locale/C-time.c100644 1676 334 2146 5266732372 13654 0ustar hjlisl/* Built-in time information for `C' locale, generated Thu Jan 1 00:00:00 1970 by li2c. */ #include #include #include CONST struct time_info __time_C = { { (char *) "Sun", (char *) "Mon", (char *) "Tue", (char *) "Wed", (char *) "Thu", (char *) "Fri", (char *) "Sat", }, { (char *) "Sunday", (char *) "Monday", (char *) "Tuesday", (char *) "Wednesday", (char *) "Thursday", (char *) "Friday", (char *) "Saturday", }, { (char *) "Jan", (char *) "Feb", (char *) "Mar", (char *) "Apr", (char *) "May", (char *) "Jun", (char *) "Jul", (char *) "Aug", (char *) "Sep", (char *) "Oct", (char *) "Nov", (char *) "Dec", }, { (char *) "January", (char *) "February", (char *) "March", (char *) "April", (char *) "May", (char *) "June", (char *) "July", (char *) "August", (char *) "September", (char *) "October", (char *) "November", (char *) "December", }, { (char *) "AM", (char *) "PM" }, (char *) "%a %b %d %H:%M:%S %Y", (char *) "%m/%d/%y", (char *) "%H:%M:%S", (char *) "GMT", (char *) "" }; CONST struct time_info *_time_info = &__time_C; ./libc-linux/locale/collate/ 40755 1676 334 0 5547123030 13700 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/localeconv.c100644 1676 334 4107 5266732174 14662 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 General Public License as published by the Free Software Foundation; either version 1, 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 General Public License for more details. You should have received a copy of the GNU General Public License along with the GNU C Library; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include /* Return monetary and numeric information about the current locale. */ struct lconv * DEFUN_VOID(localeconv) { static struct lconv result; result.decimal_point = (char *) _numeric_info->decimal_point; result.thousands_sep = (char *) _numeric_info->thousands_sep; result.grouping = (char *) _numeric_info->grouping; result.int_curr_symbol = (char *) _monetary_info->int_curr_symbol; result.currency_symbol = (char *) _monetary_info->currency_symbol; result.mon_decimal_point = (char *) _monetary_info->mon_decimal_point; result.mon_thousands_sep = (char *) _monetary_info->mon_thousands_sep; result.mon_grouping = (char *) _monetary_info->mon_grouping; result.positive_sign = (char *) _monetary_info->positive_sign; result.negative_sign = (char *) _monetary_info->negative_sign; result.int_frac_digits = _monetary_info->int_frac_digits; result.frac_digits = _monetary_info->frac_digits; result.p_cs_precedes = _monetary_info->p_cs_precedes; result.p_sep_by_space = _monetary_info->p_sep_by_space; result.n_cs_precedes = _monetary_info->p_cs_precedes; result.n_sep_by_space = _monetary_info->n_sep_by_space; result.p_sign_posn = _monetary_info->p_sign_posn; result.n_sign_posn = _monetary_info->n_sign_posn; return &result; } ./libc-linux/locale/ISO88591_ct.c100644 1676 334 23300 5475452246 14311 0ustar hjlisl#include #include #include #include CONST unsigned short int __ctype_b_ISO_8859_1 [] = { 0, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl|_ISspace|_ISblank, _IScntrl|_ISspace, _IScntrl|_ISspace, _IScntrl|_ISspace, _IScntrl|_ISspace, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _ISspace|_NOgraph|_ISblank, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISdigit|_IShex, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISupper|_IShex, _ISupper|_IShex, _ISupper|_IShex, _ISupper|_IShex, _ISupper|_IShex, _ISupper|_IShex, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISlower|_IShex, _ISlower|_IShex, _ISlower|_IShex, _ISlower|_IShex, _ISlower|_IShex, _ISlower|_IShex, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _IScntrl, _ISspace|_ISblank, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISpunct, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISupper, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, _ISlower, }; CONST unsigned char __ctype_tolower_ISO_8859_1 [] = { '\377', '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', '\040', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '\177', '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337', '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', }; CONST unsigned char __ctype_toupper_ISO_8859_1 [] = { '\377', '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', '\040', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', '\177', '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\377', }; CONST struct ctype_ctype_info __ctype_ctype_ISO_8859_1 = { (unsigned short int *) __ctype_b_ISO_8859_1, (unsigned char *) __ctype_tolower_ISO_8859_1, (unsigned char *) __ctype_toupper_ISO_8859_1 }; ./libc-linux/locale/ISO88591_mb.c100644 1676 334 224 5431575407 14236 0ustar hjlisl#include #include #include CONST struct ctype_mbchar_info __ctype_mbchar_ISO_8859_1 = { 0, NULL }; ./libc-linux/locale/ISO88591-ctype.c100644 1676 334 670 5443354164 14705 0ustar hjlisl#include #include #include extern CONST struct ctype_ctype_info __ctype_ctype_ISO_8859_1; extern CONST struct ctype_mbchar_info __ctype_mbchar_ISO_8859_1; CONST struct ctype_info __ctype_ISO_8859_1 = { (struct ctype_ctype_info*)&__ctype_ctype_ISO_8859_1, (struct ctype_mbchar_info*) &__ctype_mbchar_ISO_8859_1 }; #if 0 CONST struct ctype_info *_ctype_info = &__ctype_ISO_8859_1; #endif ./libc-linux/locale/check.c100644 1676 334 2465 5501737303 13606 0ustar hjlisl#include #include main () { printf("**********************No environs set***************************\n"); checkit(); printf("\n"); /* Set up LC_CTYPE to ISO-8859-1 and try again */ printf("******************LC_CTYPE environ set to ISO-8859-1*************\n"); setenv ("LC_CTYPE","ISO-8859-1"); checkit(); printf("\n"); /* Set up LC_CTYPE to ISO-8859-1 and try again */ printf("********************LANG environ set to ISO-8859-1***************\n"); unsetenv ("LC_CTYPE"); setenv ("LANG","ISO-8859-1"); checkit(); printf("\n"); /* Now Switch locales */ printf("********************Switching locales back to C******************\n"); unsetenv ("LANG"); setenv ("LC_CTYPE","C"); checkit(); printf("\n"); catclose(catopen("foo",1)); } checkit() { /* Set up according to environment vars */ printf("setlocale(LC_ALL,\"\") returned %s\n",setlocale(LC_ALL,"")); /* Set up al to C locale */ printf("setlocale(LC_ALL,\"C\") returned %s\n",setlocale(LC_ALL,"C")); /* Error no such locale */ printf("setlocale(LC_ALL,\"ISO\") returned %s\n",setlocale(LC_ALL,"ISO")); /* Set up LC_CTYPE according to environment var */ printf("setlocale(LC_CTYPE,\"\") returned %s\n",setlocale(LC_CTYPE,"")); /* Get current Locale */ printf("setlocale(LC_MESSAGES,(char *)0) returned %s\n",setlocale(LC_MESSAGES,(char *)NULL)); } ./libc-linux/locale/setlocale.c.saved100644 1676 334 11736 5510676244 15634 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 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 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; #endif /* 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) */ static struct message_struct { int category; CONST char *name;} ms[]= { { LC_COLLATE, "LC_COLLATE" }, { LC_CTYPE, "LC_CTYPE" }, { LC_MONETARY, "LC_MONETARY" }, { LC_NUMERIC, "LC_NUMERIC" }, { LC_TIME, "LC_TIME" }, { LC_RESPONSE, "LC_RESPONSE" }, { LC_MESSAGES, "LC_MESSAGES" }, /* * New categories go in between here. */ { LC_ALL, "LC_ALL" } }; char *ptr=NULL; int i; /* The default locale is C. */ static CONST char * current_locale = "C"; /* If not a valid category */ if (category & ~LC_ALL) return (char *) NULL; /* Return the current locale. */ if (name == NULL) return (char *) current_locale; for (i=0; i < sizeof(ms)/sizeof(struct message_struct)-1; i++) { if (category & ms[i].category) { /* If "" is given as the locale then we check environment vars */ if ( *name == (char) NULL) { if ((ptr=getenv(ms[i].name)) == NULL) { if (category == LC_ALL) { continue; } else { if ((name=getenv("LANG")) == NULL) { if ((name=getenv("LC_default"))==NULL) name="C"; } } } else { name = ptr; } } /* For POSIX or if the locale is the same as the current we do nothing. */ if (!strcmp(name, "POSIX") || !strcmp(name, current_locale)) continue; if (strcmp(name, "C") && strcmp(name, "ISO-8859-1")) { /* Not a vaild locale so return immediately */ errno = EINVAL; return NULL; } current_locale = name; switch (category & ms[i].category) { case LC_COLLATE: /* Not yet implemented */ break; case LC_CTYPE: /* Change locale */ /* For C, we use the C char set. */ if (!strcmp(name, "C")) { __ctype_b = __ctype_b_C + 1; __ctype_tolower = __ctype_tolower_C + 1; __ctype_toupper = __ctype_toupper_C + 1; _ctype_info = &__ctype_C; } else { /* For ISO-8859-1, we use the ISO-8859-1 char set. */ if (!strcmp(name, "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; } } break; case LC_MONETARY: /* Not yet implemented */ break; case LC_NUMERIC: /* Not yet implemented */ break; case LC_TIME: /* Not yet implemented */ break; case LC_RESPONSE: /* Not yet implemented */ break; case LC_MESSAGES: /* Nothing needs to be done */ break; } } } /* If we were invoked as setlocale(LC_ALL,"") and we haven't returned NULL for any invalid categories by now then we can return the current locale */ if (category == LC_ALL) return (char *) current_locale; /* If we haven't returned NULL by now, then we are fine */ return (char *) name; #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 } ./libc-linux/locale/ctype/ 40755 1676 334 0 5547123031 13402 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 5547123032 14115 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 5547123033 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 5547123033 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/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/time/ 40755 1676 334 0 5547123034 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/login/ 40755 1676 334 0 5550053150 12125 5ustar hjlisl./libc-linux/login/Makefile100644 1676 334 367 5515544120 13653 0ustar hjlisl# # Makefile for login functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS= -I. DIRS:= SRCS = getlogin.c getpass.c utmp2.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/login/pathnames.h100644 1676 334 3020 5147071042 14350 0ustar hjlisl/* * Copyright (c) 1989 The 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * @(#)pathnames.h 5.3 (Berkeley) 5/9/89 */ #define _PATH_BSHELL "/bin/sh" #define _PATH_CSHELL "/bin/csh" #define UT_NAMESIZE 8 #define _PATH_TTY "/dev/tty" #define TTYTYPES "/etc/ttytype" #define SECURETTY "/etc/securetty" #define _PATH_UTMP "/etc/utmp" #define _PATH_WTMP "/etc/wtmp" #define _PATH_DEFPATH "/usr/local/bin:/bin:/usr/bin:." #define _PATH_DEFPATH_ROOT "/bin:/usr/bin:/etc" #define _PATH_HUSHLOGIN ".hushlogin" #define _PATH_LASTLOG "/usr/adm/lastlog" #define _PATH_MAILDIR "/var/spool/mail" #define _PATH_MOTDFILE "/etc/motd" #define _PATH_NOLOGIN "/etc/nologin" #define _PATH_LOGIN "/bin/login" #define _PATH_INITTAB "/etc/inittab" #define _PATH_RC "/etc/rc" ./libc-linux/login/getpass.c100644 1676 334 1556 5341253435 14051 0ustar hjlisl#include #include #include #include #include #define TTY "/dev/tty" /* Issue prompt and read reply with echo turned off */ char *getpass(const char * prompt) { struct termios ttyb,ttysav; char *cp; int c; FILE *tty; static char pbuf[128]; if ((tty = fdopen(open(TTY, O_RDWR), "r")) == NULL) tty = stdin; else setbuf(tty, (char *)NULL); ioctl(fileno(tty), TCGETS, &ttyb); ioctl(fileno(tty), TCGETS, &ttysav); ttyb.c_lflag &= ~(ECHO|ISIG); ioctl(fileno(tty), TCSETS, &ttyb); fprintf(stderr, "%s", prompt); fflush(stderr); cp = pbuf; for (;;) { c = getc(tty); if(c == '\r' || c == '\n' || c == EOF) break; if (cp < &pbuf[127]) *cp++ = c; } *cp = '\0'; fprintf(stderr,"\r\n"); fflush(stderr); ioctl(fileno(tty), TCSETS, &ttysav); if (tty != stdin) fclose(tty); return(pbuf); } ./libc-linux/login/utmp2.c100644 1676 334 6405 5272347216 13454 0ustar hjlisl/* utmp2.c for Linux, by poe@daimi.aau.dk */ /* This code is freely distributable and is covered by the GNU copyleft */ /* This implementation of the utmp and wtmp routines, is supposed to conform to the XPG2 and SVID2 standards */ #include "utmp.h" #include #include #include #include static char Utname[40] = {'/','e','t','c','/','u','t','m','p',0}; static int Fd = -1; static struct utmp Ut; /* kludge for the benefit of getutent() whose semantics differs from the other get..() functions. When set, getutent() will not read the next entry in utmp, but immediatly returns &Ut, and resets the flag. */ static int _getutent_flag = 0; static int _setutent(void) { if(Fd != -1) close(Fd); /* first try to get write permission, if that fails then make do with read access */ if((Fd = open(Utname, O_RDWR)) < 0) { if((Fd = open(Utname, O_RDONLY)) < 0) { perror("_setutent: Can't open utmp file"); Fd = -1; return 0; } } if(read(Fd, (char *)&Ut, sizeof(Ut)) != sizeof(Ut)) return 0; return 1; } void setutent(void) { (void)_setutent(); _getutent_flag = 1; } void utmpname(const char *name) { (void)strncpy(Utname, name, sizeof(Utname)-1); if(Fd != -1) close(Fd); Fd = -1; } /* always get the logical *next* entry from the utmp file */ struct utmp *getutent(void) { if(Fd == -1) { if(!_setutent()) return (struct utmp *)0; else { _getutent_flag = 0; return &Ut; } } if(_getutent_flag) { /* well, setutent() really got it for us */ _getutent_flag = 0; return &Ut; } if(read(Fd, (char *)&Ut, sizeof(Ut)) != sizeof(Ut)) return (struct utmp *)0; else return &Ut; } struct utmp *getutid(struct utmp *ut) { if(Fd == -1) if(!_setutent()) return (struct utmp *)0; do { if(RUN_LVL <= ut->ut_type && ut->ut_type <= OLD_TIME && Ut.ut_type == ut->ut_type) return &Ut; if(INIT_PROCESS <= ut->ut_type && ut->ut_type <= DEAD_PROCESS && !strncmp(Ut.ut_id, ut->ut_id, sizeof(Ut.ut_id))) return &Ut; } while(read(Fd, (char *)&Ut, sizeof(Ut)) == sizeof(Ut)); return (struct utmp *)0; } struct utmp *getutline(struct utmp *ut) { if(Fd == -1) if(!_setutent()) return (struct utmp *)0; do { if((Ut.ut_type == USER_PROCESS || Ut.ut_type == LOGIN_PROCESS) && !strncmp(Ut.ut_line, ut->ut_line, sizeof(Ut.ut_line))) return &Ut; } while(read(Fd, (char *)&Ut, sizeof(Ut)) == sizeof(Ut)); return (struct utmp *)0; } struct utmp *_pututline(struct utmp *ut) { struct utmp my_ut; /* don't stomp on the new value even if it's in Ut */ if(ut == &Ut) { (void)memcpy(&my_ut, &Ut, sizeof(Ut)); ut = &my_ut; } /* we don't check Fd here, getutid() does it for us; this way we can create an utmp file from an empty file, if it should get lost. */ if(getutid(ut)) { (void)lseek(Fd, (off_t)-sizeof(Ut), SEEK_CUR); if(write(Fd, (char *)ut, sizeof(Ut)) != sizeof(Ut)) return (struct utmp *)0; } else { (void)lseek(Fd, (off_t)0, SEEK_END); if(write(Fd, (char *)ut, sizeof(Ut)) != sizeof(Ut)) return (struct utmp *)0; } /* if we get this far, we are successful */ if(ut == &my_ut) (void)memcpy(&Ut, &my_ut, sizeof(Ut)); return &Ut; } void pututline(struct utmp *ut) { (void)_pututline(ut); } void endutent(void) { if(Fd != -1) close(Fd); Fd = -1; } ./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/login/param.h100644 1676 334 377 5146322511 13463 0ustar hjlisl#ifndef _SYS_PARAM_H #define _SYS_PARAM_H #include #define HZ 100 #define EXEC_PAGESIZE 4096 #define getdtablesize() (NR_OPEN-1) #define NGROUPS 32 /* Max number of groups per user */ #define NOGROUP -1 #define MAXHOSTNAMELEN 8 #endif ./libc-linux/malloc/ 40755 1676 334 0 5550053177 12275 5ustar hjlisl./libc-linux/malloc/ChangeLog100644 1676 334 2027 5505465421 14144 0ustar hjlislThu Jul 11 18:15:04 1991 Roland McGrath (roland@churchy.gnu.ai.mit.edu) * Merged with C library version, which now has its own subdir. * malloc.h, *.c: Use ansideclisms and #ifdefs for portability both in and out of the C library. * Makefile: New makefile for malloc subdir in libc. Has targets to create malloc.tar{,.Z} by ansidecl processing on srcs. * malloc/Makefile: New file; Makefile for standalone distribution. * malloc/README: New file; info for same. Fri Apr 6 00:18:36 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) * Makefile: Add comments. Thu Apr 5 23:08:14 1990 Mike Haertel (mike at albert.ai.mit.edu) * mcheck.c (mcheck, checkhdr): Support user-supplied abort() function. * malloc.h: Declare __free(). * Makefile: New target libmalloc.a. Thu Apr 5 21:56:03 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) * free.c (free): Split into free and __free. * malloc.c (morecore): Call __free on oldinfo. Local Variables: mode: indented-text left-margin: 8 fill-column: 76 version-control: never End: ./libc-linux/malloc/Makefile100644 1676 334 1726 5526033524 14035 0ustar hjlisl# # Makefile for malloc library functions # override STATIC=false override SHARED=false override STATIC_SHARED=false override PROFILE=false TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules LIBMCHECK=$(TOPDIR)/debug/libmcheck.a LIBMCHECK_SRCS=mcheck-init.c LIBMCHECK_OBJS=$(addprefix $(DEBUG_DIR)/$(SUBDIR)/, $(LIBMCHECK_SRCS:.c=.o)) INC_CFLAGS= -I. -I. -I. VSCFLAGS=-D_default_morecore=__default_morecore \ -D__MALLOC_0_RETURNS_NULL -D_morecore=__morecore BASE_CFLAGS:= $(BASE_CFLAGS) $(VSCFLAGS) DIRS:= SRC1S = malloc.c free.c realloc.c calloc.c \ valloc.c memalign.c mstats.c mtrace.c mcheck.c SRC2S = cfree.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRCS:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ifeq ($(DEBUG),true) ifeq ($(SPEED),fast) .PHONY: $(LIBMCHECK) lib:: $(LIBMCHECK_OBJS) # $(LIBMCHECK) $(LIBMCHECK): $(LIBMCHECK_OBJS) $(AR) uvc $(LIBMCHECK) $? else lib:: $(LIBMCHECK)($(LIBMCHECK_OBJS)) endif endif ./libc-linux/malloc/TODO100644 1676 334 2404 5505465421 13061 0ustar hjlisl0. Access data structures with accessor macros, then turn the heapinfo into several arrays for faster access on machines with addressing modes. Also, this eventually raises the possibility of maintaining multiple heaps. 1. Possible heuristic to catch multiple frees. Introduce an extra word of heapinfo that says whether the remaining info is for something busy or something free. Then we can catch attempts to free already-free large blocks, as well as things not belonging to malloc at all. In the case of a fragment, we can check if the fragment looks like it *already* belongs to the fragment list, by comparing it with the "first" fragment of the block, or checking its "prev" pointer to see if it points into the block. Then if it looks like it might we can exhaustively search the block's free list to see if the fragment is there or not. Extending the heapinfo structure would have the benefit of making it a power of two and thus making array indexing faster, perhaps. Suitably adapted, this heuristic could also catch invalid pointers passed to realloc. All of these additional features require the inclusion of . 3. indirect reference allocator: ialloc(), ifree(), irealloc(). 4. garbage collecting allocator: galloc(), garbage(), gfree(), grealloc(). ./libc-linux/malloc/calloc.c100644 1676 334 2451 5505465421 13774 0ustar hjlisl/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be reached (Email) at the address mike@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include #endif /* Allocate an array of NMEMB elements each SIZE bytes long. The entire array is initialized to zeros. */ __ptr_t calloc (nmemb, size) register size_t nmemb; register size_t size; { register __ptr_t result = malloc (nmemb * size); if (result != NULL) (void) memset (result, 0, nmemb * size); return result; } ./libc-linux/malloc/cfree.c100644 1676 334 1731 5505465421 13623 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 #undef cfree #include function_alias(cfree, free, void, (ptr), DEFUN(cfree, (ptr), PTR ptr)) ./libc-linux/malloc/dist-Makefile100644 1676 334 2767 5505465421 15006 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. # Makefile for standalone distribution of malloc. # Use this on System V. #CPPFLAGS = -DUSG .PHONY: all all: libmalloc.a gmalloc.o sources = objects = headers = libmalloc.a: $(objects) ar crv $@ $(objects) ranlib $@ $(objects): $(headers) gmalloc.c: gmalloc-head.c $(headers) $(sources) cat gmalloc-head.c $(headers) $(sources) > $@ .c.o: $(CC) $(CFLAGS) $(CPPFLAGS) -I. -c $< $(OUTPUT_OPTION) .PHONY: clean realclean malloc-clean malloc-realclean clean malloc-clean: -rm -f libmalloc.a *.o core realclean malloc-realclean: clean -rm -f TAGS tags *~ # For inside the C library. malloc.tar malloc.tar.Z: $(MAKE) -C .. $@ ./libc-linux/malloc/dist-README100644 1676 334 1222 5505465421 14207 0ustar hjlislThis is the standalone distribution of GNU malloc. GNU malloc is part of the GNU C Library, but is also distributed separately. If you find bugs in GNU malloc, send reports to bug-glibc@prep.ai.mit.edu. GNU malloc is free software. See the file COPYING.LIB for copying conditions. The makefile builds libmalloc.a and gmalloc.o. If you are using GNU malloc to replace your system's existing malloc package, it is important to make sure you get all GNU functions, not some of the GNU functions and some from the system library. gmalloc.o has all the functions in one file, so using that will make sure you don't accidentally mix the two malloc packages. ./libc-linux/malloc/free.c100644 1676 334 14576 5505465422 13514 0ustar hjlisl/* Free a block of memory allocated by `malloc'. Copyright 1990, 1991, 1992 Free Software Foundation Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be reached (Email) at the address mike@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include #endif /* Debugging hook for free. */ void (*__free_hook) __P ((__ptr_t __ptr)); /* List of blocks allocated by memalign. */ struct alignlist *_aligned_blocks = NULL; /* Return memory to the heap. Like `free' but don't call a __free_hook if there is one. */ void _free_internal (ptr) __ptr_t ptr; { int type; size_t block, blocks; register size_t i; struct list *prev, *next; block = BLOCK (ptr); type = _heapinfo[block].busy.type; switch (type) { case 0: /* Get as many statistics as early as we can. */ --_chunks_used; _bytes_used -= _heapinfo[block].busy.info.size * BLOCKSIZE; _bytes_free += _heapinfo[block].busy.info.size * BLOCKSIZE; /* Find the free cluster previous to this one in the free list. Start searching at the last block referenced; this may benefit programs with locality of allocation. */ i = _heapindex; if (i > block) while (i > block) i = _heapinfo[i].free.prev; else { do i = _heapinfo[i].free.next; while (i > 0 && i < block); i = _heapinfo[i].free.prev; } /* Determine how to link this block into the free list. */ if (block == i + _heapinfo[i].free.size) { /* Coalesce this block with its predecessor. */ _heapinfo[i].free.size += _heapinfo[block].busy.info.size; block = i; } else { /* Really link this block back into the free list. */ _heapinfo[block].free.size = _heapinfo[block].busy.info.size; _heapinfo[block].free.next = _heapinfo[i].free.next; _heapinfo[block].free.prev = i; _heapinfo[i].free.next = block; _heapinfo[_heapinfo[block].free.next].free.prev = block; ++_chunks_free; } /* Now that the block is linked in, see if we can coalesce it with its successor (by deleting its successor from the list and adding in its size). */ if (block + _heapinfo[block].free.size == _heapinfo[block].free.next) { _heapinfo[block].free.size += _heapinfo[_heapinfo[block].free.next].free.size; _heapinfo[block].free.next = _heapinfo[_heapinfo[block].free.next].free.next; _heapinfo[_heapinfo[block].free.next].free.prev = block; --_chunks_free; } /* Now see if we can return stuff to the system. */ blocks = _heapinfo[block].free.size; if (blocks >= FINAL_FREE_BLOCKS && block + blocks == _heaplimit && (*__morecore) (0) == ADDRESS (block + blocks)) { register size_t bytes = blocks * BLOCKSIZE; _heaplimit -= blocks; (*__morecore) (-bytes); _heapinfo[_heapinfo[block].free.prev].free.next = _heapinfo[block].free.next; _heapinfo[_heapinfo[block].free.next].free.prev = _heapinfo[block].free.prev; block = _heapinfo[block].free.prev; --_chunks_free; _bytes_free -= bytes; } /* Set the next search to begin at this block. */ _heapindex = block; break; default: /* Do some of the statistics. */ --_chunks_used; _bytes_used -= 1 << type; ++_chunks_free; _bytes_free += 1 << type; /* Get the address of the first free fragment in this block. */ prev = (struct list *) ((char *) ADDRESS (block) + (_heapinfo[block].busy.info.frag.first << type)); #if 1 /* Adapted from Mike */ if (_heapinfo[block].busy.info.frag.nfree == (BLOCKSIZE >> type) - 1 && _fragblocks[type] > 1) #else if (_heapinfo[block].busy.info.frag.nfree == (BLOCKSIZE >> type) - 1) #endif { /* If all fragments of this block are free, remove them from the fragment list and free the whole block. */ #if 1 /* Adapted from Mike */ --_fragblocks[type]; #endif next = prev; for (i = 1; i < (size_t) (BLOCKSIZE >> type); ++i) next = next->next; prev->prev->next = next; if (next != NULL) next->prev = prev->prev; _heapinfo[block].busy.type = 0; _heapinfo[block].busy.info.size = 1; /* Keep the statistics accurate. */ ++_chunks_used; _bytes_used += BLOCKSIZE; _chunks_free -= BLOCKSIZE >> type; _bytes_free -= BLOCKSIZE; free (ADDRESS (block)); } else if (_heapinfo[block].busy.info.frag.nfree != 0) { /* If some fragments of this block are free, link this fragment into the fragment list after the first free fragment of this block. */ next = (struct list *) ptr; next->next = prev->next; next->prev = prev; prev->next = next; if (next->next != NULL) next->next->prev = next; ++_heapinfo[block].busy.info.frag.nfree; } else { /* No fragments of this block are free, so link this fragment into the fragment list and announce that it is the first free fragment of this block. */ prev = (struct list *) ptr; _heapinfo[block].busy.info.frag.nfree = 1; _heapinfo[block].busy.info.frag.first = (unsigned long int) ((unsigned long int) ((char *) ptr - (char *) NULL) % BLOCKSIZE >> type); prev->next = _fraghead[type].next; prev->prev = &_fraghead[type]; prev->prev->next = prev; if (prev->next != NULL) prev->next->prev = prev; } break; } } /* Return memory to the heap. */ void free (ptr) __ptr_t ptr; { register struct alignlist *l; if (ptr == NULL) return; for (l = _aligned_blocks; l != NULL; l = l->next) if (l->aligned == ptr) { l->aligned = NULL; /* Mark the slot in the list as free. */ ptr = l->exact; break; } if (__free_hook != NULL) (*__free_hook) (ptr); else _free_internal (ptr); } ./libc-linux/malloc/malloc.c100644 1676 334 22265 5505465422 14034 0ustar hjlisl/* Memory allocator `malloc'. Copyright 1990, 1991, 1992 Free Software Foundation Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be reached (Email) at the address mike@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include #endif /* How to really get more memory. */ __ptr_t (*__morecore) __P ((ptrdiff_t __size)) = __default_morecore; /* Debugging hook for `malloc'. */ __ptr_t (*__malloc_hook) __P ((size_t __size)); /* Pointer to the base of the first block. */ char *_heapbase; /* Block information table. Allocated with align/__free (not malloc/free). */ malloc_info *_heapinfo; /* Number of info entries. */ static size_t heapsize; /* Search index in the info table. */ size_t _heapindex; /* Limit of valid info table indices. */ size_t _heaplimit; #if 1 /* Adapted from Mike */ /* Count of large blocks allocated for each fragment size. */ int _fragblocks[BLOCKLOG]; #endif /* Free lists for each fragment size. */ struct list _fraghead[BLOCKLOG]; /* Instrumentation. */ size_t _chunks_used; size_t _bytes_used; size_t _chunks_free; size_t _bytes_free; /* Are you experienced? */ int __malloc_initialized; /* Aligned allocation. */ static __ptr_t align __P ((size_t)); static __ptr_t align (size) size_t size; { __ptr_t result; unsigned long int adj; result = (*__morecore) (size); adj = (unsigned long int) ((unsigned long int) ((char *) result - (char *) NULL)) % BLOCKSIZE; if (adj != 0) { adj = BLOCKSIZE - adj; (void) (*__morecore) (adj); result = (char *) result + adj; } return result; } /* Set everything up and remember that we have. */ static int initialize __P ((void)); static int initialize () { heapsize = HEAP / BLOCKSIZE; _heapinfo = (malloc_info *) align (heapsize * sizeof (malloc_info)); if (_heapinfo == NULL) return 0; memset (_heapinfo, 0, heapsize * sizeof (malloc_info)); _heapinfo[0].free.size = 0; _heapinfo[0].free.next = _heapinfo[0].free.prev = 0; _heapindex = 0; _heapbase = (char *) _heapinfo; __malloc_initialized = 1; return 1; } /* Get neatly aligned memory, initializing or growing the heap info table as necessary. */ static __ptr_t morecore __P ((size_t)); static __ptr_t morecore (size) size_t size; { __ptr_t result; malloc_info *newinfo, *oldinfo; size_t newsize; result = align (size); if (result == NULL) return NULL; /* Check if we need to grow the info table. */ if ((size_t) BLOCK ((char *) result + size) > heapsize) { newsize = heapsize; while ((size_t) BLOCK ((char *) result + size) > newsize) newsize *= 2; newinfo = (malloc_info *) align (newsize * sizeof (malloc_info)); if (newinfo == NULL) { (*__morecore) (-size); return NULL; } memset (newinfo, 0, newsize * sizeof (malloc_info)); memcpy (newinfo, _heapinfo, heapsize * sizeof (malloc_info)); oldinfo = _heapinfo; newinfo[BLOCK (oldinfo)].busy.type = 0; newinfo[BLOCK (oldinfo)].busy.info.size = BLOCKIFY (heapsize * sizeof (malloc_info)); _heapinfo = newinfo; _free_internal (oldinfo); heapsize = newsize; } _heaplimit = BLOCK ((char *) result + size); return result; } /* Allocate memory from the heap. */ __ptr_t malloc (size) size_t size; { __ptr_t result; size_t block, blocks, lastblocks, start; register size_t i; struct list *next; if (size == 0) return NULL; if (__malloc_hook != NULL) return (*__malloc_hook) (size); if (!__malloc_initialized) if (!initialize ()) return NULL; if (size < sizeof (struct list)) size = sizeof (struct list); /* Determine the allocation policy based on the request size. */ if (size <= BLOCKSIZE / 2) { /* Small allocation to receive a fragment of a block. Determine the logarithm to base two of the fragment size. */ register size_t log = 1; --size; while ((size /= 2) != 0) ++log; /* Look in the fragment lists for a free fragment of the desired size. */ next = _fraghead[log].next; if (next != NULL) { /* There are free fragments of this size. Pop a fragment out of the fragment list and return it. Update the block's nfree and first counters. */ result = (__ptr_t) next; next->prev->next = next->next; if (next->next != NULL) next->next->prev = next->prev; block = BLOCK (result); if (--_heapinfo[block].busy.info.frag.nfree != 0) _heapinfo[block].busy.info.frag.first = (unsigned long int) ((unsigned long int) ((char *) next->next - (char *) NULL) % BLOCKSIZE) >> log; /* Update the statistics. */ ++_chunks_used; _bytes_used += 1 << log; --_chunks_free; _bytes_free -= 1 << log; } else { /* No free fragments of the desired size, so get a new block and break it into fragments, returning the first. */ result = malloc (BLOCKSIZE); if (result == NULL) return NULL; #if 1 /* Adapted from Mike */ ++_fragblocks[log]; #endif /* Link all fragments but the first into the free list. */ for (i = 1; i < (size_t) (BLOCKSIZE >> log); ++i) { next = (struct list *) ((char *) result + (i << log)); next->next = _fraghead[log].next; next->prev = &_fraghead[log]; next->prev->next = next; if (next->next != NULL) next->next->prev = next; } /* Initialize the nfree and first counters for this block. */ block = BLOCK (result); _heapinfo[block].busy.type = log; _heapinfo[block].busy.info.frag.nfree = i - 1; _heapinfo[block].busy.info.frag.first = i - 1; _chunks_free += (BLOCKSIZE >> log) - 1; _bytes_free += BLOCKSIZE - (1 << log); _bytes_used -= BLOCKSIZE - (1 << log); } } else { /* Large allocation to receive one or more blocks. Search the free list in a circle starting at the last place visited. If we loop completely around without finding a large enough space we will have to get more memory from the system. */ blocks = BLOCKIFY (size); start = block = _heapindex; while (_heapinfo[block].free.size < blocks) { block = _heapinfo[block].free.next; if (block == start) { /* Need to get more from the system. Check to see if the new core will be contiguous with the final free block; if so we don't need to get as much. */ block = _heapinfo[0].free.prev; lastblocks = _heapinfo[block].free.size; if (_heaplimit != 0 && block + lastblocks == _heaplimit && (*__morecore) (0) == ADDRESS (block + lastblocks) && (morecore ((blocks - lastblocks) * BLOCKSIZE)) != NULL) { #if 1 /* Adapted from Mike */ /* Note that morecore() can change the location of the final block if it moves the info table and the old one gets coalesced into the final block. */ block = _heapinfo[0].free.prev; _heapinfo[block].free.size += blocks - lastblocks; #else _heapinfo[block].free.size = blocks; #endif _bytes_free += (blocks - lastblocks) * BLOCKSIZE; continue; } result = morecore (blocks * BLOCKSIZE); if (result == NULL) return NULL; block = BLOCK (result); _heapinfo[block].busy.type = 0; _heapinfo[block].busy.info.size = blocks; ++_chunks_used; _bytes_used += blocks * BLOCKSIZE; return result; } } /* At this point we have found a suitable free list entry. Figure out how to remove what we need from the list. */ result = ADDRESS (block); if (_heapinfo[block].free.size > blocks) { /* The block we found has a bit left over, so relink the tail end back into the free list. */ _heapinfo[block + blocks].free.size = _heapinfo[block].free.size - blocks; _heapinfo[block + blocks].free.next = _heapinfo[block].free.next; _heapinfo[block + blocks].free.prev = _heapinfo[block].free.prev; _heapinfo[_heapinfo[block].free.prev].free.next = _heapinfo[_heapinfo[block].free.next].free.prev = _heapindex = block + blocks; } else { /* The block exactly matches our requirements, so just remove it from the list. */ _heapinfo[_heapinfo[block].free.next].free.prev = _heapinfo[block].free.prev; _heapinfo[_heapinfo[block].free.prev].free.next = _heapindex = _heapinfo[block].free.next; --_chunks_free; } _heapinfo[block].busy.type = 0; _heapinfo[block].busy.info.size = blocks; ++_chunks_used; _bytes_used += blocks * BLOCKSIZE; _bytes_free -= blocks * BLOCKSIZE; } return result; } ./libc-linux/malloc/malloc.h100644 1676 334 15427 5505465422 14043 0ustar hjlisl/* Declarations for `malloc' and friends. Copyright 1990, 1991, 1992 Free Software Foundation, Inc. Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be reached (Email) at the address mike@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ #ifndef _MALLOC_H #define _MALLOC_H 1 #ifdef __cplusplus extern "C" { #endif #if defined (__cplusplus) || (defined (__STDC__) && __STDC__) #undef __P #define __P(args) args #undef __ptr_t #define __ptr_t void * #else /* Not C++ or ANSI C. */ #undef __P #define __P(args) () #undef const #define const #undef __ptr_t #define __ptr_t char * #endif /* C++ or ANSI C. */ #ifndef NULL #define NULL 0 #endif #ifdef __STDC__ #include #else #undef size_t #define size_t unsigned int #undef ptrdiff_t #define ptrdiff_t int #endif /* Allocate SIZE bytes of memory. */ extern __ptr_t malloc __P ((size_t __size)); /* Re-allocate the previously allocated block in __ptr_t, making the new block SIZE bytes long. */ extern __ptr_t realloc __P ((__ptr_t __ptr, size_t __size)); /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ extern __ptr_t calloc __P ((size_t __nmemb, size_t __size)); /* Free a block allocated by `malloc', `realloc' or `calloc'. */ extern void free __P ((__ptr_t __ptr)); /* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ extern __ptr_t memalign __P ((size_t __alignment, size_t __size)); /* Allocate SIZE bytes on a page boundary. */ extern __ptr_t valloc __P ((size_t __size)); #ifdef _MALLOC_INTERNAL #include /* Harmless, gets __GNU_LIBRARY__ defined. */ /* Count of blocks for each fragment size. */ extern int _fragblocks[]; #if defined(__GNU_LIBRARY__) || defined(STDC_HEADERS) || defined(USG) #include #else #ifndef memset #define memset(s, zero, n) bzero ((s), (n)) #endif #ifndef memcpy #define memcpy(d, s, n) bcopy ((s), (d), (n)) #endif #endif #if defined(__GNU_LIBRARY__) || defined(__STDC__) #include #else #define CHAR_BIT 8 #endif /* The allocator divides the heap into blocks of fixed size; large requests receive one or more whole blocks, and small requests receive a fragment of a block. Fragment sizes are powers of two, and all fragments of a block are the same size. When all the fragments in a block have been freed, the block itself is freed. */ #define INT_BIT (CHAR_BIT * sizeof(int)) #define BLOCKLOG (INT_BIT > 16 ? 12 : 9) #define BLOCKSIZE (1 << BLOCKLOG) #define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) /* Determine the amount of memory spanned by the initial heap table (not an absolute limit). */ #define HEAP (INT_BIT > 16 ? 4194304 : 65536) /* Number of contiguous free blocks allowed to build up at the end of memory before they will be returned to the system. */ #define FINAL_FREE_BLOCKS 8 /* Data structure giving per-block information. */ typedef union { /* Heap information for a busy block. */ struct { /* Zero for a large block, or positive giving the logarithm to the base two of the fragment size. */ int type; union { struct { size_t nfree; /* Free fragments in a fragmented block. */ size_t first; /* First free fragment of the block. */ } frag; /* Size (in blocks) of a large cluster. */ size_t size; } info; } busy; /* Heap information for a free block (that may be the first of a free cluster). */ struct { size_t size; /* Size (in blocks) of a free cluster. */ size_t next; /* Index of next free cluster. */ size_t prev; /* Index of previous free cluster. */ } free; } malloc_info; /* Pointer to first block of the heap. */ extern char *_heapbase; /* Table indexed by block number giving per-block information. */ extern malloc_info *_heapinfo; /* Address to block number and vice versa. */ #define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1) #define ADDRESS(B) ((__ptr_t) (((B) - 1) * BLOCKSIZE + _heapbase)) /* Current search index for the heap table. */ extern size_t _heapindex; /* Limit of valid info table indices. */ extern size_t _heaplimit; /* Doubly linked lists of free fragments. */ struct list { struct list *next; struct list *prev; }; /* Free list headers for each fragment size. */ extern struct list _fraghead[]; /* List of blocks allocated with `memalign' (or `valloc'). */ struct alignlist { struct alignlist *next; __ptr_t aligned; /* The address that memaligned returned. */ __ptr_t exact; /* The address that malloc returned. */ }; extern struct alignlist *_aligned_blocks; /* Instrumentation. */ extern size_t _chunks_used; extern size_t _bytes_used; extern size_t _chunks_free; extern size_t _bytes_free; /* Internal version of `free' used in `morecore' (malloc.c). */ extern void _free_internal __P ((__ptr_t __ptr)); #endif /* _MALLOC_INTERNAL. */ /* Underlying allocation function; successive calls should return contiguous pieces of memory. */ extern __ptr_t (*__morecore) __P ((ptrdiff_t __size)); /* Default value of `__morecore'. */ extern __ptr_t __default_morecore __P ((ptrdiff_t __size)); /* Nonzero if `malloc' has been called and done its initialization. */ extern int __malloc_initialized; /* Hooks for debugging versions. */ extern void (*__free_hook) __P ((__ptr_t __ptr)); extern __ptr_t (*__malloc_hook) __P ((size_t __size)); extern __ptr_t (*__realloc_hook) __P ((__ptr_t __ptr, size_t __size)); /* Activate a standard collection of debugging hooks. */ extern void mcheck __P ((void (*__func) __P ((void)))); /* Activate a standard collection of tracing hooks. */ extern void mtrace __P ((void)); /* Statistics available to the user. */ struct mstats { size_t bytes_total; /* Total size of the heap. */ size_t chunks_used; /* Chunks allocated by the user. */ size_t bytes_used; /* Byte total of user-allocated chunks. */ size_t chunks_free; /* Chunks in the free list. */ size_t bytes_free; /* Byte total of chunks in the free list. */ }; /* Pick up the current statistics. */ extern struct mstats mstats __P ((void)); #ifdef __cplusplus } #endif #endif /* malloc.h */ ./libc-linux/malloc/mcheck-init.c100644 1676 334 2171 5522764731 14736 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. */ /* The object of this file should be installed as libmcheck.a, so one can do -lmcheck to turn on mcheck. */ #include #include #include #ifdef HAVE_GNU_LD static void DEFUN_VOID (turn_on_mcheck) { mcheck (NULL); } text_set_element (__libc_subinit, turn_on_mcheck); #endif ./libc-linux/malloc/mcheck.c100644 1676 334 7036 5505465422 13776 0ustar hjlisl/* Standard debugging hooks for `malloc'. Copyright 1990, 1991, 1992 Free Software Foundation Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be reached (Email) at the address mike@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include #endif /* Old hook values. */ static void (*old_free_hook) __P ((__ptr_t ptr)); static __ptr_t (*old_malloc_hook) __P ((size_t size)); static __ptr_t (*old_realloc_hook) __P ((__ptr_t ptr, size_t size)); /* Function to call when something awful happens. */ extern void abort __P ((void)); static void (*abortfunc) __P ((void)) = (void (*) __P ((void))) abort; /* Arbitrary magical numbers. */ #define MAGICWORD 0xfedabeeb #define MAGICBYTE ((char) 0xd7) struct hdr { size_t size; /* Exact size requested by user. */ unsigned long int magic; /* Magic number to check header integrity. */ }; static void checkhdr __P ((__const struct hdr *)); static void checkhdr (hdr) __const struct hdr *hdr; { if (hdr->magic != MAGICWORD || ((char *) &hdr[1])[hdr->size] != MAGICBYTE) (*abortfunc) (); } static void freehook __P ((__ptr_t)); static void freehook (ptr) __ptr_t ptr; { struct hdr *hdr = ((struct hdr *) ptr) - 1; checkhdr (hdr); hdr->magic = 0; __free_hook = old_free_hook; free (hdr); __free_hook = freehook; } static __ptr_t mallochook __P ((size_t)); static __ptr_t mallochook (size) size_t size; { struct hdr *hdr; __malloc_hook = old_malloc_hook; hdr = (struct hdr *) malloc (sizeof (struct hdr) + size + 1); __malloc_hook = mallochook; if (hdr == NULL) return NULL; hdr->size = size; hdr->magic = MAGICWORD; ((char *) &hdr[1])[size] = MAGICBYTE; return (__ptr_t) (hdr + 1); } static __ptr_t reallochook __P ((__ptr_t, size_t)); static __ptr_t reallochook (ptr, size) __ptr_t ptr; size_t size; { struct hdr *hdr = ((struct hdr *) ptr) - 1; checkhdr (hdr); __free_hook = old_free_hook; __malloc_hook = old_malloc_hook; __realloc_hook = old_realloc_hook; hdr = (struct hdr *) realloc ((__ptr_t) hdr, sizeof (struct hdr) + size + 1); __free_hook = freehook; __malloc_hook = mallochook; __realloc_hook = reallochook; if (hdr == NULL) return NULL; hdr->size = size; ((char *) &hdr[1])[size] = MAGICBYTE; return (__ptr_t) (hdr + 1); } void mcheck (func) void (*func) __P ((void)); { static int mcheck_used = 0; if (func != NULL) abortfunc = func; /* These hooks may not be safely inserted if malloc is already in use. */ if (!__malloc_initialized && !mcheck_used) { old_free_hook = __free_hook; __free_hook = freehook; old_malloc_hook = __malloc_hook; __malloc_hook = mallochook; old_realloc_hook = __realloc_hook; __realloc_hook = reallochook; mcheck_used = 1; } } ./libc-linux/malloc/memalign.c100644 1676 334 3271 5505465422 14332 0ustar hjlisl/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include #endif __ptr_t memalign (alignment, size) size_t alignment; size_t size; { __ptr_t result; unsigned long int adj; size = ((size + alignment - 1) / alignment) * alignment; result = malloc (size); if (result == NULL) return NULL; adj = (unsigned long int) ((unsigned long int) ((char *) result - (char *) NULL)) % alignment; if (adj != 0) { struct alignlist *l; for (l = _aligned_blocks; l != NULL; l = l->next) if (l->aligned == NULL) /* This slot is free. Use it. */ break; if (l == NULL) { l = (struct alignlist *) malloc (sizeof (struct alignlist)); if (l == NULL) { free (result); return NULL; } } l->exact = result; result = l->aligned = (char *) result + alignment - adj; l->next = _aligned_blocks; _aligned_blocks = l; } return result; } ./libc-linux/malloc/malloc/ 40755 1676 334 0 5504466527 13552 5ustar hjlisl./libc-linux/malloc/malloc/gmalloc-head.c100644 1676 334 642 5270370317 16301 0ustar hjlisl/* DO NOT EDIT THIS FILE -- it is automagically generated. -*- C -*- */ #if defined(__GNU_LIBRARY__) || defined(STDC_HEADERS) || defined(USG) #include #else #define memset(s, zero, n) bzero ((s), (n)) #define memcpy(d, s, n) bcopy ((s), (d), (n)) #define memmove(d, s, n) bcopy ((s), (d), (n)) #endif #define _MALLOC_INTERNAL /* The malloc headers and source files from the C library follow here. */ ./libc-linux/malloc/mstats.c100644 1676 334 2502 5505465422 14050 0ustar hjlisl/* Access the statistics maintained by `malloc'. Copyright 1990, 1991, 1992 Free Software Foundation Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be reached (Email) at the address mike@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include #endif struct mstats mstats () { struct mstats result; result.bytes_total = (char *) (*__morecore) (0) - _heapbase; result.chunks_used = _chunks_used; result.bytes_used = _bytes_used; result.chunks_free = _chunks_free; result.bytes_free = _bytes_free; return result; } ./libc-linux/malloc/mtrace.awk100644 1676 334 1534 5505465422 14354 0ustar hjlisl# # Awk program to analyze mtrace.c output. # $1 == "+" { if (allocated[$2] != "") print "+", $2, "Alloc", NR, "duplicate:", allocated[$2]; else allocated[$2] = $3; } $1 == "-" { if (allocated[$2] != "") { allocated[$2] = ""; if (allocated[$2] != "") print "DELETE FAILED", $2, allocated[$2]; } else print "-", $2, "Free", NR, "was never alloc'd"; } $1 == "<" { if (allocated[$2] != "") allocated[$2] = ""; else print "-", $2, "Realloc", NR, "was never alloc'd"; } $1 == ">" { if (allocated[$2] != "") print "+", $2, "Realloc", NR, "duplicate:", allocated[$2]; else allocated[$2] = $3; } # Ignore "= Start" $1 == "=" { } # Ignore failed realloc attempts for now $1 == "!" { } END { for (x in allocated) if (allocated[x] != "") print "+", x, allocated[x]; } ./libc-linux/malloc/mtrace.c100644 1676 334 7761 5505465422 14024 0ustar hjlisl/* More debugging hooks for `malloc'. Copyright (C) 1991, 1992 Free Software Foundation, Inc. Written April 2, 1991 by John Gilmore of Cygnus Support. Based on mcheck.c by Mike Haertel. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be reached (Email) at the address mike@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include #endif #include #ifndef __GNU_LIBRARY__ extern char *getenv (); #else #include #endif static FILE *mallstream; static char mallenv[]= "MALLOC_TRACE"; static char mallbuf[BUFSIZ]; /* Buffer for the output. */ /* Address to breakpoint on accesses to... */ __ptr_t mallwatch; /* Old hook values. */ static void (*tr_old_free_hook) __P ((__ptr_t ptr)); static __ptr_t (*tr_old_malloc_hook) __P ((size_t size)); static __ptr_t (*tr_old_realloc_hook) __P ((__ptr_t ptr, size_t size)); /* This function is called when the block being alloc'd, realloc'd, or freed has an address matching the variable "mallwatch". In a debugger, set "mallwatch" to the address of interest, then put a breakpoint on tr_break. */ void tr_break __P ((void)); void tr_break () { } static void tr_freehook __P ((__ptr_t)); static void tr_freehook (ptr) __ptr_t ptr; { fprintf (mallstream, "- %p\n", ptr); /* Be sure to print it first. */ if (ptr == mallwatch) tr_break (); __free_hook = tr_old_free_hook; free (ptr); __free_hook = tr_freehook; } static __ptr_t tr_mallochook __P ((size_t)); static __ptr_t tr_mallochook (size) size_t size; { __ptr_t hdr; __malloc_hook = tr_old_malloc_hook; hdr = (__ptr_t) malloc (size); __malloc_hook = tr_mallochook; /* We could be printing a NULL here; that's OK. */ fprintf (mallstream, "+ %p %x\n", hdr, size); if (hdr == mallwatch) tr_break (); return hdr; } static __ptr_t tr_reallochook __P ((__ptr_t, size_t)); static __ptr_t tr_reallochook (ptr, size) __ptr_t ptr; size_t size; { __ptr_t hdr; if (ptr == mallwatch) tr_break (); __free_hook = tr_old_free_hook; __malloc_hook = tr_old_malloc_hook; __realloc_hook = tr_old_realloc_hook; hdr = (__ptr_t) realloc (ptr, size); __free_hook = tr_freehook; __malloc_hook = tr_mallochook; __realloc_hook = tr_reallochook; if (hdr == NULL) /* Failed realloc. */ fprintf (mallstream, "! %p %x\n", ptr, size); else fprintf (mallstream, "< %p\n> %p %x\n", ptr, hdr, size); if (hdr == mallwatch) tr_break (); return hdr; } /* We enable tracing if either the environment variable MALLOC_TRACE is set, or if the variable mallwatch has been patched to an address that the debugging user wants us to stop on. When patching mallwatch, don't forget to set a breakpoint on tr_break! */ void mtrace () { char *mallfile; mallfile = getenv (mallenv); if (mallfile != NULL || mallwatch != NULL) { mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "w"); if (mallstream != NULL) { /* Be sure it doesn't malloc its buffer! */ setbuf (mallstream, mallbuf); fprintf (mallstream, "= Start\n"); tr_old_free_hook = __free_hook; __free_hook = tr_freehook; tr_old_malloc_hook = __malloc_hook; __malloc_hook = tr_mallochook; tr_old_realloc_hook = __realloc_hook; __realloc_hook = tr_reallochook; } } } ./libc-linux/malloc/realloc.c100644 1676 334 10356 5505465422 14204 0ustar hjlisl/* Change the size of a block allocated by `malloc'. Copyright 1990, 1991, 1992 Free Software Foundation, Inc. Written May 1989 by Mike Haertel. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be reached (Email) at the address mike@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include #endif #define min(A, B) ((A) < (B) ? (A) : (B)) /* Debugging hook for realloc. */ __ptr_t (*__realloc_hook) __P ((__ptr_t __ptr, size_t __size)); /* Resize the given region to the new size, returning a pointer to the (possibly moved) region. This is optimized for speed; some benchmarks seem to indicate that greater compactness is achieved by unconditionally allocating and copying to a new region. This module has incestuous knowledge of the internals of both free and malloc. */ __ptr_t realloc (ptr, size) __ptr_t ptr; size_t size; { __ptr_t result; int type; size_t block, blocks, oldlimit; if (size == 0) { free (ptr); return malloc (0); } else if (ptr == NULL) return malloc (size); if (__realloc_hook != NULL) return (*__realloc_hook) (ptr, size); block = BLOCK (ptr); type = _heapinfo[block].busy.type; switch (type) { case 0: /* Maybe reallocate a large block to a small fragment. */ if (size <= BLOCKSIZE / 2) { result = malloc (size); if (result != NULL) { memcpy (result, ptr, size); free (ptr); return result; } } /* The new size is a large allocation as well; see if we can hold it in place. */ blocks = BLOCKIFY (size); if (blocks < _heapinfo[block].busy.info.size) { /* The new size is smaller; return excess memory to the free list. */ _heapinfo[block + blocks].busy.type = 0; _heapinfo[block + blocks].busy.info.size = _heapinfo[block].busy.info.size - blocks; _heapinfo[block].busy.info.size = blocks; free (ADDRESS (block + blocks)); result = ptr; } else if (blocks == _heapinfo[block].busy.info.size) /* No size change necessary. */ result = ptr; else { /* Won't fit, so allocate a new region that will. Free the old region first in case there is sufficient adjacent free space to grow without moving. */ blocks = _heapinfo[block].busy.info.size; /* Prevent free from actually returning memory to the system. */ oldlimit = _heaplimit; _heaplimit = 0; free (ptr); _heaplimit = oldlimit; result = malloc (size); if (result == NULL) { /* Now we're really in trouble. We have to unfree the thing we just freed. Unfortunately it might have been coalesced with its neighbors. */ if (_heapindex == block) (void) malloc (blocks * BLOCKSIZE); else { __ptr_t previous = malloc ((block - _heapindex) * BLOCKSIZE); (void) malloc (blocks * BLOCKSIZE); free (previous); } return NULL; } if (ptr != result) memmove (result, ptr, blocks * BLOCKSIZE); } break; default: /* Old size is a fragment; type is logarithm to base two of the fragment size. */ if (size > (size_t) (1 << (type - 1)) && size <= (size_t) (1 << type)) /* The new size is the same kind of fragment. */ result = ptr; else { /* The new size is different; allocate a new space, and copy the lesser of the new size and the old. */ result = malloc (size); if (result == NULL) return NULL; memcpy (result, ptr, min (size, (size_t) 1 << type)); free (ptr); } break; } return result; } ./libc-linux/malloc/valloc.c100644 1676 334 3317 5505465422 14022 0ustar hjlisl/* Allocate memory on a page boundary. Copyright (C) 1991, 1992 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author may be reached (Email) at the address mike@ai.mit.edu, or (US mail) as Mike Haertel c/o Free Software Foundation. */ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include #endif #ifdef emacs #include "config.h" #endif #ifdef __GNU_LIBRARY__ extern size_t __getpagesize __P ((void)); #else #ifndef USG extern size_t getpagesize __P ((void)); #define __getpagesize() getpagesize() #else #include #ifdef EXEC_PAGESIZE #define __getpagesize() EXEC_PAGESIZE #else /* No EXEC_PAGESIZE. */ #ifdef NBPG #ifndef CLSIZE #define CLSIZE 1 #endif /* No CLSIZE. */ #define __getpagesize() (NBPG * CLSIZE) #else /* No NBPG. */ #define __getpagesize() NBPC #endif /* NBPG. */ #endif /* EXEC_PAGESIZE. */ #endif /* USG. */ #endif static size_t pagesize; __ptr_t valloc (size) size_t size; { if (pagesize == 0) pagesize = __getpagesize (); return memalign (pagesize, size); } ./libc-linux/misc/ 40755 1676 334 0 5550053310 11746 5ustar hjlisl./libc-linux/misc/ldexp.c100644 1676 334 10115 5465555042 13357 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. */ /* * Copyright (c) 1985 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. */ #include #include #include #include #include "ieee754.h" double DEFUN(ldexp, (x, exp), double x AND int exp) { union ieee754_double *u = (union ieee754_double *) &x; unsigned int exponent; exponent = u->ieee.exponent; /* The order of the tests is carefully chosen to handle the usual case first, with no branches taken. */ if (exponent != 0) { /* X is nonzero and not denormalized. */ if (exponent <= DBL_MAX_EXP - DBL_MIN_EXP + 1) { /* X is finite. When EXP < 0, overflow is actually underflow. */ exponent += exp; if (exponent != 0) { if (exponent <= DBL_MAX_EXP - DBL_MIN_EXP + 1) { /* In range. */ u->ieee.exponent = exponent; return x; } if (exp >= 0) overflow: { CONST int negative = u->ieee.negative; x = HUGE_VAL; u->ieee.negative = negative; errno = ERANGE; return x; } if (exponent <= - (unsigned int) (DBL_MANT_DIG + 1)) { /* Underflow. */ CONST int negative = u->ieee.negative; x = 0.0; u->ieee.negative = negative; errno = ERANGE; return x; } } /* Gradual underflow. */ u->ieee.exponent = 1; x *= ldexp (1.0, (int) exponent - 1); if (u->ieee.mantissa0 == 0 && u->ieee.mantissa1 == 0) /* Underflow. */ errno = ERANGE; return x; } /* X is +-infinity or NaN. */ if (u->ieee.mantissa0 == 0 && u->ieee.mantissa1 == 0) { /* X is +-infinity. */ if (exp >= 0) goto overflow; else { /* (infinity * number < 1). With infinite precision, (infinity / finite) would be infinity, but otherwise it's safest to regard (infinity / 2) as indeterminate. The infinity might be (2 * finite). */ CONST int negative = u->ieee.negative; x = NAN; u->ieee.negative = negative; errno = EDOM; return x; } } /* X is NaN. */ errno = EDOM; return x; } /* X is zero or denormalized. */ if (u->ieee.mantissa0 == 0 && u->ieee.mantissa1 == 0) /* X is +-0.0. */ return x; /* X is denormalized. Multiplying by 2 ** DBL_MANT_DIG normalizes it; we then subtract the DBL_MANT_DIG we added to the exponent. */ return ldexp (x * ldexp (1.0, DBL_MANT_DIG), exp - DBL_MANT_DIG); } ./libc-linux/misc/Makefile100644 1676 334 1130 5515544326 13513 0ustar hjlisl# # This is Makefile for some misc functions. # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I. DIRS:= SRC1S= drand48.c getusersh.c insremque.c ldexp.c \ syslog.c usleep.c obstack.c ftok.c __getline.c hostid.c SRC2S = brk.c getdtsz.c gethstnm.c getpgsz.c getrusage.c ioctl.c \ mknod.c sbrk.c select.c setregid.c setreuid.c \ utimes.c stdiocompat.c dtoa.c SRC3S= __environ.S errno.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 ./libc-linux/misc/getrusage.c100644 1676 334 2061 5266174463 14215 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 #undef getrusage function_alias(getrusage, __getrusage, int, (who, usage), DEFUN(getrusage, (who, usage), enum __rusage_who who AND struct rusage *usage)) ./libc-linux/misc/drand48.c100644 1676 334 10110 5153571224 13474 0ustar hjlisl/* @(#)drand48.c 2.2 */ /*LINTLIBRARY*/ /* * drand48, etc. pseudo-random number generator * This implementation assumes unsigned short integers of at least * 16 bits, long integers of at least 32 bits, and ignores * overflows on adding or multiplying two unsigned integers. * Two's-complement representation is assumed in a few places. * Some extra masking is done if unsigneds are exactly 16 bits * or longs are exactly 32 bits, but so what? * An assembly-language implementation would run significantly faster. */ #include #ifndef HAVEFP #define HAVEFP 1 #endif #define N 16 #define MASK ((unsigned)(1 << (N - 1)) + (1 << (N - 1)) - 1) #define LOW(x) ((unsigned)(x) & MASK) #define HIGH(x) LOW((x) >> N) #define MUL(x, y, z) { long l = (long)(x) * (long)(y); \ (z)[0] = LOW(l); (z)[1] = HIGH(l); } #define CARRY(x, y) ((long)(x) + (long)(y) > MASK) #define ADDEQU(x, y, z) (z = CARRY(x, (y)), x = LOW(x + (y))) #define X0 0x330E #define X1 0xABCD #define X2 0x1234 #define A0 0xE66D #define A1 0xDEEC #define A2 0x5 #define C 0xB #define SET3(x, x0, x1, x2) ((x)[0] = (x0), (x)[1] = (x1), (x)[2] = (x2)) #define SETLOW(x, y, n) SET3(x, LOW((y)[n]), LOW((y)[(n)+1]), LOW((y)[(n)+2])) #define SEED(x0, x1, x2) (SET3(x, x0, x1, x2), SET3(a, A0, A1, A2), c = C) #define REST(v) for (i = 0; i < 3; i++) { xsubi[i] = x[i]; x[i] = temp[i]; } \ return (v); #define NEST(TYPE, f, F) TYPE f(xsubi) register unsigned short int *xsubi; { \ register int i; register TYPE v; unsigned temp[3]; \ for (i = 0; i < 3; i++) { temp[i] = x[i]; x[i] = LOW(xsubi[i]); } \ v = F(); REST(v); } #define HI_BIT (1L << (2 * N - 1)) static unsigned x[3] = { X0, X1, X2 }, a[3] = { A0, A1, A2 }, c = C; static unsigned short lastx[3]; static void next(); #if HAVEFP double drand48() { #if pdp11 static double two16m; /* old pdp11 cc can't compile an expression */ two16m = 1.0 / (1L << N); /* in "double" initializer! */ #else static double two16m = 1.0 / (1L << N); #endif next(); return (two16m * (two16m * (two16m * x[0] + x[1]) + x[2])); } NEST(double, erand48, drand48); #else long irand48(m) /* Treat x[i] as a 48-bit fraction, and multiply it by the 16-bit * multiplier m. Return integer part as result. */ register unsigned short m; { unsigned r[4], p[2], carry0 = 0; next(); MUL(m, x[0], &r[0]); MUL(m, x[2], &r[2]); MUL(m, x[1], p); if (CARRY(r[1], p[0])) ADDEQU(r[2], 1, carry0); return (r[3] + carry0 + CARRY(r[2], p[1])); } long krand48(xsubi, m) /* same as irand48, except user provides storage in xsubi[] */ register unsigned short *xsubi; unsigned short m; { register int i; register long iv; unsigned temp[3]; for (i = 0; i < 3; i++) { temp[i] = x[i]; x[i] = xsubi[i]; } iv = irand48(m); REST(iv); } #endif long int lrand48() { next(); return (((long)x[2] << (N - 1)) + (x[1] >> 1)); } long int mrand48() { register long l; next(); /* sign-extend in case length of a long > 32 bits (as on Honeywell) */ return ((l = ((long)x[2] << N) + x[1]) & HI_BIT ? l | -HI_BIT : l); } static void next() { unsigned p[2], q[2], r[2], carry0, carry1; MUL(a[0], x[0], p); ADDEQU(p[0], c, carry0); ADDEQU(p[1], carry0, carry1); MUL(a[0], x[1], q); ADDEQU(p[1], q[0], carry0); MUL(a[1], x[0], r); x[2] = LOW(carry0 + carry1 + CARRY(p[1], r[0]) + q[1] + r[1] + a[0] * x[2] + a[1] * x[1] + a[2] * x[0]); x[1] = LOW(p[1] + r[0]); x[0] = LOW(p[0]); } void srand48(long int seedval) { SEED(X0, LOW(seedval), HIGH(seedval)); } unsigned short int * seed48(unsigned short seed16v[3]) { SETLOW(lastx, x, 0); SEED(LOW(seed16v[0]), LOW(seed16v[1]), LOW(seed16v[2])); return (lastx); } void lcong48(unsigned short int param[7]) { SETLOW(x, param, 0); SETLOW(a, param, 3); c = LOW(param[6]); } NEST(long, nrand48, lrand48); NEST(long, jrand48, mrand48); #ifdef DRIVER /* This should print the sequences of integers in Tables 2 and 1 of the TM: 1623, 3442, 1447, 1829, 1305, ... 657EB7255101, D72A0C966378, 5A743C062A23, ... */ #include main() { int i; for (i = 0; i < 80; i++) { printf("%4d ", (int)(4096 * drand48())); printf("%.4X%.4X%.4X\n", x[2], x[1], x[0]); } } #endif ./libc-linux/misc/brk.c100644 1676 334 1747 5266174746 13023 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 extern int EXFUN(__brk, (PTR)); #undef brk function_alias(brk, __brk, int, (addr), DEFUN(brk, (addr), PTR addr)) ./libc-linux/misc/usleep.c100644 1676 334 403 5430342660 13467 0ustar hjlisl#include #include void usleep(unsigned long usec) { struct timeval timeout; timeout.tv_sec = usec / 1000000; timeout.tv_usec = usec - 1000000 * timeout.tv_sec; select(1, NULL, NULL, NULL, &timeout); } ./libc-linux/misc/getdtsz.c100644 1676 334 1761 5266174746 13725 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 #undef getdtablesize function_alias(getdtablesize, __getdtablesize, int, (), DEFUN_VOID(getdtablesize)) ./libc-linux/misc/gethstnm.c100644 1676 334 2061 5266174746 14064 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 #include #undef gethostname function_alias(gethostname, __gethostname, int, (name, len), DEFUN(gethostname, (name, len), char *name AND size_t len)) ./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/misc/getpgsz.c100644 1676 334 2000 5266174746 13707 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 #include #undef getpagesize function_alias(getpagesize, __getpagesize, size_t, (), DEFUN_VOID(getpagesize)) ./libc-linux/misc/getusersh.c100644 1676 334 7304 5266174746 14251 0ustar hjlisl/* * Copyright (c) 1985 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[] = "@(#)getusershell.c 5.7 (Berkeley) 2/23/91"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include #include #include #define SHELLS "/etc/shells" /* * Do not add local shells here. They should be added in /etc/shells */ static const char *okshells[] = { "/bin/sh", "/bin/csh", 0 }; static char **shells, *strings; static char **curshell = NULL; static char **initshells(); /* * Get a list of shells from SHELLS, if it exists. */ char * getusershell() { char *ret; if (curshell == NULL) curshell = initshells(); ret = *curshell; if (ret != NULL) curshell++; return (ret); } void endusershell() { if (shells != NULL) free((char *)shells); shells = NULL; if (strings != NULL) free(strings); strings = NULL; curshell = NULL; } void setusershell() { curshell = initshells(); } static char ** initshells() { register char **sp, *cp; register FILE *fp; struct stat statb; if (shells != NULL) free((char *)shells); shells = NULL; if (strings != NULL) free(strings); strings = NULL; if ((fp = fopen(SHELLS, "r")) == (FILE *)0) return(okshells); if (fstat(fileno(fp), &statb) == -1) { (void)fclose(fp); return(okshells); } if ((strings = malloc((unsigned)statb.st_size)) == NULL) { (void)fclose(fp); return(okshells); } shells = (char **)calloc((unsigned)statb.st_size / 3, sizeof (char *)); if (shells == NULL) { (void)fclose(fp); free(strings); strings = NULL; return(okshells); } sp = shells; cp = strings; while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) { while (*cp != '#' && *cp != '/' && *cp != '\0') cp++; if (*cp == '#' || *cp == '\0') continue; *sp++ = cp; while (!isspace(*cp) && *cp != '#' && *cp != '\0') cp++; *cp++ = '\0'; } *sp = (char *)0; (void)fclose(fp); return (shells); } ./libc-linux/misc/insremque.c100644 1676 334 3011 5266174746 14237 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 #include struct qelem { struct qelem *q_forw; struct qelem *q_back; char q_data[1]; }; /* Insert ELEM into a doubly-linked list, after PREV. */ void DEFUN(insque, (elem, prev) , struct qelem *elem AND struct qelem *prev) { struct qelem *next = prev->q_forw; prev->q_forw = elem; if (next != NULL) next->q_back = elem; elem->q_forw = next; elem->q_back = prev; } /* Unlink ELEM from the doubly-linked list that it is in. */ void DEFUN(remque, (elem), struct qelem *elem) { struct qelem *next = elem->q_forw; struct qelem *prev = elem->q_back; if (next != NULL) next->q_back = prev; if (prev != NULL) prev->q_forw = next; } ./libc-linux/misc/ioctl.c100644 1676 334 2324 5420344076 13332 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 #undef ioctl #ifdef HAVE_GNU_LD symbol_alias (__ioctl, ioctl); #else #include int DEFUN(ioctl, (fd, request), int fd AND int request DOTS) { va_list arglist; __ptr_t arg; va_start (arglist, request); arg = va_arg (arglist, __ptr_t); va_end (arglist); return __ioctl (fd, request, arg); } #endif ./libc-linux/misc/mknod.c100644 1676 334 2047 5266174746 13347 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 #undef mknod function_alias(mknod, __mknod, int, (path, mode, dev), DEFUN(mknod, (path, mode, dev), CONST char *path AND __mode_t mode AND int dev)) ./libc-linux/misc/sbrk.c100644 1676 334 1773 5266174746 13205 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 extern PTR EXFUN(__sbrk, (int)); #undef sbrk function_alias(sbrk, __sbrk, PTR, (increment), DEFUN(sbrk, (increment), int increment)) ./libc-linux/misc/select.c100644 1676 334 2277 5266174746 13523 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 #include #undef select function_alias(select, __select, int, (nfds, readfds, writefds, exceptfds, timeout), DEFUN(select, (nfds, readfds, writefds, exceptfds, timeout), int nfds AND fd_set *readfds AND fd_set *writefds AND fd_set *exceptfds AND struct timeval *timeout)) ./libc-linux/misc/setregid.c100644 1676 334 2014 5266174746 14037 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 #undef setregid function_alias(setregid, __setregid, int, (gid, egid), DEFUN(setregid, (gid, egid), __gid_t gid AND __gid_t egid)) ./libc-linux/misc/setreuid.c100644 1676 334 2014 5266174746 14055 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 #undef setreuid function_alias(setreuid, __setreuid, int, (uid, euid), DEFUN(setreuid, (uid, euid), __uid_t uid AND __uid_t euid)) ./libc-linux/misc/utimes.c100644 1676 334 2033 5266174746 13540 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 #undef utimes function_alias(utimes, __utimes, int, (file, tvp), DEFUN(utimes, (file, tvp), CONST char *file AND struct timeval tvp[2])) ./libc-linux/misc/soft.h100644 1676 334 3063 5270341431 13174 0ustar hjlisl#ifndef __SOFT_H #define __SOFT_H #ifndef __LIBRARY__ #define __LIBRARY__ #endif #include #include #include extern int finite(double); extern double infnan(int); extern double pio2; extern double *double_inf, *double_minf, *double_NaN; extern double *double_huge, *double_tiny; extern float *float_huge, *float_tiny; #ifdef LITTLE_ENDIAN struct bitdouble { /* internal format of an IEEE double */ unsigned mant2; unsigned mant1 : 20; unsigned exp : 11; unsigned sign : 1; /* 0=pos, 1=neg */ }; /* value = 2^(exp-BIAS) * 0b1.|mant|mant2 */ struct bitfloat { /* format of a float (single-precision IEEE) */ unsigned mant : 23; unsigned exp : 8; unsigned sign : 1; }; #else struct bitdouble { /* internal format of an IEEE double */ unsigned sign : 1; /* 0=pos, 1=neg */ unsigned exp : 11; unsigned mant1 : 20; unsigned mant2; }; /* value = 2^(exp-BIAS) * 0b1.|mant|mant2 */ struct bitfloat { /* format of a float (single-precision IEEE) */ unsigned sign : 1; unsigned exp : 8; unsigned mant : 23; }; #endif /* note: GNU CC floating-point constants are all treated as 'float's, * so loss of precision will result accordingly when using constants; * an eventual atof() should handle full double values, with which * HUGEDOUBLE may be used. -meg */ #define INFINITE (*double_inf) #define NEG_INFINITE (*double_minf) #define NOT_A_NUMBER (*double_NaN) #define DHUGE (*double_huge) #define DTINY (*double_tiny) #define FHUGE (*float_huge) #define FTINY (*float_tiny) #define BIAS 0x3ff /* added to exp of bitdouble */ #endif ./libc-linux/misc/getloadavg.c100644 1676 334 10256 5272040121 14345 0ustar hjlislFrom daemon Fri Oct 23 02:19 PDT 1992 Received: from sun2.nsfnet-relay.ac.uk by dns1.eecs.wsu.edu (16.6/5.910402) id AA22066; Fri, 23 Oct 92 02:19:18 -0700 Via: uk.ac.cambridge.mrc-applied-psychology; Fri, 23 Oct 1992 10:18:32 +0100 Received: from menkar.mrc-apu.cam.ac.uk by sirius.mrc-apu.cam.ac.uk with UK-Sendmail (4.1/UK-2.1-APU); Fri, 23 Oct 92 10:18:05 BST Message-Id: <4517.9210230918@menkar.mrc-apu.cam.ac.uk> To: hlu@eecs.wsu.edu Subject: Re: mkstemp In-Reply-To: Your message of "Thu, 22 Oct 92 13:44:50 PDT." <9210222044.AA25828@yardbird> Date: Fri, 23 Oct 92 10:18:04 +0100 From: Mitchum DSouza Status: OR Hi, Thank you, mkstemp() works fine. I tried it with sendmail and it works.... well somewhat. I've got a few questions about debugging and shared libraries. I don't know if you know much about sendmail but here goes. When I build sendmail with shared libraries (jump 4.1), and attempt to build a frozen configuration file and the send some mail, sendmail coredumps. However if I make it a static binary everything works fine. The question is is how do I debug the shared version ?? I can't debug a shared version as -g forces static ?? or am i wrong ? I know quite a bit about C but not much about how to debug a core dump ?? Also if you put sendmail in deamon mode, (sendmail -bd), and incoming mail is recieved from say another Sun, then the forked process becomes defunct (as shown by ps) and a coredump is left in /usr/spool/mqueue. This happens for either the shared or static binary. So this question is - how do I debug a process that forks ?? i.e. a deamon ? Any ideas would be greatly appreciated. Thanx in advance. P.S. here is getloadavg() from sendmail (but doesn't work on Linux) I don't know much about the kernel to make this work. Any ideas ?? /* * Copyright (c) 1989 The 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getloadavg.c 6.1 (Berkeley) 5/29/89"; #endif LIBC_SCCS and not lint #include #include #include /*#include */ #include #define _PATH_KMEM "/dev/kmem" #define _PATH_UNIX "/dos/image" static char *kmem = _PATH_KMEM; static char *vmunix = _PATH_UNIX; static struct nlist nl[] = { { "_averunnable" }, #define X_AVERUNNABLE 0 { "_fscale" }, #define X_FSCALE 1 { "" }, }; /* * getloadavg() -- Get system load averages. * * Put `nelem' samples into `loadavg' array. * Return number of samples retrieved, or -1 on error. */ getloadavg(loadavg, nelem) double loadavg[]; int nelem; { off_t lseek(); static int need_nlist = 1; u_long averunnable[3]; int fscale, kmemfd, i; /* nlist() is slow; cache result */ if (need_nlist) { if (nlist(vmunix, nl) != 0) return (-1); if (nl[X_AVERUNNABLE].n_type == 0 || nl[X_FSCALE].n_type == 0) return (-1); need_nlist = 0; } if ((kmemfd = open(kmem, O_RDONLY, 0)) < 0) return (-1); if (lseek(kmemfd, (off_t)nl[X_AVERUNNABLE].n_value, L_SET) == -1) goto bad; if (read(kmemfd, (char *)averunnable, sizeof(averunnable)) < 0) goto bad; if (lseek(kmemfd, (off_t)nl[X_FSCALE].n_value, L_SET) == -1) goto bad; if (read(kmemfd, (char *)&fscale, sizeof(fscale)) < 0) goto bad; (void) close(kmemfd); nelem = MIN(nelem, sizeof(averunnable) / sizeof(averunnable[0])); for (i = 0; i < nelem; i++) loadavg[i] = (double) averunnable[i] / fscale; return (nelem); bad: (void) close(kmemfd); return (-1); } ./libc-linux/misc/dtoa.c100644 1676 334 2077 5473736661 13171 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 #undef dtoa function_alias(dtoa, _IO_dtoa, char *, (d, m, n, dec, s, r), DEFUN(dtoa, (d, m, n, dec, s, r), double d AND int m AND int n AND int *dec AND int *s AND char **r)) ./libc-linux/misc/__environ.S100644 1676 334 56 5263225663 14123 0ustar hjlisl.globl ___environ .data ___environ: .long 0 ./libc-linux/misc/errno.S100644 1676 334 46 5263701204 13257 0ustar hjlisl.globl _errno .data _errno: .long 0 ./libc-linux/misc/ftok.c100644 1676 334 413 5406145012 13131 0ustar hjlisl#include #include key_t ftok (char *path, char id) { struct stat buf; key_t key; if (__stat (path, &buf)) { return (key_t) -1; } key = (buf.st_ino & 0xFFFF) | ((buf.st_uid & 0xFF) << 16) | (id << 24); return key; } ./libc-linux/misc/obstack.c100644 1676 334 35015 5532200717 13666 0ustar hjlisl/* obstack.c - subroutines used implicitly by object stack macros Copyright (C) 1988, 89, 90, 91, 92, 93, 94 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. 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 "obstack.h" /* This is just to get __GNU_LIBRARY__ defined. */ #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__) #ifdef __STDC__ #define POINTER void * #else #define POINTER char * #endif /* Determine default alignment. */ struct fooalign {char x; double d;}; #define DEFAULT_ALIGNMENT \ ((PTR_INT_TYPE) ((char *)&((struct fooalign *) 0)->d - (char *)0)) /* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. But in fact it might be less smart and round addresses to as much as DEFAULT_ROUNDING. So we prepare for it to do that. */ union fooround {long x; double d;}; #define DEFAULT_ROUNDING (sizeof (union fooround)) /* When we copy a long block of data, this is the unit to do it with. On some machines, copying successive ints does not work; in such a case, redefine COPYING_UNIT to `long' (if that works) or `char' as a last resort. */ #ifndef COPYING_UNIT #define COPYING_UNIT int #endif /* The non-GNU-C macros copy the obstack into this global variable to avoid multiple evaluation. */ struct obstack *_obstack; /* Define a macro that either calls functions with the traditional malloc/free calling interface, or calls functions with the mmalloc/mfree interface (that adds an extra first argument), based on the state of use_extra_arg. For free, do not use ?:, since some compilers, like the MIPS compilers, do not allow (expr) ? void : void. */ #define CALL_CHUNKFUN(h, size) \ (((h) -> use_extra_arg) \ ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ : (*(h)->chunkfun) ((size))) #define CALL_FREEFUN(h, old_chunk) \ do { \ if ((h) -> use_extra_arg) \ (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ else \ (*(h)->freefun) ((old_chunk)); \ } while (0) /* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). Objects start on multiples of ALIGNMENT (0 means use default). CHUNKFUN is the function to use to allocate chunks, and FREEFUN the function to free them. Return nonzero if successful, zero if out of memory. To recover from an out of memory error, free up some memory, then call this again. */ int _obstack_begin (h, size, alignment, chunkfun, freefun) struct obstack *h; int size; int alignment; POINTER (*chunkfun) (); void (*freefun) (); { register struct _obstack_chunk* chunk; /* points to new chunk */ if (alignment == 0) alignment = DEFAULT_ALIGNMENT; if (size == 0) /* Default size is what GNU malloc can fit in a 4096-byte block. */ { /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. Use the values for range checking, because if range checking is off, the extra bytes won't be missed terribly, but if range checking is on and we used a larger request, a whole extra 4096 bytes would be allocated. These number are irrelevant to the new GNU malloc. I suspect it is less sensitive to the size of the request. */ int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) + 4 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)); size = 4096 - extra; } h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; h->freefun = freefun; h->chunk_size = size; h->alignment_mask = alignment - 1; h->use_extra_arg = 0; chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); if (!chunk) { h->alloc_failed = 1; return 0; } h->alloc_failed = 0; h->next_free = h->object_base = chunk->contents; h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size; chunk->prev = 0; /* The initial chunk now contains no empty object. */ h->maybe_empty_object = 0; return 1; } int _obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg) struct obstack *h; int size; int alignment; POINTER (*chunkfun) (); void (*freefun) (); POINTER arg; { register struct _obstack_chunk* chunk; /* points to new chunk */ if (alignment == 0) alignment = DEFAULT_ALIGNMENT; if (size == 0) /* Default size is what GNU malloc can fit in a 4096-byte block. */ { /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. Use the values for range checking, because if range checking is off, the extra bytes won't be missed terribly, but if range checking is on and we used a larger request, a whole extra 4096 bytes would be allocated. These number are irrelevant to the new GNU malloc. I suspect it is less sensitive to the size of the request. */ int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) + 4 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)); size = 4096 - extra; } h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; h->freefun = freefun; h->chunk_size = size; h->alignment_mask = alignment - 1; h->extra_arg = arg; h->use_extra_arg = 1; chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); if (!chunk) { h->alloc_failed = 1; return 0; } h->alloc_failed = 0; h->next_free = h->object_base = chunk->contents; h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size; chunk->prev = 0; /* The initial chunk now contains no empty object. */ h->maybe_empty_object = 0; return 1; } /* Allocate a new current chunk for the obstack *H on the assumption that LENGTH bytes need to be added to the current object, or a new object of length LENGTH allocated. Copies any partial object from the end of the old chunk to the beginning of the new one. */ void _obstack_newchunk (h, length) struct obstack *h; int length; { register struct _obstack_chunk* old_chunk = h->chunk; register struct _obstack_chunk* new_chunk; register long new_size; register int obj_size = h->next_free - h->object_base; register int i; int already; /* Compute size for new chunk. */ new_size = (obj_size + length) + (obj_size >> 3) + 100; if (new_size < h->chunk_size) new_size = h->chunk_size; /* Allocate and initialize the new chunk. */ new_chunk = CALL_CHUNKFUN (h, new_size); if (!new_chunk) { h->alloc_failed = 1; return; } h->alloc_failed = 0; h->chunk = new_chunk; new_chunk->prev = old_chunk; new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; /* Move the existing object to the new chunk. Word at a time is fast and is safe if the object is sufficiently aligned. */ if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) { for (i = obj_size / sizeof (COPYING_UNIT) - 1; i >= 0; i--) ((COPYING_UNIT *)new_chunk->contents)[i] = ((COPYING_UNIT *)h->object_base)[i]; /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, but that can cross a page boundary on a machine which does not do strict alignment for COPYING_UNITS. */ already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); } else already = 0; /* Copy remaining bytes one by one. */ for (i = already; i < obj_size; i++) new_chunk->contents[i] = h->object_base[i]; /* If the object just copied was the only data in OLD_CHUNK, free that chunk and remove it from the chain. But not if that chunk might contain an empty object. */ if (h->object_base == old_chunk->contents && ! h->maybe_empty_object) { new_chunk->prev = old_chunk->prev; CALL_FREEFUN (h, old_chunk); } h->object_base = new_chunk->contents; h->next_free = h->object_base + obj_size; /* The new chunk certainly contains no empty object yet. */ h->maybe_empty_object = 0; } /* Return nonzero if object OBJ has been allocated from obstack H. This is here for debugging. If you use it in a program, you are probably losing. */ #ifdef __STDC__ /* Suppress -Wmissing-prototypes warning. We don't want to declare this in obstack.h because it is just for debugging. */ int _obstack_allocated_p (struct obstack *h, POINTER obj); #endif int _obstack_allocated_p (h, obj) struct obstack *h; POINTER obj; { register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ register struct _obstack_chunk* plp; /* point to previous chunk if any */ lp = (h)->chunk; /* We use >= rather than > since the object cannot be exactly at the beginning of the chunk but might be an empty object exactly at the end of an adjacent chunk. */ while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj)) { plp = lp->prev; lp = plp; } return lp != 0; } /* Free objects in obstack H, including OBJ and everything allocate more recently than OBJ. If OBJ is zero, free everything in H. */ #undef obstack_free /* This function has two names with identical definitions. This is the first one, called from non-ANSI code. */ void _obstack_free (h, obj) struct obstack *h; POINTER obj; { register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ register struct _obstack_chunk* plp; /* point to previous chunk if any */ lp = h->chunk; /* We use >= because there cannot be an object at the beginning of a chunk. But there can be an empty object at that address at the end of another chunk. */ while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj)) { plp = lp->prev; CALL_FREEFUN (h, lp); lp = plp; /* If we switch chunks, we can't tell whether the new current chunk contains an empty object, so assume that it may. */ h->maybe_empty_object = 1; } if (lp) { h->object_base = h->next_free = (char *)(obj); h->chunk_limit = lp->limit; h->chunk = lp; } else if (obj != 0) /* obj is not in any of the chunks! */ abort (); } /* This function is used from ANSI code. */ void obstack_free (h, obj) struct obstack *h; POINTER obj; { register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ register struct _obstack_chunk* plp; /* point to previous chunk if any */ lp = h->chunk; /* We use >= because there cannot be an object at the beginning of a chunk. But there can be an empty object at that address at the end of another chunk. */ while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj)) { plp = lp->prev; CALL_FREEFUN (h, lp); lp = plp; /* If we switch chunks, we can't tell whether the new current chunk contains an empty object, so assume that it may. */ h->maybe_empty_object = 1; } if (lp) { h->object_base = h->next_free = (char *)(obj); h->chunk_limit = lp->limit; h->chunk = lp; } else if (obj != 0) /* obj is not in any of the chunks! */ abort (); } #if 0 /* These are now turned off because the applications do not use it and it uses bcopy via obstack_grow, which causes trouble on sysV. */ /* Now define the functional versions of the obstack macros. Define them to simply use the corresponding macros to do the job. */ #ifdef __STDC__ /* These function definitions do not work with non-ANSI preprocessors; they won't pass through the macro names in parentheses. */ /* The function names appear in parentheses in order to prevent the macro-definitions of the names from being expanded there. */ POINTER (obstack_base) (obstack) struct obstack *obstack; { return obstack_base (obstack); } POINTER (obstack_next_free) (obstack) struct obstack *obstack; { return obstack_next_free (obstack); } int (obstack_object_size) (obstack) struct obstack *obstack; { return obstack_object_size (obstack); } int (obstack_room) (obstack) struct obstack *obstack; { return obstack_room (obstack); } void (obstack_grow) (obstack, pointer, length) struct obstack *obstack; POINTER pointer; int length; { obstack_grow (obstack, pointer, length); } void (obstack_grow0) (obstack, pointer, length) struct obstack *obstack; POINTER pointer; int length; { obstack_grow0 (obstack, pointer, length); } void (obstack_1grow) (obstack, character) struct obstack *obstack; int character; { obstack_1grow (obstack, character); } void (obstack_blank) (obstack, length) struct obstack *obstack; int length; { obstack_blank (obstack, length); } void (obstack_1grow_fast) (obstack, character) struct obstack *obstack; int character; { obstack_1grow_fast (obstack, character); } void (obstack_blank_fast) (obstack, length) struct obstack *obstack; int length; { obstack_blank_fast (obstack, length); } POINTER (obstack_finish) (obstack) struct obstack *obstack; { return obstack_finish (obstack); } POINTER (obstack_alloc) (obstack, length) struct obstack *obstack; int length; { return obstack_alloc (obstack, length); } POINTER (obstack_copy) (obstack, pointer, length) struct obstack *obstack; POINTER pointer; int length; { return obstack_copy (obstack, pointer, length); } POINTER (obstack_copy0) (obstack, pointer, length) struct obstack *obstack; POINTER pointer; int length; { return obstack_copy0 (obstack, pointer, length); } #endif /* __STDC__ */ #endif /* 0 */ #endif /* _LIBC or not __GNU_LIBRARY__. */ ./libc-linux/misc/__getline.c100644 1676 334 6506 5424123170 14145 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. */ #ifdef __linux__ #include #include #include #if !defined(ssize_t) && !defined(_SSIZE_T) #define _SSIZE_T #define ssize_t __ssize_t #endif #endif #include #include #include #ifndef MAX_CANON #define MAX_CANON 256 #endif /* Read up to (and including) a newline from STREAM into * *LINEPTR (and null-terminate it). *LINEPTR is a pointer * returned from malloc (or NULL), pointing to *N characters * of space. It is realloc'd as necessary. Returns the * number of characters read (not including the null * terminator), or -1 on error or EOF. */ #ifdef __linux__ ssize_t DEFUN(__getline, (lineptr, n, stream), char **lineptr AND size_t *n AND FILE *stream) #else __getline (char **lineptr, int *n, FILE *stream) #endif { char *ptr; /* the latest section of the buffer */ char *line; /* Pointer to the buffer */ int size; /* Size of the buffer */ int count; /* # of chars in the buffer */ if (lineptr == NULL || n == NULL) { errno = EINVAL; return -1; } if (ferror (stream)) return -1; /* No buffer or too small, we allocate one. */ if (*lineptr == NULL || *n < 2) { line = (*lineptr == NULL) ? malloc (MAX_CANON) : realloc (*lineptr, MAX_CANON); if (line == NULL) return -1; *lineptr = line; *n = MAX_CANON; } else { /* Assume the buffer size is `*n'. */ line = *lineptr; } size = *n; count = 0; ptr = line; for (;;) { /* We call fgets () first. For the first time, our * buffer is *n. Next time, it is MAX_CANON chars * longer. Count in 1 char for the last '\0'. Our * additional buffer is MAX_CANON + 1 char long. */ if (fgets (ptr, (count > 0 ? MAX_CANON + 1: size), stream) == NULL) { /* Check if we read in anything. */ return (count) ? count : -1; } /* How many chars we have read in so far. */ count += strlen (ptr); /* If the buffer is full and we still haven't seen the * newline, we need to expand the buffer and call * fgets () again. Caution: there may be no newline * at EOF. We will catch it when we call fgets () next * time. */ if ((count >= size - 1) && line [count - 1] != '\n') { /* Expand the buffer by MAX_CANON chars. */ size += MAX_CANON; line = realloc (line, size); if (line == NULL) return -1; *lineptr = line; *n = size; /* ptr points to the newly expanded buffer. We * start at the previous '\0'. */ ptr = &line [count]; } else break; } return count; } #if 0 void main () { char *buffer = NULL; int len, ret; while ((ret = __getline (&buffer, &len, stdin)) != -1) printf ("size: %d, len: %d: %s", len, ret, buffer); } #endif ./libc-linux/misc/hostid.c100644 1676 334 4003 5441132512 13477 0ustar hjlisl#include #include #include #include #include #include #include #define HOSTID "/etc/hostid" int sethostid(long int new_id) { int fd; int ret; if (geteuid() || getuid()) return errno=EPERM; if ((fd=open(HOSTID,O_CREAT|O_WRONLY,0644))<0) return -1; ret = write(fd,&new_id,sizeof(new_id)) == sizeof(new_id) ? 0 : -1; close (fd); return ret; } long int gethostid(void) { char host[MAXHOSTNAMELEN + 1]; int fd, id; /* If hostid was already set the we can return that value. * It is not an error if we cannot read this file. It is not even an * error if we cannot read all the bytes, we just carry on trying... */ if ((fd=open(HOSTID,O_RDONLY))>=0 && read(fd,&id,sizeof(id))) { close (fd); return id; } if (fd >= 0) close (fd); /* Try some methods of returning a unique 32 bit id. Clearly IP * numbers, if on the internet, will have a unique address. If they * are not on the internet then we can return 0 which means they should * really set this number via a sethostid() call. If their hostname * returns the loopback number (i.e. if they have put their hostname * in the /etc/hosts file with 127.0.0.1) then all such hosts will * have a non-unique hostid, but it doesn't matter anyway and * gethostid() will return a non zero number without the need for * setting one anyway. * Mitch */ if (gethostname(host,MAXHOSTNAMELEN)>=0 && *host) { struct hostent *hp; struct in_addr in; if ((hp = gethostbyname(host)) == (struct hostent *)NULL) /* This is not a error if we get here, as all it means is that * this host is not on a network and/or they have not * configured their network properly. So we return the unset * hostid which should be 0, meaning that they should set it !! */ return 0; else { memcpy((char *) &in, (char *) hp->h_addr, hp->h_length); /* Just so it doesn't look exactly like the IP addr */ return(in.s_addr<<16|in.s_addr>>16); } } else return 0; } ./libc-linux/misc/stdiocompat.c100644 1676 334 2173 5473742130 14551 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 #ifdef HAVE_GNU_LD symbol_alias(_IO_stdin_, __std_filebuf_0); symbol_alias(_IO_stdout_, __std_filebuf_1); symbol_alias(_IO_stderr_, __std_filebuf_2); symbol_alias(_IO_stdin_, _cin_sbuf); symbol_alias(_IO_stdout_, _cout_sbuf); symbol_alias(_IO_stderr_, _cerr_sbuf); #endif ./libc-linux/misc/_sbufs.c100644 1676 334 2004 5301275215 13470 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 #ifdef HAVE_GNU_LD symbol_alias(_cin_sbuf, __std_filebuf_0); symbol_alias(_cout_sbuf, __std_filebuf_1); symbol_alias(_cerr_sbuf, __std_filebuf_2); #endif ./libc-linux/posix/ 40755 1676 334 0 5550053564 12170 5ustar hjlisl./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/posix/getenv.c100644 1676 334 2443 5266156236 13730 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 #include #include #ifndef HAVE_GNU_LD #define __environ environ #endif /* Return the value of the environment variable NAME. */ char * DEFUN(getenv, (name), register CONST char *name) { register CONST size_t len = strlen(name); register char **ep; for (ep = __environ; *ep != NULL; ++ep) if (!strncmp(*ep, name, len) && (*ep)[len] == '=') return &(*ep)[len + 1]; return NULL; } ./libc-linux/posix/getopt1.c100644 1676 334 10215 5424555350 14033 0ustar hjlisl/* getopt_long and getopt_long_only entry points for GNU getopt. 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 #include "getopt.h" #if !__STDC__ && !defined(const) && IN_GCC #define const #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__ #include #else char *getenv (); #endif #ifndef NULL #define NULL 0 #endif int getopt_long (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } #endif /* _LIBC or not __GNU_LIBRARY__. */ #ifdef TEST #include int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"add", 1, 0, 0}, {"append", 0, 0, 0}, {"delete", 1, 0, 0}, {"verbose", 0, 0, 0}, {"create", 0, 0, 0}, {"file", 1, 0, 0}, {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", long_options, &option_index); if (c == EOF) break; switch (c) { case 0: printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; 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 'd': printf ("option d 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/posix/execl.c100644 1676 334 2767 5355654071 13550 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 #include #include #ifndef HAVE_GNU_LD #define __environ environ #endif /* Execute PATH with all arguments after PATH until a NULL pointer and environment from `environ'. */ int DEFUN(execl, (path), CONST char *path AND CONST char *arg DOTS) { CONST char *argv[8192]; register unsigned int i; va_list args; va_start(args, path); argv[0] = arg; for (i = 0; argv[i++] != NULL;) { if (i >= sizeof argv / sizeof argv[0]) { va_end(args); return E2BIG; } argv[i] = va_arg(args, CONST char *); } va_end(args); return __execve(path, (char *CONST *) argv, __environ); } ./libc-linux/posix/Makefile100644 1676 334 2026 5516312250 13715 0ustar hjlisl# # Makefile for POSIX functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules # 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. # COMPAT_FLAGS = -DGETOPT_COMPAT BASE_CFLAGS:= $(BASE_CFLAGS) $(COMPAT_FLAGS) DIRS:= SRC1S= cfmakeraw.c cfsetget.c clock.c confstr.c ctermid.c cuserid.c \ execl.c execle.c execlp.c execv.c execvp.c \ fnmatch.c getcwd.c getenv.c \ getopt.c getopt1.c glob.c killpg.c mktemp.c \ putenv.c raise.c readv.c sleep.c system.c tcdrain.c \ tcflow.c tcflush.c tcgetpgrp.c tcsendbrk.c \ tcsetattr.c tcsetpgrp.c ttyname.c writev.c SRC2S= environ.c execve.c fork.c fpathconf.c getegid.c geteuid.c \ getgid.c getgrps.c getpid.c getppid.c getuid.c pathconf.c \ setgid.c setsid.c setuid.c sysconf.c \ tcgetattr.c times.c wait.c wait3.c wait4.c waitpid.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/posix/sleep.c100644 1676 334 12306 5465533773 13575 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 /* SIGALRM signal handler for `sleep'. This does nothing but return, but SIG_IGN isn't supposed to break `pause'. */ static void DEFUN(sleep_handler, (sig), int sig) { return; } /* Make the process sleep for SECONDS seconds, or until a signal arrives and is not ignored. The function returns the number of seconds less than SECONDS which it actually slept (zero if it slept the full time). If a signal handler does a `longjmp' or modifies the handling of the SIGALRM signal while inside `sleep' call, the handling of the SIGALRM signal afterwards is undefined. There is no return value to indicate error, but if `sleep' returns SECONDS, it probably didn't work. */ unsigned int DEFUN(sleep, (seconds), unsigned int seconds) { unsigned int remaining, slept, realslept; time_t before, after; int save = errno; #ifdef _POSIX_SOURCE sigset_t set, oset; struct sigaction action, oldaction; #else /* _POSIX_SOURCE */ #ifdef _BSD_SOURCE int oldmask; #endif /* _BSD_SOURCE */ __sighandler_t handler; #endif /* _POSIX_SOURCE */ if (!seconds) return 0; /* We want to block SIGALRM if possible. We * unblock it later. A SIGALRM may occur after * the singal handler has been installed but before * we pause. */ #ifdef _POSIX_SOURCE __sigemptyset (&set); __sigaddset (&set, SIGALRM); if (__sigprocmask (SIG_BLOCK, &set, &oset) < 0) return seconds; action.sa_handler = sleep_handler; __sigemptyset (&action.sa_mask); action.sa_flags = 0; if (__sigaction (SIGALRM, &action, &oldaction) < 0) return seconds; #else /* _POSIX_SOURCE */ #ifdef _BSD_SOURCE if ((oldmask = __sigblock (SIGALRM)) < 0) return seconds; #endif /* _BSD_SOURCE */ handler = signal (SIGALRM, sleep_handler); if (handler == SIG_ERR) return seconds; #endif /* _POSIX_SOURCE */ before = time ((time_t *) NULL); /* return value is the time left for alarm if it was set before. if * it returns 0, what does that mean? we assume no alarm was set * before. */ remaining = alarm (seconds); if (remaining && remaining < seconds) { /* What if the previous alarm is about to expire. We reinstall * the old handler and set previous alarm. */ #ifdef _POSIX_SOURCE (void) __sigaction (SIGALRM, &oldaction, (struct sigaction *) NULL); alarm (remaining); /* Unblock SIGALRM with old signal mask and pause. It'd better * not block it. */ sigsuspend (&oset); #else /* _POSIX_SOURCE */ (void) signal (SIGALRM, handler); alarm (remaining); #ifdef _BSD_SOURCE /* Unblock SIGALRM with old signal mask and pause. It'd better * not block it. */ __sigpause (oldmask); #else /* _BSD_SOURCE */ (void) pause (); #endif /* _BSD_SOURCE */ #endif /* _POSIX_SOURCE */ after = time ((time_t *) NULL); } else { #ifdef _POSIX_SOURCE /* Unblock SIGALRM with old signal mask and pause. It'd better * not block it. */ sigsuspend (&oset); after = time ((time_t *) NULL); (void) __sigaction (SIGALRM, &oldaction, (struct sigaction *) NULL); #else /* _POSIX_SOURCE */ #ifdef _BSD_SOURCE /* Unblock SIGALRM with old signal mask and pause. It'd better * not block it. */ __sigpause (oldmask); #else /* _BSD_SOURCE */ (void) pause (); #endif /* _BSD_SOURCE */ after = time ((time_t *) NULL); (void) signal (SIGALRM, handler); #endif /* _POSIX_SOURCE */ } realslept = after - before; slept = realslept > seconds ? 0 : seconds - realslept; /* If we have called alarm () before which is scheduled to go * off after sleep (seconds), we should call alarm () again. * If sleep () is interrupted by a signal, we should turn off * the alarm (call alarm (0)). */ alarm (realslept > remaining ? 0 : remaining - realslept); /* We have to restore the old mask since sigsuspend () will * restore the previous mask with SIGALRM mask. We have to do it * just before we leave. We should get another SIGALRM in sleep.c. * Am I wrong? H.J. */ #ifdef _POSIX_SOURCE __sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL); #else /* _POSIX_SOURCE */ #ifdef _BSD_SOURCE __sigsetmask (oldmask); #endif /* _BSD_SOURCE */ #endif /* _POSIX_SOURCE */ /* Restore the `errno' value we started with. Some of * the calls we made might have failed, but we didn't * care. */ errno = save; return slept; } ./libc-linux/posix/cfsetget.c100644 1676 334 705 5131141356 14207 0ustar hjlisl#include speed_t cfgetospeed(struct termios *tp) { return (tp->c_cflag & CBAUD); } speed_t cfgetispeed(struct termios *tp) { return (tp->c_cflag & CBAUD); } int cfsetospeed(struct termios *tp, speed_t speed) { if (speed < B0 || speed > B38400) return 0; tp->c_cflag &= ~CBAUD; tp->c_cflag |= (speed & CBAUD); return 0; } int cfsetispeed(struct termios *tp, speed_t speed) { return cfsetospeed(tp, speed); } ./libc-linux/posix/tcgetpgrp.c100644 1676 334 2173 5270373366 14437 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 #include #include #include #include #include /* Return the foreground process group ID of FD. */ pid_t DEFUN(tcgetpgrp, (fd), int fd) { int pgrp; if (__ioctl(fd, TIOCGPGRP, &pgrp) < 0) return (pid_t) -1; return (pid_t) pgrp; } ./libc-linux/posix/sysconf.c100644 1676 334 1752 5263736743 14132 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 #undef sysconf function_alias(sysconf, __sysconf, long int, (name), DEFUN(sysconf, (name), int name)) ./libc-linux/posix/tcflow.c100644 1676 334 210 5301561450 13670 0ustar hjlisl#include #include #include int tcflow(int fd, int action) { return(__ioctl(fd,TCXONC,action)); } ./libc-linux/posix/tcsetpgrp.c100644 1676 334 2121 5270373506 14440 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 #include #include #include #include /* Set the foreground process group ID of FD set PGRP_ID. */ int DEFUN(tcsetpgrp, (fd, pgrp_id), int fd AND pid_t pgrp_id) { return __ioctl (fd, TIOCSPGRP, &pgrp_id); } ./libc-linux/posix/glob.c100644 1676 334 37547 5371305532 13410 0ustar hjlisl/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Modified for the Linux C library by H.J. Lu (hlu@eecs.wsu.edu) */ /* AIX requires this to be the first thing in the file. */ #if defined (_AIX) && !defined (__GNUC__) #pragma alloca #endif #undef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #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. */ #undef _LIBC #undef __GNU_LIBRARY__ #if defined (_LIBC) || !defined (__GNU_LIBRARY__) #ifdef STDC_HEADERS #include #endif #if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) extern int errno; #endif #ifndef NULL #define NULL 0 #endif #if defined (POSIX) || defined (DIRENT) || defined (__GNU_LIBRARY__) #include #ifndef __GNU_LIBRARY__ #define D_NAMLEN(d) strlen((d)->d_name) #else /* GNU C library. */ #define D_NAMLEN(d) ((d)->d_namlen) #endif /* Not GNU C library. */ #else /* Not POSIX or DIRENT. */ #define direct dirent #define D_NAMLEN(d) ((d)->d_namlen) #ifdef SYSNDIR #include #endif /* SYSNDIR */ #ifdef SYSDIR #include #endif /* SYSDIR */ #ifdef NDIR #include #endif /* NDIR */ #endif /* POSIX or DIRENT or __GNU_LIBRARY__. */ #if defined (POSIX) && !defined (__GNU_LIBRARY__) /* Posix does not require that the d_ino field be present, and some systems do not provide it. */ #define REAL_DIR_ENTRY(dp) 1 #else #define REAL_DIR_ENTRY(dp) (dp->d_ino != 0) #endif /* POSIX */ #ifdef HAVE_UNISTD_H #include #endif #if (defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)) #include #include #define ANSI_STRING #else /* No standard headers. */ #ifdef HAVE_STRING_H #include #define ANSI_STRING #else #include #endif #ifdef HAVE_MEMORY_H #include #endif extern char *malloc (), *realloc (); extern void free (); extern void qsort (); extern void abort (), exit (); #endif /* Standard headers. */ #ifndef ANSI_STRING #ifndef bzero extern void bzero (); #endif #ifndef bcopy extern void bcopy (); #endif #define memcpy(d, s, n) bcopy ((s), (d), (n)) #define strrchr rindex /* memset is only used for zero here, but let's be paranoid. */ #define memset(s, better_be_zero, n) \ ((void) ((better_be_zero) == 0 ? (bzero((s), (n)), 0) : (abort(), 0))) #endif /* Not ANSI_STRING. */ #ifndef HAVE_STRCOLL #define strcoll strcmp #endif #ifndef __GNU_LIBRARY__ #ifdef __GNUC__ __inline #endif static char * my_realloc (p, n) char *p; unsigned int n; { /* These casts are the for sake of the broken Ultrix compiler, which warns of illegal pointer combinations otherwise. */ if (p == NULL) return (char *) malloc (n); return (char *) realloc (p, n); } #define realloc my_realloc #endif #if !defined(__alloca) && !defined(__GNU_LIBRARY__) #ifdef __GNUC__ #undef alloca #define alloca(n) __builtin_alloca (n) #else /* Not GCC. */ #if defined (sparc) || defined (HAVE_ALLOCA_H) #include #else /* Not sparc or HAVE_ALLOCA_H. */ #ifndef _AIX extern char *alloca (); #endif /* Not _AIX. */ #endif /* sparc or HAVE_ALLOCA_H. */ #endif /* GCC. */ #define __alloca alloca #endif #ifndef STDC_HEADERS #undef size_t #define size_t unsigned int #endif /* Some system header files erroneously define these. We want our own definitions from to take precedence. */ #undef FNM_PATHNAME #undef FNM_NOESCAPE #undef FNM_PERIOD #include /* Some system header files erroneously define these. We want our own definitions from to take precedence. */ #undef GLOB_ERR #undef GLOB_MARK #undef GLOB_NOSORT #undef GLOB_DOOFFS #undef GLOB_NOCHECK #undef GLOB_APPEND #undef GLOB_NOESCAPE #undef GLOB_PERIOD #include __ptr_t (*__glob_opendir_hook) __P ((const char *directory)); const char *(*__glob_readdir_hook) __P ((__ptr_t stream)); void (*__glob_closedir_hook) __P ((__ptr_t stream)); static int glob_pattern_p __P ((const char *pattern, int quote)); static int glob_in_dir __P ((const char *pattern, const char *directory, int flags, int (*errfunc) __P ((const char *, int)), glob_t *pglob)); static int prefix_array __P ((const char *prefix, char **array, size_t n)); static int collated_compare __P ((const __ptr_t, const __ptr_t)); /* Do glob searching for PATTERN, placing results in PGLOB. The bits defined above may be set in FLAGS. If a directory cannot be opened or read and ERRFUNC is not nil, it is called with the pathname that caused the error, and the `errno' value from the failing call; if it returns non-zero `glob' returns GLOB_ABEND; if it returns zero, the error is ignored. If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned. Otherwise, `glob' returns zero. */ int glob (pattern, flags, errfunc, pglob) const char *pattern; int flags; int (*errfunc) __P ((const char *, int)); glob_t *pglob; { const char *filename; char *dirname; size_t dirlen; int status; int oldcount; if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0) { errno = EINVAL; return -1; } /* Find the filename. */ filename = strrchr (pattern, '/'); if (filename == NULL) { filename = pattern; dirname = (char *) "."; dirlen = 0; } else if (filename == pattern) { /* "/pattern". */ dirname = (char *) "/"; dirlen = 1; ++filename; } else { dirlen = filename - pattern; dirname = (char *) __alloca (dirlen + 1); memcpy (dirname, pattern, dirlen); dirname[dirlen] = '\0'; ++filename; } if (filename[0] == '\0' && dirlen > 1) /* "pattern/". Expand "pattern", appending slashes. */ { int ret = glob (dirname, flags | GLOB_MARK, errfunc, pglob); if (ret == 0) pglob->gl_flags = (pglob->gl_flags & ~GLOB_MARK) | (flags & GLOB_MARK); return ret; } if (!(flags & GLOB_APPEND)) { pglob->gl_pathc = 0; pglob->gl_pathv = NULL; } oldcount = pglob->gl_pathc; if (glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE))) { /* The directory name contains metacharacters, so we have to glob for the directory, and then glob for the pattern in each directory found. */ glob_t dirs; register int i; status = glob (dirname, ((flags & (GLOB_ERR | GLOB_NOCHECK | GLOB_NOESCAPE)) | GLOB_NOSORT), errfunc, &dirs); if (status != 0) return status; /* We have successfully globbed the preceding directory name. For each name we found, call glob_in_dir on it and FILENAME, appending the results to PGLOB. */ for (i = 0; i < dirs.gl_pathc; ++i) { int oldcount; #ifdef SHELL { /* Make globbing interruptible in the bash shell. */ extern int interrupt_state; if (interrupt_state) { globfree (&dirs); globfree (&files); return GLOB_ABEND; } } #endif /* SHELL. */ oldcount = pglob->gl_pathc; status = glob_in_dir (filename, dirs.gl_pathv[i], (flags | GLOB_APPEND) & ~GLOB_NOCHECK, errfunc, pglob); if (status == GLOB_NOMATCH) /* No matches in this directory. Try the next. */ continue; if (status != 0) { globfree (&dirs); globfree (pglob); return status; } /* Stick the directory on the front of each name. */ if (prefix_array (dirs.gl_pathv[i], &pglob->gl_pathv[oldcount], pglob->gl_pathc - oldcount)) { globfree (&dirs); globfree (pglob); return GLOB_NOSPACE; } } flags |= GLOB_MAGCHAR; if (pglob->gl_pathc == oldcount) /* No matches. */ if (flags & GLOB_NOCHECK) { const size_t len = strlen (pattern) + 1; char *patcopy = (char *) malloc (len); if (patcopy == NULL) return GLOB_NOSPACE; memcpy (patcopy, pattern, len); pglob->gl_pathv = (char **) realloc (pglob->gl_pathv, (pglob->gl_pathc + ((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) + 1 + 1) * sizeof (char *)); if (pglob->gl_pathv == NULL) { free (patcopy); return GLOB_NOSPACE; } if (flags & GLOB_DOOFFS) while (pglob->gl_pathc < pglob->gl_offs) pglob->gl_pathv[pglob->gl_pathc++] = NULL; pglob->gl_pathv[pglob->gl_pathc++] = patcopy; pglob->gl_pathv[pglob->gl_pathc] = NULL; pglob->gl_flags = flags; } else return GLOB_NOMATCH; } else { status = glob_in_dir (filename, dirname, flags, errfunc, pglob); if (status != 0) return status; if (dirlen > 0) { /* Stick the directory on the front of each name. */ if (prefix_array (dirname, &pglob->gl_pathv[oldcount], pglob->gl_pathc - oldcount)) { globfree (pglob); return GLOB_NOSPACE; } } } if (!(flags & GLOB_NOSORT)) /* Sort the vector. */ qsort ((__ptr_t) & pglob->gl_pathv[oldcount], pglob->gl_pathc - oldcount, sizeof (char *), collated_compare); return 0; } /* Free storage allocated in PGLOB by a previous `glob' call. */ void globfree (pglob) register glob_t *pglob; { if (pglob->gl_pathv != NULL) { register int i; for (i = 0; i < pglob->gl_pathc; ++i) if (pglob->gl_pathv[i] != NULL) free ((__ptr_t) pglob->gl_pathv[i]); free ((__ptr_t) pglob->gl_pathv); } } /* Do a collated comparison of A and B. */ static int collated_compare (a, b) const __ptr_t a; const __ptr_t b; { const char *const s1 = *(const char *const * const) a; const char *const s2 = *(const char *const * const) b; if (s1 == s2) return 0; if (s1 == NULL) return 1; if (s2 == NULL) return -1; return strcoll (s1, s2); } /* Prepend DIRNAME to each of N members of ARRAY, replacing ARRAY's elements in place. Return nonzero if out of memory, zero if successful. A slash is inserted between DIRNAME and each elt of ARRAY, unless DIRNAME is just "/". Each old element of ARRAY is freed. */ static int prefix_array (dirname, array, n) const char *dirname; char **array; const size_t n; { register size_t i; size_t dirlen = strlen (dirname); if (dirlen == 1 && dirname[0] == '/') /* DIRNAME is just "/", so normal prepending would get us "//foo". We want "/foo" instead, so don't prepend any chars from DIRNAME. */ dirlen = 0; for (i = 0; i < n; ++i) { const size_t eltlen = strlen (array[i]) + 1; char *new = (char *) malloc (dirlen + 1 + eltlen); if (new == NULL) { while (i > 0) free ((__ptr_t) array[--i]); return 1; } memcpy (new, dirname, dirlen); new[dirlen] = '/'; memcpy (&new[dirlen + 1], array[i], eltlen); free ((__ptr_t) array[i]); array[i] = new; } return 0; } /* Return nonzero if PATTERN contains any metacharacters. Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ static int glob_pattern_p (pattern, quote) const char *pattern; const int quote; { register const char *p; int open = 0; for (p = pattern; *p != '\0'; ++p) switch (*p) { case '?': case '*': return 1; case '\\': if (quote) ++p; break; case '[': open = 1; break; case ']': if (open) return 1; break; } return 0; } /* Like `glob', but PATTERN is a final pathname component, and matches are searched for in DIRECTORY. The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done. The GLOB_APPEND flag is assumed to be set (always appends). */ static int glob_in_dir (pattern, directory, flags, errfunc, pglob) const char *pattern; const char *directory; int flags; int (*errfunc) __P ((const char *, int)); glob_t *pglob; { __ptr_t stream; struct globlink { struct globlink *next; char *name; }; struct globlink *names = NULL; size_t nfound = 0; if (!glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE))) { stream = NULL; flags |= GLOB_NOCHECK; } else { flags |= GLOB_MAGCHAR; stream = (__glob_opendir_hook ? (*__glob_opendir_hook) (directory) : (__ptr_t) opendir (directory)); if (stream == NULL) { if ((errfunc != NULL && (*errfunc) (directory, errno)) || (flags & GLOB_ERR)) return GLOB_ABEND; } else while (1) { const char *name; size_t len; if (__glob_readdir_hook) { name = (*__glob_readdir_hook) (stream); if (name == NULL) break; len = 0; } else { struct dirent *d = readdir ((DIR *) stream); if (d == NULL) break; if (! REAL_DIR_ENTRY (d)) continue; name = d->d_name; #ifdef HAVE_D_NAMLEN len = d->d_namlen; #else len = 0; #endif } if (fnmatch (pattern, name, (!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)) == 0) { struct globlink *new = (struct globlink *) __alloca (sizeof (struct globlink)); if (len == 0) len = strlen (name); new->name = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1); if (new->name == NULL) goto memory_error; memcpy ((__ptr_t) new->name, name, len); if (flags & GLOB_MARK) new->name[len++] = '/'; new->name[len] = '\0'; new->next = names; names = new; ++nfound; } } } if (nfound == 0 && (flags & GLOB_NOCHECK)) { size_t len = strlen (pattern); nfound = 1; names = (struct globlink *) __alloca (sizeof (struct globlink)); names->next = NULL; names->name = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1); if (names->name == NULL) goto memory_error; memcpy (names->name, pattern, len); if (flags & GLOB_MARK) names->name[len++] = '/'; names->name[len] = '\0'; } pglob->gl_pathv = (char **) realloc (pglob->gl_pathv, (pglob->gl_pathc + ((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) + nfound + 1) * sizeof (char *)); if (pglob->gl_pathv == NULL) goto memory_error; if (flags & GLOB_DOOFFS) while (pglob->gl_pathc < pglob->gl_offs) pglob->gl_pathv[pglob->gl_pathc++] = NULL; for (; names != NULL; names = names->next) pglob->gl_pathv[pglob->gl_pathc++] = names->name; pglob->gl_pathv[pglob->gl_pathc] = NULL; pglob->gl_flags = flags; if (stream != NULL) { int save = errno; if (__glob_closedir_hook) (*__glob_closedir_hook) (stream); else (void) closedir ((DIR *) stream); errno = save; } return nfound == 0 ? GLOB_NOMATCH : 0; memory_error: { int save = errno; if (__glob_closedir_hook) (*__glob_closedir_hook) (stream); else (void) closedir ((DIR *) stream); errno = save; } while (names != NULL) { if (names->name != NULL) free ((__ptr_t) names->name); names = names->next; } return GLOB_NOSPACE; } #endif /* _LIBC or not __GNU_LIBRARY__. */ ./libc-linux/posix/tcdrain.c100644 1676 334 2171 5301561436 14052 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 #include #include #include #include #include /* Wait for pending output to be written on FD. */ int DEFUN(tcdrain, (fd), int fd) { /* With an argument of 1, TCSBRK just waits for output to drain. */ return __ioctl (fd, TCSBRK, 1); } ./libc-linux/posix/pathconf.c100644 1676 334 2017 5263736446 14243 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 #undef pathconf function_alias(pathconf, __pathconf, long int, (path, name), DEFUN(pathconf, (path, name), CONST char *path AND int name)) ./libc-linux/posix/execle.c100644 1676 334 3016 5355654071 13701 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 /* Execute PATH with all arguments after PATH until a NULL pointer, and the argument after that for environment. */ int DEFUN(execle, (path), CONST char *path AND CONST char *arg DOTS) { CONST char *argv[8192], *CONST *envp; register unsigned int i; va_list args; va_start(args, arg); argv[0] = arg; for (i = 0; argv[i++] != NULL;) { if (i >= sizeof argv / sizeof argv[0]) { va_end(args); return E2BIG; } argv[i] = va_arg(args, CONST char *); } envp = va_arg(args, CONST char *CONST *); va_end(args); return __execve(path, (char *CONST *) argv, (char *CONST *) envp); } ./libc-linux/posix/execlp.c100644 1676 334 2773 5355654071 13725 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 /* Execute FILE, searching in the `PATH' environment variable if it contains no slashes, with all arguments after FILE until a NULL pointer and environment from `environ'. */ int DEFUN(execlp, (file), CONST char *file AND CONST char *arg DOTS) { CONST char *argv[8192]; register unsigned int i; va_list args; va_start(args, file); argv[0] = arg; for (i = 0; argv[i++] != NULL;) { if (i >= sizeof argv / sizeof argv[0]) { va_end(args); return E2BIG; } argv[i] = va_arg(args, CONST char *); } va_end(args); return execvp(file, (char *CONST *) argv); } ./libc-linux/posix/execv.c100644 1676 334 2136 5263733655 13554 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 #ifndef HAVE_GNU_LD #define __environ environ #endif /* Execute PATH with arguments ARGV and environment from `environ'. */ int DEFUN(execv, (path, argv), CONST char *path AND char *CONST argv[]) { return __execve(path, argv, __environ); } ./libc-linux/posix/confstr.c100644 1676 334 3026 5270372042 14102 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 #include /* If BUF is not NULL, fill in at most LEN characters of BUF with the value corresponding to NAME. Return the number of characters required to hold NAME's entire value. */ size_t DEFUN(confstr, (name, buf, len), int name AND char *buf AND size_t len) { CONST char *string; size_t string_len; switch (name) { case _CS_PATH: { static CONST char cs_path[] = CS_PATH; string = cs_path; string_len = sizeof(cs_path); } break; default: errno = EINVAL; return 0; } if (buf != NULL) (void) strncpy(buf, string, len); return string_len; } ./libc-linux/posix/setgid.c100644 1676 334 1750 5263736612 13716 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 #undef setgid function_alias(setgid, __setgid, int, (gid), DEFUN(setgid, (gid), __gid_t gid)) ./libc-linux/posix/execvp.c100644 1676 334 6130 5417015456 13723 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 #include #include #include #include #include #ifndef HAVE_GNU_LD #define __environ environ #endif /* Execute FILE, searching in the `PATH' environment variable if it contains no slashes, with arguments ARGV and environment from `environ'. */ int DEFUN(execvp, (file, argv), CONST char *file AND char *CONST argv[]) { if (strchr (file, '/') == NULL) { char *path, *p; struct stat st; size_t len; uid_t uid; gid_t gid; int ngroups; gid_t groups[NGROUPS_MAX]; char *name; path = getenv ("PATH"); if (path == NULL) { /* There is no `PATH' in the environment. The default search path is the current directory followed by the path `confstr' returns for `_CS_PATH'. */ len = confstr (_CS_PATH, (char *) NULL, 0); path = (char *) __alloca (1 + len); path[0] = ':'; (void) confstr (_CS_PATH, path + 1, len); } len = strlen (file) + 1; name = __alloca (strlen (path) + len); uid = geteuid (); gid = getegid (); ngroups = getgroups (sizeof (groups) / sizeof (groups[0]), groups); p = path; do { path = p; p = strchr (path, ':'); if (p == NULL) p = strchr (path, '\0'); if (p == path) /* Two adjacent colons, or a colon at the beginning or the end of `PATH' means to search the current directory. */ (void) memcpy (name, file, len); else { /* Construct the pathname to try. */ (void) memcpy (name, path, p - path); name[p - path] = '/'; (void) memcpy (&name[(p - path) + 1], file, len); } if (stat (name, &st) == 0 && S_ISREG (st.st_mode)) { int bit = S_IXOTH; /* Root should be able to do anything. */ if (!uid) bit = S_IXUSR | S_IXGRP | S_IXOTH; else if (st.st_uid == uid) bit = S_IXUSR; else if (st.st_gid == gid) bit = S_IXGRP; else { register int i; for (i = 0; i < ngroups; ++i) if (st.st_gid == groups[i]) { bit = S_IXGRP; break; } } if (st.st_mode & bit) { file = name; break; } } } while (*p++ != '\0'); } return __execve (file, argv, __environ); } ./libc-linux/posix/putenv.c100644 1676 334 4275 5266156473 13771 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 #ifndef HAVE_GNU_LD #define __environ environ #endif /* Put STRING, which is of the form "NAME=VALUE", in the environment. */ int DEFUN(putenv, (string), CONST char *string) { CONST char *CONST name_end = strchr(string, '='); register size_t size; register char **ep; if (name_end == NULL) { /* Remove the variable from the environment. */ size = strlen(string); for (ep = __environ; *ep != NULL; ++ep) if (!strncmp(*ep, string, size) && (*ep)[size] == '=') { while (ep[1] != NULL) { ep[0] = ep[1]; ++ep; } *ep = NULL; return 0; } } size = 0; for (ep = __environ; *ep != NULL; ++ep) if (!strncmp(*ep, string, name_end - string) && (*ep)[name_end - string] == '=') break; else ++size; if (*ep == NULL) { static char **last_environ = NULL; char **new_environ = (char **) malloc((size + 2) * sizeof(char *)); if (new_environ == NULL) return -1; (void) memcpy((PTR) new_environ, (PTR) __environ, size * sizeof(char *)); new_environ[size] = (char *) string; new_environ[size + 1] = NULL; if (last_environ != NULL) free((PTR) last_environ); last_environ = new_environ; __environ = new_environ; } else *ep = (char *) string; return 0; } ./libc-linux/posix/fnmatch.c100644 1676 334 11615 5371305532 14071 0ustar hjlisl/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Modified for the Linux C library by H.J. Lu (hlu@eecs.wsu.edu) */ #undef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #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. */ #undef _LIBC #undef __GNU_LIBRARY__ #if defined (_LIBC) || !defined (__GNU_LIBRARY__) #if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) extern int errno; #endif /* Match STRING against the filename pattern PATTERN, returning zero if it matches, nonzero if not. */ int fnmatch (pattern, string, flags) const char *pattern; const char *string; int flags; { register const char *p = pattern, *n = string; register char c; /* Note that this evalutes C many times. */ #define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c)) while ((c = *p++) != '\0') { c = FOLD (c); switch (c) { case '?': if (*n == '\0') return FNM_NOMATCH; else if ((flags & FNM_FILE_NAME) && *n == '/') return FNM_NOMATCH; else if ((flags & FNM_PERIOD) && *n == '.' && (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) return FNM_NOMATCH; break; case '\\': if (!(flags & FNM_NOESCAPE)) { c = *p++; c = FOLD (c); } if (FOLD (*n) != c) return FNM_NOMATCH; break; case '*': if ((flags & FNM_PERIOD) && *n == '.' && (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) return FNM_NOMATCH; for (c = *p++; c == '?' || c == '*'; c = *p++, ++n) if (((flags & FNM_FILE_NAME) && *n == '/') || (c == '?' && *n == '\0')) return FNM_NOMATCH; if (c == '\0') return 0; { char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c; c1 = FOLD (c1); for (--p; *n != '\0'; ++n) if ((c == '[' || FOLD (*n) == c1) && fnmatch (p, n, flags & ~FNM_PERIOD) == 0) return 0; return FNM_NOMATCH; } case '[': { /* Nonzero if the sense of the character class is inverted. */ register int not; if (*n == '\0') return FNM_NOMATCH; if ((flags & FNM_PERIOD) && *n == '.' && (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) return FNM_NOMATCH; not = (*p == '!' || *p == '^'); if (not) ++p; c = *p++; for (;;) { register char cstart = c, cend = c; if (!(flags & FNM_NOESCAPE) && c == '\\') cstart = cend = *p++; cstart = cend = FOLD (cstart); if (c == '\0') /* [ (unterminated) loses. */ return FNM_NOMATCH; c = *p++; c = FOLD (c); if ((flags & FNM_FILE_NAME) && c == '/') /* [/] can never match. */ return FNM_NOMATCH; if (c == '-' && *p != ']') { cend = *p++; if (!(flags & FNM_NOESCAPE) && cend == '\\') cend = *p++; if (cend == '\0') return FNM_NOMATCH; cend = FOLD (cend); c = *p++; } if (FOLD (*n) >= cstart && FOLD (*n) <= cend) goto matched; if (c == ']') break; } if (!not) return FNM_NOMATCH; break; matched:; /* Skip the rest of the [...] that already matched. */ while (c != ']') { if (c == '\0') /* [... (unterminated) loses. */ return FNM_NOMATCH; c = *p++; if (!(flags & FNM_NOESCAPE) && c == '\\') /* XXX 1003.2d11 is unclear if this is right. */ ++p; } if (not) return FNM_NOMATCH; } break; default: if (c != FOLD (*n)) return FNM_NOMATCH; } ++n; } if (*n == '\0') return 0; if ((flags & FNM_LEADING_DIR) && *n == '/') /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ return 0; return FNM_NOMATCH; } #endif /* _LIBC or not __GNU_LIBRARY__. */ ./libc-linux/posix/clock.c100644 1676 334 2254 5153562157 13531 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 /* Return the time used by the program so far (user time + system time). */ clock_t DEFUN_VOID(clock) { struct tms buf; if (times(&buf) < 0) return (clock_t) -1; #if 0 return ((buf.tms_utime + buf.tms_stime) * CLK_TCK * CLOCKS_PER_SEC); #else return (buf.tms_utime + buf.tms_stime); #endif } ./libc-linux/posix/readv.c100644 1676 334 4177 5501226314 13532 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 #include #include /* Read data from file descriptor FD, and put the result in the buffers described by VECTOR, which is a vector of COUNT `struct iovec's. The buffers are filled in the order specified. Operates just like `read' (see ) except that data are put in VECTOR instead of a contiguous buffer. */ int DEFUN(readv, (fd, vector, count), int fd AND CONST struct iovec *vector AND size_t count) { char *buffer; size_t bytes; int bytes_read; register size_t i; /* Find the total number of bytes to be read. */ bytes = 0; for (i = 0; i < count; ++i) bytes += vector[i].iov_len; /* Allocate a temporary buffer to hold the data. */ buffer = (char *) __alloca(bytes); /* Read the data. */ bytes_read = read(fd, buffer, bytes); if (bytes_read < 0) return -1; if (bytes_read == 0) return 0; /* Copy the data from BUFFER into the memory specified by VECTOR. */ bytes = bytes_read; for (i = 0; i < count; ++i) { #define min(a, b) ((a) > (b) ? (b) : (a)) size_t copy = min(vector[i].iov_len, bytes); (void) memcpy((PTR) vector[i].iov_base, (PTR) buffer, copy); buffer += copy; bytes -= copy; if (bytes == 0) break; } return bytes_read; } ./libc-linux/posix/writev.c100644 1676 334 4020 5502251150 13731 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 #include #include /* Write data pointed by the buffers described by VECTOR, which is a vector of COUNT `struct iovec's, to file descriptor FD. The data is written in the order specified. Operates just like `write' (see ) except that the data are taken from VECTOR instead of a contiguous buffer. */ int DEFUN(writev, (fd, vector, count), int fd AND CONST struct iovec *vector AND size_t count) { char *buffer; register char *bp; size_t bytes, to_copy; register size_t i; /* Find the total number of bytes to be written. */ bytes = 0; for (i = 0; i < count; ++i) bytes += vector[i].iov_len; if (bytes == 0) return 0; /* Allocate a temporary buffer to hold the data. */ buffer = (char *) __alloca(bytes); /* Copy the data into BUFFER. */ to_copy = bytes; bp = buffer; for (i = 0; i < count; ++i) { #define min(a, b) ((a) > (b) ? (b) : (a)) size_t copy = min(vector[i].iov_len, to_copy); (void) memcpy((PTR) bp, (PTR) vector[i].iov_base, copy); bp += copy; to_copy -= copy; if (bytes == 0) break; } return write(fd, buffer, bytes); } ./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/mktemp.c100644 1676 334 3422 5342745241 13726 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 #include /* Generate a unique temporary file name from TEMPLATE. The last six characters of TEMPLATE must be "XXXXXX"; they are replaced with a string that makes the filename unique. */ char * DEFUN(mktemp, (template), char *template) { static CONST char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; CONST char *ptr = letters; pid_t pid = __getpid(); size_t len; struct stat statbuf; len = strlen(template); if (len < 6 || strcmp(&template[len - 6], "XXXXXX")) { errno = EINVAL; return NULL; } if (sprintf (&template[len - 5], "%.5u", (unsigned int) pid % 100000) != 5) return NULL; while (*ptr != '\0') { template[len - 6] = *ptr++; if (__stat(template, &statbuf) < 0 && errno == ENOENT) return template; } return NULL; } ./libc-linux/posix/getcwd.c100644 1676 334 12660 5355451610 13730 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 #include #include #include #include #include #include #include #ifdef __linux__ #define d_namlen d_reclen #define d_fileno d_ino #define STAT(x,y) lstat((x),(y)) #else #define STAT(x,y) stat((x),(y)) #endif /* Get the pathname of the current working directory, and put it in SIZE bytes of BUF. Returns NULL if the directory couldn't be determined or SIZE was too small. If successful, returns BUF. In GNU, if BUF is NULL, an array is allocated with `malloc'; the array is SIZE bytes long, unless SIZE <= 0, in which case it is as big as necessary. */ char * DEFUN(getcwd, (buf, size), char *buf AND size_t size) { static CONST char dots[] = "../../../../../../../../../../../../../../../../../../../../../../../\ ../../../../../../../../../../../../../../../../../../../../../../../../../../\ ../../../../../../../../../../../../../../../../../../../../../../../../../.."; CONST char *dotp, *dotlist; size_t dotsize; dev_t rootdev, thisdev; ino_t rootino, thisino; char *path; register char *pathp; struct stat st; if (size == 0) { if (buf != NULL) { errno = EINVAL; return NULL; } #ifndef PATH_MAX #define PATH_MAX 1024 #endif size = PATH_MAX + 1; } if (buf != NULL) path = buf; else { path = malloc (size); if (path == NULL) return NULL; } pathp = path + size; *--pathp = '\0'; if (STAT (".", &st) < 0) return NULL; thisdev = st.st_dev; thisino = st.st_ino; if (STAT ("/", &st) < 0) return NULL; rootdev = st.st_dev; rootino = st.st_ino; dotsize = sizeof (dots) - 1; dotp = &dots[sizeof (dots)]; dotlist = dots; while (!(thisdev == rootdev && thisino == rootino)) { register DIR *dirstream; register struct dirent *d; dev_t dotdev; ino_t dotino; char mount_point; /* Look at the parent directory. */ if (dotp == dotlist) { /* My, what a deep directory tree you have, Grandma. */ char *new; if (dotlist == dots) { new = malloc (dotsize * 2 + 1); if (new == NULL) return NULL; memcpy (new, dots, dotsize); } else { new = realloc ((PTR) dotlist, dotsize * 2 + 1); if (new == NULL) goto lose; } memcpy (&new[dotsize], new, dotsize); dotp = &new[dotsize]; dotsize *= 2; new[dotsize] = '\0'; dotlist = new; } dotp -= 3; /* Figure out if this directory is a mount point. */ if (STAT (dotp, &st) < 0) goto lose; dotdev = st.st_dev; dotino = st.st_ino; mount_point = dotdev != thisdev; /* Search for the last directory. */ dirstream = opendir (dotp); if (dirstream == NULL) goto lose; while ((d = readdir (dirstream)) != NULL) { if (d->d_name[0] == '.' && (d->d_namlen == 1 || (d->d_namlen == 2 && d->d_name[1] == '.'))) continue; if (mount_point || d->d_fileno == thisino) { char *name = __alloca (dotlist + dotsize - dotp + 1 + d->d_namlen + 1); memcpy (name, dotp, dotlist + dotsize - dotp); name[dotlist + dotsize - dotp] = '/'; memcpy (&name[dotlist + dotsize - dotp + 1], d->d_name, d->d_namlen + 1); if (STAT (name, &st) < 0) { int save = errno; (void) closedir (dirstream); errno = save; goto lose; } if (st.st_dev == thisdev && st.st_ino == thisino) break; } } if (d == NULL) { int save = errno; (void) closedir (dirstream); errno = save; goto lose; } else { if (pathp - path < d->d_namlen + 1) { if (buf != NULL) { (void) closedir (dirstream); errno = ERANGE; goto lose; } else { size *= 2; buf = realloc (path, size); if (buf == NULL) { (void) closedir (dirstream); free (path); errno = ENOMEM; /* closedir might have changed it. */ goto lose; } pathp = &buf[pathp - path]; path = buf; } } pathp -= d->d_namlen; (void) memcpy (pathp, d->d_name, d->d_namlen); (void) closedir (dirstream); *--pathp = '/'; } thisdev = dotdev; thisino = dotino; } if (pathp == &path[size - 1]) *--pathp = '/'; if (dotlist != dots) free ((PTR) dotlist); return memmove (path, pathp, path + size - pathp); lose: if (dotlist != dots) free ((PTR) dotlist); /* XXX need to free path iff it was mallocated here and for some other early returns. Should handle all cleanups (of path, dots and dirstream) by jumping here. */ return NULL; } ./libc-linux/posix/killpg.c100644 1676 334 2245 5266156263 13722 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 /* Send SIG to all processes in process group PGRP. If PGRP is zero, send SIG to all processes in the current process's process group. */ int DEFUN(killpg, (pgrp, sig), int pgrp AND int sig) { if (pgrp < 0) { errno = EINVAL; return -1; } return __kill (- pgrp, sig); } ./libc-linux/posix/raise.c100644 1676 334 1734 5266156555 13551 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 /* Raise the signal SIG. */ int DEFUN(raise, (sig), int sig) { return __kill(__getpid(), sig); } ./libc-linux/posix/ttyname.c100644 1676 334 4463 5420343542 14113 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 #include #include #include #include #ifdef linux #define d_fileno d_ino #define d_namlen d_reclen #endif char *__ttyname = NULL; /* Return the pathname of the terminal FD is open on, or NULL on errors. The returned storage is good only until the next call to this function. */ char * DEFUN(ttyname, (fd), int fd) { static CONST char dev[] = "/dev"; static char *name; static size_t namelen = 0; struct stat st; dev_t mydev; ino_t myino; DIR *dirstream; struct dirent *d; int save = errno; if (fstat (fd, &st) < 0) return NULL; mydev = st.st_dev; myino = st.st_ino; dirstream = opendir (dev); if (dirstream == NULL) return NULL; while ((d = readdir (dirstream)) != NULL) if (d->d_fileno == myino) { if (sizeof (dev) + d->d_namlen + 1 > namelen) { free (name); namelen = 2 * (sizeof (dev) + d->d_namlen + 1); /* Big enough. */ name = malloc (namelen); if (! name) return NULL; (void) memcpy (name, dev, sizeof (dev) - 1); name[sizeof (dev) - 1] = '/'; } (void) memcpy (&name[sizeof (dev)], d->d_name, d->d_namlen + 1); if (stat (name, &st) == 0 && st.st_dev == mydev) { (void) closedir (dirstream); __ttyname = name; errno = save; return name; } } (void) closedir (dirstream); errno = save; return NULL; } ./libc-linux/posix/tcflush.c100644 1676 334 2124 5301561263 14072 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 #include #include #include #include #include /* Flush pending data on FD. */ int DEFUN(tcflush, (fd, queue_selector), int fd AND int queue_selector) { return __ioctl (fd, TCFLSH, queue_selector); } ./libc-linux/posix/tcsendbrk.c100644 1676 334 3033 5270373443 14407 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 #include #include #include #include #include #include /* Send zero bits on FD. */ int DEFUN(tcsendbreak, (fd, duration), int fd AND int duration) { /* The break lasts 0.25 to 0.5 seconds if DURATION is zero, and an implementation-defined period if DURATION is nonzero. We define a positive DURATION to be number of milliseconds to break. */ if (duration <= 0) return __ioctl (fd, TCSBRK, 0); /* ioctl can't send a break of any other duration for us. This could be changed to use trickery (e.g. lower speed and send a '\0') to send the break, but for now just return an error. */ errno = EINVAL; return -1; } ./libc-linux/posix/system.c100644 1676 334 6470 5352675415 13771 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 #include #include #include #include #ifndef HAVE_GNU_LD #define __environ environ #endif #define SHELL_PATH "/bin/sh" /* Path of the shell. */ #define SHELL_NAME "sh" /* Name to give it. */ #ifndef FORK #define FORK __fork #endif /* Execute LINE as a shell command, returning its status. */ int DEFUN(system, (line), register CONST char *line) { int status, save; pid_t pid; struct sigaction sa, intr, quit; sigset_t block, omask; if (line == NULL) return 1; sa.sa_handler = SIG_IGN; sa.sa_flags = 0; __sigemptyset (&sa.sa_mask); if (__sigaction (SIGINT, &sa, &intr) < 0) return -1; if (__sigaction (SIGQUIT, &sa, &quit) < 0) { save = errno; (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); errno = save; return -1; } __sigemptyset (&block); __sigaddset (&block, SIGCHLD); save = errno; if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) { if (errno == ENOSYS) errno = save; else { save = errno; (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); (void) __sigaction(SIGQUIT, &quit, (struct sigaction *) NULL); errno = save; return -1; } } pid = FORK (); if (pid == (pid_t) 0) { /* Child side. */ CONST char *new_argv[4]; new_argv[0] = SHELL_NAME; new_argv[1] = "-c"; new_argv[2] = line; new_argv[3] = NULL; /* Restore the signals. */ (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); (void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL); /* Exec the shell. */ (void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ); _exit (127); } else if (pid < (pid_t) 0) /* The fork failed. */ status = -1; else /* Parent side. */ #ifdef NO_WAITPID { pid_t child; do { child = __wait (&status); if (child <= -1) { status = -1; break; } } while (child != pid); } #else if (__waitpid (pid, &status, 0) != pid) status = -1; #endif save = errno; if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) { if (errno == ENOSYS) errno = save; else return -1; } return status; } ./libc-linux/posix/execve.c100644 1676 334 2040 5263733655 13713 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 #undef execve function_alias(execve, __execve, int, (p, a, e), DEFUN(execve, (p, a, e), CONST char *p AND char *CONST a[] AND char *CONST e[])) ./libc-linux/posix/environ.c100644 1676 334 1666 5270371537 14124 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 #undef environ #include #ifdef HAVE_GNU_LD symbol_alias(__environ, environ); #endif ./libc-linux/posix/fork.c100644 1676 334 1721 5263734707 13401 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 #undef fork function_alias(fork, __fork, __pid_t, (), DEFUN_VOID(fork)) ./libc-linux/posix/getegid.c100644 1676 334 1726 5263735465 14057 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 #undef getegid function_alias(getegid, __getegid, __gid_t, (), DEFUN_VOID(getegid)) ./libc-linux/posix/geteuid.c100644 1676 334 1726 5263735465 14075 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 #undef geteuid function_alias(geteuid, __geteuid, __uid_t, (), DEFUN_VOID(geteuid)) ./libc-linux/posix/getgid.c100644 1676 334 1722 5263735465 13706 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 #undef getgid function_alias(getgid, __getgid, __gid_t, (), DEFUN_VOID(getgid)) ./libc-linux/posix/getpid.c100644 1676 334 1731 5263735465 13717 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 #undef getpid function_alias(getpid, __getpid, __pid_t, (), DEFUN_VOID(getpid)) ./libc-linux/posix/getppid.c100644 1676 334 1726 5263735465 14103 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 #undef getppid function_alias(getppid, __getppid, __pid_t, (), DEFUN_VOID(getppid)) ./libc-linux/posix/getuid.c100644 1676 334 1722 5263735465 13724 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 #undef getuid function_alias(getuid, __getuid, __uid_t, (), DEFUN_VOID(getuid)) ./libc-linux/posix/getgrps.c100644 1676 334 2022 5263735525 14105 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 #undef getgroups function_alias(getgroups, __getgroups, int, (size, list), DEFUN(getgroups, (size, list), int size AND __gid_t *list)) ./libc-linux/posix/fpathconf.c100644 1676 334 2005 5263735323 14377 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 #undef fpathconf function_alias(fpathconf, __fpathconf, long int, (fd, name), DEFUN(fpathconf, (fd, name), int fd AND int name)) ./libc-linux/posix/setsid.c100644 1676 334 1731 5263736612 13731 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 #undef setsid function_alias(setsid, __setsid, __pid_t, (), DEFUN_VOID(setsid)) ./libc-linux/posix/setuid.c100644 1676 334 1750 5263736612 13734 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 #undef setuid function_alias(setuid, __setuid, int, (uid), DEFUN(setuid, (uid), __uid_t uid)) ./libc-linux/posix/times.c100644 1676 334 1750 5263737020 13552 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 #undef times function_alias(times, __times, clock_t, (buf), DEFUN(times, (buf), struct tms *buf)) ./libc-linux/posix/wait.c100644 1676 334 1737 5263737062 13410 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 #undef wait function_alias(wait, __wait, __pid_t, (s), DEFUN(wait, (s), __WAIT_STATUS s)) ./libc-linux/posix/wait3.c100644 1676 334 2034 5263737062 13462 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 #include #undef wait3 function_alias(wait3, __wait3, pid_t, (s, o, u), DEFUN(wait3, (s, o, u), union wait *s AND int o AND PTR u)) ./libc-linux/posix/wait4.c100644 1676 334 2065 5263737062 13467 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 #include #undef wait4 function_alias(wait4, __wait4, pid_t, (p, s, o, u), DEFUN(wait4, (p, s, o, u), pid_t p AND union wait *s AND int o AND PTR u)) ./libc-linux/posix/waitpid.c100644 1676 334 2045 5263737062 14076 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 #include #undef waitpid function_alias(waitpid, __waitpid, pid_t, (pid, s, o), DEFUN(waitpid, (pid, s, o), pid_t pid AND int *s AND int o)) ./libc-linux/posix/tcsetattr.c100644 1676 334 633 5270373455 14433 0ustar hjlisl#include #include #include int tcsetattr(int fildes, int optional_actions, struct termios *termios_p) { switch(optional_actions) { case TCSANOW: return __ioctl(fildes, TCSETS, termios_p); case TCSADRAIN: return __ioctl(fildes, TCSETSW, termios_p); case TCSAFLUSH: return __ioctl(fildes, TCSETSF, termios_p); default: errno = EINVAL; return -1; } } ./libc-linux/posix/tcgetattr.c100644 1676 334 2044 5266171257 14436 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 #undef tcgetattr function_alias(tcgetattr, __tcgetattr, int, (fd, termios_p), DEFUN(tcgetattr, (fd, termios_p), int fd AND struct termios *termios_p)) ./libc-linux/posix/cfmakeraw.c100644 1676 334 6013 5366041130 14360 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. */ /* Modified by Al Clark 11/12/92 to no assume any initial conditions. * Also, compile time variations "#define USEPARITY" to leave parity alone, * and "define NOINTR" to disable interrupt on BREAK condition. * GNU C Library terms still apply. */ #include #include void DEFUN(cfmakeraw, (t), struct termios *t) { /* I changed it to the current form according to the suggestions * from Bruce Evans. Thanks Bruce. Please report the problems to * H.J. Lu (hlu@eecs.wsu.edu). */ #if 1 /* VMIN = 0 means non-blocking for Linux */ t->c_cc[VMIN] = 1; t->c_cc[VTIME] = 1; /* clear some bits with &= ~(bits), set others with |= */ t->c_cflag &= ~(CSIZE|PARENB|CSTOPB); t->c_cflag |= (CS8|HUPCL|CREAD); t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|INPCK|ISTRIP); t->c_iflag &= ~(INLCR|IGNCR|ICRNL|IXON|IXOFF); t->c_iflag |= (BRKINT|IGNPAR); t->c_oflag &= ~(OPOST|OLCUC|OCRNL|ONOCR|ONLRET|OFILL|OFDEL); t->c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); t->c_oflag |= (ONLCR|NL0|CR0|TAB3|BS0|VT0|FF0); t->c_lflag &= ~(ISIG|ICANON|IEXTEN|ECHO|ECHOE|ECHOK|ECHONL); t->c_lflag &= ~(NOFLSH|XCASE); #if 1 t->c_lflag &= ~(ECHOPRT|ECHOCTL|ECHOKE); #else t->c_lflag |= (ECHOPRT|ECHOCTL|ECHOKE); #endif #else /* VMIN = 0 means non-blocking for Linux */ t->c_cc[VMIN] = 1; t->c_cc[VTIME] = 1; /* clear some bits with &= ~(bits), set others with |= */ #ifdef USEPARITY /* leave parity alone */ t->c_cflag &= ~(CSTOPB|CLOCAL|CRTSCTS); t->c_cflag |= (HUPCL|CREAD); #else /* normal full eight bit case */ t->c_cflag &= ~(CSIZE|PARENB|PARODD|CSTOPB|CLOCAL|CRTSCTS); t->c_cflag |= (CS8|HUPCL|CREAD); #endif t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|INPCK|ISTRIP); t->c_iflag &= ~(INLCR|IGNCR|ICRNL|IXON|IXOFF); #ifdef NOINTR t->c_iflag |= (IGNPAR); #else t->c_iflag |= (BRKINT|IGNPAR); #endif t->c_oflag &= ~(OPOST|OLCUC|OCRNL|ONOCR|ONLRET|OFILL|OFDEL); t->c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); t->c_oflag |= (ONLCR|NL0|CR0|TAB3|BS0|VT0|FF0); t->c_lflag &= ~(ISIG|ICANON|IEXTEN|ECHO|ECHOE|ECHOK|ECHONL); t->c_lflag &= ~(NOFLSH|XCASE|TOSTOP); t->c_lflag |= (ECHOPRT|ECHOCTL|ECHOKE); #endif } ./libc-linux/pwd/ 40755 1676 334 0 5550053612 11612 5ustar hjlisl./libc-linux/pwd/Makefile100644 1676 334 447 5515544401 13336 0ustar hjlisl# # Makefile for pwd functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules DIRS:= SRCS = fgetpwent.c getpw.c getpwent.c getpwnam.c getpwuid.c \ putpwent.c pwdopen.c pwdread.c #shadow.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIAESE= include $(TOPDIR)/Maketargets ./libc-linux/pwd/fgetpwent.c100644 1676 334 2315 5154331262 14057 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 #include #include /* Read one entry from the given stream. */ struct passwd * DEFUN(fgetpwent, (stream), FILE *stream) { static PTR info = NULL; if (info == NULL) { info = __pwdalloc(); if (info == NULL) return(NULL); } return(__pwdread(stream, info)); } ./libc-linux/pwd/getpw.c100644 1676 334 2733 5266735314 13220 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 #include /* Re-construct the password-file line for the given uid in the given buffer. This knows the format that the caller will expect, but this need not be the format of the password file. */ int DEFUN(getpw, (uid, buf), __uid_t uid AND register char *buf) { register struct passwd *p; if (buf == NULL) { errno = EINVAL; return -1; } p = getpwuid (uid); if (p == NULL) return -1; if (sprintf (buf, "%s:%s:%u:%u:%s:%s:%s", p->pw_name, p->pw_passwd, p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell) < 0) return -1; return 0; } ./libc-linux/pwd/getpwent.c100644 1676 334 3440 5446306405 13716 0ustar hjlisl/* LAST EDIT: Tue Mar 30 15:01:59 1993 by Swen Thümmler (swen) */ /* 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 #ifdef YP extern void __yp_clearpwflag __P((void)) ; extern struct passwd * DEFUN(__pwdread_noyp, (stream, p), FILE *stream AND PTR CONST p) ; #endif static FILE *stream = NULL; /* Rewind the stream. */ void DEFUN_VOID(setpwent) { if (stream != NULL) rewind(stream); #ifdef YP __yp_clearpwflag(); #endif } /* Close the stream. */ void DEFUN_VOID(endpwent) { if (stream != NULL) { (void) fclose(stream); stream = NULL; } #ifdef YP __yp_clearpwflag(); #endif } /* Return one entry from the password file. */ struct passwd * DEFUN_VOID(getpwent) { static PTR info = NULL; if (info == NULL) { info = __pwdalloc(); if (info == NULL) return(NULL); } if (stream == NULL) { stream = __pwdopen(); if (stream == NULL) return(NULL); } return(__pwdread(stream, info)); } ./libc-linux/pwd/getpwnam.c100644 1676 334 4725 5446306410 13706 0ustar hjlisl/* LAST EDIT: Wed Mar 31 06:06:41 1993 by Swen Thümmler (swen) */ /* 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 #ifdef YP #include #include #include typedef struct { char *buf; size_t buflen; struct passwd p; } pwdread_info; extern int __ypparsepwd __P((struct passwd *, char *)) ; extern char *__yp_getdomain(void); extern struct passwd * DEFUN(__pwdread_noyp, (stream, p), FILE *stream AND PTR CONST p) ; #endif /* Search for an entry with a matching name. */ struct passwd * DEFUN(getpwnam, (name), register CONST char *name) { static PTR info = NULL; register FILE *stream; register struct passwd *p; if (info == NULL) { info = __pwdalloc(); if (info == NULL) return(NULL); } stream = __pwdopen(); if (stream == NULL) return(NULL); #ifdef YP while ((p = __pwdread_noyp(stream, info)) != NULL) if (!strcmp(p->pw_name, name)) break; (void) fclose(stream); if (p == NULL) { char *indomain ; char *outkey = NULL ; int r, outkeylen ; p = &((pwdread_info *) info)->p ; indomain = __yp_getdomain() ; if (indomain) { r = yp_match(indomain, "passwd.byname", name, strlen(name), &outkey, &outkeylen) ; switch (r) { case 0: (void)__ypparsepwd(p, outkey) ; break ; default: free(outkey) ; outkey = NULL; p = NULL ; } } else p = NULL ; } #else while ((p = __pwdread(stream, info)) != NULL) if (!strcmp(p->pw_name, name)) break; (void) fclose(stream); #endif /* YP */ return(p); } ./libc-linux/pwd/getpwuid.c100644 1676 334 4755 5446306412 13721 0ustar hjlisl/* LAST EDIT: Wed Mar 31 06:07:51 1993 by Swen Thümmler (swen) */ /* 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 #ifdef YP #include #include #include typedef struct { char *buf; size_t buflen; struct passwd p; } pwdread_info; extern int __ypparsepwd __P((struct passwd *, char *)) ; extern char *__yp_getdomain __P((void)) ; extern struct passwd * DEFUN(__pwdread_noyp, (stream, p), FILE *stream AND PTR CONST p) ; #endif /* Search for an entry with a matching uid. */ struct passwd * DEFUN(getpwuid, (uid), register uid_t uid) { static PTR info; register FILE *stream; register struct passwd *p; if (info == NULL) { info = __pwdalloc(); if (info == NULL) return(NULL); } stream = __pwdopen(); if (stream == NULL) return(NULL); #ifdef YP while ((p = __pwdread_noyp(stream, info)) != NULL) if (p->pw_uid == uid) break; (void) fclose(stream); if (p == NULL) { char *indomain ; char *outkey = NULL ; int r, outkeylen ; p = &((pwdread_info *) info)->p ; indomain = __yp_getdomain() ; if (indomain) { char uidbuf[20] ; sprintf(uidbuf, "%d", uid) ; r = yp_match(indomain, "passwd.byuid", uidbuf, strlen(uidbuf), &outkey, &outkeylen) ; switch (r) { case 0: (void)__ypparsepwd(p, outkey) ; break ; default: free(outkey) ; outkey = NULL ; p = NULL ; } } else p = NULL ; } #else while ((p = __pwdread(stream, info)) != NULL) if (p->pw_uid == uid) break; (void) fclose(stream); #endif return(p); } ./libc-linux/pwd/putpwent.c100644 1676 334 2512 5172652745 13755 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 #include /* Write an entry to the given stream. This must know the format of the password file. */ int DEFUN(putpwent, (p, stream), register CONST struct passwd *p AND FILE *stream) { if (p == NULL || stream == NULL) { errno = EINVAL; return(-1); } if (fprintf(stream, "%s:%s:%u:%u:%s:%s:%s\n", p->pw_name, p->pw_passwd, p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell) < 0) return(-1); return(0); } ./libc-linux/pwd/pwdopen.c100644 1676 334 1760 5154331263 13534 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 /* Return a new stream open on the password file. */ FILE * DEFUN_VOID(__pwdopen) { return(fopen("/etc/passwd", "r")); } ./libc-linux/pwd/pwdread.c100644 1676 334 15261 5511750363 13532 0ustar hjlisl/* LAST EDIT: Wed Mar 31 06:28:54 1993 by Swen Thümmler (swen) */ /* 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 #include #include #include #include #include #include #ifndef NO_SHADOW #include "shadow.h" #endif #ifdef YP #include #include #include extern int __yp_check __P((char **)) ; void __yp_setpwflag __P((void)) ; void __yp_clearpwflag __P((void)) ; int __yp_getpwmode __P((void)) ; char * __yp_getdomain __P((void)) ; int __ypparsepwd __P((struct passwd *, char *)) ; static int __yp_getline __P((char **, size_t *)) ; struct passwd * DEFUN(__pwdread_noyp, (stream, p), FILE *stream AND PTR CONST p) ; static char *__ypcurrent = NULL ; static char *__ypdomain = NULL ; static int __ypcurrentlen = 0 ; static int __ypmode = 0 ; static int __noyp = 0 ; static char line[1024] ; void __yp_setpwflag(void) { __ypmode = 1 ; } void __yp_clearpwflag(void) { __ypmode = 0 ; __ypcurrent = NULL ; } int __yp_getpwmode(void) { return(__ypmode) ; } char * __yp_getdomain(void) { if(!__ypdomain) { if(__yp_check(&__ypdomain) == 0) { return NULL ; } } return(__ypdomain); } int __ypparsepwd(struct passwd *pw, char *s) { char *start, *end; start = s ; end = strchr(start, ':') ; if (end == NULL) return (-1) ; *end = 0 ; pw->pw_name = start ; start = end + 1 ; end = strchr(start, ':') ; if (end == NULL) return (-1) ; *end = 0 ; pw->pw_passwd = start ; start = end + 1 ; end = strchr(start, ':') ; if (end == NULL) return (-1) ; *end = 0 ; pw->pw_uid = atoi(start); start = end + 1 ; end = strchr(start, ':') ; if (end == NULL) return (-1) ; *end = 0 ; pw->pw_gid = atoi(start); start = end + 1 ; end = strchr(start, ':') ; if (end == NULL) return (-1) ; *end = 0 ; pw->pw_gecos = start ; start = end + 1 ; end = strchr(start, ':') ; if (end == NULL) return (-1) ; *end = 0 ; pw->pw_dir = start ; start = end + 1 ; end = strchr(start, '\n') ; if (end != NULL) *end = 0 ; pw->pw_shell = start ; return 0; } static int DEFUN(__yp_getline, (buf, buflen), char **buf AND size_t *buflen) { char *key, *data; int keylen, datalen; int r; if(!__ypdomain) { if( __yp_check(&__ypdomain) == 0) return(-1); } if(__ypcurrent) { r = yp_next(__ypdomain, "passwd.byname", __ypcurrent, __ypcurrentlen, &key, &keylen, &data, &datalen); free(__ypcurrent); __ypcurrent = NULL; /*printf("yp_next %d\n", r);*/ switch(r) { case 0: break; default: __ypcurrent = NULL; __ypmode = 0; free(data); data = NULL; return(-1); } __ypcurrent = key; __ypcurrentlen = keylen; bcopy(data, line, datalen); free(data); data = NULL; } else { r = yp_first(__ypdomain, "passwd.byname", &__ypcurrent, &__ypcurrentlen, &data, &datalen); /*printf("yp_first %d\n", r);*/ switch(r) { case 0: break; default: __ypmode = 0; free(data); return(-1); } bcopy(data, line, datalen); free(data); data = NULL; } line[datalen] = '\0'; /*printf("line = %s\n", line);*/ *buf = line; *buflen = datalen; return(0); } #endif /* YP */ /* This is the function that all the others are based on. The format of the password file is known only here. */ /* Structure containing info kept by each __pwdread caller. */ typedef struct { char *buf; size_t buflen; struct passwd p; } pwdread_info; /* Return a chunk of memory containing a pre-initialized `pwdread_info'. */ PTR DEFUN_VOID(__pwdalloc) { pwdread_info *info = (PTR) malloc (sizeof(pwdread_info)); if (info == NULL) return NULL; info->buf = NULL; info->buflen = 0; return info; } /* Read a password entry from STREAM, filling in P. */ struct passwd * DEFUN(__pwdread, (stream, p), FILE *stream AND PTR CONST p) { register pwdread_info *CONST info = (pwdread_info *) p; char *start, *end; /* Idiocy checks. */ if (stream == NULL) { errno = EINVAL; return NULL; } again: do #ifdef YP if (__ypmode) { if (__yp_getline (&info->buf, &info->buflen) == -1) return NULL; } else #endif /* YP */ if (__getline (&info->buf, &info->buflen, stream) == -1) return NULL; while (info->buf[0] == '#'); start = info->buf; end = strchr (start, ':'); if (end == NULL) return NULL; *end = '\0'; info->p.pw_name = start; start = end + 1; end = strchr (start, ':'); if (end == NULL) return NULL; *end = '\0'; info->p.pw_passwd = start; #ifndef NO_SHADOW { struct spwd *spw = getspnam (info->p.pw_name); if (spw) info->p.pw_passwd = spw->sp_pwdp; } #endif info->p.pw_uid = (uid_t) strtol (end + 1, &end, 10); if (*end != ':') return NULL; info->p.pw_gid = (gid_t) strtol (end + 1, &end, 10); if (*end != ':') return NULL; start = end + 1; end = strchr (start, ':'); if (end == NULL) return NULL; *end = '\0'; info->p.pw_gecos = start; start = end + 1; end = strchr (start, ':'); if (end == NULL) return NULL; *end = '\0'; info->p.pw_dir = start; start = end + 1; #ifdef YP if (__ypmode) info->p.pw_shell = start; else { end = strchr (start, '\n'); if (end == NULL) return NULL; *end = '\0'; info->p.pw_shell = start; } if ((__noyp != 1) && (strcmp(info->p.pw_name,"+") == 0)) { __ypmode = 1; goto again; } #else end = strchr (start, '\n'); if (end == NULL) return NULL; *end = '\0'; info->p.pw_shell = start; #endif /* YP */ return &info->p; } #ifdef YP struct passwd * DEFUN(__pwdread_noyp, (stream, p), FILE *stream AND PTR CONST p) { struct passwd *pwptr ; __noyp = 1 ; __ypmode = 0 ; pwptr = __pwdread(stream, p); __noyp = 0 ; return(pwptr) ; } #endif ./libc-linux/pwd/shadow.c100644 1676 334 11760 5505466654 13403 0ustar hjlisl/* * Copyright 1989, 1990, 1991, 1992, John F. Haugh II * All rights reserved. * * Permission is granted to copy and create derivative works for any * non-commercial purpose, provided this copyright notice is preserved * in all copies of source code, or included in human readable form * and conspicuously displayed on all copies of object code or * distribution media. */ #include #include #include #include #include "shadow.h" #if 0 static char sccsid[] = "@(#)shadow.c 3.10 20:38:10 3/7/92"; #endif static FILE *shadow; static char *spwbuf = NULL; static struct spwd spwd; #define FIELDS 9 #define OFIELDS 5 #define MAXBUF BUFSIZ static void DEFUN_VOID(initmem) { if (spwbuf) return; spwbuf = (char *) malloc (MAXBUF + 1); } void DEFUN_VOID(setspent) { #undef TRUE #undef FALSE #define TRUE 1 #define FALSE 0 static char no_etc_shadow = FALSE; if (shadow) rewind (shadow); else if (!no_etc_shadow) no_etc_shadow = (shadow = fopen (SHADOW, "r")) ? FALSE : TRUE; } void DEFUN_VOID(endspent) { if (shadow) fclose (shadow); else shadow = NULL; } struct spwd * DEFUN(sgetspent, (string), CONST char *string) { char *fields[FIELDS]; char *cp; char *cpp; int i; initmem(); strncpy (spwbuf, string, MAXBUF); spwbuf[MAXBUF] = '\0'; if ((cp = strrchr (spwbuf, '\n'))) *cp = '\0'; for (cp = spwbuf, i = 0; *cp && i < FIELDS; i++) { fields[i] = cp; while (*cp && *cp != ':') cp++; if (*cp) *cp++ = '\0'; } if (i == FIELDS - 1) fields[i++] = cp; if (*cp || (i != FIELDS && i != OFIELDS)) return 0; spwd.sp_namp = fields[0]; spwd.sp_pwdp = fields[1]; if ((spwd.sp_lstchg = strtol (fields[2], &cpp, 10)) == 0 && *cpp) return 0; else if (fields[2][0] == '\0') spwd.sp_lstchg = -1; if ((spwd.sp_min = strtol (fields[3], &cpp, 10)) == 0 && *cpp) return 0; else if (fields[3][0] == '\0') spwd.sp_min = -1; if ((spwd.sp_max = strtol (fields[4], &cpp, 10)) == 0 && *cpp) return 0; else if (fields[4][0] == '\0') spwd.sp_max = -1; if (i == OFIELDS) { spwd.sp_warn = spwd.sp_inact = spwd.sp_expire = spwd.sp_flag = -1; return &spwd; } if ((spwd.sp_warn = strtol (fields[5], &cpp, 10)) == 0 && *cpp) return NULL; else if (fields[5][0] == '\0') spwd.sp_warn = -1; if ((spwd.sp_inact = strtol (fields[6], &cpp, 10)) == 0 && *cpp) return NULL; else if (fields[6][0] == '\0') spwd.sp_inact = -1; if ((spwd.sp_expire = strtol (fields[7], &cpp, 10)) == 0 && *cpp) return NULL; else if (fields[7][0] == '\0') spwd.sp_expire = -1; if ((spwd.sp_flag = strtol (fields[8], &cpp, 10)) == 0 && *cpp) return NULL; else if (fields[8][0] == '\0') spwd.sp_flag = -1; return &spwd; } struct spwd * DEFUN(fgetspent, (fp), FILE *fp) { char buf[BUFSIZ]; if (!fp) return NULL; if (fgets (buf, BUFSIZ, fp) == NULL) return NULL; return sgetspent (buf); } struct spwd * DEFUN_VOID(getspent) { if (!shadow) setspent (); return fgetspent (shadow); } struct spwd * DEFUN(getspnam, (name), CONST char *name) { struct spwd *sp; setspent (); while ((sp = getspent ()) != NULL) { if (strcmp (name, sp->sp_namp) == 0) return sp; } return NULL; } int DEFUN(putspent, (sp, fp), CONST struct spwd *sp AND FILE *fp) { int errors = 0; if (!fp || !sp) return -1; if (fprintf (fp, "%s:%s:", sp->sp_namp, sp->sp_pwdp) < 0) errors++; if (sp->sp_lstchg != -1) { if (fprintf (fp, "%ld:", sp->sp_lstchg) < 0) errors++; } else if (putc (':', fp) == EOF) errors++; if (sp->sp_min != -1) { if (fprintf (fp, "%ld:", sp->sp_min) < 0) errors++; } else if (putc (':', fp) == EOF) errors++; if (sp->sp_max != -1) { if (fprintf (fp, "%ld", sp->sp_max) < 0) errors++; } /* * See if the structure has any of the SVR4 fields in * it. If none of those fields have any data there is * no reason to write them out since they will be filled * in the same way when they are read back in. Otherwise * there is at least one SVR4 field that must be output. */ if (sp->sp_warn == -1 && sp->sp_inact == -1 && sp->sp_expire == -1 && sp->sp_flag == -1) { if (putc ('\n', fp) == EOF || errors) return -1; else return 0; } else if (putc (':', fp) == EOF) errors++; if (sp->sp_warn != -1) { if (fprintf (fp, "%ld:", sp->sp_warn) < 0) errors++; } else if (putc (':', fp) == EOF) errors++; if (sp->sp_inact != -1) { if (fprintf (fp, "%ld:", sp->sp_inact) < 0) errors++; } else if (putc (':', fp) == EOF) errors++; if (sp->sp_expire != -1) { if (fprintf (fp, "%ld:", sp->sp_expire) < 0) errors++; } else if (putc (':', fp) == EOF) errors++; if (sp->sp_flag != -1) { if (fprintf (fp, "%ld", sp->sp_flag) < 0) errors++; } if (putc ('\n', fp) == EOF) errors++; if (errors) return -1; else return 0; } ./libc-linux/regex/ 40755 1676 334 0 5550053673 12141 5ustar hjlisl./libc-linux/regex/Makefile100644 1676 334 333 5520467221 13650 0ustar hjlisl# # This is Makefile of GNU regex. # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules DIRS:= SRCS = regex.c # rx.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIAESE= include $(TOPDIR)/Maketargets ./libc-linux/regex/regex.c100644 1676 334 505320 5527064162 13560 0ustar hjlisl/* Extended regular expression matching and search library, version 0.12. (Implements POSIX draft P10003.2/D11.2, except for internationalization features.) Copyright (C) 1993 Free Software Foundation, Inc. This program 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 program 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* AIX requires this to be the first thing in the file. */ #if defined (_AIX) && !defined (REGEX_MALLOC) #pragma alloca #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #if defined(STDC_HEADERS) && !defined(emacs) #include #else /* We need this for `regex.h', and perhaps for the Emacs include files. */ #include #endif /* The `emacs' switch turns on certain matching commands that make sense only in Emacs. */ #ifdef emacs #include "lisp.h" #include "buffer.h" #include "syntax.h" /* Emacs uses `NULL' as a predicate. */ #undef NULL #else /* not emacs */ /* We used to test for `BSTRING' here, but only GCC and Emacs define `BSTRING', as far as I know, and neither of them use this code. */ #if HAVE_STRING_H || STDC_HEADERS #include #ifndef bcmp #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) #endif #ifndef bcopy #define bcopy(s, d, n) memcpy ((d), (s), (n)) #endif #ifndef bzero #define bzero(s, n) memset ((s), 0, (n)) #endif #else #include #endif #ifdef STDC_HEADERS #include #else char *malloc (); char *realloc (); #endif /* Define the syntax stuff for \<, \>, etc. */ /* This must be nonzero for the wordchar and notwordchar pattern commands in re_match_2. */ #ifndef Sword #define Sword 1 #endif #ifdef SYNTAX_TABLE extern char *re_syntax_table; #else /* not SYNTAX_TABLE */ /* How many characters in the character set. */ #define CHAR_SET_SIZE 256 static char re_syntax_table[CHAR_SET_SIZE]; static void init_syntax_once () { register int c; static int done = 0; if (done) return; bzero (re_syntax_table, sizeof re_syntax_table); for (c = 'a'; c <= 'z'; c++) re_syntax_table[c] = Sword; for (c = 'A'; c <= 'Z'; c++) re_syntax_table[c] = Sword; for (c = '0'; c <= '9'; c++) re_syntax_table[c] = Sword; re_syntax_table['_'] = Sword; done = 1; } #endif /* not SYNTAX_TABLE */ #define SYNTAX(c) re_syntax_table[c] #endif /* not emacs */ /* Get the interface, including the syntax bits. */ #include "regex.h" /* isalpha etc. are used for the character classes. */ #include /* Jim Meyering writes: "... Some ctype macros are valid only for character codes that isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when using /bin/cc or gcc but without giving an ansi option). So, all ctype uses should be through macros like ISPRINT... If STDC_HEADERS is defined, then autoconf has verified that the ctype macros don't need to be guarded with references to isascii. ... Defining isascii to 1 should let any compiler worth its salt eliminate the && through constant folding." */ #if ! defined (isascii) || defined (STDC_HEADERS) #undef isascii #define isascii(c) 1 #endif #ifdef isblank #define ISBLANK(c) (isascii (c) && isblank (c)) #else #define ISBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef isgraph #define ISGRAPH(c) (isascii (c) && isgraph (c)) #else #define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c)) #endif #define ISPRINT(c) (isascii (c) && isprint (c)) #define ISDIGIT(c) (isascii (c) && isdigit (c)) #define ISALNUM(c) (isascii (c) && isalnum (c)) #define ISALPHA(c) (isascii (c) && isalpha (c)) #define ISCNTRL(c) (isascii (c) && iscntrl (c)) #define ISLOWER(c) (isascii (c) && islower (c)) #define ISPUNCT(c) (isascii (c) && ispunct (c)) #define ISSPACE(c) (isascii (c) && isspace (c)) #define ISUPPER(c) (isascii (c) && isupper (c)) #define ISXDIGIT(c) (isascii (c) && isxdigit (c)) #ifndef NULL #define NULL 0 #endif /* We remove any previous definition of `SIGN_EXTEND_CHAR', since ours (we hope) works properly with all combinations of machines, compilers, `char' and `unsigned char' argument types. (Per Bothner suggested the basic approach.) */ #undef SIGN_EXTEND_CHAR #if __STDC__ #define SIGN_EXTEND_CHAR(c) ((signed char) (c)) #else /* not __STDC__ */ /* As in Harbison and Steele. */ #define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) #endif /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we use `alloca' instead of `malloc'. This is because using malloc in re_search* or re_match* could cause memory leaks when C-g is used in Emacs; also, malloc is slower and causes storage fragmentation. On the other hand, malloc is more portable, and easier to debug. Because we sometimes use alloca, some routines have to be macros, not functions -- `alloca'-allocated space disappears at the end of the function it is called in. */ #ifdef REGEX_MALLOC #define REGEX_ALLOCATE malloc #define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) #else /* not REGEX_MALLOC */ /* Emacs already defines alloca, sometimes. */ #ifndef alloca /* Make alloca work the best possible way. */ #ifdef __GNUC__ #define alloca __builtin_alloca #else /* not __GNUC__ */ #if HAVE_ALLOCA_H #include #else /* not __GNUC__ or HAVE_ALLOCA_H */ #ifndef _AIX /* Already did AIX, up at the top. */ char *alloca (); #endif /* not _AIX */ #endif /* not HAVE_ALLOCA_H */ #endif /* not __GNUC__ */ #endif /* not alloca */ #define REGEX_ALLOCATE alloca /* Assumes a `char *destination' variable. */ #define REGEX_REALLOCATE(source, osize, nsize) \ (destination = (char *) alloca (nsize), \ bcopy (source, destination, osize), \ destination) #endif /* not REGEX_MALLOC */ /* True if `size1' is non-NULL and PTR is pointing anywhere inside `string1' or just past its end. This works if PTR is NULL, which is a good thing. */ #define FIRST_STRING_P(ptr) \ (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) /* (Re)Allocate N items of type T using malloc, or fail. */ #define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) #define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) #define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t))) #define BYTEWIDTH 8 /* In bits. */ #define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) typedef char boolean; #define false 0 #define true 1 /* These are the command codes that appear in compiled regular expressions. Some opcodes are followed by argument bytes. A command code can specify any interpretation whatsoever for its arguments. Zero bytes may appear in the compiled regular expression. The value of `exactn' is needed in search.c (search_buffer) in Emacs. So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of `exactn' we use here must also be 1. */ typedef enum { no_op = 0, /* Followed by one byte giving n, then by n literal bytes. */ exactn = 1, /* Matches any (more or less) character. */ anychar, /* Matches any one char belonging to specified set. First following byte is number of bitmap bytes. Then come bytes for a bitmap saying which chars are in. Bits in each byte are ordered low-bit-first. A character is in the set if its bit is 1. A character too large to have a bit in the map is automatically not in the set. */ charset, /* Same parameters as charset, but match any character that is not one of those specified. */ charset_not, /* Start remembering the text that is matched, for storing in a register. Followed by one byte with the register number, in the range 0 to one less than the pattern buffer's re_nsub field. Then followed by one byte with the number of groups inner to this one. (This last has to be part of the start_memory only because we need it in the on_failure_jump of re_match_2.) */ start_memory, /* Stop remembering the text that is matched and store it in a memory register. Followed by one byte with the register number, in the range 0 to one less than `re_nsub' in the pattern buffer, and one byte with the number of inner groups, just like `start_memory'. (We need the number of inner groups here because we don't have any easy way of finding the corresponding start_memory when we're at a stop_memory.) */ stop_memory, /* Match a duplicate of something remembered. Followed by one byte containing the register number. */ duplicate, /* Fail unless at beginning of line. */ begline, /* Fail unless at end of line. */ endline, /* Succeeds if at beginning of buffer (if emacs) or at beginning of string to be matched (if not). */ begbuf, /* Analogously, for end of buffer/string. */ endbuf, /* Followed by two byte relative address to which to jump. */ jump, /* Same as jump, but marks the end of an alternative. */ jump_past_alt, /* Followed by two-byte relative address of place to resume at in case of failure. */ on_failure_jump, /* Like on_failure_jump, but pushes a placeholder instead of the current string position when executed. */ on_failure_keep_string_jump, /* Throw away latest failure point and then jump to following two-byte relative address. */ pop_failure_jump, /* Change to pop_failure_jump if know won't have to backtrack to match; otherwise change to jump. This is used to jump back to the beginning of a repeat. If what follows this jump clearly won't match what the repeat does, such that we can be sure that there is no use backtracking out of repetitions already matched, then we change it to a pop_failure_jump. Followed by two-byte address. */ maybe_pop_jump, /* Jump to following two-byte address, and push a dummy failure point. This failure point will be thrown away if an attempt is made to use it for a failure. A `+' construct makes this before the first repeat. Also used as an intermediary kind of jump when compiling an alternative. */ dummy_failure_jump, /* Push a dummy failure point and continue. Used at the end of alternatives. */ push_dummy_failure, /* Followed by two-byte relative address and two-byte number n. After matching N times, jump to the address upon failure. */ succeed_n, /* Followed by two-byte relative address, and two-byte number n. Jump to the address N times, then fail. */ jump_n, /* Set the following two-byte relative address to the subsequent two-byte number. The address *includes* the two bytes of number. */ set_number_at, wordchar, /* Matches any word-constituent character. */ notwordchar, /* Matches any char that is not a word-constituent. */ wordbeg, /* Succeeds if at word beginning. */ wordend, /* Succeeds if at word end. */ wordbound, /* Succeeds if at a word boundary. */ notwordbound /* Succeeds if not at a word boundary. */ #ifdef emacs ,before_dot, /* Succeeds if before point. */ at_dot, /* Succeeds if at point. */ after_dot, /* Succeeds if after point. */ /* Matches any character whose syntax is specified. Followed by a byte which contains a syntax code, e.g., Sword. */ syntaxspec, /* Matches any character whose syntax is not that specified. */ notsyntaxspec #endif /* emacs */ } re_opcode_t; /* Common operations on the compiled pattern. */ /* Store NUMBER in two contiguous bytes starting at DESTINATION. */ #define STORE_NUMBER(destination, number) \ do { \ (destination)[0] = (number) & 0377; \ (destination)[1] = (number) >> 8; \ } while (0) /* Same as STORE_NUMBER, except increment DESTINATION to the byte after where the number is stored. Therefore, DESTINATION must be an lvalue. */ #define STORE_NUMBER_AND_INCR(destination, number) \ do { \ STORE_NUMBER (destination, number); \ (destination) += 2; \ } while (0) /* Put into DESTINATION a number stored in two contiguous bytes starting at SOURCE. */ #define EXTRACT_NUMBER(destination, source) \ do { \ (destination) = *(source) & 0377; \ (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \ } while (0) #ifdef DEBUG static void extract_number _RE_ARGS((int *dest, unsigned char *source)); static void extract_number (dest, source) int *dest; unsigned char *source; { int temp = SIGN_EXTEND_CHAR (*(source + 1)); *dest = *source & 0377; *dest += temp << 8; } #ifndef EXTRACT_MACROS /* To debug the macros. */ #undef EXTRACT_NUMBER #define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) #endif /* not EXTRACT_MACROS */ #endif /* DEBUG */ /* Same as EXTRACT_NUMBER, except increment SOURCE to after the number. SOURCE must be an lvalue. */ #define EXTRACT_NUMBER_AND_INCR(destination, source) \ do { \ EXTRACT_NUMBER (destination, source); \ (source) += 2; \ } while (0) #ifdef DEBUG static void extract_number_and_incr _RE_ARGS((int *destination, unsigned char **source)); static void extract_number_and_incr (destination, source) int *destination; unsigned char **source; { extract_number (destination, *source); *source += 2; } #ifndef EXTRACT_MACROS #undef EXTRACT_NUMBER_AND_INCR #define EXTRACT_NUMBER_AND_INCR(dest, src) \ extract_number_and_incr (&dest, &src) #endif /* not EXTRACT_MACROS */ #endif /* DEBUG */ /* If DEBUG is defined, Regex prints many voluminous messages about what it is doing (if the variable `debug' is nonzero). If linked with the main program in `iregex.c', you can enter patterns and strings interactively. And if linked with the main program in `main.c' and the other test files, you can run the already-written tests. */ #ifdef DEBUG /* We use standard I/O for debugging. */ #include /* It is useful to test things that ``must'' be true when debugging. */ #include static int debug = 0; #define DEBUG_STATEMENT(e) e #define DEBUG_PRINT1(x) if (debug) printf (x) #define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) #define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) #define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4) #define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ if (debug) print_partial_compiled_pattern (s, e) #define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ if (debug) print_double_string (w, s1, sz1, s2, sz2) extern void printchar (); /* Print the fastmap in human-readable form. */ void print_fastmap (fastmap) char *fastmap; { unsigned was_a_range = 0; unsigned i = 0; while (i < (1 << BYTEWIDTH)) { if (fastmap[i++]) { was_a_range = 0; printchar (i - 1); while (i < (1 << BYTEWIDTH) && fastmap[i]) { was_a_range = 1; i++; } if (was_a_range) { printf ("-"); printchar (i - 1); } } } putchar ('\n'); } /* Print a compiled pattern string in human-readable form, starting at the START pointer into it and ending just before the pointer END. */ void print_partial_compiled_pattern (start, end) unsigned char *start; unsigned char *end; { int mcnt, mcnt2; unsigned char *p = start; unsigned char *pend = end; if (start == NULL) { printf ("(null)\n"); return; } /* Loop over pattern commands. */ while (p < pend) { printf ("%d:\t", p - start); switch ((re_opcode_t) *p++) { case no_op: printf ("/no_op"); break; case exactn: mcnt = *p++; printf ("/exactn/%d", mcnt); do { putchar ('/'); printchar (*p++); } while (--mcnt); break; case start_memory: mcnt = *p++; printf ("/start_memory/%d/%d", mcnt, *p++); break; case stop_memory: mcnt = *p++; printf ("/stop_memory/%d/%d", mcnt, *p++); break; case duplicate: printf ("/duplicate/%d", *p++); break; case anychar: printf ("/anychar"); break; case charset: case charset_not: { register int c, last = -100; register int in_range = 0; printf ("/charset [%s", (re_opcode_t) *(p - 1) == charset_not ? "^" : ""); assert (p + *p < pend); for (c = 0; c < 256; c++) if (c / 8 < *p && (p[1 + (c/8)] & (1 << (c % 8)))) { /* Are we starting a range? */ if (last + 1 == c && ! in_range) { putchar ('-'); in_range = 1; } /* Have we broken a range? */ else if (last + 1 != c && in_range) { printchar (last); in_range = 0; } if (! in_range) printchar (c); last = c; } if (in_range) printchar (last); putchar (']'); p += 1 + *p; } break; case begline: printf ("/begline"); break; case endline: printf ("/endline"); break; case on_failure_jump: extract_number_and_incr (&mcnt, &p); printf ("/on_failure_jump to %d", p + mcnt - start); break; case on_failure_keep_string_jump: extract_number_and_incr (&mcnt, &p); printf ("/on_failure_keep_string_jump to %d", p + mcnt - start); break; case dummy_failure_jump: extract_number_and_incr (&mcnt, &p); printf ("/dummy_failure_jump to %d", p + mcnt - start); break; case push_dummy_failure: printf ("/push_dummy_failure"); break; case maybe_pop_jump: extract_number_and_incr (&mcnt, &p); printf ("/maybe_pop_jump to %d", p + mcnt - start); break; case pop_failure_jump: extract_number_and_incr (&mcnt, &p); printf ("/pop_failure_jump to %d", p + mcnt - start); break; case jump_past_alt: extract_number_and_incr (&mcnt, &p); printf ("/jump_past_alt to %d", p + mcnt - start); break; case jump: extract_number_and_incr (&mcnt, &p); printf ("/jump to %d", p + mcnt - start); break; case succeed_n: extract_number_and_incr (&mcnt, &p); extract_number_and_incr (&mcnt2, &p); printf ("/succeed_n to %d, %d times", p + mcnt - start, mcnt2); break; case jump_n: extract_number_and_incr (&mcnt, &p); extract_number_and_incr (&mcnt2, &p); printf ("/jump_n to %d, %d times", p + mcnt - start, mcnt2); break; case set_number_at: extract_number_and_incr (&mcnt, &p); extract_number_and_incr (&mcnt2, &p); printf ("/set_number_at location %d to %d", p + mcnt - start, mcnt2); break; case wordbound: printf ("/wordbound"); break; case notwordbound: printf ("/notwordbound"); break; case wordbeg: printf ("/wordbeg"); break; case wordend: printf ("/wordend"); #ifdef emacs case before_dot: printf ("/before_dot"); break; case at_dot: printf ("/at_dot"); break; case after_dot: printf ("/after_dot"); break; case syntaxspec: printf ("/syntaxspec"); mcnt = *p++; printf ("/%d", mcnt); break; case notsyntaxspec: printf ("/notsyntaxspec"); mcnt = *p++; printf ("/%d", mcnt); break; #endif /* emacs */ case wordchar: printf ("/wordchar"); break; case notwordchar: printf ("/notwordchar"); break; case begbuf: printf ("/begbuf"); break; case endbuf: printf ("/endbuf"); break; default: printf ("?%d", *(p-1)); } putchar ('\n'); } printf ("%d:\tend of pattern.\n", p - start); } void print_compiled_pattern (bufp) struct re_pattern_buffer *bufp; { unsigned char *buffer = bufp->buffer; print_partial_compiled_pattern (buffer, buffer + bufp->used); printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated); if (bufp->fastmap_accurate && bufp->fastmap) { printf ("fastmap: "); print_fastmap (bufp->fastmap); } printf ("re_nsub: %d\t", bufp->re_nsub); printf ("regs_alloc: %d\t", bufp->regs_allocated); printf ("can_be_null: %d\t", bufp->can_be_null); printf ("newline_anchor: %d\n", bufp->newline_anchor); printf ("no_sub: %d\t", bufp->no_sub); printf ("not_bol: %d\t", bufp->not_bol); printf ("not_eol: %d\t", bufp->not_eol); printf ("syntax: %d\n", bufp->syntax); /* Perhaps we should print the translate table? */ } void print_double_string (where, string1, size1, string2, size2) const char *where; const char *string1; const char *string2; int size1; int size2; { unsigned this_char; if (where == NULL) printf ("(null)"); else { if (FIRST_STRING_P (where)) { for (this_char = where - string1; this_char < size1; this_char++) printchar (string1[this_char]); where = string2; } for (this_char = where - string2; this_char < size2; this_char++) printchar (string2[this_char]); } } #else /* not DEBUG */ #undef assert #define assert(e) #define DEBUG_STATEMENT(e) #define DEBUG_PRINT1(x) #define DEBUG_PRINT2(x1, x2) #define DEBUG_PRINT3(x1, x2, x3) #define DEBUG_PRINT4(x1, x2, x3, x4) #define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) #define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) #endif /* not DEBUG */ /* Set by `re_set_syntax' to the current regexp syntax to recognize. Can also be assigned to arbitrarily: each pattern buffer stores its own syntax, so it can be changed between regex compilations. */ reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; /* Specify the precise syntax of regexps for compilation. This provides for compatibility for various utilities which historically have different, incompatible syntaxes. The argument SYNTAX is a bit mask comprised of the various bits defined in regex.h. We return the old syntax. */ reg_syntax_t re_set_syntax (syntax) reg_syntax_t syntax; { reg_syntax_t ret = re_syntax_options; re_syntax_options = syntax; return ret; } /* This table gives an error message for each of the error codes listed in regex.h. Obviously the order here has to be same as there. */ static const char *re_error_msg[] = { NULL, /* REG_NOERROR */ "No match", /* REG_NOMATCH */ "Invalid regular expression", /* REG_BADPAT */ "Invalid collation character", /* REG_ECOLLATE */ "Invalid character class name", /* REG_ECTYPE */ "Trailing backslash", /* REG_EESCAPE */ "Invalid back reference", /* REG_ESUBREG */ "Unmatched [ or [^", /* REG_EBRACK */ "Unmatched ( or \\(", /* REG_EPAREN */ "Unmatched \\{", /* REG_EBRACE */ "Invalid content of \\{\\}", /* REG_BADBR */ "Invalid range end", /* REG_ERANGE */ "Memory exhausted", /* REG_ESPACE */ "Invalid preceding regular expression", /* REG_BADRPT */ "Premature end of regular expression", /* REG_EEND */ "Regular expression too big", /* REG_ESIZE */ "Unmatched ) or \\)", /* REG_ERPAREN */ }; /* Subroutine declarations and macros for regex_compile. */ static reg_errcode_t regex_compile _RE_ARGS((const char *pattern, size_t size, reg_syntax_t syntax, struct re_pattern_buffer *bufp)); static void store_op1 _RE_ARGS((re_opcode_t op, unsigned char *loc, int arg)); static void store_op2 _RE_ARGS((re_opcode_t op, unsigned char *loc, int arg1, int arg2)); static void insert_op1 _RE_ARGS((re_opcode_t op, unsigned char *loc, int arg, unsigned char *end)); static void insert_op2 _RE_ARGS((re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned char *end)); static boolean at_begline_loc_p _RE_ARGS((const char *pattern, const char *p, reg_syntax_t syntax)); static boolean at_endline_loc_p _RE_ARGS((const char *p, const char *pend, reg_syntax_t syntax)); static reg_errcode_t compile_range _RE_ARGS((const char **p_ptr, const char *pend, char *translate, reg_syntax_t syntax, unsigned char *b)); /* Fetch the next character in the uncompiled pattern---translating it if necessary. Also cast from a signed character in the constant string passed to us by the user to an unsigned char that we can use as an array index (in, e.g., `translate'). */ #define PATFETCH(c) \ do {if (p == pend) return REG_EEND; \ c = (unsigned char) *p++; \ if (translate) c = translate[c]; \ } while (0) /* Fetch the next character in the uncompiled pattern, with no translation. */ #define PATFETCH_RAW(c) \ do {if (p == pend) return REG_EEND; \ c = (unsigned char) *p++; \ } while (0) /* Go backwards one character in the pattern. */ #define PATUNFETCH p-- /* If `translate' is non-null, return translate[D], else just D. We cast the subscript to translate because some data is declared as `char *', to avoid warnings when a string constant is passed. But when we use a character as a subscript we must make it unsigned. */ #define TRANSLATE(d) (translate ? translate[(unsigned char) (d)] : (d)) /* Macros for outputting the compiled pattern into `buffer'. */ /* If the buffer isn't allocated when it comes in, use this. */ #define INIT_BUF_SIZE 32 /* Make sure we have at least N more bytes of space in buffer. */ #define GET_BUFFER_SPACE(n) \ while (b - bufp->buffer + (n) > bufp->allocated) \ EXTEND_BUFFER () /* Make sure we have one more byte of buffer space and then add C to it. */ #define BUF_PUSH(c) \ do { \ GET_BUFFER_SPACE (1); \ *b++ = (unsigned char) (c); \ } while (0) /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ #define BUF_PUSH_2(c1, c2) \ do { \ GET_BUFFER_SPACE (2); \ *b++ = (unsigned char) (c1); \ *b++ = (unsigned char) (c2); \ } while (0) /* As with BUF_PUSH_2, except for three bytes. */ #define BUF_PUSH_3(c1, c2, c3) \ do { \ GET_BUFFER_SPACE (3); \ *b++ = (unsigned char) (c1); \ *b++ = (unsigned char) (c2); \ *b++ = (unsigned char) (c3); \ } while (0) /* Store a jump with opcode OP at LOC to location TO. We store a relative address offset by the three bytes the jump itself occupies. */ #define STORE_JUMP(op, loc, to) \ store_op1 (op, loc, (int)((to) - (loc) - 3)) /* Likewise, for a two-argument jump. */ #define STORE_JUMP2(op, loc, to, arg) \ store_op2 (op, loc, (int)((to) - (loc) - 3), arg) /* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */ #define INSERT_JUMP(op, loc, to) \ insert_op1 (op, loc, (int)((to) - (loc) - 3), b) /* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */ #define INSERT_JUMP2(op, loc, to, arg) \ insert_op2 (op, loc, (int)((to) - (loc) - 3), arg, b) /* This is not an arbitrary limit: the arguments which represent offsets into the pattern are two bytes long. So if 2^16 bytes turns out to be too small, many things would have to change. */ /* Any other compiler which, like MSC, has allocation limit below 2^16 bytes will have to use approach similar to what was done below for MSC and drop MAX_BUF_SIZE a bit. Otherwise you may end up reallocating to 0 bytes. Such thing is not going to work too well. You have been warned!! */ #ifdef _MSC_VER /* Microsoft C 16-bit versions limit malloc to approx 65512 bytes. The REALLOC define eliminates a flurry of conversion warnings, but is not required. */ #define MAX_BUF_SIZE 65500L #define REALLOC(p,s) realloc((p), (size_t) (s)) #else #define MAX_BUF_SIZE (1L << 16) #define REALLOC realloc #endif /* Extend the buffer by twice its current size via realloc and reset the pointers that pointed into the old block to point to the correct places in the new one. If extending the buffer results in it being larger than MAX_BUF_SIZE, then flag memory exhausted. */ #define EXTEND_BUFFER() \ do { \ unsigned char *old_buffer = bufp->buffer; \ if (bufp->allocated == MAX_BUF_SIZE) \ return REG_ESIZE; \ bufp->allocated <<= 1; \ if (bufp->allocated > MAX_BUF_SIZE) \ bufp->allocated = MAX_BUF_SIZE; \ bufp->buffer = (unsigned char *) REALLOC(bufp->buffer, bufp->allocated);\ if (bufp->buffer == NULL) \ return REG_ESPACE; \ /* If the buffer moved, move all the pointers into it. */ \ if (old_buffer != bufp->buffer) \ { \ b = (b - old_buffer) + bufp->buffer; \ begalt = (begalt - old_buffer) + bufp->buffer; \ if (fixup_alt_jump) \ fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\ if (laststart) \ laststart = (laststart - old_buffer) + bufp->buffer; \ if (pending_exact) \ pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ } \ } while (0) /* Since we have one byte reserved for the register number argument to {start,stop}_memory, the maximum number of groups we can report things about is what fits in that byte. */ #define MAX_REGNUM 255 /* But patterns can have more than `MAX_REGNUM' registers. We just ignore the excess. */ typedef unsigned regnum_t; /* Macros for the compile stack. */ /* Since offsets can go either forwards or backwards, this type needs to be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ /* int may be not enough when sizeof(int) == 2 */ typedef long pattern_offset_t; typedef struct { pattern_offset_t begalt_offset; pattern_offset_t fixup_alt_jump; pattern_offset_t inner_group_offset; pattern_offset_t laststart_offset; regnum_t regnum; } compile_stack_elt_t; typedef struct { compile_stack_elt_t *stack; unsigned size; unsigned avail; /* Offset of next open position. */ } compile_stack_type; #define INIT_COMPILE_STACK_SIZE 32 #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) /* The next available element. */ #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) /* Set the bit for character C in a list. */ #define SET_LIST_BIT(c) \ (b[((unsigned char) (c)) / BYTEWIDTH] \ |= 1 << (((unsigned char) c) % BYTEWIDTH)) /* Get the next unsigned number in the uncompiled pattern. */ #define GET_UNSIGNED_NUMBER(num) \ { if (p != pend) \ { \ PATFETCH (c); \ while (ISDIGIT (c)) \ { \ if (num < 0) \ num = 0; \ num = num * 10 + c - '0'; \ if (p == pend) \ break; \ PATFETCH (c); \ } \ } \ } #define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ #define IS_CHAR_CLASS(string) \ (STREQ (string, "alpha") || STREQ (string, "upper") \ || STREQ (string, "lower") || STREQ (string, "digit") \ || STREQ (string, "alnum") || STREQ (string, "xdigit") \ || STREQ (string, "space") || STREQ (string, "print") \ || STREQ (string, "punct") || STREQ (string, "graph") \ || STREQ (string, "cntrl") || STREQ (string, "blank")) static boolean group_in_compile_stack _RE_ARGS((compile_stack_type compile_stack, regnum_t regnum)); /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. Returns one of error codes defined in `regex.h', or zero for success. Assumes the `allocated' (and perhaps `buffer') and `translate' fields are set in BUFP on entry. If it succeeds, results are put in BUFP (if it returns an error, the contents of BUFP are undefined): `buffer' is the compiled pattern; `syntax' is set to SYNTAX; `used' is set to the length of the compiled pattern; `fastmap_accurate' is zero; `re_nsub' is the number of subexpressions in PATTERN; `not_bol' and `not_eol' are zero; The `fastmap' and `newline_anchor' fields are neither examined nor set. */ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) const char *pattern; size_t size; reg_syntax_t syntax; struct re_pattern_buffer *bufp; { /* We fetch characters from PATTERN here. Even though PATTERN is `char *' (i.e., signed), we declare these variables as unsigned, so they can be reliably used as array indices. */ register unsigned char c, c1; /* A random tempory spot in PATTERN. */ const char *p1; /* Points to the end of the buffer, where we should append. */ register unsigned char *b; /* Keeps track of unclosed groups. */ compile_stack_type compile_stack; /* Points to the current (ending) position in the pattern. */ const char *p = pattern; const char *pend = pattern + size; /* How to translate the characters in the pattern. */ char *translate = bufp->translate; /* Address of the count-byte of the most recently inserted `exactn' command. This makes it possible to tell if a new exact-match character can be added to that command or if the character requires a new `exactn' command. */ unsigned char *pending_exact = 0; /* Address of start of the most recently finished expression. This tells, e.g., postfix * where to find the start of its operand. Reset at the beginning of groups and alternatives. */ unsigned char *laststart = 0; /* Address of beginning of regexp, or inside of last group. */ unsigned char *begalt; /* Place in the uncompiled pattern (i.e., the {) to which to go back if the interval is invalid. */ const char *beg_interval; /* Address of the place where a forward jump should go to the end of the containing expression. Each alternative of an `or' -- except the last -- ends with a forward jump of this sort. */ unsigned char *fixup_alt_jump = 0; /* Counts open-groups as they are encountered. Remembered for the matching close-group on the compile stack, so the same register number is put in the stop_memory as the start_memory. */ regnum_t regnum = 0; #ifdef DEBUG DEBUG_PRINT1 ("\nCompiling pattern: "); if (debug) { unsigned debug_count; for (debug_count = 0; debug_count < size; debug_count++) printchar (pattern[debug_count]); putchar ('\n'); } #endif /* DEBUG */ /* Initialize the compile stack. */ compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); if (compile_stack.stack == NULL) return REG_ESPACE; compile_stack.size = INIT_COMPILE_STACK_SIZE; compile_stack.avail = 0; /* Initialize the pattern buffer. */ bufp->syntax = syntax; bufp->fastmap_accurate = 0; bufp->not_bol = bufp->not_eol = 0; /* Set `used' to zero, so that if we return an error, the pattern printer (for debugging) will think there's no pattern. We reset it at the end. */ bufp->used = 0; /* Always count groups, whether or not bufp->no_sub is set. */ bufp->re_nsub = 0; #if !defined (emacs) && !defined (SYNTAX_TABLE) /* Initialize the syntax table. */ init_syntax_once (); #endif if (bufp->allocated == 0) { if (bufp->buffer) { /* If zero allocated, but buffer is non-null, try to realloc enough space. This loses if buffer's address is bogus, but that is the user's responsibility. */ RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); } else { /* Caller did not allocate a buffer. Do it for them. */ bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); } if (!bufp->buffer) return REG_ESPACE; bufp->allocated = INIT_BUF_SIZE; } begalt = b = bufp->buffer; /* Loop through the uncompiled pattern until we're at the end. */ while (p != pend) { PATFETCH (c); switch (c) { case '^': { if ( /* If at start of pattern, it's an operator. */ p == pattern + 1 /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS /* Otherwise, depends on what's come before. */ || at_begline_loc_p (pattern, p, syntax)) BUF_PUSH (begline); else goto normal_char; } break; case '$': { if ( /* If at end of pattern, it's an operator. */ p == pend /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS /* Otherwise, depends on what's next. */ || at_endline_loc_p (p, pend, syntax)) BUF_PUSH (endline); else goto normal_char; } break; case '+': case '?': if ((syntax & RE_BK_PLUS_QM) || (syntax & RE_LIMITED_OPS)) goto normal_char; handle_plus: case '*': /* If there is no previous pattern... */ if (!laststart) { if (syntax & RE_CONTEXT_INVALID_OPS) return REG_BADRPT; else if (!(syntax & RE_CONTEXT_INDEP_OPS)) goto normal_char; } { /* Are we optimizing this jump? */ boolean keep_string_p = false; /* 1 means zero (many) matches is allowed. */ char zero_times_ok = 0, many_times_ok = 0; /* If there is a sequence of repetition chars, collapse it down to just one (the right one). We can't combine interval operators with these because of, e.g., `a{2}*', which should only match an even number of `a's. */ for (;;) { zero_times_ok |= c != '+'; many_times_ok |= c != '?'; if (p == pend) break; PATFETCH (c); if (c == '*' || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?'))) ; else if (syntax & RE_BK_PLUS_QM && c == '\\') { if (p == pend) return REG_EESCAPE; PATFETCH (c1); if (!(c1 == '+' || c1 == '?')) { PATUNFETCH; PATUNFETCH; break; } c = c1; } else { PATUNFETCH; break; } /* If we get here, we found another repeat character. */ } /* Star, etc. applied to an empty pattern is equivalent to an empty pattern. */ if (!laststart) break; /* Now we know whether or not zero matches is allowed and also whether or not two or more matches is allowed. */ if (many_times_ok) { /* More than one repetition is allowed, so put in at the end a backward relative jump from `b' to before the next jump we're going to put in below (which jumps from laststart to after this jump). But if we are at the `*' in the exact sequence `.*\n', insert an unconditional jump backwards to the ., instead of the beginning of the loop. This way we only push a failure point once, instead of every time through the loop. */ assert (p - 1 > pattern); /* Allocate the space for the jump. */ GET_BUFFER_SPACE (3); /* We know we are not at the first character of the pattern, because laststart was nonzero. And we've already incremented `p', by the way, to be the character after the `*'. Do we have to do something analogous here for null bytes, because of RE_DOT_NOT_NULL? */ if (TRANSLATE (*(p - 2)) == TRANSLATE ('.') && zero_times_ok && p < pend && TRANSLATE (*p) == TRANSLATE ('\n') && !(syntax & RE_DOT_NEWLINE)) { /* We have .*\n. */ STORE_JUMP (jump, b, laststart); keep_string_p = true; } else /* Anything else. */ STORE_JUMP (maybe_pop_jump, b, laststart - 3); /* We've added more stuff to the buffer. */ b += 3; } /* On failure, jump from laststart to b + 3, which will be the end of the buffer after this jump is inserted. */ GET_BUFFER_SPACE (3); INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump : on_failure_jump, laststart, b + 3); pending_exact = 0; b += 3; if (!zero_times_ok) { /* At least one repetition is required, so insert a `dummy_failure_jump' before the initial `on_failure_jump' instruction of the loop. This effects a skip over that instruction the first time we hit that loop. */ GET_BUFFER_SPACE (3); INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); b += 3; } } break; case '.': laststart = b; BUF_PUSH (anychar); break; case '[': { boolean had_char_class = false; if (p == pend) return REG_EBRACK; /* Ensure that we have enough space to push a charset: the opcode, the length count, and the bitset; 34 bytes in all. */ GET_BUFFER_SPACE (34); laststart = b; /* We test `*p == '^' twice, instead of using an if statement, so we only need one BUF_PUSH. */ BUF_PUSH (*p == '^' ? charset_not : charset); if (*p == '^') p++; /* Remember the first position in the bracket expression. */ p1 = p; /* Push the number of bytes in the bitmap. */ BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); /* Clear the whole map. */ bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); /* charset_not matches newline according to a syntax bit. */ if ((re_opcode_t) b[-2] == charset_not && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) SET_LIST_BIT ('\n'); /* Read in characters and ranges, setting map bits. */ for (;;) { if (p == pend) return REG_EBRACK; PATFETCH (c); /* \ might escape characters inside [...] and [^...]. */ if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') { if (p == pend) return REG_EESCAPE; PATFETCH (c1); SET_LIST_BIT (c1); continue; } /* Could be the end of the bracket expression. If it's not (i.e., when the bracket expression is `[]' so far), the ']' character bit gets set way below. */ if (c == ']' && p != p1 + 1) break; /* Look ahead to see if it's a range when the last thing was a character class. */ if (had_char_class && c == '-' && *p != ']') return REG_ERANGE; /* Look ahead to see if it's a range when the last thing was a character: if this is a hyphen not at the beginning or the end of a list, then it's the range operator. */ if (c == '-' && !(p - 2 >= pattern && p[-2] == '[') && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') && *p != ']') { reg_errcode_t ret = compile_range (&p, pend, translate, syntax, b); if (ret != REG_NOERROR) return ret; } else if (p[0] == '-' && p[1] != ']') { /* This handles ranges made up of characters only. */ reg_errcode_t ret; /* Move past the `-'. */ PATFETCH (c1); ret = compile_range (&p, pend, translate, syntax, b); if (ret != REG_NOERROR) return ret; } /* See if we're at the beginning of a possible character class. */ else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') { /* Leave room for the null. */ char str[CHAR_CLASS_MAX_LENGTH + 1]; PATFETCH (c); c1 = 0; /* If pattern is `[[:'. */ if (p == pend) return REG_EBRACK; for (;;) { PATFETCH (c); if (c == ':' || c == ']' || p == pend || c1 == CHAR_CLASS_MAX_LENGTH) break; str[c1++] = c; } str[c1] = '\0'; /* If isn't a word bracketed by `[:' and:`]': undo the ending character, the letters, and leave the leading `:' and `[' (but set bits for them). */ if (c == ':' && *p == ']') { int ch; boolean is_alnum = STREQ (str, "alnum"); boolean is_alpha = STREQ (str, "alpha"); boolean is_blank = STREQ (str, "blank"); boolean is_cntrl = STREQ (str, "cntrl"); boolean is_digit = STREQ (str, "digit"); boolean is_graph = STREQ (str, "graph"); boolean is_lower = STREQ (str, "lower"); boolean is_print = STREQ (str, "print"); boolean is_punct = STREQ (str, "punct"); boolean is_space = STREQ (str, "space"); boolean is_upper = STREQ (str, "upper"); boolean is_xdigit = STREQ (str, "xdigit"); if (!IS_CHAR_CLASS (str)) return REG_ECTYPE; /* Throw away the ] at the end of the character class. */ PATFETCH (c); if (p == pend) return REG_EBRACK; for (ch = 0; ch < 1 << BYTEWIDTH; ch++) { if ( (is_alnum && ISALNUM (ch)) || (is_alpha && ISALPHA (ch)) || (is_blank && ISBLANK (ch)) || (is_cntrl && ISCNTRL (ch)) || (is_digit && ISDIGIT (ch)) || (is_graph && ISGRAPH (ch)) || (is_lower && ISLOWER (ch)) || (is_print && ISPRINT (ch)) || (is_punct && ISPUNCT (ch)) || (is_space && ISSPACE (ch)) || (is_upper && ISUPPER (ch)) || (is_xdigit && ISXDIGIT (ch))) SET_LIST_BIT (ch); } had_char_class = true; } else { c1++; while (c1--) PATUNFETCH; SET_LIST_BIT ('['); SET_LIST_BIT (':'); had_char_class = false; } } else { had_char_class = false; SET_LIST_BIT (c); } } /* Discard any (non)matching list bytes that are all 0 at the end of the map. Decrease the map-length byte too. */ while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) b[-1]--; b += b[-1]; } break; case '(': if (syntax & RE_NO_BK_PARENS) goto handle_open; else goto normal_char; case ')': if (syntax & RE_NO_BK_PARENS) goto handle_close; else goto normal_char; case '\n': if (syntax & RE_NEWLINE_ALT) goto handle_alt; else goto normal_char; case '|': if (syntax & RE_NO_BK_VBAR) goto handle_alt; else goto normal_char; case '{': if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) goto handle_interval; else goto normal_char; case '\\': if (p == pend) return REG_EESCAPE; /* Do not translate the character after the \, so that we can distinguish, e.g., \B from \b, even if we normally would translate, e.g., B to b. */ PATFETCH_RAW (c); switch (c) { case '(': if (syntax & RE_NO_BK_PARENS) goto normal_backslash; handle_open: bufp->re_nsub++; regnum++; if (COMPILE_STACK_FULL) { RETALLOC (compile_stack.stack, compile_stack.size << 1, compile_stack_elt_t); if (compile_stack.stack == NULL) return REG_ESPACE; compile_stack.size <<= 1; } /* These are the values to restore when we hit end of this group. They are all relative offsets, so that if the whole pattern moves because of realloc, they will still be valid. */ COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; COMPILE_STACK_TOP.fixup_alt_jump = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer; COMPILE_STACK_TOP.regnum = regnum; /* We will eventually replace the 0 with the number of groups inner to this one. But do not push a start_memory for groups beyond the last one we can represent in the compiled pattern. */ if (regnum <= MAX_REGNUM) { COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2; BUF_PUSH_3 (start_memory, regnum, 0); } compile_stack.avail++; fixup_alt_jump = 0; laststart = 0; begalt = b; /* If we've reached MAX_REGNUM groups, then this open won't actually generate any code, so we'll have to clear pending_exact explicitly. */ pending_exact = 0; break; case ')': if (syntax & RE_NO_BK_PARENS) goto normal_backslash; if (COMPILE_STACK_EMPTY) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_backslash; else return REG_ERPAREN; handle_close: if (fixup_alt_jump) { /* Push a dummy failure point at the end of the alternative for a possible future `pop_failure_jump' to pop. See comments at `push_dummy_failure' in `re_match_2'. */ BUF_PUSH (push_dummy_failure); /* We allocated space for this jump when we assigned to `fixup_alt_jump', in the `handle_alt' case below. */ STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1); } /* See similar code for backslashed left paren above. */ if (COMPILE_STACK_EMPTY) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_char; else return REG_ERPAREN; /* Since we just checked for an empty stack above, this ``can't happen''. */ assert (compile_stack.avail != 0); { /* We don't just want to restore into `regnum', because later groups should continue to be numbered higher, as in `(ab)c(de)' -- the second group is #2. */ regnum_t this_group_regnum; compile_stack.avail--; begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; fixup_alt_jump = COMPILE_STACK_TOP.fixup_alt_jump ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 : 0; laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; this_group_regnum = COMPILE_STACK_TOP.regnum; /* If we've reached MAX_REGNUM groups, then this open won't actually generate any code, so we'll have to clear pending_exact explicitly. */ pending_exact = 0; /* We're at the end of the group, so now we know how many groups were inside this one. */ if (this_group_regnum <= MAX_REGNUM) { unsigned char *inner_group_loc = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; *inner_group_loc = regnum - this_group_regnum; BUF_PUSH_3 (stop_memory, this_group_regnum, regnum - this_group_regnum); } } break; case '|': /* `\|'. */ if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) goto normal_backslash; handle_alt: if (syntax & RE_LIMITED_OPS) goto normal_char; /* Insert before the previous alternative a jump which jumps to this alternative if the former fails. */ GET_BUFFER_SPACE (3); INSERT_JUMP (on_failure_jump, begalt, b + 6); pending_exact = 0; b += 3; /* The alternative before this one has a jump after it which gets executed if it gets matched. Adjust that jump so it will jump to this alternative's analogous jump (put in below, which in turn will jump to the next (if any) alternative's such jump, etc.). The last such jump jumps to the correct final destination. A picture: _____ _____ | | | | | v | v a | b | c If we are at `b', then fixup_alt_jump right now points to a three-byte space after `a'. We'll put in the jump, set fixup_alt_jump to right after `b', and leave behind three bytes which we'll fill in when we get to after `c'. */ if (fixup_alt_jump) STORE_JUMP (jump_past_alt, fixup_alt_jump, b); /* Mark and leave space for a jump after this alternative, to be filled in later either by next alternative or when know we're at the end of a series of alternatives. */ fixup_alt_jump = b; GET_BUFFER_SPACE (3); b += 3; laststart = 0; begalt = b; break; case '{': /* If \{ is a literal. */ if (!(syntax & RE_INTERVALS) /* If we're at `\{' and it's not the open-interval operator. */ || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) || (p - 2 == pattern && p == pend)) goto normal_backslash; handle_interval: { /* If got here, then the syntax allows intervals. */ /* At least (most) this many matches must be made. */ int lower_bound = -1, upper_bound = -1; beg_interval = p - 1; if (p == pend) { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_EBRACE; } GET_UNSIGNED_NUMBER (lower_bound); if (c == ',') { GET_UNSIGNED_NUMBER (upper_bound); if (upper_bound < 0) upper_bound = RE_DUP_MAX; } else /* Interval such as `{1}' => match exactly once. */ upper_bound = lower_bound; if (lower_bound < 0 || upper_bound > RE_DUP_MAX || lower_bound > upper_bound) { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_BADBR; } if (!(syntax & RE_NO_BK_BRACES)) { if (c != '\\') return REG_EBRACE; PATFETCH (c); } if (c != '}') { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_BADBR; } /* We just parsed a valid interval. */ /* If it's invalid to have no preceding re. */ if (!laststart) { if (syntax & RE_CONTEXT_INVALID_OPS) return REG_BADRPT; else if (syntax & RE_CONTEXT_INDEP_OPS) laststart = b; else goto unfetch_interval; } /* If the upper bound is zero, don't want to succeed at all; jump from `laststart' to `b + 3', which will be the end of the buffer after we insert the jump. */ if (upper_bound == 0) { GET_BUFFER_SPACE (3); INSERT_JUMP (jump, laststart, b + 3); b += 3; } /* Otherwise, we have a nontrivial interval. When we're all done, the pattern will look like: set_number_at set_number_at succeed_n jump_n (The upper bound and `jump_n' are omitted if `upper_bound' is 1, though.) */ else { /* If the upper bound is > 1, we need to insert more at the end of the loop. */ unsigned nbytes = 10 + (upper_bound > 1) * 10; GET_BUFFER_SPACE (nbytes); /* Initialize lower bound of the `succeed_n', even though it will be set during matching by its attendant `set_number_at' (inserted next), because `re_compile_fastmap' needs to know. Jump to the `jump_n' we might insert below. */ INSERT_JUMP2 (succeed_n, laststart, b + 5 + (upper_bound > 1) * 5, lower_bound); b += 5; /* Code to initialize the lower bound. Insert before the `succeed_n'. The `5' is the last two bytes of this `set_number_at', plus 3 bytes of the following `succeed_n'. */ insert_op2 (set_number_at, laststart, 5, lower_bound, b); b += 5; if (upper_bound > 1) { /* More than one repetition is allowed, so append a backward jump to the `succeed_n' that starts this interval. When we've reached this during matching, we'll have matched the interval once, so jump back only `upper_bound - 1' times. */ STORE_JUMP2 (jump_n, b, laststart + 5, upper_bound - 1); b += 5; /* The location we want to set is the second parameter of the `jump_n'; that is `b-2' as an absolute address. `laststart' will be the `set_number_at' we're about to insert; `laststart+3' the number to set, the source for the relative address. But we are inserting into the middle of the pattern -- so everything is getting moved up by 5. Conclusion: (b - 2) - (laststart + 3) + 5, i.e., b - laststart. We insert this at the beginning of the loop so that if we fail during matching, we'll reinitialize the bounds. */ insert_op2 (set_number_at, laststart, b - laststart, upper_bound - 1, b); b += 5; } } pending_exact = 0; beg_interval = NULL; } break; unfetch_interval: /* If an invalid interval, match the characters as literals. */ assert (beg_interval); p = beg_interval; beg_interval = NULL; /* normal_char and normal_backslash need `c'. */ PATFETCH (c); if (!(syntax & RE_NO_BK_BRACES)) { if (p > pattern && p[-1] == '\\') goto normal_backslash; } goto normal_char; #ifdef emacs /* There is no way to specify the before_dot and after_dot operators. rms says this is ok. --karl */ case '=': BUF_PUSH (at_dot); break; case 's': laststart = b; PATFETCH (c); BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); break; case 'S': laststart = b; PATFETCH (c); BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); break; #endif /* emacs */ case 'w': if (re_syntax_options & RE_NO_GNU_OPS) goto normal_char; laststart = b; BUF_PUSH (wordchar); break; case 'W': if (re_syntax_options & RE_NO_GNU_OPS) goto normal_char; laststart = b; BUF_PUSH (notwordchar); break; case '<': if (re_syntax_options & RE_NO_GNU_OPS) goto normal_char; BUF_PUSH (wordbeg); break; case '>': if (re_syntax_options & RE_NO_GNU_OPS) goto normal_char; BUF_PUSH (wordend); break; case 'b': if (re_syntax_options & RE_NO_GNU_OPS) goto normal_char; BUF_PUSH (wordbound); break; case 'B': if (re_syntax_options & RE_NO_GNU_OPS) goto normal_char; BUF_PUSH (notwordbound); break; case '`': if (re_syntax_options & RE_NO_GNU_OPS) goto normal_char; BUF_PUSH (begbuf); break; case '\'': if (re_syntax_options & RE_NO_GNU_OPS) goto normal_char; BUF_PUSH (endbuf); break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (syntax & RE_NO_BK_REFS) goto normal_char; c1 = c - '0'; if (c1 > regnum) return REG_ESUBREG; /* Can't back reference to a subexpression if inside of it. */ if (group_in_compile_stack (compile_stack, (regnum_t)c1)) goto normal_char; laststart = b; BUF_PUSH_2 (duplicate, c1); break; case '+': case '?': if (syntax & RE_BK_PLUS_QM) goto handle_plus; else goto normal_backslash; default: normal_backslash: /* You might think it would be useful for \ to mean not to translate; but if we don't translate it it will never match anything. */ c = TRANSLATE (c); goto normal_char; } break; default: /* Expects the character in `c'. */ normal_char: /* If no exactn currently being built. */ if (!pending_exact /* If last exactn not at current position. */ || pending_exact + *pending_exact + 1 != b /* We have only one byte following the exactn for the count. */ || *pending_exact == (1 << BYTEWIDTH) - 1 /* If followed by a repetition operator. */ || *p == '*' || *p == '^' || ((syntax & RE_BK_PLUS_QM) ? *p == '\\' && (p[1] == '+' || p[1] == '?') : (*p == '+' || *p == '?')) || ((syntax & RE_INTERVALS) && ((syntax & RE_NO_BK_BRACES) ? *p == '{' : (p[0] == '\\' && p[1] == '{')))) { /* Start building a new exactn. */ laststart = b; BUF_PUSH_2 (exactn, 0); pending_exact = b - 1; } BUF_PUSH (c); (*pending_exact)++; break; } /* switch (c) */ } /* while p != pend */ /* Through the pattern now. */ if (fixup_alt_jump) STORE_JUMP (jump_past_alt, fixup_alt_jump, b); if (!COMPILE_STACK_EMPTY) return REG_EPAREN; free (compile_stack.stack); /* We have succeeded; set the length of the buffer. */ bufp->used = b - bufp->buffer; #ifdef DEBUG if (debug) { DEBUG_PRINT1 ("\nCompiled pattern: \n"); print_compiled_pattern (bufp); } #endif /* DEBUG */ return REG_NOERROR; } /* regex_compile */ /* Subroutines for `regex_compile'. */ /* Store OP at LOC followed by two-byte integer parameter ARG. */ static void store_op1 (op, loc, arg) re_opcode_t op; unsigned char *loc; int arg; { *loc = (unsigned char) op; STORE_NUMBER (loc + 1, arg); } /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ static void store_op2 (op, loc, arg1, arg2) re_opcode_t op; unsigned char *loc; int arg1, arg2; { *loc = (unsigned char) op; STORE_NUMBER (loc + 1, arg1); STORE_NUMBER (loc + 3, arg2); } /* Copy the bytes from LOC to END to open up three bytes of space at LOC for OP followed by two-byte integer parameter ARG. */ static void insert_op1 (op, loc, arg, end) re_opcode_t op; unsigned char *loc; int arg; unsigned char *end; { register unsigned char *pfrom = end; register unsigned char *pto = end + 3; while (pfrom != loc) *--pto = *--pfrom; store_op1 (op, loc, arg); } /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ static void insert_op2 (op, loc, arg1, arg2, end) re_opcode_t op; unsigned char *loc; int arg1, arg2; unsigned char *end; { register unsigned char *pfrom = end; register unsigned char *pto = end + 5; while (pfrom != loc) *--pto = *--pfrom; store_op2 (op, loc, arg1, arg2); } /* P points to just after a ^ in PATTERN. Return true if that ^ comes after an alternative or a begin-subexpression. We assume there is at least one character before the ^. */ static boolean at_begline_loc_p (pattern, p, syntax) const char *pattern, *p; reg_syntax_t syntax; { const char *prev = p - 2; boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; return /* After a subexpression? */ (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) /* After an alternative? */ || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); } /* The dual of at_begline_loc_p. This one is for $. We assume there is at least one character after the $, i.e., `P < PEND'. */ static boolean at_endline_loc_p (p, pend, syntax) const char *p, *pend; reg_syntax_t syntax; { const char *next = p; boolean next_backslash = *next == '\\'; const char *next_next = p + 1 < pend ? p + 1 : NULL; return /* Before a subexpression? */ (syntax & RE_NO_BK_PARENS ? *next == ')' : next_backslash && next_next && *next_next == ')') /* Before an alternative? */ || (syntax & RE_NO_BK_VBAR ? *next == '|' : next_backslash && next_next && *next_next == '|'); } /* Returns true if REGNUM is in one of COMPILE_STACK's elements and false if it's not. */ static boolean group_in_compile_stack (compile_stack, regnum) compile_stack_type compile_stack; regnum_t regnum; { int this_element; for (this_element = compile_stack.avail - 1; this_element >= 0; this_element--) if (compile_stack.stack[this_element].regnum == regnum) return true; return false; } /* Read the ending character of a range (in a bracket expression) from the uncompiled pattern *P_PTR (which ends at PEND). We assume the starting character is in `P[-2]'. (`P[-1]' is the character `-'.) Then we set the translation of all bits between the starting and ending characters (inclusive) in the compiled pattern B. Return an error code. We use these short variable names so we can use the same macros as `regex_compile' itself. */ static reg_errcode_t compile_range (p_ptr, pend, translate, syntax, b) const char **p_ptr, *pend; char *translate; reg_syntax_t syntax; unsigned char *b; { unsigned this_char; const char *p = *p_ptr; int range_start, range_end; if (p == pend) return REG_ERANGE; /* Even though the pattern is a signed `char *', we need to fetch with unsigned char *'s; if the high bit of the pattern character is set, the range endpoints will be negative if we fetch using a signed char *. We also want to fetch the endpoints without translating them; the appropriate translation is done in the bit-setting loop below. */ range_start = ((unsigned char *) p)[-2]; range_end = ((unsigned char *) p)[0]; /* Have to increment the pointer into the pattern string, so the caller isn't still at the ending character. */ (*p_ptr)++; /* If the start is after the end, the range is empty. */ if (range_start > range_end) return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; /* Here we see why `this_char' has to be larger than an `unsigned char' -- the range is inclusive, so if `range_end' == 0xff (assuming 8-bit characters), we would otherwise go into an infinite loop, since all characters <= 0xff. */ for (this_char = range_start; this_char <= range_end; this_char++) { SET_LIST_BIT (TRANSLATE (this_char)); } return REG_NOERROR; } /* Failure stack declarations and macros; both re_compile_fastmap and re_match_2 use a failure stack. These have to be macros because of REGEX_ALLOCATE. */ /* Number of failure points for which to initially allocate space when matching. If this number is exceeded, we allocate more space, so it is not a hard limit. */ #ifndef INIT_FAILURE_ALLOC #define INIT_FAILURE_ALLOC 5 #endif /* Roughly the maximum number of failure points on the stack. Would be exactly that if always used MAX_FAILURE_SPACE each time we failed. This is a variable only so users of regex can assign to it; we never change it ourselves. */ int re_max_failures = 2000; typedef const unsigned char *fail_stack_elt_t; typedef struct { fail_stack_elt_t *stack; unsigned size; unsigned avail; /* Offset of next open position. */ } fail_stack_type; #define FAIL_STACK_EMPTY() (fail_stack.avail == 0) #define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) #define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) #define FAIL_STACK_TOP() (fail_stack.stack[fail_stack.avail]) /* Initialize `fail_stack'. Do `return -2' if the alloc fails. */ #define INIT_FAIL_STACK() \ do { \ fail_stack.stack = (fail_stack_elt_t *) \ REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \ \ if (fail_stack.stack == NULL) \ return -2; \ \ fail_stack.size = INIT_FAILURE_ALLOC; \ fail_stack.avail = 0; \ } while (0) /* Double the size of FAIL_STACK, up to approximately `re_max_failures' items. Return 1 if succeeds, and 0 if either ran out of memory allocating space for it or it was already too large. REGEX_REALLOCATE requires `destination' be declared. */ #define DOUBLE_FAIL_STACK(fail_stack) \ ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \ ? 0 \ : ((fail_stack).stack = (fail_stack_elt_t *) \ REGEX_REALLOCATE ((fail_stack).stack, \ (fail_stack).size * sizeof (fail_stack_elt_t), \ ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \ \ (fail_stack).stack == NULL \ ? 0 \ : ((fail_stack).size <<= 1, \ 1))) /* Push PATTERN_OP on FAIL_STACK. Return 1 if was able to do so and 0 if ran out of memory allocating space to do so. */ #define PUSH_PATTERN_OP(pattern_op, fail_stack) \ ((FAIL_STACK_FULL () \ && !DOUBLE_FAIL_STACK (fail_stack)) \ ? 0 \ : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \ 1)) /* This pushes an item onto the failure stack. Must be a four-byte value. Assumes the variable `fail_stack'. Probably should only be called from within `PUSH_FAILURE_POINT'. */ #define PUSH_FAILURE_ITEM(item) \ fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item /* The complement operation. Assumes `fail_stack' is nonempty. */ #define POP_FAILURE_ITEM() fail_stack.stack[--fail_stack.avail] /* Used to omit pushing failure point id's when we're not debugging. */ #ifdef DEBUG #define DEBUG_PUSH PUSH_FAILURE_ITEM #define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_ITEM () #else #define DEBUG_PUSH(item) #define DEBUG_POP(item_addr) #endif /* Push the information about the state we will need if we ever fail back to it. Requires variables fail_stack, regstart, regend, reg_info, and num_regs be declared. DOUBLE_FAIL_STACK requires `destination' be declared. Does `return FAILURE_CODE' if runs out of memory. */ #define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \ do { \ char *destination; \ /* Must be int, so when we don't save any registers, the arithmetic \ of 0 + -1 isn't done as unsigned. */ \ /* Can't be int, since there is not a shred of a guarantee that int \ is wide enough to hold a value of something to which pointer can \ be assigned */ \ s_reg_t this_reg; \ \ DEBUG_STATEMENT (failure_id++); \ DEBUG_STATEMENT (nfailure_points_pushed++); \ DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \ DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\ DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\ \ DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \ DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \ \ /* Ensure we have enough space allocated for what we will push. */ \ while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \ { \ if (!DOUBLE_FAIL_STACK (fail_stack)) \ return failure_code; \ \ DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \ (fail_stack).size); \ DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\ } #define PUSH_FAILURE_POINT2(pattern_place, string_place, failure_code) \ /* Push the info, starting with the registers. */ \ DEBUG_PRINT1 ("\n"); \ \ PUSH_FAILURE_POINT_LOOP (); \ \ DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ PUSH_FAILURE_ITEM (lowest_active_reg); \ \ DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ PUSH_FAILURE_ITEM (highest_active_reg); \ \ DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \ DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ PUSH_FAILURE_ITEM (pattern_place); \ \ DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \ DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ size2); \ DEBUG_PRINT1 ("'\n"); \ PUSH_FAILURE_ITEM (string_place); \ \ DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \ DEBUG_PUSH (failure_id); \ } while (0) /* Pulled out of PUSH_FAILURE_POINT() to shorten the definition of that macro. (for VAX C) */ #define PUSH_FAILURE_POINT_LOOP() \ for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \ this_reg++) \ { \ DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ DEBUG_STATEMENT (num_regs_pushed++); \ \ DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ PUSH_FAILURE_ITEM (regstart[this_reg]); \ \ DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ PUSH_FAILURE_ITEM (regend[this_reg]); \ \ DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \ DEBUG_PRINT2 (" match_null=%d", \ REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ DEBUG_PRINT2 (" matched_something=%d", \ MATCHED_SOMETHING (reg_info[this_reg])); \ DEBUG_PRINT2 (" ever_matched=%d", \ EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ DEBUG_PRINT1 ("\n"); \ PUSH_FAILURE_ITEM (reg_info[this_reg].word); \ } /* This is the number of items that are pushed and popped on the stack for each register. */ #define NUM_REG_ITEMS 3 /* Individual items aside from the registers. */ #ifdef DEBUG #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ #else #define NUM_NONREG_ITEMS 4 #endif /* We push at most this many items on the stack. */ #define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS) /* We actually push this many items. */ #define NUM_FAILURE_ITEMS \ ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ + NUM_NONREG_ITEMS) /* How many items can still be added to the stack without overflowing it. */ #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) /* Pops what PUSH_FAIL_STACK pushes. We restore into the parameters, all of which should be lvalues: STR -- the saved data position. PAT -- the saved pattern position. LOW_REG, HIGH_REG -- the highest and lowest active registers. REGSTART, REGEND -- arrays of string positions. REG_INFO -- array of information about each subexpression. Also assumes the variables `fail_stack' and (if debugging), `bufp', `pend', `string1', `size1', `string2', and `size2'. */ #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\ { \ DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \ s_reg_t this_reg; \ const unsigned char *string_temp; \ \ assert (!FAIL_STACK_EMPTY ()); \ \ /* Remove failure points and point to how many regs pushed. */ \ DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \ DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \ DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \ \ assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ \ DEBUG_POP (&failure_id); \ DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \ \ /* If the saved string location is NULL, it came from an \ on_failure_keep_string_jump opcode, and we want to throw away the \ saved NULL, thus retaining our current position in the string. */ \ string_temp = POP_FAILURE_ITEM (); \ if (string_temp != NULL) \ str = (const char *) string_temp; \ \ DEBUG_PRINT2 (" Popping string 0x%x: `", str); \ DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ DEBUG_PRINT1 ("'\n"); \ \ pat = (unsigned char *) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \ DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ \ POP_FAILURE_POINT2 (low_reg, high_reg, regstart, regend, reg_info); /* Pulled out of POP_FAILURE_POINT() to shorten the definition of that macro. (for MSC 5.1) */ #define POP_FAILURE_POINT2(low_reg, high_reg, regstart, regend, reg_info) \ \ /* Restore register info. */ \ high_reg = (active_reg_t) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ \ low_reg = (active_reg_t) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ \ for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ { \ DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ \ reg_info[this_reg].word = POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ \ regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ \ regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ } \ \ DEBUG_STATEMENT (nfailure_points_popped++); \ } /* POP_FAILURE_POINT */ /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible characters can start a string that matches the pattern. This fastmap is used by re_search to skip quickly over impossible starting points. The caller must supply the address of a (1 << BYTEWIDTH)-byte data area as BUFP->fastmap. We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in the pattern buffer. Returns 0 if we succeed, -2 if an internal error. */ int re_compile_fastmap (bufp) struct re_pattern_buffer *bufp; { int j, k; fail_stack_type fail_stack; #ifndef REGEX_MALLOC char *destination; #endif /* We don't push any register information onto the failure stack. */ unsigned num_regs = 0; register char *fastmap = bufp->fastmap; unsigned char *pattern = bufp->buffer; const unsigned char *p = pattern; register unsigned char *pend = pattern + bufp->used; /* Assume that each path through the pattern can be null until proven otherwise. We set this false at the bottom of switch statement, to which we get only if a particular path doesn't match the empty string. */ boolean path_can_be_null = true; /* We aren't doing a `succeed_n' to begin with. */ boolean succeed_n_p = false; assert (fastmap != NULL && p != NULL); INIT_FAIL_STACK (); bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ bufp->fastmap_accurate = 1; /* It will be when we're done. */ bufp->can_be_null = 0; while (p != pend || !FAIL_STACK_EMPTY ()) { if (p == pend) { bufp->can_be_null |= path_can_be_null; /* Reset for next path. */ path_can_be_null = true; p = fail_stack.stack[--fail_stack.avail]; } /* We should never be about to go beyond the end of the pattern. */ assert (p < pend); #ifdef SWITCH_ENUM_BUG switch ((int) ((re_opcode_t) *p++)) #else switch ((re_opcode_t) *p++) #endif { /* I guess the idea here is to simply not bother with a fastmap if a backreference is used, since it's too hard to figure out the fastmap for the corresponding group. Setting `can_be_null' stops `re_search_2' from using the fastmap, so that is all we do. */ case duplicate: bufp->can_be_null = 1; return 0; /* Following are the cases which match a character. These end with `break'. */ case exactn: fastmap[p[1]] = 1; break; case charset: for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) fastmap[j] = 1; break; case charset_not: /* Chars beyond end of map must be allowed. */ for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) fastmap[j] = 1; for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) fastmap[j] = 1; break; case wordchar: for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) == Sword) fastmap[j] = 1; break; case notwordchar: for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) != Sword) fastmap[j] = 1; break; case anychar: /* `.' matches anything ... */ for (j = 0; j < (1 << BYTEWIDTH); j++) fastmap[j] = 1; /* ... except perhaps newline. */ if (!(bufp->syntax & RE_DOT_NEWLINE)) fastmap['\n'] = 0; /* Return if we have already set `can_be_null'; if we have, then the fastmap is irrelevant. Something's wrong here. */ else if (bufp->can_be_null) return 0; /* Otherwise, have to check alternative paths. */ break; #ifdef emacs case syntaxspec: k = *p++; for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) == (enum syntaxcode) k) fastmap[j] = 1; break; case notsyntaxspec: k = *p++; for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) != (enum syntaxcode) k) fastmap[j] = 1; break; /* All cases after this match the empty string. These end with `continue'. */ case before_dot: case at_dot: case after_dot: continue; #endif /* not emacs */ case no_op: case begline: case endline: case begbuf: case endbuf: case wordbound: case notwordbound: case wordbeg: case wordend: case push_dummy_failure: continue; case jump_n: case pop_failure_jump: case maybe_pop_jump: case jump: case jump_past_alt: case dummy_failure_jump: EXTRACT_NUMBER_AND_INCR (j, p); p += j; if (j > 0) continue; /* Jump backward implies we just went through the body of a loop and matched nothing. Opcode jumped to should be `on_failure_jump' or `succeed_n'. Just treat it like an ordinary jump. For a * loop, it has pushed its failure point already; if so, discard that as redundant. */ if ((re_opcode_t) *p != on_failure_jump && (re_opcode_t) *p != succeed_n) continue; p++; EXTRACT_NUMBER_AND_INCR (j, p); p += j; /* If what's on the stack is where we are now, pop it. */ if (!FAIL_STACK_EMPTY () && fail_stack.stack[fail_stack.avail - 1] == p) fail_stack.avail--; continue; case on_failure_jump: case on_failure_keep_string_jump: handle_on_failure_jump: EXTRACT_NUMBER_AND_INCR (j, p); /* For some patterns, e.g., `(a?)?', `p+j' here points to the end of the pattern. We don't want to push such a point, since when we restore it above, entering the switch will increment `p' past the end of the pattern. We don't need to push such a point since we obviously won't find any more fastmap entries beyond `pend'. Such a pattern can match the null string, though. */ if (p + j < pend) { if (!PUSH_PATTERN_OP (p + j, fail_stack)) return -2; } else bufp->can_be_null = 1; if (succeed_n_p) { EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ succeed_n_p = false; } continue; case succeed_n: /* Get to the number of times to succeed. */ p += 2; /* Increment p past the n for when k != 0. */ EXTRACT_NUMBER_AND_INCR (k, p); if (k == 0) { p -= 4; succeed_n_p = true; /* Spaghetti code alert. */ goto handle_on_failure_jump; } continue; case set_number_at: p += 4; continue; case start_memory: case stop_memory: p += 2; continue; default: abort (); /* We have listed all the cases. */ } /* switch *p++ */ /* Getting here means we have found the possible starting characters for one path of the pattern -- and that the empty string does not match. We need not follow this path further. Instead, look at the next alternative (remembered on the stack), or quit if no more. The test at the top of the loop does these things. */ path_can_be_null = false; p = pend; } /* while p */ /* Set `can_be_null' for the last path (also the first path, if the pattern is empty). */ bufp->can_be_null |= path_can_be_null; return 0; } /* re_compile_fastmap */ /* Set REGS to hold NUM_REGS registers, storing them in STARTS and ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use this memory for recording register information. STARTS and ENDS must be allocated using the malloc library routine, and must each be at least NUM_REGS * sizeof (regoff_t) bytes long. If NUM_REGS == 0, then subsequent matches should allocate their own register data. Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ void re_set_registers (bufp, regs, num_regs, starts, ends) struct re_pattern_buffer *bufp; struct re_registers *regs; unsigned num_regs; regoff_t *starts, *ends; { if (num_regs) { bufp->regs_allocated = REGS_REALLOCATE; regs->num_regs = num_regs; regs->start = starts; regs->end = ends; } else { bufp->regs_allocated = REGS_UNALLOCATED; regs->num_regs = 0; regs->start = regs->end = 0; } } /* Searching routines. */ /* Like re_search_2, below, but only one string is specified, and doesn't let you say where to stop matching. */ int re_search (bufp, string, size, startpos, range, regs) struct re_pattern_buffer *bufp; const char *string; int size, startpos, range; struct re_registers *regs; { return re_search_2 (bufp, NULL, 0, string, size, startpos, range, regs, size); } /* Using the compiled pattern in BUFP->buffer, first tries to match the virtual concatenation of STRING1 and STRING2, starting first at index STARTPOS, then at STARTPOS + 1, and so on. STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. RANGE is how far to scan while trying to match. RANGE = 0 means try only at STARTPOS; in general, the last start tried is STARTPOS + RANGE. In REGS, return the indices of the virtual concatenation of STRING1 and STRING2 that matched the entire BUFP->buffer and its contained subexpressions. Do not consider matching one past the index STOP in the virtual concatenation of STRING1 and STRING2. We return either the position in the strings at which the match was found, -1 if no match, or -2 if error (such as failure stack overflow). */ int re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) struct re_pattern_buffer *bufp; const char *string1, *string2; int size1, size2; int startpos; int range; struct re_registers *regs; int stop; { int val; register char *fastmap = bufp->fastmap; register char *translate = bufp->translate; int total_size = size1 + size2; int endpos = startpos + range; /* Check for out-of-range STARTPOS. */ if (startpos < 0 || startpos > total_size) return -1; /* Fix up RANGE if it might eventually take us outside the virtual concatenation of STRING1 and STRING2. */ if (endpos < -1) range = -1 - startpos; else if (endpos > total_size) range = total_size - startpos; /* If the search isn't to be a backwards one, don't waste time in a search for a pattern that must be anchored. */ if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) { if (startpos > 0) return -1; else range = 1; } /* Update the fastmap now if not correct already. */ if (fastmap && !bufp->fastmap_accurate) if (re_compile_fastmap (bufp) == -2) return -2; /* Loop through the string, looking for a place to start matching. */ for (;;) { /* If a fastmap is supplied, skip quickly over characters that cannot be the start of a match. If the pattern can match the null string, however, we don't need to skip characters; we want the first null string. */ if (fastmap && startpos < total_size && !bufp->can_be_null) { if (range > 0) /* Searching forwards. */ { register const char *d; register int lim = 0; int irange = range; if (startpos < size1 && startpos + range >= size1) lim = range - (size1 - startpos); d = (startpos >= size1 ? string2 - size1 : string1) + startpos; /* Written out as an if-else to avoid testing `translate' inside the loop. */ if (translate) while (range > lim && !fastmap[(unsigned char) translate[(unsigned char) *d++]]) range--; else while (range > lim && !fastmap[(unsigned char) *d++]) range--; startpos += irange - range; } else /* Searching backwards. */ { register char c = (size1 == 0 || startpos >= size1 ? string2[startpos - size1] : string1[startpos]); if (!fastmap[(unsigned char) TRANSLATE (c)]) goto advance; } } /* If can't match the null string, and that's all we have left, fail. */ if (range >= 0 && startpos == total_size && fastmap && !bufp->can_be_null) return -1; val = re_match_2 (bufp, string1, size1, string2, size2, startpos, regs, stop); if (val >= 0) return startpos; if (val == -2) return -2; advance: if (!range) break; else if (range > 0) { range--; startpos++; } else { range++; startpos--; } } return -1; } /* re_search_2 */ /* Structure for per-register (a.k.a. per-group) information. This must not be longer than one word, because we push this value onto the failure stack. Other register information, such as the starting and ending positions (which are addresses), and the list of inner groups (which is a bits list) are maintained in separate variables. We are making a (strictly speaking) nonportable assumption here: that the compiler will pack our bit fields into something that fits into the type of `word', i.e., is something that fits into one item on the failure stack. */ /* Declarations and macros for re_match_2. */ typedef union { fail_stack_elt_t word; struct { /* This field is one if this group can match the empty string, zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ #define MATCH_NULL_UNSET_VALUE 3 unsigned match_null_string_p : 2; unsigned is_active : 1; unsigned matched_something : 1; unsigned ever_matched_something : 1; } bits; } register_info_type; #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) #define IS_ACTIVE(R) ((R).bits.is_active) #define MATCHED_SOMETHING(R) ((R).bits.matched_something) #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) static boolean group_match_null_string_p _RE_ARGS((unsigned char **p, unsigned char *end, register_info_type *reg_info)); static boolean alt_match_null_string_p _RE_ARGS((unsigned char *p, unsigned char *end, register_info_type *reg_info)); static boolean common_op_match_null_string_p _RE_ARGS((unsigned char **p, unsigned char *end, register_info_type *reg_info)); static int bcmp_translate _RE_ARGS((const char *s1, const char *s2, int len, char *translate)); /* Call this when have matched a real character; it sets `matched' flags for the subexpressions which we are currently inside. Also records that those subexprs have matched. */ #define SET_REGS_MATCHED() \ do \ { \ active_reg_t r; \ for (r = lowest_active_reg; r <= highest_active_reg; r++) \ { \ MATCHED_SOMETHING (reg_info[r]) \ = EVER_MATCHED_SOMETHING (reg_info[r]) \ = 1; \ } \ } \ while (0) /* This converts PTR, a pointer into one of the search strings `string1' and `string2' into an offset from the beginning of that string. */ #define POINTER_TO_OFFSET(ptr) \ (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1) /* Registers are set to a sentinel when they haven't yet matched. */ #define REG_UNSET_VALUE ((char *) -1) #define REG_UNSET(e) ((e) == REG_UNSET_VALUE) /* Macros for dealing with the split strings in re_match_2. */ #define MATCHING_IN_FIRST_STRING (dend == end_match_1) /* Call before fetching a character with *d. This switches over to string2 if necessary. */ #define PREFETCH() \ while (d == dend) \ { \ /* End of string2 => fail. */ \ if (dend == end_match_2) \ goto fail; \ /* End of string1 => advance to string2. */ \ d = string2; \ dend = end_match_2; \ } /* Test if at very beginning or at very end of the virtual concatenation of `string1' and `string2'. If only one string, it's `string2'. */ #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) #define AT_STRINGS_END(d) ((d) == end2) /* Test if D points to a character which is word-constituent. We have two special cases to check for: if past the end of string1, look at the first character in string2; and if before the beginning of string2, look at the last character in string1. */ #define WORDCHAR_P(d) \ (SYNTAX ((d) == end1 ? *string2 \ : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ == Sword) /* Test if the character before D and the one at D differ with respect to being word-constituent. */ #define AT_WORD_BOUNDARY(d) \ (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \ || WORDCHAR_P (d - 1) != WORDCHAR_P (d)) /* Free everything we malloc. */ #ifdef REGEX_MALLOC #define FREE_VAR(var) if (var) free (var); var = NULL #define FREE_VARIABLES() \ do { \ FREE_VAR (fail_stack.stack); \ FREE_VAR (regstart); \ FREE_VAR (regend); \ FREE_VAR (old_regstart); \ FREE_VAR (old_regend); \ FREE_VAR (best_regstart); \ FREE_VAR (best_regend); \ FREE_VAR (reg_info); \ FREE_VAR (reg_dummy); \ FREE_VAR (reg_info_dummy); \ } while (0) #else /* not REGEX_MALLOC */ /* Some MIPS systems (at least) want this to free alloca'd storage. */ #define FREE_VARIABLES() alloca (0) #endif /* not REGEX_MALLOC */ /* These values must meet several constraints. They must not be valid register values; since we have a limit of 255 registers (because we use only one byte in the pattern for the register number), we can use numbers larger than 255. They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value for the lowest register must be larger than the value for the highest register, so we do not try to actually save any registers when none are active. */ #define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH) #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) /* Matching routines. */ #ifndef emacs /* Emacs never uses this. */ /* re_match is like re_match_2 except it takes only a single string. */ int re_match (bufp, string, size, pos, regs) struct re_pattern_buffer *bufp; const char *string; int size, pos; struct re_registers *regs; { return re_match_2 (bufp, NULL, 0, string, size, pos, regs, size); } #endif /* not emacs */ /* re_match_2 matches the compiled pattern in BUFP against the the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and SIZE2, respectively). We start matching at POS, and stop matching at STOP. If REGS is non-null and the `no_sub' field of BUFP is nonzero, we store offsets for the substring each group matched in REGS. See the documentation for exactly how many groups we fill. We return -1 if no match, -2 if an internal error (such as the failure stack overflowing). Otherwise, we return the length of the matched substring. */ int re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) struct re_pattern_buffer *bufp; const char *string1, *string2; int size1, size2; int pos; struct re_registers *regs; int stop; { /* General temporaries. */ int mcnt; unsigned char *p1; /* Just past the end of the corresponding string. */ const char *end1, *end2; /* Pointers into string1 and string2, just past the last characters in each to consider matching. */ const char *end_match_1, *end_match_2; /* Where we are in the data, and the end of the current string. */ const char *d, *dend; /* Where we are in the pattern, and the end of the pattern. */ unsigned char *p = bufp->buffer; register unsigned char *pend = p + bufp->used; /* We use this to map every character in the string. */ char *translate = bufp->translate; /* Failure point stack. Each place that can handle a failure further down the line pushes a failure point on this stack. It consists of restart, regend, and reg_info for all registers corresponding to the subexpressions we're currently inside, plus the number of such registers, and, finally, two char *'s. The first char * is where to resume scanning the pattern; the second one is where to resume scanning the strings. If the latter is zero, the failure point is a ``dummy''; if a failure happens and the failure point is a dummy, it gets discarded and the next next one is tried. */ fail_stack_type fail_stack; #ifdef DEBUG static unsigned failure_id = 0; unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; #endif /* We fill all the registers internally, independent of what we return, for use in backreferences. The number here includes an element for register zero. */ size_t num_regs = bufp->re_nsub + 1; /* The currently active registers. */ active_reg_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; active_reg_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; /* Information on the contents of registers. These are pointers into the input strings; they record just what was matched (on this attempt) by a subexpression part of the pattern, that is, the regnum-th regstart pointer points to where in the pattern we began matching and the regnum-th regend points to right after where we stopped matching the regnum-th subexpression. (The zeroth register keeps track of what the whole pattern matches.) */ const char **regstart = 0, **regend = 0; /* If a group that's operated upon by a repetition operator fails to match anything, then the register for its start will need to be restored because it will have been set to wherever in the string we are when we last see its open-group operator. Similarly for a register's end. */ const char **old_regstart = 0, **old_regend = 0; /* The is_active field of reg_info helps us keep track of which (possibly nested) subexpressions we are currently in. The matched_something field of reg_info[reg_num] helps us tell whether or not we have matched any of the pattern so far this time through the reg_num-th subexpression. These two fields get reset each time through any loop their register is in. */ register_info_type *reg_info = 0; /* The following record the register info as found in the above variables when we find a match better than any we've seen before. This happens as we backtrack through the failure points, which in turn happens only if we have not yet matched the entire string. */ unsigned best_regs_set = false; const char **best_regstart = 0, **best_regend = 0; /* Logically, this is `best_regend[0]'. But we don't want to have to allocate space for that if we're not allocating space for anything else (see below). Also, we never need info about register 0 for any of the other register vectors, and it seems rather a kludge to treat `best_regend' differently than the rest. So we keep track of the end of the best match so far in a separate variable. We initialize this to NULL so that when we backtrack the first time and need to test it, it's not garbage. */ const char *match_end = NULL; /* Used when we pop values we don't care about. */ const char **reg_dummy = 0; register_info_type *reg_info_dummy = 0; #ifdef DEBUG /* Counts the total number of registers pushed. */ unsigned num_regs_pushed = 0; #endif DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); INIT_FAIL_STACK (); /* Do not bother to initialize all the register variables if there are no groups in the pattern, as it takes a fair amount of time. If there are groups, we include space for register 0 (the whole pattern), even though we never use it, since it simplifies the array indexing. We should fix this. */ if (bufp->re_nsub) { regstart = REGEX_TALLOC (num_regs, const char *); regend = REGEX_TALLOC (num_regs, const char *); old_regstart = REGEX_TALLOC (num_regs, const char *); old_regend = REGEX_TALLOC (num_regs, const char *); best_regstart = REGEX_TALLOC (num_regs, const char *); best_regend = REGEX_TALLOC (num_regs, const char *); reg_info = REGEX_TALLOC (num_regs, register_info_type); reg_dummy = REGEX_TALLOC (num_regs, const char *); reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); if (!(regstart && regend && old_regstart && old_regend && reg_info && best_regstart && best_regend && reg_dummy && reg_info_dummy)) { FREE_VARIABLES (); return -2; } } #ifdef REGEX_MALLOC else { /* We must initialize all our variables to NULL, so that `FREE_VARIABLES' doesn't try to free them. */ regstart = regend = old_regstart = old_regend = best_regstart = best_regend = reg_dummy = NULL; reg_info = reg_info_dummy = (register_info_type *) NULL; } #endif /* REGEX_MALLOC */ /* The starting position is bogus. */ if (pos < 0 || pos > size1 + size2) { FREE_VARIABLES (); return -1; } /* Initialize subexpression text positions to -1 to mark ones that no start_memory/stop_memory has been seen for. Also initialize the register information struct. */ for (mcnt = 1; mcnt < num_regs; mcnt++) { regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE; REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; IS_ACTIVE (reg_info[mcnt]) = 0; MATCHED_SOMETHING (reg_info[mcnt]) = 0; EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; } /* We move `string1' into `string2' if the latter's empty -- but not if `string1' is null. */ if (size2 == 0 && string1 != NULL) { string2 = string1; size2 = size1; string1 = 0; size1 = 0; } end1 = string1 + size1; end2 = string2 + size2; /* Compute where to stop matching, within the two strings. */ if (stop <= size1) { end_match_1 = string1 + stop; end_match_2 = string2; } else { end_match_1 = end1; end_match_2 = string2 + stop - size1; } /* `p' scans through the pattern as `d' scans through the data. `dend' is the end of the input string that `d' points within. `d' is advanced into the following input string whenever necessary, but this happens before fetching; therefore, at the beginning of the loop, `d' can be pointing at the end of a string, but it cannot equal `string2'. */ if (size1 > 0 && pos <= size1) { d = string1 + pos; dend = end_match_1; } else { d = string2 + pos - size1; dend = end_match_2; } DEBUG_PRINT1 ("The compiled pattern is: "); DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend); DEBUG_PRINT1 ("The string to match is: `"); DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); DEBUG_PRINT1 ("'\n"); /* This loops over pattern commands. It exits by returning from the function if the match is complete, or it drops through if the match fails at this starting point in the input data. */ for (;;) { DEBUG_PRINT2 ("\n0x%x: ", p); if (p == pend) { /* End of pattern means we might have succeeded. */ DEBUG_PRINT1 ("end of pattern ... "); /* If we haven't matched the entire string, and we want the longest match, try backtracking. */ if (d != end_match_2) { DEBUG_PRINT1 ("backtracking.\n"); if (!FAIL_STACK_EMPTY ()) { /* More failure points to try. */ boolean same_str_p = (FIRST_STRING_P (match_end) == MATCHING_IN_FIRST_STRING); /* If exceeds best match so far, save it. */ if (!best_regs_set || (same_str_p && d > match_end) || (!same_str_p && !MATCHING_IN_FIRST_STRING)) { best_regs_set = true; match_end = d; DEBUG_PRINT1 ("\nSAVING match as best so far.\n"); for (mcnt = 1; mcnt < num_regs; mcnt++) { best_regstart[mcnt] = regstart[mcnt]; best_regend[mcnt] = regend[mcnt]; } } goto fail; } /* If no failure points, don't restore garbage. */ else if (best_regs_set) { restore_best_regs: /* Restore best match. It may happen that `dend == end_match_1' while the restored d is in string2. For example, the pattern `x.*y.*z' against the strings `x-' and `y-z-', if the two strings are not consecutive in memory. */ DEBUG_PRINT1 ("Restoring best registers.\n"); d = match_end; dend = ((d >= string1 && d <= end1) ? end_match_1 : end_match_2); for (mcnt = 1; mcnt < num_regs; mcnt++) { regstart[mcnt] = best_regstart[mcnt]; regend[mcnt] = best_regend[mcnt]; } } } /* d != end_match_2 */ DEBUG_PRINT1 ("Accepting match.\n"); /* If caller wants register contents data back, do it. */ if (regs && !bufp->no_sub) { /* Have the register data arrays been allocated? */ if (bufp->regs_allocated == REGS_UNALLOCATED) { /* No. So allocate them with malloc. We need one extra element beyond `num_regs' for the `-1' marker GNU code uses. */ regs->num_regs = MAX (RE_NREGS, num_regs + 1); regs->start = TALLOC (regs->num_regs, regoff_t); regs->end = TALLOC (regs->num_regs, regoff_t); if (regs->start == NULL || regs->end == NULL) return -2; bufp->regs_allocated = REGS_REALLOCATE; } else if (bufp->regs_allocated == REGS_REALLOCATE) { /* Yes. If we need more elements than were already allocated, reallocate them. If we need fewer, just leave it alone. */ if (regs->num_regs < num_regs + 1) { regs->num_regs = num_regs + 1; RETALLOC (regs->start, regs->num_regs, regoff_t); RETALLOC (regs->end, regs->num_regs, regoff_t); if (regs->start == NULL || regs->end == NULL) return -2; } } else { /* These braces fend off a "empty body in an else-statement" warning under GCC when assert expands to nothing. */ assert (bufp->regs_allocated == REGS_FIXED); } /* Convert the pointer data in `regstart' and `regend' to indices. Register zero has to be set differently, since we haven't kept track of any info for it. */ if (regs->num_regs > 0) { regs->start[0] = pos; regs->end[0] = (MATCHING_IN_FIRST_STRING ? d - string1 : d - string2 + size1); } /* Go through the first `min (num_regs, regs->num_regs)' registers, since that is all we initialized. */ for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++) { if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt])) regs->start[mcnt] = regs->end[mcnt] = -1; else { regs->start[mcnt] = POINTER_TO_OFFSET (regstart[mcnt]); regs->end[mcnt] = POINTER_TO_OFFSET (regend[mcnt]); } } /* If the regs structure we return has more elements than were in the pattern, set the extra elements to -1. If we (re)allocated the registers, this is the case, because we always allocate enough to have at least one -1 at the end. */ for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++) regs->start[mcnt] = regs->end[mcnt] = -1; } /* regs && !bufp->no_sub */ FREE_VARIABLES (); DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", nfailure_points_pushed, nfailure_points_popped, nfailure_points_pushed - nfailure_points_popped); DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed); mcnt = d - pos - (MATCHING_IN_FIRST_STRING ? string1 : string2 - size1); DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); return mcnt; } /* Otherwise match next pattern command. */ #ifdef SWITCH_ENUM_BUG switch ((int) ((re_opcode_t) *p++)) #else switch ((re_opcode_t) *p++) #endif { /* Ignore these. Used to ignore the n of succeed_n's which currently have n == 0. */ case no_op: DEBUG_PRINT1 ("EXECUTING no_op.\n"); break; /* Match the next n pattern characters exactly. The following byte in the pattern defines n, and the n bytes after that are the characters to match. */ case exactn: mcnt = *p++; DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt); /* This is written out as an if-else so we don't waste time testing `translate' inside the loop. */ if (translate) { do { PREFETCH (); if (translate[(unsigned char) *d++] != (char) *p++) goto fail; } while (--mcnt); } else { do { PREFETCH (); if (*d++ != (char) *p++) goto fail; } while (--mcnt); } SET_REGS_MATCHED (); break; /* Match any character except possibly a newline or a null. */ case anychar: DEBUG_PRINT1 ("EXECUTING anychar.\n"); PREFETCH (); if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n') || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000')) goto fail; SET_REGS_MATCHED (); DEBUG_PRINT2 (" Matched `%d'.\n", *d); d++; break; case charset: case charset_not: { register unsigned char c; boolean not = (re_opcode_t) *(p - 1) == charset_not; DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : ""); PREFETCH (); c = TRANSLATE (*d); /* The character to match. */ /* Cast to `unsigned' instead of `unsigned char' in case the bit list is a full 32 bytes long. */ if (c < (unsigned) (*p * BYTEWIDTH) && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) not = !not; p += 1 + *p; if (!not) goto fail; SET_REGS_MATCHED (); d++; break; } /* The beginning of a group is represented by start_memory. The arguments are the register number in the next byte, and the number of groups inner to this one in the next. The text matched within the group is recorded (in the internal registers data structure) under the register number. */ case start_memory: DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]); /* Find out if this group can match the empty string. */ p1 = p; /* To send to group_match_null_string_p. */ if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE) REG_MATCH_NULL_STRING_P (reg_info[*p]) = group_match_null_string_p (&p1, pend, reg_info); /* Save the position in the string where we were the last time we were at this open-group operator in case the group is operated upon by a repetition operator, e.g., with `(a*)*b' against `ab'; then we want to ignore where we are now in the string in case this attempt to match fails. */ old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) ? REG_UNSET (regstart[*p]) ? d : regstart[*p] : regstart[*p]; DEBUG_PRINT2 (" old_regstart: %d\n", POINTER_TO_OFFSET (old_regstart[*p])); regstart[*p] = d; DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p])); IS_ACTIVE (reg_info[*p]) = 1; MATCHED_SOMETHING (reg_info[*p]) = 0; /* This is the new highest active register. */ highest_active_reg = *p; /* If nothing was active before, this is the new lowest active register. */ if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) lowest_active_reg = *p; /* Move past the register number and inner group count. */ p += 2; break; /* The stop_memory opcode represents the end of a group. Its arguments are the same as start_memory's: the register number, and the number of inner groups. */ case stop_memory: DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]); /* We need to save the string position the last time we were at this close-group operator in case the group is operated upon by a repetition operator, e.g., with `((a*)*(b*)*)*' against `aba'; then we want to ignore where we are now in the string in case this attempt to match fails. */ old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) ? REG_UNSET (regend[*p]) ? d : regend[*p] : regend[*p]; DEBUG_PRINT2 (" old_regend: %d\n", POINTER_TO_OFFSET (old_regend[*p])); regend[*p] = d; DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p])); /* This register isn't active anymore. */ IS_ACTIVE (reg_info[*p]) = 0; /* If this was the only register active, nothing is active anymore. */ if (lowest_active_reg == highest_active_reg) { lowest_active_reg = NO_LOWEST_ACTIVE_REG; highest_active_reg = NO_HIGHEST_ACTIVE_REG; } else { /* We must scan for the new highest active register, since it isn't necessarily one less than now: consider (a(b)c(d(e)f)g). When group 3 ends, after the f), the new highest active register is 1. */ unsigned char r = *p - 1; while (r > 0 && !IS_ACTIVE (reg_info[r])) r--; /* If we end up at register zero, that means that we saved the registers as the result of an `on_failure_jump', not a `start_memory', and we jumped to past the innermost `stop_memory'. For example, in ((.)*) we save registers 1 and 2 as a result of the *, but when we pop back to the second ), we are at the stop_memory 1. Thus, nothing is active. */ if (r == 0) { lowest_active_reg = NO_LOWEST_ACTIVE_REG; highest_active_reg = NO_HIGHEST_ACTIVE_REG; } else highest_active_reg = r; } /* If just failed to match something this time around with a group that's operated on by a repetition operator, try to force exit from the ``loop'', and restore the register information for this group that we had before trying this last match. */ if ((!MATCHED_SOMETHING (reg_info[*p]) || (re_opcode_t) p[-3] == start_memory) && (p + 2) < pend) { boolean is_a_jump_n = false; p1 = p + 2; mcnt = 0; switch ((re_opcode_t) *p1++) { case jump_n: is_a_jump_n = true; case pop_failure_jump: case maybe_pop_jump: case jump: case dummy_failure_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p1); if (is_a_jump_n) p1 += 2; break; default: /* do nothing */ ; } p1 += mcnt; /* If the next operation is a jump backwards in the pattern to an on_failure_jump right before the start_memory corresponding to this stop_memory, exit from the loop by forcing a failure after pushing on the stack the on_failure_jump's jump in the pattern, and d. */ if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump && (re_opcode_t) p1[3] == start_memory && p1[4] == *p) { /* If this group ever matched anything, then restore what its registers were before trying this last failed match, e.g., with `(a*)*b' against `ab' for regstart[1], and, e.g., with `((a*)*(b*)*)*' against `aba' for regend[3]. Also restore the registers for inner groups for, e.g., `((a*)(b*))*' against `aba' (register 3 would otherwise get trashed). */ if (EVER_MATCHED_SOMETHING (reg_info[*p])) { unsigned r; EVER_MATCHED_SOMETHING (reg_info[*p]) = 0; /* Restore this and inner groups' (if any) registers. */ for (r = *p; r < *p + *(p + 1); r++) { regstart[r] = old_regstart[r]; /* xx why this test? */ if ((s_reg_t) old_regend[r] >= (s_reg_t) regstart[r]) regend[r] = old_regend[r]; } } p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); PUSH_FAILURE_POINT (p1 + mcnt, d, -2); PUSH_FAILURE_POINT2(p1 + mcnt, d, -2); goto fail; } } /* Move past the register number and the inner group count. */ p += 2; break; /* \ has been turned into a `duplicate' command which is followed by the numeric value of as the register number. */ case duplicate: { register const char *d2, *dend2; int regno = *p++; /* Get which register to match against. */ DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno); /* Can't back reference a group which we've never matched. */ if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) goto fail; /* Where in input to try to start matching. */ d2 = regstart[regno]; /* Where to stop matching; if both the place to start and the place to stop matching are in the same string, then set to the place to stop, otherwise, for now have to use the end of the first string. */ dend2 = ((FIRST_STRING_P (regstart[regno]) == FIRST_STRING_P (regend[regno])) ? regend[regno] : end_match_1); for (;;) { /* If necessary, advance to next segment in register contents. */ while (d2 == dend2) { if (dend2 == end_match_2) break; if (dend2 == regend[regno]) break; /* End of string1 => advance to string2. */ d2 = string2; dend2 = regend[regno]; } /* At end of register contents => success */ if (d2 == dend2) break; /* If necessary, advance to next segment in data. */ PREFETCH (); /* How many characters left in this segment to match. */ mcnt = dend - d; /* Want how many consecutive characters we can match in one shot, so, if necessary, adjust the count. */ if (mcnt > dend2 - d2) mcnt = dend2 - d2; /* Compare that many; failure if mismatch, else move past them. */ if (translate ? bcmp_translate (d, d2, mcnt, translate) : bcmp (d, d2, mcnt)) goto fail; d += mcnt, d2 += mcnt; } } break; /* begline matches the empty string at the beginning of the string (unless `not_bol' is set in `bufp'), and, if `newline_anchor' is set, after newlines. */ case begline: DEBUG_PRINT1 ("EXECUTING begline.\n"); if (AT_STRINGS_BEG (d)) { if (!bufp->not_bol) break; } else if (d[-1] == '\n' && bufp->newline_anchor) { break; } /* In all other cases, we fail. */ goto fail; /* endline is the dual of begline. */ case endline: DEBUG_PRINT1 ("EXECUTING endline.\n"); if (AT_STRINGS_END (d)) { if (!bufp->not_eol) break; } /* We have to ``prefetch'' the next character. */ else if ((d == end1 ? *string2 : *d) == '\n' && bufp->newline_anchor) { break; } goto fail; /* Match at the very beginning of the data. */ case begbuf: DEBUG_PRINT1 ("EXECUTING begbuf.\n"); if (AT_STRINGS_BEG (d)) break; goto fail; /* Match at the very end of the data. */ case endbuf: DEBUG_PRINT1 ("EXECUTING endbuf.\n"); if (AT_STRINGS_END (d)) break; goto fail; /* on_failure_keep_string_jump is used to optimize `.*\n'. It pushes NULL as the value for the string on the stack. Then `pop_failure_point' will keep the current value for the string, instead of restoring it. To see why, consider matching `foo\nbar' against `.*\n'. The .* matches the foo; then the . fails against the \n. But the next thing we want to do is match the \n against the \n; if we restored the string value, we would be back at the foo. Because this is used only in specific cases, we don't need to check all the things that `on_failure_jump' does, to make sure the right things get saved on the stack. Hence we don't share its code. The only reason to push anything on the stack at all is that otherwise we would have to change `anychar's code to do something besides goto fail in this case; that seems worse than this. */ case on_failure_keep_string_jump: DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt); PUSH_FAILURE_POINT (p + mcnt, NULL, -2); PUSH_FAILURE_POINT2(p + mcnt, NULL, -2); break; /* Uses of on_failure_jump: Each alternative starts with an on_failure_jump that points to the beginning of the next alternative. Each alternative except the last ends with a jump that in effect jumps past the rest of the alternatives. (They really jump to the ending jump of the following alternative, because tensioning these jumps is a hassle.) Repeats start with an on_failure_jump that points past both the repetition text and either the following jump or pop_failure_jump back to this on_failure_jump. */ case on_failure_jump: on_failure: DEBUG_PRINT1 ("EXECUTING on_failure_jump"); EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt); /* If this on_failure_jump comes right before a group (i.e., the original * applied to a group), save the information for that group and all inner ones, so that if we fail back to this point, the group's information will be correct. For example, in \(a*\)*\1, we need the preceding group, and in \(\(a*\)b*\)\2, we need the inner group. */ /* We can't use `p' to check ahead because we push a failure point to `p + mcnt' after we do this. */ p1 = p; /* We need to skip no_op's before we look for the start_memory in case this on_failure_jump is happening as the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 against aba. */ while (p1 < pend && (re_opcode_t) *p1 == no_op) p1++; if (p1 < pend && (re_opcode_t) *p1 == start_memory) { /* We have a new highest active register now. This will get reset at the start_memory we are about to get to, but we will have saved all the registers relevant to this repetition op, as described above. */ highest_active_reg = *(p1 + 1) + *(p1 + 2); if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) lowest_active_reg = *(p1 + 1); } DEBUG_PRINT1 (":\n"); PUSH_FAILURE_POINT (p + mcnt, d, -2); PUSH_FAILURE_POINT2(p + mcnt, d, -2); break; /* A smart repeat ends with `maybe_pop_jump'. We change it to either `pop_failure_jump' or `jump'. */ case maybe_pop_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); { register unsigned char *p2 = p; /* Compare the beginning of the repeat with what in the pattern follows its end. If we can establish that there is nothing that they would both match, i.e., that we would have to backtrack because of (as in, e.g., `a*a') then we can change to pop_failure_jump, because we'll never have to backtrack. This is not true in the case of alternatives: in `(a|ab)*' we do need to backtrack to the `ab' alternative (e.g., if the string was `ab'). But instead of trying to detect that here, the alternative has put on a dummy failure point which is what we will end up popping. */ /* Skip over open/close-group commands. */ while (p2 + 2 < pend && ((re_opcode_t) *p2 == stop_memory || (re_opcode_t) *p2 == start_memory)) p2 += 3; /* Skip over args, too. */ /* If we're at the end of the pattern, we can change. */ if (p2 == pend) { /* Consider what happens when matching ":\(.*\)" against ":/". I don't really understand this code yet. */ p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT1 (" End of pattern: change to `pop_failure_jump'.\n"); } else if ((re_opcode_t) *p2 == exactn || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) { register unsigned char c = *p2 == (unsigned char) endline ? '\n' : p2[2]; p1 = p + mcnt; /* p1[0] ... p1[2] are the `on_failure_jump' corresponding to the `maybe_finalize_jump' of this case. Examine what follows. */ if ((re_opcode_t) p1[3] == exactn && p1[5] != c) { p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", c, p1[5]); } else if ((re_opcode_t) p1[3] == charset || (re_opcode_t) p1[3] == charset_not) { int not = (re_opcode_t) p1[3] == charset_not; if (c < (unsigned char) (p1[4] * BYTEWIDTH) && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) not = !not; /* `not' is equal to 1 if c would match, which means that we can't change to pop_failure_jump. */ if (!not) { p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); } } } } p -= 2; /* Point at relative address again. */ if ((re_opcode_t) p[-1] != pop_failure_jump) { p[-1] = (unsigned char) jump; DEBUG_PRINT1 (" Match => jump.\n"); goto unconditional_jump; } /* Note fall through. */ /* The end of a simple repeat has a pop_failure_jump back to its matching on_failure_jump, where the latter will push a failure point. The pop_failure_jump takes off failure points put on by this pop_failure_jump's matching on_failure_jump; we got through the pattern to here from the matching on_failure_jump, so didn't fail. */ case pop_failure_jump: { /* We need to pass separate storage for the lowest and highest registers, even though we don't care about the actual values. Otherwise, we will restore only one register from the stack, since lowest will == highest in `pop_failure_point'. */ active_reg_t dummy_low_reg, dummy_high_reg; unsigned char *pdummy; const char *sdummy; DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n"); POP_FAILURE_POINT (sdummy, pdummy, dummy_low_reg, dummy_high_reg, reg_dummy, reg_dummy, reg_info_dummy); } /* Note fall through. */ /* Unconditionally jump (without popping any failure points). */ case jump: unconditional_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); p += mcnt; /* Do the jump. */ DEBUG_PRINT2 ("(to 0x%x).\n", p); break; /* We need this opcode so we can detect where alternatives end in `group_match_null_string_p' et al. */ case jump_past_alt: DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n"); goto unconditional_jump; /* Normally, the on_failure_jump pushes a failure point, which then gets popped at pop_failure_jump. We will end up at pop_failure_jump, also, and with a pattern of, say, `a+', we are skipping over the on_failure_jump, so we have to push something meaningless for pop_failure_jump to pop. */ case dummy_failure_jump: DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n"); /* It doesn't matter what we push for the string here. What the code at `fail' tests is the value for the pattern. */ PUSH_FAILURE_POINT (0, 0, -2); PUSH_FAILURE_POINT2(0, 0, -2); goto unconditional_jump; /* At the end of an alternative, we need to push a dummy failure point in case we are followed by a `pop_failure_jump', because we don't want the failure point for the alternative to be popped. For example, matching `(a|ab)*' against `aab' requires that we match the `ab' alternative. */ case push_dummy_failure: DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n"); /* See comments just above at `dummy_failure_jump' about the two zeroes. */ PUSH_FAILURE_POINT (0, 0, -2); PUSH_FAILURE_POINT2(0, 0, -2); break; /* Have to succeed matching what follows at least n times. After that, handle like `on_failure_jump'. */ case succeed_n: EXTRACT_NUMBER (mcnt, p + 2); DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); assert (mcnt >= 0); /* Originally, this is how many times we HAVE to succeed. */ if (mcnt > 0) { mcnt--; p += 2; STORE_NUMBER_AND_INCR (p, mcnt); DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p, mcnt); } else if (mcnt == 0) { DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", p+2); p[2] = (unsigned char) no_op; p[3] = (unsigned char) no_op; goto on_failure; } break; case jump_n: EXTRACT_NUMBER (mcnt, p + 2); DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); /* Originally, this is how many times we CAN jump. */ if (mcnt) { mcnt--; STORE_NUMBER (p + 2, mcnt); goto unconditional_jump; } /* If don't have to jump any more, skip over the rest of command. */ else p += 4; break; case set_number_at: { DEBUG_PRINT1 ("EXECUTING set_number_at.\n"); EXTRACT_NUMBER_AND_INCR (mcnt, p); p1 = p + mcnt; EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt); STORE_NUMBER (p1, mcnt); break; } case wordbound: DEBUG_PRINT1 ("EXECUTING wordbound.\n"); if (AT_WORD_BOUNDARY (d)) break; goto fail; case notwordbound: DEBUG_PRINT1 ("EXECUTING notwordbound.\n"); if (AT_WORD_BOUNDARY (d)) goto fail; break; case wordbeg: DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) break; goto fail; case wordend: DEBUG_PRINT1 ("EXECUTING wordend.\n"); if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1) && (!WORDCHAR_P (d) || AT_STRINGS_END (d))) break; goto fail; #ifdef emacs #ifdef emacs19 case before_dot: DEBUG_PRINT1 ("EXECUTING before_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) >= point) goto fail; break; case at_dot: DEBUG_PRINT1 ("EXECUTING at_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) != point) goto fail; break; case after_dot: DEBUG_PRINT1 ("EXECUTING after_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) <= point) goto fail; break; #else /* not emacs19 */ case at_dot: DEBUG_PRINT1 ("EXECUTING at_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point) goto fail; break; #endif /* not emacs19 */ case syntaxspec: DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); mcnt = *p++; goto matchsyntax; case wordchar: DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n"); mcnt = (int) Sword; matchsyntax: PREFETCH (); if (SYNTAX (*d++) != (enum syntaxcode) mcnt) goto fail; SET_REGS_MATCHED (); break; case notsyntaxspec: DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt); mcnt = *p++; goto matchnotsyntax; case notwordchar: DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n"); mcnt = (int) Sword; matchnotsyntax: PREFETCH (); if (SYNTAX (*d++) == (enum syntaxcode) mcnt) goto fail; SET_REGS_MATCHED (); break; #else /* not emacs */ case wordchar: DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); PREFETCH (); if (!WORDCHAR_P (d)) goto fail; SET_REGS_MATCHED (); d++; break; case notwordchar: DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); PREFETCH (); if (WORDCHAR_P (d)) goto fail; SET_REGS_MATCHED (); d++; break; #endif /* not emacs */ default: abort (); } continue; /* Successfully executed one pattern command; keep going. */ /* We goto here if a matching operation fails. */ fail: if (!FAIL_STACK_EMPTY ()) { /* A restart point is known. Restore to that state. */ DEBUG_PRINT1 ("\nFAIL:\n"); POP_FAILURE_POINT (d, p, lowest_active_reg, highest_active_reg, regstart, regend, reg_info); /* If this failure point is a dummy, try the next one. */ if (!p) goto fail; /* If we failed to the end of the pattern, don't examine *p. */ assert (p <= pend); if (p < pend) { boolean is_a_jump_n = false; /* If failed to a backwards jump that's part of a repetition loop, need to pop this failure point and use the next one. */ switch ((re_opcode_t) *p) { case jump_n: is_a_jump_n = true; case maybe_pop_jump: case pop_failure_jump: case jump: p1 = p + 1; EXTRACT_NUMBER_AND_INCR (mcnt, p1); p1 += mcnt; if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n) || (!is_a_jump_n && (re_opcode_t) *p1 == on_failure_jump)) goto fail; break; default: /* do nothing */ ; } } if (d >= string1 && d <= end1) dend = end_match_1; } else break; /* Matching at this starting point really fails. */ } /* for (;;) */ if (best_regs_set) goto restore_best_regs; FREE_VARIABLES (); return -1; /* Failure to match. */ } /* re_match_2 */ /* Subroutine definitions for re_match_2. */ /* We are passed P pointing to a register number after a start_memory. Return true if the pattern up to the corresponding stop_memory can match the empty string, and false otherwise. If we find the matching stop_memory, sets P to point to one past its number. Otherwise, sets P to an undefined byte less than or equal to END. We don't handle duplicates properly (yet). */ static boolean group_match_null_string_p (p, end, reg_info) unsigned char **p, *end; register_info_type *reg_info; { int mcnt; /* Point to after the args to the start_memory. */ unsigned char *p1 = *p + 2; while (p1 < end) { /* Skip over opcodes that can match nothing, and return true or false, as appropriate, when we get to one that can't, or to the matching stop_memory. */ switch ((re_opcode_t) *p1) { /* Could be either a loop or a series of alternatives. */ case on_failure_jump: p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); /* If the next operation is not a jump backwards in the pattern. */ if (mcnt >= 0) { /* Go through the on_failure_jumps of the alternatives, seeing if any of the alternatives cannot match nothing. The last alternative starts with only a jump, whereas the rest start with on_failure_jump and end with a jump, e.g., here is the pattern for `a|b|c': /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6 /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3 /exactn/1/c So, we have to first go through the first (n-1) alternatives and then deal with the last one separately. */ /* Deal with the first (n-1) alternatives, which start with an on_failure_jump (see above) that jumps to right past a jump_past_alt. */ while ((re_opcode_t) p1[mcnt-3] == jump_past_alt) { /* `mcnt' holds how many bytes long the alternative is, including the ending `jump_past_alt' and its number. */ if (!alt_match_null_string_p (p1, p1 + mcnt - 3, reg_info)) return false; /* Move to right after this alternative, including the jump_past_alt. */ p1 += mcnt; /* Break if it's the beginning of an n-th alternative that doesn't begin with an on_failure_jump. */ if ((re_opcode_t) *p1 != on_failure_jump) break; /* Still have to check that it's not an n-th alternative that starts with an on_failure_jump. */ p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); if ((re_opcode_t) p1[mcnt-3] != jump_past_alt) { /* Get to the beginning of the n-th alternative. */ p1 -= 3; break; } } /* Deal with the last alternative: go back and get number of the `jump_past_alt' just before it. `mcnt' contains the length of the alternative. */ EXTRACT_NUMBER (mcnt, p1 - 2); if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info)) return false; p1 += mcnt; /* Get past the n-th alternative. */ } /* if mcnt > 0 */ break; case stop_memory: assert (p1[1] == **p); *p = p1 + 2; return true; default: if (!common_op_match_null_string_p (&p1, end, reg_info)) return false; } } /* while p1 < end */ return false; } /* group_match_null_string_p */ /* Similar to group_match_null_string_p, but doesn't deal with alternatives: It expects P to be the first byte of a single alternative and END one byte past the last. The alternative can contain groups. */ static boolean alt_match_null_string_p (p, end, reg_info) unsigned char *p, *end; register_info_type *reg_info; { int mcnt; unsigned char *p1 = p; while (p1 < end) { /* Skip over opcodes that can match nothing, and break when we get to one that can't. */ switch ((re_opcode_t) *p1) { /* It's a loop. */ case on_failure_jump: p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); p1 += mcnt; break; default: if (!common_op_match_null_string_p (&p1, end, reg_info)) return false; } } /* while p1 < end */ return true; } /* alt_match_null_string_p */ /* Deals with the ops common to group_match_null_string_p and alt_match_null_string_p. Sets P to one after the op and its arguments, if any. */ static boolean common_op_match_null_string_p (p, end, reg_info) unsigned char **p, *end; register_info_type *reg_info; { int mcnt; boolean ret; int reg_no; unsigned char *p1 = *p; switch ((re_opcode_t) *p1++) { case no_op: case begline: case endline: case begbuf: case endbuf: case wordbeg: case wordend: case wordbound: case notwordbound: #ifdef emacs case before_dot: case at_dot: case after_dot: #endif break; case start_memory: reg_no = *p1; assert (reg_no > 0 && reg_no <= MAX_REGNUM); ret = group_match_null_string_p (&p1, end, reg_info); /* Have to set this here in case we're checking a group which contains a group and a back reference to it. */ if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE) REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret; if (!ret) return false; break; /* If this is an optimized succeed_n for zero times, make the jump. */ case jump: EXTRACT_NUMBER_AND_INCR (mcnt, p1); if (mcnt >= 0) p1 += mcnt; else return false; break; case succeed_n: /* Get to the number of times to succeed. */ p1 += 2; EXTRACT_NUMBER_AND_INCR (mcnt, p1); if (mcnt == 0) { p1 -= 4; EXTRACT_NUMBER_AND_INCR (mcnt, p1); p1 += mcnt; } else return false; break; case duplicate: if (!REG_MATCH_NULL_STRING_P (reg_info[*p1])) return false; break; case set_number_at: p1 += 4; default: /* All other opcodes mean we cannot match the empty string. */ return false; } *p = p1; return true; } /* common_op_match_null_string_p */ /* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN bytes; nonzero otherwise. */ static int bcmp_translate (s1, s2, len, translate) const char *s1, *s2; register int len; char *translate; { register const unsigned char *p1 = (const unsigned char *) s1, *p2 = (const unsigned char *) s2; while (len) { if (translate[*p1++] != translate[*p2++]) return 1; len--; } return 0; } /* Entry points for GNU code. */ /* re_compile_pattern is the GNU regular expression compiler: it compiles PATTERN (of length SIZE) and puts the result in BUFP. Returns 0 if the pattern was valid, otherwise an error string. Assumes the `allocated' (and perhaps `buffer') and `translate' fields are set in BUFP on entry. We call regex_compile to do the actual compilation. */ const char * re_compile_pattern (pattern, length, bufp) const char *pattern; size_t length; struct re_pattern_buffer *bufp; { reg_errcode_t ret; /* GNU code is written to assume at least RE_NREGS registers will be set (and at least one extra will be -1). */ bufp->regs_allocated = REGS_UNALLOCATED; /* And GNU code determines whether or not to get register information by passing null for the REGS argument to re_match, etc., not by setting no_sub. */ bufp->no_sub = 0; /* Match anchors at newline. */ bufp->newline_anchor = 1; ret = regex_compile (pattern, length, re_syntax_options, bufp); return re_error_msg[(int) ret]; } /* Entry points compatible with 4.2 BSD regex library. We don't define them if this is an Emacs or POSIX compilation. */ #if (!defined (emacs) && !defined (_POSIX_SOURCE)) || defined(USE_BSD_REGEX) /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer re_comp_buf; char * re_comp (s) const char *s; { reg_errcode_t ret; if (!s || *s == '\0') { if (!re_comp_buf.buffer) return "No previous regular expression"; return 0; } if (!re_comp_buf.buffer) { re_comp_buf.buffer = (unsigned char *) malloc (200); if (re_comp_buf.buffer == NULL) return "Memory exhausted"; re_comp_buf.allocated = 200; re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); if (re_comp_buf.fastmap == NULL) return "Memory exhausted"; } /* Since `re_exec' always passes NULL for the `regs' argument, we don't need to initialize the pattern buffer fields which affect it. */ /* Match anchors at newlines. */ re_comp_buf.newline_anchor = 1; ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf); /* Yes, we're discarding `const' here. */ return (char *) re_error_msg[(int) ret]; } int re_exec (s) const char *s; { const int len = strlen (s); return 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); } #endif /* not emacs and not _POSIX_SOURCE */ /* POSIX.2 functions. Don't define these for Emacs. */ #ifndef emacs /* regcomp takes a regular expression as a string and compiles it. PREG is a regex_t *. We do not expect any fields to be initialized, since POSIX says we shouldn't. Thus, we set `buffer' to the compiled pattern; `used' to the length of the compiled pattern; `syntax' to RE_SYNTAX_POSIX_EXTENDED if the REG_EXTENDED bit in CFLAGS is set; otherwise, to RE_SYNTAX_POSIX_BASIC; `newline_anchor' to REG_NEWLINE being set in CFLAGS; `fastmap' and `fastmap_accurate' to zero; `re_nsub' to the number of subexpressions in PATTERN. PATTERN is the address of the pattern string. CFLAGS is a series of bits which affect compilation. If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we use POSIX basic syntax. If REG_NEWLINE is set, then . and [^...] don't match newline. Also, regexec will try a match beginning after every newline. If REG_ICASE is set, then we considers upper- and lowercase versions of letters to be equivalent when matching. If REG_NOSUB is set, then when PREG is passed to regexec, that routine will report only success or failure, and nothing about the registers. It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for the return codes and their meanings.) */ int regcomp (preg, pattern, cflags) regex_t *preg; const char *pattern; int cflags; { reg_errcode_t ret; reg_syntax_t syntax = (cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; /* regex_compile will allocate the space for the compiled pattern. */ preg->buffer = 0; preg->allocated = 0; preg->used = 0; /* Don't bother to use a fastmap when searching. This simplifies the REG_NEWLINE case: if we used a fastmap, we'd have to put all the characters after newlines into the fastmap. This way, we just try every character. */ preg->fastmap = 0; if (cflags & REG_ICASE) { unsigned i; preg->translate = (char *) malloc (CHAR_SET_SIZE); if (preg->translate == NULL) return (int) REG_ESPACE; /* Map uppercase characters to corresponding lowercase ones. */ for (i = 0; i < CHAR_SET_SIZE; i++) preg->translate[i] = ISUPPER (i) ? tolower (i) : i; } else preg->translate = NULL; /* If REG_NEWLINE is set, newlines are treated differently. */ if (cflags & REG_NEWLINE) { /* REG_NEWLINE implies neither . nor [^...] match newline. */ syntax &= ~RE_DOT_NEWLINE; syntax |= RE_HAT_LISTS_NOT_NEWLINE; /* It also changes the matching behavior. */ preg->newline_anchor = 1; } else preg->newline_anchor = 0; preg->no_sub = !!(cflags & REG_NOSUB); /* POSIX says a null character in the pattern terminates it, so we can use strlen here in compiling the pattern. */ ret = regex_compile (pattern, strlen (pattern), syntax, preg); /* POSIX doesn't distinguish between an unmatched open-group and an unmatched close-group: both are REG_EPAREN. */ if (ret == REG_ERPAREN) ret = REG_EPAREN; return (int) ret; } /* regexec searches for a given pattern, specified by PREG, in the string STRING. If NMATCH is zero or REG_NOSUB was set in the cflags argument to `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at least NMATCH elements, and we set them to the offsets of the corresponding matched substrings. EFLAGS specifies `execution flags' which affect matching: if REG_NOTBOL is set, then ^ does not match at the beginning of the string; if REG_NOTEOL is set, then $ does not match at the end. We return 0 if we find a match and REG_NOMATCH if not. */ int regexec (preg, string, nmatch, pmatch, eflags) const regex_t *preg; const char *string; size_t nmatch; regmatch_t pmatch[]; int eflags; { int ret; struct re_registers regs; regex_t private_preg; int len = strlen (string); boolean want_reg_info = !preg->no_sub && nmatch > 0; private_preg = *preg; private_preg.not_bol = !!(eflags & REG_NOTBOL); private_preg.not_eol = !!(eflags & REG_NOTEOL); /* The user has told us exactly how many registers to return information about, via `nmatch'. We have to pass that on to the matching routines. */ private_preg.regs_allocated = REGS_FIXED; if (want_reg_info) { regs.num_regs = nmatch; regs.start = TALLOC (nmatch, regoff_t); regs.end = TALLOC (nmatch, regoff_t); if (regs.start == NULL || regs.end == NULL) return (int) REG_NOMATCH; } /* Perform the searching operation. */ ret = re_search (&private_preg, string, len, /* start: */ 0, /* range: */ len, want_reg_info ? ®s : (struct re_registers *) 0); /* Copy the register information to the POSIX structure. */ if (want_reg_info) { if (ret >= 0) { unsigned r; for (r = 0; r < nmatch; r++) { pmatch[r].rm_so = regs.start[r]; pmatch[r].rm_eo = regs.end[r]; } } /* If we needed the temporary register info, free the space now. */ free (regs.start); free (regs.end); } /* We want zero return to mean success, unlike `re_search'. */ return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH; } /* Returns a message corresponding to an error code, ERRCODE, returned from either regcomp or regexec. We don't use PREG here. */ size_t regerror (errcode, preg, errbuf, errbuf_size) int errcode; const regex_t *preg; char *errbuf; size_t errbuf_size; { const char *msg; size_t msg_size; if (errcode < 0 || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0]))) /* Only error codes returned by the rest of the code should be passed to this routine. If we are given anything else, or if other regex code generates an invalid error code, then the program has a bug. Dump core so we can fix it. */ abort (); msg = re_error_msg[errcode]; /* POSIX doesn't require that we do anything in this case, but why not be nice. */ if (! msg) msg = "Success"; msg_size = strlen (msg) + 1; /* Includes the null. */ if (errbuf_size != 0) { if (msg_size > errbuf_size) { strncpy (errbuf, msg, errbuf_size - 1); errbuf[errbuf_size - 1] = 0; } else strcpy (errbuf, msg); } return msg_size; } /* Free dynamically allocated space used by PREG. */ void regfree (preg) regex_t *preg; { if (preg->buffer != NULL) free (preg->buffer); preg->buffer = NULL; preg->allocated = 0; preg->used = 0; if (preg->fastmap != NULL) free (preg->fastmap); preg->fastmap = NULL; preg->fastmap_accurate = 0; if (preg->translate != NULL) free (preg->translate); preg->translate = NULL; } #endif /* not emacs */ /* Local variables: make-backup-files: t version-control: t trim-versions-without-asking: nil End: */ ./libc-linux/regex/regex.diff100755 1676 334 2321 5527062577 14212 0ustar hjlisl*** regex.c.orig Fri Feb 11 11:44:45 1994 --- regex.c Fri Feb 11 11:50:31 1994 *************** *** 24,30 **** --- 24,32 ---- #pragma alloca #endif + #ifndef _GNU_SOURCE #define _GNU_SOURCE + #endif #ifdef HAVE_CONFIG_H #include "config.h" *************** *** 4762,4768 **** /* Entry points compatible with 4.2 BSD regex library. We don't define them if this is an Emacs or POSIX compilation. */ ! #if !defined (emacs) && !defined (_POSIX_SOURCE) /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer re_comp_buf; --- 4764,4770 ---- /* Entry points compatible with 4.2 BSD regex library. We don't define them if this is an Emacs or POSIX compilation. */ ! #if (!defined (emacs) && !defined (_POSIX_SOURCE)) || defined(USE_BSD_REGEX) /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer re_comp_buf; *************** *** 4773,4779 **** { reg_errcode_t ret; ! if (!s) { if (!re_comp_buf.buffer) return "No previous regular expression"; --- 4775,4781 ---- { reg_errcode_t ret; ! if (!s || *s == '\0') { if (!re_comp_buf.buffer) return "No previous regular expression"; ./libc-linux/regex/rx.c100644 1676 334 661756 5520375500 13111 0ustar hjlisl/* Copyright (C) 1992, 1993 Free Software Foundation, Inc. This program 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 program 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 this software; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* NOTE!!! AIX requires this to be the first thing in the file. * Do not put ANYTHING before it! */ #if !defined (__GNUC__) && defined (_AIX) #pragma alloca #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif static char rx_version_string[] = "GNU Rx version 0.03"; /* ``Too hard!'' * -- anon. */ #include #include #ifndef isgraph #define isgraph(c) (isprint (c) && !isspace (c)) #endif #ifndef isblank #define isblank(c) ((c) == ' ' || (c) == '\t') #endif #include #include #include "rx.h" #undef MAX #undef MIN #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) typedef char boolean; #define false 0 #define true 1 /* This page is decls to the interesting subsystems and lower layers * of rx. Everything which doesn't have a public counterpart in * regex.c is declared here. * * A useful (i hope) system is obtained by removing all or part of the regex.c * reimplementation and making these all extern. I think this package * could be used to implement on-line lexers and parsers and who knows what * else. */ /* In the definitions, these functions are qualified by `RX_DECL' */ #define RX_DECL static #ifdef __STDC__ RX_DECL int rx_bitset_is_subset (int size, rx_Bitset a, rx_Bitset b); RX_DECL void rx_bitset_null (int size, rx_Bitset b); RX_DECL void rx_bitset_universe (int size, rx_Bitset b); RX_DECL void rx_bitset_complement (int size, rx_Bitset b); RX_DECL void rx_bitset_assign (int size, rx_Bitset a, rx_Bitset b); RX_DECL void rx_bitset_union (int size, rx_Bitset a, rx_Bitset b); RX_DECL void rx_bitset_intersection (int size, rx_Bitset a, rx_Bitset b); RX_DECL void rx_bitset_difference (int size, rx_Bitset a, rx_Bitset b); RX_DECL unsigned long rx_bitset_hash (int size, rx_Bitset b); RX_DECL struct rx_hash_item * rx_hash_find (struct rx_hash * table, unsigned long hash, void * value, struct rx_hash_rules * rules); RX_DECL struct rx_hash_item * rx_hash_store (struct rx_hash * table, unsigned long hash, void * value, struct rx_hash_rules * rules); RX_DECL void rx_hash_free (struct rx_hash_item * it, struct rx_hash_rules * rules); RX_DECL rx_Bitset rx_cset (struct rx *rx); RX_DECL rx_Bitset rx_copy_cset (struct rx *rx, rx_Bitset a); RX_DECL void rx_free_cset (struct rx * rx, rx_Bitset c); RX_DECL struct rexp_node * rexp_node (struct rx *rx, enum rexp_node_type type); RX_DECL struct rexp_node * rx_mk_r_cset (struct rx * rx, rx_Bitset b); RX_DECL struct rexp_node * rx_mk_r_concat (struct rx * rx, struct rexp_node * a, struct rexp_node * b); RX_DECL struct rexp_node * rx_mk_r_alternate (struct rx * rx, struct rexp_node * a, struct rexp_node * b); RX_DECL struct rexp_node * rx_mk_r_opt (struct rx * rx, struct rexp_node * a); RX_DECL struct rexp_node * rx_mk_r_star (struct rx * rx, struct rexp_node * a); RX_DECL struct rexp_node * rx_mk_r_2phase_star (struct rx * rx, struct rexp_node * a, struct rexp_node * b); RX_DECL struct rexp_node * rx_mk_r_side_effect (struct rx * rx, rx_side_effect a); RX_DECL struct rexp_node * rx_mk_r_data (struct rx * rx, void * a); RX_DECL void rx_free_rexp (struct rx * rx, struct rexp_node * node); RX_DECL struct rexp_node * rx_copy_rexp (struct rx *rx, struct rexp_node *node); RX_DECL struct rx_nfa_state * rx_nfa_state (struct rx *rx); RX_DECL void rx_free_nfa_state (struct rx_nfa_state * n); RX_DECL struct rx_nfa_state * rx_id_to_nfa_state (struct rx * rx, int id); RX_DECL struct rx_nfa_edge * rx_nfa_edge (struct rx *rx, enum rx_nfa_etype type, struct rx_nfa_state *start, struct rx_nfa_state *dest); RX_DECL void rx_free_nfa_edge (struct rx_nfa_edge * e); RX_DECL void rx_free_nfa (struct rx *rx); RX_DECL int rx_build_nfa (struct rx *rx, struct rexp_node *rexp, struct rx_nfa_state **start, struct rx_nfa_state **end); RX_DECL void rx_name_nfa_states (struct rx *rx); RX_DECL int rx_eclose_nfa (struct rx *rx); RX_DECL void rx_delete_epsilon_transitions (struct rx *rx); RX_DECL int rx_compactify_nfa (struct rx *rx, void **mem, unsigned long *size); RX_DECL struct rx_superset * rx_superstate_eclosure_union (struct rx * rx, struct rx_superset *set, struct rx_nfa_state_set *ecl) ; RX_DECL void rx_release_superset (struct rx *rx, struct rx_superset *set); RX_DECL struct rx_superstate * rx_superstate (struct rx *rx, struct rx_superset *set); RX_DECL struct rx_inx * rx_handle_cache_miss (struct rx *rx, struct rx_superstate *super, unsigned char chr, void *data) ; #else /* ndef __STDC__ */ RX_DECL int rx_bitset_is_subset (); RX_DECL void rx_bitset_null (); RX_DECL void rx_bitset_universe (); RX_DECL void rx_bitset_complement (); RX_DECL void rx_bitset_assign (); RX_DECL void rx_bitset_union (); RX_DECL void rx_bitset_intersection (); RX_DECL void rx_bitset_difference (); RX_DECL unsigned long rx_bitset_hash (); RX_DECL struct rx_hash_item * rx_hash_find (); RX_DECL struct rx_hash_item * rx_hash_store (); RX_DECL void rx_hash_free (); RX_DECL rx_Bitset rx_cset (); RX_DECL rx_Bitset rx_copy_cset (); RX_DECL void rx_free_cset (); RX_DECL struct rexp_node * rexp_node (); RX_DECL struct rexp_node * rx_mk_r_cset (); RX_DECL struct rexp_node * rx_mk_r_concat (); RX_DECL struct rexp_node * rx_mk_r_alternate (); RX_DECL struct rexp_node * rx_mk_r_opt (); RX_DECL struct rexp_node * rx_mk_r_star (); RX_DECL struct rexp_node * rx_mk_r_2phase_star (); RX_DECL struct rexp_node * rx_mk_r_side_effect (); RX_DECL struct rexp_node * rx_mk_r_data (); RX_DECL void rx_free_rexp (); RX_DECL struct rexp_node * rx_copy_rexp (); RX_DECL struct rx_nfa_state * rx_nfa_state (); RX_DECL void rx_free_nfa_state (); RX_DECL struct rx_nfa_state * rx_id_to_nfa_state (); RX_DECL struct rx_nfa_edge * rx_nfa_edge (); RX_DECL void rx_free_nfa_edge (); RX_DECL void rx_free_nfa (); RX_DECL int rx_build_nfa (); RX_DECL void rx_name_nfa_states (); RX_DECL int rx_eclose_nfa (); RX_DECL void rx_delete_epsilon_transitions (); RX_DECL int rx_compactify_nfa (); RX_DECL struct rx_superset * rx_superstate_eclosure_union (); RX_DECL void rx_release_superset (); RX_DECL struct rx_superstate * rx_superstate (); RX_DECL struct rx_inx * rx_handle_cache_miss (); #endif /* ndef __STDC__ */ /* Emacs already defines alloca, sometimes. */ #ifndef alloca /* Make alloca work the best possible way. */ #ifdef __GNUC__ #define alloca __builtin_alloca #else /* not __GNUC__ */ #if HAVE_ALLOCA_H #include #else /* not __GNUC__ or HAVE_ALLOCA_H */ #ifndef _AIX /* Already did AIX, up at the top. */ char *alloca (); #endif /* not _AIX */ #endif /* not HAVE_ALLOCA_H */ #endif /* not __GNUC__ */ #endif /* not alloca */ /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we * use `alloca' instead of `malloc' for the backtracking stack. * * Emacs will die miserably if we don't do this. */ #ifdef REGEX_MALLOC #define REGEX_ALLOCATE malloc #else /* not REGEX_MALLOC */ #define REGEX_ALLOCATE alloca #endif /* not REGEX_MALLOC */ /* Memory management and stuff for emacs. */ #define BYTEWIDTH 8 /* In bits. */ /* (Re)Allocate N items of type T using malloc. */ #define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) #define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) #define remalloc(M, S) (M ? realloc (M, S) : malloc (S)) #ifdef emacs /* The `emacs' switch turns on certain matching commands * that make sense only in Emacs. */ #include "config.h" #include "lisp.h" #include "buffer.h" #include "syntax.h" /* Emacs uses `NULL' as a predicate. */ #undef NULL #else /* not emacs */ /* Setting RX_MEMDBUG is useful if you have dbmalloc. Maybe with similar * packages too. */ #ifdef RX_MEMDBUG #include #else /* not RX_RX_MEMDBUG */ /* We used to test for `BSTRING' here, but only GCC and Emacs define * `BSTRING', as far as I know, and neither of them use this code. */ #if HAVE_STRING_H || STDC_HEADERS #include #ifndef bcmp #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) #endif #ifndef bcopy #define bcopy(s, d, n) memcpy ((d), (s), (n)) #endif #ifndef bzero #define bzero(s, n) memset ((s), 0, (n)) #endif #else #include #endif #ifdef STDC_HEADERS #include #else /* not STDC_HEADERS */ char *malloc (); char *realloc (); #endif /* not STDC_HEADERS */ #endif /* not RX_RX_MEMDBUG */ /* Define the syntax basics for \<, \>, etc. * This must be nonzero for the wordchar and notwordchar pattern * commands in re_match_2. */ #ifndef Sword #define Sword 1 #endif #ifdef SYNTAX_TABLE extern char *re_syntax_table; #else /* not SYNTAX_TABLE */ /* How many characters in the character set. */ #define CHAR_SET_SIZE (1 << BYTEWIDTH) static char re_syntax_table[CHAR_SET_SIZE]; #ifdef __STDC__ static void init_syntax_once (void) #else static void init_syntax_once () #endif { register int c; static int done = 0; if (done) return; bzero (re_syntax_table, sizeof re_syntax_table); for (c = 'a'; c <= 'z'; c++) re_syntax_table[c] = Sword; for (c = 'A'; c <= 'Z'; c++) re_syntax_table[c] = Sword; for (c = '0'; c <= '9'; c++) re_syntax_table[c] = Sword; re_syntax_table['_'] = Sword; done = 1; } #endif /* not SYNTAX_TABLE */ #define SYNTAX(c) re_syntax_table[c] #endif /* not emacs */ /* Compile with `-DRX_DEBUG' and use the following flags. * * Debugging flags: * rx_debug - print information as a regexp is compiled * rx_debug_trace - print information as a regexp is executed */ #ifdef RX_DEBUG int rx_debug_compile = 0; int rx_debug_trace = 0; static struct re_pattern_buffer * dbug_rxb = 0; #ifdef __STDC__ typedef void (*side_effect_printer) (struct rx *, void *, FILE *); #else typedef void (*side_effect_printer) (); #endif #ifdef __STDC__ static void print_cset (struct rx *rx, rx_Bitset cset, FILE * fp); #else static void print_cset (); #endif #ifdef __STDC__ static void print_rexp (struct rx *rx, struct rexp_node *node, int depth, side_effect_printer seprint, FILE * fp) #else static void print_rexp (rx, node, depth, seprint, fp) struct rx *rx; struct rexp_node *node; int depth; side_effect_printer seprint; FILE * fp; #endif { if (!node) return; else { switch (node->type) { case r_cset: { fprintf (fp, "%*s", depth, ""); print_cset (rx, node->params.cset, fp); fputc ('\n', fp); break; } case r_opt: case r_star: fprintf (fp, "%*s%s\n", depth, "", node->type == r_opt ? "opt" : "star"); print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp); break; case r_2phase_star: fprintf (fp, "%*s2phase star\n", depth, ""); print_rexp (rx, node->params.pair.right, depth + 3, seprint, fp); print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp); break; case r_alternate: case r_concat: fprintf (fp, "%*s%s\n", depth, "", node->type == r_alternate ? "alt" : "concat"); print_rexp (rx, node->params.pair.left, depth + 3, seprint, fp); print_rexp (rx, node->params.pair.right, depth + 3, seprint, fp); break; case r_side_effect: fprintf (fp, "%*sSide effect: ", depth, ""); seprint (rx, node->params.side_effect, fp); fputc ('\n', fp); } } } #ifdef __STDC__ static void print_nfa (struct rx * rx, struct rx_nfa_state * n, side_effect_printer seprint, FILE * fp) #else static void print_nfa (rx, n, seprint, fp) struct rx * rx; struct rx_nfa_state * n; side_effect_printer seprint; FILE * fp; #endif { while (n) { struct rx_nfa_edge *e = n->edges; struct rx_possible_future *ec = n->futures; fprintf (fp, "node %d %s\n", n->id, n->is_final ? "final" : (n->is_start ? "start" : "")); while (e) { fprintf (fp, " edge to %d, ", e->dest->id); switch (e->type) { case ne_epsilon: fprintf (fp, "epsilon\n"); break; case ne_side_effect: fprintf (fp, "side effect "); seprint (rx, e->params.side_effect, fp); fputc ('\n', fp); break; case ne_cset: fprintf (fp, "cset "); print_cset (rx, e->params.cset, fp); fputc ('\n', fp); break; } e = e->next; } while (ec) { int x; struct rx_nfa_state_set * s; struct rx_se_list * l; fprintf (fp, " eclosure to {"); for (s = ec->destset; s; s = s->cdr) fprintf (fp, "%d ", s->car->id); fprintf (fp, "} ("); for (l = ec->effects; l; l = l->cdr) { seprint (rx, l->car, fp); fputc (' ', fp); } fprintf (fp, ")\n"); ec = ec->next; } n = n->next; } } static char * efnames [] = { "bogon", "re_se_try", "re_se_pushback", "re_se_push0", "re_se_pushpos", "re_se_chkpos", "re_se_poppos", "re_se_at_dot", "re_se_syntax", "re_se_not_syntax", "re_se_begbuf", "re_se_hat", "re_se_wordbeg", "re_se_wordbound", "re_se_notwordbound", "re_se_wordend", "re_se_endbuf", "re_se_dollar", "re_se_fail", }; static char * efnames2[] = { "re_se_win" "re_se_lparen", "re_se_rparen", "re_se_backref", "re_se_iter", "re_se_end_iter", "re_se_tv" }; static char * inx_names[] = { "rx_backtrack_point", "rx_do_side_effects", "rx_cache_miss", "rx_next_char", "rx_backtrack", "rx_error_inx", "rx_num_instructions" }; #ifdef __STDC__ static void re_seprint (struct rx * rx, void * effect, FILE * fp) #else static void re_seprint (rx, effect, fp) struct rx * rx; void * effect; FILE * fp; #endif { if ((int)effect < 0) fputs (efnames[-(int)effect], fp); else if (dbug_rxb) { struct re_se_params * p = &dbug_rxb->se_params[(int)effect]; fprintf (fp, "%s(%d,%d)", efnames2[p->se], p->op1, p->op2); } else fprintf (fp, "[complex op # %d]", (int)effect); } /* These are for so the regex.c regression tests will compile. */ void print_compiled_pattern (rxb) struct re_pattern_buffer * rxb; { } void print_fastmap (fm) char * fm; { } #endif /* RX_DEBUG */ /* This page: Bitsets. Completely unintersting. */ #if 0 #ifdef __STDC__ RX_DECL int rx_bitset_is_equal (int size, rx_Bitset a, rx_Bitset b) #else RX_DECL int rx_bitset_is_equal (size, a, b) int size; rx_Bitset a; rx_Bitset b; #endif { int x; RX_subset s = b[0]; b[0] = ~a[0]; for (x = rx_bitset_numb_subsets(size) - 1; a[x] == b[x]; --x) ; b[0] = s; return !x && s == a[0]; } #endif #ifdef __STDC__ RX_DECL int rx_bitset_is_subset (int size, rx_Bitset a, rx_Bitset b) #else RX_DECL int rx_bitset_is_subset (size, a, b) int size; rx_Bitset a; rx_Bitset b; #endif { int x = rx_bitset_numb_subsets(size) - 1; while (x-- && (a[x] & b[x]) == a[x]); return x == -1; } #if 0 #ifdef __STDC__ RX_DECL int rx_bitset_empty (int size, rx_Bitset set) #else RX_DECL int rx_bitset_empty (size, set) int size; rx_Bitset set; #endif { int x; RX_subset s = set[0]; set[0] = 1; for (x = rx_bitset_numb_subsets(size) - 1; !set[x]; --x) ; set[0] = s; return !s; } #endif #ifdef __STDC__ RX_DECL void rx_bitset_null (int size, rx_Bitset b) #else RX_DECL void rx_bitset_null (size, b) int size; rx_Bitset b; #endif { bzero (b, rx_sizeof_bitset(size)); } #ifdef __STDC__ RX_DECL void rx_bitset_universe (int size, rx_Bitset b) #else RX_DECL void rx_bitset_universe (size, b) int size; rx_Bitset b; #endif { int x = rx_bitset_numb_subsets (size); while (x--) *b++ = ~(RX_subset)0; } #ifdef __STDC__ RX_DECL void rx_bitset_complement (int size, rx_Bitset b) #else RX_DECL void rx_bitset_complement (size, b) int size; rx_Bitset b; #endif { int x = rx_bitset_numb_subsets (size); while (x--) { *b = ~*b; ++b; } } #ifdef __STDC__ RX_DECL void rx_bitset_assign (int size, rx_Bitset a, rx_Bitset b) #else RX_DECL void rx_bitset_assign (size, a, b) int size; rx_Bitset a; rx_Bitset b; #endif { int x; for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) a[x] = b[x]; } #ifdef __STDC__ RX_DECL void rx_bitset_union (int size, rx_Bitset a, rx_Bitset b) #else RX_DECL void rx_bitset_union (size, a, b) int size; rx_Bitset a; rx_Bitset b; #endif { int x; for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) a[x] |= b[x]; } #ifdef __STDC__ RX_DECL void rx_bitset_intersection (int size, rx_Bitset a, rx_Bitset b) #else RX_DECL void rx_bitset_intersection (size, a, b) int size; rx_Bitset a; rx_Bitset b; #endif { int x; for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) a[x] &= b[x]; } #ifdef __STDC__ RX_DECL void rx_bitset_difference (int size, rx_Bitset a, rx_Bitset b) #else RX_DECL void rx_bitset_difference (size, a, b) int size; rx_Bitset a; rx_Bitset b; #endif { int x; for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) a[x] &= ~ b[x]; } #if 0 #ifdef __STDC__ RX_DECL void rx_bitset_revdifference (int size, rx_Bitset a, rx_Bitset b) #else RX_DECL void rx_bitset_revdifference (size, a, b) int size; rx_Bitset a; rx_Bitset b; #endif { int x; for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) a[x] = ~a[x] & b[x]; } #ifdef __STDC__ RX_DECL void rx_bitset_xor (int size, rx_Bitset a, rx_Bitset b) #else RX_DECL void rx_bitset_xor (size, a, b) int size; rx_Bitset a; rx_Bitset b; #endif { int x; for (x = rx_bitset_numb_subsets(size) - 1; x >=0; --x) a[x] ^= b[x]; } #endif #ifdef __STDC__ RX_DECL unsigned long rx_bitset_hash (int size, rx_Bitset b) #else RX_DECL unsigned long rx_bitset_hash (size, b) int size; rx_Bitset b; #endif { int x; unsigned long hash = (unsigned long)rx_bitset_hash; for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x) hash ^= rx_bitset_subset_val(b, x); return hash; } RX_DECL RX_subset rx_subset_singletons [RX_subset_bits] = { 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000, 0x800000, 0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000 }; #ifdef RX_DEBUG #ifdef __STDC__ static void print_cset (struct rx *rx, rx_Bitset cset, FILE * fp) #else static void print_cset (rx, cset, fp) struct rx *rx; rx_Bitset cset; FILE * fp; #endif { int x; fputc ('[', fp); for (x = 0; x < rx->local_cset_size; ++x) if (isprint(x) && RX_bitset_member (cset, x)) fputc (x, fp); fputc (']', fp); } #endif /* RX_DEBUG */ /* This page: small object pools. */ struct freelist { struct freelist * next; }; struct chunked_pool { int size; struct freelist * freelist; char * chunk; int num_left; #if RX_DEBUG int leakiness; #endif }; #define DEF_POOL(NAME,TYPE) \ struct chunked_pool NAME = { sizeof(TYPE), 0, 0, 0 } #ifdef __STDC__ static char * chunk_malloc (struct chunked_pool * pool) #else static char * chunk_malloc (pool) struct chunked_pool * pool; #endif { struct freelist * it; if (pool->freelist) { it = pool->freelist; pool->freelist = it->next; } else { if (!pool->num_left) { pool->chunk = (char *)malloc (pool->size * 128); if (!pool->chunk) return 0; pool->num_left = 128; } it = (struct freelist *)pool->chunk; pool->chunk += pool->size; --pool->num_left; } #if RX_DEBUG if (it) ++pool->leakiness; #endif return (char *)it; } #ifdef __STDC__ static void chunk_free (struct chunked_pool * pool, char * mem) #else static void chunk_free (pool, mem) struct chunked_pool * pool; char * mem; #endif { struct freelist * it = (struct freelist *)mem; it->next = pool->freelist; pool->freelist = it; #if RX_DEBUG --pool->leakiness; #endif } /* This is for pools of variable size objects where there are only a few * sizes and where we tend to burst on one size at a time. */ struct linked_chunk { struct chunked_pool pool; struct linked_chunk * next; }; struct chunk_group { struct linked_chunk * list; struct linked_chunk * current; }; #ifdef __STDC__ static int cg_find_pool (struct chunk_group * group, int size) #else static int cg_find_pool (group, size) struct chunk_group * group; int size; #endif { if (!(group->current && (group->current->pool.size == size))) { struct linked_chunk * lc = group->list; while (lc) if (lc->pool.size == size) { group->current = lc; return 1; } else lc = lc->next; lc = (struct linked_chunk *)malloc (sizeof (*lc)); if (!lc) return 0; bzero (lc, sizeof (*lc)); lc->pool.size = size; lc->next = group->list; group->list = lc; group->current = lc; } return 1; } #ifdef __STDC__ static char * cg_malloc (struct chunk_group * group, int size) #else static char * cg_malloc (group, size) struct chunk_group * group; int size; #endif { return (cg_find_pool (group, size) ? chunk_malloc (&group->current->pool) : 0); } #ifdef __STDC__ static void cg_free (struct chunk_group * group, int size, char * mem) #else static void cg_free (group, size, mem) struct chunk_group * group; int size; char * mem; #endif { if (cg_find_pool (group, size)) chunk_free (&group->current->pool, mem); } static unsigned long rx_hash_masks[4] = { 0x12488421, 0x96699669, 0xbe7dd7eb, 0xffffffff }; /* Hash tables */ #ifdef __STDC__ RX_DECL struct rx_hash_item * rx_hash_find (struct rx_hash * table, unsigned long hash, void * value, struct rx_hash_rules * rules) #else RX_DECL struct rx_hash_item * rx_hash_find (table, hash, value, rules) struct rx_hash * table; unsigned long hash; void * value; struct rx_hash_rules * rules; #endif { rx_hash_eq eq = rules->eq; int maskc = 0; int mask = rx_hash_masks [0]; int bucket = (hash & mask) % 13; while (table->children [bucket]) { table = table->children [bucket]; ++maskc; mask = rx_hash_masks[maskc]; bucket = (hash & mask) % 13; } { struct rx_hash_item * it = table->buckets[bucket]; while (it) if (eq (it->data, value)) return it; else it = it->next_same_hash; } return 0; } #ifdef __STDC__ RX_DECL struct rx_hash_item * rx_hash_store (struct rx_hash * table, unsigned long hash, void * value, struct rx_hash_rules * rules) #else RX_DECL struct rx_hash_item * rx_hash_store (table, hash, value, rules) struct rx_hash * table; unsigned long hash; void * value; struct rx_hash_rules * rules; #endif { rx_hash_eq eq = rules->eq; int maskc = 0; int mask = rx_hash_masks[0]; int bucket = (hash & mask) % 13; int depth = 0; while (table->children [bucket]) { table = table->children [bucket]; ++maskc; mask = rx_hash_masks[maskc]; bucket = (hash & mask) % 13; ++depth; } { struct rx_hash_item * it = table->buckets[bucket]; while (it) if (eq (it->data, value)) return it; else it = it->next_same_hash; } { if ( (depth < 3) && (table->bucket_size [bucket] >= 4)) { struct rx_hash * newtab = ((struct rx_hash *) rules->hash_alloc (rules)); if (!newtab) goto add_to_bucket; bzero (newtab, sizeof (*newtab)); newtab->parent = table; { struct rx_hash_item * them = table->buckets[bucket]; unsigned long newmask = rx_hash_masks[maskc + 1]; while (them) { struct rx_hash_item * save = them->next_same_hash; int new_buck = (them->hash & newmask) % 13; them->next_same_hash = newtab->buckets[new_buck]; newtab->buckets[new_buck] = them; them->table = newtab; them = save; ++newtab->bucket_size[new_buck]; ++newtab->refs; } table->refs = (table->refs - table->bucket_size[bucket] + 1); table->bucket_size[bucket] = 0; table->buckets[bucket] = 0; table->children[bucket] = newtab; table = newtab; bucket = (hash & newmask) % 13; } } } add_to_bucket: { struct rx_hash_item * it = ((struct rx_hash_item *) rules->hash_item_alloc (rules, value)); if (!it) return 0; it->hash = hash; it->table = table; /* DATA and BINDING are to be set in hash_item_alloc */ it->next_same_hash = table->buckets [bucket]; table->buckets[bucket] = it; ++table->bucket_size [bucket]; ++table->refs; return it; } } #ifdef __STDC__ RX_DECL void rx_hash_free (struct rx_hash_item * it, struct rx_hash_rules * rules) #else RX_DECL void rx_hash_free (it, rules) struct rx_hash_item * it; struct rx_hash_rules * rules; #endif { if (it) { struct rx_hash * table = it->table; unsigned long hash = it->hash; int depth = (table->parent ? (table->parent->parent ? (table->parent->parent->parent ? 3 : 2) : 1) : 0); int bucket = (hash & rx_hash_masks [depth]) % 13; struct rx_hash_item ** pos = &table->buckets [bucket]; while (*pos != it) pos = &(*pos)->next_same_hash; *pos = it->next_same_hash; rules->free_hash_item (it, rules); --table->bucket_size[bucket]; --table->refs; while (!table->refs && depth) { struct rx_hash * save = table; table = table->parent; --depth; bucket = (hash & rx_hash_masks [depth]) % 13; --table->refs; table->children[bucket] = 0; rules->free_hash (save, rules); } } } #ifdef __STDC__ typedef void (*rx_hash_freefn) (struct rx_hash_item * it); #else /* ndef __STDC__ */ typedef void (*rx_hash_freefn) (); #endif /* ndef __STDC__ */ #ifdef __STDC__ RX_DECL void rx_free_hash_table (struct rx_hash * tab, rx_hash_freefn freefn, struct rx_hash_rules * rules) #else RX_DECL void rx_free_hash_table (tab, freefn, rules) struct rx_hash * tab; rx_hash_freefn freefn; struct rx_hash_rules * rules; #endif { int x; for (x = 0; x < 13; ++x) if (tab->children[x]) { rx_free_hash_table (tab->children[x], freefn, rules); rules->free_hash (tab->children[x], rules); } else { struct rx_hash_item * them = tab->buckets[x]; while (them) { struct rx_hash_item * that = them; them = that->next_same_hash; freefn (that); rules->free_hash_item (that, rules); } } } /* Utilities for manipulating bitset represntations of characters sets. */ static struct chunk_group cset_chunks = {0, 0}; #ifdef __STDC__ RX_DECL rx_Bitset rx_cset (struct rx *rx) #else RX_DECL rx_Bitset rx_cset (rx) struct rx *rx; #endif { rx_Bitset b = (rx_Bitset) cg_malloc (&cset_chunks, rx_sizeof_bitset (rx->local_cset_size)); if (b) rx_bitset_null (rx->local_cset_size, b); return b; } #ifdef __STDC__ RX_DECL rx_Bitset rx_copy_cset (struct rx *rx, rx_Bitset a) #else RX_DECL rx_Bitset rx_copy_cset (rx, a) struct rx *rx; rx_Bitset a; #endif { rx_Bitset cs = rx_cset (rx); if (cs) rx_bitset_union (rx->local_cset_size, cs, a); return cs; } #ifdef __STDC__ RX_DECL void rx_free_cset (struct rx * rx, rx_Bitset c) #else RX_DECL void rx_free_cset (rx, c) struct rx * rx; rx_Bitset c; #endif { if (c) cg_free (&cset_chunks, rx_sizeof_bitset (rx->local_cset_size), (char *)c); } /* Hash table memory allocation policy for the regexp compiler */ static DEF_POOL(hash_tabs, struct rx_hash); static DEF_POOL(hash_items, struct rx_hash_item); #ifdef __STDC__ struct rx_hash * compiler_hash_alloc (struct rx_hash_rules * rules) #else struct rx_hash * compiler_hash_alloc (rules) struct rx_hash_rules * rules; #endif { return (struct rx_hash *)chunk_malloc (&hash_tabs); } #ifdef __STDC__ struct rx_hash_item * compiler_hash_item_alloc (struct rx_hash_rules * rules, void * value) #else struct rx_hash_item * compiler_hash_item_alloc (rules, value) struct rx_hash_rules * rules; void * value; #endif { struct rx_hash_item * it = (struct rx_hash_item *)chunk_malloc (&hash_items); if (it) { it->data = value; it->binding = 0; } return it; } #ifdef __STDC__ void compiler_free_hash (struct rx_hash * tab, struct rx_hash_rules * rules) #else void compiler_free_hash (tab, rules) struct rx_hash * tab; struct rx_hash_rules * rules; #endif { chunk_free (&hash_tabs, (char *)tab); } #ifdef __STDC__ void compiler_free_hash_item (struct rx_hash_item * item, struct rx_hash_rules * rules) #else void compiler_free_hash_item (item, rules) struct rx_hash_item * item; struct rx_hash_rules * rules; #endif { chunk_free (&hash_items, (char *)item); } /* This page: REXP_NODE (expression tree) structures. */ static DEF_POOL (rexp_pool, struct rexp_node); #ifdef __STDC__ RX_DECL struct rexp_node * rexp_node (struct rx *rx, enum rexp_node_type type) #else RX_DECL struct rexp_node * rexp_node (rx, type) struct rx *rx; enum rexp_node_type type; #endif { struct rexp_node *n; n = (struct rexp_node *)chunk_malloc (&rexp_pool); bzero (n, sizeof (*n)); if (n) n->type = type; return n; } /* free_rexp_node assumes that the bitset passed to rx_mk_r_cset * can be freed using rx_free_cset. */ #ifdef __STDC__ RX_DECL struct rexp_node * rx_mk_r_cset (struct rx * rx, rx_Bitset b) #else RX_DECL struct rexp_node * rx_mk_r_cset (rx, b) struct rx * rx; rx_Bitset b; #endif { struct rexp_node * n = rexp_node (rx, r_cset); if (n) n->params.cset = b; return n; } #ifdef __STDC__ RX_DECL struct rexp_node * rx_mk_r_concat (struct rx * rx, struct rexp_node * a, struct rexp_node * b) #else RX_DECL struct rexp_node * rx_mk_r_concat (rx, a, b) struct rx * rx; struct rexp_node * a; struct rexp_node * b; #endif { struct rexp_node * n = rexp_node (rx, r_concat); if (n) { n->params.pair.left = a; n->params.pair.right = b; } return n; } #ifdef __STDC__ RX_DECL struct rexp_node * rx_mk_r_alternate (struct rx * rx, struct rexp_node * a, struct rexp_node * b) #else RX_DECL struct rexp_node * rx_mk_r_alternate (rx, a, b) struct rx * rx; struct rexp_node * a; struct rexp_node * b; #endif { struct rexp_node * n = rexp_node (rx, r_alternate); if (n) { n->params.pair.left = a; n->params.pair.right = b; } return n; } #ifdef __STDC__ RX_DECL struct rexp_node * rx_mk_r_opt (struct rx * rx, struct rexp_node * a) #else RX_DECL struct rexp_node * rx_mk_r_opt (rx, a) struct rx * rx; struct rexp_node * a; #endif { struct rexp_node * n = rexp_node (rx, r_opt); if (n) { n->params.pair.left = a; n->params.pair.right = 0; } return n; } #ifdef __STDC__ RX_DECL struct rexp_node * rx_mk_r_star (struct rx * rx, struct rexp_node * a) #else RX_DECL struct rexp_node * rx_mk_r_star (rx, a) struct rx * rx; struct rexp_node * a; #endif { struct rexp_node * n = rexp_node (rx, r_star); if (n) { n->params.pair.left = a; n->params.pair.right = 0; } return n; } #ifdef __STDC__ RX_DECL struct rexp_node * rx_mk_r_2phase_star (struct rx * rx, struct rexp_node * a, struct rexp_node * b) #else RX_DECL struct rexp_node * rx_mk_r_2phase_star (rx, a, b) struct rx * rx; struct rexp_node * a; struct rexp_node * b; #endif { struct rexp_node * n = rexp_node (rx, r_2phase_star); if (n) { n->params.pair.left = a; n->params.pair.right = b; } return n; } #ifdef __STDC__ RX_DECL struct rexp_node * rx_mk_r_side_effect (struct rx * rx, rx_side_effect a) #else RX_DECL struct rexp_node * rx_mk_r_side_effect (rx, a) struct rx * rx; rx_side_effect a; #endif { struct rexp_node * n = rexp_node (rx, r_side_effect); if (n) { n->params.side_effect = a; n->params.pair.right = 0; } return n; } #ifdef __STDC__ RX_DECL struct rexp_node * rx_mk_r_data (struct rx * rx, void * a) #else RX_DECL struct rexp_node * rx_mk_r_data (rx, a) struct rx * rx; void * a; #endif { struct rexp_node * n = rexp_node (rx, r_data); if (n) { n->params.pair.left = a; n->params.pair.right = 0; } return n; } #ifdef __STDC__ RX_DECL void rx_free_rexp (struct rx * rx, struct rexp_node * node) #else RX_DECL void rx_free_rexp (rx, node) struct rx * rx; struct rexp_node * node; #endif { if (node) { switch (node->type) { case r_cset: if (node->params.cset) rx_free_cset (rx, node->params.cset); case r_side_effect: break; case r_concat: case r_alternate: case r_2phase_star: case r_opt: case r_star: rx_free_rexp (rx, node->params.pair.left); rx_free_rexp (rx, node->params.pair.right); break; case r_data: /* This shouldn't occur. */ break; } chunk_free (&rexp_pool, (char *)node); } } #ifdef __STDC__ RX_DECL struct rexp_node * rx_copy_rexp (struct rx *rx, struct rexp_node *node) #else RX_DECL struct rexp_node * rx_copy_rexp (rx, node) struct rx *rx; struct rexp_node *node; #endif { if (!node) return 0; else { struct rexp_node *n = rexp_node (rx, node->type); if (!n) return 0; switch (node->type) { case r_cset: n->params.cset = rx_copy_cset (rx, node->params.cset); if (!n->params.cset) { rx_free_rexp (rx, n); return 0; } break; case r_side_effect: n->params.side_effect = node->params.side_effect; break; case r_concat: case r_alternate: case r_opt: case r_2phase_star: case r_star: n->params.pair.left = rx_copy_rexp (rx, node->params.pair.left); n->params.pair.right = rx_copy_rexp (rx, node->params.pair.right); if ( (node->params.pair.left && !n->params.pair.left) || (node->params.pair.right && !n->params.pair.right)) { rx_free_rexp (rx, n); return 0; } break; case r_data: /* shouldn't happen */ break; } return n; } } /* This page: functions to build and destroy graphs that describe nfa's */ static DEF_POOL(state_pool, struct rx_nfa_state); /* Constructs a new nfa node. */ #ifdef __STDC__ RX_DECL struct rx_nfa_state * rx_nfa_state (struct rx *rx) #else RX_DECL struct rx_nfa_state * rx_nfa_state (rx) struct rx *rx; #endif { struct rx_nfa_state * n = (struct rx_nfa_state *)chunk_malloc (&state_pool); if (!n) return 0; bzero (n, sizeof (*n)); n->next = rx->nfa_states; rx->nfa_states = n; return n; } #ifdef __STDC__ RX_DECL void rx_free_nfa_state (struct rx_nfa_state * n) #else RX_DECL void rx_free_nfa_state (n) struct rx_nfa_state * n; #endif { chunk_free (&state_pool, (char *)n); } /* This looks up an nfa node, given a numeric id. Numeric id's are * assigned after the nfa has been built. */ #ifdef __STDC__ RX_DECL struct rx_nfa_state * rx_id_to_nfa_state (struct rx * rx, int id) #else RX_DECL struct rx_nfa_state * rx_id_to_nfa_state (rx, id) struct rx * rx; int id; #endif { struct rx_nfa_state * n; for (n = rx->nfa_states; n; n = n->next) if (n->id == id) return n; return 0; } /* This adds an edge between two nodes, but doesn't initialize the * edge label. */ static DEF_POOL(edge_pool, struct rx_nfa_edge); #ifdef __STDC__ RX_DECL struct rx_nfa_edge * rx_nfa_edge (struct rx *rx, enum rx_nfa_etype type, struct rx_nfa_state *start, struct rx_nfa_state *dest) #else RX_DECL struct rx_nfa_edge * rx_nfa_edge (rx, type, start, dest) struct rx *rx; enum rx_nfa_etype type; struct rx_nfa_state *start; struct rx_nfa_state *dest; #endif { struct rx_nfa_edge *e = (struct rx_nfa_edge *)chunk_malloc (&edge_pool); if (!e) return 0; e->next = start->edges; start->edges = e; e->type = type; e->dest = dest; return e; } #ifdef __STDC__ RX_DECL void rx_free_nfa_edge (struct rx_nfa_edge * e) #else RX_DECL void rx_free_nfa_edge (e) struct rx_nfa_edge * e; #endif { chunk_free (&edge_pool, (char *)e); } /* This constructs a POSSIBLE_FUTURE, which is a kind epsilon-closure * of an NFA. These are added to an nfa automaticly by eclose_nfa. */ static DEF_POOL(pf_pool, struct rx_possible_future); #ifdef __STDC__ static struct rx_possible_future * rx_possible_future (struct rx * rx, struct rx_se_list * effects) #else static struct rx_possible_future * rx_possible_future (rx, effects) struct rx * rx; struct rx_se_list * effects; #endif { struct rx_possible_future *ec = ((struct rx_possible_future *) chunk_malloc (&pf_pool)); if (!ec) return 0; ec->destset = 0; ec->next = 0; ec->effects = effects; return ec; } #ifdef __STDC__ static void rx_free_possible_future (struct rx_possible_future * pf) #else static void rx_free_possible_future (pf) struct rx_possible_future * pf; #endif { chunk_free (&pf_pool, (char *)pf); } #ifdef __STDC__ RX_DECL void rx_free_nfa (struct rx *rx) #else RX_DECL void rx_free_nfa (rx) struct rx *rx; #endif { while (rx->nfa_states) { while (rx->nfa_states->edges) { switch (rx->nfa_states->edges->type) { case ne_cset: rx_free_cset (rx, rx->nfa_states->edges->params.cset); break; default: break; } { struct rx_nfa_edge * e; e = rx->nfa_states->edges; rx->nfa_states->edges = rx->nfa_states->edges->next; rx_free_nfa_edge (e); } } /* while (rx->nfa_states->edges) */ { /* Iterate over the partial epsilon closures of rx->nfa_states */ struct rx_possible_future * pf = rx->nfa_states->futures; while (pf) { struct rx_possible_future * pft = pf; pf = pf->next; rx_free_possible_future (pft); } } { struct rx_nfa_state *n; n = rx->nfa_states; rx->nfa_states = rx->nfa_states->next; rx_free_nfa_state (n); } } } /* This page: translating a pattern expression in to an nfa and doing the * static part of the nfa->super-nfa translation. */ /* This is the thompson regexp->nfa algorithm. */ #ifdef __STDC__ RX_DECL int rx_build_nfa (struct rx *rx, struct rexp_node *rexp, struct rx_nfa_state **start, struct rx_nfa_state **end) #else RX_DECL int rx_build_nfa (rx, rexp, start, end) struct rx *rx; struct rexp_node *rexp; struct rx_nfa_state **start; struct rx_nfa_state **end; #endif { struct rx_nfa_edge *edge; /* Start & end nodes may have been allocated by the caller. */ *start = *start ? *start : rx_nfa_state (rx); if (!*start) return 0; if (!rexp) { *end = *start; return 1; } *end = *end ? *end : rx_nfa_state (rx); if (!*end) { rx_free_nfa_state (*start); return 0; } switch (rexp->type) { case r_data: return 0; break; case r_cset: edge = rx_nfa_edge (rx, ne_cset, *start, *end); if (!edge) return 0; edge->params.cset = rx_copy_cset (rx, rexp->params.cset); if (!edge->params.cset) { rx_free_nfa_edge (edge); return 0; } return 1; case r_opt: return (rx_build_nfa (rx, rexp->params.pair.left, start, end) && rx_nfa_edge (rx, ne_epsilon, *start, *end)); case r_star: { struct rx_nfa_state * star_start = 0; struct rx_nfa_state * star_end = 0; return (rx_build_nfa (rx, rexp->params.pair.left, &star_start, &star_end) && star_start && star_end && rx_nfa_edge (rx, ne_epsilon, star_start, star_end) && rx_nfa_edge (rx, ne_epsilon, *start, star_start) && rx_nfa_edge (rx, ne_epsilon, star_end, *end) && rx_nfa_edge (rx, ne_epsilon, star_end, star_start)); } case r_2phase_star: { struct rx_nfa_state * star_start = 0; struct rx_nfa_state * star_end = 0; struct rx_nfa_state * loop_exp_start = 0; struct rx_nfa_state * loop_exp_end = 0; return (rx_build_nfa (rx, rexp->params.pair.left, &star_start, &star_end) && rx_build_nfa (rx, rexp->params.pair.right, &loop_exp_start, &loop_exp_end) && star_start && star_end && loop_exp_end && loop_exp_start && rx_nfa_edge (rx, ne_epsilon, star_start, *end) && rx_nfa_edge (rx, ne_epsilon, *start, star_start) && rx_nfa_edge (rx, ne_epsilon, star_end, *end) && rx_nfa_edge (rx, ne_epsilon, star_end, loop_exp_start) && rx_nfa_edge (rx, ne_epsilon, loop_exp_end, star_start)); } case r_concat: { struct rx_nfa_state *shared = 0; return (rx_build_nfa (rx, rexp->params.pair.left, start, &shared) && rx_build_nfa (rx, rexp->params.pair.right, &shared, end)); } case r_alternate: { struct rx_nfa_state *ls = 0; struct rx_nfa_state *le = 0; struct rx_nfa_state *rs = 0; struct rx_nfa_state *re = 0; return (rx_build_nfa (rx, rexp->params.pair.left, &ls, &le) && rx_build_nfa (rx, rexp->params.pair.right, &rs, &re) && rx_nfa_edge (rx, ne_epsilon, *start, ls) && rx_nfa_edge (rx, ne_epsilon, *start, rs) && rx_nfa_edge (rx, ne_epsilon, le, *end) && rx_nfa_edge (rx, ne_epsilon, re, *end)); } case r_side_effect: edge = rx_nfa_edge (rx, ne_side_effect, *start, *end); if (!edge) return 0; edge->params.side_effect = rexp->params.side_effect; return 1; }; } /* NAME_RX->NFA_STATES identifies all nodes with non-epsilon transitions. * These nodes can occur in super-states. All nodes are given an integer id. * The id is non-negative if the node has non-epsilon out-transitions, negative * otherwise (this is because we want the non-negative ids to be used as * array indexes in a few places). */ #ifdef __STDC__ RX_DECL void rx_name_nfa_states (struct rx *rx) #else RX_DECL void rx_name_nfa_states (rx) struct rx *rx; #endif { struct rx_nfa_state *n = rx->nfa_states; rx->nodec = 0; rx->epsnodec = -1; while (n) { struct rx_nfa_edge *e = n->edges; if (n->is_start) n->eclosure_needed = 1; while (e) { switch (e->type) { case ne_epsilon: case ne_side_effect: break; case ne_cset: n->id = rx->nodec++; { struct rx_nfa_edge *from_n = n->edges; while (from_n) { from_n->dest->eclosure_needed = 1; from_n = from_n->next; } } goto cont; } e = e->next; } n->id = rx->epsnodec--; cont: n = n->next; } rx->epsnodec = -rx->epsnodec; } /* This page: data structures for the static part of the nfa->supernfa * translation. */ /* The next several functions compare, construct, etc. lists of side * effects. See ECLOSE_NFA (below) for details. */ /* Ordering of rx_se_list * (-1, 0, 1 return value convention). */ #ifdef __STDC__ static int se_list_cmp (void * va, void * vb) #else static int se_list_cmp (va, vb) void * va; void * vb; #endif { struct rx_se_list * a = (struct rx_se_list *)va; struct rx_se_list * b = (struct rx_se_list *)vb; return ((va == vb) ? 0 : (!va ? -1 : (!vb ? 1 : ((long)a->car < (long)b->car ? 1 : ((long)a->car > (long)b->car ? -1 : se_list_cmp ((void *)a->cdr, (void *)b->cdr)))))); } #ifdef __STDC__ static int se_list_equal (void * va, void * vb) #else static int se_list_equal (va, vb) void * va; void * vb; #endif { return !(se_list_cmp (va, vb)); } static struct rx_hash_rules se_list_hash_rules = { se_list_equal, compiler_hash_alloc, compiler_free_hash, compiler_hash_item_alloc, compiler_free_hash_item }; static DEF_POOL(sel_pool, struct rx_se_list); #ifdef __STDC__ static struct rx_se_list * side_effect_cons (struct rx * rx, void * se, struct rx_se_list * list) #else static struct rx_se_list * side_effect_cons (rx, se, list) struct rx * rx; void * se; struct rx_se_list * list; #endif { struct rx_se_list * l = ((struct rx_se_list *) chunk_malloc (&sel_pool)); if (!l) return 0; l->car = se; l->cdr = list; return l; } #ifdef __STDC__ static struct rx_se_list * hash_cons_se_prog (struct rx * rx, struct rx_hash * memo, void * car, struct rx_se_list * cdr) #else static struct rx_se_list * hash_cons_se_prog (rx, memo, car, cdr) struct rx * rx; struct rx_hash * memo; void * car; struct rx_se_list * cdr; #endif { long hash = (long)car ^ (long)cdr; struct rx_se_list template; template.car = car; template.cdr = cdr; { struct rx_hash_item * it = rx_hash_store (memo, hash, (void *)&template, &se_list_hash_rules); if (!it) return 0; if (it->data == (void *)&template) { struct rx_se_list * consed = ((struct rx_se_list *) chunk_malloc (&sel_pool)); *consed = template; it->data = (void *)consed; } return (struct rx_se_list *)it->data; } } #ifdef __STDC__ static struct rx_se_list * hash_se_prog (struct rx * rx, struct rx_hash * memo, struct rx_se_list * prog) #else static struct rx_se_list * hash_se_prog (rx, memo, prog) struct rx * rx; struct rx_hash * memo; struct rx_se_list * prog; #endif { struct rx_se_list * answer = 0; while (prog) { answer = hash_cons_se_prog (rx, memo, prog->car, answer); if (!answer) return 0; prog = prog->cdr; } return answer; } /* This page: more data structures for nfa->supernfa. Specificly, * sets of nfa states. */ #ifdef __STDC__ static int nfa_set_cmp (void * va, void * vb) #else static int nfa_set_cmp (va, vb) void * va; void * vb; #endif { struct rx_nfa_state_set * a = (struct rx_nfa_state_set *)va; struct rx_nfa_state_set * b = (struct rx_nfa_state_set *)vb; return ((va == vb) ? 0 : (!va ? -1 : (!vb ? 1 : (a->car->id < b->car->id ? 1 : (a->car->id > b->car->id ? -1 : nfa_set_cmp ((void *)a->cdr, (void *)b->cdr)))))); } #ifdef __STDC__ static int nfa_set_equal (void * va, void * vb) #else static int nfa_set_equal (va, vb) void * va; void * vb; #endif { return !nfa_set_cmp (va, vb); } static struct rx_hash_rules nfa_set_hash_rules = { nfa_set_equal, compiler_hash_alloc, compiler_free_hash, compiler_hash_item_alloc, compiler_free_hash_item }; /* CONS -- again, sets with == elements are ==. */ static DEF_POOL(nfa_sets, struct rx_nfa_state_set); #ifdef __STDC__ static struct rx_nfa_state_set * nfa_set_cons (struct rx * rx, struct rx_hash * memo, struct rx_nfa_state * state, struct rx_nfa_state_set * set) #else static struct rx_nfa_state_set * nfa_set_cons (rx, memo, state, set) struct rx * rx; struct rx_hash * memo; struct rx_nfa_state * state; struct rx_nfa_state_set * set; #endif { struct rx_nfa_state_set template; struct rx_hash_item * node; template.car = state; template.cdr = set; node = rx_hash_store (memo, (((long)state) >> 8) ^ (long)set, &template, &nfa_set_hash_rules); if (!node) return 0; if (node->data == &template) { struct rx_nfa_state_set * l = ((struct rx_nfa_state_set *) chunk_malloc (&nfa_sets)); node->data = (void *) l; if (!l) return 0; *l = template; } return (struct rx_nfa_state_set *)node->data; } #ifdef __STDC__ static struct rx_nfa_state_set * nfa_set_enjoin (struct rx * rx, struct rx_hash * memo, struct rx_nfa_state * state, struct rx_nfa_state_set * set) #else static struct rx_nfa_state_set * nfa_set_enjoin (rx, memo, state, set) struct rx * rx; struct rx_hash * memo; struct rx_nfa_state * state; struct rx_nfa_state_set * set; #endif { if (!set || state->id < set->car->id) return nfa_set_cons (rx, memo, state, set); if (state->id == set->car->id) return set; else { struct rx_nfa_state_set * newcdr = nfa_set_enjoin (rx, memo, state, set->cdr); if (newcdr != set->cdr) set = nfa_set_cons (rx, memo, set->car, newcdr); return set; } } /* This page: computing epsilon closures. The closures aren't total. * Each node's closures are partitioned according to the side effects entailed * along the epsilon edges. Return true on success. */ struct eclose_frame { struct rx_se_list *prog_backwards; }; #ifdef __STDC__ static int eclose_node (struct rx *rx, struct rx_nfa_state *outnode, struct rx_nfa_state *node, struct eclose_frame *frame) #else static int eclose_node (rx, outnode, node, frame) struct rx *rx; struct rx_nfa_state *outnode; struct rx_nfa_state *node; struct eclose_frame *frame; #endif { struct rx_nfa_edge *e = node->edges; /* For each node, we follow all epsilon paths to build the closure. * The closure omits nodes that have only epsilon edges. * The closure is split into partial closures -- all the states in * a partial closure are reached by crossing the same list of * of side effects (though not necessarily the same path). */ if (node->mark) return 1; node->mark = 1; if (node->id >= 0 || node->is_final) { struct rx_possible_future **ec; struct rx_se_list * prog_in_order = ((struct rx_se_list *)hash_se_prog (rx, &rx->se_list_memo, frame->prog_backwards)); int cmp; ec = &outnode->futures; while (*ec) { cmp = se_list_cmp ((void *)(*ec)->effects, (void *)prog_in_order); if (cmp <= 0) break; ec = &(*ec)->next; } if (!*ec || (cmp < 0)) { struct rx_possible_future * saved = *ec; *ec = rx_possible_future (rx, prog_in_order); (*ec)->next = saved; if (!*ec) return 0; } if (node->id >= 0) { (*ec)->destset = nfa_set_enjoin (rx, &rx->set_list_memo, node, (*ec)->destset); if (!(*ec)->destset) return 0; } } while (e) { switch (e->type) { case ne_epsilon: if (!eclose_node (rx, outnode, e->dest, frame)) return 0; break; case ne_side_effect: { frame->prog_backwards = side_effect_cons (rx, e->params.side_effect, frame->prog_backwards); if (!frame->prog_backwards) return 0; if (!eclose_node (rx, outnode, e->dest, frame)) return 0; { struct rx_se_list * dying = frame->prog_backwards; frame->prog_backwards = frame->prog_backwards->cdr; chunk_free (&sel_pool, (char *)dying); } break; } default: break; } e = e->next; } node->mark = 0; return 1; } #ifdef __STDC__ RX_DECL int rx_eclose_nfa (struct rx *rx) #else RX_DECL int rx_eclose_nfa (rx) struct rx *rx; #endif { struct rx_nfa_state *n = rx->nfa_states; struct eclose_frame frame; static int rx_id = 0; frame.prog_backwards = 0; rx->rx_id = rx_id++; bzero (&rx->se_list_memo, sizeof (rx->se_list_memo)); bzero (&rx->set_list_memo, sizeof (rx->set_list_memo)); while (n) { n->futures = 0; if (n->eclosure_needed && !eclose_node (rx, n, n, &frame)) return 0; /* clear_marks (rx); */ n = n->next; } return 1; } /* This deletes epsilon edges from an NFA. After running eclose_node, * we have no more need for these edges. They are removed to simplify * further operations on the NFA. */ #ifdef __STDC__ RX_DECL void rx_delete_epsilon_transitions (struct rx *rx) #else RX_DECL void rx_delete_epsilon_transitions (rx) struct rx *rx; #endif { struct rx_nfa_state *n = rx->nfa_states; struct rx_nfa_edge **e; while (n) { e = &n->edges; while (*e) { struct rx_nfa_edge *t; switch ((*e)->type) { case ne_epsilon: case ne_side_effect: t = *e; *e = t->next; rx_free_nfa_edge (t); break; default: e = &(*e)->next; break; } } n = n->next; } } /* This page: storing the nfa in a contiguous region of memory for * subsequent conversion to a super-nfa. */ /* This is for qsort on an array of nfa_states. The order * is based on state ids and goes * [0...MAX][MIN..-1] where (MAX>=0) and (MIN<0) * This way, positive ids double as array indices. */ #ifdef __STDC__ static int nfacmp (void * va, void * vb) #else static int nfacmp (va, vb) void * va; void * vb; #endif { struct rx_nfa_state **a = (struct rx_nfa_state **)va; struct rx_nfa_state **b = (struct rx_nfa_state **)vb; return (*a == *b /* &&&& 3.18 */ ? 0 : (((*a)->id < 0) == ((*b)->id < 0) ? (((*a)->id < (*b)->id) ? -1 : 1) : (((*a)->id < 0) ? 1 : -1))); } #ifdef __STDC__ static int count_hash_nodes (struct rx_hash * st) #else static int count_hash_nodes (st) struct rx_hash * st; #endif { int x; int count = 0; for (x = 0; x < 13; ++x) count += ((st->children[x]) ? count_hash_nodes (st->children[x]) : st->bucket_size[x]); return count; } #ifdef __STDC__ static void se_memo_freer (struct rx_hash_item * node) #else static void se_memo_freer (node) struct rx_hash_item * node; #endif { chunk_free (&sel_pool, (char *)node->data); } #ifdef __STDC__ static void nfa_set_freer (struct rx_hash_item * node) #else static void nfa_set_freer (node) struct rx_hash_item * node; #endif { chunk_free (&nfa_sets, (char *)node->data); } /* This copies an entire NFA into a single malloced block of memory. * Mostly this is for compatability with regex.c, though it is convenient * to have the nfa nodes in an array. */ #ifdef __STDC__ RX_DECL int rx_compactify_nfa (struct rx *rx, void **mem, unsigned long *size) #else RX_DECL int rx_compactify_nfa (rx, mem, size) struct rx *rx; void **mem; unsigned long *size; #endif { int total_nodec; struct rx_nfa_state *n; int edgec = 0; int eclosec = 0; int se_list_consc = count_hash_nodes (&rx->se_list_memo); int nfa_setc = count_hash_nodes (&rx->set_list_memo); unsigned long total_size; /* This takes place in two stages. First, the total size of the * nfa is computed, then structures are copied. */ n = rx->nfa_states; total_nodec = 0; while (n) { struct rx_nfa_edge *e = n->edges; struct rx_possible_future *ec = n->futures; ++total_nodec; while (e) { ++edgec; e = e->next; } while (ec) { ++eclosec; ec = ec->next; } n = n->next; } total_size = (total_nodec * sizeof (struct rx_nfa_state) + edgec * rx_sizeof_bitset (rx->local_cset_size) + edgec * sizeof (struct rx_nfa_edge) + nfa_setc * sizeof (struct rx_nfa_state_set) + eclosec * sizeof (struct rx_possible_future) + se_list_consc * sizeof (struct rx_se_list) + rx->reserved); if (total_size > *size) { *mem = remalloc (*mem, total_size); if (*mem) *size = total_size; else return 0; } /* Now we've allocated the memory; this copies the NFA. */ { static struct rx_nfa_state **scratch = 0; static int scratch_alloc = 0; struct rx_nfa_state *state_base = (struct rx_nfa_state *) * mem; struct rx_nfa_state *new_state = state_base; struct rx_nfa_edge *new_edge = (struct rx_nfa_edge *) ((char *) state_base + total_nodec * sizeof (struct rx_nfa_state)); struct rx_se_list * new_se_list = (struct rx_se_list *) ((char *)new_edge + edgec * sizeof (struct rx_nfa_edge)); struct rx_possible_future *new_close = ((struct rx_possible_future *) ((char *) new_se_list + se_list_consc * sizeof (struct rx_se_list))); struct rx_nfa_state_set * new_nfa_set = ((struct rx_nfa_state_set *) ((char *)new_close + eclosec * sizeof (struct rx_possible_future))); char *new_bitset = ((char *) new_nfa_set + nfa_setc * sizeof (struct rx_nfa_state_set)); int x; struct rx_nfa_state *n; if (scratch_alloc < total_nodec) { scratch = ((struct rx_nfa_state **) remalloc (scratch, total_nodec * sizeof (*scratch))); if (scratch) scratch_alloc = total_nodec; else { scratch_alloc = 0; return 0; } } for (x = 0, n = rx->nfa_states; n; n = n->next) scratch[x++] = n; qsort (scratch, total_nodec, sizeof (struct rx_nfa_state *), (int (*)())nfacmp); for (x = 0; x < total_nodec; ++x) { struct rx_possible_future *eclose = scratch[x]->futures; struct rx_nfa_edge *edge = scratch[x]->edges; struct rx_nfa_state *cn = new_state++; cn->futures = 0; cn->edges = 0; cn->next = (x == total_nodec - 1) ? 0 : (cn + 1); cn->id = scratch[x]->id; cn->is_final = scratch[x]->is_final; cn->is_start = scratch[x]->is_start; cn->mark = 0; while (edge) { int indx = (edge->dest->id < 0 ? (total_nodec + edge->dest->id) : edge->dest->id); struct rx_nfa_edge *e = new_edge++; rx_Bitset cset = (rx_Bitset) new_bitset; new_bitset += rx_sizeof_bitset (rx->local_cset_size); rx_bitset_null (rx->local_cset_size, cset); rx_bitset_union (rx->local_cset_size, cset, edge->params.cset); e->next = cn->edges; cn->edges = e; e->type = edge->type; e->dest = state_base + indx; e->params.cset = cset; edge = edge->next; } while (eclose) { struct rx_possible_future *ec = new_close++; struct rx_hash_item * sp; struct rx_se_list ** sepos; struct rx_se_list * sesrc; struct rx_nfa_state_set * destlst; struct rx_nfa_state_set ** destpos; ec->next = cn->futures; cn->futures = ec; for (sepos = &ec->effects, sesrc = eclose->effects; sesrc; sesrc = sesrc->cdr, sepos = &(*sepos)->cdr) { sp = rx_hash_find (&rx->se_list_memo, (long)sesrc->car ^ (long)sesrc->cdr, sesrc, &se_list_hash_rules); if (sp->binding) { sesrc = (struct rx_se_list *)sp->binding; break; } *new_se_list = *sesrc; sp->binding = (void *)new_se_list; *sepos = new_se_list; ++new_se_list; } *sepos = sesrc; for (destpos = &ec->destset, destlst = eclose->destset; destlst; destpos = &(*destpos)->cdr, destlst = destlst->cdr) { sp = rx_hash_find (&rx->set_list_memo, ((((long)destlst->car) >> 8) ^ (long)destlst->cdr), destlst, &nfa_set_hash_rules); if (sp->binding) { destlst = (struct rx_nfa_state_set *)sp->binding; break; } *new_nfa_set = *destlst; new_nfa_set->car = state_base + destlst->car->id; sp->binding = (void *)new_nfa_set; *destpos = new_nfa_set; ++new_nfa_set; } *destpos = destlst; eclose = eclose->next; } } } rx_free_hash_table (&rx->se_list_memo, se_memo_freer, &se_list_hash_rules); bzero (&rx->se_list_memo, sizeof (rx->se_list_memo)); rx_free_hash_table (&rx->set_list_memo, nfa_set_freer, &nfa_set_hash_rules); bzero (&rx->set_list_memo, sizeof (rx->set_list_memo)); rx_free_nfa (rx); rx->nfa_states = (struct rx_nfa_state *)*mem; return 1; } /* The functions in the next several pages define the lazy-NFA-conversion used * by matchers. The input to this construction is an NFA such as * is built by compactify_nfa (rx.c). The output is the superNFA. */ /* Match engines can use arbitrary values for opcodes. So, the parse tree * is built using instructions names (enum rx_opcode), but the superstate * nfa is populated with mystery opcodes (void *). * * For convenience, here is an id table. The opcodes are == to their inxs * * The lables in re_search_2 would make good values for instructions. */ void * rx_id_instruction_table[rx_num_instructions] = { (void *) rx_backtrack_point, (void *) rx_do_side_effects, (void *) rx_cache_miss, (void *) rx_next_char, (void *) rx_backtrack, (void *) rx_error_inx }; /* Memory mgt. for superstate graphs. */ #ifdef __STDC__ static char * rx_cache_malloc (struct rx_cache * cache, int bytes) #else static char * rx_cache_malloc (cache, bytes) struct rx_cache * cache; int bytes; #endif { while (cache->bytes_left < bytes) { if (cache->memory_pos) cache->memory_pos = cache->memory_pos->next; if (!cache->memory_pos) { cache->morecore (cache); if (!cache->memory_pos) return 0; } cache->bytes_left = cache->memory_pos->bytes; cache->memory_addr = ((char *)cache->memory_pos + sizeof (struct rx_blocklist)); } cache->bytes_left -= bytes; { char * addr = cache->memory_addr; cache->memory_addr += bytes; return addr; } } #ifdef __STDC__ static void rx_cache_free (struct rx_cache * cache, struct rx_freelist ** freelist, char * mem) #else static void rx_cache_free (cache, freelist, mem) struct rx_cache * cache; struct rx_freelist ** freelist; char * mem; #endif { struct rx_freelist * it = (struct rx_freelist *)mem; it->next = *freelist; *freelist = it; } /* The partially instantiated superstate graph has a transition * table at every node. There is one entry for every character. * This fills in the transition for a set. */ #ifdef __STDC__ static void install_transition (struct rx_superstate *super, struct rx_inx *answer, rx_Bitset trcset) #else static void install_transition (super, answer, trcset) struct rx_superstate *super; struct rx_inx *answer; rx_Bitset trcset; #endif { struct rx_inx * transitions = super->transitions; int chr; for (chr = 0; chr < 256; ) if (!*trcset) { ++trcset; chr += 32; } else { RX_subset sub = *trcset; RX_subset mask = 1; int bound = chr + 32; while (chr < bound) { if (sub & mask) transitions [chr] = *answer; ++chr; mask <<= 1; } ++trcset; } } #if 1 static int qlen (q) struct rx_superstate * q; { int count = 1; struct rx_superstate * it; if (!q) return 0; for (it = q->next_recyclable; it != q; it = it->next_recyclable) ++count; return count; } static void check_cache (cache) struct rx_cache * cache; { struct rx_cache * you_fucked_up = 0; int total = cache->superstates; int semi = cache->semifree_superstates; if (semi != qlen (cache->semifree_superstate)) check_cache (you_fucked_up); if ((total - semi) != qlen (cache->lru_superstate)) check_cache (you_fucked_up); } #endif #ifdef __STDC__ static void semifree_superstate (struct rx_cache * cache) #else static void semifree_superstate (cache) struct rx_cache * cache; #endif { int disqualified = cache->semifree_superstates; if (disqualified == cache->superstates) return; while (cache->lru_superstate->locks) { cache->lru_superstate = cache->lru_superstate->next_recyclable; ++disqualified; if (disqualified == cache->superstates) return; } { struct rx_superstate * it = cache->lru_superstate; it->next_recyclable->prev_recyclable = it->prev_recyclable; it->prev_recyclable->next_recyclable = it->next_recyclable; cache->lru_superstate = (it == it->next_recyclable ? 0 : it->next_recyclable); if (!cache->semifree_superstate) { cache->semifree_superstate = it; it->next_recyclable = it; it->prev_recyclable = it; } else { it->prev_recyclable = cache->semifree_superstate->prev_recyclable; it->next_recyclable = cache->semifree_superstate; it->prev_recyclable->next_recyclable = it; it->next_recyclable->prev_recyclable = it; } { struct rx_distinct_future *df; it->is_semifree = 1; ++cache->semifree_superstates; df = it->transition_refs; if (df) { df->prev_same_dest->next_same_dest = 0; for (df = it->transition_refs; df; df = df->next_same_dest) { df->future_frame.inx = cache->instruction_table[rx_cache_miss]; df->future_frame.data = 0; df->future_frame.data_2 = (void *) df; /* If there are any NEXT-CHAR instruction frames that * refer to this state, we convert them to CACHE-MISS frames. */ if (!df->effects && (df->edge->options->next_same_super_edge[0] == df->edge->options)) install_transition (df->present, &df->future_frame, df->edge->cset); } df = it->transition_refs; df->prev_same_dest->next_same_dest = df; } } } } #ifdef __STDC__ static void refresh_semifree_superstate (struct rx_cache * cache, struct rx_superstate * super) #else static void refresh_semifree_superstate (cache, super) struct rx_cache * cache; struct rx_superstate * super; #endif { struct rx_distinct_future *df; if (super->transition_refs) { super->transition_refs->prev_same_dest->next_same_dest = 0; for (df = super->transition_refs; df; df = df->next_same_dest) { df->future_frame.inx = cache->instruction_table[rx_next_char]; df->future_frame.data = (void *) super->transitions; /* CACHE-MISS instruction frames that refer to this state, * must be converted to NEXT-CHAR frames. */ if (!df->effects && (df->edge->options->next_same_super_edge[0] == df->edge->options)) install_transition (df->present, &df->future_frame, df->edge->cset); } super->transition_refs->prev_same_dest->next_same_dest = super->transition_refs; } if (cache->semifree_superstate == super) cache->semifree_superstate = (super->prev_recyclable == super ? 0 : super->prev_recyclable); super->next_recyclable->prev_recyclable = super->prev_recyclable; super->prev_recyclable->next_recyclable = super->next_recyclable; if (!cache->lru_superstate) (cache->lru_superstate = super->next_recyclable = super->prev_recyclable = super); else { super->next_recyclable = cache->lru_superstate; super->prev_recyclable = cache->lru_superstate->prev_recyclable; super->next_recyclable->prev_recyclable = super; super->prev_recyclable->next_recyclable = super; } super->is_semifree = 0; --cache->semifree_superstates; } #ifdef __STDC__ static void rx_refresh_this_superstate (struct rx_cache * cache, struct rx_superstate * superstate) #else static void rx_refresh_this_superstate (cache, superstate) struct rx_cache * cache; struct rx_superstate * superstate; #endif { if (superstate->is_semifree) refresh_semifree_superstate (cache, superstate); else if (cache->lru_superstate == superstate) cache->lru_superstate = superstate->next_recyclable; else if (superstate != cache->lru_superstate->prev_recyclable) { superstate->next_recyclable->prev_recyclable = superstate->prev_recyclable; superstate->prev_recyclable->next_recyclable = superstate->next_recyclable; superstate->next_recyclable = cache->lru_superstate; superstate->prev_recyclable = cache->lru_superstate->prev_recyclable; superstate->next_recyclable->prev_recyclable = superstate; superstate->prev_recyclable->next_recyclable = superstate; } } #ifdef __STDC__ static void release_superset_low (struct rx_cache * cache, struct rx_superset *set) #else static void release_superset_low (cache, set) struct rx_cache * cache; struct rx_superset *set; #endif { if (!--set->refs) { if (set->cdr) release_superset_low (cache, set->cdr); set->starts_for = 0; rx_hash_free (rx_hash_find (&cache->superset_table, (unsigned long)set->car ^ set->id ^ (unsigned long)set->cdr, (void *)set, &cache->superset_hash_rules), &cache->superset_hash_rules); rx_cache_free (cache, &cache->free_supersets, (char *)set); } } /* This tries to add a new superstate to the superstate freelist. * It might, as a result, free some edge pieces or hash tables. * If nothing can be freed because too many locks are being held, fail. */ #ifdef __STDC__ static int rx_really_free_superstate (struct rx_cache * cache) #else static int rx_really_free_superstate (cache) struct rx_cache * cache; #endif { int locked_superstates = 0; struct rx_superstate * it; if (!cache->superstates) return 0; { /* This is a total guess. The idea is that we should expect as * many misses as we've recently experienced. I.e., cache->misses * should be the same as cache->semifree_superstates. */ while ((cache->hits + cache->misses) > cache->superstates_allowed) { cache->hits >>= 1; cache->misses >>= 1; } if ( ((cache->hits + cache->misses) * cache->semifree_superstates) < (cache->superstates * cache->misses)) { semifree_superstate (cache); semifree_superstate (cache); } } while (cache->semifree_superstate && cache->semifree_superstate->locks) { refresh_semifree_superstate (cache, cache->semifree_superstate); ++locked_superstates; if (locked_superstates == cache->superstates) return 0; } if (cache->semifree_superstate) { it = cache->semifree_superstate; it->next_recyclable->prev_recyclable = it->prev_recyclable; it->prev_recyclable->next_recyclable = it->next_recyclable; cache->semifree_superstate = ((it == it->next_recyclable) ? 0 : it->next_recyclable); --cache->semifree_superstates; } else { while (cache->lru_superstate->locks) { cache->lru_superstate = cache->lru_superstate->next_recyclable; ++locked_superstates; if (locked_superstates == cache->superstates) return 0; } it = cache->lru_superstate; it->next_recyclable->prev_recyclable = it->prev_recyclable; it->prev_recyclable->next_recyclable = it->next_recyclable; cache->lru_superstate = ((it == it->next_recyclable) ? 0 : it->next_recyclable); } if (it->transition_refs) { struct rx_distinct_future *df; for (df = it->transition_refs, df->prev_same_dest->next_same_dest = 0; df; df = df->next_same_dest) { df->future_frame.inx = cache->instruction_table[rx_cache_miss]; df->future_frame.data = 0; df->future_frame.data_2 = (void *) df; df->future = 0; } it->transition_refs->prev_same_dest->next_same_dest = it->transition_refs; } { struct rx_super_edge *tc = it->edges; while (tc) { struct rx_distinct_future * df; struct rx_super_edge *tct = tc->next; df = tc->options; df->next_same_super_edge[1]->next_same_super_edge[0] = 0; while (df) { struct rx_distinct_future *dft = df; df = df->next_same_super_edge[0]; if (dft->future && dft->future->transition_refs == dft) { dft->future->transition_refs = dft->next_same_dest; if (dft->future->transition_refs == dft) dft->future->transition_refs = 0; } dft->next_same_dest->prev_same_dest = dft->prev_same_dest; dft->prev_same_dest->next_same_dest = dft->next_same_dest; rx_cache_free (cache, &cache->free_discernable_futures, (char *)dft); } rx_cache_free (cache, &cache->free_transition_classes, (char *)tc); tc = tct; } } if (it->contents->superstate == it) it->contents->superstate = 0; release_superset_low (cache, it->contents); rx_cache_free (cache, &cache->free_superstates, (char *)it); --cache->superstates; return 1; } #ifdef __STDC__ static char * rx_cache_get (struct rx_cache * cache, struct rx_freelist ** freelist) #else static char * rx_cache_get (cache, freelist) struct rx_cache * cache; struct rx_freelist ** freelist; #endif { while (!*freelist && rx_really_free_superstate (cache)) ; if (!*freelist) return 0; { struct rx_freelist * it = *freelist; *freelist = it->next; return (char *)it; } } #ifdef __STDC__ static char * rx_cache_malloc_or_get (struct rx_cache * cache, struct rx_freelist ** freelist, int bytes) #else static char * rx_cache_malloc_or_get (cache, freelist, bytes) struct rx_cache * cache; struct rx_freelist ** freelist; int bytes; #endif { if (!*freelist) { char * answer = rx_cache_malloc (cache, bytes); if (answer) return answer; } return rx_cache_get (cache, freelist); } #ifdef __STDC__ static char * rx_cache_get_superstate (struct rx_cache * cache) #else static char * rx_cache_get_superstate (cache) struct rx_cache * cache; #endif { char * answer; int bytes = ( sizeof (struct rx_superstate) + cache->local_cset_size * sizeof (struct rx_inx)); if (!cache->free_superstates && (cache->superstates < cache->superstates_allowed)) { answer = rx_cache_malloc (cache, bytes); if (answer) { ++cache->superstates; return answer; } } answer = rx_cache_get (cache, &cache->free_superstates); if (!answer) { answer = rx_cache_malloc (cache, bytes); if (answer) ++cache->superstates_allowed; } ++cache->superstates; return answer; } static int supersetcmp (va, vb) void * va; void * vb; { struct rx_superset * a = (struct rx_superset *)va; struct rx_superset * b = (struct rx_superset *)vb; return ( (a == b) || (a && b && (a->car == b->car) && (a->cdr == b->cdr))); } #ifdef __STDC__ static struct rx_hash_item * superset_allocator (struct rx_hash_rules * rules, void * val) #else static struct rx_hash_item * superset_allocator (rules, val) struct rx_hash_rules * rules; void * val; #endif { struct rx_cache * cache = ((struct rx_cache *) ((char *)rules - (unsigned long)(&((struct rx_cache *)0)->superset_hash_rules))); struct rx_superset * template = (struct rx_superset *)val; struct rx_superset * newset = ((struct rx_superset *) rx_cache_malloc_or_get (cache, &cache->free_supersets, sizeof (*template))); newset->refs = 0; newset->car = template->car; newset->id = template->car->id; newset->cdr = template->cdr; newset->superstate = 0; rx_protect_superset (rx, template->cdr); newset->hash_item.data = (void *)newset; newset->hash_item.binding = 0; return &newset->hash_item; } #ifdef __STDC__ static struct rx_hash * super_hash_allocator (struct rx_hash_rules * rules) #else static struct rx_hash * super_hash_allocator (rules) struct rx_hash_rules * rules; #endif { struct rx_cache * cache = ((struct rx_cache *) ((char *)rules - (unsigned long)(&((struct rx_cache *)0)->superset_hash_rules))); return ((struct rx_hash *) rx_cache_malloc_or_get (cache, &cache->free_hash, sizeof (struct rx_hash))); } #ifdef __STDC__ static void super_hash_liberator (struct rx_hash * hash, struct rx_hash_rules * rules) #else static void super_hash_liberator (hash, rules) struct rx_hash * hash; struct rx_hash_rules * rules; #endif { struct rx_cache * cache = ((struct rx_cache *) (char *)rules - (long)(&((struct rx_cache *)0)->superset_hash_rules)); rx_cache_free (cache, &cache->free_hash, (char *)hash); } #ifdef __STDC__ static void superset_hash_item_liberator (struct rx_hash_item * it, struct rx_hash_rules * rules) #else static void superset_hash_item_liberator (it, rules) /* Well, it does ya know. */ struct rx_hash_item * it; struct rx_hash_rules * rules; #endif { } int rx_cache_bound = 128; static int rx_default_cache_got = 0; #ifdef __STDC__ static int bytes_for_cache_size (int supers, int cset_size) #else static int bytes_for_cache_size (supers, cset_size) int supers; int cset_size; #endif { return (int) ((float)supers * ( (1.03 * (float) ( rx_sizeof_bitset (cset_size) + sizeof (struct rx_super_edge))) + (1.80 * (float) sizeof (struct rx_possible_future)) + (float) ( sizeof (struct rx_superstate) + cset_size * sizeof (struct rx_inx)))); } #ifdef __STDC__ static void rx_morecore (struct rx_cache * cache) #else static void rx_morecore (cache) struct rx_cache * cache; #endif { if (rx_default_cache_got >= rx_cache_bound) return; rx_default_cache_got += 16; cache->superstates_allowed = rx_cache_bound; { struct rx_blocklist ** pos = &cache->memory; int size = bytes_for_cache_size (16, cache->local_cset_size); while (*pos) pos = &(*pos)->next; *pos = ((struct rx_blocklist *) malloc (size + sizeof (struct rx_blocklist))); if (!*pos) return; (*pos)->next = 0; (*pos)->bytes = size; cache->memory_pos = *pos; cache->memory_addr = (char *)*pos + sizeof (**pos); cache->bytes_left = size; } } static struct rx_cache default_cache = { { supersetcmp, super_hash_allocator, super_hash_liberator, superset_allocator, superset_hash_item_liberator, }, 0, 0, 0, 0, rx_morecore, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 256, rx_id_instruction_table, { 0, 0, {0}, {0}, {0} } }; /* This adds an element to a superstate set. These sets are lists, such * that lists with == elements are ==. The empty set is returned by * superset_cons (rx, 0, 0) and is NOT equivelent to * (struct rx_superset)0. */ #ifdef __STDC__ RX_DECL struct rx_superset * rx_superset_cons (struct rx * rx, struct rx_nfa_state *car, struct rx_superset *cdr) #else RX_DECL struct rx_superset * rx_superset_cons (rx, car, cdr) struct rx * rx; struct rx_nfa_state *car; struct rx_superset *cdr; #endif { struct rx_cache * cache = rx->cache; if (!car && !cdr) { if (!cache->empty_superset) { cache->empty_superset = ((struct rx_superset *) rx_cache_malloc_or_get (cache, &cache->free_supersets, sizeof (struct rx_superset))); if (!cache->empty_superset) return 0; bzero (cache->empty_superset, sizeof (struct rx_superset)); cache->empty_superset->refs = 1000; } return cache->empty_superset; } { struct rx_superset template; struct rx_hash_item * hit; template.car = car; template.cdr = cdr; template.id = car->id; hit = rx_hash_store (&cache->superset_table, (unsigned long)car ^ car->id ^ (unsigned long)cdr, (void *)&template, &cache->superset_hash_rules); return (hit ? (struct rx_superset *)hit->data : 0); } } /* This computes a union of two NFA state sets. The sets do not have the * same representation though. One is a RX_SUPERSET structure (part * of the superstate NFA) and the other is an NFA_STATE_SET (part of the NFA). */ #ifdef __STDC__ RX_DECL struct rx_superset * rx_superstate_eclosure_union (struct rx * rx, struct rx_superset *set, struct rx_nfa_state_set *ecl) #else RX_DECL struct rx_superset * rx_superstate_eclosure_union (rx, set, ecl) struct rx * rx; struct rx_superset *set; struct rx_nfa_state_set *ecl; #endif { if (!ecl) return set; if (!set->car) return rx_superset_cons (rx, ecl->car, rx_superstate_eclosure_union (rx, set, ecl->cdr)); { if (set->car == ecl->car) return rx_superstate_eclosure_union (rx, set, ecl->cdr); if (set->car > ecl->car) return rx_superset_cons (rx, set->car, rx_superstate_eclosure_union (rx, set->cdr, ecl)); return rx_superset_cons (rx, ecl->car, rx_superstate_eclosure_union (rx, set, ecl->cdr)); } } #ifdef __STDC__ RX_DECL void rx_release_superset (struct rx *rx, struct rx_superset *set) #else RX_DECL void rx_release_superset (rx, set) struct rx *rx; struct rx_superset *set; #endif { release_superset_low (rx->cache, set); } /* * This makes sure that a list of rx_distinct_futures contains * a future for each possible set of side effects in the eclosure * of a given state. This is some of the work of filling in a * superstate transition. */ #ifdef __STDC__ static struct rx_distinct_future * include_futures (struct rx *rx, struct rx_distinct_future *df, struct rx_nfa_state *state, struct rx_superstate *superstate) #else static struct rx_distinct_future * include_futures (rx, df, state, superstate) struct rx *rx; struct rx_distinct_future *df; struct rx_nfa_state *state; struct rx_superstate *superstate; #endif { struct rx_possible_future *future; struct rx_cache * cache = rx->cache; for (future = state->futures; future; future = future->next) { struct rx_distinct_future *dfp; struct rx_distinct_future *insert_before = 0; if (df) df->next_same_super_edge[1]->next_same_super_edge[0] = 0; for (dfp = df; dfp; dfp = dfp->next_same_super_edge[0]) if (dfp->effects == future->effects) break; else { int order = rx->se_list_cmp (rx, dfp->effects, future->effects); if (order > 0) { insert_before = dfp; dfp = 0; break; } } if (df) df->next_same_super_edge[1]->next_same_super_edge[0] = df; if (!dfp) { dfp = ((struct rx_distinct_future *) rx_cache_malloc_or_get (cache, &cache->free_discernable_futures, sizeof (struct rx_distinct_future))); if (!dfp) return 0; if (!df) { df = insert_before = dfp; df->next_same_super_edge[0] = df->next_same_super_edge[1] = df; } else if (!insert_before) insert_before = df; else if (insert_before == df) df = dfp; dfp->next_same_super_edge[0] = insert_before; dfp->next_same_super_edge[1] = insert_before->next_same_super_edge[1]; dfp->next_same_super_edge[1]->next_same_super_edge[0] = dfp; dfp->next_same_super_edge[0]->next_same_super_edge[1] = dfp; dfp->next_same_dest = dfp->prev_same_dest = dfp; dfp->future = 0; dfp->present = superstate; dfp->future_frame.inx = rx->instruction_table[rx_cache_miss]; dfp->future_frame.data = 0; dfp->future_frame.data_2 = (void *) dfp; dfp->side_effects_frame.inx = rx->instruction_table[rx_do_side_effects]; dfp->side_effects_frame.data = 0; dfp->side_effects_frame.data_2 = (void *) dfp; dfp->effects = future->effects; } } return df; } /* This constructs a new superstate from its state set. The only * complexity here is memory management. */ #ifdef __STDC__ RX_DECL struct rx_superstate * rx_superstate (struct rx *rx, struct rx_superset *set) #else RX_DECL struct rx_superstate * rx_superstate (rx, set) struct rx *rx; struct rx_superset *set; #endif { struct rx_cache * cache = rx->cache; struct rx_superstate * superstate = 0; /* Does the superstate already exist in the cache? */ if (set->superstate) { if (set->superstate->rx_id != rx->rx_id) { /* Aha. It is in the cache, but belongs to a superstate * that refers to an NFA that no longer exists. * (We know it no longer exists because it was evidently * stored in the same region of memory as the current nfa * yet it has a different id.) */ superstate = set->superstate; if (!superstate->is_semifree) { if (cache->lru_superstate == superstate) { cache->lru_superstate = superstate->next_recyclable; if (cache->lru_superstate == superstate) cache->lru_superstate = 0; } { superstate->next_recyclable->prev_recyclable = superstate->prev_recyclable; superstate->prev_recyclable->next_recyclable = superstate->next_recyclable; if (!cache->semifree_superstate) { (cache->semifree_superstate = superstate->next_recyclable = superstate->prev_recyclable = superstate); } else { superstate->next_recyclable = cache->semifree_superstate; superstate->prev_recyclable = cache->semifree_superstate->prev_recyclable; superstate->next_recyclable->prev_recyclable = superstate; superstate->prev_recyclable->next_recyclable = superstate; cache->semifree_superstate = superstate; } ++cache->semifree_superstates; } } set->superstate = 0; goto handle_cache_miss; } ++cache->hits; superstate = set->superstate; rx_refresh_this_superstate (cache, superstate); return superstate; } handle_cache_miss: /* This point reached only for cache misses. */ ++cache->misses; #if RX_DEBUG if (rx_debug_trace > 1) { struct rx_superset * setp = set; fprintf (stderr, "Building a superstet %d(%d): ", rx->rx_id, set); while (setp) { fprintf (stderr, "%d ", setp->id); setp = setp->cdr; } fprintf (stderr, "(%d)\n", set); } #endif superstate = (struct rx_superstate *)rx_cache_get_superstate (cache); if (!superstate) return 0; if (!cache->lru_superstate) (cache->lru_superstate = superstate->next_recyclable = superstate->prev_recyclable = superstate); else { superstate->next_recyclable = cache->lru_superstate; superstate->prev_recyclable = cache->lru_superstate->prev_recyclable; ( superstate->prev_recyclable->next_recyclable = superstate->next_recyclable->prev_recyclable = superstate); } superstate->rx_id = rx->rx_id; superstate->transition_refs = 0; superstate->locks = 0; superstate->is_semifree = 0; set->superstate = superstate; superstate->contents = set; rx_protect_superset (rx, set); superstate->edges = 0; { int x; /* None of the transitions from this superstate are known yet. */ for (x = 0; x < rx->local_cset_size; ++x) /* &&&&& 3.8 % */ { struct rx_inx * ifr = &superstate->transitions[x]; ifr->inx = rx->instruction_table [rx_cache_miss]; ifr->data = ifr->data_2 = 0; } } return superstate; } /* This computes the destination set of one edge of the superstate NFA. * Note that a RX_DISTINCT_FUTURE is a superstate edge. * Returns 0 on an allocation failure. */ #ifdef __STDC__ static int solve_destination (struct rx *rx, struct rx_distinct_future *df) #else static int solve_destination (rx, df) struct rx *rx; struct rx_distinct_future *df; #endif { struct rx_super_edge *tc = df->edge; struct rx_superset *nfa_state; struct rx_superset *nil_set = rx_superset_cons (rx, 0, 0); struct rx_superset *solution = nil_set; struct rx_superstate *dest; /* Iterate over all NFA states in the state set of this superstate. */ for (nfa_state = df->present->contents; nfa_state->car; nfa_state = nfa_state->cdr) { struct rx_nfa_edge *e; /* Iterate over all edges of each NFA state. */ for (e = nfa_state->car->edges; e; e = e->next) /* If we find an edge that is labeled with * the characters we are solving for..... */ if (rx_bitset_is_subset (rx->local_cset_size, tc->cset, e->params.cset)) { struct rx_nfa_state *n = e->dest; struct rx_possible_future *pf; /* ....search the partial epsilon closures of the destination * of that edge for a path that involves the same set of * side effects we are solving for. * If we find such a RX_POSSIBLE_FUTURE, we add members to the * stateset we are computing. */ for (pf = n->futures; pf; pf = pf->next) if (pf->effects == df->effects) { struct rx_superset * old_sol = solution; rx_protect_superset (rx, solution); solution = rx_superstate_eclosure_union (rx, solution, pf->destset); if (!solution) return 0; rx_release_superset (rx, old_sol); } } } /* It is possible that the RX_DISTINCT_FUTURE we are working on has * the empty set of NFA states as its definition. In that case, this * is a failure point. */ if (solution == nil_set) { df->future_frame.inx = (void *) rx_backtrack; df->future_frame.data = 0; df->future_frame.data_2 = 0; return 1; } rx_protect_superset (rx, solution); dest = rx_superstate (rx, solution); rx_release_superset (rx, solution); if (!dest) return 0; { struct rx_distinct_future *dft; dft = df; df->prev_same_dest->next_same_dest = 0; while (dft) { dft->future = dest; dft->future_frame.inx = rx->instruction_table[rx_next_char]; dft->future_frame.data = (void *) dest->transitions; dft = dft->next_same_dest; } df->prev_same_dest->next_same_dest = df; } if (!dest->transition_refs) dest->transition_refs = df; else { struct rx_distinct_future *dft = dest->transition_refs->next_same_dest; dest->transition_refs->next_same_dest = df->next_same_dest; df->next_same_dest->prev_same_dest = dest->transition_refs; df->next_same_dest = dft; dft->prev_same_dest = df; } return 1; } /* This takes a superstate and a character, and computes some edges * from the superstate NFA. In particular, this computes all edges * that lead from SUPERSTATE given CHR. This function also * computes the set of characters that share this edge set. * This returns 0 on allocation error. * The character set and list of edges are returned through * the paramters CSETOUT and DFOUT. } */ #ifdef __STDC__ static int compute_super_edge (struct rx *rx, struct rx_distinct_future **dfout, rx_Bitset csetout, struct rx_superstate *superstate, unsigned char chr) #else static int compute_super_edge (rx, dfout, csetout, superstate, chr) struct rx *rx; struct rx_distinct_future **dfout; rx_Bitset csetout; struct rx_superstate *superstate; unsigned char chr; #endif { struct rx_superset *stateset = superstate->contents; /* To compute the set of characters that share edges with CHR, * we start with the full character set, and subtract. */ rx_bitset_universe (rx->local_cset_size, csetout); *dfout = 0; /* Iterate over the NFA states in the superstate state-set. */ while (stateset->car) { struct rx_nfa_edge *e; for (e = stateset->car->edges; e; e = e->next) if (RX_bitset_member (e->params.cset, chr)) { /* If we find an NFA edge that applies, we make sure there * are corresponding edges in the superstate NFA. */ *dfout = include_futures (rx, *dfout, e->dest, superstate); if (!*dfout) return 0; /* We also trim the character set a bit. */ rx_bitset_intersection (rx->local_cset_size, csetout, e->params.cset); } else /* An edge that doesn't apply at least tells us some characters * that don't share the same edge set as CHR. */ rx_bitset_difference (rx->local_cset_size, csetout, e->params.cset); stateset = stateset->cdr; } return 1; } /* This is a constructor for RX_SUPER_EDGE structures. These are * wrappers for lists of superstate NFA edges that share character sets labels. * If a transition class contains more than one rx_distinct_future (superstate * edge), then it represents a non-determinism in the superstate NFA. */ #ifdef __STDC__ static struct rx_super_edge * rx_super_edge (struct rx *rx, struct rx_superstate *super, rx_Bitset cset, struct rx_distinct_future *df) #else static struct rx_super_edge * rx_super_edge (rx, super, cset, df) struct rx *rx; struct rx_superstate *super; rx_Bitset cset; struct rx_distinct_future *df; #endif { struct rx_super_edge *tc = (struct rx_super_edge *)rx_cache_malloc_or_get (rx->cache, &rx->cache->free_transition_classes, sizeof (struct rx_super_edge) + rx_sizeof_bitset (rx->local_cset_size)); if (!tc) return 0; tc->next = super->edges; super->edges = tc; tc->rx_backtrack_frame.inx = rx->instruction_table[rx_backtrack_point]; tc->rx_backtrack_frame.data = 0; tc->rx_backtrack_frame.data_2 = (void *) tc; tc->options = df; tc->cset = (rx_Bitset) ((char *) tc + sizeof (*tc)); rx_bitset_assign (rx->local_cset_size, tc->cset, cset); if (df) { struct rx_distinct_future * dfp = df; df->next_same_super_edge[1]->next_same_super_edge[0] = 0; while (dfp) { dfp->edge = tc; dfp = dfp->next_same_super_edge[0]; } df->next_same_super_edge[1]->next_same_super_edge[0] = df; } return tc; } /* There are three kinds of cache miss. The first occurs when a * transition is taken that has never been computed during the * lifetime of the source superstate. That cache miss is handled by * calling COMPUTE_SUPER_EDGE. The second kind of cache miss * occurs when the destination superstate of a transition doesn't * exist. SOLVE_DESTINATION is used to construct the destination superstate. * Finally, the third kind of cache miss occurs when the destination * superstate of a transition is in a `semi-free state'. That case is * handled by UNFREE_SUPERSTATE. * * The function of HANDLE_CACHE_MISS is to figure out which of these * cases applies. */ #ifdef __STDC__ static void install_partial_transition (struct rx_superstate *super, struct rx_inx *answer, RX_subset set, int offset) #else static void install_partial_transition (super, answer, set, offset) struct rx_superstate *super; struct rx_inx *answer; RX_subset set; int offset; #endif { int start = offset; int end = start + 32; RX_subset pos = 1; struct rx_inx * transitions = super->transitions; while (start < end) { if (set & pos) transitions[start] = *answer; pos <<= 1; ++start; } } #ifdef __STDC__ RX_DECL struct rx_inx * rx_handle_cache_miss (struct rx *rx, struct rx_superstate *super, unsigned char chr, void *data) #else RX_DECL struct rx_inx * rx_handle_cache_miss (rx, super, chr, data) struct rx *rx; struct rx_superstate *super; unsigned char chr; void *data; #endif { int offset = chr / RX_subset_bits; struct rx_distinct_future *df = data; if (!df) /* must be the shared_cache_miss_frame */ { /* Perhaps this is just a transition waiting to be filled. */ struct rx_super_edge *tc; RX_subset mask = rx_subset_singletons [chr % RX_subset_bits]; for (tc = super->edges; tc; tc = tc->next) if (tc->cset[offset] & mask) { struct rx_inx * answer; df = tc->options; answer = ((tc->options->next_same_super_edge[0] != tc->options) ? &tc->rx_backtrack_frame : (df->effects ? &df->side_effects_frame : &df->future_frame)); install_partial_transition (super, answer, tc->cset [offset], offset * 32); return answer; } /* Otherwise, it's a flushed or newly encountered edge. */ { rx_Bitset trcset = rx_cset (rx); struct rx_inx *answer; if (!trcset) return 0; rx_lock_superstate (rx, super); if (!compute_super_edge (rx, &df, trcset, super, chr)) { rx_unlock_superstate (rx, super); return 0; } if (!df) /* We just computed the fail transition. */ { static struct rx_inx shared_fail_frame = { (void *)rx_backtrack, 0, 0 }; answer = &shared_fail_frame; } else { tc = rx_super_edge (rx, super, trcset, df); if (!tc) { rx_unlock_superstate (rx, super); return 0; } answer = ((tc->options->next_same_super_edge[0] != tc->options) ? &tc->rx_backtrack_frame : (df->effects ? &df->side_effects_frame : &df->future_frame)); } install_partial_transition (super, answer, trcset[offset], offset * 32); rx_free_cset (rx, trcset); rx_unlock_superstate (rx, super); return answer; } } else if (df->future) /* A cache miss on an edge with a future? Must be * a semi-free destination. */ { if (df->future->is_semifree) refresh_semifree_superstate (rx->cache, df->future); return &df->future_frame; } else /* no future superstate on an existing edge */ { rx_lock_superstate (rx, super); if (!solve_destination (rx, df)) { rx_unlock_superstate (rx, super); return 0; } if (!df->effects && (df->edge->options->next_same_super_edge[0] == df->edge->options)) install_partial_transition (super, &df->future_frame, df->edge->cset[offset], offset * 32); rx_unlock_superstate (rx, super); return &df->future_frame; } } /* The rest of the code provides a regex.c compatable interface. */ const char *re_error_msg[] = { 0, /* REG_NOUT */ "No match", /* REG_NOMATCH */ "Invalid regular expression", /* REG_BADPAT */ "Invalid collation character", /* REG_ECOLLATE */ "Invalid character class name", /* REG_ECTYPE */ "Trailing backslash", /* REG_EESCAPE */ "Invalid back reference", /* REG_ESUBREG */ "Unmatched [ or [^", /* REG_EBRACK */ "Unmatched ( or \\(", /* REG_EPAREN */ "Unmatched \\{", /* REG_EBRACE */ "Invalid content of \\{\\}", /* REG_BADBR */ "Invalid range end", /* REG_ERANGE */ "Memory exhausted", /* REG_ESPACE */ "Invalid preceding regular expression", /* REG_BADRPT */ "Premature end of regular expression", /* REG_EEND */ "Regular expression too big", /* REG_ESIZE */ "Unmatched ) or \\)", /* REG_ERPAREN */ }; /* * Macros used while compiling patterns. * * By convention, PEND points just past the end of the uncompiled pattern, * P points to the read position in the pattern. `translate' is the name * of the translation table (`TRANSLATE' is the name of a macro that looks * things up in `translate'). */ /* * Fetch the next character in the uncompiled pattern---translating it * if necessary. *Also cast from a signed character in the constant * string passed to us by the user to an unsigned char that we can use * as an array index (in, e.g., `translate'). */ #define PATFETCH(c) \ do {if (p == pend) return REG_EEND; \ c = (unsigned char) *p++; \ c = translate[c]; \ } while (0) /* * Fetch the next character in the uncompiled pattern, with no * translation. */ #define PATFETCH_RAW(c) \ do {if (p == pend) return REG_EEND; \ c = (unsigned char) *p++; \ } while (0) /* Go backwards one character in the pattern. */ #define PATUNFETCH p-- #define TRANSLATE(d) translate[(unsigned char) (d)] typedef unsigned regnum_t; /* Since offsets can go either forwards or backwards, this type needs to * be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ typedef int pattern_offset_t; typedef struct { struct rexp_node ** top_expression; /* was begalt */ struct rexp_node ** last_expression; /* was laststart */ pattern_offset_t inner_group_offset; regnum_t regnum; } compile_stack_elt_t; typedef struct { compile_stack_elt_t *stack; unsigned size; unsigned avail; /* Offset of next open position. */ } compile_stack_type; #define INIT_COMPILE_STACK_SIZE 32 #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) /* The next available element. */ #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) /* Set the bit for character C in a list. */ #define SET_LIST_BIT(c) \ (b[((unsigned char) (c)) / BYTEWIDTH] \ |= 1 << (((unsigned char) c) % BYTEWIDTH)) /* Get the next unsigned number in the uncompiled pattern. */ #define GET_UNSIGNED_NUMBER(num) \ { if (p != pend) \ { \ PATFETCH (c); \ while (isdigit (c)) \ { \ if (num < 0) \ num = 0; \ num = num * 10 + c - '0'; \ if (p == pend) \ break; \ PATFETCH (c); \ } \ } \ } #define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ #define IS_CHAR_CLASS(string) \ (!strcmp (string, "alpha") || !strcmp (string, "upper") \ || !strcmp (string, "lower") || !strcmp (string, "digit") \ || !strcmp (string, "alnum") || !strcmp (string, "xdigit") \ || !strcmp (string, "space") || !strcmp (string, "print") \ || !strcmp (string, "punct") || !strcmp (string, "graph") \ || !strcmp (string, "cntrl") || !strcmp (string, "blank")) /* These predicates are used in regex_compile. */ /* P points to just after a ^ in PATTERN. Return true if that ^ comes * after an alternative or a begin-subexpression. We assume there is at * least one character before the ^. */ #ifdef __STDC__ static boolean at_begline_loc_p (const char *pattern, const char * p, reg_syntax_t syntax) #else static boolean at_begline_loc_p (pattern, p, syntax) const char *pattern; const char * p; reg_syntax_t syntax; #endif { const char *prev = p - 2; boolean prev_prev_backslash = ((prev > pattern) && (prev[-1] == '\\')); return (/* After a subexpression? */ ((*prev == '(') && ((syntax & RE_NO_BK_PARENS) || prev_prev_backslash)) || /* After an alternative? */ ((*prev == '|') && ((syntax & RE_NO_BK_VBAR) || prev_prev_backslash)) ); } /* The dual of at_begline_loc_p. This one is for $. We assume there is * at least one character after the $, i.e., `P < PEND'. */ #ifdef __STDC__ static boolean at_endline_loc_p (const char *p, const char *pend, int syntax) #else static boolean at_endline_loc_p (p, pend, syntax) const char *p; const char *pend; int syntax; #endif { const char *next = p; boolean next_backslash = (*next == '\\'); const char *next_next = (p + 1 < pend) ? (p + 1) : 0; return ( /* Before a subexpression? */ ((syntax & RE_NO_BK_PARENS) ? (*next == ')') : (next_backslash && next_next && (*next_next == ')'))) || /* Before an alternative? */ ((syntax & RE_NO_BK_VBAR) ? (*next == '|') : (next_backslash && next_next && (*next_next == '|'))) ); } static char id_translation[256] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 }; /* The compiler keeps an inverted translation table. * This looks up/inititalize elements. * VALID is an array of booleans that validate CACHE. */ #ifdef __STDC__ static rx_Bitset inverse_translation (struct re_pattern_buffer * rxb, char * valid, rx_Bitset cache, char * translate, int c) #else static rx_Bitset inverse_translation (rxb, valid, cache, translate, c) struct re_pattern_buffer * rxb; char * valid; rx_Bitset cache; char * translate; int c; #endif { rx_Bitset cs = cache + c * rx_bitset_numb_subsets (rxb->rx.local_cset_size); if (!valid[c]) { int x; int c_tr = TRANSLATE(c); rx_bitset_null (rxb->rx.local_cset_size, cs); for (x = 0; x < 256; ++x) /* &&&& 13.37 */ if (TRANSLATE(x) == c_tr) RX_bitset_enjoin (cs, x); valid[c] = 1; } return cs; } /* More subroutine declarations and macros for regex_compile. */ /* Returns true if REGNUM is in one of COMPILE_STACK's elements and false if it's not. */ #ifdef __STDC__ static boolean group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) #else static boolean group_in_compile_stack (compile_stack, regnum) compile_stack_type compile_stack; regnum_t regnum; #endif { int this_element; for (this_element = compile_stack.avail - 1; this_element >= 0; this_element--) if (compile_stack.stack[this_element].regnum == regnum) return true; return false; } /* * Read the ending character of a range (in a bracket expression) from the * uncompiled pattern *P_PTR (which ends at PEND). We assume the * starting character is in `P[-2]'. (`P[-1]' is the character `-'.) * Then we set the translation of all bits between the starting and * ending characters (inclusive) in the compiled pattern B. * * Return an error code. * * We use these short variable names so we can use the same macros as * `regex_compile' itself. */ #ifdef __STDC__ static reg_errcode_t compile_range (struct re_pattern_buffer * rxb, rx_Bitset cs, const char ** p_ptr, const char * pend, char * translate, reg_syntax_t syntax, rx_Bitset inv_tr, char * valid_inv_tr) #else static reg_errcode_t compile_range (rxb, cs, p_ptr, pend, translate, syntax, inv_tr, valid_inv_tr) struct re_pattern_buffer * rxb; rx_Bitset cs; const char ** p_ptr; const char * pend; char * translate; reg_syntax_t syntax; rx_Bitset inv_tr; char * valid_inv_tr; #endif { unsigned this_char; const char *p = *p_ptr; unsigned char range_end; unsigned char range_start = TRANSLATE(p[-2]); if (p == pend) return REG_ERANGE; PATFETCH (range_end); (*p_ptr)++; if (range_start > range_end) return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; for (this_char = range_start; this_char <= range_end; this_char++) { rx_Bitset it = inverse_translation (rxb, valid_inv_tr, inv_tr, translate, this_char); rx_bitset_union (rxb->rx.local_cset_size, cs, it); } return REG_NOERROR; } /* This searches a regexp for backreference side effects. * It fills in the array OUT with 1 at the index of every register pair * referenced by a backreference. * * This is used to help optimize patterns for searching. The information is * useful because, if the caller doesn't want register values, backreferenced * registers are the only registers for which we need rx_backtrack. */ #ifdef __STDC__ static void find_backrefs (char * out, struct rexp_node * rexp, struct re_se_params * params) #else static void find_backrefs (out, rexp, params) char * out; struct rexp_node * rexp; struct re_se_params * params; #endif { if (rexp) switch (rexp->type) { case r_cset: case r_data: return; case r_alternate: case r_concat: case r_opt: case r_star: case r_2phase_star: find_backrefs (out, rexp->params.pair.left, params); find_backrefs (out, rexp->params.pair.right, params); return; case r_side_effect: if ( ((int)rexp->params.side_effect >= 0) && (params [(int)rexp->params.side_effect].se == re_se_backref)) out[ params [(int)rexp->params.side_effect].op1] = 1; return; } } /* Returns 0 unless the pattern can match the empty string. */ #ifdef __STDC__ static int compute_fastset (struct re_pattern_buffer * rxb, struct rexp_node * rexp) #else static int compute_fastset (rxb, rexp) struct re_pattern_buffer * rxb; struct rexp_node * rexp; #endif { if (!rexp) return 1; switch (rexp->type) { case r_data: return 1; case r_cset: { rx_bitset_union (rxb->rx.local_cset_size, rxb->fastset, rexp->params.cset); } return 0; case r_concat: return (compute_fastset (rxb, rexp->params.pair.left) && compute_fastset (rxb, rexp->params.pair.right)); case r_2phase_star: compute_fastset (rxb, rexp->params.pair.left); /* compute_fastset (rxb, rexp->params.pair.right); nope... */ return 1; case r_alternate: return !!(compute_fastset (rxb, rexp->params.pair.left) + compute_fastset (rxb, rexp->params.pair.right)); case r_opt: case r_star: compute_fastset (rxb, rexp->params.pair.left); return 1; case r_side_effect: return 1; } } /* returns * 1 -- yes, definately anchored by the given side effect. * 2 -- maybe anchored, maybe the empty string. * 0 -- definately not anchored * There is simply no other possibility. */ #ifdef __STDC__ static int is_anchored (struct rexp_node * rexp, rx_side_effect se) #else static int is_anchored (rexp, se) struct rexp_node * rexp; rx_side_effect se; #endif { if (!rexp) return 2; switch (rexp->type) { case r_cset: case r_data: return 0; case r_concat: case r_2phase_star: { int l = is_anchored (rexp->params.pair.left, se); return (l == 2 ? is_anchored (rexp->params.pair.right, se) : l); } case r_alternate: { int l = is_anchored (rexp->params.pair.left, se); int r = l ? is_anchored (rexp->params.pair.right, se) : 0; return MAX (l, r); } case r_opt: case r_star: return is_anchored (rexp->params.pair.left, se) ? 2 : 0; case r_side_effect: return ((rexp->params.side_effect == se) ? 1 : 2); } } /* This removes register assignments that aren't required by backreferencing. * This can speed up explore_future, especially if it eliminates * non-determinism in the superstate NFA. * * NEEDED is an array of characters, presumably filled in by FIND_BACKREFS. * The non-zero elements of the array indicate which register assignments * can NOT be removed from the expression. */ #ifdef __STDC__ static struct rexp_node * remove_unecessary_side_effects (struct rx * rx, char * needed, struct rexp_node * rexp, struct re_se_params * params) #else static struct rexp_node * remove_unecessary_side_effects (rx, needed, rexp, params) struct rx * rx; char * needed; struct rexp_node * rexp; struct re_se_params * params; #endif { struct rexp_node * l; struct rexp_node * r; if (!rexp) return 0; else switch (rexp->type) { case r_cset: case r_data: return rexp; case r_alternate: case r_concat: case r_2phase_star: l = remove_unecessary_side_effects (rx, needed, rexp->params.pair.left, params); r = remove_unecessary_side_effects (rx, needed, rexp->params.pair.right, params); if ((l && r) || (rexp->type != r_concat)) { rexp->params.pair.left = l; rexp->params.pair.right = r; return rexp; } else { rexp->params.pair.left = rexp->params.pair.right = 0; rx_free_rexp (rx, rexp); return l ? l : r; } case r_opt: case r_star: l = remove_unecessary_side_effects (rx, needed, rexp->params.pair.left, params); if (l) { rexp->params.pair.left = l; return rexp; } else { rexp->params.pair.left = 0; rx_free_rexp (rx, rexp); return 0; } case r_side_effect: { int se = (int)rexp->params.side_effect; if ( (se >= 0) && ( ((enum re_side_effects)params[se].se == re_se_lparen) || ((enum re_side_effects)params[se].se == re_se_rparen)) && (params [se].op1 > 0) && (!needed [params [se].op1])) { rx_free_rexp (rx, rexp); return 0; } else return rexp; } } } #ifdef __STDC__ static int pointless_if_repeated (struct rexp_node * node, struct re_se_params * params) #else static int pointless_if_repeated (node, params) struct rexp_node * node; struct re_se_params * params; #endif { if (!node) return 1; switch (node->type) { case r_cset: return 0; case r_alternate: case r_concat: case r_2phase_star: return (pointless_if_repeated (node->params.pair.left, params) && pointless_if_repeated (node->params.pair.right, params)); case r_opt: case r_star: return pointless_if_repeated (node->params.pair.left, params); case r_side_effect: switch (((int)node->params.side_effect < 0) ? (enum re_side_effects)node->params.side_effect : (enum re_side_effects)params[(int)node->params.side_effect].se) { case re_se_try: case re_se_at_dot: case re_se_begbuf: case re_se_hat: case re_se_wordbeg: case re_se_wordbound: case re_se_notwordbound: case re_se_wordend: case re_se_endbuf: case re_se_dollar: case re_se_fail: case re_se_win: return 1; case re_se_lparen: case re_se_rparen: case re_se_iter: case re_se_end_iter: case re_se_syntax: case re_se_not_syntax: case re_se_backref: return 0; } case r_data: default: return 0; } } #ifdef __STDC__ static int registers_on_stack (struct re_pattern_buffer * rxb, struct rexp_node * rexp, int in_danger, struct re_se_params * params) #else static int registers_on_stack (rxb, rexp, in_danger, params) struct re_pattern_buffer * rxb; struct rexp_node * rexp; int in_danger; struct re_se_params * params; #endif { if (!rexp) return 0; else switch (rexp->type) { case r_cset: case r_data: return 0; case r_alternate: case r_concat: return ( registers_on_stack (rxb, rexp->params.pair.left, in_danger, params) || (registers_on_stack (rxb, rexp->params.pair.right, in_danger, params))); case r_opt: return registers_on_stack (rxb, rexp->params.pair.left, 0, params); case r_star: return registers_on_stack (rxb, rexp->params.pair.left, 1, params); case r_2phase_star: return ( registers_on_stack (rxb, rexp->params.pair.left, 1, params) || registers_on_stack (rxb, rexp->params.pair.right, 1, params)); case r_side_effect: { int se = (int)rexp->params.side_effect; if ( in_danger && (se >= 0) && (params [se].op1 > 0) && ( ((enum re_side_effects)params[se].se == re_se_lparen) || ((enum re_side_effects)params[se].se == re_se_rparen))) return 1; else return 0; } } } static char idempotent_complex_se[] = { #define RX_WANT_SE_DEFS 1 #undef RX_DEF_SE #undef RX_DEF_CPLX_SE #define RX_DEF_SE(IDEM, NAME, VALUE) #define RX_DEF_CPLX_SE(IDEM, NAME, VALUE) IDEM, #include "rx.h" #undef RX_DEF_SE #undef RX_DEF_CPLX_SE #undef RX_WANT_SE_DEFS 23 }; static char idempotent_se[] = { 13, #define RX_WANT_SE_DEFS 1 #undef RX_DEF_SE #undef RX_DEF_CPLX_SE #define RX_DEF_SE(IDEM, NAME, VALUE) IDEM, #define RX_DEF_CPLX_SE(IDEM, NAME, VALUE) #include "rx.h" #undef RX_DEF_SE #undef RX_DEF_CPLX_SE #undef RX_WANT_SE_DEFS 42 }; #ifdef __STDC__ static int has_any_se (struct rx * rx, struct rexp_node * rexp) #else static int has_any_se (rx, rexp) struct rx * rx; struct rexp_node * rexp; #endif { if (!rexp) return 0; switch (rexp->type) { case r_cset: case r_data: return 0; case r_side_effect: return 1; case r_2phase_star: case r_concat: case r_alternate: return ( has_any_se (rx, rexp->params.pair.left) || has_any_se (rx, rexp->params.pair.right)); case r_opt: case r_star: return has_any_se (rx, rexp->params.pair.left); } } /* This must be called AFTER `convert_hard_loops' for a given REXP. */ #ifdef __STDC__ static int has_non_idempotent_epsilon_path (struct rx * rx, struct rexp_node * rexp, struct re_se_params * params) #else static int has_non_idempotent_epsilon_path (rx, rexp, params) struct rx * rx; struct rexp_node * rexp; struct re_se_params * params; #endif { if (!rexp) return 0; switch (rexp->type) { case r_cset: case r_data: case r_star: return 0; case r_side_effect: return !((int)rexp->params.side_effect > 0 ? idempotent_complex_se [ params [(int)rexp->params.side_effect].se ] : idempotent_se [-(int)rexp->params.side_effect]); case r_alternate: return ( has_non_idempotent_epsilon_path (rx, rexp->params.pair.left, params) || has_non_idempotent_epsilon_path (rx, rexp->params.pair.right, params)); case r_2phase_star: case r_concat: return ( has_non_idempotent_epsilon_path (rx, rexp->params.pair.left, params) && has_non_idempotent_epsilon_path (rx, rexp->params.pair.right, params)); case r_opt: return has_non_idempotent_epsilon_path (rx, rexp->params.pair.left, params); } } /* This computes rougly what it's name suggests. It can (and does) go wrong * in the direction of returning spurious 0 without causing disasters. */ #ifdef __STDC__ static int begins_with_complex_se (struct rx * rx, struct rexp_node * rexp) #else static int begins_with_complex_se (rx, rexp) struct rx * rx; struct rexp_node * rexp; #endif { if (!rexp) return 0; switch (rexp->type) { case r_cset: case r_data: return 0; case r_side_effect: return ((int)rexp->params.side_effect >= 0); case r_alternate: return ( begins_with_complex_se (rx, rexp->params.pair.left) && begins_with_complex_se (rx, rexp->params.pair.right)); case r_concat: return has_any_se (rx, rexp->params.pair.left); case r_opt: case r_star: case r_2phase_star: return 0; } } /* This destructively removes some of the re_se_tv side effects from * a rexp tree. In particular, during parsing re_se_tv was inserted on the * right half of every | to guarantee that posix path preference could be * honored. This function removes some which it can be determined aren't * needed. */ #ifdef __STDC__ static void speed_up_alt (struct rx * rx, struct rexp_node * rexp, int unposix) #else static void speed_up_alt (rx, rexp, unposix) struct rx * rx; struct rexp_node * rexp; int unposix; #endif { if (!rexp) return; switch (rexp->type) { case r_cset: case r_data: case r_side_effect: return; case r_opt: case r_star: speed_up_alt (rx, rexp->params.pair.left, unposix); return; case r_2phase_star: case r_concat: speed_up_alt (rx, rexp->params.pair.left, unposix); speed_up_alt (rx, rexp->params.pair.right, unposix); return; case r_alternate: /* the right child is guaranteed to be (concat re_se_tv ) */ speed_up_alt (rx, rexp->params.pair.left, unposix); speed_up_alt (rx, rexp->params.pair.right->params.pair.right, unposix); if ( unposix || (begins_with_complex_se (rx, rexp->params.pair.right->params.pair.right)) || !( has_any_se (rx, rexp->params.pair.right->params.pair.right) || has_any_se (rx, rexp->params.pair.left))) { struct rexp_node * conc = rexp->params.pair.right; rexp->params.pair.right = conc->params.pair.right; conc->params.pair.right = 0; rx_free_rexp (rx, conc); } } } /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. Returns one of error codes defined in `regex.h', or zero for success. Assumes the `allocated' (and perhaps `buffer') and `translate' fields are set in BUFP on entry. If it succeeds, results are put in BUFP (if it returns an error, the contents of BUFP are undefined): `buffer' is the compiled pattern; `syntax' is set to SYNTAX; `used' is set to the length of the compiled pattern; `fastmap_accurate' is set to zero; `re_nsub' is set to the number of groups in PATTERN; `not_bol' and `not_eol' are set to zero. The `fastmap' and `newline_anchor' fields are neither examined nor set. */ #ifdef __STDC__ reg_errcode_t rx_compile (const char *pattern, int size, reg_syntax_t syntax, struct re_pattern_buffer * rxb) #else reg_errcode_t rx_compile (pattern, size, syntax, rxb) const char *pattern; int size; reg_syntax_t syntax; struct re_pattern_buffer * rxb; #endif { RX_subset inverse_translate [CHAR_SET_SIZE * rx_bitset_numb_subsets(CHAR_SET_SIZE)]; char validate_inv_tr [CHAR_SET_SIZE * rx_bitset_numb_subsets(CHAR_SET_SIZE)]; /* We fetch characters from PATTERN here. Even though PATTERN is `char *' (i.e., signed), we declare these variables as unsigned, so they can be reliably used as array indices. */ register unsigned char c, c1; /* A random tempory spot in PATTERN. */ const char *p1; /* Keeps track of unclosed groups. */ compile_stack_type compile_stack; /* Points to the current (ending) position in the pattern. */ const char *p = pattern; const char *pend = pattern + size; /* How to translate the characters in the pattern. */ char *translate = rxb->translate ? rxb->translate : id_translation; /* When parsing is done, this will hold the expression tree. */ struct rexp_node * rexp = 0; /* In the midst of compilation, this holds onto the regexp * first parst while rexp goes on to aquire additional constructs. */ struct rexp_node * orig_rexp = 0; struct rexp_node * fewer_side_effects = 0; /* This and top_expression are saved on the compile stack. */ struct rexp_node ** top_expression = &rexp; struct rexp_node ** last_expression = top_expression; /* Parameter to `goto append_node' */ struct rexp_node * append; /* Counts open-groups as they are encountered. This is the index of the * innermost group being compiled. */ regnum_t regnum = 0; /* Place in the uncompiled pattern (i.e., the {) to * which to go back if the interval is invalid. */ const char *beg_interval; struct re_se_params * params = 0; int paramc = 0; /* How many complex side effects so far? */ rx_side_effect side; /* param to `goto add_side_effect' */ bzero (validate_inv_tr, sizeof (validate_inv_tr)); rxb->rx.instruction_table = rx_id_instruction_table; /* Initialize the compile stack. */ compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); if (compile_stack.stack == 0) return REG_ESPACE; compile_stack.size = INIT_COMPILE_STACK_SIZE; compile_stack.avail = 0; /* Initialize the pattern buffer. */ rxb->rx.cache = &default_cache; rxb->syntax = syntax; rxb->fastmap_accurate = 0; rxb->not_bol = rxb->not_eol = 0; rxb->least_subs = 0; /* Always count groups, whether or not rxb->no_sub is set. * The whole pattern is implicitly group 0, so counting begins * with 1. */ rxb->re_nsub = 0; #if !defined (emacs) && !defined (SYNTAX_TABLE) /* Initialize the syntax table. */ init_syntax_once (); #endif /* Loop through the uncompiled pattern until we're at the end. */ while (p != pend) { PATFETCH (c); switch (c) { case '^': { if ( /* If at start of pattern, it's an operator. */ p == pattern + 1 /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS /* Otherwise, depends on what's come before. */ || at_begline_loc_p (pattern, p, syntax)) { struct rexp_node * n = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_hat); if (!n) return REG_ESPACE; append = n; goto append_node; } else goto normal_char; } break; case '$': { if ( /* If at end of pattern, it's an operator. */ p == pend /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS /* Otherwise, depends on what's next. */ || at_endline_loc_p (p, pend, syntax)) { struct rexp_node * n = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_dollar); if (!n) return REG_ESPACE; append = n; goto append_node; } else goto normal_char; } break; case '+': case '?': if ((syntax & RE_BK_PLUS_QM) || (syntax & RE_LIMITED_OPS)) goto normal_char; handle_plus: case '*': /* If there is no previous pattern... */ if (pointless_if_repeated (*last_expression, params)) { if (syntax & RE_CONTEXT_INVALID_OPS) return REG_BADRPT; else if (!(syntax & RE_CONTEXT_INDEP_OPS)) goto normal_char; } { /* 1 means zero (many) matches is allowed. */ char zero_times_ok = 0, many_times_ok = 0; /* If there is a sequence of repetition chars, collapse it down to just one (the right one). We can't combine interval operators with these because of, e.g., `a{2}*', which should only match an even number of `a's. */ for (;;) { zero_times_ok |= c != '+'; many_times_ok |= c != '?'; if (p == pend) break; PATFETCH (c); if (c == '*' || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?'))) ; else if (syntax & RE_BK_PLUS_QM && c == '\\') { if (p == pend) return REG_EESCAPE; PATFETCH (c1); if (!(c1 == '+' || c1 == '?')) { PATUNFETCH; PATUNFETCH; break; } c = c1; } else { PATUNFETCH; break; } /* If we get here, we found another repeat character. */ } /* Star, etc. applied to an empty pattern is equivalent to an empty pattern. */ if (!last_expression) break; /* Now we know whether or not zero matches is allowed * and also whether or not two or more matches is allowed. */ { struct rexp_node * inner_exp = *last_expression; int need_sync = 0; if (many_times_ok && has_non_idempotent_epsilon_path (&rxb->rx, inner_exp, params)) { struct rexp_node * pusher = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_pushpos); struct rexp_node * checker = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_chkpos); struct rexp_node * pushback = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_pushback); rx_Bitset cs = rx_cset (&rxb->rx); struct rexp_node * lit_t = rx_mk_r_cset (&rxb->rx, cs); struct rexp_node * fake_state = rx_mk_r_concat (&rxb->rx, pushback, lit_t); struct rexp_node * phase2 = rx_mk_r_concat (&rxb->rx, checker, fake_state); struct rexp_node * popper = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_poppos); struct rexp_node * star = rx_mk_r_2phase_star (&rxb->rx, inner_exp, phase2); struct rexp_node * a = rx_mk_r_concat (&rxb->rx, pusher, star); struct rexp_node * whole_thing = rx_mk_r_concat (&rxb->rx, a, popper); if (!(pusher && star && pushback && lit_t && fake_state && lit_t && phase2 && checker && popper && a && whole_thing)) return REG_ESPACE; RX_bitset_enjoin (cs, 't'); *last_expression = whole_thing; } else { struct rexp_node * star = (many_times_ok ? rx_mk_r_star : rx_mk_r_opt) (&rxb->rx, *last_expression); if (!star) return REG_ESPACE; *last_expression = star; need_sync = has_any_se (&rxb->rx, *last_expression); } if (!zero_times_ok) { struct rexp_node * concat = rx_mk_r_concat (&rxb->rx, inner_exp, rx_copy_rexp (&rxb->rx, *last_expression)); if (!concat) return REG_ESPACE; *last_expression = concat; } if (need_sync) { int sync_se = paramc; params = (params ? ((struct re_se_params *) realloc (params, sizeof (*params) * (1 + paramc))) : ((struct re_se_params *) malloc (sizeof (*params)))); if (!params) return REG_ESPACE; ++paramc; params [sync_se].se = re_se_tv; side = (rx_side_effect)sync_se; goto add_side_effect; } } /* The old regex.c used to optimize `.*\n'. * Maybe rx should too? */ } break; case '.': { rx_Bitset cs = rx_cset (&rxb->rx); struct rexp_node * n = rx_mk_r_cset (&rxb->rx, cs); if (!(cs && n)) return REG_ESPACE; rx_bitset_universe (rxb->rx.local_cset_size, cs); if (!(rxb->syntax & RE_DOT_NEWLINE)) RX_bitset_remove (cs, '\n'); if (!(rxb->syntax & RE_DOT_NOT_NULL)) RX_bitset_remove (cs, 0); append = n; goto append_node; break; } case '[': if (p == pend) return REG_EBRACK; { boolean had_char_class = false; rx_Bitset cs = rx_cset (&rxb->rx); struct rexp_node * node = rx_mk_r_cset (&rxb->rx, cs); int is_inverted = *p == '^'; if (!(node && cs)) return REG_ESPACE; /* This branch of the switch is normally exited with *`goto append_node' */ append = node; if (is_inverted) p++; /* Remember the first position in the bracket expression. */ p1 = p; /* Read in characters and ranges, setting map bits. */ for (;;) { if (p == pend) return REG_EBRACK; PATFETCH (c); /* \ might escape characters inside [...] and [^...]. */ if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') { if (p == pend) return REG_EESCAPE; PATFETCH (c1); { rx_Bitset it = inverse_translation (rxb, validate_inv_tr, inverse_translate, translate, c1); rx_bitset_union (rxb->rx.local_cset_size, cs, it); } continue; } /* Could be the end of the bracket expression. If it's not (i.e., when the bracket expression is `[]' so far), the ']' character bit gets set way below. */ if (c == ']' && p != p1 + 1) goto finalize_class_and_append; /* Look ahead to see if it's a range when the last thing was a character class. */ if (had_char_class && c == '-' && *p != ']') return REG_ERANGE; /* Look ahead to see if it's a range when the last thing was a character: if this is a hyphen not at the beginning or the end of a list, then it's the range operator. */ if (c == '-' && !(p - 2 >= pattern && p[-2] == '[') && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') && *p != ']') { reg_errcode_t ret = compile_range (rxb, cs, &p, pend, translate, syntax, inverse_translate, validate_inv_tr); if (ret != REG_NOERROR) return ret; } else if (p[0] == '-' && p[1] != ']') { /* This handles ranges made up of characters only. */ reg_errcode_t ret; /* Move past the `-'. */ PATFETCH (c1); ret = compile_range (rxb, cs, &p, pend, translate, syntax, inverse_translate, validate_inv_tr); if (ret != REG_NOERROR) return ret; } /* See if we're at the beginning of a possible character class. */ else if ((syntax & RE_CHAR_CLASSES) && (c == '[') && (*p == ':')) { char str[CHAR_CLASS_MAX_LENGTH + 1]; PATFETCH (c); c1 = 0; /* If pattern is `[[:'. */ if (p == pend) return REG_EBRACK; for (;;) { PATFETCH (c); if (c == ':' || c == ']' || p == pend || c1 == CHAR_CLASS_MAX_LENGTH) break; str[c1++] = c; } str[c1] = '\0'; /* If isn't a word bracketed by `[:' and:`]': undo the ending character, the letters, and leave the leading `:' and `[' (but set bits for them). */ if (c == ':' && *p == ']') { int ch; boolean is_alnum = !strcmp (str, "alnum"); boolean is_alpha = !strcmp (str, "alpha"); boolean is_blank = !strcmp (str, "blank"); boolean is_cntrl = !strcmp (str, "cntrl"); boolean is_digit = !strcmp (str, "digit"); boolean is_graph = !strcmp (str, "graph"); boolean is_lower = !strcmp (str, "lower"); boolean is_print = !strcmp (str, "print"); boolean is_punct = !strcmp (str, "punct"); boolean is_space = !strcmp (str, "space"); boolean is_upper = !strcmp (str, "upper"); boolean is_xdigit = !strcmp (str, "xdigit"); if (!IS_CHAR_CLASS (str)) return REG_ECTYPE; /* Throw away the ] at the end of the character class. */ PATFETCH (c); if (p == pend) return REG_EBRACK; for (ch = 0; ch < 1 << BYTEWIDTH; ch++) { if ( (is_alnum && isalnum (ch)) || (is_alpha && isalpha (ch)) || (is_blank && isblank (ch)) || (is_cntrl && iscntrl (ch)) || (is_digit && isdigit (ch)) || (is_graph && isgraph (ch)) || (is_lower && islower (ch)) || (is_print && isprint (ch)) || (is_punct && ispunct (ch)) || (is_space && isspace (ch)) || (is_upper && isupper (ch)) || (is_xdigit && isxdigit (ch))) { rx_Bitset it = inverse_translation (rxb, validate_inv_tr, inverse_translate, translate, ch); rx_bitset_union (rxb->rx.local_cset_size, cs, it); } } had_char_class = true; } else { c1++; while (c1--) PATUNFETCH; { rx_Bitset it = inverse_translation (rxb, validate_inv_tr, inverse_translate, translate, '['); rx_bitset_union (rxb->rx.local_cset_size, cs, it); } { rx_Bitset it = inverse_translation (rxb, validate_inv_tr, inverse_translate, translate, ':'); rx_bitset_union (rxb->rx.local_cset_size, cs, it); } had_char_class = false; } } else { had_char_class = false; { rx_Bitset it = inverse_translation (rxb, validate_inv_tr, inverse_translate, translate, c); rx_bitset_union (rxb->rx.local_cset_size, cs, it); } } } finalize_class_and_append: if (is_inverted) { rx_bitset_complement (rxb->rx.local_cset_size, cs); if (syntax & RE_HAT_LISTS_NOT_NEWLINE) RX_bitset_remove (cs, '\n'); } goto append_node; } break; case '(': if (syntax & RE_NO_BK_PARENS) goto handle_open; else goto normal_char; case ')': if (syntax & RE_NO_BK_PARENS) goto handle_close; else goto normal_char; case '\n': if (syntax & RE_NEWLINE_ALT) goto handle_alt; else goto normal_char; case '|': if (syntax & RE_NO_BK_VBAR) goto handle_alt; else goto normal_char; case '{': if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) goto handle_interval; else goto normal_char; case '\\': if (p == pend) return REG_EESCAPE; /* Do not translate the character after the \, so that we can distinguish, e.g., \B from \b, even if we normally would translate, e.g., B to b. */ PATFETCH_RAW (c); switch (c) { case '(': if (syntax & RE_NO_BK_PARENS) goto normal_backslash; handle_open: rxb->re_nsub++; regnum++; if (COMPILE_STACK_FULL) { RETALLOC (compile_stack.stack, compile_stack.size << 1, compile_stack_elt_t); if (compile_stack.stack == 0) return REG_ESPACE; compile_stack.size <<= 1; } if (*last_expression) { struct rexp_node * concat = rx_mk_r_concat (&rxb->rx, *last_expression, 0); if (!concat) return REG_ESPACE; *last_expression = concat; last_expression = &concat->params.pair.right; } /* * These are the values to restore when we hit end of this * group. */ COMPILE_STACK_TOP.top_expression = top_expression; COMPILE_STACK_TOP.last_expression = last_expression; COMPILE_STACK_TOP.regnum = regnum; compile_stack.avail++; top_expression = last_expression; break; case ')': if (syntax & RE_NO_BK_PARENS) goto normal_backslash; handle_close: /* See similar code for backslashed left paren above. */ if (COMPILE_STACK_EMPTY) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_char; else return REG_ERPAREN; /* Since we just checked for an empty stack above, this ``can't happen''. */ { /* We don't just want to restore into `regnum', because later groups should continue to be numbered higher, as in `(ab)c(de)' -- the second group is #2. */ regnum_t this_group_regnum; struct rexp_node ** inner = top_expression; compile_stack.avail--; top_expression = COMPILE_STACK_TOP.top_expression; last_expression = COMPILE_STACK_TOP.last_expression; this_group_regnum = COMPILE_STACK_TOP.regnum; { int left_se = paramc; int right_se = paramc + 1; params = (params ? ((struct re_se_params *) realloc (params, (paramc + 2) * sizeof (params[0]))) : ((struct re_se_params *) malloc (2 * sizeof (params[0])))); if (!params) return REG_ESPACE; paramc += 2; params[left_se].se = re_se_lparen; params[left_se].op1 = this_group_regnum; params[right_se].se = re_se_rparen; params[right_se].op1 = this_group_regnum; { struct rexp_node * left = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)left_se); struct rexp_node * right = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)right_se); struct rexp_node * c1 = (*inner ? rx_mk_r_concat (&rxb->rx, left, *inner) : left); struct rexp_node * c2 = rx_mk_r_concat (&rxb->rx, c1, right); if (!(left && right && c1 && c2)) return REG_ESPACE; *inner = c2; } } break; } case '|': /* `\|'. */ if ((syntax & RE_LIMITED_OPS) || (syntax & RE_NO_BK_VBAR)) goto normal_backslash; handle_alt: if (syntax & RE_LIMITED_OPS) goto normal_char; { struct rexp_node * alt = rx_mk_r_alternate (&rxb->rx, *top_expression, 0); if (!alt) return REG_ESPACE; *top_expression = alt; last_expression = &alt->params.pair.right; { int sync_se = paramc; params = (params ? ((struct re_se_params *) realloc (params, (paramc + 1) * sizeof (params[0]))) : ((struct re_se_params *) malloc (sizeof (params[0])))); if (!params) return REG_ESPACE; ++paramc; params[sync_se].se = re_se_tv; { struct rexp_node * sync = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)sync_se); struct rexp_node * conc = rx_mk_r_concat (&rxb->rx, sync, 0); if (!sync || !conc) return REG_ESPACE; *last_expression = conc; last_expression = &conc->params.pair.right; } } } break; case '{': /* If \{ is a literal. */ if (!(syntax & RE_INTERVALS) /* If we're at `\{' and it's not the open-interval operator. */ || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) || (p - 2 == pattern && p == pend)) goto normal_backslash; handle_interval: { /* If got here, then the syntax allows intervals. */ /* At least (most) this many matches must be made. */ int lower_bound = -1, upper_bound = -1; beg_interval = p - 1; if (p == pend) { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_EBRACE; } GET_UNSIGNED_NUMBER (lower_bound); if (c == ',') { GET_UNSIGNED_NUMBER (upper_bound); if (upper_bound < 0) upper_bound = RE_DUP_MAX; } else /* Interval such as `{1}' => match exactly once. */ upper_bound = lower_bound; if (lower_bound < 0 || upper_bound > RE_DUP_MAX || lower_bound > upper_bound) { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_BADBR; } if (!(syntax & RE_NO_BK_BRACES)) { if (c != '\\') return REG_EBRACE; PATFETCH (c); } if (c != '}') { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_BADBR; } /* We just parsed a valid interval. */ /* If it's invalid to have no preceding re. */ if (pointless_if_repeated (*last_expression, params)) { if (syntax & RE_CONTEXT_INVALID_OPS) return REG_BADRPT; else if (!(syntax & RE_CONTEXT_INDEP_OPS)) goto unfetch_interval; /* was: else laststart = b; */ } /* If the upper bound is zero, don't want to iterate * at all. */ if (upper_bound == 0) { if (*last_expression) { rx_free_rexp (&rxb->rx, *last_expression); *last_expression = 0; } } else /* Otherwise, we have a nontrivial interval. */ { int iter_se = paramc; int end_se = paramc + 1; params = (params ? ((struct re_se_params *) realloc (params, sizeof (*params) * (2 + paramc))) : ((struct re_se_params *) malloc (2 * sizeof (*params)))); if (!params) return REG_ESPACE; paramc += 2; params [iter_se].se = re_se_iter; params [iter_se].op1 = lower_bound; params[iter_se].op2 = upper_bound; params[end_se].se = re_se_end_iter; params[end_se].op1 = lower_bound; params[end_se].op2 = upper_bound; { struct rexp_node * push0 = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_push0); struct rexp_node * start_one_iter = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)iter_se); struct rexp_node * phase1 = rx_mk_r_concat (&rxb->rx, start_one_iter, *last_expression); struct rexp_node * pushback = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)re_se_pushback); rx_Bitset cs = rx_cset (&rxb->rx); struct rexp_node * lit_t = rx_mk_r_cset (&rxb->rx, cs); struct rexp_node * phase2 = rx_mk_r_concat (&rxb->rx, pushback, lit_t); struct rexp_node * loop = rx_mk_r_2phase_star (&rxb->rx, phase1, phase2); struct rexp_node * push_n_loop = rx_mk_r_concat (&rxb->rx, push0, loop); struct rexp_node * final_test = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)end_se); struct rexp_node * full_exp = rx_mk_r_concat (&rxb->rx, push_n_loop, final_test); if (!(push0 && start_one_iter && phase1 && pushback && lit_t && phase2 && loop && push_n_loop && final_test && full_exp)) return REG_ESPACE; RX_bitset_enjoin(cs, 't'); *last_expression = full_exp; } } beg_interval = 0; } break; unfetch_interval: /* If an invalid interval, match the characters as literals. */ p = beg_interval; beg_interval = NULL; /* normal_char and normal_backslash need `c'. */ PATFETCH (c); if (!(syntax & RE_NO_BK_BRACES)) { if (p > pattern && p[-1] == '\\') goto normal_backslash; } goto normal_char; #ifdef emacs /* There is no way to specify the before_dot and after_dot operators. rms says this is ok. --karl */ case '=': side = at_dot; goto add_side_effect; break; case 's': case 'S': { rx_Bitset cs = cset (&rxb->rx); struct rexp_node * set = rx_mk_r_cset (&rxb->rx, cs); if (!(cs && set)) return REG_ESPACE; if (c == 'S') rx_bitset_universe (rxb->rx.local_cset_size, cs); PATFETCH (c); { int x; char code = syntax_spec_code (c); for (x = 0; x < 256; ++x) { if (SYNTAX (x) & code) { rx_Bitset it = inverse_translation (rxb, validate_inv_tr, inverse_translate, translate, x); rx_bitset_xor (rxb->rx.local_cset_size, cs, it); } } } goto append_node; } break; #endif /* emacs */ case 'w': case 'W': { rx_Bitset cs = rx_cset (&rxb->rx); struct rexp_node * n = (cs ? rx_mk_r_cset (&rxb->rx, cs) : 0); if (!(cs && n)) return REG_ESPACE; if (c == 'W') rx_bitset_universe (rxb->rx.local_cset_size ,cs); { int x; for (x = rxb->rx.local_cset_size - 1; x > 0; --x) if (re_syntax_table[x] & Sword) RX_bitset_toggle (cs, x); } append = n; goto append_node; } break; /* With a little extra work, some of these side effects could be optimized * away (basicly by looking at what we already know about the surrounding * chars). */ case '<': side = (rx_side_effect)re_se_wordbeg; goto add_side_effect; break; case '>': side = (rx_side_effect)re_se_wordend; goto add_side_effect; break; case 'b': side = (rx_side_effect)re_se_wordbound; goto add_side_effect; break; case 'B': side = (rx_side_effect)re_se_notwordbound; goto add_side_effect; break; case '`': side = (rx_side_effect)re_se_begbuf; goto add_side_effect; break; case '\'': side = (rx_side_effect)re_se_endbuf; goto add_side_effect; break; add_side_effect: { struct rexp_node * se = rx_mk_r_side_effect (&rxb->rx, side); if (!se) return REG_ESPACE; append = se; goto append_node; } break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (syntax & RE_NO_BK_REFS) goto normal_char; c1 = c - '0'; if (c1 > regnum) return REG_ESUBREG; /* Can't back reference to a subexpression if inside of it. */ if (group_in_compile_stack (compile_stack, c1)) goto normal_char; { int backref_se = paramc; params = (params ? ((struct re_se_params *) realloc (params, sizeof (*params) * (1 + paramc))) : ((struct re_se_params *) malloc (sizeof (*params)))); if (!params) return REG_ESPACE; ++paramc; params[backref_se].se = re_se_backref; params[backref_se].op1 = c1; side = (rx_side_effect)backref_se; goto add_side_effect; } break; case '+': case '?': if (syntax & RE_BK_PLUS_QM) goto handle_plus; else goto normal_backslash; default: normal_backslash: /* You might think it would be useful for \ to mean not to translate; but if we don't translate it it will never match anything. */ c = TRANSLATE (c); goto normal_char; } break; default: /* Expects the character in `c'. */ normal_char: { rx_Bitset cs = rx_cset(&rxb->rx); struct rexp_node * match = rx_mk_r_cset (&rxb->rx, cs); rx_Bitset it; if (!(cs && match)) return REG_ESPACE; it = inverse_translation (rxb, validate_inv_tr, inverse_translate, translate, c); rx_bitset_union (CHAR_SET_SIZE, cs, it); append = match; append_node: /* This genericly appends the rexp APPEND to *LAST_EXPRESSION * and then parses the next character normally. */ if (*last_expression) { struct rexp_node * concat = rx_mk_r_concat (&rxb->rx, *last_expression, append); if (!concat) return REG_ESPACE; *last_expression = concat; last_expression = &concat->params.pair.right; } else *last_expression = append; } } /* switch (c) */ } /* while p != pend */ { int win_se = paramc; params = (params ? ((struct re_se_params *) realloc (params, sizeof (*params) * (1 + paramc))) : ((struct re_se_params *) malloc (sizeof (*params)))); if (!params) return REG_ESPACE; ++paramc; params[win_se].se = re_se_win; { struct rexp_node * se = rx_mk_r_side_effect (&rxb->rx, (rx_side_effect)win_se); struct rexp_node * concat = rx_mk_r_concat (&rxb->rx, rexp, se); if (!(se && concat)) return REG_ESPACE; rexp = concat; } } /* Through the pattern now. */ if (!COMPILE_STACK_EMPTY) return REG_EPAREN; free (compile_stack.stack); orig_rexp = rexp; #ifdef RX_DEBUG if (rx_debug_compile) { dbug_rxb = rxb; fputs ("\n\nCompiling ", stdout); fwrite (pattern, 1, size, stdout); fputs (":\n", stdout); rxb->se_params = params; print_rexp (&rxb->rx, orig_rexp, 2, re_seprint, stdout); } #endif { rx_Bitset cs = rx_cset(&rxb->rx); rx_Bitset cs2 = rx_cset(&rxb->rx); char * se_map = (char *) alloca (paramc); struct rexp_node * new_rexp = 0; bzero (se_map, paramc); find_backrefs (se_map, rexp, params); fewer_side_effects = remove_unecessary_side_effects (&rxb->rx, se_map, rx_copy_rexp (&rxb->rx, rexp), params); speed_up_alt (&rxb->rx, rexp, 0); speed_up_alt (&rxb->rx, fewer_side_effects, 1); { char * syntax_parens = rxb->syntax_parens; if (syntax_parens == (char *)0x1) rexp = remove_unecessary_side_effects (&rxb->rx, se_map, rexp, params); else if (syntax_parens) { int x; for (x = 0; x < paramc; ++x) if (( (params[x].se == re_se_lparen) || (params[x].se == re_se_rparen)) && (!syntax_parens [params[x].op1])) se_map [x] = 1; rexp = remove_unecessary_side_effects (&rxb->rx, se_map, rexp, params); } } /* At least one more optimization would be nice to have here but i ran out * of time. The idea would be to delay side effects. * For examle, `(abc)' is the same thing as `abc()' except that the * left paren is offset by 3 (which we know at compile time). * (In this comment, write that second pattern `abc(:3:)' * where `(:3:' is a syntactic unit.) * * Trickier: `(abc|defg)' is the same as `(abc(:3:|defg(:4:))' * (The paren nesting may be hard to follow -- that's an alternation * of `abc(:3:' and `defg(:4:' inside (purely syntactic) parens * followed by the closing paren from the original expression.) * * Neither the expression tree representation nor the the nfa make * this very easy to write. :( */ /* What we compile is different than what the parser returns. * Suppose the parser returns expression R. * Let R' be R with unnecessary register assignments removed * (see REMOVE_UNECESSARY_SIDE_EFFECTS, above). * * What we will compile is the expression: * * m{try}R{win}\|s{try}R'{win} * * {try} and {win} denote side effect epsilons (see EXPLORE_FUTURE). * * When trying a match, we insert an `m' at the beginning of the * string if the user wants registers to be filled, `s' if not. */ new_rexp = rx_mk_r_alternate (&rxb->rx, rx_mk_r_concat (&rxb->rx, rx_mk_r_cset (&rxb->rx, cs2), rexp), rx_mk_r_concat (&rxb->rx, rx_mk_r_cset (&rxb->rx, cs), fewer_side_effects)); if (!(new_rexp && cs && cs2)) return REG_ESPACE; RX_bitset_enjoin (cs2, '\0'); /* prefixed to the rexp used for matching. */ RX_bitset_enjoin (cs, '\1'); /* prefixed to the rexp used for searching. */ rexp = new_rexp; } #ifdef RX_DEBUG if (rx_debug_compile) { fputs ("\n...which is compiled as:\n", stdout); print_rexp (&rxb->rx, rexp, 2, re_seprint, stdout); } #endif { struct rx_nfa_state *start = 0; struct rx_nfa_state *end = 0; if (!rx_build_nfa (&rxb->rx, rexp, &start, &end)) return REG_ESPACE; /* */ else { void * mem = (void *)rxb->buffer; unsigned long size = rxb->allocated; int start_id; char * perm_mem; int iterator_size = paramc * sizeof (params[0]); end->is_final = 1; start->is_start = 1; rx_name_nfa_states (&rxb->rx); start_id = start->id; #ifdef RX_DEBUG if (rx_debug_compile) { fputs ("...giving the NFA: \n", stdout); dbug_rxb = rxb; print_nfa (&rxb->rx, rxb->rx.nfa_states, re_seprint, stdout); } #endif if (!rx_eclose_nfa (&rxb->rx)) return REG_ESPACE; else { rx_delete_epsilon_transitions (&rxb->rx); /* For compatability reasons, we need to shove the * compiled nfa into one chunk of malloced memory. */ rxb->rx.reserved = ( sizeof (params[0]) * paramc + rx_sizeof_bitset (rxb->rx.local_cset_size)); #ifdef RX_DEBUG if (rx_debug_compile) { dbug_rxb = rxb; fputs ("...which cooks down (uncompactified) to: \n", stdout); print_nfa (&rxb->rx, rxb->rx.nfa_states, re_seprint, stdout); } #endif if (!rx_compactify_nfa (&rxb->rx, &mem, &size)) return REG_ESPACE; rxb->buffer = mem; rxb->allocated = size; rxb->rx.buffer = mem; rxb->rx.allocated = size; perm_mem = ((char *)rxb->rx.buffer + rxb->rx.allocated - rxb->rx.reserved); rxb->se_params = ((struct re_se_params *)perm_mem); bcopy (params, rxb->se_params, iterator_size); perm_mem += iterator_size; rxb->fastset = (rx_Bitset) perm_mem; rxb->start = rx_id_to_nfa_state (&rxb->rx, start_id); } rx_bitset_null (rxb->rx.local_cset_size, rxb->fastset); rxb->can_match_empty = compute_fastset (rxb, orig_rexp); rxb->match_regs_on_stack = registers_on_stack (rxb, orig_rexp, 0, params); rxb->search_regs_on_stack = registers_on_stack (rxb, fewer_side_effects, 0, params); if (rxb->can_match_empty) rx_bitset_universe (rxb->rx.local_cset_size, rxb->fastset); rxb->is_anchored = is_anchored (orig_rexp, (rx_side_effect) re_se_hat); rxb->begbuf_only = is_anchored (orig_rexp, (rx_side_effect) re_se_begbuf); } rx_free_rexp (&rxb->rx, rexp); if (params) free (params); #ifdef RX_DEBUG if (rx_debug_compile) { dbug_rxb = rxb; fputs ("...which cooks down to: \n", stdout); print_nfa (&rxb->rx, rxb->rx.nfa_states, re_seprint, stdout); } #endif } return REG_NOERROR; } /* This table gives an error message for each of the error codes listed in regex.h. Obviously the order here has to be same as there. */ const char * rx_error_msg[] = { 0, /* REG_NOERROR */ "No match", /* REG_NOMATCH */ "Invalid regular expression", /* REG_BADPAT */ "Invalid collation character", /* REG_ECOLLATE */ "Invalid character class name", /* REG_ECTYPE */ "Trailing backslash", /* REG_EESCAPE */ "Invalid back reference", /* REG_ESUBREG */ "Unmatched [ or [^", /* REG_EBRACK */ "Unmatched ( or \\(", /* REG_EPAREN */ "Unmatched \\{", /* REG_EBRACE */ "Invalid content of \\{\\}", /* REG_BADBR */ "Invalid range end", /* REG_ERANGE */ "Memory exhausted", /* REG_ESPACE */ "Invalid preceding regular expression", /* REG_BADRPT */ "Premature end of regular expression", /* REG_EEND */ "Regular expression too big", /* REG_ESIZE */ "Unmatched ) or \\)", /* REG_ERPAREN */ }; /* Test if at very beginning or at very end of the virtual concatenation * of `string1' and `string2'. If only one string, it's `string2'. */ #define AT_STRINGS_BEG() \ (string1 \ ? ((tst_half == 0) \ && ((unsigned char *)tst_pos == (unsigned char *)string1 - 1)) \ : ((unsigned char *)tst_pos == (unsigned char *)string2 - 1)) #define AT_STRINGS_END() \ (string2 \ ? ((tst_half == 1) \ && ((unsigned char *)tst_pos \ == ((unsigned char *)string2 + size2 - 1))) \ : ((unsigned char *)tst_pos == ((unsigned char *)string1 + size1 - 1))) /* Test if D points to a character which is word-constituent. We have * two special cases to check for: if past the end of string1, look at * the first character in string2; and if before the beginning of * string2, look at the last character in string1. * * Assumes `string1' exists, so use in conjunction with AT_STRINGS_BEG (). */ #define LETTER_P(d) \ (SYNTAX ((string2 && (tst_half == 0) \ && ((d) == ((unsigned char *)string1 + size1))) \ ? *(unsigned char *)string2 \ : ((string1 && (tst_half == 1) \ && ((d) == (unsigned char *)string2 - 1)) \ ? *((unsigned char *)string1 + size1 - 1) \ : *(d))) == Sword) /* Test if the character at D and the one after D differ with respect * to being word-constituent. */ #define AT_WORD_BOUNDARY(d) \ (AT_STRINGS_BEG () || AT_STRINGS_END () || LETTER_P (d) != LETTER_P (d + 1)) static char slowmap [256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; #ifdef __STDC__ static void rx_blow_up_fastmap (struct re_pattern_buffer * rxb) #else static void rx_blow_up_fastmap (rxb) struct re_pattern_buffer * rxb; #endif { int x; for (x = 0; x < 256; ++x) /* &&&& 3.6 % */ rxb->fastmap [x] = !!RX_bitset_member (rxb->fastset, x); rxb->fastmap_accurate = 1; } struct stack_chunk { struct stack_chunk * next_chunk; int bytes_left; char * sp; }; #define PUSH(CHUNK_VAR,BYTES) \ if (!CHUNK_VAR || (CHUNK_VAR->bytes_left < (BYTES))) \ { \ struct stack_chunk * new_chunk; \ if (free_chunks) \ { \ new_chunk = free_chunks; \ free_chunks = free_chunks->next_chunk; \ } \ else \ { \ new_chunk = (struct stack_chunk *)alloca (chunk_bytes); \ if (!new_chunk) \ { \ ret_val = 0; \ goto test_do_return; \ } \ } \ new_chunk->sp = (char *)new_chunk + sizeof (struct stack_chunk); \ new_chunk->bytes_left = (chunk_bytes \ - (BYTES) \ - sizeof (struct stack_chunk)); \ new_chunk->next_chunk = CHUNK_VAR; \ CHUNK_VAR = new_chunk; \ } \ else \ (CHUNK_VAR->sp += (BYTES)), (CHUNK_VAR->bytes_left -= (BYTES)) #define POP(CHUNK_VAR,BYTES) \ if (CHUNK_VAR->sp == ((char *)CHUNK_VAR + sizeof(*CHUNK_VAR))) \ { \ struct stack_chunk * new_chunk = CHUNK_VAR->next_chunk; \ CHUNK_VAR->next_chunk = free_chunks; \ free_chunks = CHUNK_VAR; \ CHUNK_VAR = new_chunk; \ } \ else \ (CHUNK_VAR->sp -= BYTES), (CHUNK_VAR->bytes_left += BYTES) struct counter_frame { int tag; int val; struct counter_frame * inherited_from; /* If this is a copy. */ struct counter_frame * cdr; }; struct backtrack_frame { char * counter_stack_sp; /* A frame is used to save the matchers state when it crosses a * backtracking point. The `stk_' fields correspond to variables * in re_search_2 (just strip off thes `stk_'). They are documented * tere. */ struct rx_superstate * stk_super; const unsigned char * stk_tst_pos; int stk_tst_half; unsigned int stk_c; const unsigned char * stk_tst_str_half; const unsigned char * stk_tst_end_half; int stk_last_l; int stk_last_r; int stk_test_ret; /* This is the list of options left to explore at the backtrack * point for which this frame was created. */ struct rx_distinct_future * df; struct rx_distinct_future * first_df; #ifdef RX_DEBUG int stk_line_no; #endif }; #if !defined(REGEX_MALLOC) && !defined(__GNUC__) #define RE_SEARCH_2_FN inner_re_search_2 #else #define RE_SEARCH_2_FN re_search_2 #endif #ifdef __STDC__ int RE_SEARCH_2_FN (struct re_pattern_buffer *rxb, const char * string1, int size1, const char * string2, int size2, int startpos, int range, struct re_registers *regs, int stop) #else int RE_SEARCH_2_FN (rxb, string1, size1, string2, size2, startpos, range, regs, stop) struct re_pattern_buffer *rxb; const char * string1; int size1; const char * string2; int size2; int startpos; int range; struct re_registers *regs; int stop; #endif { /* Two groups of registers are kept. The group with the register state * of the current test match, and the group that holds the state at the end * of the best known match, if any. * * For some patterns, there may also be registers saved on the stack. */ regoff_t * lparen = 0; /* scratch space for register returns */ regoff_t * rparen = 0; regoff_t * best_lpspace = 0; /* in case the user doesn't want these */ regoff_t * best_rpspace = 0; /* values, we still need space to store * them. Normally, this memoryis unused * and the space pointed to by REGS is * used instead. */ int last_l; /* Highest index of a valid lparen. */ int last_r; /* It's dual. */ int * best_lparen; /* This contains the best known register */ int * best_rparen; /* assignments. * This may point to the same mem as * best_lpspace, or it might point to memory * passed by the caller. */ int best_last_l; /* best_last_l:best_lparen::last_l:lparen */ int best_last_r; /* Figure the number of registers we may need for use in backreferences. * The number here includes an element for register zero. */ unsigned num_regs = rxb->re_nsub + 1; int total_size = size1 + size2; /***** INIT re_search_2 */ /* Check for out-of-range STARTPOS. */ if ((startpos < 0) || (startpos > total_size)) return -1; /* Fix up RANGE if it might eventually take us outside * the virtual concatenation of STRING1 and STRING2. */ { int endpos = startpos + range; if (endpos < -1) range = (-1 - startpos); else if (endpos > total_size) range = total_size - startpos; } /* If the search isn't to be a backwards one, don't waste time in a * long search for a pattern that says it is anchored. */ if (rxb->begbuf_only && (range > 0)) { if (startpos > 0) return -1; else range = 1; } /* Then, decide whether to use internal or user-provided reg buffers. */ if (!regs || rxb->no_sub) { best_lpspace = (regoff_t *)REGEX_ALLOCATE (num_regs * sizeof(regoff_t)); best_rpspace = (regoff_t *)REGEX_ALLOCATE (num_regs * sizeof(regoff_t)); best_lparen = best_lpspace; best_rparen = best_rpspace; } else { /* Have the register data arrays been allocated? */ if (rxb->regs_allocated == REGS_UNALLOCATED) { /* No. So allocate them with malloc. We need one extra element beyond `num_regs' for the `-1' marker GNU code uses. */ regs->num_regs = MAX (RE_NREGS, rxb->re_nsub + 1); regs->start = TALLOC (regs->num_regs, regoff_t); regs->end = TALLOC (regs->num_regs, regoff_t); if (regs->start == 0 || regs->end == 0) return -2; rxb->regs_allocated = REGS_REALLOCATE; } else if (rxb->regs_allocated == REGS_REALLOCATE) { /* Yes. If we need more elements than were already allocated, reallocate them. If we need fewer, just leave it alone. */ if (regs->num_regs < num_regs + 1) { regs->num_regs = num_regs + 1; RETALLOC (regs->start, regs->num_regs, regoff_t); RETALLOC (regs->end, regs->num_regs, regoff_t); if (regs->start == 0 || regs->end == 0) return -2; } } else if (rxb->regs_allocated != REGS_FIXED) return -2; if (regs->num_regs < num_regs + 1) { best_lpspace = ((regoff_t *) REGEX_ALLOCATE (num_regs * sizeof(regoff_t))); best_rpspace = ((regoff_t *) REGEX_ALLOCATE (num_regs * sizeof(regoff_t))); best_lparen = best_lpspace; best_rparen = best_rpspace; } else { best_lparen = regs->start; best_rparen = regs->end; } } lparen = (regoff_t *) REGEX_ALLOCATE (num_regs * sizeof(regoff_t)); rparen = (regoff_t *) REGEX_ALLOCATE (num_regs * sizeof(regoff_t)); if (!(best_rparen && best_lparen && lparen && rparen)) return -2; best_last_l = best_last_r = -1; /***** fastmap/search loop, initialization */ /* This is the loop that scans using the fastmap, and sometimes tries to * match. From this point on, don't return. Instead, assign to ret_val * and goto fail. */ { const char * translate = rxb->translate ? rxb->translate : id_translation; /** This is state associated with returning to the caller. */ int ret_val = -1; /* A sentinal is sometimes installed in the fastmap. This records * where so it can be removed before returning. */ int fastmap_chr = -1; int fastmap_val; /** End of state associated with returning to the caller. */ /** Start of variables associated with the fastmap based search: */ char * fastmap = rxb->fastmap ? (char *)rxb->fastmap : (char *)slowmap; int search_direction; /* 1 or -1 */ int search_end; /* first position to not try */ int offset; /* either size1 or 0 as string == string2 */ /* The string-pair position of the fastmap/search loop: */ const unsigned char * pos; /* The current pos. */ const unsigned char * string; /* The current string half. */ const unsigned char * end; /* End of current string. */ int size; /* Current string's size */ int half; /* 0 means string1, 1 means string2 */ /** End of variables associated with the fastmap based search: */ /** Start of variables associated with trying a match * after the fastmap has found a plausible starting point. */ struct rx_superstate * start_super = 0; /* The superNFA start state. */ /* * Two nfa's were compiled. * `0' is complete. * `1' faster but gets registers wrong and ends too soon. */ int nfa_choice = ((regs && !rxb->least_subs) ? '\0' : '\1'); const unsigned char * abs_end; /* Don't fetch a character from here. */ int first_found; /* If true, return after finding any match. */ /** End of variables associated with trying a match. */ /* Update the fastmap now if not correct already. * When the regexp was compiled, the fastmap was computed * and stored in a bitset. This expands the bitset into a * character array containing 1s and 0s. */ if ((fastmap == rxb->fastmap) && !rxb->fastmap_accurate) rx_blow_up_fastmap (rxb); /* Now we build the starting state of the supernfa. */ { struct rx_superset * start_contents; struct rx_nfa_state_set * start_nfa_set; /* We presume here that the nfa start state has only one * possible future with no side effects. */ start_nfa_set = rxb->start->futures->destset; if ( rxb->rx.start_set && (rxb->rx.start_set->starts_for == &rxb->rx)) start_contents = rxb->rx.start_set; else { start_contents = rx_superstate_eclosure_union (&rxb->rx, rx_superset_cons (&rxb->rx, 0, 0), start_nfa_set); if (!start_contents) return -1; start_contents->starts_for = &rxb->rx; rxb->rx.start_set = start_contents; } if ( start_contents->superstate && (start_contents->superstate->rx_id == rxb->rx.rx_id)) { start_super = start_contents->superstate; rx_lock_superstate (&rxb->rx, start_super); } else { rx_protect_superset (&rxb->rx, start_contents); start_super = rx_superstate (&rxb->rx, start_contents); if (!start_super) return -1; rx_lock_superstate (&rxb->rx, start_super); rx_release_superset (&rxb->rx, start_contents); } } /* This computes an upper bound on string addresses for use by * the match-test. */ abs_end = ((const unsigned char *) ((stop <= size1) ? string1 + stop : string2 + stop - size1)); /* We have the option to look for the best match or the first * one we can find. If the user isn't asking for register information, * we don't need to find the best match. */ first_found = !regs; /* Compute search_end & search_direction for the fastmap loop. */ if (range >= 0) { search_end = MIN (size1 + size2, startpos + range) + 1; search_direction = 1; } else { search_end = MAX(-1, startpos + range); search_direction = -1; } /* The vacuous search always turns up nothing. */ if ((search_direction == 1) ? (startpos > search_end) : (startpos < search_end)) return -1; /* Set string/size/offset/end -- the state that tells the fastmap * loop which half of the string we're in. Also set pos, which * is the addr of the current fastmap scan position. */ if (!string2 || (startpos < size1)) { string = (const unsigned char *)string1; size = size1; offset = 0; pos = (const unsigned char *)(string1 + startpos); half = 0; end = (const unsigned char *)MIN(string1 + size1, string1 + stop); } else { string = (const unsigned char *)string2; size = size2; offset = size1; pos = (const unsigned char *)(string2 + startpos - size1); half = 1; end = (const unsigned char *)MIN(string2 + size2, string2 + stop - size1); } /***** fastmap/search loop, body */ init_fastmap_sentinal: /* For the sake of fast fastmapping, set a sentinal in the fastmap. * This sentinal will trap the fastmap loop when it reaches the last * valid character in a string half. * * This must be reset when the fastmap/search loop crosses a string * boundry, and before returning to the caller. So sometimes, * the fastmap loop is restarted with `continue', othertimes by * `goto init_fastmap_sentinal'. */ if (size) { fastmap_chr = ((search_direction == 1) ? *(end - 1) : *string); fastmap_val = fastmap[fastmap_chr]; fastmap[fastmap_chr] = 1; } else fastmap_chr = -1; do { /* If we haven't reached the end of a string half, and if the * pattern can't match the empty string, then the fastmap * optimization applies. This conditional scans using the * fastmap -- stoping when a string half ends, or when a * plausible starting point for a match is found. * It updates HIT_BOUND to tell which case occured. */ if (pos == end) goto fastmap_hit_bound; else { if (search_direction == 1) { if (fastmap_val) { for (;;) { while (!fastmap[*pos]) ++pos; goto commence_a_matchin; } } else { for (;;) { while (!fastmap[*pos]) ++pos; if (*pos != fastmap_chr) goto commence_a_matchin; else { ++pos; if (pos == end) goto fastmap_hit_bound; } } } } else { const unsigned char * bound = string - 1; for (;;) { while (!fastmap[*pos]) --pos; if ((*pos != fastmap_chr) || fastmap_val) goto commence_a_matchin; else { --pos; if (pos == bound) goto fastmap_hit_bound; } } } } fastmap_hit_bound: { /* If we hit a bound, it may simply be time to switch sides * between strings. */ if ((search_direction == 1) && string2 && (half == 0)) { string = (const unsigned char *)string2; size = size2; offset = size1; half = 1; end = (const unsigned char *)MIN(string2 + size2, string2 + stop - size1); startpos = size1; pos = (const unsigned char *)string2; goto init_fastmap_sentinal; } else if ( string1 && (search_direction == -1) && (half == 1)) { string = (const unsigned char *)string1; size = size1; offset = 0; end = (const unsigned char *)string1 + size1; half = 0; startpos = size1 - 1; pos = (const unsigned char *)string1 + size1 - 1; goto init_fastmap_sentinal; } /* ...not a string split, simply no more string. * * When searching backward, running out of string * is reason to quit. */ else if (search_direction == -1) goto finish; /* ...when searching forward, we allow the possibility * of an (empty) match after the last character in the * virtual string. So, fall through to the matcher */ } commence_a_matchin: /***** fastmap/search loop body * test for a match that begins at pos */ /* Now the fastmap loop has brought us to a plausible * starting point for a match. So, it's time to run the * NFA and see if a match occured. */ startpos = pos - string + offset; if (startpos == search_end) goto finish; last_l = last_r = 0; lparen[0] = startpos; /* We know match-begin for this test... */ /* The test matcher is essentially a recursive function * that does an exhaustive run of the superNFA at the * test position. For performance, that function has * been in-lined by hand. */ #undef OF #ifndef HAVE_GNUC_LABELS #define OF(A,B) A #else #define OF(A,B) A: B static void * rx_labels_instruction_table[] = { [rx_backtrack_point] &&backtrack_point, [rx_backtrack] &&backtrack, [rx_do_side_effects] &&do_side_effects, [rx_cache_miss] &&cache_miss, [rx_next_char] 0, [rx_error_inx] 0 }; #endif { /* The current superNFA position of the matcher. */ struct rx_superstate * super = start_super; /* The matcher interprets a series of instruction frames. * This is the `instruction counter' for the interpretation. */ struct rx_inx * ifr; /* We insert a ghost character in the string to prime * the nfa. tst_pos, tst_str_half, and tst_end_half * keep track of the test-match position and string-half. */ const unsigned char * tst_pos = pos - 1; int tst_half = half; unsigned char c = nfa_choice; const unsigned char * tst_str_half = string; const unsigned char * tst_end_half = end; struct stack_chunk * counter_stack = 0; struct stack_chunk * backtrack_stack = 0; int backtrack_frame_bytes = (sizeof (struct backtrack_frame) + (rxb->match_regs_on_stack ? sizeof (regoff_t) * (num_regs + 1) * 2 : 0)); int chunk_bytes = backtrack_frame_bytes * 64; struct stack_chunk * free_chunks = 0; #ifdef RX_DEBUG int backtrack_depth = 0; #endif /* To return from this function, set test_ret and * `goto test_do_return'. * * Possible return values are: * 1 --- end of string while the superNFA is still going * 0 --- internal error (out of memory) * -1 --- search completed by reaching the superNFA fail state * -2 --- a match was found, maybe not the longest. * * When the search is complete (-1), best_last_r indicates whether * a match was found. * * -2 is return only if first_found is non-zero. * * if first_found is non-zero, a return of -1 indicates no match, * otherwise, best_last_r has to be checked. */ int test_ret = -1; while (1) { int inx; #ifdef RX_DEBUG /* There is a search tree with every node as set of deterministic * transitions in the super nfa. For every branch of a * backtrack point is an edge in the tree. * This counts up a pre-order of nodes in that tree. * It's saved on the search stack and printed when debugging. */ int line_no = 0; int lines_found = 0; #endif top_of_cycle: /* A superstate is basicly a transition table, indexed by * characters from the string being tested, and containing * RX_INX structures. */ ifr = &super->transitions [c]; recurse_test_match: /* This is the point to which control is sent when the * test matcher recurses. Before jumping here, some variables * need to be saved on the stack and setup for the recursion. */ restart: /* Some instructions don't advance the matcher, but just * carry out some side effects and fetch a new instruction. * To dispatch that new instruction, `goto restart'. */ { struct rx_inx * next_tr_table = (struct rx_inx *)ifr->data; struct rx_inx * this_tr_table = super->transitions; /* The fastest route through the loop is when the instruction * is RX_NEXT_CHAR. This case is detected when IFR->DATA * is non-zero. In that case, it points to the next * superstate. * * This allows us to not bother fetching the bytecode. */ while (next_tr_table) { #ifdef RX_DEBUG if (rx_debug_trace) { struct rx_superset * setp; fprintf (stderr, "%d %d>> re_next_char @ %d (%d)", line_no, backtrack_depth, (tst_pos - tst_str_half + (tst_half == 0 ? 0 : size1)), c); super = ((struct rx_superstate *) ((char *)this_tr_table - ((unsigned long) ((struct rx_superstate *)0)->transitions))); setp = super->contents; fprintf (stderr, " superstet (rx=%d, &=%x: ", rxb->rx.rx_id, setp); while (setp) { fprintf (stderr, "%d ", setp->id); setp = setp->cdr; } fprintf (stderr, "\n"); } #endif this_tr_table = next_tr_table; ++tst_pos; if (tst_pos == tst_end_half) { if ( (tst_pos != abs_end) && string2 && half == 0) { /* Here we are crossing the break * in a split string. */ tst_str_half = (const unsigned char *)string2; tst_end_half = abs_end; tst_pos = (const unsigned char *)string2; tst_half = 1; } else { test_ret = 1; goto test_do_return; } } c = *tst_pos; ifr = this_tr_table + c; next_tr_table = (struct rx_inx *)ifr->data; } /* Here when we ran out cached next-char transitions. * So, it will be necessary to do a more expensive * dispatch on the current instruction. The superstate * pointer is allowed to become invalid during next-char * transitions -- now we must bring it up to date. */ super = ((struct rx_superstate *) ((char *)this_tr_table - ((unsigned long) ((struct rx_superstate *)0)->transitions))); } /* We've encountered an instruction other than next-char. * Dispatch that instruction: */ inx = (int)ifr->inx; #ifdef HAVE_GNUC_LABELS goto *rx_labels_instruction_table[inx]; #endif #ifdef RX_DEBUG if (rx_debug_trace) { struct rx_superset * setp = super->contents; fprintf (stderr, "%d %d>> %s @ %d (%d)", line_no, backtrack_depth, inx_names[inx], (tst_pos - tst_str_half + (tst_half == 0 ? 0 : size1)), c); fprintf (stderr, " superstet (rx=%d, &=%x: ", rxb->rx.rx_id, setp); while (setp) { fprintf (stderr, "%d ", setp->id); setp = setp->cdr; } fprintf (stderr, "\n"); } #endif switch ((enum rx_opcode)inx) { case OF(rx_do_side_effects,do_side_effects): /* RX_DO_SIDE_EFFECTS occurs when we cross epsilon * edges associated with parentheses, backreferencing, etc. */ { struct rx_distinct_future * df = (struct rx_distinct_future *)ifr->data_2; struct rx_se_list * el = df->effects; /* Side effects come in lists. This walks down * a list, dispatching. */ while (el) { #ifdef HAVE_GNUC_LABELS static void * se_labels[] = { [-re_se_try] &&se_try, [-re_se_pushback] &&se_pushback, [-re_se_push0] &&se_push0, [-re_se_pushpos] &&se_pushpos, [-re_se_chkpos] &&se_chkpos, [-re_se_poppos] &&se_poppos, #ifdef emacs [-re_se_at_dot] &&se_at_dot, [-re_se_syntax] &&se_syntax, [-re_se_not_syntax] &&se_not_syntax, #endif [-re_se_begbuf] &&se_begbuf, [-re_se_hat] &&se_hat, [-re_se_wordbeg] &&se_wordbeg, [-re_se_wordbound] &&se_wordbound, [-re_se_notwordbound] &&se_notwordbound, [-re_se_wordend] &&se_wordend, [-re_se_endbuf] &&se_endbuf, [-re_se_dollar] &&se_dollar, [-re_se_fail] &&se_fail, }; static void * se_lables2[] = { [re_se_win] &&se_win [re_se_lparen] &&se_lparen, [re_se_rparen] &&se_rparen, [re_se_backref] &&se_backref, [re_se_iter] &&se_iter, [re_se_end_iter] &&se_end_iter, [re_se_tv] &&se_tv }; #endif int effect = (int)el->car; if (effect < 0) { #ifdef HAVE_GNUC_LABELS goto *se_labels[-effect]; #endif #ifdef RX_DEBUG if (rx_debug_trace) { struct rx_superset * setp = super->contents; fprintf (stderr, "....%d %d>> %s\n", line_no, backtrack_depth, efnames[-effect]); } #endif switch ((enum re_side_effects) effect) { case OF(re_se_pushback,se_pushback): ifr = &df->future_frame; if (!ifr->data) { struct rx_superstate * sup = super; rx_lock_superstate (rx, sup); if (!rx_handle_cache_miss (&rxb->rx, super, c, ifr->data_2)) { rx_unlock_superstate (rx, sup); test_ret = 0; goto test_do_return; } rx_unlock_superstate (rx, sup); } /* --tst_pos; */ c = 't'; super = ((struct rx_superstate *) ((char *)ifr->data - (long)(((struct rx_superstate *)0) ->transitions))); goto top_of_cycle; break; case OF(re_se_push0,se_push0): { struct counter_frame * old_cf = (counter_stack ? ((struct counter_frame *) counter_stack->sp) : 0); struct counter_frame * cf; PUSH (counter_stack, sizeof (struct counter_frame)); cf = ((struct counter_frame *) counter_stack->sp); cf->tag = re_se_iter; cf->val = 0; cf->inherited_from = 0; cf->cdr = old_cf; break; } case OF(re_se_fail,se_fail): goto test_do_return; case OF(re_se_begbuf,se_begbuf): if (!AT_STRINGS_BEG ()) goto test_do_return; break; case OF(re_se_endbuf,se_endbuf): if (!AT_STRINGS_END ()) goto test_do_return; break; case OF(re_se_wordbeg,se_wordbeg): if ( LETTER_P (tst_pos + 1) && ( AT_STRINGS_BEG() || !LETTER_P (tst_pos))) break; else goto test_do_return; case OF(re_se_wordend,se_wordend): if ( !AT_STRINGS_BEG () && LETTER_P (tst_pos) && (AT_STRINGS_END () || !LETTER_P (tst_pos + 1))) break; else goto test_do_return; case OF(re_se_wordbound,se_wordbound): if (AT_WORD_BOUNDARY (tst_pos)) break; else goto test_do_return; case OF(re_se_notwordbound,se_notwordbound): if (!AT_WORD_BOUNDARY (tst_pos)) break; else goto test_do_return; case OF(re_se_hat,se_hat): if (AT_STRINGS_BEG ()) { if (rxb->not_bol) goto test_do_return; else break; } else { char pos_c = *tst_pos; if ( (TRANSLATE (pos_c) == TRANSLATE('\n')) && rxb->newline_anchor) break; else goto test_do_return; } case OF(re_se_dollar,se_dollar): if (AT_STRINGS_END ()) { if (rxb->not_eol) goto test_do_return; else break; } else { const unsigned char * next_pos = ((string2 && (tst_half == 0) && (tst_pos == ((unsigned char *) string1 + size1 - 1))) ? (unsigned char *)string2 : tst_pos + 1); if ( (TRANSLATE (*next_pos) == TRANSLATE ('\n')) && rxb->newline_anchor) break; else goto test_do_return; } case OF(re_se_try,se_try): /* This is the first side effect in every * expression. * * FOR NO GOOD REASON...get rid of it... */ break; case OF(re_se_pushpos,se_pushpos): { int urhere = ((int)(tst_pos - tst_str_half) + ((tst_half == 0) ? 0 : size1)); struct counter_frame * old_cf = (counter_stack ? ((struct counter_frame *) counter_stack->sp) : 0); struct counter_frame * cf; PUSH(counter_stack, sizeof (struct counter_frame)); cf = ((struct counter_frame *) counter_stack->sp); cf->tag = re_se_pushpos; cf->val = urhere; cf->inherited_from = 0; cf->cdr = old_cf; break; } case OF(re_se_chkpos,se_chkpos): { int urhere = ((int)(tst_pos - tst_str_half) + ((tst_half == 0) ? 0 : size1)); struct counter_frame * cf = ((struct counter_frame *) counter_stack->sp); if (cf->val == urhere) goto test_do_return; cf->val = urhere; break; } break; case OF(re_se_poppos,se_poppos): POP(counter_stack, sizeof (struct counter_frame)); break; case OF(re_se_at_dot,se_at_dot): case OF(re_se_syntax,se_syntax): case OF(re_se_not_syntax,se_not_syntax): #ifdef emacs this release lacks emacs support; (coming soon); #endif break; case re_se_win: case re_se_lparen: case re_se_rparen: case re_se_backref: case re_se_iter: case re_se_end_iter: case re_se_tv: case re_floogle_flap: ret_val = 0; goto test_do_return; } } else { #ifdef HAVE_GNUC_LABELS goto *se_lables2[(rxb->se_params [effect].se)]; #endif #ifdef RX_DEBUG if (rx_debug_trace) fprintf (stderr, "....%d %d>> %s %d %d\n", line_no, backtrack_depth, efnames2[rxb->se_params [effect].se], rxb->se_params [effect].op1, rxb->se_params [effect].op2); #endif switch (rxb->se_params [effect].se) { case OF(re_se_win,se_win): /* This side effect indicates that we've * found a match, though not necessarily the * best match. This is a fancy assignment to * register 0 unless the caller didn't * care about registers. In which case, * this stops the match. */ { int urhere = ((int)(tst_pos - tst_str_half) + ((tst_half == 0) ? 0 : size1)); if ( (best_last_r < 0) || (urhere + 1 > best_rparen[0])) { /* Record the best known and keep * looking. */ int x; for (x = 0; x <= last_l; ++x) best_lparen[x] = lparen[x]; best_last_l = last_l; for (x = 0; x <= last_r; ++x) best_rparen[x] = rparen[x]; best_rparen[0] = urhere + 1; best_last_r = last_r; } /* If we're not reporting the match-length * or other register info, we need look no * further. */ if (first_found) { test_ret = -2; goto test_do_return; } } break; case OF(re_se_lparen,se_lparen): { int urhere = ((int)(tst_pos - tst_str_half) + ((tst_half == 0) ? 0 : size1)); int reg = rxb->se_params [effect].op1; #if 0 if (reg > last_l) #endif { lparen[reg] = urhere + 1; /* In addition to making this assignment, * we now know that lower numbered regs * that haven't already been assigned, * won't be. We make sure they're * filled with -1, so they can be * recognized as unassigned. */ if (last_l < reg) while (++last_l < reg) lparen[last_l] = -1; } break; } case OF(re_se_rparen,se_rparen): { int urhere = ((int)(tst_pos - tst_str_half) + ((tst_half == 0) ? 0 : size1)); int reg = rxb->se_params [effect].op1; rparen[reg] = urhere + 1; if (last_r < reg) { while (++last_r < reg) rparen[last_r] = -1; } break; } case OF(re_se_backref,se_backref): { int reg = rxb->se_params [effect].op1; if (reg > last_r || rparen[reg] < 0) goto test_do_return; { /* fixme */ const unsigned char * there = tst_str_half + lparen[reg]; const unsigned char * last = tst_str_half + rparen[reg]; const unsigned char * here = tst_pos + 1; if ((here == tst_end_half) && string2 && (tst_str_half == (unsigned char *) string1) && (tst_end_half != abs_end)) { here = (unsigned char *)string2; tst_end_half = abs_end; } while (there < last && here < tst_end_half) /* 4% */ if (TRANSLATE(*there) /* &&&& 6% */ != TRANSLATE(*here)) goto test_do_return; else { ++there; ++here; if ((here == tst_end_half) && string2 && (tst_str_half == (unsigned char *)string1) && (tst_end_half != abs_end)) { here = (unsigned char *)string2; tst_end_half = abs_end; tst_half = 1; } } if (there != last) goto test_do_return; tst_pos = here - 1; if ((here == (unsigned char *)string2) && (unsigned char *)string1) { tst_pos = ((unsigned char *)string1 + size1 - 1); tst_end_half = tst_pos + 1; tst_half = 0; } } break; } case OF(re_se_iter,se_iter): { struct counter_frame * csp = ((struct counter_frame *) counter_stack->sp); if (csp->val == rxb->se_params[effect].op2) goto test_do_return; else ++csp->val; break; } case OF(re_se_end_iter,se_end_iter): { struct counter_frame * csp = ((struct counter_frame *) counter_stack->sp); if (csp->val < rxb->se_params[effect].op1) goto test_do_return; else { struct counter_frame * source = csp; while (source->inherited_from) source = source->inherited_from; if (!source || !source->cdr) { POP(counter_stack, sizeof(struct counter_frame)); } else { source = source->cdr; csp->val = source->val; csp->tag = source->tag; csp->cdr = 0; csp->inherited_from = source; } } break; } case OF(re_se_tv, se_tv): /* is a noop */ break; case re_se_try: case re_se_pushback: case re_se_push0: case re_se_pushpos: case re_se_chkpos: case re_se_poppos: case re_se_at_dot: case re_se_syntax: case re_se_not_syntax: case re_se_begbuf: case re_se_hat: case re_se_wordbeg: case re_se_wordbound: case re_se_notwordbound: case re_se_wordend: case re_se_endbuf: case re_se_dollar: case re_se_fail: case re_floogle_flap: ret_val = 0; goto test_do_return; } } el = el->cdr; } /* Now the side effects are done, * so get the next instruction. * and move on. */ ifr = &df->future_frame; goto restart; } case OF(rx_backtrack_point,backtrack_point): { /* A backtrack point indicates that we've reached a * non-determinism in the superstate NFA. This is a * loop that exhaustively searches the possibilities. * * A backtracking strategy is used. We keep track of what * registers are valid so we can erase side effects. * * First, make sure there is some stack space to hold * our state. */ struct backtrack_frame * bf; PUSH(backtrack_stack, backtrack_frame_bytes); #ifdef RX_DEBUG ++backtrack_depth; #endif bf = ((struct backtrack_frame *) backtrack_stack->sp); { bf->stk_super = super; /* We prevent the current superstate from being * deleted from the superstate cache. */ rx_lock_superstate (&rxb->rx, super); bf->stk_tst_pos = tst_pos; #ifdef RX_DEBUG bf->stk_line_no = line_no; #endif bf->stk_tst_half = tst_half; bf->stk_c = c; bf->stk_tst_str_half = tst_str_half; bf->stk_tst_end_half = tst_end_half; bf->stk_last_l = last_l; bf->stk_last_r = last_r; bf->df = ((struct rx_super_edge *)ifr->data_2)->options; bf->first_df = bf->df; bf->counter_stack_sp = (counter_stack ? counter_stack->sp : 0); bf->stk_test_ret = test_ret; if (rxb->match_regs_on_stack) { int x; regoff_t * stk = (regoff_t *)((char *)bf + sizeof (*bf)); for (x = 0; x <= last_l; ++x) stk[x] = lparen[x]; stk += x; for (x = 0; x <= last_r; ++x) stk[x] = rparen[x]; } } /* Here is a while loop whose body is mainly a function * call and some code to handle a return from that * function. * * From here on for the rest of `case backtrack_point' it * is unsafe to assume that the variables saved on the * stack are valid -- so reread their values from the stack * as needed. * * This lets us re-use one generation fewer stack saves in * the call-graph of a search. */ while_non_det_options: #ifdef RX_DEBUG ++lines_found; if (rx_debug_trace) fprintf (stderr, "@@@ %d calls %d @@@\n", line_no, lines_found); line_no = lines_found; #endif if (bf->df->next_same_super_edge[0] == bf->first_df) { /* This is a tail-call optimization -- we don't recurse * for the last of the possible futures. */ ifr = (bf->df->effects ? &bf->df->side_effects_frame : &bf->df->future_frame); rx_unlock_superstate (&rxb->rx, super); POP(backtrack_stack, backtrack_frame_bytes); #ifdef RX_DEBUG --backtrack_depth; #endif goto restart; } else { if (counter_stack) { struct counter_frame * old_cf = ((struct counter_frame *)counter_stack->sp); struct counter_frame * cf; PUSH(counter_stack, sizeof (struct counter_frame)); cf = ((struct counter_frame *)counter_stack->sp); cf->tag = old_cf->tag; cf->val = old_cf->val; cf->inherited_from = old_cf; cf->cdr = 0; } /* `Call' this test-match block */ ifr = (bf->df->effects ? &bf->df->side_effects_frame : &bf->df->future_frame); goto recurse_test_match; } /* Returns in this block are accomplished by * goto test_do_return. There are two cases. * If there is some search-stack left, * then it is a return from a `recursive' call. * If there is no search-stack left, then * we should return to the fastmap/search loop. */ test_do_return: if (!backtrack_stack) { #ifdef RX_DEBUG if (rx_debug_trace) fprintf (stderr, "!!! %d bails returning %d !!!\n", line_no, test_ret); #endif /* No more search-stack -- this test is done. */ if (test_ret) goto return_from_test_match; else goto error_in_testing_match; } /* Ok..we're returning from a recursive call to * the test match block: */ bf = ((struct backtrack_frame *) backtrack_stack->sp); #ifdef RX_DEBUG if (rx_debug_trace) fprintf (stderr, "+++ %d returns %d (to %d)+++\n", line_no, test_ret, bf->stk_line_no); #endif while (counter_stack && (!bf->counter_stack_sp || (bf->counter_stack_sp != counter_stack->sp))) { POP(counter_stack, sizeof (struct counter_frame)); } if (!test_ret) { POP (backtrack_stack, backtrack_frame_bytes); goto test_do_return; } /* If any possible future reaches the end of the * string without failing, make sure we propogate * that information to the caller. */ if ((test_ret == -2) && first_found) { rx_unlock_superstate (&rxb->rx, bf->stk_super); POP (backtrack_stack, backtrack_frame_bytes); goto test_do_return; } if (bf->stk_test_ret < 0) test_ret = bf->stk_test_ret; last_l = bf->stk_last_l; last_r = bf->stk_last_r; bf->df = bf->df->next_same_super_edge[0]; super = bf->stk_super; tst_pos = bf->stk_tst_pos; tst_half = bf->stk_tst_half; c = bf->stk_c; tst_str_half = bf->stk_tst_str_half; tst_end_half = bf->stk_tst_end_half; #ifdef RX_DEBUG line_no = bf->stk_line_no; #endif if (rxb->match_regs_on_stack) { int x; regoff_t * stk = (regoff_t *)((char *)bf + sizeof (*bf)); for (x = 0; x <= last_l; ++x) lparen[x] = stk[x]; stk += x; for (x = 0; x <= last_r; ++x) rparen[x] = stk[x]; } goto while_non_det_options; } case OF(rx_cache_miss,cache_miss): /* Because the superstate NFA is lazily constructed, * and in fact may erode from underneath us, we sometimes * have to construct the next instruction from the hard way. * This invokes one step in the lazy-conversion. */ ifr = rx_handle_cache_miss (&rxb->rx, super, c, ifr->data_2); if (!ifr) { test_ret = 0; goto test_do_return; } goto restart; case OF(rx_backtrack,backtrack): /* RX_BACKTRACK means that we've reached the empty * superstate, indicating that match can't succeed * from this point. */ goto test_do_return; case rx_next_char: case rx_error_inx: case rx_num_instructions: ret_val = 0; goto test_do_return; } } } /* Healthy exists from the test-match loop do a * `goto return_from_test_match' On the other hand, * we might end up here. */ error_in_testing_match: ret_val = -2; goto finish; /***** fastmap/search loop body * considering the results testing for a match */ return_from_test_match: if (best_last_l >= 0) { if (regs && (regs->start != best_lparen)) { bcopy (best_lparen, regs->start, regs->num_regs * sizeof (int)); bcopy (best_rparen, regs->end, regs->num_regs * sizeof (int)); } if (regs && !rxb->no_sub) { int q; int bound = (regs->num_regs > num_regs ? regs->num_regs : num_regs); regoff_t * s = regs->start; regoff_t * e = regs->end; for (q = best_last_l + 1; q < bound; ++q) s[q] = e[q] = -1; } ret_val = best_lparen[0]; goto finish; } /***** fastmap/search loop, increment and loop-test */ pos += search_direction; startpos += search_direction; } while (startpos < search_end); /**** Exit code for fastmap/searchloop and the entire re_search_2 fn. */ finish: /* Unset the fastmap sentinel */ if (fastmap_chr >= 0) fastmap[fastmap_chr] = fastmap_val; if (start_super) rx_unlock_superstate (&rxb->rx, start_super); #ifdef REGEX_MALLOC if (lparen) free (lparen); if (rparen) free (rparen); if (best_lpspace) free (best_lpspace); if (best_rpspace) free (best_rpspace); #endif return ret_val; } } #if !defined(REGEX_MALLOC) && !defined(__GNUC__) #ifdef __STDC__ int re_search_2 (struct re_pattern_buffer *rxb, const char * string1, int size1, const char * string2, int size2, int startpos, int range, struct re_registers *regs, int stop) #else int re_search_2 (rxb, string1, size1, string2, size2, startpos, range, regs, stop) struct re_pattern_buffer *rxb; const char * string1; int size1; const char * string2; int size2; int startpos; int range; struct re_registers *regs; int stop; #endif { int ret; ret = inner_re_search_2 (rxb, string1, size1, string2, size2, startpos, range, regs, stop); alloca (0); return ret; } #endif /* Like re_search_2, above, but only one string is specified, and * doesn't let you say where to stop matching. */ #ifdef __STDC__ int re_search (struct re_pattern_buffer * rxb, const char *string, int size, int startpos, int range, struct re_registers *regs) #else int re_search (rxb, string, size, startpos, range, regs) struct re_pattern_buffer * rxb; const char * string; int size; int startpos; int range; struct re_registers *regs; #endif { return re_search_2 (rxb, 0, 0, string, size, startpos, range, regs, size); } #ifdef __STDC__ int re_match_2 (struct re_pattern_buffer * rxb, const char * string1, int size1, const char * string2, int size2, int pos, struct re_registers *regs, int stop) #else int re_match_2 (rxb, string1, size1, string2, size2, pos, regs, stop) struct re_pattern_buffer * rxb; const char * string1; int size1; const char * string2; int size2; int pos; struct re_registers *regs; int stop; #endif { struct re_registers some_regs; regoff_t start; regoff_t end; int srch; int save = rxb->regs_allocated; struct re_registers * regs_to_pass = regs; if (!regs) { some_regs.start = &start; some_regs.end = &end; some_regs.num_regs = 1; regs_to_pass = &some_regs; rxb->regs_allocated = REGS_FIXED; } srch = re_search_2 (rxb, string1, size1, string2, size2, pos, 1, regs_to_pass, stop); if (regs_to_pass != regs) rxb->regs_allocated = save; if (srch < 0) return srch; return regs_to_pass->end[0] - regs_to_pass->start[0]; } /* re_match is like re_match_2 except it takes only a single string. */ #ifdef __STDC__ int re_match (struct re_pattern_buffer * rxb, const char * string, int size, int pos, struct re_registers *regs) #else int re_match (rxb, string, size, pos, regs) struct re_pattern_buffer * rxb; const char *string; int size; int pos; struct re_registers *regs; #endif { return re_match_2 (rxb, string, size, 0, 0, pos, regs, size); } /* Set by `re_set_syntax' to the current regexp syntax to recognize. Can also be assigned to arbitrarily: each pattern buffer stores its own syntax, so it can be changed between regex compilations. */ reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; /* Specify the precise syntax of regexps for compilation. This provides for compatibility for various utilities which historically have different, incompatible syntaxes. The argument SYNTAX is a bit mask comprised of the various bits defined in regex.h. We return the old syntax. */ #ifdef __STDC__ reg_syntax_t re_set_syntax (reg_syntax_t syntax) #else reg_syntax_t re_set_syntax (syntax) reg_syntax_t syntax; #endif { reg_syntax_t ret = re_syntax_options; re_syntax_options = syntax; return ret; } /* Set REGS to hold NUM_REGS registers, storing them in STARTS and ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use this memory for recording register information. STARTS and ENDS must be allocated using the malloc library routine, and must each be at least NUM_REGS * sizeof (regoff_t) bytes long. If NUM_REGS == 0, then subsequent matches should allocate their own register data. Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ #ifdef __STDC__ void re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, unsigned num_regs, regoff_t * starts, regoff_t * ends) #else void re_set_registers (bufp, regs, num_regs, starts, ends) struct re_pattern_buffer *bufp; struct re_registers *regs; unsigned num_regs; regoff_t * starts; regoff_t * ends; #endif { if (num_regs) { bufp->regs_allocated = REGS_REALLOCATE; regs->num_regs = num_regs; regs->start = starts; regs->end = ends; } else { bufp->regs_allocated = REGS_UNALLOCATED; regs->num_regs = 0; regs->start = regs->end = (regoff_t) 0; } } #ifdef __STDC__ static int cplx_se_sublist_len (struct rx_se_list * list) #else static int cplx_se_sublist_len (list) struct rx_se_list * list; #endif { int x = 0; while (list) { if ((int)list->car >= 0) ++x; list = list->cdr; } return x; } /* For rx->se_list_cmp */ #ifdef __STDC__ static int posix_se_list_order (struct rx * rx, struct rx_se_list * a, struct rx_se_list * b) #else static int posix_se_list_order (rx, a, b) struct rx * rx; struct rx_se_list * a; struct rx_se_list * b; #endif { int al = cplx_se_sublist_len (a); int bl = cplx_se_sublist_len (b); if (!al && !bl) return ((a == b) ? 0 : ((a < b) ? -1 : 1)); else if (!al) return -1; else if (!bl) return 1; else { rx_side_effect * av = ((rx_side_effect *) alloca (sizeof (rx_side_effect) * (al + 1))); rx_side_effect * bv = ((rx_side_effect *) alloca (sizeof (rx_side_effect) * (bl + 1))); struct rx_se_list * ap = a; struct rx_se_list * bp = b; int ai, bi; for (ai = al - 1; ai >= 0; --ai) { while ((int)ap->car < 0) ap = ap->cdr; av[ai] = ap->car; ap = ap->cdr; } av[al] = (rx_side_effect)-2; for (bi = bl - 1; bi >= 0; --bi) { while ((int)bp->car < 0) bp = bp->cdr; bv[bi] = bp->car; bp = bp->cdr; } bv[bl] = (rx_side_effect)-1; { int ret; int x = 0; while (av[x] == bv[x]) ++x; ret = ((av[x] < bv[x]) ? -1 : 1); return ret; } } } /* re_compile_pattern is the GNU regular expression compiler: it compiles PATTERN (of length SIZE) and puts the result in RXB. Returns 0 if the pattern was valid, otherwise an error string. Assumes the `allocated' (and perhaps `buffer') and `translate' fields are set in RXB on entry. We call rx_compile to do the actual compilation. */ #ifdef __STDC__ const char * re_compile_pattern (const char *pattern, int length, struct re_pattern_buffer * rxb) #else const char * re_compile_pattern (pattern, length, rxb) const char *pattern; int length; struct re_pattern_buffer * rxb; #endif { reg_errcode_t ret; /* GNU code is written to assume at least RE_NREGS registers will be set (and at least one extra will be -1). */ rxb->regs_allocated = REGS_UNALLOCATED; /* And GNU code determines whether or not to get register information by passing null for the REGS argument to re_match, etc., not by setting no_sub. */ rxb->no_sub = 0; rxb->rx.local_cset_size = 256; /* Match anchors at newline. */ rxb->newline_anchor = 1; rxb->re_nsub = 0; rxb->start = 0; rxb->se_params = 0; rxb->rx.nodec = 0; rxb->rx.epsnodec = 0; rxb->rx.instruction_table = 0; rxb->rx.nfa_states = 0; rxb->rx.se_list_cmp = posix_se_list_order; rxb->rx.start_set = 0; ret = rx_compile (pattern, length, re_syntax_options, rxb); alloca (0); return rx_error_msg[(int) ret]; } #ifdef __STDC__ int re_compile_fastmap (struct re_pattern_buffer * rxb) #else int re_compile_fastmap (rxb) struct re_pattern_buffer * rxb; #endif { rx_blow_up_fastmap (rxb); return 0; } /* Entry points compatible with 4.2 BSD regex library. We don't define them if this is an Emacs or POSIX compilation. */ #if (!defined (emacs) && !defined (_POSIX_SOURCE)) || defined(USE_BSD_REGEX) /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer rx_comp_buf; #ifdef __STDC__ char * re_comp (const char *s) #else char * re_comp (s) const char *s; #endif { reg_errcode_t ret; if (!s || *s == '\0') { if (!rx_comp_buf.buffer) return "No previous regular expression"; return 0; } if (!rx_comp_buf.fastmap) { rx_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); if (!rx_comp_buf.fastmap) return "Memory exhausted"; } /* Since `rx_exec' always passes NULL for the `regs' argument, we don't need to initialize the pattern buffer fields which affect it. */ /* Match anchors at newlines. */ rx_comp_buf.newline_anchor = 1; rx_comp_buf.re_nsub = 0; rx_comp_buf.start = 0; rx_comp_buf.se_params = 0; rx_comp_buf.rx.nodec = 0; rx_comp_buf.rx.epsnodec = 0; rx_comp_buf.rx.instruction_table = 0; rx_comp_buf.rx.nfa_states = 0; rx_comp_buf.rx.start = 0; rx_comp_buf.rx.se_list_cmp = posix_se_list_order; ret = rx_compile (s, strlen (s), re_syntax_options, &rx_comp_buf); alloca (0); /* Yes, we're discarding `const' here. */ return (char *) rx_error_msg[(int) ret]; } #ifdef __STDC__ int re_exec (const char *s) #else int re_exec (s) const char *s; #endif { const int len = strlen (s); return 0 <= re_search (&rx_comp_buf, s, len, 0, len, (struct re_registers *) 0); } #endif /* not emacs and not _POSIX_SOURCE */ /* POSIX.2 functions. Don't define these for Emacs. */ #if !defined(emacs) /* regcomp takes a regular expression as a string and compiles it. PREG is a regex_t *. We do not expect any fields to be initialized, since POSIX says we shouldn't. Thus, we set `buffer' to the compiled pattern; `used' to the length of the compiled pattern; `syntax' to RE_SYNTAX_POSIX_EXTENDED if the REG_EXTENDED bit in CFLAGS is set; otherwise, to RE_SYNTAX_POSIX_BASIC; `newline_anchor' to REG_NEWLINE being set in CFLAGS; `fastmap' and `fastmap_accurate' to zero; `re_nsub' to the number of subexpressions in PATTERN. PATTERN is the address of the pattern string. CFLAGS is a series of bits which affect compilation. If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we use POSIX basic syntax. If REG_NEWLINE is set, then . and [^...] don't match newline. Also, regexec will try a match beginning after every newline. If REG_ICASE is set, then we considers upper- and lowercase versions of letters to be equivalent when matching. If REG_NOSUB is set, then when PREG is passed to regexec, that routine will report only success or failure, and nothing about the registers. It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for the return codes and their meanings.) */ #ifdef __STDC__ int regcomp (regex_t * preg, const char * pattern, int cflags) #else int regcomp (preg, pattern, cflags) regex_t * preg; const char * pattern; int cflags; #endif { reg_errcode_t ret; unsigned syntax = cflags & REG_EXTENDED ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; /* regex_compile will allocate the space for the compiled pattern. */ preg->buffer = 0; preg->allocated = 0; preg->fastmap = malloc (256); if (!preg->fastmap) return REG_ESPACE; preg->fastmap_accurate = 0; if (cflags & REG_ICASE) { unsigned i; preg->translate = (char *) malloc (256); if (!preg->translate) return (int) REG_ESPACE; /* Map uppercase characters to corresponding lowercase ones. */ for (i = 0; i < CHAR_SET_SIZE; i++) preg->translate[i] = isupper (i) ? tolower (i) : i; } else preg->translate = 0; /* If REG_NEWLINE is set, newlines are treated differently. */ if (cflags & REG_NEWLINE) { /* REG_NEWLINE implies neither . nor [^...] match newline. */ syntax &= ~RE_DOT_NEWLINE; syntax |= RE_HAT_LISTS_NOT_NEWLINE; /* It also changes the matching behavior. */ preg->newline_anchor = 1; } else preg->newline_anchor = 0; preg->no_sub = !!(cflags & REG_NOSUB); /* POSIX says a null character in the pattern terminates it, so we can use strlen here in compiling the pattern. */ preg->re_nsub = 0; preg->start = 0; preg->se_params = 0; preg->rx.nodec = 0; preg->rx.epsnodec = 0; preg->rx.instruction_table = 0; preg->rx.nfa_states = 0; preg->rx.local_cset_size = 256; preg->rx.start = 0; preg->rx.se_list_cmp = posix_se_list_order; preg->rx.start_set = 0; ret = rx_compile (pattern, strlen (pattern), syntax, preg); alloca (0); /* POSIX doesn't distinguish between an unmatched open-group and an unmatched close-group: both are REG_EPAREN. */ if (ret == REG_ERPAREN) ret = REG_EPAREN; return (int) ret; } /* regexec searches for a given pattern, specified by PREG, in the string STRING. If NMATCH is zero or REG_NOSUB was set in the cflags argument to `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at least NMATCH elements, and we set them to the offsets of the corresponding matched substrings. EFLAGS specifies `execution flags' which affect matching: if REG_NOTBOL is set, then ^ does not match at the beginning of the string; if REG_NOTEOL is set, then $ does not match at the end. We return 0 if we find a match and REG_NOMATCH if not. */ #ifdef __STDC__ int regexec (const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags) #else int regexec (preg, string, nmatch, pmatch, eflags) const regex_t *preg; const char *string; size_t nmatch; regmatch_t pmatch[]; int eflags; #endif { int ret; struct re_registers regs; regex_t private_preg; int len = strlen (string); boolean want_reg_info = !preg->no_sub && nmatch > 0; private_preg = *preg; private_preg.not_bol = !!(eflags & REG_NOTBOL); private_preg.not_eol = !!(eflags & REG_NOTEOL); /* The user has told us exactly how many registers to return * information about, via `nmatch'. We have to pass that on to the * matching routines. */ private_preg.regs_allocated = REGS_FIXED; if (want_reg_info) { regs.num_regs = nmatch; regs.start = TALLOC (nmatch, regoff_t); regs.end = TALLOC (nmatch, regoff_t); if (regs.start == 0 || regs.end == 0) return (int) REG_NOMATCH; } /* Perform the searching operation. */ ret = re_search (&private_preg, string, len, /* start: */ 0, /* range: */ len, want_reg_info ? ®s : (struct re_registers *) 0); /* Copy the register information to the POSIX structure. */ if (want_reg_info) { if (ret >= 0) { unsigned r; for (r = 0; r < nmatch; r++) { pmatch[r].rm_so = regs.start[r]; pmatch[r].rm_eo = regs.end[r]; } } /* If we needed the temporary register info, free the space now. */ free (regs.start); free (regs.end); } /* We want zero return to mean success, unlike `re_search'. */ return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH; } /* Returns a message corresponding to an error code, ERRCODE, returned from either regcomp or regexec. */ #ifdef __STDC__ size_t regerror (int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size) #else size_t regerror (errcode, preg, errbuf, errbuf_size) int errcode; const regex_t *preg; char *errbuf; size_t errbuf_size; #endif { const char *msg = rx_error_msg[errcode] == 0 ? "Success" : rx_error_msg[errcode]; size_t msg_size = strlen (msg) + 1; /* Includes the 0. */ if (errbuf_size != 0) { if (msg_size > errbuf_size) { strncpy (errbuf, msg, errbuf_size - 1); errbuf[errbuf_size - 1] = 0; } else strcpy (errbuf, msg); } return msg_size; } /* Free dynamically allocated space used by PREG. */ #ifdef __STDC__ void regfree (regex_t *preg) #else void regfree (preg) regex_t *preg; #endif { if (preg->buffer != 0) free (preg->buffer); preg->buffer = 0; preg->allocated = 0; if (preg->fastmap != 0) free (preg->fastmap); preg->fastmap = 0; preg->fastmap_accurate = 0; if (preg->translate != 0) free (preg->translate); preg->translate = 0; } #endif /* not emacs */ ./libc-linux/regex/rx.diff100644 1676 334 4615 5520507606 13524 0ustar hjlisl*** /home/titanic/hjl/gnu/src/sed-2.03/rx.c Sat Aug 7 12:00:44 1993 --- ./rx.c Sat Jan 22 23:21:20 1994 *************** *** 21,26 **** --- 21,31 ---- #pragma alloca #endif + + #ifndef _GNU_SOURCE + #define _GNU_SOURCE + #endif + static char rx_version_string[] = "GNU Rx version 0.03"; /* ``Too hard!'' *************** *** 8443,8449 **** /* Entry points compatible with 4.2 BSD regex library. We don't define them if this is an Emacs or POSIX compilation. */ ! #if !defined (emacs) && !defined (_POSIX_SOURCE) && 0 /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer rx_comp_buf; --- 8448,8455 ---- /* Entry points compatible with 4.2 BSD regex library. We don't define them if this is an Emacs or POSIX compilation. */ ! #if (!defined (emacs) && !defined (_POSIX_SOURCE)) || defined(USE_BSD_REGEX) ! /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer rx_comp_buf; *************** *** 8459,8465 **** { reg_errcode_t ret; ! if (!s) { if (!rx_comp_buf.buffer) return "No previous regular expression"; --- 8465,8471 ---- { reg_errcode_t ret; ! if (!s || *s == '\0') { if (!rx_comp_buf.buffer) return "No previous regular expression"; *************** *** 8489,8495 **** rx_comp_buf.rx.start = 0; rx_comp_buf.rx.se_list_cmp = posix_se_list_order; ! ret = rx_compile (s, strlen (s), rx_syntax_options, &rx_comp_buf); alloca (0); /* Yes, we're discarding `const' here. */ --- 8495,8501 ---- rx_comp_buf.rx.start = 0; rx_comp_buf.rx.se_list_cmp = posix_se_list_order; ! ret = rx_compile (s, strlen (s), re_syntax_options, &rx_comp_buf); alloca (0); /* Yes, we're discarding `const' here. */ *************** *** 8499,8514 **** #ifdef __STDC__ int ! rx_exec (const char *s) #else int ! rx_exec (s) const char *s; #endif { const int len = strlen (s); return ! 0 <= re_search (&rx_comp_buf, s, len, 0, len, (struct rx_registers *) 0); } #endif /* not emacs and not _POSIX_SOURCE */ --- 8505,8520 ---- #ifdef __STDC__ int ! re_exec (const char *s) #else int ! re_exec (s) const char *s; #endif { const int len = strlen (s); return ! 0 <= re_search (&rx_comp_buf, s, len, 0, len, (struct re_registers *) 0); } #endif /* not emacs and not _POSIX_SOURCE */ ./libc-linux/regex/rx.h100644 1676 334 103613 5520467465 13111 0ustar hjlisl#if !defined(_RX_H) || defined(RX_WANT_SE_DEFS) #define _RX_H /* Copyright (C) 1992, 1993 Free Software Foundation, Inc. This program 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 program 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 this software; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* t. lord Wed Sep 23 18:20:57 1992 */ #ifndef RX_WANT_SE_DEFS #include __BEGIN_DECLS /* This page: Bitsets */ #ifndef RX_subset typedef unsigned int RX_subset; #define RX_subset_bits (32) #define RX_subset_mask (RX_subset_bits - 1) #endif typedef RX_subset * rx_Bitset; #ifdef __STDC__ typedef void (*rx_bitset_iterator) (void *, int member_index); #else typedef void (*rx_bitset_iterator) (); #endif #define rx_bitset_subset(N) ((N) / RX_subset_bits) #define rx_bitset_subset_val(B,N) ((B)[rx_bitset_subset(N)]) #define RX_bitset_access(B,N,OP) \ ((B)[rx_bitset_subset(N)] OP rx_subset_singletons[(N) & RX_subset_mask]) #define RX_bitset_member(B,N) RX_bitset_access(B, N, &) #define RX_bitset_enjoin(B,N) RX_bitset_access(B, N, |=) #define RX_bitset_remove(B,N) RX_bitset_access(B, N, &= ~) #define RX_bitset_toggle(B,N) RX_bitset_access(B, N, ^= ) #define rx_bitset_numb_subsets(N) (((N) + RX_subset_bits - 1) / RX_subset_bits) #define rx_sizeof_bitset(N) (rx_bitset_numb_subsets(N) * sizeof(RX_subset)) /* This page: Splay trees. */ #ifdef __STDC__ typedef int (*rx_sp_comparer) (void * a, void * b); #else typedef int (*rx_sp_comparer) (); #endif struct rx_sp_node { void * key; void * data; struct rx_sp_node * kids[2]; }; #ifdef __STDC__ typedef void (*rx_sp_key_data_freer) (struct rx_sp_node *); #else typedef void (*rx_sp_key_data_freer) (); #endif /* giant inflatable hash trees */ struct rx_hash_item { struct rx_hash_item * next_same_hash; struct rx_hash * table; unsigned long hash; void * data; void * binding; }; struct rx_hash { struct rx_hash * parent; int refs; struct rx_hash * children[13]; struct rx_hash_item * buckets [13]; int bucket_size [13]; }; struct rx_hash_rules; #ifdef __STDC__ /* should return like == */ typedef int (*rx_hash_eq)(void *, void *); typedef struct rx_hash * (*rx_alloc_hash)(struct rx_hash_rules *); typedef void (*rx_free_hash)(struct rx_hash *, struct rx_hash_rules *); typedef struct rx_hash_item * (*rx_alloc_hash_item)(struct rx_hash_rules *, void *); typedef void (*rx_free_hash_item)(struct rx_hash_item *, struct rx_hash_rules *); #else typedef int (*rx_hash_eq)(); typedef struct rx_hash * (*rx_alloc_hash)(); typedef void (*rx_free_hash)(); typedef struct rx_hash_item * (*rx_alloc_hash_item)(); typedef void (*rx_free_hash_item)(); #endif struct rx_hash_rules { rx_hash_eq eq; rx_alloc_hash hash_alloc; rx_free_hash free_hash; /* oh, shut up don */ rx_alloc_hash_item hash_item_alloc; rx_free_hash_item free_hash_item; }; /* Matchers decide what to do by examining a series of these. * Instruction types are described below. */ struct rx_inx { void * inx; void * data; void * data_2; void * fnord; }; /* Struct RX holds a compiled regular expression - that is, an nfa ready to be * converted on demand to a more efficient nfa. This is for the low level interface. * The high-level interface incloses this in a `struct re_pattern_buffer'. */ struct rx_cache; #ifdef __STDC__ struct rx_se_list; struct rx; typedef int (*rx_se_list_order) (struct rx *, struct rx_se_list *, struct rx_se_list *); #else typedef int (*rx_se_list_order) (); #endif struct rx_superset; struct rx { int rx_id; /* Every edition numbered and signed by eclose_nfa. */ struct rx_cache * cache; /* Where superstates come from */ /* Every regex defines the size of its own character set. */ int local_cset_size; void * buffer; /* Malloced memory for the nfa. */ unsigned long allocated; /* Size of that memory. */ /* How much buffer space to save for external uses. After compilation, * this space will be available at (buffer + allocated - reserved) */ unsigned long reserved; /* --------- The remaining fields are for internal use only. --------- */ /* --------- But! they should be initialized to 0. --------- */ /* NODEC is the number of nodes in the NFA with non-epsilon * orx transitions. */ int nodec; /* EPSNODEC is the number of nodes with only epsilon (orx) transitions. */ int epsnodec; /* The sum of NODEC & EPSNODEC is the total number of states in the * compiled NFA. */ /* side_effect_progs temporarily holds a tree of side effect lists. */ struct rx_hash se_list_memo; /* A memo for sets of states in the possible_future lists of an nfa: */ struct rx_hash set_list_memo; /* The instruction table is indexed by the enum of instructions defined in * rxrun.h. The values in the table are used to fill in the `inx' * slot of instruction frames (see rxrun.h). */ void ** instruction_table; struct rx_nfa_state *nfa_states; struct rx_nfa_state *start; /* This orders the search through super-nfa paths. */ rx_se_list_order se_list_cmp; struct rx_superset * start_set; }; /* An RX NFA may contain epsilon edges labeled with side effects. * These side effects represent match actions that can not normally be * defined in a `pure' NFA; for example, recording the location at * which a paren is crossed in a register structure. * * A matcher is supposed to find a particular path * through the NFA (such as leftmost-longest), and then to execute the * side effects along that path. Operationally, the space of paths is * searched and side effects are carried out incrementally, and with * backtracking. * * As the NFA is manipulated during matching sets of side effects. * Simple lists are used to hold side effect lists. */ typedef void * rx_side_effect; struct rx_se_list { rx_side_effect car; struct rx_se_list * cdr; }; /* Struct rexp_node holds an expression tree that represents a regexp. * In this expression tree, every node has a type, and some parameters * appropriate to that type. */ enum rexp_node_type { r_cset, /* Match from a character set. `a' or `[a-z]'*/ r_concat, /* Concat two regexps. `ab' */ r_alternate, /* Choose one of two regexps. `a\|b' */ r_opt, /* Optional regexp. `a?' */ r_star, /* Repeated regexp. `a*' */ r_2phase_star, /* hard to explain */ r_side_effect, /* Matches the empty string, but * implies that a side effect must * take place. These nodes are used * by the parser to implement parens, * backreferences etc. */ r_data /* R_DATA is soley for the convenience * of parsers or other rexp * transformers that want to * (temporarily) introduce new node * types in rexp structures. These * must be eliminated * by the time build_nfa is called. */ }; struct rexp_node { enum rexp_node_type type; union { rx_Bitset cset; rx_side_effect side_effect; struct { struct rexp_node *left; struct rexp_node *right; } pair; void * data; } params; }; /* This defines the structure of the NFA into which rexps are compiled. */ struct rx_nfa_state { int id; struct rx_nfa_edge *edges; struct rx_possible_future *futures; unsigned int is_final:1; unsigned int is_start:1; unsigned int eclosure_needed:1; struct rx_nfa_state *next; unsigned int mark:1; }; enum rx_nfa_etype { ne_cset, ne_epsilon, ne_side_effect /* A special kind of epsilon. */ }; struct rx_nfa_edge { struct rx_nfa_edge *next; enum rx_nfa_etype type; struct rx_nfa_state *dest; union { rx_Bitset cset; rx_side_effect side_effect; } params; }; struct rx_nfa_state_set { struct rx_nfa_state * car; struct rx_nfa_state_set * cdr; }; struct rx_possible_future { struct rx_possible_future *next; struct rx_se_list * effects; struct rx_nfa_state_set * destset; }; enum rx_opcode { /* * BACKTRACK_POINT is invoked when a transition results in more * than one possible future. * * There is one occurence of this instruction per transition_class * structure; that occurence is only ever executed if the * transition_class contains a list of more than 1 edge. */ rx_backtrack_point = 0, /* data is (struct transition_class *) */ /* * RX_DO_SIDE_EFFECTS evaluates the side effects of an epsilon path. * There is one occurence of this instruction per rx_distinct_future. * This instruction is skipped if a rx_distinct_future has no side effects. */ rx_do_side_effects = rx_backtrack_point + 1, /* data is (struct rx_distinct_future *) */ /* * RX_CACHE_MISS instructions are stored in rx_distinct_futures whose * destination superstate has been reclaimed (or was never built). * It recomputes the destination superstate. * RX_CACHE_MISS is also stored in a superstate transition table before * any of its edges have been built. */ rx_cache_miss = rx_do_side_effects + 1, /* data is (struct rx_distinct_future *) */ /* * RX_NEXT_CHAR is called to consume the next character and take the * corresponding transition. This is the only instruction that uses * the DATA field of the instruction frame instead of DATA_2. * (see EXPLORE_FUTURE in regex.c). */ rx_next_char = rx_cache_miss + 1, /* data is (struct superstate *) */ /* RX_BACKTRACK indicates that a transition fails. */ rx_backtrack = rx_next_char + 1, /* no data */ /* * RX_ERROR_INX is stored only in places that should never be executed. */ rx_error_inx = rx_backtrack + 1, /* Not supposed to occur. */ rx_num_instructions = rx_error_inx + 1 }; /* An id_instruction_table holds the values stored in instruction * frames. The table is indexed by the enums declared above. */ extern void * rx_id_instruction_table[rx_num_instructions]; #if 0 /* Already declared way above. */ /* If the instruction is `rx_next_char' then data is valid. Otherwise it's 0 * and data_2 is valid. */ struct rx_inx { void * inx; void * data; void * data_2; }; #endif #ifndef RX_TAIL_ARRAY #define RX_TAIL_ARRAY 1 #endif /* A superstate corresponds to a set of nfa states. Those sets are * represented by STRUCT RX_SUPERSET. The constructors * guarantee that only one (shared) structure is created for a given set. */ struct rx_superset { int refs; struct rx_nfa_state * car; /* May or may not be a valid addr. */ int id; /* == car->id for the initial value of *car */ struct rx_superset * cdr; /* May be NULL or a live or semifreed super*/ /* If the corresponding superstate exists: */ struct rx_superstate * superstate; /* If this is a starting state (as built by re_search_2) * this points to the `struct rx'. The memory for these objects * is typed -- so even after they are freed it is safe to look * at this field (to check, in fact, if this was freed. */ struct rx * starts_for; struct rx_hash_item hash_item; }; #define rx_protect_superset(RX,CON) (++(CON)->refs) /* Every character occurs in at most one super edge per super-state. * But, that edge might have more than one option, indicating a point * of non-determinism. */ struct rx_super_edge { struct rx_super_edge *next; struct rx_inx rx_backtrack_frame; int cset_size; rx_Bitset cset; struct rx_distinct_future *options; }; /* A superstate is a set of nfa states (RX_SUPERSET) along * with a transition table. Superstates are built on demand and reclaimed * without warning. To protect a superstate, use LOCK_SUPERSTATE. */ struct rx_superstate { int rx_id; int locks; struct rx_superstate * next_recyclable; struct rx_superstate * prev_recyclable; struct rx_distinct_future * transition_refs; struct rx_superset * contents; struct rx_super_edge * edges; int is_semifree; int trans_size; struct rx_inx transitions[RX_TAIL_ARRAY]; /* cset sized */ }; struct rx_distinct_future { struct rx_distinct_future * next_same_super_edge[2]; struct rx_distinct_future * next_same_dest; struct rx_distinct_future * prev_same_dest; struct rx_superstate * present; /* source state */ struct rx_superstate * future; /* destination state */ struct rx_super_edge * edge; struct rx_inx future_frame; struct rx_inx side_effects_frame; struct rx_se_list * effects; }; #define rx_lock_superstate(R,S) ((S)->locks++) #define rx_unlock_superstate(R,S) (--(S)->locks) /* This page destined for rx.h */ struct rx_blocklist { struct rx_blocklist * next; int bytes; }; struct rx_freelist { struct rx_freelist * next; }; struct rx_cache; #ifdef __STDC__ typedef void (*rx_morecore_fn)(struct rx_cache *); #else typedef void (*rx_morecore_fn)(); #endif struct rx_cache { struct rx_hash_rules superset_hash_rules; /* Objects are allocated by incrementing a pointer that * scans across rx_blocklists. */ struct rx_blocklist * memory; struct rx_blocklist * memory_pos; int bytes_left; char * memory_addr; rx_morecore_fn morecore; /* Freelists. */ struct rx_freelist * free_superstates; struct rx_freelist * free_transition_classes; struct rx_freelist * free_discernable_futures; struct rx_freelist * free_supersets; struct rx_freelist * free_hash; /* Two sets of superstates -- those that are semifreed, and those * that are being used. */ struct rx_superstate * lru_superstate; struct rx_superstate * semifree_superstate; struct rx_superset * empty_superset; int superstates; int semifree_superstates; int hits; int misses; int superstates_allowed; int local_cset_size; void ** instruction_table; struct rx_hash superset_table; }; /* regex.h * * The remaining declarations replace regex.h. */ /* This is an array of error messages corresponding to the error codes. */ extern const char *re_error_msg[]; /* If any error codes are removed, changed, or added, update the `re_error_msg' table in regex.c. */ typedef enum { REG_NOERROR = 0, /* Success. */ REG_NOMATCH, /* Didn't find a match (for regexec). */ /* POSIX regcomp return error codes. (In the order listed in the standard.) */ REG_BADPAT, /* Invalid pattern. */ REG_ECOLLATE, /* Not implemented. */ REG_ECTYPE, /* Invalid character class name. */ REG_EESCAPE, /* Trailing backslash. */ REG_ESUBREG, /* Invalid back reference. */ REG_EBRACK, /* Unmatched left bracket. */ REG_EPAREN, /* Parenthesis imbalance. */ REG_EBRACE, /* Unmatched \{. */ REG_BADBR, /* Invalid contents of \{\}. */ REG_ERANGE, /* Invalid range end. */ REG_ESPACE, /* Ran out of memory. */ REG_BADRPT, /* No preceding re for repetition op. */ /* Error codes we've added. */ REG_EEND, /* Premature end. */ REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ } reg_errcode_t; /* The regex.c support, as a client of rx, defines a set of possible * side effects that can be added to the edge lables of nfa edges. * Here is the list of sidef effects in use. */ enum re_side_effects { #define RX_WANT_SE_DEFS 1 #undef RX_DEF_SE #undef RX_DEF_CPLX_SE #define RX_DEF_SE(IDEM, NAME, VALUE) NAME VALUE, #define RX_DEF_CPLX_SE(IDEM, NAME, VALUE) NAME VALUE, #include "rx.h" #undef RX_DEF_SE #undef RX_DEF_CPLX_SE #undef RX_WANT_SE_DEFS re_floogle_flap = 65533 }; /* These hold paramaters for the kinds of side effects that are possible * in the supported pattern languages. These include things like the * numeric bounds of {} operators and the index of paren registers for * subexpression measurement or backreferencing. */ struct re_se_params { enum re_side_effects se; int op1; int op2; }; typedef unsigned reg_syntax_t; struct re_pattern_buffer { struct rx rx; reg_syntax_t syntax; /* See below for syntax bit definitions. */ unsigned int no_sub:1; /* If set, don't return register offsets. */ unsigned int not_bol:1; /* If set, the anchors ('^' and '$') don't */ unsigned int not_eol:1; /* match at the ends of the string. */ unsigned int newline_anchor:1;/* If true, an anchor at a newline matches.*/ unsigned int least_subs:1; /* If set, and returning registers, return * as few values as possible. Only * backreferenced groups and group 0 (the whole * match) will be returned. */ /* If true, this says that the matcher should keep registers on its * backtracking stack. For many patterns, we can easily determine that * this isn't necessary. */ unsigned int match_regs_on_stack:1; unsigned int search_regs_on_stack:1; /* is_anchored and begbuf_only are filled in by rx_compile. */ unsigned int is_anchored:1; /* Anchorded by ^? */ unsigned int begbuf_only:1; /* Anchored to char position 0? */ /* If REGS_UNALLOCATED, allocate space in the `regs' structure * for `max (RE_NREGS, re_nsub + 1)' groups. * If REGS_REALLOCATE, reallocate space if necessary. * If REGS_FIXED, use what's there. */ #define REGS_UNALLOCATED 0 #define REGS_REALLOCATE 1 #define REGS_FIXED 2 unsigned int regs_allocated:2; /* Either a translate table to apply to all characters before * comparing them, or zero for no translation. The translation * is applied to a pattern when it is compiled and to a string * when it is matched. */ char * translate; /* If this is a valid pointer, it tells rx not to store the extents of * certain subexpressions (those corresponding to non-zero entries). * Passing 0x1 is the same as passing an array of all ones. Passing 0x0 * is the same as passing an array of all zeros. * The array should contain as many entries as their are subexps in the * regexp. */ char * syntax_parens; /* Number of subexpressions found by the compiler. */ size_t re_nsub; void * buffer; /* Malloced memory for the nfa. */ unsigned long allocated; /* Size of that memory. */ /* Pointer to a fastmap, if any, otherwise zero. re_search uses * the fastmap, if there is one, to skip over impossible * starting points for matches. */ char *fastmap; unsigned int fastmap_accurate:1; /* These three are internal. */ unsigned int can_match_empty:1; struct rx_nfa_state * start; /* The nfa starting state. */ /* This is the list of iterator bounds for {lo,hi} constructs. * The memory pointed to is part of the rx->buffer. */ struct re_se_params *se_params; /* This is a bitset representation of the fastmap. * This is a true fastmap that already takes the translate * table into account. */ rx_Bitset fastset; }; /* Type for byte offsets within the string. POSIX mandates this. */ typedef int regoff_t; /* This is the structure we store register match data in. See regex.texinfo for a full description of what registers match. */ struct re_registers { unsigned num_regs; regoff_t *start; regoff_t *end; }; typedef struct re_pattern_buffer regex_t; /* POSIX specification for registers. Aside from the different names than `re_registers', POSIX uses an array of structures, instead of a structure of arrays. */ typedef struct { regoff_t rm_so; /* Byte offset from string's start to substring's start. */ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ } regmatch_t; /* The following bits are used to determine the regexp syntax we recognize. The set/not-set meanings are chosen so that Emacs syntax remains the value 0. The bits are given in alphabetical order, and the definitions shifted by one from the previous bit; thus, when we add or remove a bit, only one other definition need change. */ /* If this bit is not set, then \ inside a bracket expression is literal. If set, then such a \ quotes the following character. */ #define RE_BACKSLASH_ESCAPE_IN_LISTS (1) /* If this bit is not set, then + and ? are operators, and \+ and \? are literals. If set, then \+ and \? are operators and + and ? are literals. */ #define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) /* If this bit is set, then character classes are supported. They are: [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. If not set, then character classes are not supported. */ #define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) /* If this bit is set, then ^ and $ are always anchors (outside bracket expressions, of course). If this bit is not set, then it depends: ^ is an anchor if it is at the beginning of a regular expression or after an open-group or an alternation operator; $ is an anchor if it is at the end of a regular expression, or before a close-group or an alternation operator. This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because POSIX draft 11.2 says that * etc. in leading positions is undefined. We already implemented a previous draft which made those constructs invalid, though, so we haven't changed the code back. */ #define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) /* If this bit is set, then special characters are always special regardless of where they are in the pattern. If this bit is not set, then special characters are special only in some contexts; otherwise they are ordinary. Specifically, * + ? and intervals are only special when not after the beginning, open-group, or alternation operator. */ #define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) /* If this bit is set, then *, +, ?, and { cannot be first in an re or immediately after an alternation or begin-group operator. */ #define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) /* If this bit is set, then . matches newline. If not set, then it doesn't. */ #define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) /* If this bit is set, then . doesn't match NUL. If not set, then it does. */ #define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) /* If this bit is set, nonmatching lists [^...] do not match newline. If not set, they do. */ #define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) /* If this bit is set, either \{...\} or {...} defines an interval, depending on RE_NO_BK_BRACES. If not set, \{, \}, {, and } are literals. */ #define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) /* If this bit is set, +, ? and | aren't recognized as operators. If not set, they are. */ #define RE_LIMITED_OPS (RE_INTERVALS << 1) /* If this bit is set, newline is an alternation operator. If not set, newline is literal. */ #define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) /* If this bit is set, then `{...}' defines an interval, and \{ and \} are literals. If not set, then `\{...\}' defines an interval. */ #define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) /* If this bit is set, (...) defines a group, and \( and \) are literals. If not set, \(...\) defines a group, and ( and ) are literals. */ #define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) /* If this bit is set, then \ matches . If not set, then \ is a back-reference. */ #define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) /* If this bit is set, then | is an alternation operator, and \| is literal. If not set, then \| is an alternation operator, and | is literal. */ #define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) /* If this bit is set, then an ending range point collating higher than the starting range point, as in [z-a], is invalid. If not set, then when ending range point collates higher than the starting range point, the range is ignored. */ #define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) /* If this bit is set, then an unmatched ) is ordinary. If not set, then an unmatched ) is invalid. */ #define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) /* This global variable defines the particular regexp syntax to use (for some interfaces). When a regexp is compiled, the syntax used is stored in the pattern buffer, so changing this does not affect already-compiled regexps. */ extern reg_syntax_t re_syntax_options; /* Define combinations of the above bits for the standard possibilities. (The [[[ comments delimit what gets put into the Texinfo file, so don't delete them!) */ /* [[[begin syntaxes]]] */ #define RE_SYNTAX_EMACS 0 #define RE_SYNTAX_AWK \ (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ | RE_NO_BK_PARENS | RE_NO_BK_REFS \ | RE_NO_BK_VAR | RE_NO_EMPTY_RANGES \ | RE_UNMATCHED_RIGHT_PAREN_ORD) #define RE_SYNTAX_POSIX_AWK \ (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) #define RE_SYNTAX_GREP \ (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ | RE_NEWLINE_ALT) #define RE_SYNTAX_EGREP \ (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ | RE_NO_BK_VBAR) #define RE_SYNTAX_POSIX_EGREP \ (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) #define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC /* Syntax bits common to both basic and extended POSIX regex syntax. */ #define _RE_SYNTAX_POSIX_COMMON \ (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ | RE_INTERVALS | RE_NO_EMPTY_RANGES) #define RE_SYNTAX_POSIX_BASIC \ (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) /* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this isn't minimal, since other operators, such as \`, aren't disabled. */ #define RE_SYNTAX_POSIX_MINIMAL_BASIC \ (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) #define RE_SYNTAX_POSIX_EXTENDED \ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ | RE_UNMATCHED_RIGHT_PAREN_ORD) /* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ #define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ | RE_NO_BK_PARENS | RE_NO_BK_REFS \ | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) /* [[[end syntaxes]]] */ /* Maximum number of duplicates an interval can allow. Some systems (erroneously) define this in other header files, but we want our value, so remove any previous define. */ #ifdef RE_DUP_MAX #undef RE_DUP_MAX #endif #define RE_DUP_MAX ((1 << 15) - 1) /* POSIX `cflags' bits (i.e., information for `regcomp'). */ /* If this bit is set, then use extended regular expression syntax. If not set, then use basic regular expression syntax. */ #define REG_EXTENDED 1 /* If this bit is set, then ignore case when matching. If not set, then case is significant. */ #define REG_ICASE (REG_EXTENDED << 1) /* If this bit is set, then anchors do not match at newline characters in the string. If not set, then anchors do match at newlines. */ #define REG_NEWLINE (REG_ICASE << 1) /* If this bit is set, then report only success or fail in regexec. If not set, then returns differ between not matching and errors. */ #define REG_NOSUB (REG_NEWLINE << 1) /* POSIX `eflags' bits (i.e., information for regexec). */ /* If this bit is set, then the beginning-of-line operator doesn't match the beginning of the string (presumably because it's not the beginning of a line). If not set, then the beginning-of-line operator does match the beginning of the string. */ #define REG_NOTBOL 1 /* Like REG_NOTBOL, except for the end-of-line. */ #define REG_NOTEOL (1 << 1) /* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, * `re_match_2' returns information about at least this many registers * the first time a `regs' structure is passed. * * Also, this is the greatest number of backreferenced subexpressions * allowed in a pattern being matched without caller-supplied registers. */ #ifndef RE_NREGS #define RE_NREGS 30 #endif extern int rx_cache_bound; extern reg_errcode_t rx_compile __P ((__const char *__pattern, int __size, reg_syntax_t __syntax, struct re_pattern_buffer * __rxb)); /* Search in the string STRING (with length LENGTH) for the pattern compiled into BUFFER. Start searching at position START, for RANGE characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ extern int re_search __P ((struct re_pattern_buffer *__buffer, __const char *__string, int __length, int __start, int __range, struct re_registers *__regs)); /* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ extern int re_search_2 __P ((struct re_pattern_buffer *__buffer, __const char *__string1, int __length1, __const char *__string2, int __length2, int __start, int __range, struct re_registers *__regs, int __stop)); /* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ extern int re_match __P ((struct re_pattern_buffer *__buffer, __const char *__string, int __length, int __start, struct re_registers *__regs)); /* Relates to `re_match' as `re_search_2' relates to `re_search'. */ extern int re_match_2 __P ((struct re_pattern_buffer *__buffer, __const char *__string1, int __length1, __const char *__string2, int __length2, int __start, struct re_registers *__regs, int __stop)); /* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ extern reg_syntax_t re_set_syntax __P ((reg_syntax_t __syntax)); /* Set REGS to hold NUM_REGS registers, storing them in STARTS and ENDS. Subsequent matches using BUFFER and REGS will use this memory for recording register information. STARTS and ENDS must be allocated with malloc, and must each be at least `NUM_REGS * sizeof (regoff_t)' bytes long. If NUM_REGS == 0, then subsequent matches should allocate their own register data. Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ extern void re_set_registers __P ((struct re_pattern_buffer *__buffer, struct re_registers *__regs, unsigned __num_regs, regoff_t *__starts, regoff_t *__ends)); /* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ extern __const char *re_compile_pattern __P ((__const char *__pattern, int __length, struct re_pattern_buffer *__buffer)); /* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ extern int re_compile_fastmap __P ((struct re_pattern_buffer *__buffer)); /* 4.2 bsd compatibility. */ extern char *re_comp __P ((__const char *__s)); extern int re_exec __P ((__const char *__s)); /* POSIX compatibility. */ extern int regcomp __P ((regex_t *__preg, __const char *__pattern, int __cflags)); extern int regexec __P ((__const regex_t *__preg, __const char *__string, size_t __nmatch, regmatch_t __pmatch[], int __eflags)); extern size_t regerror __P ((int __errcode, __const regex_t *__preg, char *__errbuf, size_t __errbuf_size)); extern void regfree __P ((regex_t *__preg)); __END_DECLS #else /* RX_WANT_SE_DEFS */ /* Integers are used to represent side effects. * * Simple side effects are given negative integer names by these enums. * * Non-negative names are reserved for complex effects. * * Complex effects are those that take arguments. For example, * a register assignment associated with a group is complex because * it requires an argument to tell which group is being matched. * * The integer name of a complex effect is an index into rxb->se_params. */ RX_DEF_SE(1, re_se_try, = -1) /* Epsilon from start state */ RX_DEF_SE(0, re_se_pushback, = re_se_try - 1) RX_DEF_SE(0, re_se_push0, = re_se_pushback -1) RX_DEF_SE(0, re_se_pushpos, = re_se_push0 - 1) RX_DEF_SE(0, re_se_chkpos, = re_se_pushpos -1) RX_DEF_SE(0, re_se_poppos, = re_se_chkpos - 1) RX_DEF_SE(1, re_se_at_dot, = re_se_poppos - 1) /* Emacs only */ RX_DEF_SE(0, re_se_syntax, = re_se_at_dot - 1) /* Emacs only */ RX_DEF_SE(0, re_se_not_syntax, = re_se_syntax - 1) /* Emacs only */ RX_DEF_SE(1, re_se_begbuf, = re_se_not_syntax - 1) /* match beginning of buffer */ RX_DEF_SE(1, re_se_hat, = re_se_begbuf - 1) /* match beginning of line */ RX_DEF_SE(1, re_se_wordbeg, = re_se_hat - 1) RX_DEF_SE(1, re_se_wordbound, = re_se_wordbeg - 1) RX_DEF_SE(1, re_se_notwordbound, = re_se_wordbound - 1) RX_DEF_SE(1, re_se_wordend, = re_se_notwordbound - 1) RX_DEF_SE(1, re_se_endbuf, = re_se_wordend - 1) /* This fails except at the end of a line. * It deserves to go here since it is typicly one of the last steps * in a match. */ RX_DEF_SE(1, re_se_dollar, = re_se_endbuf - 1) /* Simple effects: */ RX_DEF_SE(1, re_se_fail, = re_se_dollar - 1) /* Complex effects. These are used in the 'se' field of * a struct re_se_params. Indexes into the se array * are stored as instructions on nfa edges. */ RX_DEF_CPLX_SE(1, re_se_win, = 0) RX_DEF_CPLX_SE(1, re_se_lparen, = re_se_win + 1) RX_DEF_CPLX_SE(1, re_se_rparen, = re_se_lparen + 1) RX_DEF_CPLX_SE(0, re_se_backref, = re_se_rparen + 1) RX_DEF_CPLX_SE(0, re_se_iter, = re_se_backref + 1) RX_DEF_CPLX_SE(0, re_se_end_iter, = re_se_iter + 1) RX_DEF_CPLX_SE(0, re_se_tv, = re_se_end_iter + 1) #endif #endif ./libc-linux/regex/ChangeLog.rx100644 1676 334 4261 5520507236 14437 0ustar hjlisl------ version 0.03 ------ Fri Aug 6 01:57:28 1993 Tom Lord (lord@unix1.andrew.cmu.edu) * rx.c (re_search_2): sped up the fastmap search a little to as to not be slower than regex.c on simple patterns. Rx will still lose by a couple instructions in some degenerate cases but mostly will win. Thu Aug 5 11:39:57 1993 Tom Lord (lord@thisbe.weh.andrew.cmu.edu) * rx.c (re_search_2 & compilation front-ends): cache the starting superset of super-nfa's so that it isn't necessary to do an eclosure union for every call to re_search_2. * rx.c (re_search_2): (from Eric Backus) arrange to call alloca(0) from a shallower stack frame than re_search_2 if callling it at all. This could use a better cpp test. Right now, an extra function call is added to re_search_2 unles __GNUC__ is defined. If there were something like _HAVE_LOSER_ALLOCA_.... * rx.c (rx_compile, re_search_2, several new fns): changed the order of side effect lists so that possible futures that begin with complex effects more to the right are explored after futures more to the left. Added a noop complex effect to alts and stars to guarantee they are explored in the right order. An optimization after the parse removes some from the alts (and not all stars get them in the first place). Changed the `best match' criterea -- now that possible futures are ordered posixly, we only want to check the length of the match. For a given length, the best subexpression partitioning is the first one found. A side effect of this is that Rx will always return the same register assignements for a given regexp/input text. Bummer :-) / 2. ------ version 0.02 ------ ed Jul 21 13:10:56 1993 Tom Lord (lord@unix8.andrew.cmu.edu) * rx.c (re_search_2): elaborated on the rule for picking the best match so that the lengths of subexpressions are taken into account. This is for Posix compatability. ------ version 0.01 ------ Sun Jun 13 17:20:35 1993 Tom Lord (lord@tsunami.ucc.andrew.cmu.edu) * This is the first release of rx.c. Although some of the code is derived from regex.c, there is not much continuity between the two implementations. ./libc-linux/yp/ 40755 1676 334 0 5550056204 11450 5ustar hjlisl./libc-linux/yp/Makefile100644 1676 334 376 5515544623 13203 0ustar hjlisl# # This is Makefile for YP functions. # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I. DIRS:= SRCS = xdryp.c xdryppasswd.c yplib.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/yp/xdryp.c100644 1676 334 21012 5511750365 13101 0ustar hjlisl/* * Copyright (c) 1992/3 Theo de Raadt * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. */ #ifndef LINT static char *rcsid = "xdryp.c,v 2.1 1994/01/03 08:01:57 swen Exp"; #endif #include #include #include #include #include #include #include #include #include extern int (*ypresp_allfn) __P ((int, char *, int, char *, int, char *)); extern void *ypresp_data; bool_t xdr_domainname (xdrs, objp) XDR *xdrs; char *objp; { if (!xdr_string (xdrs, &objp, YPMAXDOMAIN)) { return (FALSE); } return (TRUE); } bool_t xdr_peername (xdrs, objp) XDR *xdrs; char *objp; { if (!xdr_string (xdrs, &objp, YPMAXPEER)) { return (FALSE); } return (TRUE); } bool_t xdr_datum (xdrs, objp) XDR *xdrs; datum *objp; { if (!xdr_bytes (xdrs, (char **) &objp->dptr, (u_int *) & objp->dsize, YPMAXRECORD)) { return (FALSE); } return (TRUE); } bool_t xdr_mapname (xdrs, objp) XDR *xdrs; char *objp; { if (!xdr_string (xdrs, &objp, YPMAXMAP)) { return (FALSE); } return (TRUE); } bool_t xdr_ypreq_key (xdrs, objp) XDR *xdrs; struct ypreq_key *objp; { if (!xdr_domainname (xdrs, objp->domain)) { return (FALSE); } if (!xdr_mapname (xdrs, objp->map)) { return (FALSE); } if (!xdr_datum (xdrs, &objp->keydat)) { return (FALSE); } return (TRUE); } bool_t xdr_ypreq_nokey (xdrs, objp) XDR *xdrs; struct ypreq_nokey *objp; { if (!xdr_domainname (xdrs, objp->domain)) { return (FALSE); } if (!xdr_mapname (xdrs, objp->map)) { return (FALSE); } return (TRUE); } bool_t xdr_yp_inaddr (xdrs, objp) XDR *xdrs; struct in_addr *objp; { if (!xdr_opaque (xdrs, (caddr_t) & objp->s_addr, sizeof objp->s_addr)) { return (FALSE); } return (TRUE); } bool_t xdr_ypbind_binding (xdrs, objp) XDR *xdrs; struct ypbind_binding *objp; { if (!xdr_yp_inaddr (xdrs, &objp->ypbind_binding_addr)) { return (FALSE); } if (!xdr_opaque (xdrs, (void *) &objp->ypbind_binding_port, sizeof objp->ypbind_binding_port)) { return (FALSE); } return (TRUE); } bool_t xdr_ypbind_resptype (xdrs, objp) XDR *xdrs; enum ypbind_resptype *objp; { if (!xdr_enum (xdrs, (enum_t *) objp)) { return (FALSE); } return (TRUE); } bool_t xdr_ypstat (xdrs, objp) XDR *xdrs; enum ypbind_resptype *objp; { if (!xdr_enum (xdrs, (enum_t *) objp)) { return (FALSE); } return (TRUE); } bool_t xdr_ypbind_resp (xdrs, objp) XDR *xdrs; struct ypbind_resp *objp; { if (!xdr_ypbind_resptype (xdrs, &objp->ypbind_status)) { return (FALSE); } switch (objp->ypbind_status) { case YPBIND_FAIL_VAL: if (!xdr_u_int (xdrs, (u_int *) & objp->ypbind_respbody.ypbind_error)) { return (FALSE); } break; case YPBIND_SUCC_VAL: if (!xdr_ypbind_binding (xdrs, &objp->ypbind_respbody.ypbind_bindinfo)) { return (FALSE); } break; default: return (FALSE); } return (TRUE); } bool_t xdr_ypresp_val (xdrs, objp) XDR *xdrs; struct ypresp_val *objp; { if (!xdr_ypstat (xdrs, &objp->status)) { return (FALSE); } if (!xdr_datum (xdrs, &objp->valdat)) { return (FALSE); } return (TRUE); } bool_t xdr_ypbind_setdom (xdrs, objp) XDR *xdrs; struct ypbind_setdom *objp; { if (!xdr_domainname (xdrs, objp->ypsetdom_domain)) { return (FALSE); } if (!xdr_ypbind_binding (xdrs, &objp->ypsetdom_binding)) { return (FALSE); } if (!xdr_u_short (xdrs, &objp->ypsetdom_vers)) { return (FALSE); } return (TRUE); } bool_t xdr_ypresp_key_val (xdrs, objp) XDR *xdrs; struct ypresp_key_val *objp; { if (!xdr_ypstat (xdrs, &objp->status)) { return (FALSE); } if (!xdr_datum (xdrs, &objp->valdat)) { return (FALSE); } if (!xdr_datum (xdrs, &objp->keydat)) { return (FALSE); } return (TRUE); } bool_t xdr_ypresp_all (xdrs, objp) XDR *xdrs; struct ypresp_all *objp; { if (!xdr_bool (xdrs, &objp->more)) { return (FALSE); } switch (objp->more) { case TRUE: if (!xdr_ypresp_key_val (xdrs, &objp->ypresp_all_u.val)) { return (FALSE); } break; case FALSE: break; default: return (FALSE); } return (TRUE); } bool_t xdr_ypresp_all_seq (xdrs, objp) XDR *xdrs; u_long *objp; { struct ypresp_all out; u_long status; char *key, *val; int r; bzero (&out, sizeof out); while (1) { if (!xdr_ypresp_all (xdrs, &out)) { xdr_free (xdr_ypresp_all, (char *) &out); *objp = YP_YPERR; return FALSE; } if (out.more == 0) { xdr_free (xdr_ypresp_all, (char *) &out); return FALSE; } status = out.ypresp_all_u.val.status; switch (status) { case YP_TRUE: key = (char *) malloc (out.ypresp_all_u.val.keydat.dsize + 1); bcopy (out.ypresp_all_u.val.keydat.dptr, key, out.ypresp_all_u.val.keydat.dsize); key[out.ypresp_all_u.val.keydat.dsize] = '\0'; val = (char *) malloc (out.ypresp_all_u.val.valdat.dsize + 1); bcopy (out.ypresp_all_u.val.valdat.dptr, val, out.ypresp_all_u.val.valdat.dsize); val[out.ypresp_all_u.val.valdat.dsize] = '\0'; xdr_free (xdr_ypresp_all, (char *) &out); r = (*ypresp_allfn) (status, key, out.ypresp_all_u.val.keydat.dsize, val, out.ypresp_all_u.val.valdat.dsize, ypresp_data); *objp = status; free (key); free (val); if (r) return TRUE; break; case YP_NOMORE: xdr_free (xdr_ypresp_all, (char *) &out); return TRUE; default: xdr_free (xdr_ypresp_all, (char *) &out); *objp = status; return TRUE; } } } bool_t xdr_ypresp_master (xdrs, objp) XDR *xdrs; struct ypresp_master *objp; { if (!xdr_ypstat (xdrs, &objp->status)) { return (FALSE); } if (!xdr_string (xdrs, &objp->master, YPMAXPEER)) { return (FALSE); } return (TRUE); } bool_t xdr_ypmaplist_str (xdrs, objp) XDR *xdrs; char *objp; { if (!xdr_string (xdrs, &objp, YPMAXMAP + 1)) { return (FALSE); } return (TRUE); } bool_t xdr_ypmaplist (xdrs, objp) XDR *xdrs; struct ypmaplist *objp; { if (!xdr_ypmaplist_str (xdrs, objp->ypml_name)) { return (FALSE); } if (!xdr_pointer (xdrs, (caddr_t *) & objp->ypml_next, sizeof (struct ypmaplist), xdr_ypmaplist)) { return (FALSE); } return (TRUE); } bool_t xdr_ypresp_maplist (xdrs, objp) XDR *xdrs; struct ypresp_maplist *objp; { if (!xdr_ypstat (xdrs, &objp->status)) { return (FALSE); } if (!xdr_pointer (xdrs, (caddr_t *) & objp->list, sizeof (struct ypmaplist), xdr_ypmaplist)) { return (FALSE); } return (TRUE); } bool_t xdr_ypresp_order (xdrs, objp) XDR *xdrs; struct ypresp_order *objp; { if (!xdr_ypstat (xdrs, &objp->status)) { return (FALSE); } if (!xdr_u_long (xdrs, &objp->ordernum)) { return (FALSE); } return (TRUE); } ./libc-linux/yp/xdryppasswd.c100644 1676 334 4442 5443606603 14312 0ustar hjlisl/* * Copyright (c) 1992/3 Theo de Raadt * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. */ #include #include #include bool_t xdr_passwd(xdrs, objp) XDR *xdrs; yp_passwd_rec *objp; { if (!xdr_string(xdrs, &objp->pw_name, ~0)) { return (FALSE); } if (!xdr_string(xdrs, &objp->pw_passwd, ~0)) { return (FALSE); } if (!xdr_int(xdrs, &objp->pw_uid)) { return (FALSE); } if (!xdr_int(xdrs, &objp->pw_gid)) { return (FALSE); } if (!xdr_string(xdrs, &objp->pw_gecos, ~0)) { return (FALSE); } if (!xdr_string(xdrs, &objp->pw_dir, ~0)) { return (FALSE); } if (!xdr_string(xdrs, &objp->pw_shell, ~0)) { return (FALSE); } return (TRUE); } bool_t xdr_yppasswd(xdrs, objp) XDR *xdrs; yppasswd *objp; { if (!xdr_string(xdrs, &objp->oldpass, ~0)) { return (FALSE); } if (!xdr_passwd(xdrs, &objp->newpw)) { return (FALSE); } return (TRUE); } ./libc-linux/yp/yplib.c100644 1676 334 45751 5511750366 13073 0ustar hjlisl/* * Copyright (c) 1992/3 Theo de Raadt * 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. The name of the author may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. */ #ifndef LINT static char *rcsid = "yplib.c,v 2.1 1994/01/03 08:01:58 swen Exp"; #endif #include #include #include #include #include #include #include #include #include #include #include #include #ifndef BINDINGDIR #define BINDINGDIR "/var/yp/binding" #endif #define YPMATCHCACHE extern bool_t xdr_domainname __P ((XDR *, char *)); extern bool_t xdr_ypresp_all __P ((XDR *, struct ypresp_all *)); extern bool_t xdr_ypresp_all_seq __P ((XDR *, u_long *)); int (*ypresp_allfn) __P ((int, char *, int, char *, int, char *)); void *ypresp_data; static void ypmatch_add __P ((char *, char *, int, char *, int)); static bool_t ypmatch_find __P ((char *, char *, int, char **, int *)); int __yp_dobind __P ((char *, struct dom_binding **)); static void __yp_unbind __P ((struct dom_binding *)); int __yp_check __P ((char **)); struct dom_binding *__ypbindlist; static char __yp_domain[MAXHOSTNAMELEN]; int __yplib_timeout = 10; #ifdef YPMATCHCACHE int __yplib_cache = 5; static struct ypmatch_ent { struct ypmatch_ent *next; char *map, *key, *val; int keylen, vallen; time_t expire_t; } *ypmc; static void ypmatch_add (map, key, keylen, val, vallen) char *map; char *key; int keylen; char *val; int vallen; { struct ypmatch_ent *ep; time_t t; time (&t); for (ep = ypmc; ep; ep = ep->next) if (ep->expire_t < t) break; if (ep == NULL) { ep = (struct ypmatch_ent *) malloc (sizeof *ep); bzero ((char *) ep, sizeof *ep); if (ypmc) ep->next = ypmc; ypmc = ep; } if (ep->key) free (ep->key); if (ep->val) free (ep->val); ep->key = NULL; ep->val = NULL; ep->key = (char *) malloc (keylen); if (ep->key == NULL) return; ep->val = (char *) malloc (vallen); if (ep->key == NULL) { free (ep->key); ep->key = NULL; return; } ep->keylen = keylen; ep->vallen = vallen; bcopy (key, ep->key, ep->keylen); bcopy (val, ep->val, ep->vallen); if (ep->map) { if (strcmp (ep->map, map)) { free (ep->map); ep->map = strdup (map); } } else { ep->map = strdup (map); } ep->expire_t = t + __yplib_cache; } static bool_t ypmatch_find (map, key, keylen, val, vallen) char *map; char *key; int keylen; char **val; int *vallen; { struct ypmatch_ent *ep; time_t t; if (ypmc == NULL) return 0; time (&t); for (ep = ypmc; ep; ep = ep->next) { if (ep->keylen != keylen) continue; if (strcmp (ep->map, map)) continue; if (bcmp (ep->key, key, keylen)) continue; if (t > ep->expire_t) continue; *val = ep->val; *vallen = ep->vallen; return 1; } return 0; } #endif int __yp_dobind (dom, ypdb) char *dom; struct dom_binding **ypdb; { static int pid = -1; char path[MAXPATHLEN]; struct dom_binding *ysd, *ysd2; struct ypbind_resp ypbr; struct timeval tv; struct sockaddr_in clnt_sin; int clnt_sock, fd, gpid; CLIENT *client; int new = 0, r; gpid = getpid (); if (!(pid == -1 || pid == gpid)) { ysd = __ypbindlist; while (ysd) { if (ysd->dom_client) clnt_destroy (ysd->dom_client); ysd2 = ysd->dom_pnext; free (ysd); ysd = ysd2; } __ypbindlist = NULL; } pid = gpid; if (ypdb != NULL) *ypdb = NULL; if (dom == NULL || strlen (dom) == 0) return YPERR_BADARGS; for (ysd = __ypbindlist; ysd; ysd = ysd->dom_pnext) if (strcmp (dom, ysd->dom_domain) == 0) break; if (ysd == NULL) { ysd = (struct dom_binding *) malloc (sizeof *ysd); bzero ((char *) ysd, sizeof *ysd); ysd->dom_socket = -1; ysd->dom_vers = 0; new = 1; } again: #ifdef BINDINGDIR if (ysd->dom_vers == 0) { sprintf (path, "%s/%s.%d", BINDINGDIR, dom, 2); if ((fd = open (path, O_RDONLY)) == -1) { /* no binding file, YP is dead. */ if (new) free (ysd); return YPERR_YPBIND; } if (flock (fd, LOCK_EX | LOCK_NB) == -1 && errno == EWOULDBLOCK) { struct iovec iov[2]; struct ypbind_resp ybr; u_short ypb_port; iov[0].iov_base = (caddr_t) & ypb_port; iov[0].iov_len = sizeof ypb_port; iov[1].iov_base = (caddr_t) & ybr; iov[1].iov_len = sizeof ybr; r = readv (fd, iov, 2); if (r != iov[0].iov_len + iov[1].iov_len) { close (fd); ysd->dom_vers = -1; goto again; } bzero (&ysd->dom_server_addr, sizeof ysd->dom_server_addr); ysd->dom_server_addr.sin_family = AF_INET; ysd->dom_server_addr.sin_addr = ybr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr; ysd->dom_server_addr.sin_port = ybr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_port; ysd->dom_server_port = ysd->dom_server_addr.sin_port; close (fd); goto gotit; } else { /* no lock on binding file, YP is dead. */ close (fd); if (new) free (ysd); return YPERR_YPBIND; } } #endif if (ysd->dom_vers == -1 || ysd->dom_vers == 0) { bzero ((char *) &clnt_sin, sizeof clnt_sin); clnt_sin.sin_family = AF_INET; clnt_sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK); clnt_sock = RPC_ANYSOCK; client = clnttcp_create (&clnt_sin, YPBINDPROG, YPBINDVERS, &clnt_sock, 0, 0); if (client == NULL) { clnt_pcreateerror ("clnttcp_create"); if (new) free (ysd); return YPERR_YPBIND; } tv.tv_sec = __yplib_timeout; tv.tv_usec = 0; r = clnt_call (client, YPBINDPROC_DOMAIN, xdr_domainname, dom, xdr_ypbind_resp, &ypbr, tv); if (r != RPC_SUCCESS) { fprintf (stderr, "YP: server for domain %s not responding, still trying\n", dom); clnt_destroy (client); ysd->dom_vers = -1; goto again; } clnt_destroy (client); bzero ((char *) &ysd->dom_server_addr, sizeof ysd->dom_server_addr); ysd->dom_server_addr.sin_family = AF_INET; ysd->dom_server_addr.sin_port = ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_port; ysd->dom_server_addr.sin_addr.s_addr = ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_addr.s_addr; ysd->dom_server_port = ypbr.ypbind_respbody.ypbind_bindinfo.ypbind_binding_port; gotit: ysd->dom_vers = YPVERS; strcpy (ysd->dom_domain, dom); } tv.tv_sec = __yplib_timeout / 2; tv.tv_usec = 0; if (ysd->dom_client) clnt_destroy (ysd->dom_client); ysd->dom_socket = RPC_ANYSOCK; ysd->dom_client = clntudp_create (&ysd->dom_server_addr, YPPROG, YPVERS, tv, &ysd->dom_socket); if (ysd->dom_client == NULL) { clnt_pcreateerror ("clntudp_create"); ysd->dom_vers = -1; goto again; } if (fcntl (ysd->dom_socket, F_SETFD, 1) == -1) perror ("fcntl: F_SETFD"); if (new) { ysd->dom_pnext = __ypbindlist; __ypbindlist = ysd; } if (ypdb != NULL) *ypdb = ysd; return 0; } static void __yp_unbind (ypb) struct dom_binding *ypb; { clnt_destroy (ypb->dom_client); ypb->dom_client = NULL; ypb->dom_socket = -1; } int yp_bind (dom) char *dom; { return __yp_dobind (dom, NULL); } void yp_unbind (dom) char *dom; { struct dom_binding *ypb, *ypbp; ypbp = NULL; for (ypb = __ypbindlist; ypb; ypb = ypb->dom_pnext) { if (strcmp (dom, ypb->dom_domain) == 0) { clnt_destroy (ypb->dom_client); if (ypbp) ypbp->dom_pnext = ypb->dom_pnext; else __ypbindlist = ypb->dom_pnext; free (ypb); return; } ypbp = ypb; } return; } int yp_match (indomain, inmap, inkey, inkeylen, outval, outvallen) char *indomain; char *inmap; char *inkey; int inkeylen; char **outval; int *outvallen; { struct dom_binding *ysd; struct ypresp_val yprv; struct timeval tv; struct ypreq_key yprk; int r; *outval = NULL; *outvallen = 0; again: if (__yp_dobind (indomain, &ysd) != 0) return YPERR_DOMAIN; #ifdef YPMATCHCACHE if (!strcmp (__yp_domain, indomain) && ypmatch_find (inmap, inkey, inkeylen, &yprv.valdat.dptr, &yprv.valdat.dsize)) { *outvallen = yprv.valdat.dsize; *outval = (char *) malloc (*outvallen + 1); bcopy (yprv.valdat.dptr, *outval, *outvallen); (*outval)[*outvallen] = '\0'; return 0; } #endif tv.tv_sec = __yplib_timeout; tv.tv_usec = 0; yprk.domain = indomain; yprk.map = inmap; yprk.keydat.dptr = inkey; yprk.keydat.dsize = inkeylen; bzero ((char *) &yprv, sizeof yprv); r = clnt_call (ysd->dom_client, YPPROC_MATCH, xdr_ypreq_key, &yprk, xdr_ypresp_val, &yprv, tv); if (r != RPC_SUCCESS) { clnt_perror (ysd->dom_client, "yp_match: clnt_call"); ysd->dom_vers = -1; goto again; } if (!(r = ypprot_err (yprv.status))) { *outvallen = yprv.valdat.dsize; *outval = (char *) malloc (*outvallen + 1); bcopy (yprv.valdat.dptr, *outval, *outvallen); (*outval)[*outvallen] = '\0'; #ifdef YPMATCHCACHE if (strcmp (__yp_domain, indomain) == 0) ypmatch_add (inmap, inkey, inkeylen, *outval, *outvallen); #endif } xdr_free (xdr_ypresp_val, (char *) &yprv); __yp_unbind (ysd); return r; } int yp_get_default_domain (domp) char **domp; { *domp = NULL; if (__yp_domain[0] == '\0') if (getdomainname (__yp_domain, sizeof __yp_domain)) return YPERR_NODOM; *domp = __yp_domain; return 0; } int yp_first (indomain, inmap, outkey, outkeylen, outval, outvallen) char *indomain; char *inmap; char **outkey; int *outkeylen; char **outval; int *outvallen; { struct ypresp_key_val yprkv; struct ypreq_nokey yprnk; struct dom_binding *ysd; struct timeval tv; int r; *outkey = *outval = NULL; *outkeylen = *outvallen = 0; again: if (__yp_dobind (indomain, &ysd) != 0) return YPERR_DOMAIN; tv.tv_sec = __yplib_timeout; tv.tv_usec = 0; yprnk.domain = indomain; yprnk.map = inmap; bzero ((char *) &yprkv, sizeof yprkv); r = clnt_call (ysd->dom_client, YPPROC_FIRST, xdr_ypreq_nokey, &yprnk, xdr_ypresp_key_val, &yprkv, tv); if (r != RPC_SUCCESS) { clnt_perror (ysd->dom_client, "yp_first: clnt_call"); ysd->dom_vers = -1; goto again; } if (!(r = ypprot_err (yprkv.status))) { *outkeylen = yprkv.keydat.dsize; *outkey = (char *) malloc (*outkeylen + 1); bcopy (yprkv.keydat.dptr, *outkey, *outkeylen); (*outkey)[*outkeylen] = '\0'; *outvallen = yprkv.valdat.dsize; *outval = (char *) malloc (*outvallen + 1); bcopy (yprkv.valdat.dptr, *outval, *outvallen); (*outval)[*outvallen] = '\0'; } xdr_free (xdr_ypresp_key_val, (char *) &yprkv); __yp_unbind (ysd); return r; } int yp_next (indomain, inmap, inkey, inkeylen, outkey, outkeylen, outval, outvallen) char *indomain; char *inmap; char *inkey; int inkeylen; char **outkey; int *outkeylen; char **outval; int *outvallen; { struct ypresp_key_val yprkv; struct ypreq_key yprk; struct dom_binding *ysd; struct timeval tv; int r; *outkey = *outval = NULL; *outkeylen = *outvallen = 0; again: if (__yp_dobind (indomain, &ysd) != 0) return YPERR_DOMAIN; tv.tv_sec = __yplib_timeout; tv.tv_usec = 0; yprk.domain = indomain; yprk.map = inmap; yprk.keydat.dptr = inkey; yprk.keydat.dsize = inkeylen; bzero ((char *) &yprkv, sizeof yprkv); r = clnt_call (ysd->dom_client, YPPROC_NEXT, xdr_ypreq_key, &yprk, xdr_ypresp_key_val, &yprkv, tv); if (r != RPC_SUCCESS) { clnt_perror (ysd->dom_client, "yp_next: clnt_call"); ysd->dom_vers = -1; goto again; } if (!(r = ypprot_err (yprkv.status))) { *outkeylen = yprkv.keydat.dsize; *outkey = (char *) malloc (*outkeylen + 1); bcopy (yprkv.keydat.dptr, *outkey, *outkeylen); (*outkey)[*outkeylen] = '\0'; *outvallen = yprkv.valdat.dsize; *outval = (char *) malloc (*outvallen + 1); bcopy (yprkv.valdat.dptr, *outval, *outvallen); (*outval)[*outvallen] = '\0'; } xdr_free (xdr_ypresp_key_val, (char *) &yprkv); __yp_unbind (ysd); return r; } int yp_all (indomain, inmap, incallback) char *indomain; char *inmap; struct ypall_callback *incallback; { struct ypreq_nokey yprnk; struct dom_binding *ysd; struct timeval tv; struct sockaddr_in clnt_sin; CLIENT *clnt; u_long status; int clnt_sock; if (__yp_dobind (indomain, &ysd) != 0) return YPERR_DOMAIN; tv.tv_sec = __yplib_timeout; tv.tv_usec = 0; clnt_sock = RPC_ANYSOCK; clnt_sin = ysd->dom_server_addr; clnt_sin.sin_port = 0; clnt = clnttcp_create (&clnt_sin, YPPROG, YPVERS, &clnt_sock, 0, 0); if (clnt == NULL) { printf ("clnttcp_create failed\n"); return YPERR_PMAP; } yprnk.domain = indomain; yprnk.map = inmap; ypresp_allfn = incallback->foreach; ypresp_data = (void *) incallback->data; (void) clnt_call (clnt, YPPROC_ALL, xdr_ypreq_nokey, &yprnk, xdr_ypresp_all_seq, &status, tv); clnt_destroy (clnt); xdr_free (xdr_ypresp_all_seq, (char *) &status); /* not really needed... */ __yp_unbind (ysd); if (status != YP_FALSE) return ypprot_err (status); return 0; } int yp_order (indomain, inmap, outorder) char *indomain; char *inmap; int *outorder; { struct dom_binding *ysd; struct ypresp_order ypro; struct ypreq_nokey yprnk; struct timeval tv; int r; again: if (__yp_dobind (indomain, &ysd) != 0) return YPERR_DOMAIN; tv.tv_sec = __yplib_timeout; tv.tv_usec = 0; yprnk.domain = indomain; yprnk.map = inmap; bzero ((char *) (char *) &ypro, sizeof ypro); r = clnt_call (ysd->dom_client, YPPROC_ORDER, xdr_ypreq_nokey, &yprnk, xdr_ypresp_order, &ypro, tv); if (r != RPC_SUCCESS) { clnt_perror (ysd->dom_client, "yp_order: clnt_call"); ysd->dom_vers = -1; goto again; } *outorder = ypro.ordernum; xdr_free (xdr_ypresp_order, (char *) &ypro); __yp_unbind (ysd); return ypprot_err (ypro.status); } int yp_master (indomain, inmap, outname) char *indomain; char *inmap; char **outname; { struct dom_binding *ysd; struct ypresp_master yprm; struct ypreq_nokey yprnk; struct timeval tv; int r; again: if (__yp_dobind (indomain, &ysd) != 0) return YPERR_DOMAIN; tv.tv_sec = __yplib_timeout; tv.tv_usec = 0; yprnk.domain = indomain; yprnk.map = inmap; bzero ((char *) &yprm, sizeof yprm); r = clnt_call (ysd->dom_client, YPPROC_MASTER, xdr_ypreq_nokey, &yprnk, xdr_ypresp_master, &yprm, tv); if (r != RPC_SUCCESS) { clnt_perror (ysd->dom_client, "yp_master: clnt_call"); ysd->dom_vers = -1; goto again; } if (!(r = ypprot_err (yprm.status))) { *outname = (char *) strdup (yprm.master); } xdr_free (xdr_ypresp_master, (char *) &yprm); __yp_unbind (ysd); return r; } int yp_maplist (indomain, outmaplist) char *indomain; struct ypmaplist **outmaplist; { struct dom_binding *ysd; struct ypresp_maplist ypml; struct timeval tv; int r; again: if (__yp_dobind (indomain, &ysd) != 0) return YPERR_DOMAIN; tv.tv_sec = __yplib_timeout; tv.tv_usec = 0; bzero ((char *) &ypml, sizeof ypml); r = clnt_call (ysd->dom_client, YPPROC_MAPLIST, xdr_domainname, indomain, xdr_ypresp_maplist, &ypml, tv); if (r != RPC_SUCCESS) { clnt_perror (ysd->dom_client, "yp_maplist: clnt_call"); ysd->dom_vers = -1; goto again; } *outmaplist = ypml.list; /* NO: xdr_free(xdr_ypresp_maplist, &ypml);*/ __yp_unbind (ysd); return ypprot_err (ypml.status); } char * yperr_string (incode) int incode; { static char err[80]; switch (incode) { case 0: return "Success"; case YPERR_BADARGS: return "Request arguments bad"; case YPERR_RPC: return "RPC failure"; case YPERR_DOMAIN: return "Can't bind to server which serves this domain"; case YPERR_MAP: return "No such map in server's domain"; case YPERR_KEY: return "No such key in map"; case YPERR_YPERR: return "YP server error"; case YPERR_RESRC: return "Local resource allocation failure"; case YPERR_NOMORE: return "No more records in map database"; case YPERR_PMAP: return "Can't communicate with portmapper"; case YPERR_YPBIND: return "Can't communicate with ypbind"; case YPERR_YPSERV: return "Can't communicate with ypserv"; case YPERR_NODOM: return "Local domain name not set"; case YPERR_BADDB: return "Server data base is bad"; case YPERR_VERS: return "YP server version mismatch - server can't supply service."; case YPERR_ACCESS: return "Access violation"; case YPERR_BUSY: return "Database is busy"; } sprintf (err, "YP unknown error %d\n", incode); return err; } int ypprot_err (incode) unsigned int incode; { switch (incode) { case YP_TRUE: return 0; case YP_FALSE: return YPERR_YPBIND; case YP_NOMORE: return YPERR_NOMORE; case YP_NOMAP: return YPERR_MAP; case YP_NODOM: return YPERR_NODOM; case YP_NOKEY: return YPERR_KEY; case YP_BADOP: return YPERR_YPERR; case YP_BADDB: return YPERR_BADDB; case YP_YPERR: return YPERR_YPERR; case YP_BADARGS: return YPERR_BADARGS; case YP_VERS: return YPERR_VERS; } return YPERR_YPERR; } int __yp_check (dom) char **dom; { int use_yp = 0; char *unused; if (__yp_domain[0] == '\0') if (yp_get_default_domain (&unused)) return 0; if (dom) *dom = __yp_domain; if (yp_bind (__yp_domain) == 0) return 1; return 0; } ./libc-linux/stdlib/ 40755 1676 334 0 5550054564 12310 5ustar hjlisl./libc-linux/stdlib/Makefile100644 1676 334 1016 5515544511 14040 0ustar hjlisl# # This is Makefile of stdlib functions for Linux. # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I. DIRS:= SRC1S= __random.c _quicksort.c abort.c atexit.c atof.c \ atoi.c atol.c bsearch.c exit.c labs.c ldiv.c \ mblen.c mbstowcs.c mbtowc.c on_exit.c qsort.c rand.c \ strtol.c strtoul.c wcstombs.c wctomb.c SRC2S= abs.c random.c srand.c strtod.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/stdlib/abort.c100644 1676 334 3356 5465557116 13675 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 #include /* Cause an abnormal program termination with core-dump. */ void DEFUN_VOID(abort) { sig_atomic_t aborting = 0; sigset_t sigs; if (__sigemptyset(&sigs) == 0 && __sigaddset(&sigs, SIGABRT) == 0) (void) __sigprocmask(SIG_UNBLOCK, &sigs, (sigset_t *) NULL); if (!aborting) { aborting = 1; #if defined(HAVE_GNU_LD) && !defined(linux) { extern unsigned long int __libc_atexit[]; register unsigned long int i; for (i = 1; i <= __libc_atexit[0]; ++i) (*(void EXFUN((*), (NOARGS))) __libc_atexit[i])(); } #else { extern void EXFUN(_cleanup, (NOARGS)); _cleanup(); } #endif } while (1) if (raise(SIGABRT)) /* If we can't signal ourselves, exit. */ _exit(127); /* If we signal ourselves and are still alive, or can't exit, loop forever. */ } ./libc-linux/stdlib/abs.c100644 1676 334 231 5263677327 13303 0ustar hjlisl#include #include #undef abs #undef labs #include function_alias(abs, labs, int, (i), DEFUN(abs, (i), int i)) ./libc-linux/stdlib/strtol.c100644 1676 334 7223 5263700570 14100 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 #include #include #ifndef UNSIGNED #define UNSIGNED 0 #endif /* Convert NPTR to an `unsigned long int' or `long int' in base BASE. If BASE is 0 the base is determined by the presence of a leading zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal. If BASE is < 2 or > 36, it is reset to 10. If ENDPTR is not NULL, a pointer to the character after the last one converted is stored in *ENDPTR. */ #if UNSIGNED unsigned long int #define strtol strtoul #else long int #endif DEFUN(strtol, (nptr, endptr, base), CONST char *nptr AND char **endptr AND int base) { int negative; register unsigned long int cutoff; register unsigned int cutlim; register unsigned long int i; register CONST char *s; register unsigned char c; CONST char *save; int overflow; if (base < 0 || base == 1 || base > 36) base = 10; s = nptr; /* Skip white space. */ while (isspace(*s)) ++s; if (*s == '\0') goto noconv; /* Check for a sign. */ if (*s == '-') { negative = 1; ++s; } else if (*s == '+') { negative = 0; ++s; } else negative = 0; if (base == 16 && s[0] == '0' && toupper(s[1]) == 'X') s += 2; /* If BASE is zero, figure it out ourselves. */ if (base == 0) if (*s == '0') { if (toupper(s[1]) == 'X') { s += 2; base = 16; } else base = 8; } else base = 10; /* Save the pointer so we can check later if anything happened. */ save = s; cutoff = ULONG_MAX / (unsigned long int) base; cutlim = ULONG_MAX % (unsigned long int) base; overflow = 0; i = 0; for (c = *s; c != '\0'; c = *++s) { if (isdigit(c)) c -= '0'; else if (isalpha(c)) c = toupper(c) - 'A' + 10; else break; if (c >= base) break; /* Check for overflow. */ if (i > cutoff || (i == cutoff && c > cutlim)) overflow = 1; else { i *= (unsigned long int) base; i += c; } } /* Check if anything actually happened. */ if (s == save) goto noconv; /* Store in ENDPTR the address of one character past the last character we converted. */ if (endptr != NULL) *endptr = (char *) s; #if !UNSIGNED /* Check for a value that is within the range of `unsigned long int', but outside the range of `long int'. */ if (i > (negative ? - (unsigned long int) LONG_MIN : (unsigned long int) LONG_MAX)) overflow = 1; #endif if (overflow) { errno = ERANGE; #if UNSIGNED return ULONG_MAX; #else return negative ? LONG_MIN : LONG_MAX; #endif } /* Return the result of the appropriate sign. */ return (negative ? - i : i); noconv: /* There was no number to convert. */ if (endptr != NULL) *endptr = (char *) nptr; return 0L; } ./libc-linux/stdlib/atexit.c100644 1676 334 3402 5151607121 14034 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 "exit.h" /* Register FUNC to be executed by `exit'. */ int DEFUN(atexit, (func), void EXFUN((*func), (NOARGS))) { struct exit_function *new = __new_exitfn(); if (new == NULL) return -1; new->flavor = ef_at; new->func.at = func; return 0; } static struct exit_function_list fnlist = { NULL, 0, }; struct exit_function_list *__exit_funcs = &fnlist; struct exit_function * DEFUN_VOID(__new_exitfn) { register struct exit_function_list *l; for (l = __exit_funcs; l != NULL; l = l->next) { register size_t i; for (i = 0; i < l->idx; ++i) if (l->fns[i].flavor == ef_free) return &l->fns[i]; if (l->idx < sizeof(l->fns) / sizeof(l->fns[0])) return &l->fns[l->idx++]; } l = (struct exit_function_list *) malloc(sizeof(struct exit_function_list)); if (l == NULL) return NULL; l->next = __exit_funcs; __exit_funcs = l; l->idx = 1; return &l->fns[0]; } ./libc-linux/stdlib/atof.c100644 1676 334 1760 5153255224 13501 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 #undef atof /* Convert a string to a double. */ double DEFUN(atof, (nptr), CONST char *nptr) { return(strtod(nptr, (char **) NULL)); } ./libc-linux/stdlib/atoi.c100644 1676 334 1765 5153255224 13511 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 #undef atoi /* Convert a string to an int. */ int DEFUN(atoi, (nptr), CONST char *nptr) { return((int) strtol(nptr, (char **) NULL, 10)); } ./libc-linux/stdlib/atol.c100644 1676 334 1770 5153255224 13510 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 #undef atol /* Convert a string to a long int. */ long int DEFUN(atol, (nptr), CONST char *nptr) { return(strtol(nptr, (char **) NULL, 10)); } ./libc-linux/stdlib/bsearch.c100644 1676 334 3116 5263676567 14177 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 /* Perform a binary search for KEY in BASE which has NMEMB elements of SIZE bytes each. The comparisons are done by (*COMPAR)(). */ PTR DEFUN(bsearch, (key, base, nmemb, size, compar), register CONST PTR key AND register CONST PTR base AND size_t nmemb AND register size_t size AND register int EXFUN((*compar), (CONST PTR, CONST PTR))) { register size_t l, u, idx; register CONST PTR p; register int comparison; l = 0; u = nmemb; while (l < u) { idx = (l + u) / 2; p = (PTR) (((CONST char *) base) + (idx * size)); comparison = (*compar)(key, p); if (comparison < 0) u = idx; else if (comparison > 0) l = idx + 1; else return (PTR) p; } return NULL; } ./libc-linux/stdlib/__random.c100644 1676 334 30346 5263700467 14356 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. */ /* * This is derived from the Berkeley source: * @(#)random.c 5.5 (Berkeley) 7/6/88 * It was reworked for the GNU C Library by Roland McGrath. */ #include #include #include #include #include /* An improved random number generation package. In addition to the standard rand()/srand() like interface, this package also has a special state info interface. The initstate() routine is called with a seed, an array of bytes, and a count of how many bytes are being passed in; this array is then initialized to contain information for random number generation with that much state information. Good sizes for the amount of state information are 32, 64, 128, and 256 bytes. The state can be switched by calling the setstate() function with the same array as was initiallized with initstate(). By default, the package runs with 128 bytes of state information and generates far better random numbers than a linear congruential generator. If the amount of state information is less than 32 bytes, a simple linear congruential R.N.G. is used. Internally, the state information is treated as an array of longs; the zeroeth element of the array is the type of R.N.G. being used (small integer); the remainder of the array is the state information for the R.N.G. Thus, 32 bytes of state information will give 7 longs worth of state information, which will allow a degree seven polynomial. (Note: The zeroeth word of state information also has some other information stored in it; see setstate for details). The random number generation technique is a linear feedback shift register approach, employing trinomials (since there are fewer terms to sum up that way). In this approach, the least significant bit of all the numbers in the state table will act as a linear feedback shift register, and will have period 2^deg - 1 (where deg is the degree of the polynomial being used, assuming that the polynomial is irreducible and primitive). The higher order bits will have longer periods, since their values are also influenced by pseudo-random carries out of the lower bits. The total period of the generator is approximately deg*(2**deg - 1); thus doubling the amount of state information has a vast influence on the period of the generator. Note: The deg*(2**deg - 1) is an approximation only good for large deg, when the period of the shift register is the dominant factor. With deg equal to seven, the period is actually much longer than the 7*(2**7 - 1) predicted by this formula. */ /* For each of the currently supported random number generators, we have a break value on the amount of state information (you need at least thi bytes of state info to support this random number generator), a degree for the polynomial (actually a trinomial) that the R.N.G. is based on, and separation between the two lower order coefficients of the trinomial. */ /* Linear congruential. */ #define TYPE_0 0 #define BREAK_0 8 #define DEG_0 0 #define SEP_0 0 /* x**7 + x**3 + 1. */ #define TYPE_1 1 #define BREAK_1 32 #define DEG_1 7 #define SEP_1 3 /* x**15 + x + 1. */ #define TYPE_2 2 #define BREAK_2 64 #define DEG_2 15 #define SEP_2 1 /* x**31 + x**3 + 1. */ #define TYPE_3 3 #define BREAK_3 128 #define DEG_3 31 #define SEP_3 3 /* x**63 + x + 1. */ #define TYPE_4 4 #define BREAK_4 256 #define DEG_4 63 #define SEP_4 1 /* Array versions of the above information to make code run faster. Relies on fact that TYPE_i == i. */ #define MAX_TYPES 5 /* Max number of types above. */ static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; static int seps[MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; /* Initially, everything is set up as if from: initstate(1, randtbl, 128); Note that this initialization takes advantage of the fact that srandom advances the front and rear pointers 10*rand_deg times, and hence the rear pointer which starts at 0 will also end up at zero; thus the zeroeth element of the state information, which contains info about the current position of the rear pointer is just (MAX_TYPES * (rptr - state)) + TYPE_3 == TYPE_3. */ static long int randtbl[DEG_3 + 1] = { TYPE_3, -851904987, -43806228, -2029755270, 1390239686, -1912102820, -485608943, 1969813258, -1590463333, -1944053249, 455935928, 508023712, -1714531963, 1800685987, -2015299881, 654595283, -1149023258, -1470005550, -1143256056, -1325577603, -1568001885, 1275120390, -607508183, -205999574, -1696891592, 1492211999, -1528267240, -952028296, -189082757, 362343714, 1424981831, 2039449641, }; /* FPTR and RPTR are two pointers into the state info, a front and a rear pointer. These two pointers are always rand_sep places aparts, as they cycle through the state information. (Yes, this does mean we could get away with just one pointer, but the code for random is more efficient this way). The pointers are left positioned as they would be from the call: initstate(1, randtbl, 128); (The position of the rear pointer, rptr, is really 0 (as explained above in the initialization of randtbl) because the state table pointer is set to point to randtbl[1] (as explained below).) */ static long int *fptr = &randtbl[SEP_3 + 1]; static long int *rptr = &randtbl[1]; /* The following things are the pointer to the state information table, the type of the current generator, the degree of the current polynomial being used, and the separation between the two pointers. Note that for efficiency of random, we remember the first location of the state information, not the zeroeth. Hence it is valid to access state[-1], which is used to store the type of the R.N.G. Also, we remember the last location, since this is more efficient than indexing every time to find the address of the last element to see if the front and rear pointers have wrapped. */ static long int *state = &randtbl[1]; static int rand_type = TYPE_3; static int rand_deg = DEG_3; static int rand_sep = SEP_3; static long int *end_ptr = &randtbl[sizeof(randtbl) / sizeof(randtbl[0])]; /* Initialize the random number generator based on the given seed. If the type is the trivial no-state-information type, just remember the seed. Otherwise, initializes state[] based on the given "seed" via a linear congruential generator. Then, the pointers are set to known locations that are exactly rand_sep places apart. Lastly, it cycles the state information a given number of times to get rid of any initial dependencies introduced by the L.C.R.N.G. Note that the initialization of randtbl[] for default usage relies on values produced by this routine. */ void DEFUN(__srandom, (x), unsigned int x) { state[0] = x; if (rand_type != TYPE_0) { register long int i; for (i = 1; i < rand_deg; ++i) state[i] = (1103515145 * state[i - 1]) + 12345; fptr = &state[rand_sep]; rptr = &state[0]; for (i = 0; i < 10 * rand_deg; ++i) (void) __random(); } } /* Initialize the state information in the given array of N bytes for future random number generation. Based on the number of bytes we are given, and the break values for the different R.N.G.'s, we choose the best (largest) one we can and set things up for it. srandom is then called to initialize the state information. Note that on return from srandom, we set state[-1] to be the type multiplexed with the current value of the rear pointer; this is so successive calls to initstate won't lose this information and will be able to restart with setstate. Note: The first thing we do is save the current state, if any, just like setstate so that it doesn't matter when initstate is called. Returns a pointer to the old state. */ PTR DEFUN(__initstate, (seed, arg_state, n), unsigned int seed AND PTR arg_state AND size_t n) { PTR ostate = (PTR) &state[-1]; if (rand_type == TYPE_0) state[-1] = rand_type; else state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; if (n < BREAK_1) { if (n < BREAK_0) { errno = EINVAL; return NULL; } rand_type = TYPE_0; rand_deg = DEG_0; rand_sep = SEP_0; } else if (n < BREAK_2) { rand_type = TYPE_1; rand_deg = DEG_1; rand_sep = SEP_1; } else if (n < BREAK_3) { rand_type = TYPE_2; rand_deg = DEG_2; rand_sep = SEP_2; } else if (n < BREAK_4) { rand_type = TYPE_3; rand_deg = DEG_3; rand_sep = SEP_3; } else { rand_type = TYPE_4; rand_deg = DEG_4; rand_sep = SEP_4; } state = &((long int *) arg_state)[1]; /* First location. */ /* Must set END_PTR before srandom. */ end_ptr = &state[rand_deg]; __srandom(seed); if (rand_type == TYPE_0) state[-1] = rand_type; else state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; return ostate; } /* Restore the state from the given state array. Note: It is important that we also remember the locations of the pointers in the current state information, and restore the locations of the pointers from the old state information. This is done by multiplexing the pointer location into the zeroeth word of the state information. Note that due to the order in which things are done, it is OK to call setstate with the same state as the current state Returns a pointer to the old state information. */ PTR DEFUN(__setstate, (arg_state), PTR arg_state) { register long int *new_state = (long int *) arg_state; register int type = new_state[0] % MAX_TYPES; register int rear = new_state[0] / MAX_TYPES; PTR ostate = (PTR) &state[-1]; if (rand_type == TYPE_0) state[-1] = rand_type; else state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; switch (type) { case TYPE_0: case TYPE_1: case TYPE_2: case TYPE_3: case TYPE_4: rand_type = type; rand_deg = degrees[type]; rand_sep = seps[type]; break; default: /* State info munged. */ errno = EINVAL; return NULL; } state = &new_state[1]; if (rand_type != TYPE_0) { rptr = &state[rear]; fptr = &state[(rear + rand_sep) % rand_deg]; } /* Set end_ptr too. */ end_ptr = &state[rand_deg]; return ostate; } /* If we are using the trivial TYPE_0 R.N.G., just do the old linear congruential bit. Otherwise, we do our fancy trinomial stuff, which is the same in all ther other cases due to all the global variables that have been set up. The basic operation is to add the number at the rear pointer into the one at the front pointer. Then both pointers are advanced to the next location cyclically in the table. The value returned is the sum generated, reduced to 31 bits by throwing away the "least random" low bit. Note: The code takes advantage of the fact that both the front and rear pointers can't wrap on the same call by not testing the rear pointer if the front one has wrapped. Returns a 31-bit random number. */ long int DEFUN_VOID(__random) { if (rand_type == TYPE_0) { state[0] = ((state[0] * 1103515245) + 12345) & LONG_MAX; return state[0]; } else { long int i; *fptr += *rptr; /* Chucking least random bit. */ i = (*fptr >> 1) & LONG_MAX; ++fptr; if (fptr >= end_ptr) { fptr = state; ++rptr; } else { ++rptr; if (rptr >= end_ptr) rptr = state; } return i; } } ./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/stdlib/exit.h100644 1676 334 2500 5471517023 13520 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. */ #ifndef _EXIT_H struct exit_function { enum { ef_free, ef_on, ef_at } flavor; /* `ef_free' MUST be zero! */ union { void EXFUN((*at), (NOARGS)); struct { void EXFUN((*fn), (int status, PTR arg)); PTR arg; } on; } func; }; struct exit_function_list { struct exit_function_list *next; size_t idx; struct exit_function fns[32]; }; extern struct exit_function_list *__exit_funcs; extern struct exit_function *EXFUN(__new_exitfn, (NOARGS)); #endif /* exit.h */ ./libc-linux/stdlib/srand.c100644 1676 334 1752 5221410520 13644 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 #undef srand #include function_alias(srand, __srandom, void, (seed), DEFUN(srand, (seed), unsigned int seed)) ./libc-linux/stdlib/random.c100644 1676 334 2547 5221412465 14032 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 #undef random #undef srandom #undef initstate #undef setstate #include function_alias(random, __random, long int, (), DEFUN_VOID(random)) function_alias(srandom, __srandom, void, (seed), DEFUN(srandom, (seed), unsigned int seed)) function_alias(initstate, __initstate, PTR, (seed, buf, size), DEFUN(initstate, (seed, buf, size), unsigned int seed AND PTR buf AND size_t size)) function_alias(setstate, __setstate, PTR, (buf), DEFUN(setstate, (buf), PTR buf)) ./libc-linux/stdlib/ldiv.c100644 1676 334 7761 5471467027 13526 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. */ /* * Copyright (c) 1990 Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * 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. */ #include #include /* Return the `ldiv_t' representation of NUMER over DENOM. */ ldiv_t DEFUN(ldiv, (numer, denom), long int numer AND long int denom) { ldiv_t result; result.quot = numer / denom; result.rem = numer % denom; /* The ANSI standard says that |QUOT| <= |NUMER / DENOM|, where NUMER / DENOM is to be computed in infinite precision. In other words, we should always truncate the quotient towards zero, never -infinity. Machine division and remainer may work either way when one or both of NUMER or DENOM is negative. If only one is negative and QUOT has been truncated towards -infinity, REM will have the same sign as DENOM and the opposite sign of NUMER; if both are negative and QUOT has been truncated towards -infinity, REM will be positive (will have the opposite sign of NUMER). These are considered `wrong'. If both are NUM and DENOM are positive, RESULT will always be positive. This all boils down to: if NUMER >= 0, but REM < 0, we got the wrong answer. In that case, to get the right answer, add 1 to QUOT and subtract DENOM from REM. */ /* I was told i386 does this right. */ #ifndef i386 if (numer >= 0 && result.rem < 0) { ++result.quot; result.rem -= denom; } #endif return result; } ./libc-linux/stdlib/on_exit.c100644 1676 334 2262 5151607126 14213 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 "exit.h" /* Register a function to be called by exit. */ int DEFUN(on_exit, (func, arg), void EXFUN((*func), (int status, PTR arg)) AND PTR arg) { struct exit_function *new = __new_exitfn(); if (new == NULL) return -1; new->flavor = ef_on; new->func.on.fn = func; new->func.on.arg = arg; return 0; } ./libc-linux/stdlib/qsort.c100644 1676 334 4742 5263674505 13734 0ustar hjlisl/* msort -- an alternative to qsort, with an identical interface. Copyright (C) 1992 Free Software Foundation, Inc. Written by Mike Haertel, September 1988. 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 #define MEMCPY(dst, src, s) \ ((s) == sizeof (int) \ ? (*(int *) (dst) = *(int *) (src), (dst)) \ : memcpy (dst, src, s)) static void DEFUN(msort_with_tmp, (b, n, s, cmp, t), PTR b AND size_t n AND size_t s AND __compar_fn_t cmp AND char *t) { char *tmp; char *b1, *b2; size_t n1, n2; if (n <= 1) return; n1 = n / 2; n2 = n - n1; b1 = b; b2 = (char *) b + (n1 * s); msort_with_tmp (b1, n1, s, cmp, t); msort_with_tmp (b2, n2, s, cmp, t); tmp = t; while (n1 > 0 && n2 > 0) { if ((*cmp) (b1, b2) <= 0) { MEMCPY (tmp, b1, s); b1 += s; --n1; } else { MEMCPY (tmp, b2, s); b2 += s; --n2; } tmp += s; } if (n1 > 0) memcpy (tmp, b1, n1 * s); memcpy (b, t, (n - n2) * s); } void DEFUN(qsort, (b, n, s, cmp), PTR b AND size_t n AND size_t s AND __compar_fn_t cmp) { CONST size_t size = n * s; if (size < 1024) /* The temporary array is small, so put it on the stack. */ msort_with_tmp (b, n, s, cmp, __alloca (size)); else { /* It's somewhat large, so malloc it. */ int save = errno; char *tmp = malloc (size); if (tmp == NULL) { /* Couldn't get space, so use the slower algorithm that doesn't need a temporary array. */ extern void EXFUN(_quicksort, (PTR __base, size_t __nmemb, size_t __size, __compar_fn_t __compar)); _quicksort (b, n, s, cmp); } else { msort_with_tmp (b, n, s, cmp, tmp); free (tmp); } errno = save; } } ./libc-linux/stdlib/mblen.c100644 1676 334 2112 5153255257 13643 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 #undef mblen /* Return the length of the multibyte character (if there is one) at S which is no longer than N characters. */ int DEFUN(mblen, (s, n), CONST char *s AND size_t n) { return(mbtowc((wchar_t *) NULL, s, n)); } ./libc-linux/stdlib/mbstowcs.c100644 1676 334 3744 5263700300 14405 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 #include extern int _mb_shift; /* Defined in mbtowc.c. */ /* Convert the string of multibyte characters in S to `wchar_t's in PWCS, writing no more than N. Return the number written, or (size_t) -1 if an invalid multibyte character is encountered. */ size_t DEFUN(mbstowcs, (pwcs, s, n), register wchar_t *pwcs AND register CONST char *s AND register size_t n) { int save_shift; register size_t written = 0; /* Save the shift state. */ save_shift = _mb_shift; /* Reset the shift state. */ _mb_shift = 0; while (*s != '\0') { int len; if (isascii (*s)) { *pwcs = (wchar_t) *s; len = 1; } else len = mbtowc (pwcs, s, n); if (len < 1) { /* Return an error. */ written = (size_t) -1; break; } else { /* Multibyte character converted. */ ++pwcs; ++written; s += len; n -= len; } } /* Terminate the string if it has space. */ if (n > 0) *pwcs = (wchar_t) 0; /* Restore the old shift state. */ _mb_shift = save_shift; /* Return how many we wrote (or maybe an error). */ return written; } ./libc-linux/stdlib/mbtowc.c100644 1676 334 4020 5263700324 14031 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 #include #include #include #include long int _mb_shift = 0; /* Convert the multibyte character at S, which is no longer than N characters, to its `wchar_t' representation, placing this n *PWC and returning its length. */ int DEFUN(mbtowc, (pwc, s, n), wchar_t *pwc AND CONST char *s AND size_t n) { register CONST mb_char *mb; register wchar_t i; if (s == NULL) return _mb_shift != 0; if (*s == '\0') return 0; if (_ctype_info->mbchar == NULL || _ctype_info->mbchar->mb_chars == NULL) return -1; if (n > MB_CUR_MAX) n = MB_CUR_MAX; for (i = 0; i < WCHAR_MAX; ++i) { mb = &_ctype_info->mbchar->mb_chars[i]; /* EOF and NUL aren't MB chars. */ if (i == (wchar_t) EOF || i == (wchar_t) '\0') continue; /* Normal ASCII values can't start MB chars. */ else if (isascii(i)) continue; else if (mb->string == NULL || mb->len == 0) continue; else if (mb->len > n) continue; else if (!strncmp(mb->string, s, mb->len)) { _mb_shift += mb->shift; if (pwc != NULL) *pwc = i; return mb->len; } } return -1; } ./libc-linux/stdlib/wcstombs.c100644 1676 334 4121 5263700654 14407 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 #include #include #include #include /* Convert the `wchar_t' string in PWCS to a multibyte character string in S, writing no more than N characters. Return the number of bytes written, or (size_t) -1 if an invalid `wchar_t' was found. */ size_t DEFUN(wcstombs, (s, pwcs, n), register char *s AND register CONST wchar_t *pwcs AND register size_t n) { register CONST mb_char *mb; register int shift = 0; register size_t written = 0; register wchar_t w; while ((w = *pwcs++) != (wchar_t) '\0') { if (isascii (w)) { /* A normal character. */ *s++ = (unsigned char) w; --n; ++written; } else { mb = &_ctype_info->mbchar->mb_chars[w + shift]; if (mb->string == NULL || mb->len == 0) { written = (size_t) -1; break; } else if (mb->len > n) break; else { memcpy ((PTR) s, (CONST PTR) mb->string, mb->len); s += mb->len; n -= mb->len; written += mb->len; shift += mb->shift; } } } /* Terminate the string if it has space. */ if (n > 0) *s = '\0'; /* Return the number of characters written (or maybe an error). */ return written; } ./libc-linux/stdlib/wctomb.c100644 1676 334 3270 5153255257 14047 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 #include extern int _mb_shift; /* Defined in mbtowc.c. */ /* Convert WCHAR into its multibyte character representation, putting this in S and returning its length. */ int DEFUN(wctomb, (s, wchar), register char *s AND wchar_t wchar) { register CONST mb_char *mb; if (_ctype_info->mbchar == NULL) mb = NULL; else mb = _ctype_info->mbchar->mb_chars; /* If S is NULL, just say if we're shifted or not. */ if (s == NULL) return _mb_shift != 0; if (wchar == (wchar_t) '\0') { _mb_shift = 0; return 0; } else if (mb == NULL) return -1; mb += wchar + _mb_shift; if (mb->string == NULL || mb->len == 0) return -1; memcpy((PTR) s, (CONST PTR) mb->string, mb->len + 1); _mb_shift += mb->shift; return mb->len; } ./libc-linux/stdlib/strtoul.c100644 1676 334 1541 5153255260 14261 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. */ #define UNSIGNED 1 #include ./libc-linux/stdlib/rand.c100644 1676 334 1735 5221410520 13462 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 #undef rand /* Return a random integer between 0 and RAND_MAX. */ int DEFUN_VOID(rand) { return (int) __random(); } ./libc-linux/stdlib/_quicksort.c100644 1676 334 17730 5263674175 14773 0ustar hjlisl/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Douglas C. Schmidt (schmidt@ics.uci.edu). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as 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 /* Byte-wise swap two items of size SIZE. */ #define SWAP(a, b, size) \ do \ { \ register size_t __size = (size); \ register char *__a = (a), *__b = (b); \ do \ { \ char __tmp = *__a; \ *__a++ = *__b; \ *__b++ = __tmp; \ } while (--__size > 0); \ } while (0) /* Discontinue quicksort algorithm when partition gets below this size. This particular magic number was chosen to work best on a Sun 4/260. */ #define MAX_THRESH 4 /* Stack node declarations used to store unfulfilled partition obligations. */ typedef struct { char *lo; char *hi; } stack_node; /* The next 4 #defines implement a very fast in-line stack abstraction. */ #define STACK_SIZE (8 * sizeof(unsigned long int)) #define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) #define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) #define STACK_NOT_EMPTY (stack < top) /* Order size using quicksort. This implementation incorporates four optimizations discussed in Sedgewick: 1. Non-recursive, using an explicit stack of pointer that store the next array partition to sort. To save time, this maximum amount of space required to store an array of MAX_INT is allocated on the stack. Assuming a 32-bit integer, this needs only 32 * sizeof(stack_node) == 136 bits. Pretty cheap, actually. 2. Chose the pivot element using a median-of-three decision tree. This reduces the probability of selecting a bad pivot value and eliminates certain extraneous comparisons. 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving insertion sort to order the MAX_THRESH items within each partition. This is a big win, since insertion sort is faster for small, mostly sorted array segements. 4. The larger of the two sub-partitions is always pushed onto the stack first, with the algorithm then concentrating on the smaller partition. This *guarantees* no more than log (n) stack size is needed (actually O(1) in this case)! */ void DEFUN(_quicksort, (pbase, total_elems, size, cmp), PTR CONST pbase AND size_t total_elems AND size_t size AND int EXFUN((*cmp), (CONST PTR, CONST PTR))) { register char *base_ptr = (char *) pbase; /* Allocating SIZE bytes for a pivot buffer facilitates a better algorithm below since we can do comparisons directly on the pivot. */ char *pivot_buffer = (char *) __alloca (size); CONST size_t max_thresh = MAX_THRESH * size; if (total_elems == 0) /* Avoid lossage with unsigned arithmetic below. */ return; if (total_elems > MAX_THRESH) { char *lo = base_ptr; char *hi = &lo[size * (total_elems - 1)]; /* Largest size needed for 32-bit int!!! */ stack_node stack[STACK_SIZE]; stack_node *top = stack + 1; while (STACK_NOT_EMPTY) { char *left_ptr; char *right_ptr; char *pivot = pivot_buffer; /* Select median value from among LO, MID, and HI. Rearrange LO and HI so the three values are sorted. This lowers the probability of picking a pathological pivot value and skips a comparison for both the LEFT_PTR and RIGHT_PTR. */ char *mid = lo + size * ((hi - lo) / size >> 1); if ((*cmp)((PTR) mid, (PTR) lo) < 0) SWAP(mid, lo, size); if ((*cmp)((PTR) hi, (PTR) mid) < 0) SWAP(mid, hi, size); else goto jump_over; if ((*cmp)((PTR) mid, (PTR) lo) < 0) SWAP(mid, lo, size); jump_over:; memcpy(pivot, mid, size); pivot = pivot_buffer; left_ptr = lo + size; right_ptr = hi - size; /* Here's the famous ``collapse the walls'' section of quicksort. Gotta like those tight inner loops! They are the main reason that this algorithm runs much faster than others. */ do { while ((*cmp)((PTR) left_ptr, (PTR) pivot) < 0) left_ptr += size; while ((*cmp)((PTR) pivot, (PTR) right_ptr) < 0) right_ptr -= size; if (left_ptr < right_ptr) { SWAP(left_ptr, right_ptr, size); left_ptr += size; right_ptr -= size; } else if (left_ptr == right_ptr) { left_ptr += size; right_ptr -= size; break; } } while (left_ptr <= right_ptr); /* Set up pointers for next iteration. First determine whether left and right partitions are below the threshold size. If so, ignore one or both. Otherwise, push the larger partition's bounds on the stack and continue sorting the smaller one. */ if ((size_t) (right_ptr - lo) <= max_thresh) { if ((size_t) (hi - left_ptr) <= max_thresh) /* Ignore both small partitions. */ POP(lo, hi); else /* Ignore small left partition. */ lo = left_ptr; } else if ((size_t) (hi - left_ptr) <= max_thresh) /* Ignore small right partition. */ hi = right_ptr; else if ((right_ptr - lo) > (hi - left_ptr)) { /* Push larger left partition indices. */ PUSH(lo, right_ptr); lo = left_ptr; } else { /* Push larger right partition indices. */ PUSH(left_ptr, hi); hi = right_ptr; } } } /* Once the BASE_PTR array is partially sorted by quicksort the rest is completely sorted using insertion sort, since this is efficient for partitions below MAX_THRESH size. BASE_PTR points to the beginning of the array to sort, and END_PTR points at the very last element in the array (*not* one beyond it!). */ #define min(x, y) ((x) < (y) ? (x) : (y)) { char *CONST end_ptr = &base_ptr[size * (total_elems - 1)]; char *tmp_ptr = base_ptr; char *thresh = min(end_ptr, base_ptr + max_thresh); register char *run_ptr; /* Find smallest element in first threshold and place it at the array's beginning. This is the smallest array element, and the operation speeds up insertion sort's inner loop. */ for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) if ((*cmp)((PTR) run_ptr, (PTR) tmp_ptr) < 0) tmp_ptr = run_ptr; if (tmp_ptr != base_ptr) SWAP(tmp_ptr, base_ptr, size); /* Insertion sort, running from left-hand-side up to right-hand-side. */ run_ptr = base_ptr + size; while ((run_ptr += size) <= end_ptr) { tmp_ptr = run_ptr - size; while ((*cmp)((PTR) run_ptr, (PTR) tmp_ptr) < 0) tmp_ptr -= size; tmp_ptr += size; if (tmp_ptr != run_ptr) { char *trav; trav = run_ptr + size; while (--trav >= run_ptr) { char c = *trav; char *hi, *lo; for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) *hi = *lo; *hi = c; } } } } } ./libc-linux/stdlib/labs.c100644 1676 334 1735 5471467026 13503 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 #undef labs /* Return the absolute value of I. */ long int DEFUN(labs, (i), long int i) { return(i < 0 ? -i : i); } ./libc-linux/stdlib/fpalloc.c100644 1676 334 626 5376230420 14146 0ustar hjlisl#include #include #include #ifdef IEEE_754 #ifdef __BIG_ENDIAN #define snan_bytes { } #else #define snan_bytes { } #endif void * fpalloc (size_t n) { void * ptr; ptr = malloc (n); if (!ptr) return ptr; return memtile (ptr, n, snan_bytes, sizeof (snan_bytes)); } #elese void * fpalloc (size_t n) { return malloc (n); } #endif ./libc-linux/stdlib/strtod.c100644 1676 334 2012 5473737311 14065 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 #undef strtod function_alias(strtod, _IO_strtod, double, (n, e), DEFUN(strtod, (n, e), CONST char *n AND CONST char **e)) ./libc-linux/string/ 40755 1676 334 0 5550054711 12327 5ustar hjlisl./libc-linux/string/bcmp.c100644 1676 334 1745 5515066347 13531 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 #undef bcmp #define isbcmp /* #ifdef __i386__ */ #if 0 #include #else #include #endif ./libc-linux/string/index.c100644 1676 334 2012 5263452467 13705 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 #undef index #include function_alias(index, strchr, char *, (s, c), DEFUN(index, (s, c), CONST char *s AND int c)) ./libc-linux/string/memccpy.c100644 1676 334 2054 5263452467 14241 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 #undef memccpy #include function_alias(memccpy, __memccpy, PTR, (dest, src, c, n), DEFUN(memccpy, (dest, src, c, n), PTR dest AND CONST PTR src AND int c AND size_t n)) ./libc-linux/string/memfrob.c100644 1676 334 1756 5263452467 14243 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 #include PTR DEFUN(memfrob, (s, n), PTR s AND size_t n) { register char *p = (char *) s; while (n-- > 0) *p++ ^= 42; return s; } ./libc-linux/string/rindex.c100644 1676 334 2010 5263452467 14065 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 #undef rindex #include function_alias(rindex, strrchr, char *, (s, c), DEFUN(rindex, (s, c), CONST char *s AND int c)) ./libc-linux/string/strcoll.c100644 1676 334 4273 5263452470 14265 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 /* Compare S1 and S2, returning less than, equal to or greater than zero if the collated form of S1 is lexiographically less than, equal to or greater than the collated form of S2. */ int DEFUN(strcoll, (s1, s2), CONST char *s1 AND CONST char *s2) { if (_collate_info == NULL || _collate_info->values == NULL) return strcmp(s1, s2); else { CONST unsigned char *CONST values = _collate_info->values; CONST unsigned char *CONST offsets = _collate_info->offsets; while (*s1 != '\0' && *s2 != '\0') { CONST unsigned char c1 = *s1++, c2 = *s2++; CONST unsigned char v1 = values[c1], v2 = values[c2]; CONST unsigned char o1 = offsets[c1], o2 = offsets[c2]; if (v1 == UCHAR_MAX && o1 == 0) /* This is a non-collating element. Skip it. */ --s2; else if (v2 == UCHAR_MAX && o2 == 0) --s1; else if (v1 == UCHAR_MAX && o1 == CHAR_MAX) { /* This element collates lower than anything else. */ if (v2 != UCHAR_MAX || o2 != CHAR_MAX) return -1; } else if (v2 == UCHAR_MAX && o2 == CHAR_MAX) return 1; else if (v1 != v2) return v1 - v2; else if (o1 != o2) return o1 - o2; } if (*s1 == '\0') return *s2 == '\0' ? 0 : -1; else if (*s2 == '\0') return 1; return 0; } } ./libc-linux/string/strdup.c100644 1676 334 2210 5263452470 14111 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 /* Duplicate S, returning an identical malloc'd string. */ char * DEFUN(strdup, (s), CONST char *s) { size_t len = strlen(s) + 1; PTR new = malloc(len); if (new == NULL) return NULL; memcpy(new, (PTR) s, len); return (char *) new; } ./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/strfry.c100644 1676 334 2363 5263452470 14132 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 #include #include #include char * DEFUN(strfry, (string), char *string) { static int init = 0; size_t len, i; if (!init) { srand (time ((time_t *) NULL)); init = 1; } len = strlen (string); for (i = 0; i < len; ++i) { size_t j = rand () % len; char c = string[i]; string[i] = string[j]; string[j] = c; } return string; } ./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 } ./libc-linux/string/strtok.c100644 1676 334 3504 5263452470 14125 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 static char *olds = NULL; /* Parse S into tokens separated by characters in DELIM. If S is NULL, the last string strtok() was called with is used. For example: char s[] = "-abc=-def"; x = strtok(s, "-"); // x = "abc" x = strtok(NULL, "=-"); // x = "def" x = strtok(NULL, "="); // x = NULL // s = "abc\0-def\0" */ char * DEFUN(strtok, (s, delim), register char *s AND register CONST char *delim) { char *token; if (s == NULL) { if (olds == NULL) { errno = EINVAL; return NULL; } else s = olds; } /* Scan leading delimiters. */ s += strspn(s, delim); if (*s == '\0') { olds = NULL; return NULL; } /* Find the end of the token. */ token = s; s = strpbrk(token, delim); if (s == NULL) /* This token finishes the string. */ olds = NULL; else { /* Terminate the token and make OLDS point past it. */ *s = '\0'; olds = s + 1; } return token; } ./libc-linux/string/strxfrm.c100644 1676 334 4361 5263452470 14306 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 /* Transform SRC into a form such that the result of strcmp on two strings that have been transformed by strxfrm is the same as the result of strcoll on the two strings before their transformation. The transformed string is put in at most N characters of DEST and its length is returned. */ size_t DEFUN(strxfrm, (dest, src, n), char *dest AND CONST char *src AND size_t n) { CONST unsigned char *CONST values = _collate_info != NULL ? _collate_info->values : NULL; CONST unsigned char *CONST offsets = _collate_info != NULL ? _collate_info->offsets : NULL; register size_t done = 0; while (*src != '\0') { CONST unsigned char c = *src++; ++done; if (offsets != NULL && offsets[c] != 0) { ++done; if (offsets[c] == CHAR_MAX) ++done; } if (done < n && dest != NULL) { if (values == NULL) *dest++ = c; else if (values[c] == UCHAR_MAX && offsets[c] == 0) /* This is a non-collating element. Skip it. */ ; else if (values[c] == UCHAR_MAX && offsets[c] == CHAR_MAX) { /* This element collates lower than anything else. */ *dest++ = '\001'; *dest++ = '\001'; *dest++ = '\001'; } else { *dest++ = values[c]; *dest++ = offsets[c]; } } } if (dest != NULL) *dest = '\0'; return done; } ./libc-linux/string/swab.c100644 1676 334 2057 5263452470 13535 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 #include void DEFUN(swab, (from, to, n), CONST char *from AND char *to AND size_t n) { while (n > 1) { CONST char b0 = from[--n], b1 = from[--n]; to[n] = b0; to[n + 1] = b1; } } ./libc-linux/string/testcopy.c100644 1676 334 5702 5263452470 14453 0ustar hjlisl/* Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 int DEFUN(main, (argc, argv), int argc AND char **argv) { char *mem, *memp; char *rand_mem; char *lo_around, *hi_around; int size, max_size; int src_off, dst_off; int i; int space_around = 10; max_size = 256; mem = malloc (max_size + 2 * max_size + 2 * space_around); rand_mem = malloc (max_size); lo_around = malloc (space_around); hi_around = malloc (space_around); memp = mem + space_around; /* Fill RAND_MEM with random bytes, each non-zero. */ for (i = 0; i < max_size; i++) { int x; do x = random (); while (x == 0); rand_mem[i] = x; } for (size = 0; size < max_size; size++) { printf("phase %d\n", size); for (src_off = 0; src_off <= 16; src_off++) { for (dst_off = 0; dst_off <= 16; dst_off++) { /* Put zero around the intended destination, to check that it's not clobbered. */ for (i = 1; i < space_around; i++) { memp[dst_off - i] = 0; memp[dst_off + size - 1 + i] = 0; } /* Fill the source area with known contents. */ for (i = 0; i < size; i++) memp[src_off + i] = rand_mem[i]; /* Remember the contents around the destination area. (It might not be what we wrote some lines above, since the src area and the dst area overlap.) */ for (i = 1; i < space_around; i++) { lo_around[i] = memp[dst_off - i]; hi_around[i] = memp[dst_off + size - 1 + i]; } memmove (memp + dst_off, memp + src_off, size); /* Check that the destination area has the same contents we wrote to the source area. */ for (i = 0; i < size; i++) { if (memp[dst_off + i] != rand_mem[i]) abort (); } /* Check that the area around the destination is not clobbered. */ for (i = 1; i < space_around; i++) { if (memp[dst_off - i] != lo_around[i]) abort (); if (memp[dst_off + size - 1 + i] != hi_around[i]) abort (); } } } } puts ("Test succeeded."); return 0; } ./libc-linux/string/tester.c100644 1676 334 47021 5263515256 14131 0ustar hjlisl#include #include #include #include #include #include #include #ifndef HAVE_GNU_LD #define _sys_nerr sys_nerr #define _sys_errlist sys_errlist #endif #define STREQ(a, b) (strcmp((a), (b)) == 0) CONST char *it = ""; /* Routine name for message routines. */ size_t errors = 0; /* Complain if condition is not true. */ void DEFUN(check, (thing, number), int thing AND int number) { if (!thing) { printf("%s flunked test %d with result %d\n", it, number, thing); ++errors; } } /* Complain if first two args don't strcmp as equal. */ void DEFUN(equal, (a, b, number), CONST char *a AND CONST char *b AND int number) { check(a != NULL && b != NULL && STREQ(a, b), number); } char one[50]; char two[50]; int DEFUN(main, (argc, argv), int argc AND char **argv) { /* Test strcmp first because we use it to test other things. */ it = "strcmp"; check(strcmp("", "") == 0, 1); /* Trivial case. */ check(strcmp("a", "a") == 0, 2); /* Identity. */ check(strcmp("abc", "abc") == 0, 3); /* Multicharacter. */ check(strcmp("abc", "abcd") < 0, 4); /* Length mismatches. */ check(strcmp("abcd", "abc") > 0, 5); check(strcmp("abcd", "abce") < 0, 6); /* Honest miscompares. */ check(strcmp("abce", "abcd") > 0, 7); /* printf ("strcmp 8: %d\n", strcmp("a\203", "a")); */ check(strcmp("a\203", "a") > 0, 8); /* Tricky if char signed. */ /* printf ("strcmp 9: %d\n", strcmp("a\203", "a\003")); */ check(strcmp("a\203", "a\003") > 0, 9); /* Test strcpy next because we need it to set up other tests. */ it = "strcpy"; check(strcpy(one, "abcd") == one, 1); /* Returned value. */ equal(one, "abcd", 2); /* Basic test. */ (void) strcpy(one, "x"); equal(one, "x", 3); /* Writeover. */ equal(one+2, "cd", 4); /* Wrote too much? */ (void) strcpy(two, "hi there"); (void) strcpy(one, two); equal(one, "hi there", 5); /* Basic test encore. */ equal(two, "hi there", 6); /* Stomped on source? */ (void) strcpy(one, ""); equal(one, "", 7); /* Boundary condition. */ /* strcat. */ it = "strcat"; (void) strcpy(one, "ijk"); check(strcat(one, "lmn") == one, 1); /* Returned value. */ equal(one, "ijklmn", 2); /* Basic test. */ (void) strcpy(one, "x"); (void) strcat(one, "yz"); equal(one, "xyz", 3); /* Writeover. */ equal(one+4, "mn", 4); /* Wrote too much? */ (void) strcpy(one, "gh"); (void) strcpy(two, "ef"); (void) strcat(one, two); equal(one, "ghef", 5); /* Basic test encore. */ equal(two, "ef", 6); /* Stomped on source? */ (void) strcpy(one, ""); (void) strcat(one, ""); equal(one, "", 7); /* Boundary conditions. */ (void) strcpy(one, "ab"); (void) strcat(one, ""); equal(one, "ab", 8); (void) strcpy(one, ""); (void) strcat(one, "cd"); equal(one, "cd", 9); /* strncat - first test it as strcat, with big counts, then test the count mechanism. */ it = "strncat"; (void) strcpy(one, "ijk"); check(strncat(one, "lmn", 99) == one, 1); /* Returned value. */ equal(one, "ijklmn", 2); /* Basic test. */ (void) strcpy(one, "x"); (void) strncat(one, "yz", 99); equal(one, "xyz", 3); /* Writeover. */ equal(one+4, "mn", 4); /* Wrote too much? */ (void) strcpy(one, "gh"); (void) strcpy(two, "ef"); (void) strncat(one, two, 99); equal(one, "ghef", 5); /* Basic test encore. */ equal(two, "ef", 6); /* Stomped on source? */ (void) strcpy(one, ""); (void) strncat(one, "", 99); equal(one, "", 7); /* Boundary conditions. */ (void) strcpy(one, "ab"); (void) strncat(one, "", 99); equal(one, "ab", 8); (void) strcpy(one, ""); (void) strncat(one, "cd", 99); equal(one, "cd", 9); (void) strcpy(one, "ab"); (void) strncat(one, "cdef", 2); equal(one, "abcd", 10); /* Count-limited. */ (void) strncat(one, "gh", 0); equal(one, "abcd", 11); /* Zero count. */ (void) strncat(one, "gh", 2); equal(one, "abcdgh", 12); /* Count and length equal. */ /* strncmp - first test as strcmp with big counts, then test count code. */ it = "strncmp"; check(strncmp("", "", 99) == 0, 1); /* Trivial case. */ check(strncmp("a", "a", 99) == 0, 2); /* Identity. */ check(strncmp("abc", "abc", 99) == 0, 3); /* Multicharacter. */ check(strncmp("abc", "abcd", 99) < 0, 4); /* Length unequal. */ check(strncmp("abcd", "abc", 99) > 0, 5); check(strncmp("abcd", "abce", 99) < 0, 6); /* Honestly unequal. */ check(strncmp("abce", "abcd", 99) > 0, 7); check(strncmp("a\203", "a", 2) > 0, 8); /* Tricky if '\203' < 0 */ check(strncmp("a\203", "a\003", 2) > 0, 9); check(strncmp("abce", "abcd", 3) == 0, 10); /* Count limited. */ check(strncmp("abce", "abc", 3) == 0, 11); /* Count == length. */ check(strncmp("abcd", "abce", 4) < 0, 12); /* Nudging limit. */ check(strncmp("abc", "def", 0) == 0, 13); /* Zero count. */ /* strncpy - testing is a bit different because of odd semantics. */ it = "strncpy"; check(strncpy(one, "abc", 4) == one, 1); /* Returned value. */ equal(one, "abc", 2); /* Did the copy go right? */ (void) strcpy(one, "abcdefgh"); (void) strncpy(one, "xyz", 2); equal(one, "xycdefgh", 3); /* Copy cut by count. */ (void) strcpy(one, "abcdefgh"); (void) strncpy(one, "xyz", 3); /* Copy cut just before NUL. */ equal(one, "xyzdefgh", 4); (void) strcpy(one, "abcdefgh"); (void) strncpy(one, "xyz", 4); /* Copy just includes NUL. */ equal(one, "xyz", 5); equal(one+4, "efgh", 6); /* Wrote too much? */ (void) strcpy(one, "abcdefgh"); (void) strncpy(one, "xyz", 5); /* Copy includes padding. */ equal(one, "xyz", 7); equal(one+4, "", 8); equal(one+5, "fgh", 9); (void) strcpy(one, "abc"); (void) strncpy(one, "xyz", 0); /* Zero-length copy. */ equal(one, "abc", 10); (void) strncpy(one, "", 2); /* Zero-length source. */ equal(one, "", 11); equal(one+1, "", 12); equal(one+2, "c", 13); (void) strcpy(one, "hi there"); (void) strncpy(two, one, 9); equal(two, "hi there", 14); /* Just paranoia. */ equal(one, "hi there", 15); /* Stomped on source? */ /* strlen. */ it = "strlen"; check(strlen("") == 0, 1); /* Empty. */ check(strlen("a") == 1, 2); /* Single char. */ check(strlen("abcd") == 4, 3); /* Multiple chars. */ /* strchr. */ it = "strchr"; check(strchr("abcd", 'z') == NULL, 1); /* Not found. */ (void) strcpy(one, "abcd"); check(strchr(one, 'c') == one+2, 2); /* Basic test. */ check(strchr(one, 'd') == one+3, 3); /* End of string. */ check(strchr(one, 'a') == one, 4); /* Beginning. */ check(strchr(one, '\0') == one+4, 5); /* Finding NUL. */ (void) strcpy(one, "ababa"); check(strchr(one, 'b') == one+1, 6); /* Finding first. */ (void) strcpy(one, ""); check(strchr(one, 'b') == NULL, 7); /* Empty string. */ check(strchr(one, '\0') == one, 8); /* NUL in empty string. */ /* index - just like strchr. */ it = "index"; check(index("abcd", 'z') == NULL, 1); /* Not found. */ (void) strcpy(one, "abcd"); check(index(one, 'c') == one+2, 2); /* Basic test. */ check(index(one, 'd') == one+3, 3); /* End of string. */ check(index(one, 'a') == one, 4); /* Beginning. */ check(index(one, '\0') == one+4, 5); /* Finding NUL. */ (void) strcpy(one, "ababa"); check(index(one, 'b') == one+1, 6); /* Finding first. */ (void) strcpy(one, ""); check(index(one, 'b') == NULL, 7); /* Empty string. */ check(index(one, '\0') == one, 8); /* NUL in empty string. */ /* strrchr. */ it = "strrchr"; check(strrchr("abcd", 'z') == NULL, 1); /* Not found. */ (void) strcpy(one, "abcd"); check(strrchr(one, 'c') == one+2, 2); /* Basic test. */ check(strrchr(one, 'd') == one+3, 3); /* End of string. */ check(strrchr(one, 'a') == one, 4); /* Beginning. */ check(strrchr(one, '\0') == one+4, 5); /* Finding NUL. */ (void) strcpy(one, "ababa"); check(strrchr(one, 'b') == one+3, 6); /* Finding last. */ (void) strcpy(one, ""); check(strrchr(one, 'b') == NULL, 7); /* Empty string. */ check(strrchr(one, '\0') == one, 8); /* NUL in empty string. */ /* rindex - just like strrchr. */ it = "rindex"; check(rindex("abcd", 'z') == NULL, 1); /* Not found. */ (void) strcpy(one, "abcd"); check(rindex(one, 'c') == one+2, 2); /* Basic test. */ check(rindex(one, 'd') == one+3, 3); /* End of string. */ check(rindex(one, 'a') == one, 4); /* Beginning. */ check(rindex(one, '\0') == one+4, 5); /* Finding NUL. */ (void) strcpy(one, "ababa"); check(rindex(one, 'b') == one+3, 6); /* Finding last. */ (void) strcpy(one, ""); check(rindex(one, 'b') == NULL, 7); /* Empty string. */ check(rindex(one, '\0') == one, 8); /* NUL in empty string. */ /* strpbrk - somewhat like strchr. */ it = "strpbrk"; check(strpbrk("abcd", "z") == NULL, 1); /* Not found. */ (void) strcpy(one, "abcd"); check(strpbrk(one, "c") == one+2, 2); /* Basic test. */ check(strpbrk(one, "d") == one+3, 3); /* End of string. */ check(strpbrk(one, "a") == one, 4); /* Beginning. */ check(strpbrk(one, "") == NULL, 5); /* Empty search list. */ check(strpbrk(one, "cb") == one+1, 6); /* Multiple search. */ (void) strcpy(one, "abcabdea"); check(strpbrk(one, "b") == one+1, 7); /* Finding first. */ check(strpbrk(one, "cb") == one+1, 8); /* With multiple search. */ check(strpbrk(one, "db") == one+1, 9); /* Another variant. */ (void) strcpy(one, ""); check(strpbrk(one, "bc") == NULL, 10); /* Empty string. */ check(strpbrk(one, "") == NULL, 11); /* Both strings empty. */ /* strstr - somewhat like strchr. */ it = "strstr"; check(strstr("abcd", "z") == NULL, 1); /* Not found. */ check(strstr("abcd", "abx") == NULL, 2); /* Dead end. */ (void) strcpy(one, "abcd"); check(strstr(one, "c") == one+2, 3); /* Basic test. */ check(strstr(one, "bc") == one+1, 4); /* Multichar. */ check(strstr(one, "d") == one+3, 5); /* End of string. */ check(strstr(one, "cd") == one+2, 6); /* Tail of string. */ check(strstr(one, "abc") == one, 7); /* Beginning. */ check(strstr(one, "abcd") == one, 8); /* Exact match. */ check(strstr(one, "abcde") == NULL, 9); /* Too long. */ check(strstr(one, "de") == NULL, 10); /* Past end. */ check(strstr(one, "") == one+4, 11); /* Finding empty. */ (void) strcpy(one, "ababa"); check(strstr(one, "ba") == one+1, 12); /* Finding first. */ (void) strcpy(one, ""); check(strstr(one, "b") == NULL, 13); /* Empty string. */ check(strstr(one, "") == one, 14); /* Empty in empty string. */ (void) strcpy(one, "bcbca"); check(strstr(one, "bca") == one+2, 15); /* False start. */ (void) strcpy(one, "bbbcabbca"); check(strstr(one, "bbca") == one+1, 16); /* With overlap. */ /* strspn. */ it = "strspn"; check(strspn("abcba", "abc") == 5, 1); /* Whole string. */ check(strspn("abcba", "ab") == 2, 2); /* Partial. */ check(strspn("abc", "qx") == 0, 3); /* None. */ check(strspn("", "ab") == 0, 4); /* Null string. */ check(strspn("abc", "") == 0, 5); /* Null search list. */ /* strcspn. */ it = "strcspn"; check(strcspn("abcba", "qx") == 5, 1); /* Whole string. */ check(strcspn("abcba", "cx") == 2, 2); /* Partial. */ check(strcspn("abc", "abc") == 0, 3); /* None. */ check(strcspn("", "ab") == 0, 4); /* Null string. */ check(strcspn("abc", "") == 3, 5); /* Null search list. */ /* strtok - the hard one. */ it = "strtok"; (void) strcpy(one, "first, second, third"); equal(strtok(one, ", "), "first", 1); /* Basic test. */ equal(one, "first", 2); equal(strtok((char *)NULL, ", "), "second", 3); equal(strtok((char *)NULL, ", "), "third", 4); check(strtok((char *)NULL, ", ") == NULL, 5); (void) strcpy(one, ", first, "); equal(strtok(one, ", "), "first", 6); /* Extra delims, 1 tok. */ check(strtok((char *)NULL, ", ") == NULL, 7); (void) strcpy(one, "1a, 1b; 2a, 2b"); equal(strtok(one, ", "), "1a", 8); /* Changing delim lists. */ equal(strtok((char *)NULL, "; "), "1b", 9); equal(strtok((char *)NULL, ", "), "2a", 10); (void) strcpy(two, "x-y"); equal(strtok(two, "-"), "x", 11); /* New string before done. */ equal(strtok((char *)NULL, "-"), "y", 12); check(strtok((char *)NULL, "-") == NULL, 13); (void) strcpy(one, "a,b, c,, ,d"); equal(strtok(one, ", "), "a", 14); /* Different separators. */ equal(strtok((char *)NULL, ", "), "b", 15); equal(strtok((char *)NULL, " ,"), "c", 16); /* Permute list too. */ equal(strtok((char *)NULL, " ,"), "d", 17); check(strtok((char *)NULL, ", ") == NULL, 18); check(strtok((char *)NULL, ", ") == NULL, 19); /* Persistence. */ (void) strcpy(one, ", "); check(strtok(one, ", ") == NULL, 20); /* No tokens. */ (void) strcpy(one, ""); check(strtok(one, ", ") == NULL, 21); /* Empty string. */ (void) strcpy(one, "abc"); equal(strtok(one, ", "), "abc", 22); /* No delimiters. */ check(strtok((char *)NULL, ", ") == NULL, 23); (void) strcpy(one, "abc"); equal(strtok(one, ""), "abc", 24); /* Empty delimiter list. */ check(strtok((char *)NULL, "") == NULL, 25); (void) strcpy(one, "abcdefgh"); (void) strcpy(one, "a,b,c"); equal(strtok(one, ","), "a", 26); /* Basics again... */ equal(strtok((char *)NULL, ","), "b", 27); equal(strtok((char *)NULL, ","), "c", 28); check(strtok((char *)NULL, ",") == NULL, 29); equal(one+6, "gh", 30); /* Stomped past end? */ equal(one, "a", 31); /* Stomped old tokens? */ equal(one+2, "b", 32); equal(one+4, "c", 33); /* memcmp. */ it = "memcmp"; check(memcmp("a", "a", 1) == 0, 1); /* Identity. */ check(memcmp("abc", "abc", 3) == 0, 2); /* Multicharacter. */ check(memcmp("abcd", "abce", 4) < 0, 3); /* Honestly unequal. */ check(memcmp("abce", "abcd", 4) > 0, 4); check(memcmp("alph", "beta", 4) < 0, 5); check(memcmp("a\203", "a\003", 2) > 0, 6); check(memcmp("abce", "abcd", 3) == 0, 7); /* Count limited. */ check(memcmp("abc", "def", 0) == 0, 8); /* Zero count. */ /* memchr. */ it = "memchr"; check(memchr("abcd", 'z', 4) == NULL, 1); /* Not found. */ (void) strcpy(one, "abcd"); check(memchr(one, 'c', 4) == one+2, 2); /* Basic test. */ check(memchr(one, 'd', 4) == one+3, 3); /* End of string. */ check(memchr(one, 'a', 4) == one, 4); /* Beginning. */ check(memchr(one, '\0', 5) == one+4, 5); /* Finding NUL. */ (void) strcpy(one, "ababa"); check(memchr(one, 'b', 5) == one+1, 6); /* Finding first. */ check(memchr(one, 'b', 0) == NULL, 7); /* Zero count. */ check(memchr(one, 'a', 1) == one, 8); /* Singleton case. */ (void) strcpy(one, "a\203b"); check(memchr(one, 0203, 3) == one+1, 9); /* Unsignedness. */ /* memcpy - need not work for overlap. */ it = "memcpy"; check(memcpy(one, "abc", 4) == one, 1); /* Returned value. */ equal(one, "abc", 2); /* Did the copy go right? */ (void) strcpy(one, "abcdefgh"); (void) memcpy(one+1, "xyz", 2); equal(one, "axydefgh", 3); /* Basic test. */ (void) strcpy(one, "abc"); (void) memcpy(one, "xyz", 0); equal(one, "abc", 4); /* Zero-length copy. */ (void) strcpy(one, "hi there"); (void) strcpy(two, "foo"); (void) memcpy(two, one, 9); equal(two, "hi there", 5); /* Just paranoia. */ equal(one, "hi there", 6); /* Stomped on source? */ /* memmove - must work on overlap. */ it = "memmove"; check(memmove(one, "abc", 4) == one, 1); /* Returned value. */ equal(one, "abc", 2); /* Did the copy go right? */ (void) strcpy(one, "abcdefgh"); (void) memmove(one+1, "xyz", 2); equal(one, "axydefgh", 3); /* Basic test. */ (void) strcpy(one, "abc"); (void) memmove(one, "xyz", 0); equal(one, "abc", 4); /* Zero-length copy. */ (void) strcpy(one, "hi there"); (void) strcpy(two, "foo"); (void) memmove(two, one, 9); equal(two, "hi there", 5); /* Just paranoia. */ equal(one, "hi there", 6); /* Stomped on source? */ (void) strcpy(one, "abcdefgh"); (void) memmove(one+1, one, 9); equal(one, "aabcdefgh", 7); /* Overlap, right-to-left. */ (void) strcpy(one, "abcdefgh"); (void) memmove(one+1, one+2, 7); equal(one, "acdefgh", 8); /* Overlap, left-to-right. */ (void) strcpy(one, "abcdefgh"); (void) memmove(one, one, 9); equal(one, "abcdefgh", 9); /* 100% overlap. */ /* memccpy - first test like memcpy, then the search part The SVID, the only place where memccpy is mentioned, says overlap might fail, so we don't try it. Besides, it's hard to see the rationale for a non-left-to-right memccpy. */ it = "memccpy"; check(memccpy(one, "abc", 'q', 4) == NULL, 1); /* Returned value. */ equal(one, "abc", 2); /* Did the copy go right? */ (void) strcpy(one, "abcdefgh"); (void) memccpy(one+1, "xyz", 'q', 2); equal(one, "axydefgh", 3); /* Basic test. */ (void) strcpy(one, "abc"); (void) memccpy(one, "xyz", 'q', 0); equal(one, "abc", 4); /* Zero-length copy. */ (void) strcpy(one, "hi there"); (void) strcpy(two, "foo"); (void) memccpy(two, one, 'q', 9); equal(two, "hi there", 5); /* Just paranoia. */ equal(one, "hi there", 6); /* Stomped on source? */ (void) strcpy(one, "abcdefgh"); (void) strcpy(two, "horsefeathers"); check(memccpy(two, one, 'f', 9) == two+6, 7); /* Returned value. */ equal(one, "abcdefgh", 8); /* Source intact? */ equal(two, "abcdefeathers", 9); /* Copy correct? */ (void) strcpy(one, "abcd"); (void) strcpy(two, "bumblebee"); check(memccpy(two, one, 'a', 4) == two+1, 10); /* First char. */ equal(two, "aumblebee", 11); check(memccpy(two, one, 'd', 4) == two+4, 12); /* Last char. */ equal(two, "abcdlebee", 13); (void) strcpy(one, "xyz"); check(memccpy(two, one, 'x', 1) == two+1, 14); /* Singleton. */ equal(two, "xbcdlebee", 15); /* memset. */ it = "memset"; (void) strcpy(one, "abcdefgh"); check(memset(one+1, 'x', 3) == one+1, 1); /* Return value. */ equal(one, "axxxefgh", 2); /* Basic test. */ (void) memset(one+2, 'y', 0); equal(one, "axxxefgh", 3); /* Zero-length set. */ (void) memset(one+5, 0, 1); equal(one, "axxxe", 4); /* Zero fill. */ equal(one+6, "gh", 5); /* And the leftover. */ (void) memset(one+2, 010045, 1); equal(one, "ax\045xe", 6); /* Unsigned char convert. */ /* bcopy - much like memcpy. Berklix manual is silent about overlap, so don't test it. */ it = "bcopy"; (void) bcopy("abc", one, 4); equal(one, "abc", 1); /* Simple copy. */ (void) strcpy(one, "abcdefgh"); (void) bcopy("xyz", one+1, 2); equal(one, "axydefgh", 2); /* Basic test. */ (void) strcpy(one, "abc"); (void) bcopy("xyz", one, 0); equal(one, "abc", 3); /* Zero-length copy. */ (void) strcpy(one, "hi there"); (void) strcpy(two, "foo"); (void) bcopy(one, two, 9); equal(two, "hi there", 4); /* Just paranoia. */ equal(one, "hi there", 5); /* Stomped on source? */ /* bzero. */ it = "bzero"; (void) strcpy(one, "abcdef"); bzero(one+2, 2); equal(one, "ab", 1); /* Basic test. */ equal(one+3, "", 2); equal(one+4, "ef", 3); (void) strcpy(one, "abcdef"); bzero(one+2, 0); equal(one, "abcdef", 4); /* Zero-length copy. */ /* bcmp - somewhat like memcmp. */ it = "bcmp"; check(bcmp("a", "a", 1) == 0, 1); /* Identity. */ check(bcmp("abc", "abc", 3) == 0, 2); /* Multicharacter. */ check(bcmp("abcd", "abce", 4) != 0, 3); /* Honestly unequal. */ check(bcmp("abce", "abcd", 4) != 0, 4); check(bcmp("alph", "beta", 4) != 0, 5); check(bcmp("abce", "abcd", 3) == 0, 6); /* Count limited. */ check(bcmp("abc", "def", 0) == 0, 8); /* Zero count. */ /* strerror - VERY system-dependent. */ { int f; it = "strerror"; f = open("/", O_WRONLY); /* Should always fail. */ check(f < 0 && errno > 0 && errno < sys_nerr, 1); equal(strerror(errno), sys_errlist[errno], 2); } { int status; if (errors == 0) { status = EXIT_SUCCESS; puts("No errors."); } else { status = EXIT_FAILURE; printf("%d errors.\n", errors); } exit(status); } } ./libc-linux/string/strncscmp.c100644 1676 334 1561 5377242725 14622 0ustar hjlisl/* * This file is part of the C library for Linux and is * covered by the GNU Library General Public license version 2, or * any later version. * * Copyright (C) 1992, 1993 Hoongjiu Lu * */ #include #include #include /* Compare no more than N characters of S1 and S2, ignoring case, returning less than, equal to or greater than zero if S1 is lexiographically less than, equal to or greater than S2. */ int DEFUN(strncasecmp, (s1, s2, n), CONST char *s1 AND CONST char *s2 AND size_t n) { register CONST unsigned char *p1 = (CONST unsigned char *) s1; register CONST unsigned char *p2 = (CONST unsigned char *) s2; register int ret; unsigned char c1; if (p1 == p2) return 0; for (; n--; p1++, p2++) { if (ret = (c1 = tolower(*p1)) - tolower(*p2)) return ret; if (c1 == '\0') break; } return (0); } ./libc-linux/string/memcpy.c100644 1676 334 3575 5263452716 14104 0ustar hjlisl/* memcpy -- copy memory to memory until the specified number of bytes has been copied. Overlap is NOT handled correctly. Copyright (C) 1991 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 PTR DEFUN(memcpy, (dstpp, srcpp, len), PTR dstpp AND CONST PTR srcpp AND size_t len) { unsigned long int dstp = (long int) dstpp; unsigned long int srcp = (long int) srcpp; /* Copy from the beginning to the end. */ /* If there not too few bytes to copy, use word copy. */ if (len >= OP_T_THRES) { /* Copy just a few bytes to make DSTP aligned. */ len -= (-dstp) % OPSIZ; BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ); /* Copy from SRCP to DSTP taking advantage of the known alignment of DSTP. Number of bytes remaining is put in the third argumnet, i.e. in LEN. This number may vary from machine to machine. */ WORD_COPY_FWD (dstp, srcp, len, len); /* Fall out and copy the tail. */ } /* There are just a few bytes to copy. Use byte memory operations. */ BYTE_COPY_FWD (dstp, srcp, len); return dstpp; } ./libc-linux/string/memmem.c100644 1676 334 2721 5263452716 14057 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 /* Return the first occurrence of NEEDLE in HAYSTACK. */ PTR DEFUN(memmem, (needle, needle_len, haystack, haystack_len), CONST PTRCONST needle AND CONST size_t needle_len AND CONST PTRCONST haystack AND CONST size_t haystack_len) { register CONST char *begin; if (needle_len == 0) return (PTR) &((CONST char *) haystack)[needle_len - 1]; for (begin = &((CONST char *) haystack)[needle_len - 1]; begin < (CONST char *) haystack + haystack_len; ++begin) if (!memcmp ((PTR) begin, needle, needle_len)) return (PTR) begin; return NULL; } ./libc-linux/string/memmove.c100644 1676 334 6315 5304265225 14243 0ustar hjlisl/* memmove -- copy memory to memory until the specified number of bytes has been copied. Overlap is handled correctly. Copyright (C) 1991 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 /* All this is so that bcopy.c can #include this file after defining some things. */ #ifndef a1 #define a1 dest /* First arg is DEST. */ #define a1const #define a2 src /* Second arg is SRC. */ #define a2const CONST #endif #if !defined(RETURN) || !defined(rettype) #define RETURN(s) return (s) /* Return DEST. */ #define rettype PTR #endif #ifdef isbcopy #define size_t int #endif rettype DEFUN(memmove, (a1, a2, len), a1const PTR a1 AND a2const PTR a2 AND size_t len) { unsigned long int dstp = (long int) dest; unsigned long int srcp = (long int) src; #ifdef isbcopy if (len <= 0) return; #endif /* This test makes the forward copying code be used whenever possible. Reduces the working set. */ if (dstp - srcp >= len) /* *Unsigned* compare! */ { /* Copy from the beginning to the end. */ /* If there not too few bytes to copy, use word copy. */ if (len >= OP_T_THRES) { /* Copy just a few bytes to make DSTP aligned. */ len -= (-dstp) % OPSIZ; BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ); /* Copy from SRCP to DSTP taking advantage of the known alignment of DSTP. Number of bytes remaining is put in the third argumnet, i.e. in LEN. This number may vary from machine to machine. */ WORD_COPY_FWD (dstp, srcp, len, len); /* Fall out and copy the tail. */ } /* There are just a few bytes to copy. Use byte memory operations. */ BYTE_COPY_FWD (dstp, srcp, len); } else { /* Copy from the end to the beginning. */ srcp += len; dstp += len; /* If there not too few bytes to copy, use word copy. */ if (len >= OP_T_THRES) { /* Copy just a few bytes to make DSTP aligned. */ len -= dstp % OPSIZ; BYTE_COPY_BWD (dstp, srcp, dstp % OPSIZ); /* Copy from SRCP to DSTP taking advantage of the known alignment of DSTP. Number of bytes remaining is put in the third argumnet, i.e. in LEN. This number may vary from machine to machine. */ WORD_COPY_BWD (dstp, srcp, len, len); /* Fall out and copy the tail. */ } /* There are just a few bytes to copy. Use byte memory operations. */ BYTE_COPY_BWD (dstp, srcp, len); } RETURN(dest); } ./libc-linux/string/strcasecmp.c100644 1676 334 1445 5377242674 14756 0ustar hjlisl/* * This file is part of the C library for Linux and is * covered by the GNU Library General Public license version 2, or * any later version. * * Copyright (C) 1992, 1993 Hoongjiu Lu * */ #include #include #include /* Compare S1 and S2, ignoring case, returning less than, equal to or greater than zero if S1 is lexiographically less than, equal to or greater than S2. */ int DEFUN(strcasecmp, (s1, s2), CONST char *s1 AND CONST char *s2) { register CONST unsigned char *p1 = (CONST unsigned char *) s1; register CONST unsigned char *p2 = (CONST unsigned char *) s2; register int ret; unsigned char c1; if (p1 == p2) return 0; for (; !(ret = (c1 = tolower(*p1)) - tolower(*p2)); p1++, p2++) if (c1 == '\0') break; return ret; } ./libc-linux/string/strcpy.c100644 1676 334 2226 5263452717 14127 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 /* Copy SRC to DEST. */ char * DEFUN(strcpy, (dest, src), char *dest AND CONST char *src) { reg_char c; char *s = (char *) src; CONST ptrdiff_t off = dest - src - 1; do { c = *s++; s[off] = c; } while (c != '\0'); return dest; } ./libc-linux/string/strncat.c100644 1676 334 3247 5263452717 14265 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 char * DEFUN(strncat, (s1, s2, n), char *s1 AND CONST char *s2 AND size_t n) { reg_char c; char *s = s1; /* Find the end of S1. */ do c = *s1++; while (c != '\0'); /* Make S1 point before next character, so we can increment it while memory is read (wins on pipelined cpus). */ s1 -= 2; if (n >= 4) { size_t n4 = n >> 2; do { c = *s2++; *++s1 = c; if (c == '\0') return s; c = *s2++; *++s1 = c; if (c == '\0') return s; c = *s2++; *++s1 = c; if (c == '\0') return s; c = *s2++; *++s1 = c; if (c == '\0') return s; } while (--n4 > 0); n &= 3; } while (n > 0) { c = *s2++; *++s1 = c; if (c == '\0') return s; n--; } if (c != '\0') *++s1 = '\0'; return s; } ./libc-linux/string/strncpy.c100644 1676 334 3173 5263452717 14307 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 char * DEFUN(strncpy, (s1, s2, n), char *s1 AND CONST char *s2 AND size_t n) { reg_char c; char *s = s1; --s1; if (n >= 4) { size_t n4 = n >> 2; for (;;) { c = *s2++; *++s1 = c; if (c == '\0') break; c = *s2++; *++s1 = c; if (c == '\0') break; c = *s2++; *++s1 = c; if (c == '\0') break; c = *s2++; *++s1 = c; if (c == '\0') break; if (--n4 == 0) goto last_chars; } n = n - (s1 - s) - 1; if (n == 0) return s; goto zero_fill; } last_chars: n &= 3; if (n == 0) return s; do { c = *s2++; *++s1 = c; if (--n == 0) return s; } while (c != '\0'); zero_fill: do *++s1 = '\0'; while (--n > 0); return s; } ./libc-linux/string/strsep.c100644 1676 334 2127 5362716043 14116 0ustar hjlisl/* Copyright (C) 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 char * DEFUN (strsep, (pp, delim), char **pp AND CONST char *delim) { char *p, *q; if (!(p = *pp)) return 0; if (q = strpbrk (p, delim)) { *pp = q + 1; *q = '\0'; } else *pp = 0; return p; } ./libc-linux/string/bcopy.c100644 1676 334 2037 5263506721 13712 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 #define memmove bcopy #define rettype void #define RETURN(s) return #define a1 src #define a1const CONST #define a2 dest #define a2const #define isbcopy #include ./libc-linux/string/strstr.c100644 1676 334 3515 5346060011 14126 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 /* Return the first ocurrence of NEEDLE in HAYSTACK. */ char * DEFUN(strstr, (haystack, needle), CONST char *CONST haystack AND CONST char *CONST needle) { register CONST char *CONST needle_end = strchr(needle, '\0'); register CONST char *CONST haystack_end = strchr(haystack, '\0'); register CONST size_t needle_len = needle_end - needle; register CONST size_t needle_last = needle_len - 1; register CONST char *begin; if (needle_len == 0) #ifdef __linux__ return (char *) haystack; #else return (char *) haystack_end; #endif if ((size_t) (haystack_end - haystack) < needle_len) return NULL; for (begin = &haystack[needle_last]; begin < haystack_end; ++begin) { register CONST char *n = &needle[needle_last]; register CONST char *h = begin; do if (*h != *n) goto loop; /* continue for loop */ while (--n >= needle && --h >= haystack); return (char *) h; loop:; } return NULL; } ./libc-linux/string/Makefile100644 1676 334 1401 5515544530 14064 0ustar hjlisl# # Makefile for string functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I. -I$(TOPDIR) \ -I$(TOPDIR)/sysdeps/$(TARGET_ARCH) \ -I$(TOPDIR)/sysdeps/generic DIRS:= SRC1S= __memccpy.c bcmp.c bcopy.c \ memcpy.c memfrob.c memmem.c memmove.c strcasecmp.c \ strcoll.c strcpy.c strdup.c strerror.c strfry.c \ strncscmp.c strncat.c strncpy.c strsep.c strsignal.c \ strstr.c strtok.c strxfrm.c swab.c # bzero.c ffs.c memchr.c memcmp.c memset.c strcat.c strchr.c strcmp.c # strcspn.c strlen.c strncmp.c strpbrk.c strrchr.c strspn.c # SRC2S= index.c memccpy.c rindex.c errlist.c siglist.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/string/__memccpy.c100644 1676 334 2576 5263505344 14541 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 /* For size_t and NULL. */ /* * Copy no more than N bytes of SRC to DEST, stopping when C is found. * Return the position in DEST one byte past where C was copied, * or NULL if C was not found in the first N bytes of SRC. */ PTR DEFUN(__memccpy, (dest, src, c, n), PTR dest AND CONST PTR src AND int c AND size_t n) { register CONST char *s = src; register char *d = dest; register CONST int x = (unsigned char) c; register size_t i = n; while (i-- > 0) if ((*d++ = *s++) == x) return d; return NULL; } ./libc-linux/string/strbug.c100644 1676 334 1235 5263632326 14104 0ustar hjlisl#include #include #include #include #include #include #ifndef HAVE_GNU_LD #define _sys_nerr sys_nerr #define _sys_errlist sys_errlist #endif #define STREQ(a, b) (strcmp((a), (b)) == 0) /* Complain if condition is not true. */ void check (int thing, int number) { if (!thing) { printf("strcmp: flunked test %d with result %d\n", number, thing); } else printf("strcmp: passed test %d with result %d\n", number, thing); } int main () { /* Test strcmp first because we use it to test other things. */ check(strcmp("abcd", "abc"), 5); check(strcmp("abcd", "abc") > 0, 5); } ./libc-linux/string/errlist.c100644 1676 334 214 5266474235 14244 0ustar hjlisl#include #undef sys_errlist #undef sys_nerr symbol_alias (_sys_errlist, sys_errlist); symbol_alias (_sys_nerr, sys_nerr); ./libc-linux/string/siglist.c100644 1676 334 127 5266474074 14242 0ustar hjlisl#include #undef sys_siglist symbol_alias (_sys_siglist, sys_siglist); ./libc-linux/string/memfill.c100644 1676 334 2504 5376252750 14227 0ustar hjlisl/* memfill -- fill a block of memory with n bytes. For Intel 80x86, x>=3. Copyright (C) 1993 Free Software Foundation, Inc. Contributed by H.J. Lu (hlu@eecs.wsu.edu) The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as 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 PTR DEFUN(memfill, (dstpp, dstlen, srcpp, srclen), PTR dstpp AND size_t dstlen AND PTR srcpp AND size_t srclen) { unsigned long int dstp = (unsigned long int) dstpp; if (!dstlen || !srclen) return dstpp; for (;dstlen >= srclen; dstlen -= srclen, dstp += srclen) { memcpy ((PTR) dstp, srcpp, srclen); } if (dstlen) memcpy ((PTR) dstp, srcpp, dstlen); return (dstpp); } ./libc-linux/string/stricmp.c100644 1676 334 1430 5431264244 14251 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 #undef stricmp #include function_alias(stricmp, strcasecmp, int, (s1, s2), DEFUN(stricmp, (s1, s2), CONST char *s1 AND CONST char *s2)) ./libc-linux/string/strnicmp.c100644 1676 334 1457 5431264665 14447 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 #undef strnicmp #include function_alias(strnicmp, strncasecmp, int, (s1, s2, n), DEFUN(strnicmp, (s1, s2, n), CONST char *s1 AND CONST char *s2 AND size_t n)) ./libc-linux/termcap/ 40755 1676 334 0 5550055765 12466 5ustar hjlisl./libc-linux/termcap/termcap.c100644 1676 334 42411 5372247572 14405 0ustar hjlisl/* Work-alike for termcap, plus extra features. Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc. This program 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 program 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 this program; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Emacs config.h may rename various library functions such as malloc. */ #ifdef HAVE_CONFIG_H #include "config.h" #else /* not HAVE_CONFIG_H */ #ifdef __linux__ #undef STDC_HEADERS #define STDC_HEADERS #define HAVE_UNISTD_H #define HAVE_SYS_IOCTL_H #else #if defined(HAVE_STRING_H) || defined(STDC_HEADERS) #define bcopy(s, d, n) memcpy ((d), (s), (n)) #endif #endif #ifdef STDC_HEADERS #include #include #else char *getenv (); char *malloc (); char *realloc (); #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef _POSIX_VERSION #include #endif #ifdef HAVE_SYS_IOCTL_H #include #include #endif #endif /* not HAVE_CONFIG_H */ #ifndef NULL #define NULL (char *) 0 #endif /* BUFSIZE is the initial size allocated for the buffer for reading the termcap file. It is not a limit. Make it large normally for speed. Make it variable when debugging, so can exercise increasing the space dynamically. */ #ifndef BUFSIZE #ifdef DEBUG #define BUFSIZE bufsize int bufsize = 128; #else #define BUFSIZE 2048 #endif #endif #ifdef TIOCGWINSZ #define ADJUST_WIN_EXTENT #endif #ifndef emacs static void memory_out () { write (2, "virtual memory exhausted\n", 25); exit (1); } static char * xmalloc (size) unsigned size; { register char *tem = malloc (size); if (!tem) memory_out (); return tem; } static char * xrealloc (ptr, size) char *ptr; unsigned size; { register char *tem = realloc (ptr, size); if (!tem) memory_out (); return tem; } #endif /* not emacs */ /* Looking up capabilities in the entry already found. */ /* The pointer to the data made by tgetent is left here for tgetnum, tgetflag and tgetstr to find. */ static char *term_entry; static char *tgetst1 (); /* Search entry BP for capability CAP. Return a pointer to the capability (in BP) if found, 0 if not found. */ static char * find_capability (bp, cap) register char *bp, *cap; { for (; *bp; bp++) if (bp[0] == ':' && bp[1] == cap[0] && bp[2] == cap[1]) return &bp[4]; return NULL; } int tgetnum (cap) char *cap; { register char *ptr = find_capability (term_entry, cap); if (!ptr || ptr[-1] != '#') return -1; return atoi (ptr); } int tgetflag (cap) char *cap; { register char *ptr = find_capability (term_entry, cap); return ptr && ptr[-1] == ':'; } /* Look up a string-valued capability CAP. If AREA is non-null, it points to a pointer to a block in which to store the string. That pointer is advanced over the space used. If AREA is null, space is allocated with `malloc'. */ char * tgetstr (cap, area) char *cap; char **area; { register char *ptr = find_capability (term_entry, cap); if (!ptr || (ptr[-1] != '=' && ptr[-1] != '~')) return NULL; return tgetst1 (ptr, area); } /* Table, indexed by a character in range 0100 to 0140 with 0100 subtracted, gives meaning of character following \, or a space if no special meaning. Eight characters per line within the string. */ static char esctab[] = " \007\010 \033\014 \ \012 \ \015 \011 \013 \ "; /* PTR points to a string value inside a termcap entry. Copy that value, processing \ and ^ abbreviations, into the block that *AREA points to, or to newly allocated storage if AREA is NULL. Return the address to which we copied the value, or NULL if PTR is NULL. */ static char * tgetst1 (ptr, area) char *ptr; char **area; { register char *p, *r; register int c; register int size; char *ret; register int c1; if (!ptr) return NULL; /* `ret' gets address of where to store the string. */ if (!area) { /* Compute size of block needed (may overestimate). */ p = ptr; while ((c = *p++) && c != ':' && c != '\n') ; ret = (char *) xmalloc (p - ptr + 1); } else ret = *area; /* Copy the string value, stopping at null or colon. Also process ^ and \ abbreviations. */ p = ptr; r = ret; while ((c = *p++) && c != ':' && c != '\n') { if (c == '^') c = *p++ & 037; else if (c == '\\') { c = *p++; if (c >= '0' && c <= '7') { c -= '0'; size = 0; while (++size < 3 && (c1 = *p) >= '0' && c1 <= '7') { c *= 8; c += c1 - '0'; p++; } } else if (c >= 0100 && c < 0200) { c1 = esctab[(c & ~040) - 0100]; if (c1 != ' ') c = c1; } } *r++ = c; } *r = '\0'; /* Update *AREA. */ if (area) *area = r + 1; return ret; } /* Outputting a string with padding. */ #ifdef __linux__ speed_t ospeed; #else short ospeed; #endif /* If OSPEED is 0, we use this as the actual baud rate. */ int tputs_baud_rate; char PC; /* Actual baud rate if positive; - baud rate / 100 if negative. */ static short speeds[] = { #ifdef VMS 0, 50, 75, 110, 134, 150, -3, -6, -12, -18, -20, -24, -36, -48, -72, -96, -192 #else /* not VMS */ 0, 50, 75, 110, 135, 150, -2, -3, -6, -12, -18, -24, -48, -96, -192, -384 #endif /* not VMS */ }; void tputs (str, nlines, outfun) register char *str; int nlines; register int (*outfun) (); { register int padcount = 0; register int speed; #ifdef emacs extern baud_rate; speed = baud_rate; #else if (ospeed == 0) speed = tputs_baud_rate; else speed = speeds[ospeed]; #endif if (!str) return; while (*str >= '0' && *str <= '9') { padcount += *str++ - '0'; padcount *= 10; } if (*str == '.') { str++; padcount += *str++ - '0'; } if (*str == '*') { str++; padcount *= nlines; } while (*str) (*outfun) (*str++); /* padcount is now in units of tenths of msec. */ padcount *= speeds[ospeed]; padcount += 500; padcount /= 1000; if (speeds[ospeed] < 0) padcount = -padcount; else { padcount += 50; padcount /= 100; } while (padcount-- > 0) (*outfun) (PC); } /* Finding the termcap entry in the termcap data base. */ struct buffer { char *beg; int size; char *ptr; int ateof; int full; }; /* Forward declarations of static functions. */ static int scan_file (); static char *gobble_line (); static int compare_contin (); static int name_match (); #ifdef ADJUST_WIN_EXTENT #ifdef TIOCGWINSZ static int get_win_extent(li, co) int *li, *co; { struct winsize ws; /* Some TIOCGWINSZ may be broken. Make sure ws.ws_row and * ws.ws_col are not zero. */ if (ioctl(0, TIOCGWINSZ, &ws) != 0 || !ws.ws_row || !ws.ws_col) return -1; *li = ws.ws_row; *co = ws.ws_col; return 0; } #endif /* TIOCGWINSZ */ static int adjust_win_extent(bpp, howalloc, li, co) char **bpp; int howalloc; /* 0 must do in place, 1 must use malloc, 2 must use realloc */ int li, co; { int licolen, o_len, t, colon; char *licobuf, *s; if (li < 0 || co < 0) return 0; for (s = *bpp, colon = -1; *s; ++s) if (*s == ':' && colon < 0) colon = s - *bpp; o_len = s - *bpp; licolen = 11; for (t = li; (t /= 10) > 0; ++licolen); for (t = co; (t /= 10) > 0; ++licolen); licobuf = xmalloc(licolen + 1); sprintf(licobuf, ":li#%d:co#%d:", li, co); if (howalloc == 0) { bcopy(*bpp + colon, *bpp + colon + licolen, o_len - colon + 1); bcopy(licobuf, *bpp + colon, licolen); } else if (howalloc == 1) { char *newbp; newbp = xmalloc(o_len + licolen + 1); bcopy(*bpp, newbp, colon); bcopy(licobuf, newbp + colon, licolen); strcpy(newbp + colon + licolen, *bpp + colon); *bpp = newbp; } else /* (howalloc == 2) */ { char *newbp; newbp = xrealloc(*bpp, o_len + licolen + 1); bcopy(newbp + colon, newbp + colon + licolen, o_len - colon + 1); bcopy(licobuf, newbp + colon, licolen); *bpp = newbp; } free(licobuf); return 1; } #endif /* ADJUST_WIN_EXTENT */ #ifdef VMS #include #include #include static int valid_filename_p (fn) char *fn; { struct FAB fab = cc$rms_fab; struct NAM nam = cc$rms_nam; char esa[NAM$C_MAXRSS]; fab.fab$l_fna = fn; fab.fab$b_fns = strlen(fn); fab.fab$l_nam = &nam; fab.fab$l_fop = FAB$M_NAM; nam.nam$l_esa = esa; nam.nam$b_ess = sizeof esa; return SYS$PARSE(&fab, 0, 0) == RMS$_NORMAL; } #else /* !VMS */ #define valid_filename_p(fn) (*(fn) == '/') #endif /* !VMS */ /* Find the termcap entry data for terminal type NAME and store it in the block that BP points to. Record its address for future use. If BP is null, space is dynamically allocated. Return -1 if there is some difficulty accessing the data base of terminal types, 0 if the data base is accessible but the type NAME is not defined in it, and some other value otherwise. */ int tgetent (bp, name) char *bp, *name; { register char *termcap_name; register int fd; struct buffer buf; register char *bp1; char *bp2; char *term; int malloc_size = 0; register int c; char *tcenv; /* TERMCAP value, if it contains :tc=. */ char *indirect = NULL; /* Terminal type in :tc= in TERMCAP value. */ int filep; #ifdef ADJUST_WIN_EXTENT int li, co; /* #lines and columns on this tty */ if (get_win_extent(&li, &co) != 0) li = co = -1; #endif /* ADJUST_WIN_EXTENT */ termcap_name = getenv ("TERMCAP"); if (termcap_name && *termcap_name == '\0') termcap_name = NULL; filep = termcap_name && valid_filename_p (termcap_name); /* If termcap_name is non-null and starts with / (in the un*x case, that is), it is a file name to use instead of /etc/termcap. If it is non-null and does not start with /, it is the entry itself, but only if the name the caller requested matches the TERM variable. */ if (termcap_name && !filep && !strcmp (name, getenv ("TERM"))) { indirect = tgetst1 (find_capability (termcap_name, "tc"), (char **) 0); if (!indirect) { if (!bp) { bp = termcap_name; #ifdef ADJUST_WIN_EXTENT if (adjust_win_extent(&bp, 1, li, co)) malloc_size = 1; /* force return of bp */ #endif /* ADJUST_WIN_EXTENT */ } else { strcpy (bp, termcap_name); #ifdef ADJUST_WIN_EXTENT adjust_win_extent(&bp, 0, li, co); #endif /* ADJUST_WIN_EXTENT */ } goto ret; } else { /* It has tc=. Need to read /etc/termcap. */ tcenv = termcap_name; termcap_name = NULL; } } if (!termcap_name || !filep) #ifdef VMS termcap_name = "emacs_library:[etc]termcap.dat"; #else termcap_name = "/etc/termcap"; #endif /* Here we know we must search a file and termcap_name has its name. */ fd = open (termcap_name, 0, 0); if (fd < 0) return -1; buf.size = BUFSIZE; /* Add 1 to size to ensure room for terminating null. */ buf.beg = (char *) xmalloc (buf.size + 1); term = indirect ? indirect : name; if (!bp) { malloc_size = indirect ? strlen (tcenv) + 1 : buf.size; bp = (char *) xmalloc (malloc_size); } bp1 = bp; if (indirect) /* Copy the data from the environment variable. */ { strcpy (bp, tcenv); bp1 += strlen (tcenv); } while (term) { /* Scan the file, reading it via buf, till find start of main entry. */ if (scan_file (term, fd, &buf) == 0) { close (fd); free (buf.beg); if (malloc_size) free (bp); return 0; } /* Free old `term' if appropriate. */ if (term != name) free (term); /* If BP is malloc'd by us, make sure it is big enough. */ if (malloc_size) { malloc_size = bp1 - bp + buf.size; termcap_name = (char *) xrealloc (bp, malloc_size); bp1 += termcap_name - bp; bp = termcap_name; } bp2 = bp1; /* Copy the line of the entry from buf into bp. */ termcap_name = buf.ptr; while ((*bp1++ = c = *termcap_name++) && c != '\n') /* Drop out any \ newline sequence. */ if (c == '\\' && *termcap_name == '\n') { bp1--; termcap_name++; } *bp1 = '\0'; /* Does this entry refer to another terminal type's entry? If something is found, copy it into heap and null-terminate it. */ term = tgetst1 (find_capability (bp2, "tc"), (char **) 0); } close (fd); free (buf.beg); if (malloc_size) bp = (char *) xrealloc (bp, bp1 - bp + 1); #ifdef ADJUST_WIN_EXTENT adjust_win_extent(&bp, malloc_size ? 2 : 0, li, co); #endif /* ADJUST_WIN_EXTENT */ ret: term_entry = bp; if (malloc_size) return (int) bp; return 1; } /* Given file open on FD and buffer BUFP, scan the file from the beginning until a line is found that starts the entry for terminal type STR. Return 1 if successful, with that line in BUFP, or 0 if no entry is found in the file. */ static int scan_file (str, fd, bufp) char *str; int fd; register struct buffer *bufp; { register char *end; bufp->ptr = bufp->beg; bufp->full = 0; bufp->ateof = 0; *bufp->ptr = '\0'; lseek (fd, 0L, 0); while (!bufp->ateof) { /* Read a line into the buffer. */ end = NULL; do { /* if it is continued, append another line to it, until a non-continued line ends. */ end = gobble_line (fd, bufp, end); } while (!bufp->ateof && end[-2] == '\\'); if (*bufp->ptr != '#' && name_match (bufp->ptr, str)) return 1; /* Discard the line just processed. */ bufp->ptr = end; } return 0; } /* Return nonzero if NAME is one of the names specified by termcap entry LINE. */ static int name_match (line, name) char *line, *name; { register char *tem; if (!compare_contin (line, name)) return 1; /* This line starts an entry. Is it the right one? */ for (tem = line; *tem && *tem != '\n' && *tem != ':'; tem++) if (*tem == '|' && !compare_contin (tem + 1, name)) return 1; return 0; } static int compare_contin (str1, str2) register char *str1, *str2; { register int c1, c2; while (1) { c1 = *str1++; c2 = *str2++; while (c1 == '\\' && *str1 == '\n') { str1++; while ((c1 = *str1++) == ' ' || c1 == '\t'); } if (c2 == '\0') { /* End of type being looked up. */ if (c1 == '|' || c1 == ':') /* If end of name in data base, we win. */ return 0; else return 1; } else if (c1 != c2) return 1; } } /* Make sure that the buffer <- BUFP contains a full line of the file open on FD, starting at the place BUFP->ptr points to. Can read more of the file, discard stuff before BUFP->ptr, or make the buffer bigger. Return the pointer to after the newline ending the line, or to the end of the file, if there is no newline to end it. Can also merge on continuation lines. If APPEND_END is non-null, it points past the newline of a line that is continued; we add another line onto it and regard the whole thing as one line. The caller decides when a line is continued. */ static char * gobble_line (fd, bufp, append_end) int fd; register struct buffer *bufp; char *append_end; { register char *end; register int nread; register char *buf = bufp->beg; register char *tem; if (!append_end) append_end = bufp->ptr; while (1) { end = append_end; while (*end && *end != '\n') end++; if (*end) break; if (bufp->ateof) return buf + bufp->full; if (bufp->ptr == buf) { if (bufp->full == bufp->size) { bufp->size *= 2; /* Add 1 to size to ensure room for terminating null. */ tem = (char *) xrealloc (buf, bufp->size + 1); bufp->ptr = (bufp->ptr - buf) + tem; append_end = (append_end - buf) + tem; bufp->beg = buf = tem; } } else { append_end -= bufp->ptr - buf; bcopy (bufp->ptr, buf, bufp->full -= bufp->ptr - buf); bufp->ptr = buf; } if (!(nread = read (fd, buf + bufp->full, bufp->size - bufp->full))) bufp->ateof = 1; bufp->full += nread; buf[bufp->full] = '\0'; } return end + 1; } #ifdef TEST #ifdef NULL #undef NULL #endif #include main (argc, argv) int argc; char **argv; { char *term; char *buf; term = argv[1]; printf ("TERM: %s\n", term); buf = (char *) tgetent (0, term); if ((int) buf <= 0) { printf ("No entry.\n"); return 0; } printf ("Entry: %s\n", buf); tprint ("cm"); tprint ("AL"); printf ("co: %d\n", tgetnum ("co")); printf ("am: %d\n", tgetflag ("am")); } tprint (cap) char *cap; { char *x = tgetstr (cap, 0); register char *y; printf ("%s: ", cap); if (x) { for (y = x; *y; y++) if (*y <= ' ' || *y == 0177) printf ("\\%0o", *y); else putchar (*y); free (x); } else printf ("none"); putchar ('\n'); } #endif /* TEST */ ./libc-linux/termcap/tparam.c100644 1676 334 17024 5364066361 14234 0ustar hjlisl/* Merge parameters into a termcap entry string. Copyright (C) 1985, 1987, 1993 Free Software Foundation, Inc. This program 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 program 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 this program; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Emacs config.h may rename various library functions such as malloc. */ #ifdef HAVE_CONFIG_H #include "config.h" #else /* not HAVE_CONFIG_H */ #ifdef __linux__ #undef STDC_HEADERS #define STDC_HEADERS #define HAVE_UNISTD_H #if defined(HAVE_STRING_H) || defined(STDC_HEADERS) #define bcopy(s, d, n) memcpy ((d), (s), (n)) #endif #endif #ifdef STDC_HEADERS #include #include #else char *malloc (); char *realloc (); #endif #endif /* not HAVE_CONFIG_H */ #ifndef NULL #define NULL (char *) 0 #endif #ifndef emacs static void memory_out () { write (2, "virtual memory exhausted\n", 25); exit (1); } static char * xmalloc (size) unsigned size; { register char *tem = malloc (size); if (!tem) memory_out (); return tem; } static char * xrealloc (ptr, size) char *ptr; unsigned size; { register char *tem = realloc (ptr, size); if (!tem) memory_out (); return tem; } #endif /* not emacs */ /* Assuming STRING is the value of a termcap string entry containing `%' constructs to expand parameters, merge in parameter values and store result in block OUTSTRING points to. LEN is the length of OUTSTRING. If more space is needed, a block is allocated with `malloc'. The value returned is the address of the resulting string. This may be OUTSTRING or may be the address of a block got with `malloc'. In the latter case, the caller must free the block. The fourth and following args to tparam serve as the parameter values. */ static char *tparam1 (); /* VARARGS 2 */ char * tparam (string, outstring, len, arg0, arg1, arg2, arg3) char *string; char *outstring; int len; int arg0, arg1, arg2, arg3; { #ifdef NO_ARG_ARRAY int arg[4]; arg[0] = arg0; arg[1] = arg1; arg[2] = arg2; arg[3] = arg3; return tparam1 (string, outstring, len, NULL, NULL, arg); #else return tparam1 (string, outstring, len, NULL, NULL, &arg0); #endif } char *BC; char *UP; static char tgoto_buf[50]; char * tgoto (cm, hpos, vpos) char *cm; int hpos, vpos; { int args[2]; if (!cm) return NULL; args[0] = vpos; args[1] = hpos; return tparam1 (cm, tgoto_buf, 50, UP, BC, args); } static char * tparam1 (string, outstring, len, up, left, argp) char *string; char *outstring; int len; char *up, *left; register int *argp; { register int c; register char *p = string; register char *op = outstring; char *outend; int outlen = 0; register int tem; int *old_argp = argp; int doleft = 0; int doup = 0; outend = outstring + len; while (1) { /* If the buffer might be too short, make it bigger. */ if (op + 5 >= outend) { register char *new; if (outlen == 0) { outlen = len + 40; new = (char *) xmalloc (outlen); outend += 40; bcopy (outstring, new, op - outstring); } else { outend += outlen; outlen *= 2; new = (char *) xrealloc (outstring, outlen); } op += new - outstring; outend += new - outstring; outstring = new; } c = *p++; if (!c) break; if (c == '%') { c = *p++; tem = *argp; switch (c) { case 'd': /* %d means output in decimal. */ if (tem < 10) goto onedigit; if (tem < 100) goto twodigit; case '3': /* %3 means output in decimal, 3 digits. */ if (tem > 999) { *op++ = tem / 1000 + '0'; tem %= 1000; } *op++ = tem / 100 + '0'; case '2': /* %2 means output in decimal, 2 digits. */ twodigit: tem %= 100; *op++ = tem / 10 + '0'; onedigit: *op++ = tem % 10 + '0'; argp++; break; case 'C': /* For c-100: print quotient of value by 96, if nonzero, then do like %+. */ if (tem >= 96) { *op++ = tem / 96; tem %= 96; } case '+': /* %+x means add character code of char x. */ tem += *p++; case '.': /* %. means output as character. */ if (left) { /* If want to forbid output of 0 and \n and \t, and this is one of them, increment it. */ while (tem == 0 || tem == '\n' || tem == '\t') { tem++; if (argp == old_argp) doup++, outend -= strlen (up); else doleft++, outend -= strlen (left); } } *op++ = tem ? tem : 0200; case 'f': /* %f means discard next arg. */ argp++; break; case 'b': /* %b means back up one arg (and re-use it). */ argp--; break; case 'r': /* %r means interchange following two args. */ argp[0] = argp[1]; argp[1] = tem; old_argp++; break; case '>': /* %>xy means if arg is > char code of x, */ if (argp[0] > *p++) /* then add char code of y to the arg, */ argp[0] += *p; /* and in any case don't output. */ p++; /* Leave the arg to be output later. */ break; case 'a': /* %a means arithmetic. */ /* Next character says what operation. Add or subtract either a constant or some other arg. */ /* First following character is + to add or - to subtract or = to assign. */ /* Next following char is 'p' and an arg spec (0100 plus position of that arg relative to this one) or 'c' and a constant stored in a character. */ tem = p[2] & 0177; if (p[1] == 'p') tem = argp[tem - 0100]; if (p[0] == '-') argp[0] -= tem; else if (p[0] == '+') argp[0] += tem; else if (p[0] == '*') argp[0] *= tem; else if (p[0] == '/') argp[0] /= tem; else argp[0] = tem; p += 3; break; case 'i': /* %i means add one to arg, */ argp[0] ++; /* and leave it to be output later. */ argp[1] ++; /* Increment the following arg, too! */ break; case '%': /* %% means output %; no arg. */ goto ordinary; case 'n': /* %n means xor each of next two args with 140. */ argp[0] ^= 0140; argp[1] ^= 0140; break; case 'm': /* %m means xor each of next two args with 177. */ argp[0] ^= 0177; argp[1] ^= 0177; break; case 'B': /* %B means express arg as BCD char code. */ argp[0] += 6 * (tem / 10); break; case 'D': /* %D means weird Delta Data transformation. */ argp[0] -= 2 * (tem % 16); break; } } else /* Ordinary character in the argument string. */ ordinary: *op++ = c; } *op = 0; while (doup-- > 0) strcat (op, up); while (doleft-- > 0) strcat (op, left); return outstring; } #ifdef DEBUG main (argc, argv) int argc; char **argv; { char buf[50]; int args[3]; args[0] = atoi (argv[2]); args[1] = atoi (argv[3]); args[2] = atoi (argv[4]); tparam1 (argv[1], buf, "LEFT", "UP", args); printf ("%s\n", buf); return 0; } #endif /* DEBUG */ ./libc-linux/termcap/version.c100644 1676 334 202 5363067313 14360 0ustar hjlisl/* Make the library identifiable with the RCS ident command. */ static char *version_string = "\n$Version: GNU termcap 1.2 $\n"; ./libc-linux/termcap/Makefile100644 1676 334 707 5527714142 14202 0ustar hjlisl# # Makefile for termcap functions # override DEBUG=false override PROFILE=false #override CHECKER=false JUMP_LIB=libtermcap TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules override STATIC_LIB=$(STATIC_DIR)/libtermcap.a override SHARED_LIB=$(SHARED_DIR)/libtermcap.a override CHECKER_LIB=$(CHECKER_DIR)/libtermcap.a DIRS:= SRCS = termcap.c tparam.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/termcap/ChangeLog100644 1676 334 2766 5364066676 14356 0ustar hjlislSat Apr 17 13:50:10 1993 H.J. Lu (hlu@nighthawk) * modify termcap.c and tparam.c for Linux. Thu Apr 15 12:45:10 1993 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu) * Version 1.2. * tparam.c [!emacs] (xmalloc, xrealloc, memory_out): New functions. (tparam1): Use them. * termcap.c, tparam.c: Use NULL or '\0' where appropriate instead of 0. Rename some vars. * termcap.c (tgetent): If EOF is reached on termcap file, free allocated resources before returning. * termcap.c (tgetent): Use /etc/termcap if TERMCAP is an entry for a term type other than TERM. From pjr@jet.UK (Paul J Rippin). Sat Apr 10 23:55:12 1993 Richard Stallman (rms@mole.gnu.ai.mit.edu) * tparam.c (tparam1): Don't set the 0200 bit on a non-0 character code. From junio@twinsun.COM (Junio Hamano). Tue Dec 8 22:02:15 1992 David J. MacKenzie (djm@kropotkin.gnu.ai.mit.edu) * termcap.c, tparam.c: Use HAVE_STRING_H instead of USG. Thu Dec 3 13:47:56 1992 David J. MacKenzie (djm@nutrimat.gnu.ai.mit.edu) * termcap.c, tparam.c [HAVE_CONFIG_H]: Include config.h. Fri Oct 23 12:35:29 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) * termcap.h [__STDC__]: Add consts. From Franc,ois Pinard. Tue Oct 13 15:52:21 1992 David J. MacKenzie (djm@goldman.gnu.ai.mit.edu) * Version 1.1. Tue Sep 29 21:04:39 1992 David J. MacKenzie (djm@geech.gnu.ai.mit.edu) * termcap.[ch], tparam.c: Fix some lint. * version.c: New file. Local Variables: mode: indented-text left-margin: 8 version-control: never End: ./libc-linux/termcap/COPYING100644 1676 334 43076 5022247405 13634 0ustar hjlisl GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program 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 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ./libc-linux/termcap/README100644 1676 334 1255 5266625101 13435 0ustar hjlislThis is the GNU termcap library -- a library of C functions that enable programs to send control strings to terminals in a way independent of the terminal type. Most of this package is also distributed with GNU Emacs, but it is available in this separate distribution to make it easier to install as -ltermcap. The GNU termcap library does not place an arbitrary limit on the size of termcap entries, unlike most other termcap libraries. See the file INSTALL for compilation and installation instructions. Please report any bugs in this library to bug-gnu-emacs@prep.ai.mit.edu. You can check which version of the library you have by using the RCS `ident' command on libtermcap.a. ./libc-linux/termcap/NEWS100644 1676 334 447 5363321544 13240 0ustar hjlislMajor changes in release 1.2: For `%.', only set the high bit on NUL. Fix a file descriptor and memory leak. Add const in termcap.h prototypes. Configuration improvements. Major changes in release 1.1: Fix portability problems. Improve configuration and installation. Fix compiler warnings. ./libc-linux/time/ 40755 1676 334 0 5550056031 11754 5ustar hjlisl./libc-linux/time/Makefile100644 1676 334 714 5515544577 13515 0ustar hjlisl# # This is Makefile of time lib for Linux. # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules TIME_FLAGS=-DTZDIR='"/usr/lib/zoneinfo"' INC_CFLAGS=-I. BASE_CFLAGS := $(BASE_CFLAGS) $(TIME_FLAGS) DIRS:= SRC1S= bsdtime.c difftime.c strftime.c SRC2S= getitmr.c gettod.c setitmr.c settod.c adjtime.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/time/bsdtime.c100644 1676 334 103744 5362364171 13725 0ustar hjlisl/* * Copyright (c) 1987, 1989 Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * Arthur David Olson of the National Cancer Institute. * * 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[] = "@(#)ctime.c 5.26 (Berkeley) 2/23/91"; #endif /* LIBC_SCCS and not lint */ /* ** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu). ** POSIX-style TZ environment variable handling from Guy Harris ** (guy@auspex.com). */ /*LINTLIBRARY*/ #include #include #include #include #include #include #include #include #ifdef __STDC__ #include #define P(s) s #define alloc_size_t size_t #define qsort_size_t size_t #define fread_size_t size_t #define fwrite_size_t size_t #else /* !defined __STDC__ */ #define P(s) () typedef char * genericptr_t; typedef unsigned alloc_size_t; typedef int qsort_size_t; typedef int fread_size_t; typedef int fwrite_size_t; extern char * calloc(); extern char * malloc(); extern char * realloc(); extern char * getenv(); #endif /* !defined __STDC__ */ extern time_t time(); #define ACCESS_MODE O_RDONLY #define OPEN_MODE O_RDONLY #ifndef WILDABBR /* ** Someone might make incorrect use of a time zone abbreviation: ** 1. They might reference tzname[0] before calling tzset (explicitly ** or implicitly). ** 2. They might reference tzname[1] before calling tzset (explicitly ** or implicitly). ** 3. They might reference tzname[1] after setting to a time zone ** in which Daylight Saving Time is never observed. ** 4. They might reference tzname[0] after setting to a time zone ** in which Standard Time is never observed. ** 5. They might reference tm.TM_ZONE after calling offtime. ** What's best to do in the above cases is open to debate; ** for now, we just set things up so that in any of the five cases ** WILDABBR is used. Another possibility: initialize tzname[0] to the ** string "tzname[0] used before set", and similarly for the other cases. ** And another: initialize tzname[0] to "ERA", with an explanation in the ** manual page of what this "time zone abbreviation" means (doing this so ** that tzname[0] has the "normal" length of three characters). */ #define WILDABBR " " #endif /* !defined WILDABBR */ #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif /* !defined TRUE */ static const char GMT[] = "GMT"; struct ttinfo { /* time type information */ long tt_gmtoff; /* GMT offset in seconds */ int tt_isdst; /* used to set tm_isdst */ int tt_abbrind; /* abbreviation list index */ int tt_ttisstd; /* TRUE if transition is std time */ }; struct lsinfo { /* leap second information */ time_t ls_trans; /* transition time */ long ls_corr; /* correction to apply */ }; struct state { int leapcnt; int timecnt; int typecnt; int charcnt; time_t ats[TZ_MAX_TIMES]; unsigned char types[TZ_MAX_TIMES]; struct ttinfo ttis[TZ_MAX_TYPES]; char chars[(TZ_MAX_CHARS + 1 > sizeof GMT) ? TZ_MAX_CHARS + 1 : sizeof GMT]; struct lsinfo lsis[TZ_MAX_LEAPS]; }; struct rule { int r_type; /* type of rule--see below */ int r_day; /* day number of rule */ int r_week; /* week number of rule */ int r_mon; /* month number of rule */ long r_time; /* transition time of rule */ }; #define JULIAN_DAY 0 /* Jn - Julian day */ #define DAY_OF_YEAR 1 /* n - day of year */ #define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ /* ** Prototypes for static functions. */ static long detzcode P((const char * codep)); static const char * getzname P((const char * strp)); static const char * getnum P((const char * strp, int * nump, int min, int max)); static const char * getsecs P((const char * strp, long * secsp)); static const char * getoffset P((const char * strp, long * offsetp)); static const char * getrule P((const char * strp, struct rule * rulep)); static void gmtload P((struct state * sp)); static void gmtsub P((const time_t * timep, long offset, struct tm * tmp)); static void localsub P((const time_t * timep, long offset, struct tm * tmp)); static void normalize P((int * tensptr, int * unitsptr, int base)); static void settzname P((void)); static time_t time1 P((struct tm * tmp, void (* funcp)(), long offset)); static time_t time2 P((struct tm *tmp, void (* funcp)(), long offset, int * okayp)); static void timesub P((const time_t * timep, long offset, const struct state * sp, struct tm * tmp)); static int tmcomp P((const struct tm * atmp, const struct tm * btmp)); static time_t transtime P((time_t janfirst, int year, const struct rule * rulep, long offset)); static int tzload P((const char * name, struct state * sp)); static int tzparse P((const char * name, struct state * sp, int lastditch)); #ifdef ALL_STATE static struct state * lclptr; static struct state * gmtptr; #endif /* defined ALL_STATE */ #ifndef ALL_STATE static struct state lclmem; static struct state gmtmem; #define lclptr (&lclmem) #define gmtptr (&gmtmem) #endif /* State Farm */ static int lcl_is_set; static int gmt_is_set; char * tzname[2] = { WILDABBR, WILDABBR }; #define USG_COMPAT #ifdef USG_COMPAT time_t timezone = 0; int daylight = 0; #endif /* defined USG_COMPAT */ #ifdef ALTZONE time_t altzone = 0; #endif /* defined ALTZONE */ static long detzcode(codep) const char * const codep; { register long result; register int i; result = 0; for (i = 0; i < 4; ++i) result = (result << 8) | (codep[i] & 0xff); return result; } static void settzname() { register const struct state * const sp = lclptr; register int i; tzname[0] = WILDABBR; tzname[1] = WILDABBR; #ifdef USG_COMPAT daylight = 0; timezone = 0; #endif /* defined USG_COMPAT */ #ifdef ALTZONE altzone = 0; #endif /* defined ALTZONE */ #ifdef ALL_STATE if (sp == NULL) { tzname[0] = tzname[1] = GMT; return; } #endif /* defined ALL_STATE */ for (i = 0; i < sp->typecnt; ++i) { register const struct ttinfo * const ttisp = &sp->ttis[i]; tzname[ttisp->tt_isdst] = (char *) &sp->chars[ttisp->tt_abbrind]; #ifdef USG_COMPAT if (ttisp->tt_isdst) daylight = 1; if (i == 0 || !ttisp->tt_isdst) timezone = -(ttisp->tt_gmtoff); #endif /* defined USG_COMPAT */ #ifdef ALTZONE if (i == 0 || ttisp->tt_isdst) altzone = -(ttisp->tt_gmtoff); #endif /* defined ALTZONE */ } /* ** And to get the latest zone names into tzname. . . */ for (i = 0; i < sp->timecnt; ++i) { register const struct ttinfo * const ttisp = &sp->ttis[sp->types[i]]; tzname[ttisp->tt_isdst] = (char *) &sp->chars[ttisp->tt_abbrind]; } } static int tzload(name, sp) register const char * name; register struct state * const sp; { register const char * p; register int i; register int fid; if (name == NULL && (name = TZDEFAULT) == NULL) return -1; { char fullname[FILENAME_MAX + 1]; if (name[0] == ':') ++name; if (name[0] != '/') { if ((p = TZDIR) == NULL) return -1; if ((strlen(p) + strlen(name) + 1) >= sizeof fullname) return -1; (void) strcpy(fullname, p); (void) strcat(fullname, "/"); (void) strcat(fullname, name); name = fullname; } if ((fid = __open(name, OPEN_MODE)) == -1) return -1; } { register const struct tzhead * tzhp; char buf[sizeof *sp + sizeof *tzhp]; int ttisstdcnt; i = __read(fid, buf, sizeof buf); if (__close(fid) != 0 || i < sizeof *tzhp) return -1; tzhp = (struct tzhead *) buf; ttisstdcnt = (int) detzcode(tzhp->tzh_ttisstdcnt); sp->leapcnt = (int) detzcode(tzhp->tzh_leapcnt); sp->timecnt = (int) detzcode(tzhp->tzh_timecnt); sp->typecnt = (int) detzcode(tzhp->tzh_typecnt); sp->charcnt = (int) detzcode(tzhp->tzh_charcnt); if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS || sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES || sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES || sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS || (ttisstdcnt != sp->typecnt && ttisstdcnt != 0)) return -1; if (i < sizeof *tzhp + sp->timecnt * (4 + sizeof (char)) + sp->typecnt * (4 + 2 * sizeof (char)) + sp->charcnt * sizeof (char) + sp->leapcnt * 2 * 4 + ttisstdcnt * sizeof (char)) return -1; p = buf + sizeof *tzhp; for (i = 0; i < sp->timecnt; ++i) { sp->ats[i] = detzcode(p); p += 4; } for (i = 0; i < sp->timecnt; ++i) { sp->types[i] = (unsigned char) *p++; if (sp->types[i] >= sp->typecnt) return -1; } for (i = 0; i < sp->typecnt; ++i) { register struct ttinfo * ttisp; ttisp = &sp->ttis[i]; ttisp->tt_gmtoff = detzcode(p); p += 4; ttisp->tt_isdst = (unsigned char) *p++; if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1) return -1; ttisp->tt_abbrind = (unsigned char) *p++; if (ttisp->tt_abbrind < 0 || ttisp->tt_abbrind > sp->charcnt) return -1; } for (i = 0; i < sp->charcnt; ++i) sp->chars[i] = *p++; sp->chars[i] = '\0'; /* ensure '\0' at end */ for (i = 0; i < sp->leapcnt; ++i) { register struct lsinfo * lsisp; lsisp = &sp->lsis[i]; lsisp->ls_trans = detzcode(p); p += 4; lsisp->ls_corr = detzcode(p); p += 4; } for (i = 0; i < sp->typecnt; ++i) { register struct ttinfo * ttisp; ttisp = &sp->ttis[i]; if (ttisstdcnt == 0) ttisp->tt_ttisstd = FALSE; else { ttisp->tt_ttisstd = *p++; if (ttisp->tt_ttisstd != TRUE && ttisp->tt_ttisstd != FALSE) return -1; } } } return 0; } static const int mon_lengths[2][MONSPERYEAR] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static const int year_lengths[2] = { DAYSPERNYEAR, DAYSPERLYEAR }; /* ** Given a pointer into a time zone string, scan until a character that is not ** a valid character in a zone name is found. Return a pointer to that ** character. */ static const char * getzname(strp) register const char * strp; { register char c; while ((c = *strp) != '\0' && !isdigit(c) && c != ',' && c != '-' && c != '+') ++strp; return strp; } /* ** Given a pointer into a time zone string, extract a number from that string. ** Check that the number is within a specified range; if it is not, return ** NULL. ** Otherwise, return a pointer to the first character not part of the number. */ static const char * getnum(strp, nump, min, max) register const char * strp; int * const nump; const int min; const int max; { register char c; register int num; if (strp == NULL || !isdigit(*strp)) return NULL; num = 0; while ((c = *strp) != '\0' && isdigit(c)) { num = num * 10 + (c - '0'); if (num > max) return NULL; /* illegal value */ ++strp; } if (num < min) return NULL; /* illegal value */ *nump = num; return strp; } /* ** Given a pointer into a time zone string, extract a number of seconds, ** in hh[:mm[:ss]] form, from the string. ** If any error occurs, return NULL. ** Otherwise, return a pointer to the first character not part of the number ** of seconds. */ static const char * getsecs(strp, secsp) register const char * strp; long * const secsp; { int num; strp = getnum(strp, &num, 0, HOURSPERDAY); if (strp == NULL) return NULL; *secsp = num * SECSPERHOUR; if (*strp == ':') { ++strp; strp = getnum(strp, &num, 0, MINSPERHOUR - 1); if (strp == NULL) return NULL; *secsp += num * SECSPERMIN; if (*strp == ':') { ++strp; strp = getnum(strp, &num, 0, SECSPERMIN - 1); if (strp == NULL) return NULL; *secsp += num; } } return strp; } /* ** Given a pointer into a time zone string, extract an offset, in ** [+-]hh[:mm[:ss]] form, from the string. ** If any error occurs, return NULL. ** Otherwise, return a pointer to the first character not part of the time. */ static const char * getoffset(strp, offsetp) register const char * strp; long * const offsetp; { register int neg; if (*strp == '-') { neg = 1; ++strp; } else if (isdigit(*strp) || *strp++ == '+') neg = 0; else return NULL; /* illegal offset */ strp = getsecs(strp, offsetp); if (strp == NULL) return NULL; /* illegal time */ if (neg) *offsetp = -*offsetp; return strp; } /* ** Given a pointer into a time zone string, extract a rule in the form ** date[/time]. See POSIX section 8 for the format of "date" and "time". ** If a valid rule is not found, return NULL. ** Otherwise, return a pointer to the first character not part of the rule. */ static const char * getrule(strp, rulep) const char * strp; register struct rule * const rulep; { if (*strp == 'J') { /* ** Julian day. */ rulep->r_type = JULIAN_DAY; ++strp; strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR); } else if (*strp == 'M') { /* ** Month, week, day. */ rulep->r_type = MONTH_NTH_DAY_OF_WEEK; ++strp; strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR); if (strp == NULL) return NULL; if (*strp++ != '.') return NULL; strp = getnum(strp, &rulep->r_week, 1, 5); if (strp == NULL) return NULL; if (*strp++ != '.') return NULL; strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1); } else if (isdigit(*strp)) { /* ** Day of year. */ rulep->r_type = DAY_OF_YEAR; strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1); } else return NULL; /* invalid format */ if (strp == NULL) return NULL; if (*strp == '/') { /* ** Time specified. */ ++strp; strp = getsecs(strp, &rulep->r_time); } else rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */ return strp; } /* ** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the ** year, a rule, and the offset from GMT at the time that rule takes effect, ** calculate the Epoch-relative time that rule takes effect. */ static time_t transtime(janfirst, year, rulep, offset) const time_t janfirst; const int year; register const struct rule * const rulep; const long offset; { register int leapyear; register time_t value; register int i; int d, m1, yy0, yy1, yy2, dow; leapyear = isleap(year); switch (rulep->r_type) { case JULIAN_DAY: /* ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap ** years. ** In non-leap years, or if the day number is 59 or less, just ** add SECSPERDAY times the day number-1 to the time of ** January 1, midnight, to get the day. */ value = janfirst + (rulep->r_day - 1) * SECSPERDAY; if (leapyear && rulep->r_day >= 60) value += SECSPERDAY; break; case DAY_OF_YEAR: /* ** n - day of year. ** Just add SECSPERDAY times the day number to the time of ** January 1, midnight, to get the day. */ value = janfirst + rulep->r_day * SECSPERDAY; break; case MONTH_NTH_DAY_OF_WEEK: /* ** Mm.n.d - nth "dth day" of month m. */ value = janfirst; for (i = 0; i < rulep->r_mon - 1; ++i) value += mon_lengths[leapyear][i] * SECSPERDAY; /* ** Use Zeller's Congruence to get day-of-week of first day of ** month. */ m1 = (rulep->r_mon + 9) % 12 + 1; yy0 = (rulep->r_mon <= 2) ? (year - 1) : year; yy1 = yy0 / 100; yy2 = yy0 % 100; dow = ((26 * m1 - 2) / 10 + 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7; if (dow < 0) dow += DAYSPERWEEK; /* ** "dow" is the day-of-week of the first day of the month. Get ** the day-of-month (zero-origin) of the first "dow" day of the ** month. */ d = rulep->r_day - dow; if (d < 0) d += DAYSPERWEEK; for (i = 1; i < rulep->r_week; ++i) { if (d + DAYSPERWEEK >= mon_lengths[leapyear][rulep->r_mon - 1]) break; d += DAYSPERWEEK; } /* ** "d" is the day-of-month (zero-origin) of the day we want. */ value += d * SECSPERDAY; break; } /* ** "value" is the Epoch-relative time of 00:00:00 GMT on the day in ** question. To get the Epoch-relative time of the specified local ** time on that day, add the transition time and the current offset ** from GMT. */ return value + rulep->r_time + offset; } /* ** Given a POSIX section 8-style TZ string, fill in the rule tables as ** appropriate. */ static int tzparse(name, sp, lastditch) const char * name; register struct state * const sp; const int lastditch; { const char * stdname; const char * dstname; int stdlen; int dstlen; long stdoffset; long dstoffset; register time_t * atp; register unsigned char * typep; register char * cp; register int load_result; stdname = name; if (lastditch) { stdlen = strlen(name); /* length of standard zone name */ name += stdlen; if (stdlen >= sizeof sp->chars) stdlen = (sizeof sp->chars) - 1; } else { name = getzname(name); stdlen = name - stdname; if (stdlen < 3) return -1; } if (*name == '\0') return -1; else { name = getoffset(name, &stdoffset); if (name == NULL) return -1; } load_result = tzload(TZDEFRULES, sp); if (load_result != 0) sp->leapcnt = 0; /* so, we're off a little */ if (*name != '\0') { dstname = name; name = getzname(name); dstlen = name - dstname; /* length of DST zone name */ if (dstlen < 3) return -1; if (*name != '\0' && *name != ',' && *name != ';') { name = getoffset(name, &dstoffset); if (name == NULL) return -1; } else dstoffset = stdoffset - SECSPERHOUR; if (*name == ',' || *name == ';') { struct rule start; struct rule end; register int year; register time_t janfirst; time_t starttime; time_t endtime; ++name; if ((name = getrule(name, &start)) == NULL) return -1; if (*name++ != ',') return -1; if ((name = getrule(name, &end)) == NULL) return -1; if (*name != '\0') return -1; sp->typecnt = 2; /* standard time and DST */ /* ** Two transitions per year, from EPOCH_YEAR to 2037. */ sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1); if (sp->timecnt > TZ_MAX_TIMES) return -1; sp->ttis[0].tt_gmtoff = -dstoffset; sp->ttis[0].tt_isdst = 1; sp->ttis[0].tt_abbrind = stdlen + 1; sp->ttis[1].tt_gmtoff = -stdoffset; sp->ttis[1].tt_isdst = 0; sp->ttis[1].tt_abbrind = 0; atp = sp->ats; typep = sp->types; janfirst = 0; for (year = EPOCH_YEAR; year <= 2037; ++year) { starttime = transtime(janfirst, year, &start, stdoffset); endtime = transtime(janfirst, year, &end, dstoffset); if (starttime > endtime) { *atp++ = endtime; *typep++ = 1; /* DST ends */ *atp++ = starttime; *typep++ = 0; /* DST begins */ } else { *atp++ = starttime; *typep++ = 0; /* DST begins */ *atp++ = endtime; *typep++ = 1; /* DST ends */ } janfirst += year_lengths[isleap(year)] * SECSPERDAY; } } else { int sawstd; int sawdst; long stdfix; long dstfix; long oldfix; int isdst; register int i; if (*name != '\0') return -1; if (load_result != 0) return -1; /* ** Compute the difference between the real and ** prototype standard and summer time offsets ** from GMT, and put the real standard and summer ** time offsets into the rules in place of the ** prototype offsets. */ sawstd = FALSE; sawdst = FALSE; stdfix = 0; dstfix = 0; for (i = 0; i < sp->typecnt; ++i) { if (sp->ttis[i].tt_isdst) { oldfix = dstfix; dstfix = sp->ttis[i].tt_gmtoff + dstoffset; if (sawdst && (oldfix != dstfix)) return -1; sp->ttis[i].tt_gmtoff = -dstoffset; sp->ttis[i].tt_abbrind = stdlen + 1; sawdst = TRUE; } else { oldfix = stdfix; stdfix = sp->ttis[i].tt_gmtoff + stdoffset; if (sawstd && (oldfix != stdfix)) return -1; sp->ttis[i].tt_gmtoff = -stdoffset; sp->ttis[i].tt_abbrind = 0; sawstd = TRUE; } } /* ** Make sure we have both standard and summer time. */ if (!sawdst || !sawstd) return -1; /* ** Now correct the transition times by shifting ** them by the difference between the real and ** prototype offsets. Note that this difference ** can be different in standard and summer time; ** the prototype probably has a 1-hour difference ** between standard and summer time, but a different ** difference can be specified in TZ. */ isdst = FALSE; /* we start in standard time */ for (i = 0; i < sp->timecnt; ++i) { register const struct ttinfo * ttisp; /* ** If summer time is in effect, and the ** transition time was not specified as ** standard time, add the summer time ** offset to the transition time; ** otherwise, add the standard time offset ** to the transition time. */ ttisp = &sp->ttis[sp->types[i]]; sp->ats[i] += (isdst && !ttisp->tt_ttisstd) ? dstfix : stdfix; isdst = ttisp->tt_isdst; } } } else { dstlen = 0; sp->typecnt = 1; /* only standard time */ sp->timecnt = 0; sp->ttis[0].tt_gmtoff = -stdoffset; sp->ttis[0].tt_isdst = 0; sp->ttis[0].tt_abbrind = 0; } sp->charcnt = stdlen + 1; if (dstlen != 0) sp->charcnt += dstlen + 1; if (sp->charcnt > sizeof sp->chars) return -1; cp = sp->chars; (void) strncpy(cp, stdname, stdlen); cp += stdlen; *cp++ = '\0'; if (dstlen != 0) { (void) strncpy(cp, dstname, dstlen); *(cp + dstlen) = '\0'; } return 0; } static void gmtload(sp) struct state * const sp; { if (tzload(GMT, sp) != 0) (void) tzparse(GMT, sp, TRUE); } void tzset() { register const char * name; void tzsetwall(); name = getenv("TZ"); if (name == NULL) { tzsetwall(); return; } lcl_is_set = TRUE; #ifdef ALL_STATE if (lclptr == NULL) { lclptr = (struct state *) malloc(sizeof *lclptr); if (lclptr == NULL) { settzname(); /* all we can do */ return; } } #endif /* defined ALL_STATE */ if (*name == '\0') { /* ** User wants it fast rather than right. */ lclptr->leapcnt = 0; /* so, we're off a little */ lclptr->timecnt = 0; lclptr->ttis[0].tt_gmtoff = 0; lclptr->ttis[0].tt_abbrind = 0; (void) strcpy(lclptr->chars, GMT); } else if (tzload(name, lclptr) != 0) if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) (void) gmtload(lclptr); settzname(); } void tzsetwall() { lcl_is_set = TRUE; #ifdef ALL_STATE if (lclptr == NULL) { lclptr = (struct state *) malloc(sizeof *lclptr); if (lclptr == NULL) { settzname(); /* all we can do */ return; } } #endif /* defined ALL_STATE */ if (tzload((char *) NULL, lclptr) != 0) gmtload(lclptr); settzname(); } /* ** The easy way to behave "as if no library function calls" localtime ** is to not call it--so we drop its guts into "localsub", which can be ** freely called. (And no, the PANS doesn't require the above behavior-- ** but it *is* desirable.) ** ** The unused offset argument is for the benefit of mktime variants. */ /*ARGSUSED*/ static void localsub(timep, offset, tmp) const time_t * const timep; const long offset; struct tm * const tmp; { register struct state * sp; register const struct ttinfo * ttisp; register int i; const time_t t = *timep; if (!lcl_is_set) tzset(); sp = lclptr; #ifdef ALL_STATE if (sp == NULL) { gmtsub(timep, offset, tmp); return; } #endif /* defined ALL_STATE */ if (sp->timecnt == 0 || t < sp->ats[0]) { i = 0; while (sp->ttis[i].tt_isdst) if (++i >= sp->typecnt) { i = 0; break; } } else { for (i = 1; i < sp->timecnt; ++i) if (t < sp->ats[i]) break; i = sp->types[i - 1]; } ttisp = &sp->ttis[i]; /* ** To get (wrong) behavior that's compatible with System V Release 2.0 ** you'd replace the statement below with ** t += ttisp->tt_gmtoff; ** timesub(&t, 0L, sp, tmp); */ timesub(&t, ttisp->tt_gmtoff, sp, tmp); tmp->tm_isdst = ttisp->tt_isdst; tzname[tmp->tm_isdst] = (char *) &sp->chars[ttisp->tt_abbrind]; #ifdef HAVE_TM_ZONE tmp->tm_zone = &sp->chars[ttisp->tt_abbrind]; #endif } struct tm * localtime(timep) const time_t * const timep; { static struct tm tm; localsub(timep, 0L, &tm); return &tm; } /* ** gmtsub is to gmtime as localsub is to localtime. */ static void gmtsub(timep, offset, tmp) const time_t * const timep; const long offset; struct tm * const tmp; { if (!gmt_is_set) { gmt_is_set = TRUE; #ifdef ALL_STATE gmtptr = (struct state *) malloc(sizeof *gmtptr); if (gmtptr != NULL) #endif /* defined ALL_STATE */ gmtload(gmtptr); } timesub(timep, offset, gmtptr, tmp); /* ** Could get fancy here and deliver something such as ** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero, ** but this is no time for a treasure hunt. */ #ifdef HAVE_TM_ZONE if (offset != 0) tmp->tm_zone = WILDABBR; else { #ifdef ALL_STATE if (gmtptr == NULL) tmp->TM_ZONE = GMT; else tmp->TM_ZONE = gmtptr->chars; #endif /* defined ALL_STATE */ #ifndef ALL_STATE tmp->tm_zone = gmtptr->chars; #endif /* State Farm */ } #endif /* HAVE_TM_ZONE */ } struct tm * gmtime(timep) const time_t * const timep; { static struct tm tm; gmtsub(timep, 0L, &tm); return &tm; } static void timesub(timep, offset, sp, tmp) const time_t * const timep; const long offset; register const struct state * const sp; register struct tm * const tmp; { register const struct lsinfo * lp; register long days; register long rem; register int y; register int yleap; register const int * ip; register long corr; register int hit; register int i; corr = 0; hit = FALSE; #ifdef ALL_STATE i = (sp == NULL) ? 0 : sp->leapcnt; #endif /* defined ALL_STATE */ #ifndef ALL_STATE i = sp->leapcnt; #endif /* State Farm */ while (--i >= 0) { lp = &sp->lsis[i]; if (*timep >= lp->ls_trans) { if (*timep == lp->ls_trans) hit = ((i == 0 && lp->ls_corr > 0) || lp->ls_corr > sp->lsis[i - 1].ls_corr); corr = lp->ls_corr; break; } } days = *timep / SECSPERDAY; rem = *timep % SECSPERDAY; #ifdef mc68k if (*timep == 0x80000000) { /* ** A 3B1 muffs the division on the most negative number. */ days = -24855; rem = -11648; } #endif /* mc68k */ rem += (offset - corr); while (rem < 0) { rem += SECSPERDAY; --days; } while (rem >= SECSPERDAY) { rem -= SECSPERDAY; ++days; } tmp->tm_hour = (int) (rem / SECSPERHOUR); rem = rem % SECSPERHOUR; tmp->tm_min = (int) (rem / SECSPERMIN); tmp->tm_sec = (int) (rem % SECSPERMIN); if (hit) /* ** A positive leap second requires a special ** representation. This uses "... ??:59:60". */ ++(tmp->tm_sec); tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); if (tmp->tm_wday < 0) tmp->tm_wday += DAYSPERWEEK; y = EPOCH_YEAR; if (days >= 0) for ( ; ; ) { yleap = isleap(y); if (days < (long) year_lengths[yleap]) break; ++y; days = days - (long) year_lengths[yleap]; } else do { --y; yleap = isleap(y); days = days + (long) year_lengths[yleap]; } while (days < 0); tmp->tm_year = y - TM_YEAR_BASE; tmp->tm_yday = (int) days; ip = mon_lengths[yleap]; for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon)) days = days - (long) ip[tmp->tm_mon]; tmp->tm_mday = (int) (days + 1); tmp->tm_isdst = 0; #ifdef HAVE_TM_GMTOFF tmp->tm_gmtoff = offset; #endif } /* ** A la X3J11 */ char * asctime(timeptr) register const struct tm * timeptr; { static const char wday_name[DAYSPERWEEK][3] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static const char mon_name[MONSPERYEAR][3] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; static char result[26]; (void) sprintf(result, "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n", wday_name[timeptr->tm_wday], mon_name[timeptr->tm_mon], timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec, TM_YEAR_BASE + timeptr->tm_year); return result; } char * ctime(timep) const time_t * const timep; { return asctime(localtime(timep)); } /* ** Adapted from code provided by Robert Elz, who writes: ** The "best" way to do mktime I think is based on an idea of Bob ** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now). ** It does a binary search of the time_t space. Since time_t's are ** just 32 bits, its a max of 32 iterations (even at 64 bits it ** would still be very reasonable). */ #ifndef WRONG #define WRONG (-1) #endif /* !defined WRONG */ static void normalize(tensptr, unitsptr, base) int * const tensptr; int * const unitsptr; const int base; { if (*unitsptr >= base) { *tensptr += *unitsptr / base; *unitsptr %= base; } else if (*unitsptr < 0) { --*tensptr; *unitsptr += base; if (*unitsptr < 0) { *tensptr -= 1 + (-*unitsptr) / base; *unitsptr = base - (-*unitsptr) % base; } } } static int tmcomp(atmp, btmp) register const struct tm * const atmp; register const struct tm * const btmp; { register int result; if ((result = (atmp->tm_year - btmp->tm_year)) == 0 && (result = (atmp->tm_mon - btmp->tm_mon)) == 0 && (result = (atmp->tm_mday - btmp->tm_mday)) == 0 && (result = (atmp->tm_hour - btmp->tm_hour)) == 0 && (result = (atmp->tm_min - btmp->tm_min)) == 0) result = atmp->tm_sec - btmp->tm_sec; return result; } static time_t time2(tmp, funcp, offset, okayp) struct tm * const tmp; void (* const funcp)(); const long offset; int * const okayp; { register const struct state * sp; register int dir; register int bits; register int i, j ; register int saved_seconds; time_t newt; time_t t; struct tm yourtm, mytm; *okayp = FALSE; yourtm = *tmp; if (yourtm.tm_sec >= SECSPERMIN + 2 || yourtm.tm_sec < 0) normalize(&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN); normalize(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR); normalize(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY); normalize(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR); while (yourtm.tm_mday <= 0) { --yourtm.tm_year; yourtm.tm_mday += year_lengths[isleap(yourtm.tm_year + TM_YEAR_BASE)]; } for ( ; ; ) { i = mon_lengths[isleap(yourtm.tm_year + TM_YEAR_BASE)][yourtm.tm_mon]; if (yourtm.tm_mday <= i) break; yourtm.tm_mday -= i; if (++yourtm.tm_mon >= MONSPERYEAR) { yourtm.tm_mon = 0; ++yourtm.tm_year; } } saved_seconds = yourtm.tm_sec; yourtm.tm_sec = 0; /* ** Calculate the number of magnitude bits in a time_t ** (this works regardless of whether time_t is ** signed or unsigned, though lint complains if unsigned). */ for (bits = 0, t = 1; t > 0; ++bits, t <<= 1) ; /* ** If time_t is signed, then 0 is the median value, ** if time_t is unsigned, then 1 << bits is median. */ t = (t < 0) ? 0 : ((time_t) 1 << bits); for ( ; ; ) { (*funcp)(&t, offset, &mytm); dir = tmcomp(&mytm, &yourtm); if (dir != 0) { if (bits-- < 0) return WRONG; if (bits < 0) --t; else if (dir > 0) t -= (time_t) 1 << bits; else t += (time_t) 1 << bits; continue; } if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst) break; /* ** Right time, wrong type. ** Hunt for right time, right type. ** It's okay to guess wrong since the guess ** gets checked. */ sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr); #ifdef ALL_STATE if (sp == NULL) return WRONG; #endif /* defined ALL_STATE */ for (i = 0; i < sp->typecnt; ++i) { if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) continue; for (j = 0; j < sp->typecnt; ++j) { if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) continue; newt = t + sp->ttis[j].tt_gmtoff - sp->ttis[i].tt_gmtoff; (*funcp)(&newt, offset, &mytm); if (tmcomp(&mytm, &yourtm) != 0) continue; if (mytm.tm_isdst != yourtm.tm_isdst) continue; /* ** We have a match. */ t = newt; goto label; } } return WRONG; } label: t += saved_seconds; (*funcp)(&t, offset, tmp); *okayp = TRUE; return t; } static time_t time1(tmp, funcp, offset) struct tm * const tmp; void (* const funcp)(); const long offset; { register time_t t; register const struct state * sp; register int samei, otheri; int okay; if (tmp->tm_isdst > 1) tmp->tm_isdst = 1; t = time2(tmp, funcp, offset, &okay); if (okay || tmp->tm_isdst < 0) return t; /* ** We're supposed to assume that somebody took a time of one type ** and did some math on it that yielded a "struct tm" that's bad. ** We try to divine the type they started from and adjust to the ** type they need. */ sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr); #ifdef ALL_STATE if (sp == NULL) return WRONG; #endif /* defined ALL_STATE */ for (samei = 0; samei < sp->typecnt; ++samei) { if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) continue; for (otheri = 0; otheri < sp->typecnt; ++otheri) { if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) continue; tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - sp->ttis[samei].tt_gmtoff; tmp->tm_isdst = !tmp->tm_isdst; t = time2(tmp, funcp, offset, &okay); if (okay) return t; tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - sp->ttis[samei].tt_gmtoff; tmp->tm_isdst = !tmp->tm_isdst; } } return WRONG; } time_t mktime(tmp) struct tm * const tmp; { return time1(tmp, localsub, 0L); } ./libc-linux/time/tzfile.h100644 1676 334 10642 5273203430 13541 0ustar hjlisl#ifndef TZFILE_H #define TZFILE_H /* ** This header is for use ONLY with the time conversion code. ** There is no guarantee that it will remain unchanged, ** or that it will remain at all. ** Do NOT copy it to any system include directory. ** Thank you! */ /* ** ID */ #if 0 #ifndef lint #ifndef NOID static char tzfilehid[] = "@(#)tzfile.h 7.1"; #endif /* !defined NOID */ #endif /* !defined lint */ #endif /* ** Information about time zone files. */ #ifndef TZDIR #define TZDIR "/usr/lib/zoneinfo" /* Time zone object file directory */ #endif /* !defined TZDIR */ #ifndef TZDEFAULT #define TZDEFAULT "localtime" #endif /* !defined TZDEFAULT */ #ifndef TZDEFRULES #define TZDEFRULES "posixrules" #endif /* !defined TZDEFRULES */ /* ** Each file begins with. . . */ struct tzhead { char tzh_reserved[24]; /* reserved for future use */ char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ char tzh_leapcnt[4]; /* coded number of leap seconds */ char tzh_timecnt[4]; /* coded number of transition times */ char tzh_typecnt[4]; /* coded number of local time types */ char tzh_charcnt[4]; /* coded number of abbr. chars */ }; /* ** . . .followed by. . . ** ** tzh_timecnt (char [4])s coded transition times a la time(2) ** tzh_timecnt (unsigned char)s types of local time starting at above ** tzh_typecnt repetitions of ** one (char [4]) coded GMT offset in seconds ** one (unsigned char) used to set tm_isdst ** one (unsigned char) that's an abbreviation list index ** tzh_charcnt (char)s '\0'-terminated zone abbreviations ** tzh_leapcnt repetitions of ** one (char [4]) coded leap second transition times ** one (char [4]) total correction after above ** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition ** time is standard time, if FALSE, ** transition time is wall clock time ** if absent, transition times are ** assumed to be wall clock time */ /* ** In the current implementation, "tzset()" refuses to deal with files that ** exceed any of the limits below. */ #ifndef TZ_MAX_TIMES /* ** The TZ_MAX_TIMES value below is enough to handle a bit more than a ** year's worth of solar time (corrected daily to the nearest second) or ** 138 years of Pacific Presidential Election time ** (where there are three time zone transitions every fourth year). */ #define TZ_MAX_TIMES 370 #endif /* !defined TZ_MAX_TIMES */ #ifndef TZ_MAX_TYPES #ifndef NOSOLAR #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ #else /* !defined NOSOLAR */ #define TZ_MAX_TYPES 10 /* Maximum number of local time types */ #endif /* !defined NOSOLAR */ #endif /* !defined TZ_MAX_TYPES */ #ifndef TZ_MAX_CHARS #define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ #endif /* !defined TZ_MAX_CHARS */ #ifndef TZ_MAX_LEAPS #define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ #endif /* !defined TZ_MAX_LEAPS */ #define SECSPERMIN 60 #define MINSPERHOUR 60 #define HOURSPERDAY 24 #define DAYSPERWEEK 7 #define DAYSPERNYEAR 365 #define DAYSPERLYEAR 366 #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) #define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) #define MONSPERYEAR 12 #define TM_SUNDAY 0 #define TM_MONDAY 1 #define TM_TUESDAY 2 #define TM_WEDNESDAY 3 #define TM_THURSDAY 4 #define TM_FRIDAY 5 #define TM_SATURDAY 6 #define TM_JANUARY 0 #define TM_FEBRUARY 1 #define TM_MARCH 2 #define TM_APRIL 3 #define TM_MAY 4 #define TM_JUNE 5 #define TM_JULY 6 #define TM_AUGUST 7 #define TM_SEPTEMBER 8 #define TM_OCTOBER 9 #define TM_NOVEMBER 10 #define TM_DECEMBER 11 #define TM_YEAR_BASE 1900 #define EPOCH_YEAR 1970 #define EPOCH_WDAY TM_THURSDAY /* ** Accurate only for the past couple of centuries; ** that will probably do. */ #define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) #ifndef USG /* ** Use of the underscored variants may cause problems if you move your code to ** certain System-V-based systems; for maximum portability, use the ** underscore-free variants. The underscored variants are provided for ** backward compatibility only; they may disappear from future versions of ** this file. */ #define SECS_PER_MIN SECSPERMIN #define MINS_PER_HOUR MINSPERHOUR #define HOURS_PER_DAY HOURSPERDAY #define DAYS_PER_WEEK DAYSPERWEEK #define DAYS_PER_NYEAR DAYSPERNYEAR #define DAYS_PER_LYEAR DAYSPERLYEAR #define SECS_PER_HOUR SECSPERHOUR #define SECS_PER_DAY SECSPERDAY #define MONS_PER_YEAR MONSPERYEAR #endif /* !defined USG */ #endif /* !defined TZFILE_H */ ./libc-linux/time/difftime.c100644 1676 334 2006 5465557310 14015 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 /* Return the difference between TIME1 and TIME0. */ double DEFUN(difftime, (time1, time0), time_t time1 AND time_t time0) { return (double) (time1 - time0); } ./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/time/time.h100644 1676 334 314 5474023635 13147 0ustar hjlisl#if 0 #include "../../linux/include/time.h" #else #include_next #endif #include "errno.h" #define __tzname tzname #define __tzset tzset #define __daylight daylight #define __timezone timezone ./libc-linux/time/gettod.c100644 1676 334 2074 5272576531 13523 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 #undef gettimeofday #include function_alias(gettimeofday, __gettimeofday, int, (tv, tz), DEFUN(gettimeofday, (tv, tz), struct timeval *tv AND struct timezone *tz)) ./libc-linux/time/settod.c100644 1676 334 2110 5272576532 13527 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 #undef settimeofday #include function_alias(settimeofday, __settimeofday, int, (tv, tz), DEFUN(settimeofday, (tv, tz), CONST struct timeval *tv AND CONST struct timezone *tz)) ./libc-linux/time/getitmr.c100644 1676 334 2123 5272576532 13704 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 #undef getitimer #include function_alias(getitimer, __getitimer, int, (which, value), DEFUN(getitimer, (which, value), enum __itimer_which which AND struct itimerval *value)) ./libc-linux/time/setitmr.c100644 1676 334 2161 5272576532 13722 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 #undef setitimer #include function_alias(setitimer, __setitimer, int, (which, old, new), DEFUN(setitimer, (which, old, new), enum __itimer_which which AND struct itimerval *old AND struct itimerval *new)) ./libc-linux/time/strftime.c.aod100644 1676 334 23225 5420337350 14642 0ustar hjlisl#ifdef __linux__ #define NOID #endif #ifndef lint #ifndef NOID static char elsieid[] = "@(#)strftime.c 7.15"; /* ** Based on the UCB version whose ID appears below. ** This is ANSIish only when time is treated identically in all locales and ** when "multibyte character == plain character". */ #endif /* !defined NOID */ #endif /* !defined lint */ /* * Copyright (c) 1989 The 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)strftime.c 5.4 (Berkeley) 3/14/89"; #endif /* LIBC_SCCS and not lint */ #ifdef __linux__ #include #include #include #include #define P(x) __P(x) #ifndef INT_STRLEN_MAXIMUM /* ** 302 / 1000 is log10(2.0) rounded up. ** Subtract one for the sign bit; ** add one for integer division truncation; ** add one more for a minus sign. */ #define INT_STRLEN_MAXIMUM(type) \ ((sizeof(type) * CHAR_BIT - 1) * 302 / 1000 + 2) #endif /* !defined INT_STRLEN_MAXIMUM */ #else #include "private.h" #endif #include "tzfile.h" static const char afmt[][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static const char Afmt[][10] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; static const char bfmt[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; static const char Bfmt[][10] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; static char *_add P((const char *, char *, const char *)); static char *_conv P((int, const char *, char *, const char *)); static char *_fmt P((const char *, const struct tm *, char *, const char *)); size_t strftime P((char *, size_t, const char *, const struct tm *)); extern char *tzname[]; size_t strftime(s, maxsize, format, t) char *s; size_t maxsize; const char *format; const struct tm *t; { char *p; p = _fmt(format, t, s, s + maxsize); if (p == s + maxsize) return 0; *p = '\0'; return p - s; } static char * _fmt(format, t, pt, ptlim) const char *format; const struct tm *t; char *pt; const char *ptlim; { for (; *format; ++format) { if (*format == '%') { label: switch(*++format) { case '\0': --format; break; case 'A': pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ? "?" : Afmt[t->tm_wday], pt, ptlim); continue; case 'a': pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ? "?" : afmt[t->tm_wday], pt, ptlim); continue; case 'B': pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ? "?" : Bfmt[t->tm_mon], pt, ptlim); continue; case 'b': case 'h': pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ? "?" : bfmt[t->tm_mon], pt, ptlim); continue; case 'c': pt = _fmt("%D %X", t, pt, ptlim); continue; case 'C': /* ** %C used to do a... ** _fmt("%a %b %e %X %Y", t); ** ...whereas now POSIX 1003.2 calls for ** something completely different. ** (ado, 5/24/93) */ pt = _conv((t->tm_year + TM_YEAR_BASE) / 100, "%02d", pt, ptlim); continue; case 'D': pt = _fmt("%m/%d/%y", t, pt, ptlim); continue; case 'x': /* ** Version 3.0 of strftime from Arnold Robbins ** (arnold@skeeve.atl.ga.us) does the ** equivalent of... ** _fmt("%a %b %e %Y"); ** ...for %x; since the X3J11 C language ** standard calls for "date, using locale's ** date format," anything goes. Using just ** numbers (as here) makes Quakers happier. ** Word from Paul Eggert (eggert@twinsun.com) ** is that %Y-%m-%d is the ISO standard date ** format, specified in ISO 2014 and later ** ISO 8601:1988, with a summary available in ** pub/doc/ISO/english/ISO8601.ps.Z on ** ftp.uni-erlangen.de. ** (ado, 5/30/93) */ pt = _fmt("%m/%d/%y", t, pt, ptlim); continue; case 'd': pt = _conv(t->tm_mday, "%02d", pt, ptlim); continue; case 'E': case 'O': /* ** POSIX locale extensions, a la ** Arnold Robbins' strftime version 3.0. ** The sequences ** %Ec %EC %Ex %Ey %EY ** %Od %oe %OH %OI %Om %OM ** %OS %Ou %OU %OV %Ow %OW %Oy ** are supposed to provide alternate ** representations. ** (ado, 5/24/93) */ goto label; case 'e': pt = _conv(t->tm_mday, "%2d", pt, ptlim); continue; case 'H': pt = _conv(t->tm_hour, "%02d", pt, ptlim); continue; case 'I': pt = _conv((t->tm_hour % 12) ? (t->tm_hour % 12) : 12, "%02d", pt, ptlim); continue; case 'j': pt = _conv(t->tm_yday + 1, "%03d", pt, ptlim); continue; case 'k': /* ** This used to be... ** _conv(t->tm_hour % 12 ? ** t->tm_hour % 12 : 12, 2, ' '); ** ...and has been changed to the below to ** match SunOS 4.1.1 and Arnold Robbins' ** strftime version 3.0. That is, "%k" and ** "%l" have been swapped. ** (ado, 5/24/93) */ pt = _conv(t->tm_hour, "%2d", pt, ptlim); continue; #ifdef KITCHEN_SINK case 'K': /* ** After all this time, still unclaimed! */ pt = _add("kitchen sink", pt, ptlim); continue; #endif /* defined KITCHEN_SINK */ case 'l': /* ** This used to be... ** _conv(t->tm_hour, 2, ' '); ** ...and has been changed to the below to ** match SunOS 4.1.1 and Arnold Robbin's ** strftime version 3.0. That is, "%k" and ** "%l" have been swapped. ** (ado, 5/24/93) */ pt = _conv((t->tm_hour % 12) ? (t->tm_hour % 12) : 12, "%2d", pt, ptlim); continue; case 'M': pt = _conv(t->tm_min, "%02d", pt, ptlim); continue; case 'm': pt = _conv(t->tm_mon + 1, "%02d", pt, ptlim); continue; case 'n': pt = _add("\n", pt, ptlim); continue; case 'p': pt = _add(t->tm_hour >= 12 ? "PM" : "AM", pt, ptlim); continue; case 'R': pt = _fmt("%H:%M", t, pt, ptlim); continue; case 'r': pt = _fmt("%I:%M:%S %p", t, pt, ptlim); continue; case 'S': pt = _conv(t->tm_sec, "%02d", pt, ptlim); continue; case 'T': case 'X': pt = _fmt("%H:%M:%S", t, pt, ptlim); continue; case 't': pt = _add("\t", pt, ptlim); continue; case 'U': pt = _conv((t->tm_yday + 7 - t->tm_wday) / 7, "%02d", pt, ptlim); continue; case 'u': /* ** From Arnold Robbins' strftime version 3.0: ** "ISO 8601: Weekday as a decimal number ** [1 (Monday) - 7]" ** (ado, 5/24/93) */ pt = _conv((t->tm_wday == 0) ? 7 : t->tm_wday, "%d", pt, ptlim); continue; case 'V': /* ** From Arnold Robbins' strftime version 3.0: ** "the week number of the year (the first ** Monday as the first day of week 1) as a ** decimal number (01-53). The method for ** determining the week number is as specified ** by ISO 8601 (to wit: if the week containing ** January 1 has four or more days in the new ** year, then it is week 1, otherwise it is ** week 53 of the previous year and the next ** week is week 1)." ** (ado, 5/24/93) */ /* ** XXX--If January 1 falls on a Friday, ** January 1-3 are part of week 53 of the ** previous year. By analogy, if January ** 1 falls on a Thursday, are December 29-31 ** of the PREVIOUS year part of week 1??? ** (ado 5/24/93) ** ** You are understood not to expect this. */ { int i; i = (t->tm_yday + 10 - (t->tm_wday ? (t->tm_wday - 1) : 6)) / 7; pt = _conv((i == 0) ? 53 : i, "%02d", pt, ptlim); } continue; case 'v': /* ** From Arnold Robbins' strftime version 3.0: ** "date as dd-bbb-YYYY" ** (ado, 5/24/93) */ pt = _fmt("%e-%b-%Y", t, pt, ptlim); continue; case 'W': pt = _conv((t->tm_yday + 7 - (t->tm_wday ? (t->tm_wday - 1) : 6)) / 7, "%02d", pt, ptlim); continue; case 'w': pt = _conv(t->tm_wday, "%d", pt, ptlim); continue; case 'y': pt = _conv((t->tm_year + TM_YEAR_BASE) % 100, "%02d", pt, ptlim); continue; case 'Y': pt = _conv(t->tm_year + TM_YEAR_BASE, "%04d", pt, ptlim); continue; case 'Z': #ifdef TM_ZONE if (t->TM_ZONE) pt = _add(t->TM_ZONE, pt, ptlim); else #endif /* defined TM_ZONE */ if (t->tm_isdst == 0 || t->tm_isdst == 1) { pt = _add(tzname[t->tm_isdst], pt, ptlim); } else pt = _add("?", pt, ptlim); continue; case '%': /* * X311J/88-090 (4.12.3.5): if conversion char is * undefined, behavior is undefined. Print out the * character itself as printf(3) also does. */ default: break; } } if (pt == ptlim) break; *pt++ = *format; } return pt; } static char * _conv(n, format, pt, ptlim) int n; const char *format; char *pt; const char *ptlim; { char buf[INT_STRLEN_MAXIMUM(int) + 1]; (void) sprintf(buf, format, n); return _add(buf, pt, ptlim); } static char * _add(str, pt, ptlim) const char *str; char *pt; const char *ptlim; { while (pt < ptlim && (*pt = *str++) != '\0') ++pt; return pt; } ./libc-linux/time/strftime.c.old100644 1676 334 25212 5272106460 14654 0ustar hjlisl/* strftime - custom formatting of date and/or time Copyright (C) 1989, 1991, 1992 Free Software Foundation, Inc. This program 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 program 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Note: this version of strftime lacks locale support, but it is standalone. Performs `%' substitutions similar to those in printf. Except where noted, substituted fields have a fixed size; numeric fields are padded if necessary. Padding is with zeros by default; for fields that display a single number, padding can be changed or inhibited by following the `%' with one of the modifiers described below. Unknown field specifiers are copied as normal characters. All other characters are copied to the output without change. Supports a superset of the ANSI C field specifiers. Literal character fields: % % n newline t tab Numeric modifiers (a nonstandard extension): - do not pad the field _ pad the field with spaces Time fields: %H hour (00..23) %I hour (01..12) %k hour ( 0..23) %l hour ( 1..12) %M minute (00..59) %p locale's AM or PM %r time, 12-hour (hh:mm:ss [AP]M) %R time, 24-hour (hh:mm) %S second (00..61) %T time, 24-hour (hh:mm:ss) %X locale's time representation (%H:%M:%S) %Z time zone (EDT), or nothing if no time zone is determinable Date fields: %a locale's abbreviated weekday name (Sun..Sat) %A locale's full weekday name, variable length (Sunday..Saturday) %b locale's abbreviated month name (Jan..Dec) %B locale's full month name, variable length (January..December) %c locale's date and time (Sat Nov 04 12:02:33 EST 1989) %C century (00..99) %d day of month (01..31) %e day of month ( 1..31) %D date (mm/dd/yy) %h same as %b %j day of year (001..366) %m month (01..12) %U week number of year with Sunday as first day of week (00..53) %w day of week (0..6) %W week number of year with Monday as first day of week (00..53) %x locale's date representation (mm/dd/yy) %y last two digits of year (00..99) %Y year (1970...) David MacKenzie */ #define HAVE_TZNAME #include #if defined(TM_IN_SYS_TIME) || (!defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME)) #include #else #include #endif #ifndef linux #if defined(HAVE_TZNAME) extern char *tzname[2]; #endif #endif #if !__STDC__ #define const #endif /* Types of padding for numbers in date and time. */ enum padding { none, blank, zero }; static char *days[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; static char *months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; /* Add character C to STRING and increment LENGTH, unless LENGTH would exceed MAX. */ #define add_char(c) (length + 1 <= max) && (string[length++] = (c)) /* Add a 2 digit number to STRING, padding if specified. Return the number of characters added, up to MAX. */ static int add_num2 (string, num, max, pad) char *string; int num; int max; enum padding pad; { int top = num / 10; int length = 0; if (top == 0 && pad == blank) add_char (' '); else if (top != 0 || pad == zero) add_char (top + '0'); add_char (num % 10 + '0'); return length; } /* Add a 3 digit number to STRING, padding if specified. Return the number of characters added, up to MAX. */ static int add_num3 (string, num, max, pad) char *string; int num; int max; enum padding pad; { int top = num / 100; int mid = (num - top * 100) / 10; int length = 0; if (top == 0 && pad == blank) add_char (' '); else if (top != 0 || pad == zero) add_char (top + '0'); if (mid == 0 && top == 0 && pad == blank) add_char (' '); else if (mid != 0 || top != 0 || pad == zero) add_char (mid + '0'); add_char (num % 10 + '0'); return length; } /* Like strncpy except return the number of characters copied. */ static int add_str (to, from, max) char *to; char *from; int max; { int i; for (i = 0; from[i] && i <= max; ++i) to[i] = from[i]; return i; } /* Return the week in the year of the time in TM, with the weeks starting on Sundays. */ static int sun_week (tm) struct tm *tm; { int dl; /* Set `dl' to the day in the year of the last day of the week previous to the one containing the day specified in TM. If the day specified in TM is in the first week of the year, `dl' will be negative or 0. 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 = tm->tm_yday - tm->tm_wday; return dl <= 0 ? 0 : dl / 7 + (dl % 7 != 0); } /* Return the week in the year of the time in TM, with the weeks starting on Mondays. */ static int mon_week (tm) struct tm *tm; { int dl, wday; if (tm->tm_wday == 0) wday = 6; else wday = tm->tm_wday - 1; dl = tm->tm_yday - wday; return dl <= 0 ? 0 : dl / 7 + (dl % 7 != 0); } #if !defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME) char * zone_name (tp) struct tm *tp; { char *timezone (); struct timeval tv; struct timezone tz; __gettimeofday (&tv, &tz); return timezone (tz.tz_minuteswest, tp->tm_isdst); } #endif /* Format the time given in TM according to FORMAT, and put the results in STRING. Return the number of characters (not including terminating null) that were put into STRING, or 0 if the length would have exceeded MAX. */ size_t strftime (string, max, format, tm) char *string; size_t max; const char *format; const struct tm *tm; { enum padding pad; /* Type of padding to apply. */ size_t length = 0; /* Characters put in STRING so far. */ for (; *format && length < max; ++format) { if (*format != '%') add_char (*format); else { ++format; /* Modifiers: */ if (*format == '-') { pad = none; ++format; } else if (*format == '_') { pad = blank; ++format; } else pad = zero; switch (*format) { /* Literal character fields: */ case 0: case '%': add_char ('%'); break; case 'n': add_char ('\n'); break; case 't': add_char ('\t'); break; default: add_char (*format); break; /* Time fields: */ case 'H': case 'k': length += add_num2 (&string[length], tm->tm_hour, max - length, *format == 'H' ? pad : blank); break; case 'I': case 'l': { int hour12; if (tm->tm_hour == 0) hour12 = 12; else if (tm->tm_hour > 12) hour12 = tm->tm_hour - 12; else hour12 = tm->tm_hour; length += add_num2 (&string[length], hour12, max - length, *format == 'I' ? pad : blank); } break; case 'M': length += add_num2 (&string[length], tm->tm_min, max - length, pad); break; case 'p': if (tm->tm_hour < 12) add_char ('A'); else add_char ('P'); add_char ('M'); break; case 'r': length += strftime (&string[length], max - length, "%I:%M:%S %p", tm); break; case 'R': length += strftime (&string[length], max - length, "%H:%M", tm); break; case 'S': length += add_num2 (&string[length], tm->tm_sec, max - length, pad); break; case 'T': length += strftime (&string[length], max - length, "%H:%M:%S", tm); break; case 'X': length += strftime (&string[length], max - length, "%H:%M:%S", tm); break; case 'Z': #ifdef HAVE_TM_ZONE length += add_str (&string[length], tm->tm_zone, max - length); #else #ifdef HAVE_TZNAME if (tm->tm_isdst && tzname[1] && *tzname[1]) length += add_str (&string[length], tzname[1], max - length); else length += add_str (&string[length], tzname[0], max - length); #else length += add_str (&string[length], zone_name (tm), max - length); #endif #endif break; /* Date fields: */ case 'a': add_char (days[tm->tm_wday][0]); add_char (days[tm->tm_wday][1]); add_char (days[tm->tm_wday][2]); break; case 'A': length += add_str (&string[length], days[tm->tm_wday], max - length); break; case 'b': case 'h': add_char (months[tm->tm_mon][0]); add_char (months[tm->tm_mon][1]); add_char (months[tm->tm_mon][2]); break; case 'B': length += add_str (&string[length], months[tm->tm_mon], max - length); break; case 'c': length += strftime (&string[length], max - length, "%a %b %d %H:%M:%S %Z %Y", tm); break; case 'C': length += add_num2 (&string[length], (tm->tm_year + 1900) / 100, max - length, pad); break; case 'd': length += add_num2 (&string[length], tm->tm_mday, max - length, pad); break; case 'e': length += add_num2 (&string[length], tm->tm_mday, max - length, blank); break; case 'D': length += strftime (&string[length], max - length, "%m/%d/%y", tm); break; case 'j': length += add_num3 (&string[length], tm->tm_yday + 1, max - length, pad); break; case 'm': length += add_num2 (&string[length], tm->tm_mon + 1, max - length, pad); break; case 'U': length += add_num2 (&string[length], sun_week (tm), max - length, pad); break; case 'w': add_char (tm->tm_wday + '0'); break; case 'W': length += add_num2 (&string[length], mon_week (tm), max - length, pad); break; case 'x': length += strftime (&string[length], max - length, "%m/%d/%y", tm); break; case 'y': length += add_num2 (&string[length], tm->tm_year % 100, max - length, pad); break; case 'Y': add_char ((tm->tm_year + 1900) / 1000 + '0'); length += add_num3 (&string[length], (1900 + tm->tm_year) % 1000, max - length, zero); break; } } } add_char (0); return length - 1; } ./libc-linux/time/adjtime.c100644 1676 334 2124 5465012062 13632 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 #undef adjtime #include function_alias(adjtime, __adjtime, int, (delta, olddelta), DEFUN(adjtime, (delta, olddelta), CONST struct timeval *delta AND struct timeval *olddelta)) ./libc-linux/ufc/ 40755 1676 334 0 5550056041 11574 5ustar hjlisl./libc-linux/ufc/COPYING100644 1676 334 61261 5146323676 12766 0ustar hjlisl GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Library General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! ./libc-linux/ufc/Makefile100644 1676 334 351 5515544611 13316 0ustar hjlisl# # This is Makefile of ufc lib for Linux. # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules DIRS:= SRCS = crypt.c crypt_util.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/ufc/README100644 1676 334 13261 5146323677 12611 0ustar hjlisl UFC-crypt: ultra fast 'crypt' implementation ============================================ @(#)README 2.10 01/30/92 Design goals/non goals: ---------------------- - Crypt implementation plugin compatible with crypt(3)/fcrypt. - High performance when used for password cracking. - Portable to most 32/64 bit machines. - Startup time/mixed salt performance not critical. Features of the implementation: ------------------------------ - Runs 30-60 times faster than crypt(3) when invoked repeated times with the same salt and varying passwords. - With mostly constant salts, performance is about three times that of the default fcrypt implementation shipped with Alec Muffets 'Crack' password cracker. For instructions on how to plug UFC-crypt into 'Crack', see below. - With alternating salts, performance is only about twice that of crypt(3). - Tested on 680x0, 386, SPARC, MIPS, HP-PA, Convex, Pyramid and IBM RS/6000 systems as well as with gcc on IBM PS/2. - Requires 165 kb for tables. Author & licensing etc ---------------------- UFC-crypt is written by Michael Glad, email: glad@daimi.aau.dk. It is covered by the GNU library license version 2, see the file 'COPYING'. Installing ---------- Edit the Makefile setting the variables CRYPT: The encryption module to use; crypt.o should always work. If compiling for one of the machines for which special support is available, select the appropriate module. CC: The compiler to use. OFLAGS: The highest level of optimization available. Now run 'make'. UFC-crypt is compiled into 'libufc.a'. A test program: ufc is also linked. Try it out: './ufc 1' to test proper operation. For a more thorough test, run 'make tests'. This compiles and invokes a DES validation suite as well as two benchmark programs comparing UFC-crypt with the native crypt(3) implementation. If your friendly vendor has omitted crypt(3) from libc, compilation of the native benchmark program 'speedc' will fail. 'libufc.a' can be linked into your applications. It is compatible with both crypt(3) and the fcrypt shipped with Alec Muffett's Crack program. Installing UFC-crypt into Crack: ------------------------------- Crack Release 4.0a: in 'Sources/Makefile', change the CRACKCRYPT macro to a path leading to 'libufc.a' and invoke the Crack script as usual. 4.1 and later: Crack knows about UFC-crypt. Refer to the Crack docs for instructions. Benchmark table: --------------- The table shows how many operations per second UFC-crypt can do on various machines. |--------------|-------------------------------------------| |Machine | SUN* SUN* HP* DecStation HP | | | 3/50 ELC 9000/425e 3100 9000/720 | |--------------|-------------------------------------------| | Crypt(3)/sec | 4.6 30 15 25 57 | | Ufc/sec | 220 990 780 1015 3500 | |--------------|-------------------------------------------| | Speedup | 48 30 52 40 60 | |--------------|-------------------------------------------| *) Compiled using special assembly language support module. It seems as if performance is limited by CPU bus and data cache capacity. This also makes the benchmarks debatable compared to a real test with UFC-crypt wired into Crack. However, the table gives an outline of what can be expected. Optimizations: ------------- Here are the optimizations used relative to an ordinary implementation such as the one said to be used in crypt(3). Major optimizations ******************* - Keep data packed as bits in integer variables -- allows for fast permutations & parallel xor's in CPU hardware. - Let adjacent final & initial permutations collapse. - Keep working data in 'E expanded' format all the time. - Implement DES 'f' function mostly by table lookup - Calculate the above function on 12 bit basis rather than 6 as would be the most natural. - Implement setup routines so that performance is limited by the DES inner loops only. Minor (dirty) optimizations *************************** - combine iterations of DES inner loop so that DES only loops 8 times. This saves a lot of variable swapping. - Implement key access by a walking pointer rather than coding as array indexing. - As described, the table based f function uses a 3 dimensional array: sb ['number of 12 bit segment']['12 bit index']['48 bit half index'] Code the routine with 4 (one dimensional) vectors. - Design the internal data format & uglify the DES loops so that the compiler does not need to do bit shifts when indexing vectors. Portability issues ****************** UFC-crypt does not need to know the byte endianness of the machine is runs on. To speed up the DES inner loop, it does a dirty trick requiring the availability of a integer flavoured data type occupying exactly 32 (or 64) bits. This is normally the case of 'long'. The header file 'ufc-crypt.h' contains typedefs for this type. If you have to change it (or any other part) to get things working, please drop me a note. UFC-crypt can take advantage of 64 bit integers. At the moment, it is only configured to do so automatically for Convex machines. Revision history **************** UFC patchlevel 0: base version; released to alt.sources on Sep 24 1991 UFC patchlevel 1: patch released to alt.sources on Sep 27 1991. No longer rebuilds sb tables when seeing a new salt. UFC-crypt pl0: Essentially UFC pl 1. Released to comp.sources.misc on Oct 22 1991. UFC-crypt pl1: Released to comp.sources.misc in February 1992 * setkey/encrypt routines added * added validation/benchmarking programs * reworked keyschedule setup code * memory demands reduced * 64 bit support added ./libc-linux/ufc/S2o100755 1676 334 1712 5146323677 12300 0ustar hjlisl#!/bin/sh # UFC-crypt: ultra fast crypt(3) implementation # Copyright (C) 1991, 1992, Michael Glad, email: glad@daimi.aau.dk # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # @(#)S2o 2.5 1/11/92 # # Preprocessor compiling .S files into .o files # /lib/cpp -P $1 | tr \; '\012' > ./tmp.s as ./tmp.s -o $2 ./libc-linux/ufc/cert.c100644 1676 334 2713 5146323677 13012 0ustar hjlisl /* * This crypt(3) validation program shipped with UFC-crypt * is derived from one distributed with Phil Karns PD DES package. * * Michael Glad, email: glad@daimi.aau.dk * * @(#)cert.c 1.4 01/13/92 */ #include int totfails = 0; void good_bye () { if(totfails == 0) { printf("Passed DES validation suite\n"); exit(0); } else { printf("%d failures during DES validation suite!!!\n", totfails); exit(1); } } main() { char key[64],plain[64],cipher[64],answer[64]; int i; int test; int fail; for(test=0;!feof(stdin);test++){ get8(key); printf(" K: "); put8(key); setkey(key); get8(plain); printf(" P: "); put8(plain); get8(answer); printf(" C: "); put8(answer); for(i=0;i<64;i++) cipher[i] = plain[i]; encrypt(cipher, 0); for(i=0;i<64;i++) if(cipher[i] != answer[i]) break; fail = 0; if(i != 64){ printf(" Encrypt FAIL"); fail++; totfails++; } encrypt(cipher, 1); for(i=0;i<64;i++) if(cipher[i] != plain[i]) break; if(i != 64){ printf(" Decrypt FAIL"); fail++; totfails++; } if(fail == 0) printf(" OK"); printf("\n"); } good_bye(); } get8(cp) char *cp; { int i,j,t; for(i=0;i<8;i++){ scanf("%2x",&t); if(feof(stdin)) good_bye(); for(j=0; j<8 ; j++) { *cp++ = (t & (0x01 << (7-j))) != 0; } } } put8(cp) char *cp; { int i,j,t; for(i=0;i<8;i++){ t = 0; for(j = 0; j<8; j++) t = (t<<1) | *cp++; printf("%02x", t); } } ./libc-linux/ufc/cert.data100644 1676 334 21021 5146323677 13512 0ustar hjlisl0101010101010101 95f8a5e5dd31d900 8000000000000000 0101010101010101 dd7f121ca5015619 4000000000000000 0101010101010101 2e8653104f3834ea 2000000000000000 0101010101010101 4bd388ff6cd81d4f 1000000000000000 0101010101010101 20b9e767b2fb1456 0800000000000000 0101010101010101 55579380d77138ef 0400000000000000 0101010101010101 6cc5defaaf04512f 0200000000000000 0101010101010101 0d9f279ba5d87260 0100000000000000 0101010101010101 d9031b0271bd5a0a 0080000000000000 0101010101010101 424250b37c3dd951 0040000000000000 0101010101010101 b8061b7ecd9a21e5 0020000000000000 0101010101010101 f15d0f286b65bd28 0010000000000000 0101010101010101 add0cc8d6e5deba1 0008000000000000 0101010101010101 e6d5f82752ad63d1 0004000000000000 0101010101010101 ecbfe3bd3f591a5e 0002000000000000 0101010101010101 f356834379d165cd 0001000000000000 0101010101010101 2b9f982f20037fa9 0000800000000000 0101010101010101 889de068a16f0be6 0000400000000000 0101010101010101 e19e275d846a1298 0000200000000000 0101010101010101 329a8ed523d71aec 0000100000000000 0101010101010101 e7fce22557d23c97 0000080000000000 0101010101010101 12a9f5817ff2d65d 0000040000000000 0101010101010101 a484c3ad38dc9c19 0000020000000000 0101010101010101 fbe00a8a1ef8ad72 0000010000000000 0101010101010101 750d079407521363 0000008000000000 0101010101010101 64feed9c724c2faf 0000004000000000 0101010101010101 f02b263b328e2b60 0000002000000000 0101010101010101 9d64555a9a10b852 0000001000000000 0101010101010101 d106ff0bed5255d7 0000000800000000 0101010101010101 e1652c6b138c64a5 0000000400000000 0101010101010101 e428581186ec8f46 0000000200000000 0101010101010101 aeb5f5ede22d1a36 0000000100000000 0101010101010101 e943d7568aec0c5c 0000000080000000 0101010101010101 df98c8276f54b04b 0000000040000000 0101010101010101 b160e4680f6c696f 0000000020000000 0101010101010101 fa0752b07d9c4ab8 0000000010000000 0101010101010101 ca3a2b036dbc8502 0000000008000000 0101010101010101 5e0905517bb59bcf 0000000004000000 0101010101010101 814eeb3b91d90726 0000000002000000 0101010101010101 4d49db1532919c9f 0000000001000000 0101010101010101 25eb5fc3f8cf0621 0000000000800000 0101010101010101 ab6a20c0620d1c6f 0000000000400000 0101010101010101 79e90dbc98f92cca 0000000000200000 0101010101010101 866ecedd8072bb0e 0000000000100000 0101010101010101 8b54536f2f3e64a8 0000000000080000 0101010101010101 ea51d3975595b86b 0000000000040000 0101010101010101 caffc6ac4542de31 0000000000020000 0101010101010101 8dd45a2ddf90796c 0000000000010000 0101010101010101 1029d55e880ec2d0 0000000000008000 0101010101010101 5d86cb23639dbea9 0000000000004000 0101010101010101 1d1ca853ae7c0c5f 0000000000002000 0101010101010101 ce332329248f3228 0000000000001000 0101010101010101 8405d1abe24fb942 0000000000000800 0101010101010101 e643d78090ca4207 0000000000000400 0101010101010101 48221b9937748a23 0000000000000200 0101010101010101 dd7c0bbd61fafd54 0000000000000100 0101010101010101 2fbc291a570db5c4 0000000000000080 0101010101010101 e07c30d7e4e26e12 0000000000000040 0101010101010101 0953e2258e8e90a1 0000000000000020 0101010101010101 5b711bc4ceebf2ee 0000000000000010 0101010101010101 cc083f1e6d9e85f6 0000000000000008 0101010101010101 d2fd8867d50d2dfe 0000000000000004 0101010101010101 06e7ea22ce92708f 0000000000000002 0101010101010101 166b40b44aba4bd6 0000000000000001 8001010101010101 0000000000000000 95a8d72813daa94d 4001010101010101 0000000000000000 0eec1487dd8c26d5 2001010101010101 0000000000000000 7ad16ffb79c45926 1001010101010101 0000000000000000 d3746294ca6a6cf3 0801010101010101 0000000000000000 809f5f873c1fd761 0401010101010101 0000000000000000 c02faffec989d1fc 0201010101010101 0000000000000000 4615aa1d33e72f10 0180010101010101 0000000000000000 2055123350c00858 0140010101010101 0000000000000000 df3b99d6577397c8 0120010101010101 0000000000000000 31fe17369b5288c9 0110010101010101 0000000000000000 dfdd3cc64dae1642 0108010101010101 0000000000000000 178c83ce2b399d94 0104010101010101 0000000000000000 50f636324a9b7f80 0102010101010101 0000000000000000 a8468ee3bc18f06d 0101800101010101 0000000000000000 a2dc9e92fd3cde92 0101400101010101 0000000000000000 cac09f797d031287 0101200101010101 0000000000000000 90ba680b22aeb525 0101100101010101 0000000000000000 ce7a24f350e280b6 0101080101010101 0000000000000000 882bff0aa01a0b87 0101040101010101 0000000000000000 25610288924511c2 0101020101010101 0000000000000000 c71516c29c75d170 0101018001010101 0000000000000000 5199c29a52c9f059 0101014001010101 0000000000000000 c22f0a294a71f29f 0101012001010101 0000000000000000 ee371483714c02ea 0101011001010101 0000000000000000 a81fbd448f9e522f 0101010801010101 0000000000000000 4f644c92e192dfed 0101010401010101 0000000000000000 1afa9a66a6df92ae 0101010201010101 0000000000000000 b3c1cc715cb879d8 0101010180010101 0000000000000000 19d032e64ab0bd8b 0101010140010101 0000000000000000 3cfaa7a7dc8720dc 0101010120010101 0000000000000000 b7265f7f447ac6f3 0101010110010101 0000000000000000 9db73b3c0d163f54 0101010108010101 0000000000000000 8181b65babf4a975 0101010104010101 0000000000000000 93c9b64042eaa240 0101010102010101 0000000000000000 5570530829705592 0101010101800101 0000000000000000 8638809e878787a0 0101010101400101 0000000000000000 41b9a79af79ac208 0101010101200101 0000000000000000 7a9be42f2009a892 0101010101100101 0000000000000000 29038d56ba6d2745 0101010101080101 0000000000000000 5495c6abf1e5df51 0101010101040101 0000000000000000 ae13dbd561488933 0101010101020101 0000000000000000 024d1ffa8904e389 0101010101018001 0000000000000000 d1399712f99bf02e 0101010101014001 0000000000000000 14c1d7c1cffec79e 0101010101012001 0000000000000000 1de5279dae3bed6f 0101010101011001 0000000000000000 e941a33f85501303 0101010101010801 0000000000000000 da99dbbc9a03f379 0101010101010401 0000000000000000 b7fc92f91d8e92e9 0101010101010201 0000000000000000 ae8e5caa3ca04e85 0101010101010180 0000000000000000 9cc62df43b6eed74 0101010101010140 0000000000000000 d863dbb5c59a91a0 0101010101010120 0000000000000000 a1ab2190545b91d7 0101010101010110 0000000000000000 0875041e64c570f7 0101010101010108 0000000000000000 5a594528bebef1cc 0101010101010104 0000000000000000 fcdb3291de21f0c0 0101010101010102 0000000000000000 869efd7f9f265a09 1046913489980131 0000000000000000 88d55e54f54c97b4 1007103489988020 0000000000000000 0c0cc00c83ea48fd 10071034c8980120 0000000000000000 83bc8ef3a6570183 1046103489988020 0000000000000000 df725dcad94ea2e9 1086911519190101 0000000000000000 e652b53b550be8b0 1086911519580101 0000000000000000 af527120c485cbb0 5107b01519580101 0000000000000000 0f04ce393db926d5 1007b01519190101 0000000000000000 c9f00ffc74079067 3107915498080101 0000000000000000 7cfd82a593252b4e 3107919498080101 0000000000000000 cb49a2f9e91363e3 10079115b9080140 0000000000000000 00b588be70d23f56 3107911598090140 0000000000000000 406a9a6ab43399ae 1007d01589980101 0000000000000000 6cb773611dca9ada 9107911589980101 0000000000000000 67fd21c17dbb5d70 9107d01589190101 0000000000000000 9592cb4110430787 1007d01598980120 0000000000000000 a6b7ff68a318ddd3 1007940498190101 0000000000000000 4d102196c914ca16 0107910491190401 0000000000000000 2dfa9f4573594965 0107910491190101 0000000000000000 b46604816c0e0774 0107940491190401 0000000000000000 6e7e6221a4f34e87 19079210981a0101 0000000000000000 aa85e74643233199 1007911998190801 0000000000000000 2e5a19db4d1962d6 10079119981a0801 0000000000000000 23a866a809d30894 1007921098190101 0000000000000000 d812d961f017d320 100791159819010b 0000000000000000 055605816e58608f 1004801598190101 0000000000000000 abd88e8b1b7716f1 1004801598190102 0000000000000000 537ac95be69da1e1 1004801598190108 0000000000000000 aed0f6ae3c25cdd8 1002911598100104 0000000000000000 b3e35a5ee53e7b8d 1002911598190104 0000000000000000 61c79c71921a2ef8 1002911598100201 0000000000000000 e2f5728f0995013c 1002911698100101 0000000000000000 1aeac39a61f0a464 7ca110454a1a6e57 01a1d6d039776742 690f5b0d9a26939b 0131d9619dc1376e 5cd54ca83def57da 7a389d10354bd271 07a1133e4a0b2686 0248d43806f67172 868ebb51cab4599a 3849674c2602319e 51454b582ddf440a 7178876e01f19b2a 04b915ba43feb5b6 42fd443059577fa2 af37fb421f8c4095 0113b970fd34f2ce 059b5e0851cf143a 86a560f10ec6d85b 0170f175468fb5e6 0756d8e0774761d2 0cd3da020021dc09 43297fad38e373fe 762514b829bf486a ea676b2cb7db2b7a 07a7137045da2a16 3bdd119049372802 dfd64a815caf1a0f 04689104c2fd3b2f 26955f6835af609a 5c513c9c4886c088 37d06bb516cb7546 164d5e404f275232 0a2aeeae3ff4ab77 1f08260d1ac2465e 6b056e18759f5cca ef1bf03e5dfa575a 584023641aba6176 004bd6ef09176062 88bf0db6d70dee56 025816164629b007 480d39006ee762f2 a1f9915541020b56 49793ebc79b3258f 437540c8698f3cfa 6fbf1cafcffd0556 4fb05e1515ab73a7 072d43a077075292 2f22e49bab7ca1ac 49e95d6d4ca229bf 02fe55778117f12a 5a6b612cc26cce4a 018310dc409b26d6 1d9d5c5018f728c2 5f4c038ed12b2e41 1c587f1c13924fef 305532286d6f295a 63fac0d034d9f793 ./libc-linux/ufc/crypt.c100644 1676 334 6270 5146323677 13220 0ustar hjlisl/* * UFC-crypt: ultra fast crypt(3) implementation * * Copyright (C) 1991, 1992, Michael Glad, email: glad@daimi.aau.dk * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * @(#)crypt.c 2.14 01/23/92 * * Semiportable C version * */ #include "ufc-crypt.h" extern ufc_long *ufc_dofinalperm(); #ifdef _UFC_32_ /* * 32 bit version */ extern long32 ufc_keytab[16][2]; extern long32 ufc_sb0[], ufc_sb1[], ufc_sb2[], ufc_sb3[]; #define SBA(sb, v) (*(long32*)((char*)(sb)+(v))) ufc_long *ufc_doit(l1, l2, r1, r2, itr) ufc_long l1, l2, r1, r2, itr; { int i; long32 s, *k; while(itr--) { k = &ufc_keytab[0][0]; for(i=8; i--; ) { s = *k++ ^ r1; l1 ^= SBA(ufc_sb1, s & 0xffff); l2 ^= SBA(ufc_sb1, (s & 0xffff) + 4); l1 ^= SBA(ufc_sb0, s >>= 16); l2 ^= SBA(ufc_sb0, (s) + 4); s = *k++ ^ r2; l1 ^= SBA(ufc_sb3, s & 0xffff); l2 ^= SBA(ufc_sb3, (s & 0xffff) + 4); l1 ^= SBA(ufc_sb2, s >>= 16); l2 ^= SBA(ufc_sb2, (s) + 4); s = *k++ ^ l1; r1 ^= SBA(ufc_sb1, s & 0xffff); r2 ^= SBA(ufc_sb1, (s & 0xffff) + 4); r1 ^= SBA(ufc_sb0, s >>= 16); r2 ^= SBA(ufc_sb0, (s) + 4); s = *k++ ^ l2; r1 ^= SBA(ufc_sb3, s & 0xffff); r2 ^= SBA(ufc_sb3, (s & 0xffff) + 4); r1 ^= SBA(ufc_sb2, s >>= 16); r2 ^= SBA(ufc_sb2, (s) + 4); } s=l1; l1=r1; r1=s; s=l2; l2=r2; r2=s; } return ufc_dofinalperm(l1, l2, r1, r2); } #endif #ifdef _UFC_64_ /* * 64 bit version */ extern long64 ufc_keytab[16]; extern long64 ufc_sb0[], ufc_sb1[], ufc_sb2[], ufc_sb3[]; #ifdef cray #define SBA(sb, v) (*(long64*)((long64)(sb)+(v))) #else #define SBA(sb, v) (*(long64*)((char*)(sb)+(v))) #endif ufc_long *ufc_doit(l1, l2, r1, r2, itr) ufc_long l1, l2, r1, r2, itr; { int i; long64 l, r, s, *k; l = (((long64)l1) << 32) | ((long64)l2); r = (((long64)r1) << 32) | ((long64)r2); while(itr--) { k = &ufc_keytab[0]; for(i=8; i--; ) { s = *k++ ^ r; l ^= SBA(ufc_sb3, (s >> 0) & 0xffff); l ^= SBA(ufc_sb2, (s >> 16) & 0xffff); l ^= SBA(ufc_sb1, (s >> 32) & 0xffff); l ^= SBA(ufc_sb0, (s >> 48) & 0xffff); s = *k++ ^ l; r ^= SBA(ufc_sb3, (s >> 0) & 0xffff); r ^= SBA(ufc_sb2, (s >> 16) & 0xffff); r ^= SBA(ufc_sb1, (s >> 32) & 0xffff); r ^= SBA(ufc_sb0, (s >> 48) & 0xffff); } s=l; l=r; r=s; } l1 = l >> 32; l2 = l & 0xffffffff; r1 = r >> 32; r2 = r & 0xffffffff; return ufc_dofinalperm(l1, l2, r1, r2); } #endif ./libc-linux/ufc/crypt.s300.S100644 1676 334 4402 5146323677 13657 0ustar hjlisl # # UFC-crypt: ultra fast crypt(3) implementation # Copyright (C) 1991, 1992, Michael Glad, email: glad@daimi.aau.dk # # This library is free software, you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation, either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library, if not, write to the Free # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # @(#)crypt.s300.S 2.5 12/30/91 # # MC680x0/Hp9000 s300/s400 assembly code # #define L1 %d0 #define L2 %d1 #define R1 %d2 #define R2 %d3 #define SCR1 %d4 #define SCR2 %d5 #define I %d7 #define ITR 24(%a6) #define SB0 %a0 #define SB1 %a1 #define SB2 %a2 #define SB3 %a3 #define KPTR %a4 #define F(I,O1,O2,SBX,SBY) \ mov.l (KPTR)+,SCR1 ; eor.l I,SCR1 ; \ mov.l 0(SBX,SCR1.w),SCR2 ; eor.l SCR2,O1 ; \ mov.l 4(SBX,SCR1.w),SCR2 ; eor.l SCR2,O2 ; \ swap.w SCR1 ; \ mov.l 0(SBY,SCR1.w),SCR2 ; eor.l SCR2,O1 ; \ mov.l 4(SBY,SCR1.w),SCR2 ; eor.l SCR2,O2 ; #define G(I1,I2,O1,O2) \ F(I1,O1,O2,SB1,SB0) F(I2,O1,O2,SB3,SB2) #define H G(R1,R2,L1,L2) ; G(L1,L2,R1,R2) text global _ufc_doit _ufc_doit: # # Preamble # link %a6,&-56 movem.l &15612,(%sp) mov.l 20(%a6),R2 mov.l 16(%a6),R1 mov.l 12(%a6),L2 mov.l 8(%a6),L1 # # Setup address registers with sb pointers # mov.l &_ufc_sb0,SB0 ; mov.l &_ufc_sb1,SB1 mov.l &_ufc_sb2,SB2 ; mov.l &_ufc_sb3,SB3 # # And loop... # Lagain: mov.l &_ufc_keytab,KPTR moveq &8,I Lagain1: H subq.l &1,I bne Lagain1 # Permute mov.l L1,SCR1 ; mov.l R1,L1 ; mov.l SCR1,R1 mov.l L2,SCR1 ; mov.l R2,L2 ; mov.l SCR1,R2 # subq.l &1,ITR tst.l ITR bne Lagain # # Output conversion # mov.l R2,-(%sp) ; mov.l R1,-(%sp) mov.l L2,-(%sp) ; mov.l L1,-(%sp) jsr _ufc_dofinalperm ; add.l &16,%sp # # Postamble # movem.l (-56)(%a6),&15612 ; unlk %a6 ; rts ./libc-linux/ufc/crypt.sparc.S100644 1676 334 4720 5146323677 14305 0ustar hjlisl! ! UFC-crypt: ultra fast crypt(3) implementation ! Copyright (C) 1991, 1992, Michael Glad, email: glad@daimi.aau.dk ! ! This library is free software, you can redistribute it and/or ! modify it under the terms of the GNU Library General Public ! License as published by the Free Software Foundation, either ! version 2 of the License, or (at your option) any later version. ! ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY, without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Library General Public License for more details. ! ! You should have received a copy of the GNU Library General Public ! License along with this library, if not, write to the Free ! Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! ! @(#)crypt.sparc.S 2.5 12/30/91 ! ! Assembly code for SPARC architecture machines ! #define I %i3 #define ITR %i4 #define L1 %o0 #define L2 %o1 #define R1 %o2 #define R2 %o3 #define KPTR %g1 #define MASK %g2 #define SCR1a %g3 #define SCR1b %g4 #define SCR1 %g5 #define SCR2 %g6 #define SCR3 %g7 #define SB0a %l0 #define SB0b %l1 #define SB1a %l2 #define SB1b %l3 #define SB2a %l4 #define SB2b %l5 #define SB3a %l6 #define SB3b %l7 #define ASSIGN(reg,value) sethi %hi(value),reg ; or %lo(value),reg,reg ; #define F(I,O1,O2,SBX1,SBX2,SBY1,SBY2) \ ld [KPTR],SCR1 ; \ xor SCR1,I,SCR1 ; \ and SCR1,MASK,SCR1a ; \ \ ld [SBX1+SCR1a],SCR2 ; inc 4,KPTR ; \ srl SCR1,16,SCR1b ; \ ld [SBX2+SCR1a],SCR3 ; xor SCR2,O1,O1 ; \ \ ld [SBY1+SCR1b],SCR2 ; xor SCR3,O2,O2 ; \ ld [SBY2+SCR1b],SCR3 ; xor SCR2,O1,O1 ; \ \ xor SCR3,O2,O2 ; #define G(I1,I2,O1,O2) \ F(I1,O1,O2,SB1a,SB1b,SB0a,SB0b) F(I2,O1,O2,SB3a,SB3b,SB2a,SB2b) #define H G(R1,R2,L1,L2) ; G(L1,L2,R1,R2) .seg "text" .global _ufc_doit _ufc_doit: ! ! Preamble ! save %sp,-104,%sp mov %i0,L1 ; mov %i1,L2 mov %i2,R1 ; mov %i3,R2 ! ! Set up sb pointers ! ASSIGN(SB0a,_ufc_sb0) ; add SB0a,4,SB0b ASSIGN(SB1a,_ufc_sb1) ; add SB1a,4,SB1b ASSIGN(SB2a,_ufc_sb2) ; add SB2a,4,SB2b ASSIGN(SB3a,_ufc_sb3) ; add SB3a,4,SB3b ! ASSIGN(MASK,0xffff) ! ! Loop ! Lagain: ASSIGN(KPTR,_ufc_keytab) ASSIGN(I, 8) Lagain1: H deccc I bnz Lagain1 nop ! Permute mov L1,SCR1 ; mov R1,L1 ; mov SCR1,R1 mov L2,SCR1 ; mov R2,L2 ; mov SCR1,R2 ! deccc ITR bnz Lagain nop ! ! Output conversion ! call _ufc_dofinalperm,4 nop ! ! Postamble ! ret ; restore %g0,%o0,%o0 ./libc-linux/ufc/crypt.sun3.S100644 1676 334 4252 5146323677 14065 0ustar hjlisl| | UFC-crypt: ultra fast crypt(3) implementation | Copyright (C) 1991, 1992, Michael Glad, email: glad@daimi.aau.dk | | This library is free software, you can redistribute it and/or | modify it under the terms of the GNU Library General Public | License as published by the Free Software Foundation, either | version 2 of the License, or (at your option) any later version. | | This library is distributed in the hope that it will be useful, | but WITHOUT ANY WARRANTY, without even the implied warranty of | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | Library General Public License for more details. | | You should have received a copy of the GNU Library General Public | License along with this library, if not, write to the Free | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | | @(#)crypt.sun3.S 2.8 01/11/92 | | Assembly code for SUN3 68000 based workstations. | #define L1 d0 #define L2 d1 #define R1 d2 #define R2 d3 #define SCR1 d4 #define SCR2 d5 #define I d7 #define ITR a6@(24) #define SB0 a0 #define SB1 a1 #define SB2 a2 #define SB3 a3 #define KPTR a4 #define F(I,O1,O2,SBX,SBY) \ movl KPTR@+,SCR1 ; eorl I,SCR1 ; \ movl SBX@(0,SCR1:w),SCR2 ; eorl SCR2,O1 ; \ movl SBX@(4,SCR1:w),SCR2 ; eorl SCR2,O2 ; \ swap SCR1 ; \ movl SBY@(0,SCR1:w),SCR2 ; eorl SCR2,O1 ; \ movl SBY@(4,SCR1:w),SCR2 ; eorl SCR2,O2 ; #define G(I1,I2,O1,O2) \ F(I1,O1,O2,SB1,SB0) F(I2,O1,O2,SB3,SB2) #define H G(R1,R2,L1,L2) ; G(L1,L2,R1,R2) .text .proc .globl _ufc_doit _ufc_doit: | | Preamble | link a6,#-56 moveml #15612,sp@ movl a6@(20),R2 movl a6@(16),R1 movl a6@(12),L2 movl a6@(8),L1 | | Setup address registers with sb pointers | movl #_ufc_sb0,SB0 ; movl #_ufc_sb1,SB1 movl #_ufc_sb2,SB2 ; movl #_ufc_sb3,SB3 | | And loop... | Lagain: movl #_ufc_keytab,KPTR moveq #8,I Lagain1: H subql #1,I tstl I jne Lagain1 | Permute movl L1,SCR1 ; movl R1,L1 ; movl SCR1,R1 movl L2,SCR1 ; movl R2,L2 ; movl SCR1,R2 | subql #1,ITR jne Lagain | | Output conversion | movl R2,sp@- ; movl R1,sp@- movl L2,sp@- ; movl L1,sp@- jbsr _ufc_dofinalperm ; addl #16,sp | | Postamble | moveml a6@(-56),#15612 ; unlk a6 ; rts ./libc-linux/ufc/crypt_util.c100644 1676 334 53465 5164504715 14277 0ustar hjlisl/* * UFC-crypt: ultra fast crypt(3) implementation * * Copyright (C) 1991, 1992, Michael Glad, email: glad@daimi.aau.dk * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * @(#)crypt_util.c 2.29 01/23/92 * * Support routines * */ #ifdef DEBUG #include #endif #ifdef linux #include #endif #ifndef STATIC #define STATIC static #endif #include "patchlevel.h" #include "ufc-crypt.h" static char patchlevel_str[] = PATCHLEVEL; /* * Permutation done once on the 56 bit * key derived from the original 8 byte ASCII key. */ static int pc1[56] = { 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, 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 }; /* * How much to rotate each 28 bit half of the pc1 permutated * 56 bit key before using pc2 to give the i' key */ static int rots[16] = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 }; /* * Permutation giving the key * of the i' DES round */ static int pc2[48] = { 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 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 E expansion table which selects * bits from the 32 bit intermediate result. */ static int esel[48] = { 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 }; static int e_inverse[64]; /* * Permutation done on the * result of sbox lookups */ static int perm32[32] = { 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 }; /* * The sboxes */ static int sbox[8][4][16]= { { { 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7 }, { 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8 }, { 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0 }, { 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 } }, { { 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10 }, { 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5 }, { 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15 }, { 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9 } }, { { 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8 }, { 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1 }, { 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7 }, { 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12 } }, { { 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15 }, { 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9 }, { 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4 }, { 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14 } }, { { 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9 }, { 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6 }, { 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14 }, { 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3 } }, { { 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11 }, { 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8 }, { 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6 }, { 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 } }, { { 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1 }, { 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6 }, { 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2 }, { 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 } }, { { 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7 }, { 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2 }, { 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8 }, { 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 } } }; /* * This is the initial * permutation matrix */ static int initial_perm[64] = { 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 }; /* * This is the final * permutation matrix */ static int final_perm[64] = { 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 }; /* * The 16 DES keys in BITMASK format */ #ifdef _UFC_32_ long32 ufc_keytab[16][2]; #endif #ifdef _UFC_64_ long64 ufc_keytab[16]; #endif #define ascii_to_bin(c) ((c)>='a'?(c-59):(c)>='A'?((c)-53):(c)-'.') #define bin_to_ascii(c) ((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.') /* Macro to set a bit (0..23) */ #define BITMASK(i) ( (1<<(11-(i)%12+3)) << ((i)<12?16:0) ) /* * sb arrays: * * Workhorses of the inner loop of the DES implementation. * They do sbox lookup, shifting of this value, 32 bit * permutation and E permutation for the next round. * * Kept in 'BITMASK' format. */ #ifdef _UFC_32_ long32 ufc_sb0[8192], ufc_sb1[8192], ufc_sb2[8192], ufc_sb3[8192]; static long32 *sb[4] = {ufc_sb0, ufc_sb1, ufc_sb2, ufc_sb3}; #endif #ifdef _UFC_64_ long64 ufc_sb0[4096], ufc_sb1[4096], ufc_sb2[4096], ufc_sb3[4096]; static long64 *sb[4] = {ufc_sb0, ufc_sb1, ufc_sb2, ufc_sb3}; #endif /* * eperm32tab: do 32 bit permutation and E selection * * The first index is the byte number in the 32 bit value to be permuted * - second - is the value of this byte * - third - selects the two 32 bit values * * The table is used and generated internally in init_des to speed it up */ static ufc_long eperm32tab[4][256][2]; /* * do_pc1: permform pc1 permutation in the key schedule generation. * * The first index is the byte number in the 8 byte ASCII key * - second - - the two 28 bits halfs of the result * - third - selects the 7 bits actually used of each byte * * The result is kept with 28 bit per 32 bit with the 4 most significant * bits zero. */ static ufc_long do_pc1[8][2][128]; /* * do_pc2: permform pc2 permutation in the key schedule generation. * * The first index is the septet number in the two 28 bit intermediate values * - second - - - septet values * * Knowledge of the structure of the pc2 permutation is used. * * The result is kept with 28 bit per 32 bit with the 4 most significant * bits zero. */ static ufc_long do_pc2[8][128]; /* * efp: undo an extra e selection and do final * permutation giving the DES result. * * Invoked 6 bit a time on two 48 bit values * giving two 32 bit longs. */ static ufc_long efp[16][64][2]; static unsigned char bytemask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; static ufc_long longmask[32] = { 0x80000000, 0x40000000, 0x20000000, 0x10000000, 0x08000000, 0x04000000, 0x02000000, 0x01000000, 0x00800000, 0x00400000, 0x00200000, 0x00100000, 0x00080000, 0x00040000, 0x00020000, 0x00010000, 0x00008000, 0x00004000, 0x00002000, 0x00001000, 0x00000800, 0x00000400, 0x00000200, 0x00000100, 0x00000080, 0x00000040, 0x00000020, 0x00000010, 0x00000008, 0x00000004, 0x00000002, 0x00000001 }; #ifdef DEBUG pr_bits(a, n) ufc_long *a; int n; { ufc_long i, j, t, tmp; n /= 8; for(i = 0; i < n; i++) { tmp=0; for(j = 0; j < 8; j++) { t=8*i+j; tmp|=(a[t/24] & BITMASK(t % 24))?bytemask[j]:0; } (void)printf("%02x ",tmp); } printf(" "); } static set_bits(v, b) ufc_long v; ufc_long *b; { ufc_long i; *b = 0; for(i = 0; i < 24; i++) { if(v & longmask[8 + i]) *b |= BITMASK(i); } } #endif /* * Silly rewrite of 'bzero'. I do so * because some machines don't have * bzero and some don't have memset. */ STATIC void clearmem(start, cnt) char *start; int cnt; { while(cnt--) *start++ = '\0'; } static int initialized = 0; /* lookup a 6 bit value in sbox */ #define s_lookup(i,s) sbox[(i)][(((s)>>4) & 0x2)|((s) & 0x1)][((s)>>1) & 0xf]; /* * Initialize unit - may be invoked directly * by fcrypt users. */ void init_des() { int comes_from_bit; int bit, sg; ufc_long j; ufc_long mask1, mask2; /* * Create the do_pc1 table used * to affect pc1 permutation * when generating keys */ for(bit = 0; bit < 56; bit++) { comes_from_bit = pc1[bit] - 1; mask1 = bytemask[comes_from_bit % 8 + 1]; mask2 = longmask[bit % 28 + 4]; for(j = 0; j < 128; j++) { if(j & mask1) do_pc1[comes_from_bit / 8][bit / 28][j] |= mask2; } } /* * Create the do_pc2 table used * to affect pc2 permutation when * generating keys */ for(bit = 0; bit < 48; bit++) { comes_from_bit = pc2[bit] - 1; mask1 = bytemask[comes_from_bit % 7 + 1]; mask2 = BITMASK(bit % 24); for(j = 0; j < 128; j++) { if(j & mask1) do_pc2[comes_from_bit / 7][j] |= mask2; } } /* * Now generate the table used to do combined * 32 bit permutation and e expansion * * We use it because we have to permute 16384 32 bit * longs into 48 bit in order to initialize sb. * * Looping 48 rounds per permutation becomes * just too slow... * */ clearmem((char*)eperm32tab, sizeof(eperm32tab)); for(bit = 0; bit < 48; bit++) { ufc_long mask1,comes_from; comes_from = perm32[esel[bit]-1]-1; mask1 = bytemask[comes_from % 8]; for(j = 256; j--;) { if(j & mask1) eperm32tab[comes_from / 8][j][bit / 24] |= BITMASK(bit % 24); } } /* * Create the sb tables: * * For each 12 bit segment of an 48 bit intermediate * result, the sb table precomputes the two 4 bit * values of the sbox lookups done with the two 6 * bit halves, shifts them to their proper place, * sends them through perm32 and finally E expands * them so that they are ready for the next * DES round. * */ for(sg = 0; sg < 4; sg++) { int j1, j2; int s1, s2; for(j1 = 0; j1 < 64; j1++) { s1 = s_lookup(2 * sg, j1); for(j2 = 0; j2 < 64; j2++) { ufc_long to_permute, inx; s2 = s_lookup(2 * sg + 1, j2); to_permute = ((s1 << 4) | s2) << (24 - 8 * sg); #ifdef _UFC_32_ inx = ((j1 << 6) | j2) << 1; sb[sg][inx ] = eperm32tab[0][(to_permute >> 24) & 0xff][0]; sb[sg][inx+1] = eperm32tab[0][(to_permute >> 24) & 0xff][1]; sb[sg][inx ] |= eperm32tab[1][(to_permute >> 16) & 0xff][0]; sb[sg][inx+1] |= eperm32tab[1][(to_permute >> 16) & 0xff][1]; sb[sg][inx ] |= eperm32tab[2][(to_permute >> 8) & 0xff][0]; sb[sg][inx+1] |= eperm32tab[2][(to_permute >> 8) & 0xff][1]; sb[sg][inx ] |= eperm32tab[3][(to_permute) & 0xff][0]; sb[sg][inx+1] |= eperm32tab[3][(to_permute) & 0xff][1]; #endif #ifdef _UFC_64_ inx = ((j1 << 6) | j2); sb[sg][inx] = ((long64)eperm32tab[0][(to_permute >> 24) & 0xff][0] << 32) | (long64)eperm32tab[0][(to_permute >> 24) & 0xff][1]; sb[sg][inx] |= ((long64)eperm32tab[1][(to_permute >> 16) & 0xff][0] << 32) | (long64)eperm32tab[1][(to_permute >> 16) & 0xff][1]; sb[sg][inx] |= ((long64)eperm32tab[2][(to_permute >> 8) & 0xff][0] << 32) | (long64)eperm32tab[2][(to_permute >> 8) & 0xff][1]; sb[sg][inx] |= ((long64)eperm32tab[3][(to_permute) & 0xff][0] << 32) | (long64)eperm32tab[3][(to_permute) & 0xff][1]; #endif } } } /* * Create an inverse matrix for esel telling * where to plug out bits if undoing it */ for(bit=48; bit--;) { e_inverse[esel[bit] - 1 ] = bit; e_inverse[esel[bit] - 1 + 32] = bit + 48; } /* * create efp: the matrix used to * undo the E expansion and effect final permutation */ clearmem((char*)efp, sizeof efp); for(bit = 0; bit < 64; bit++) { int o_bit, o_long; ufc_long word_value, mask1, mask2; int comes_from_f_bit, comes_from_e_bit; int comes_from_word, bit_within_word; /* See where bit i belongs in the two 32 bit long's */ o_long = bit / 32; /* 0..1 */ o_bit = bit % 32; /* 0..31 */ /* * And find a bit in the e permutated value setting this bit. * * Note: the e selection may have selected the same bit several * times. By the initialization of e_inverse, we only look * for one specific instance. */ comes_from_f_bit = final_perm[bit] - 1; /* 0..63 */ comes_from_e_bit = e_inverse[comes_from_f_bit]; /* 0..95 */ comes_from_word = comes_from_e_bit / 6; /* 0..15 */ bit_within_word = comes_from_e_bit % 6; /* 0..5 */ mask1 = longmask[bit_within_word + 26]; mask2 = longmask[o_bit]; for(word_value = 64; word_value--;) { if(word_value & mask1) efp[comes_from_word][word_value][o_long] |= mask2; } } initialized++; } /* * Process the elements of the sb table permuting the * bits swapped in the expansion by the current salt. */ #ifdef _UFC_32_ STATIC void shuffle_sb(k, saltbits) long32 *k; ufc_long saltbits; { ufc_long j; long32 x; for(j=4096; j--;) { x = (k[0] ^ k[1]) & (long32)saltbits; *k++ ^= x; *k++ ^= x; } } #endif #ifdef _UFC_64_ STATIC void shuffle_sb(k, saltbits) long64 *k; ufc_long saltbits; { ufc_long j; long64 x; for(j=4096; j--;) { x = ((*k >> 32) ^ *k) & (long64)saltbits; *k++ ^= (x << 32) | x; } } #endif /* * Setup the unit for a new salt * Hopefully we'll not see a new salt in each crypt call. */ static char current_salt[3] = "&&"; /* invalid value */ static ufc_long current_saltbits = 0; static int direction = 0; STATIC void setup_salt(s) char *s; { ufc_long i, j, saltbits; if(!initialized) init_des(); if(s[0] == current_salt[0] && s[1] == current_salt[1]) return; current_salt[0] = s[0]; current_salt[1] = s[1]; /* * This is the only crypt change to DES: * entries are swapped in the expansion table * according to the bits set in the salt. */ saltbits = 0; for(i = 0; i < 2; i++) { long c=ascii_to_bin(s[i]); if(c < 0 || c > 63) c = 0; for(j = 0; j < 6; j++) { if((c >> j) & 0x1) saltbits |= BITMASK(6 * i + j); } } /* * Permute the sb table values * to reflect the changed e * selection table */ shuffle_sb(ufc_sb0, current_saltbits ^ saltbits); shuffle_sb(ufc_sb1, current_saltbits ^ saltbits); shuffle_sb(ufc_sb2, current_saltbits ^ saltbits); shuffle_sb(ufc_sb3, current_saltbits ^ saltbits); current_saltbits = saltbits; } STATIC void ufc_mk_keytab(key) char *key; { ufc_long v1, v2, *k1; int i; #ifdef _UFC_32_ long32 v, *k2 = &ufc_keytab[0][0]; #endif #ifdef _UFC_64_ long64 v, *k2 = &ufc_keytab[0]; #endif v1 = v2 = 0; k1 = &do_pc1[0][0][0]; for(i = 8; i--;) { v1 |= k1[*key & 0x7f]; k1 += 128; v2 |= k1[*key++ & 0x7f]; k1 += 128; } for(i = 0; i < 16; i++) { k1 = &do_pc2[0][0]; v1 = (v1 << rots[i]) | (v1 >> (28 - rots[i])); v = k1[(v1 >> 21) & 0x7f]; k1 += 128; v |= k1[(v1 >> 14) & 0x7f]; k1 += 128; v |= k1[(v1 >> 7) & 0x7f]; k1 += 128; v |= k1[(v1 ) & 0x7f]; k1 += 128; #ifdef _UFC_32_ *k2++ = v; v = 0; #endif #ifdef _UFC_64_ v <<= 32; #endif v2 = (v2 << rots[i]) | (v2 >> (28 - rots[i])); v |= k1[(v2 >> 21) & 0x7f]; k1 += 128; v |= k1[(v2 >> 14) & 0x7f]; k1 += 128; v |= k1[(v2 >> 7) & 0x7f]; k1 += 128; v |= k1[(v2 ) & 0x7f]; *k2++ = v; } direction = 0; } /* * Undo an extra E selection and do final permutations */ ufc_long *ufc_dofinalperm(l1, l2, r1, r2) ufc_long l1,l2,r1,r2; { ufc_long v1, v2, x; static ufc_long ary[2]; x = (l1 ^ l2) & current_saltbits; l1 ^= x; l2 ^= x; x = (r1 ^ r2) & current_saltbits; r1 ^= x; r2 ^= x; v1=v2=0; l1 >>= 3; l2 >>= 3; r1 >>= 3; r2 >>= 3; v1 |= efp[15][ r2 & 0x3f][0]; v2 |= efp[15][ r2 & 0x3f][1]; v1 |= efp[14][(r2 >>= 6) & 0x3f][0]; v2 |= efp[14][ r2 & 0x3f][1]; v1 |= efp[13][(r2 >>= 10) & 0x3f][0]; v2 |= efp[13][ r2 & 0x3f][1]; v1 |= efp[12][(r2 >>= 6) & 0x3f][0]; v2 |= efp[12][ r2 & 0x3f][1]; v1 |= efp[11][ r1 & 0x3f][0]; v2 |= efp[11][ r1 & 0x3f][1]; v1 |= efp[10][(r1 >>= 6) & 0x3f][0]; v2 |= efp[10][ r1 & 0x3f][1]; v1 |= efp[ 9][(r1 >>= 10) & 0x3f][0]; v2 |= efp[ 9][ r1 & 0x3f][1]; v1 |= efp[ 8][(r1 >>= 6) & 0x3f][0]; v2 |= efp[ 8][ r1 & 0x3f][1]; v1 |= efp[ 7][ l2 & 0x3f][0]; v2 |= efp[ 7][ l2 & 0x3f][1]; v1 |= efp[ 6][(l2 >>= 6) & 0x3f][0]; v2 |= efp[ 6][ l2 & 0x3f][1]; v1 |= efp[ 5][(l2 >>= 10) & 0x3f][0]; v2 |= efp[ 5][ l2 & 0x3f][1]; v1 |= efp[ 4][(l2 >>= 6) & 0x3f][0]; v2 |= efp[ 4][ l2 & 0x3f][1]; v1 |= efp[ 3][ l1 & 0x3f][0]; v2 |= efp[ 3][ l1 & 0x3f][1]; v1 |= efp[ 2][(l1 >>= 6) & 0x3f][0]; v2 |= efp[ 2][ l1 & 0x3f][1]; v1 |= efp[ 1][(l1 >>= 10) & 0x3f][0]; v2 |= efp[ 1][ l1 & 0x3f][1]; v1 |= efp[ 0][(l1 >>= 6) & 0x3f][0]; v2 |= efp[ 0][ l1 & 0x3f][1]; ary[0] = v1; ary[1] = v2; return ary; } /* * crypt only: convert from 64 bit to 11 bit ASCII * prefixing with the salt */ STATIC char *output_conversion(v1, v2, salt) ufc_long v1, v2; char *salt; { static char outbuf[14]; int i, s; outbuf[0] = salt[0]; outbuf[1] = salt[1] ? salt[1] : salt[0]; for(i = 0; i < 5; i++) outbuf[i + 2] = bin_to_ascii((v1 >> (26 - 6 * i)) & 0x3f); s = (v2 & 0xf) << 2; v2 = (v2 >> 2) | ((v1 & 0x3) << 30); for(i = 5; i < 10; i++) outbuf[i + 2] = bin_to_ascii((v2 >> (56 - 6 * i)) & 0x3f); outbuf[12] = bin_to_ascii(s); outbuf[13] = 0; return outbuf; } ufc_long *ufc_doit(); /* * UNIX crypt function */ char *crypt(key, salt) char *key, *salt; { ufc_long *s; char ktab[9]; /* * Hack DES tables according to salt */ setup_salt(salt); /* * Setup key schedule */ clearmem(ktab, sizeof ktab); (void)strncpy(ktab, key, 8); ufc_mk_keytab(ktab); /* * Go for the 25 DES encryptions */ s = ufc_doit((ufc_long)0, (ufc_long)0, (ufc_long)0, (ufc_long)0, (ufc_long)25); /* * And convert back to 6 bit ASCII */ return output_conversion(s[0], s[1], salt); } /* * To make fcrypt users happy. * They don't need to call init_des. */ char *fcrypt(key, salt) char *key; char *salt; { return crypt(key, salt); } /* * UNIX encrypt function. Takes a bitvector * represented by one byte per bit and * encrypt/decrypt according to edflag */ void encrypt(block, edflag) char *block; int edflag; { ufc_long l1, l2, r1, r2, *s; int i; /* * Undo any salt changes to E expansion */ setup_salt(".."); /* * Reverse key table if * changing operation (encrypt/decrypt) */ if((edflag == 0) != (direction == 0)) { for(i = 0; i < 8; i++) { #ifdef _UFC_32_ long32 x; x = ufc_keytab[15-i][0]; ufc_keytab[15-i][0] = ufc_keytab[i][0]; ufc_keytab[i][0] = x; x = ufc_keytab[15-i][1]; ufc_keytab[15-i][1] = ufc_keytab[i][1]; ufc_keytab[i][1] = x; #endif #ifdef _UFC_64_ long64 x; x = ufc_keytab[15-i]; ufc_keytab[15-i] = ufc_keytab[i]; ufc_keytab[i] = x; #endif } direction = edflag; } /* * Do initial permutation + E expansion */ i = 0; for(l1 = 0; i < 24; i++) { if(block[initial_perm[esel[i]-1]-1]) l1 |= BITMASK(i); } for(l2 = 0; i < 48; i++) { if(block[initial_perm[esel[i]-1]-1]) l2 |= BITMASK(i-24); } i = 0; for(r1 = 0; i < 24; i++) { if(block[initial_perm[esel[i]-1+32]-1]) r1 |= BITMASK(i); } for(r2 = 0; i < 48; i++) { if(block[initial_perm[esel[i]-1+32]-1]) r2 |= BITMASK(i-24); } /* * Do DES inner loops + final conversion */ s = ufc_doit(l1, l2, r1, r2, (ufc_long)1); /* * And convert to bit array */ l1 = s[0]; r1 = s[1]; for(i = 0; i < 32; i++) { *block++ = (l1 & longmask[i]) != 0; } for(i = 0; i < 32; i++) { *block++ = (r1 & longmask[i]) != 0; } } /* * UNIX setkey function. Take a 64 bit DES * key and setup the machinery. */ void setkey(key) char *key; { int i,j; unsigned char c; unsigned char ktab[8]; setup_salt(".."); /* be sure we're initialized */ for(i = 0; i < 8; i++) { for(j = 0, c = 0; j < 8; j++) c = c << 1 | *key++; ktab[i] = c >> 1; } ufc_mk_keytab(ktab); } ./libc-linux/ufc/patchlevel.h100644 1676 334 1707 5146323700 14176 0ustar hjlisl/* * UFC-crypt: ultra fast crypt(3) implementation * * Copyright (C) 1991, 1992, Michael Glad, email: glad@daimi.aau.dk * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * @(#)patchlevel.h 1.6 01/31/92 * */ #define PATCHLEVEL "UFC-crypt, patchlevel 1a, @(#)patchlevel.h 1.6 01/31/92" ./libc-linux/ufc/speeds.c100644 1676 334 2412 5146323700 13317 0ustar hjlisl/* * This fcrypt/crypt speed testing program * is derived from one floating around in * the net. It's distributed along with * UFC-crypt but is not. * * Michael Glad, email: glad@daimi.aau.dk * * @(#)speeds.c 1.5 01/23/92 */ #include #include #include static int cnt; #define ITIME 10 /* Number of seconds to run test. */ void Stop () { printf ("Did %f %s()s per second.\n", ((float) cnt) / ((float) ITIME), #if defined(FCRYPT) "fcrypt" #else "crypt" #endif ); exit (0); } /* * Silly rewrite of 'bzero'. I do so * because some machines don't have * bzero and some don't have memset. */ static void clearmem(start, cnt) char *start; int cnt; { while(cnt--) *start++ = '\0'; } main () { struct itimerval itv; clearmem (&itv, sizeof (itv)); printf ("Running %s for %d seconds of virtual time ...\n", #ifdef FCRYPT "UFC-crypt", #else "crypt(libc)", #endif ITIME); #ifdef FCRYPT init_des (); #endif signal (SIGVTALRM, Stop); itv.it_value.tv_sec = ITIME; itv.it_value.tv_usec = 0; setitimer (ITIMER_VIRTUAL, &itv, NULL); for (cnt = 0;; cnt++) { #ifdef FCRYPT fcrypt ("fredfred", "eek"); #else crypt ("fredfred", "eek"); #endif } } ./libc-linux/ufc/ufc-crypt.h100644 1676 334 4321 5146323700 13756 0ustar hjlisl/* * UFC-crypt: ultra fast crypt(3) implementation * * Copyright (C) 1991, 1992, Michael Glad, email: glad@daimi.aau.dk * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * @(#)ufc-crypt.h 1.11 01/20/92 * * Definitions of datatypes * */ /* * Requirements for datatypes: * * A datatype 'ufc_long' of at least 32 bit * *and* * A type 'long32' of exactly 32 bits (_UFC_32_) * *or* * A type 'long64' of exactly 64 bits (_UFC_64_) * * 'int' is assumed to be at least 8 bit */ /* * #ifdef's for various architectures */ #ifdef cray /* Cray: all integer flavoured datatypes are 64 bit wide. Not tested -- please notify me if you are able to test it. */ typedef unsigned long ufc_long; typedef unsigned long long64; #define _UFC_64_ #endif #ifdef convex /* thanks to pcl@convex.oxford.ac.uk (Paul Leyland) for testing */ typedef unsigned long ufc_long; typedef long long long64; #define _UFC_64_ #endif /* * For debugging 64 bit code etc with 'gcc' */ #ifdef GCC3232 typedef unsigned long ufc_long; typedef unsigned long long32; #define _UFC_32_ #endif #ifdef GCC3264 typedef unsigned long ufc_long; typedef long long long64; #define _UFC_64_ #endif #ifdef GCC6432 typedef long long ufc_long; typedef unsigned long long32; #define _UFC_32_ #endif #ifdef GCC6464 typedef long long ufc_long; typedef long long long64; #define _UFC_64_ #endif /* * Catch all for 99.95% of all UNIX machines */ #ifndef _UFC_64_ #ifndef _UFC_32_ #define _UFC_32_ typedef unsigned ufc_long; typedef unsigned long long32; #endif #endif ./libc-linux/ufc/ufc.c100644 1676 334 2677 5146323700 12626 0ustar hjlisl/* * UFC-crypt: ultra fast crypt(3) implementation * * Copyright (C) 1991, 1992, Michael Glad, email: glad@daimi.aau.dk * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * @(#)ufc.c 2.4 12/30/91 * * Stub main program for debugging * and benchmarking. * */ #include char *crypt(); main(argc, argv) int argc; char **argv; { char *s; unsigned long i,iterations; if(argc != 2) { fprintf(stderr, "usage: ufc iterations\n"); exit(1); } argv++; iterations = atoi(*argv); printf("ufc: running %d iterations\n", iterations); for(i=0; i #include #include #include function_alias(setmntent, _IO_fopen, FILE *, (filename, mode), DEFUN(_IO_fopen, (filename, mode), CONST char *filename AND CONST char *mode)) ./libc-linux/mntent/mntent.c100644 1676 334 3035 5525253613 14101 0ustar hjlisl#include #include #include #include struct mntent *getmntent(FILE *filep) { char *cp, *sep = " \t\n"; static char buff[MNTMAXSTR]; static struct mntent mnt; /* Loop on the file, skipping comment lines. - FvK 03/07/93 */ while((cp = fgets(buff, sizeof buff, filep)) != NULL) { if (buff[0] == '#' || buff[0] == '\n') continue; break; } /* At the EOF, the buffer should be unchanged. We should * check the return value from fgets (). */ if (cp == NULL) return NULL; mnt.mnt_fsname = strtok(buff, sep); if (mnt.mnt_fsname == NULL) return NULL; mnt.mnt_dir = strtok(NULL, sep); if (mnt.mnt_dir == NULL) return NULL; mnt.mnt_type = strtok(NULL, sep); if (mnt.mnt_type == NULL) #if 0 mnt.mnt_type = MNTTYPE_MINIX; #else return NULL; #endif mnt.mnt_opts = strtok(NULL, sep); if (mnt.mnt_opts == NULL) mnt.mnt_opts = ""; cp = strtok(NULL, sep); mnt.mnt_freq = (cp != NULL) ? atoi(cp) : 0; cp = strtok(NULL, sep); mnt.mnt_passno = (cp != NULL) ? atoi(cp) : 0; return &mnt; } int addmntent(FILE *filep, const struct mntent *mnt) { if (fseek(filep, 0, SEEK_END) < 0) return 1; if (fprintf(filep, "%s %s %s %s %d %d\n", mnt->mnt_fsname, mnt->mnt_dir, mnt->mnt_type, mnt->mnt_opts, mnt->mnt_freq, mnt->mnt_passno) < 1) return 1; return 0; } char *hasmntopt(const struct mntent *mnt, const char *opt) { return strstr(mnt->mnt_opts, opt); } int endmntent(FILE *filep) { if (filep != NULL) fclose(filep); return 1; } ./libc-linux/mntent/Makefile100644 1676 334 436 5527732163 14056 0ustar hjlisl# # Makefile for mntent functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules DIRS:= SRC1S= mntent.c SRC2S= setmntent.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/io/ 40755 1676 334 0 5550052277 11435 5ustar hjlisl./libc-linux/io/access.c100644 1676 334 2001 5263140644 13125 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 #undef access function_alias(access, __access, int, (file, type), DEFUN(access, (file, type), CONST char *file AND int type)) ./libc-linux/io/chdir.c100644 1676 334 1745 5263140644 12773 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 #undef chdir function_alias(chdir, __chdir, int, (path), DEFUN(chdir, (path), CONST char *path)) ./libc-linux/io/chmod.c100644 1676 334 2013 5263140644 12761 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 #undef chmod function_alias(chmod, __chmod, int, (file, mode), DEFUN(chmod, (file, mode), CONST char *file AND __mode_t mode)) ./libc-linux/io/chown.c100644 1676 334 2062 5263140644 13011 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 #undef chown function_alias(chown, __chown, int, (file, owner, group), DEFUN(chown, (file, owner, group), CONST char *file AND __uid_t owner AND __gid_t group)) ./libc-linux/io/close.c100644 1676 334 1726 5263140644 13006 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 #undef close function_alias(close, __close, int, (fd), DEFUN(close, (fd), int fd)) ./libc-linux/io/creat.c100644 1676 334 2056 5263140645 12775 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 #undef creat /* Create FILE with protections MODE. */ int DEFUN(creat, (file, mode), CONST char *file AND mode_t mode) { return __open(file, O_WRONLY|O_CREAT|O_TRUNC, mode); } ./libc-linux/io/dup.c100644 1676 334 1742 5263140645 12470 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 #undef dup function_alias(dup, __dup, int, (fd), DEFUN(dup, (fd), int fd)) ./libc-linux/io/dup2.c100644 1676 334 2017 5263140645 12546 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 #undef dup2 function_alias(dup2, __dup2, int, (fd, fd2), DEFUN(dup2, (fd, fd2), int fd AND int fd2)) ./libc-linux/io/fchmod.c100644 1676 334 2026 5263140645 13134 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 #include #undef fchmod function_alias(fchmod, __fchmod, int, (fd, mode), DEFUN(fchmod, (fd, mode), int fd AND mode_t mode)) ./libc-linux/io/fchown.c100644 1676 334 2073 5263140645 13162 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 #include #undef fchown function_alias(fchown, __fchown, int, (fd, owner, group), DEFUN(fchown, (fd, owner, group), int fd AND uid_t owner AND gid_t group)) ./libc-linux/io/fcntl.c100644 1676 334 2015 5263140645 13000 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 #include #undef fcntl function_alias(fcntl, __fcntl, int, (fd, cmd), DEFUN(fcntl, (fd, cmd), int fd AND int cmd DOTS)) ./libc-linux/io/flock.c100644 1676 334 2007 5263140645 12771 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 #include #include #undef flock function_alias(flock, __flock, int, (fd, operation), DEFUN(flock, (fd, operation), int fd AND int operation)) ./libc-linux/io/fstat.c100644 1676 334 1767 5263140645 13030 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 #undef fstat function_alias(fstat, __fstat, int, (fd, buf), DEFUN(fstat, (fd, buf), int fd AND struct stat *buf)) ./libc-linux/io/ftw.c100644 1676 334 11020 5266731032 12505 0ustar hjlisl/* Copyright (C) 1992 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ian Lance Taylor (ian@airs.com). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include #include #include #ifdef linux #define d_namlen d_reclen #endif /* Traverse one level of a directory tree. */ static int #ifdef linux DEFUN (ftw_dir, (dirs, level, descriptors, dir, len, func), DIR **dirs AND int level AND int descriptors AND char *dir AND size_t len AND __ftw_func_t func) #else DEFUN (ftw_dir, (dirs, level, descriptors, dir, len, func), DIR **dirs AND int level AND int descriptors AND char *dir AND size_t len AND int EXFUN((*func), (CONST char *file, struct stat *status, int flag))) #endif { int got; struct dirent *entry; got = 0; errno = 0; while ((entry = readdir (dirs[level])) != NULL) { struct stat s; int flag, ret, newlev; ++got; if (entry->d_name[0] == '.' && (entry->d_namlen == 1 || (entry->d_namlen == 2 && entry->d_name[1] == '.'))) { errno = 0; continue; } if (entry->d_namlen + len + 1 > PATH_MAX) { #ifdef ENAMETOOLONG errno = ENAMETOOLONG; #else errno = ENOMEM; #endif return -1; } dir[len] = '/'; memcpy ((PTR) (dir + len + 1), (PTR) entry->d_name, entry->d_namlen + 1); if (stat (dir, &s) < 0) { if (errno != EACCES) return -1; flag = FTW_NS; } else if (S_ISDIR (s.st_mode)) { newlev = (level + 1) % descriptors; if (dirs[newlev] != NULL) closedir (dirs[newlev]); dirs[newlev] = opendir (dir); if (dirs[newlev] != NULL) flag = FTW_D; else { if (errno != EACCES) return -1; flag = FTW_DNR; } } else flag = FTW_F; ret = (*func) (dir, &s, flag); if (flag == FTW_D) { if (ret == 0) ret = ftw_dir (dirs, newlev, descriptors, dir, entry->d_namlen + len + 1, func); if (dirs[newlev] != NULL) { int save; save = errno; closedir (dirs[newlev]); errno = save; dirs[newlev] = NULL; } } if (ret != 0) return ret; if (dirs[level] == NULL) { int skip; dir[len] = '\0'; dirs[level] = opendir (dir); if (dirs[level] == NULL) return -1; skip = got; while (skip-- != 0) { errno = 0; if (readdir (dirs[level]) == NULL) return errno == 0 ? 0 : -1; } } errno = 0; } return errno == 0 ? 0 : -1; } /* Call a function on every element in a directory tree. */ int #ifdef linux DEFUN(ftw, (dir, func, descriptors), CONST char *dir AND __ftw_func_t func AND int descriptors) #else DEFUN(ftw, (dir, func, descriptors), CONST char *dir AND *func), (CONST char *file, struct stat *status, int flag)) AND int descriptors) #endif { DIR **dirs; size_t len; char buf[PATH_MAX + 1]; struct stat s; int flag, ret; int i; if (descriptors <= 0) descriptors = 1; dirs = (DIR **) __alloca (descriptors * sizeof (DIR *)); i = descriptors; while (i-- > 0) dirs[i] = NULL; if (stat (dir, &s) < 0) { if (errno != EACCES) return -1; flag = FTW_NS; } else if (S_ISDIR (s.st_mode)) { dirs[0] = opendir (dir); if (dirs[0] != NULL) flag = FTW_D; else { if (errno != EACCES) return -1; flag = FTW_DNR; } } else flag = FTW_F; len = strlen (dir); memcpy ((PTR) buf, (PTR) dir, len + 1); ret = (*func) (buf, &s, flag); if (flag == FTW_D) { if (ret == 0) ret = ftw_dir (dirs, 0, descriptors, buf, len, func); if (dirs[0] != NULL) { int save; save = errno; closedir (dirs[0]); errno = save; } } return ret; } ./libc-linux/io/getdirname.c100644 1676 334 2723 5263140646 14020 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 #include #include #include #include /* Return a malloc'd string containing the current directory name. If the environment variable `PWD' is set, and its value is correct, that value is used. */ char * DEFUN_VOID(get_current_dir_name) { char *pwd; struct stat dotstat, pwdstat; pwd = getenv ("PWD"); if (pwd != NULL && stat (".", &dotstat) == 0 && stat (pwd, &pwdstat) == 0 && pwdstat.st_dev == dotstat.st_dev && pwdstat.st_ino == dotstat.st_ino) /* The PWD value is correct. Use it. */ return strdup (pwd); return getcwd ((char *) NULL, 0); } ./libc-linux/io/getwd.c100644 1676 334 2717 5263140646 13016 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 #include #include /* Put the absolute pathname of the current working direction in BUF. If successful, return BUF. If not, put an error message in BUF and return NULL. BUF should be at least PATH_MAX bytes long. */ char * DEFUN(getwd, (buf), char *buf) { if (buf == NULL) { errno = EINVAL; return NULL; } #ifndef PATH_MAX #define PATH_MAX 1024 /* Arbitrary; this function is unreliable. */ #endif if (getcwd (buf, PATH_MAX) == NULL) { (void) strncpy (buf, strerror (errno), PATH_MAX); return NULL; } return buf; } ./libc-linux/io/isatty.c100644 1676 334 1733 5263140646 13216 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 #undef isatty function_alias(isatty, __isatty, int, (fd), DEFUN(isatty, (fd), int fd)) ./libc-linux/io/link.c100644 1676 334 1774 5263140646 12643 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 #undef link function_alias(link, __link, int, (from, to), DEFUN(link, (from, to), CONST char *from AND CONST char *to)) ./libc-linux/io/lseek.c100644 1676 334 2035 5263140646 13000 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 #include #undef lseek function_alias(lseek, __lseek, off_t, (fd, off, w), DEFUN(lseek, (fd, off, w), int fd AND off_t off AND int w)) ./libc-linux/io/lstat.c100644 1676 334 2014 5263140646 13021 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 #undef lstat function_alias(lstat, __lstat, int, (file, buf), DEFUN(lstat, (file, buf), CONST char *file AND struct stat *buf)) ./libc-linux/io/mkdir.c100644 1676 334 2012 5263140646 12776 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 #undef mkdir function_alias(mkdir, __mkdir, int, (path, mode), DEFUN(mkdir, (path, mode), CONST char *path AND __mode_t mode)) ./libc-linux/io/open.c100644 1676 334 2551 5263140646 12641 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 /* The `open' function might take three arguments. */ #undef open #ifdef HAVE_GNU_LD #include symbol_alias(__open, open); #else /* No GNU stabs. */ #include int DEFUN(open, (file, oflag), CONST char *file AND int oflag DOTS) { if (oflag & O_CREAT) { va_list args; int mode; va_start(args, oflag); mode = va_arg(args, int); va_end(args); return __open(file, oflag, mode); } return __open(file, oflag); } #endif /* GNU stabs. */ ./libc-linux/io/pipe.c100644 1676 334 1770 5263140646 12637 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 #undef pipe function_alias(pipe, __pipe, int, (pipedes), DEFUN(pipe, (pipedes), int pipedes[2])) ./libc-linux/io/read.c100644 1676 334 2042 5263140647 12607 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 #include #undef read function_alias(read, __read, __ssize_t, (fd, buf, n), DEFUN(read, (fd, buf, n), int fd AND PTR buf AND size_t n)) ./libc-linux/io/readlink.c100644 1676 334 2051 5263140647 13465 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 #undef readlink function_alias(readlink, __readlink, int, (path, buf, len), DEFUN(readlink, (path, buf, len), CONST char *path AND char *buf AND size_t len)) ./libc-linux/io/rmdir.c100644 1676 334 1745 5263140647 13022 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 #undef rmdir function_alias(rmdir, __rmdir, int, (path), DEFUN(rmdir, (path), CONST char *path)) ./libc-linux/io/stat.c100644 1676 334 2016 5263140647 12650 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 #undef stat function_alias(stat, __stat, int, (file, buf), DEFUN(stat, (file, buf), CONST char *file AND struct stat *buf)) ./libc-linux/io/symlink.c100644 1676 334 2010 5263140647 13355 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 #undef symlink function_alias(symlink, __symlink, int, (from, to), DEFUN(symlink, (from, to), CONST char *from AND CONST char *to)) ./libc-linux/io/umask.c100644 1676 334 1760 5263140647 13022 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 #undef umask function_alias(umask, __umask, __mode_t, (mask), DEFUN(umask, (mask), __mode_t mask)) ./libc-linux/io/unlink.c100644 1676 334 1750 5263140647 13201 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 #undef unlink function_alias(unlink, __unlink, int, (name), DEFUN(unlink, (name), CONST char *name)) ./libc-linux/io/write.c100644 1676 334 2043 5263140647 13027 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 #include #undef write function_alias(write, __write, __ssize_t, (d, b, n), DEFUN(write, (d, b, n), int d AND CONST PTR b AND size_t n)) ./libc-linux/io/Makefile100644 1676 334 1046 5515544042 13170 0ustar hjlisl# # This is Makefile of io for Linux # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS= -I. -I$(TOPDIR) DIRS:= SRC1S= ftw.c getdirname.c getwd.c SRC2S= access.c chdir.c chmod.c chown.c close.c dup.c dup2.c \ fchmod.c fchown.c fcntl.c flock.c fstat.c isatty.c link.c \ lseek.c lstat.c mkdir.c open.c pipe.c read.c readlink.c \ rmdir.c stat.c symlink.c umask.c unlink.c write.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./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/rpc/ 40755 1676 334 0 5550054122 11601 5ustar hjlisl./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/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/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/pmap_getport.c100644 1676 334 5434 5376775462 14600 0ustar hjlisl/* @(#)pmap_getport.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_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro"; #endif /* * pmap_getport.c * Client interface to pmap rpc service. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include #include #include static struct timeval timeout = { 5, 0 }; static struct timeval tottimeout = { 60, 0 }; /* * Find the mapped port for program,version. * Calls the pmap service remotely to do the lookup. * Returns 0 if no map exists. */ u_short pmap_getport(address, program, version, protocol) struct sockaddr_in *address; u_long program; u_long version; u_int protocol; { u_short port = 0; int socket = -1; register CLIENT *client; struct pmap parms; address->sin_port = htons(PMAPPORT); client = clntudp_bufcreate(address, PMAPPROG, PMAPVERS, timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); if (client != (CLIENT *)NULL) { parms.pm_prog = program; parms.pm_vers = version; parms.pm_prot = protocol; parms.pm_port = 0; /* not needed or used */ if (CLNT_CALL(client, PMAPPROC_GETPORT, xdr_pmap, &parms, xdr_u_short, &port, tottimeout) != RPC_SUCCESS){ rpc_createerr.cf_stat = RPC_PMAPFAILURE; clnt_geterr(client, &rpc_createerr.cf_error); } else if (port == 0) { rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED; } CLNT_DESTROY(client); } (void)close(socket); address->sin_port = 0; return (port); } ./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/Makefile100644 1676 334 1757 5515544422 13360 0ustar hjlisl# # Makefile for SUN rpc functions # # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules # very special flags. gcc is broken on the builtin ffs (). VSCFLAGS=-fno-builtin INC_CFLAGS=-I$(TOPDIR)/include BASE_CFLAGS:= $(BASE_CFLAGS) $(VSCFLAGS) DIRS:= SRCS = auth_none.c auth_unix.c auth_prot.c bindresvport.c SRCS = auth_none.c auth_unix.c auth_prot.c \ clnt_generic.c clnt_perror.c clnt_raw.c clnt_simple.c \ clnt_tcp.c clnt_udp.c rpc_dtblsz.c get_myaddr.c \ getrpcent.c getrpcport.c pmap_clnt.c pmap_getmaps.c \ pmap_getport.c pmap_prot.c pmap_prot2.c pmap_rmt.c \ rpc_prot.c rpc_comdata.c rpc_callmsg.c svc.c svc_auth.c \ svc_au_ux.c svc_raw.c svc_run.c svc_simple.c \ svc_tcp.c svc_udp.c xdr.c xdr_array.c xdr_float.c xdr_mem.c \ xdr_rec.c xdr_ref.c xdr_stdio.c HDRS = auth.h auth_unix.h clnt.h netdb.h pmap_clnt.h pmap_prot.h \ pmap_rmt.h rpc.h rpc_msg.h svc.h svc_auth.h types.h xdr.h ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/rpc/auth_none.c100644 1676 334 6415 5262760650 14042 0ustar hjlisl/* @(#)auth_none.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[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; #endif /* * auth_none.c * Creates a client authentication handle for passing "null" * credentials and verifiers to remote systems. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #ifdef __STDC__ #include #endif #define MAX_MARSHEL_SIZE 20 /* * Authenticator operations routines */ static void authnone_verf(); static void authnone_destroy(); static bool_t authnone_marshal(); static bool_t authnone_validate(); static bool_t authnone_refresh(); static struct auth_ops ops = { authnone_verf, authnone_marshal, authnone_validate, authnone_refresh, authnone_destroy }; static struct authnone_private { AUTH no_client; char marshalled_client[MAX_MARSHEL_SIZE]; u_int mcnt; } *authnone_private; AUTH * authnone_create() { register struct authnone_private *ap = authnone_private; XDR xdr_stream; register XDR *xdrs; if (ap == 0) { ap = (struct authnone_private *)calloc(1, sizeof (*ap)); if (ap == 0) return (0); authnone_private = ap; } if (!ap->mcnt) { ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; ap->no_client.ah_ops = &ops; xdrs = &xdr_stream; xdrmem_create(xdrs, ap->marshalled_client, (u_int)MAX_MARSHEL_SIZE, XDR_ENCODE); (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_cred); (void)xdr_opaque_auth(xdrs, &ap->no_client.ah_verf); ap->mcnt = XDR_GETPOS(xdrs); XDR_DESTROY(xdrs); } return (&ap->no_client); } /*ARGSUSED*/ static bool_t authnone_marshal(client, xdrs) AUTH *client; XDR *xdrs; { register struct authnone_private *ap = authnone_private; if (ap == 0) return (0); return ((*xdrs->x_ops->x_putbytes)(xdrs, ap->marshalled_client, ap->mcnt)); } static void authnone_verf() { } static bool_t authnone_validate() { return (TRUE); } static bool_t authnone_refresh() { return (FALSE); } static void authnone_destroy() { } ./libc-linux/rpc/clnt_simple.c100644 1676 334 6750 5303100614 14355 0ustar hjlisl/* @(#)clnt_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[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro"; #endif /* * clnt_simple.c * Simplified front end to rpc. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include #include #include #ifdef __STDC__ #include #endif static struct callrpc_private { CLIENT *client; int socket; int oldprognum, oldversnum, valid; char *oldhost; } *callrpc_private; int callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) char *host; u_long prognum; u_long versnum; u_long procnum; xdrproc_t inproc, outproc; char *in, *out; { register struct callrpc_private *crp = callrpc_private; struct sockaddr_in server_addr; enum clnt_stat clnt_stat; struct hostent *hp; struct timeval timeout, tottimeout; if (crp == 0) { crp = (struct callrpc_private *)calloc(1, sizeof (*crp)); if (crp == 0) return (0); callrpc_private = crp; } if (crp->oldhost == NULL) { crp->oldhost = malloc(256); crp->oldhost[0] = 0; crp->socket = RPC_ANYSOCK; } if (crp->valid && crp->oldprognum == prognum && crp->oldversnum == versnum && strcmp(crp->oldhost, host) == 0) { /* reuse old client */ } else { crp->valid = 0; (void)close(crp->socket); crp->socket = RPC_ANYSOCK; if (crp->client) { clnt_destroy(crp->client); crp->client = NULL; } if ((hp = gethostbyname(host)) == NULL) return ((int) RPC_UNKNOWNHOST); timeout.tv_usec = 0; timeout.tv_sec = 5; bcopy(hp->h_addr, (char *)&server_addr.sin_addr, hp->h_length); server_addr.sin_family = AF_INET; server_addr.sin_port = 0; if ((crp->client = clntudp_create(&server_addr, (u_long)prognum, (u_long)versnum, timeout, &crp->socket)) == NULL) return ((int) rpc_createerr.cf_stat); crp->valid = 1; crp->oldprognum = prognum; crp->oldversnum = versnum; (void) strcpy(crp->oldhost, host); } tottimeout.tv_sec = 25; tottimeout.tv_usec = 0; clnt_stat = clnt_call(crp->client, procnum, inproc, in, outproc, out, tottimeout); /* * if call failed, empty cache */ if (clnt_stat != RPC_SUCCESS) crp->valid = 0; return ((int) clnt_stat); } ./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/svc_auth.c100644 1676 334 7243 5262760650 13676 0ustar hjlisl#if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC; from 1.19 87/08/11 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 */ /* * svc_auth_nodes.c, Server-side rpc authenticator interface, * *WITHOUT* DES authentication. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include /* * svcauthsw is the bdevsw of server side authentication. * * Server side authenticators are called from authenticate by * using the client auth struct flavor field to index into svcauthsw. * The server auth flavors must implement a routine that looks * like: * * enum auth_stat * flavorx_auth(rqst, msg) * register struct svc_req *rqst; * register struct rpc_msg *msg; * */ enum auth_stat _svcauth_null(); /* no authentication */ enum auth_stat _svcauth_unix(); /* unix style (uid, gids) */ enum auth_stat _svcauth_short(); /* short hand unix style */ static struct { enum auth_stat (*authenticator)(); } svcauthsw[] = { _svcauth_null, /* AUTH_NULL */ _svcauth_unix, /* AUTH_UNIX */ _svcauth_short, /* AUTH_SHORT */ }; #define AUTH_MAX 2 /* HIGHEST AUTH NUMBER */ /* * The call rpc message, msg has been obtained from the wire. The msg contains * the raw form of credentials and verifiers. authenticate returns AUTH_OK * if the msg is successfully authenticated. If AUTH_OK then the routine also * does the following things: * set rqst->rq_xprt->verf to the appropriate response verifier; * sets rqst->rq_client_cred to the "cooked" form of the credentials. * * NB: rqst->rq_cxprt->verf must be pre-alloctaed; * its length is set appropriately. * * The caller still owns and is responsible for msg->u.cmb.cred and * msg->u.cmb.verf. The authentication system retains ownership of * rqst->rq_client_cred, the cooked credentials. * * There is an assumption that any flavour less than AUTH_NULL is * invalid. */ enum auth_stat _authenticate(rqst, msg) register struct svc_req *rqst; struct rpc_msg *msg; { register int cred_flavor; rqst->rq_cred = msg->rm_call.cb_cred; rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor; rqst->rq_xprt->xp_verf.oa_length = 0; cred_flavor = rqst->rq_cred.oa_flavor; if ((cred_flavor <= AUTH_MAX) && (cred_flavor >= AUTH_NULL)) { return ((*(svcauthsw[cred_flavor].authenticator))(rqst, msg)); } return (AUTH_REJECTEDCRED); } enum auth_stat _svcauth_null(/*rqst, msg*/) /*struct svc_req *rqst; struct rpc_msg *msg;*/ { return (AUTH_OK); } ./libc-linux/rpc/getrpcent.c100644 1676 334 16001 5421261323 14053 0ustar hjlisl/* @(#)getrpcent.c 2.2 88/07/29 4.0 RPCSRC */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)getrpcent.c 1.9 87/08/11 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 */ /* * Copyright (c) 1985 by Sun Microsystems, Inc. */ #include #include #include #include #include #ifdef YP #include #include #endif #ifdef __STDC__ #include #endif /* * Internet version. */ static struct rpcdata { FILE *rpcf; char *current; int currentlen; int stayopen; #define MAXALIASES 35 char *rpc_aliases[MAXALIASES]; struct rpcent rpc; char line[BUFSIZ+1]; char *domain; } *rpcdata; static struct rpcent *interpret(); #ifdef __linux__ #include #include #else char *inet_ntoa(); struct hostent *gethostent(); static char *index(); static char RPCDB[] = "/net/etc/rpc"; #endif static struct rpcdata * _rpcdata() { register struct rpcdata *d = rpcdata; if (d == 0) { d = (struct rpcdata *)calloc(1, sizeof (struct rpcdata)); rpcdata = d; } return (d); } struct rpcent * getrpcbynumber(number) register int number; { register struct rpcdata *d = _rpcdata(); register struct rpcent *p; #ifdef YP int reason; char adrstr[16], *val = NULL; int vallen; #endif if (d == 0) return (0); #ifdef YP if (__yp_check(NULL)) { if (d->domain == NULL) yp_get_default_domain(&d->domain); sprintf(adrstr, "%d", number); if ((reason = yp_match(d->domain, "rpc.bynumber", adrstr, strlen(adrstr), &d->current, &d->currentlen)) != 0) { return(0); } p = interpret(d->current, d->currentlen); (void) free(d->current); return p; } #endif setrpcent(0); while (p = getrpcent()) { if (p->r_number == number) break; } endrpcent(); return (p); } struct rpcent * #ifdef __linux__ getrpcbyname(const char *name) #else getrpcbyname(name) char *name; #endif { struct rpcent *rpc; char **rp; setrpcent(0); while(rpc = getrpcent()) { #ifdef __linux__ if (strcmp(rpc->r_name, name) == 0) { endrpcent(); return (rpc); } #else if (strcmp(rpc->r_name, name) == 0) return (rpc); #endif for (rp = rpc->r_aliases; *rp != NULL; rp++) { #ifdef __linux__ if (strcmp(*rp, name) == 0) { endrpcent(); return (rpc); } #else if (strcmp(*rp, name) == 0) return (rpc); #endif } } endrpcent(); return (NULL); } #ifdef __linux__ void #endif setrpcent(f) int f; { register struct rpcdata *d = _rpcdata(); if (d == 0) return; #ifdef YP if (__yp_check(NULL)) { if (d->current) free(d->current); d->current = NULL; d->currentlen = 0; return; } #endif if (d->rpcf == NULL) #ifdef __linux__ d->rpcf = fopen(_PATH_RPC, "r"); #else d->rpcf = fopen(RPCDB, "r"); #endif else rewind(d->rpcf); if (d->current) free(d->current); d->current = NULL; d->stayopen |= f; } #ifdef __linux__ void #endif endrpcent() { register struct rpcdata *d = _rpcdata(); if (d == 0) return; #ifdef YP if (__yp_check(NULL)) { if (d->current) free(d->current); d->current = NULL; d->currentlen = 0; return; } #endif if (d->current && !d->stayopen) { free(d->current); d->current = NULL; } if (d->rpcf && !d->stayopen) { fclose(d->rpcf); d->rpcf = NULL; } } struct rpcent * getrpcent() { register struct rpcdata *d = _rpcdata(); #ifdef YP struct rpcent *hp; int reason; char *key = NULL, *val = NULL; int keylen, vallen; #endif if (d == 0) return(NULL); #ifdef YP if(__yp_check(NULL)) { if (d->domain == NULL) yp_get_default_domain(&d->domain); if (d->current == NULL && d->currentlen == 0) { reason = yp_first(d->domain, "rpc.bynumber", &d->current, &d->currentlen, &val, &vallen); } else { reason = yp_next(d->domain, "rpc.bynumber", d->current, d->currentlen, &d->current, &d->currentlen, &val, &vallen); } if (reason != 0) { return(NULL); } hp = interpret(val, vallen); (void) free(val); return hp; } #endif #ifdef __linux__ if (d->rpcf == NULL && (d->rpcf = fopen(_PATH_RPC, "r")) == NULL) #else if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL) #endif return (NULL); if (fgets(d->line, BUFSIZ, d->rpcf) == NULL) return (NULL); return interpret(d->line, strlen(d->line)); } #ifdef __linux__ static char * firstwhite(s) char *s; { char *s1, *s2; s1 = index(s, ' '); s2 = index(s, '\t'); if (s1) { if (s2) return (s1 < s2) ? s1 : s2; else return s1; } else return s2; } #endif static struct rpcent * interpret(val, len) char *val; int len; { register struct rpcdata *d = _rpcdata(); char *p; register char *cp, **q; if (d == 0) return NULL; strncpy(d->line, val, len); p = d->line; d->line[len] = '\n'; if (*p == '#') return (getrpcent()); cp = index(p, '#'); if (cp == NULL) { cp = index(p, '\n'); if (cp == NULL) return (getrpcent()); } *cp = '\0'; #ifdef __linux__ if ((cp = firstwhite(p))) *cp++ = 0; else return (getrpcent()); #else cp = index(p, ' '); if (cp == NULL) { cp = index(p, '\t'); if (cp == NULL) return (getrpcent()); } *cp++ = '\0'; #endif /* THIS STUFF IS INTERNET SPECIFIC */ d->rpc.r_name = d->line; while (*cp == ' ' || *cp == '\t') cp++; d->rpc.r_number = atoi(cp); q = d->rpc.r_aliases = d->rpc_aliases; #ifdef __linux__ if ((cp = firstwhite(cp))) *cp++ = '\0'; #else cp = index(p, ' '); if (cp != NULL) *cp++ = '\0'; else { cp = index(p, '\t'); if (cp != NULL) *cp++ = '\0'; } #endif while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &(d->rpc_aliases[MAXALIASES - 1])) *q++ = cp; #ifdef __linux__ if ((cp = firstwhite(cp))) *cp++ = '\0'; #else cp = index(p, ' '); if (cp != NULL) *cp++ = '\0'; else { cp = index(p, '\t'); if (cp != NULL) *cp++ = '\0'; } #endif } *q = NULL; return (&d->rpc); } ./libc-linux/rpc/pmap_prot2.c100644 1676 334 7350 5303100615 14125 0ustar hjlisl/* @(#)pmap_prot2.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[] = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro"; #endif /* * pmap_prot2.c * Protocol for the local binder service, or pmap. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include /* * What is going on with linked lists? (!) * First recall the link list declaration from pmap_prot.h: * * struct pmaplist { * struct pmap pml_map; * struct pmaplist *pml_map; * }; * * Compare that declaration with a corresponding xdr declaration that * is (a) pointer-less, and (b) recursive: * * typedef union switch (bool_t) { * * case TRUE: struct { * struct pmap; * pmaplist_t foo; * }; * * case FALSE: struct {}; * } pmaplist_t; * * Notice that the xdr declaration has no nxt pointer while * the C declaration has no bool_t variable. The bool_t can be * interpreted as ``more data follows me''; if FALSE then nothing * follows this bool_t; if TRUE then the bool_t is followed by * an actual struct pmap, and then (recursively) by the * xdr union, pamplist_t. * * This could be implemented via the xdr_union primitive, though this * would cause a one recursive call per element in the list. Rather than do * that we can ``unwind'' the recursion * into a while loop and do the union arms in-place. * * The head of the list is what the C programmer wishes to past around * the net, yet is the data that the pointer points to which is interesting; * this sounds like a job for xdr_reference! */ bool_t xdr_pmaplist(xdrs, rp) register XDR *xdrs; register struct pmaplist **rp; { /* * more_elements is pre-computed in case the direction is * XDR_ENCODE or XDR_FREE. more_elements is overwritten by * xdr_bool when the direction is XDR_DECODE. */ bool_t more_elements; register int freeing = (xdrs->x_op == XDR_FREE); register struct pmaplist **next = NULL; while (TRUE) { more_elements = (bool_t)(*rp != NULL); if (! xdr_bool(xdrs, &more_elements)) return (FALSE); if (! more_elements) return (TRUE); /* we are done */ /* * the unfortunate side effect of non-recursion is that in * the case of freeing we must remember the next object * before we free the current object ... */ if (freeing) next = &((*rp)->pml_next); if (! xdr_reference(xdrs, (caddr_t *)rp, (u_int)sizeof(struct pmaplist), xdr_pmap)) return (FALSE); rp = (freeing) ? next : &((*rp)->pml_next); } } ./libc-linux/rpc/rpc_callmsg.c100644 1676 334 13107 5262760651 14365 0ustar hjlisl/* @(#)rpc_callmsg.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[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro"; #endif /* * rpc_callmsg.c * * Copyright (C) 1984, Sun Microsystems, Inc. * */ #include #include /* * XDR a call message */ bool_t xdr_callmsg(xdrs, cmsg) register XDR *xdrs; register struct rpc_msg *cmsg; { register long *buf; register struct opaque_auth *oa; if (xdrs->x_op == XDR_ENCODE) { if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) { return (FALSE); } if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) { return (FALSE); } buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT + RNDUP(cmsg->rm_call.cb_cred.oa_length) + 2 * BYTES_PER_XDR_UNIT + RNDUP(cmsg->rm_call.cb_verf.oa_length)); if (buf != NULL) { IXDR_PUT_LONG(buf, cmsg->rm_xid); IXDR_PUT_ENUM(buf, cmsg->rm_direction); if (cmsg->rm_direction != CALL) { return (FALSE); } IXDR_PUT_LONG(buf, cmsg->rm_call.cb_rpcvers); if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) { return (FALSE); } IXDR_PUT_LONG(buf, cmsg->rm_call.cb_prog); IXDR_PUT_LONG(buf, cmsg->rm_call.cb_vers); IXDR_PUT_LONG(buf, cmsg->rm_call.cb_proc); oa = &cmsg->rm_call.cb_cred; IXDR_PUT_ENUM(buf, oa->oa_flavor); IXDR_PUT_LONG(buf, oa->oa_length); if (oa->oa_length) { bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length); buf += RNDUP(oa->oa_length) / sizeof (long); } oa = &cmsg->rm_call.cb_verf; IXDR_PUT_ENUM(buf, oa->oa_flavor); IXDR_PUT_LONG(buf, oa->oa_length); if (oa->oa_length) { bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length); /* no real need.... buf += RNDUP(oa->oa_length) / sizeof (long); */ } return (TRUE); } } if (xdrs->x_op == XDR_DECODE) { buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT); if (buf != NULL) { cmsg->rm_xid = IXDR_GET_LONG(buf); cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type); if (cmsg->rm_direction != CALL) { return (FALSE); } cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG(buf); if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) { return (FALSE); } cmsg->rm_call.cb_prog = IXDR_GET_LONG(buf); cmsg->rm_call.cb_vers = IXDR_GET_LONG(buf); cmsg->rm_call.cb_proc = IXDR_GET_LONG(buf); oa = &cmsg->rm_call.cb_cred; oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t); oa->oa_length = IXDR_GET_LONG(buf); if (oa->oa_length) { if (oa->oa_length > MAX_AUTH_BYTES) { return (FALSE); } if (oa->oa_base == NULL) { oa->oa_base = (caddr_t) mem_alloc(oa->oa_length); } buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); if (buf == NULL) { if (xdr_opaque(xdrs, oa->oa_base, oa->oa_length) == FALSE) { return (FALSE); } } else { bcopy((caddr_t)buf, oa->oa_base, oa->oa_length); /* no real need.... buf += RNDUP(oa->oa_length) / sizeof (long); */ } } oa = &cmsg->rm_call.cb_verf; buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE || xdr_u_int(xdrs, &oa->oa_length) == FALSE) { return (FALSE); } } else { oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t); oa->oa_length = IXDR_GET_LONG(buf); } if (oa->oa_length) { if (oa->oa_length > MAX_AUTH_BYTES) { return (FALSE); } if (oa->oa_base == NULL) { oa->oa_base = (caddr_t) mem_alloc(oa->oa_length); } buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); if (buf == NULL) { if (xdr_opaque(xdrs, oa->oa_base, oa->oa_length) == FALSE) { return (FALSE); } } else { bcopy((caddr_t)buf, oa->oa_base, oa->oa_length); /* no real need... buf += RNDUP(oa->oa_length) / sizeof (long); */ } } return (TRUE); } } if ( xdr_u_long(xdrs, &(cmsg->rm_xid)) && xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) && (cmsg->rm_direction == CALL) && xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) && (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) && xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) && xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)) && xdr_u_long(xdrs, &(cmsg->rm_call.cb_proc)) && xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) ) return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf))); return (FALSE); } ./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_raw.c100644 1676 334 10103 5262760651 13534 0ustar hjlisl/* @(#)svc_raw.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[] = "@(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro"; #endif /* * svc_raw.c, This a toy for simple testing and timing. * Interface to create an rpc client and server in the same UNIX process. * This lets us similate rpc and get rpc (round trip) overhead, without * any interference from the kernal. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #ifdef __STDC__ #include #endif /* * This is the "network" that we will be moving data over */ static struct svcraw_private { char _raw_buf[UDPMSGSIZE]; SVCXPRT server; XDR xdr_stream; char verf_body[MAX_AUTH_BYTES]; } *svcraw_private; static bool_t svcraw_recv(); static enum xprt_stat svcraw_stat(); static bool_t svcraw_getargs(); static bool_t svcraw_reply(); static bool_t svcraw_freeargs(); static void svcraw_destroy(); static struct xp_ops server_ops = { svcraw_recv, svcraw_stat, svcraw_getargs, svcraw_reply, svcraw_freeargs, svcraw_destroy }; SVCXPRT * svcraw_create() { register struct svcraw_private *srp = svcraw_private; if (srp == 0) { srp = (struct svcraw_private *)calloc(1, sizeof (*srp)); if (srp == 0) return (0); } srp->server.xp_sock = 0; srp->server.xp_port = 0; srp->server.xp_ops = &server_ops; srp->server.xp_verf.oa_base = srp->verf_body; xdrmem_create(&srp->xdr_stream, srp->_raw_buf, UDPMSGSIZE, XDR_FREE); return (&srp->server); } static enum xprt_stat svcraw_stat() { return (XPRT_IDLE); } static bool_t svcraw_recv(xprt, msg) SVCXPRT *xprt; struct rpc_msg *msg; { register struct svcraw_private *srp = svcraw_private; register XDR *xdrs; if (srp == 0) return (0); xdrs = &srp->xdr_stream; xdrs->x_op = XDR_DECODE; XDR_SETPOS(xdrs, 0); if (! xdr_callmsg(xdrs, msg)) return (FALSE); return (TRUE); } static bool_t svcraw_reply(xprt, msg) SVCXPRT *xprt; struct rpc_msg *msg; { register struct svcraw_private *srp = svcraw_private; register XDR *xdrs; if (srp == 0) return (FALSE); xdrs = &srp->xdr_stream; xdrs->x_op = XDR_ENCODE; XDR_SETPOS(xdrs, 0); if (! xdr_replymsg(xdrs, msg)) return (FALSE); (void)XDR_GETPOS(xdrs); /* called just for overhead */ return (TRUE); } static bool_t svcraw_getargs(xprt, xdr_args, args_ptr) SVCXPRT *xprt; xdrproc_t xdr_args; caddr_t args_ptr; { register struct svcraw_private *srp = svcraw_private; if (srp == 0) return (FALSE); return ((*xdr_args)(&srp->xdr_stream, args_ptr)); } static bool_t svcraw_freeargs(xprt, xdr_args, args_ptr) SVCXPRT *xprt; xdrproc_t xdr_args; caddr_t args_ptr; { register struct svcraw_private *srp = svcraw_private; register XDR *xdrs; if (srp == 0) return (FALSE); xdrs = &srp->xdr_stream; xdrs->x_op = XDR_FREE; return ((*xdr_args)(xdrs, args_ptr)); } static void svcraw_destroy() { } ./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/xdr_mem.c100644 1676 334 10260 5262760654 13532 0ustar hjlisl/* @(#)xdr_mem.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_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro"; #endif /* * xdr_mem.h, XDR implementation using memory buffers. * * Copyright (C) 1984, Sun Microsystems, Inc. * * If you have some data to be interpreted as external data representation * or to be converted to external data representation in a memory buffer, * then this is the package for you. * */ #include #include #include #include static bool_t xdrmem_getlong(); static bool_t xdrmem_putlong(); static bool_t xdrmem_getbytes(); static bool_t xdrmem_putbytes(); static u_int xdrmem_getpos(); static bool_t xdrmem_setpos(); static long * xdrmem_inline(); static void xdrmem_destroy(); static struct xdr_ops xdrmem_ops = { xdrmem_getlong, xdrmem_putlong, xdrmem_getbytes, xdrmem_putbytes, xdrmem_getpos, xdrmem_setpos, xdrmem_inline, xdrmem_destroy }; /* * The procedure xdrmem_create initializes a stream descriptor for a * memory buffer. */ void xdrmem_create(xdrs, addr, size, op) register XDR *xdrs; caddr_t addr; u_int size; enum xdr_op op; { xdrs->x_op = op; xdrs->x_ops = &xdrmem_ops; xdrs->x_private = xdrs->x_base = addr; xdrs->x_handy = size; } static void xdrmem_destroy(/*xdrs*/) /*XDR *xdrs;*/ { } static bool_t xdrmem_getlong(xdrs, lp) register XDR *xdrs; long *lp; { if ((xdrs->x_handy -= sizeof(long)) < 0) return (FALSE); *lp = (long)ntohl((u_long)(*((long *)(xdrs->x_private)))); xdrs->x_private += sizeof(long); return (TRUE); } static bool_t xdrmem_putlong(xdrs, lp) register XDR *xdrs; long *lp; { if ((xdrs->x_handy -= sizeof(long)) < 0) return (FALSE); *(long *)xdrs->x_private = (long)htonl((u_long)(*lp)); xdrs->x_private += sizeof(long); return (TRUE); } static bool_t xdrmem_getbytes(xdrs, addr, len) register XDR *xdrs; caddr_t addr; register u_int len; { if ((xdrs->x_handy -= len) < 0) return (FALSE); bcopy(xdrs->x_private, addr, len); xdrs->x_private += len; return (TRUE); } static bool_t xdrmem_putbytes(xdrs, addr, len) register XDR *xdrs; caddr_t addr; register u_int len; { if ((xdrs->x_handy -= len) < 0) return (FALSE); bcopy(addr, xdrs->x_private, len); xdrs->x_private += len; return (TRUE); } static u_int xdrmem_getpos(xdrs) register XDR *xdrs; { return ((u_int)xdrs->x_private - (u_int)xdrs->x_base); } static bool_t xdrmem_setpos(xdrs, pos) register XDR *xdrs; u_int pos; { register caddr_t newaddr = xdrs->x_base + pos; register caddr_t lastaddr = xdrs->x_private + xdrs->x_handy; if ((long)newaddr > (long)lastaddr) return (FALSE); xdrs->x_private = newaddr; xdrs->x_handy = (int)lastaddr - (int)newaddr; return (TRUE); } static long * xdrmem_inline(xdrs, len) register XDR *xdrs; int len; { long *buf = 0; if (xdrs->x_handy >= len) { xdrs->x_handy -= len; buf = (long *) xdrs->x_private; xdrs->x_private += len; } return (buf); } ./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/rpc_prot.c100644 1676 334 16075 5262760654 13741 0ustar hjlisl/* @(#)rpc_prot.c 2.3 88/08/07 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[] = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro"; #endif /* * rpc_prot.c * * Copyright (C) 1984, Sun Microsystems, Inc. * * This set of routines implements the rpc message definition, * its serializer and some common rpc utility routines. * The routines are meant for various implementations of rpc - * they are NOT for the rpc client or rpc service implementations! * Because authentication stuff is easy and is part of rpc, the opaque * routines are also in this program. */ #include #include /* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */ extern struct opaque_auth _null_auth; /* * XDR an opaque authentication struct * (see auth.h) */ bool_t xdr_opaque_auth(xdrs, ap) register XDR *xdrs; register struct opaque_auth *ap; { if (xdr_enum(xdrs, &(ap->oa_flavor))) return (xdr_bytes(xdrs, &ap->oa_base, &ap->oa_length, MAX_AUTH_BYTES)); return (FALSE); } /* * XDR a DES block */ bool_t xdr_des_block(xdrs, blkp) register XDR *xdrs; register des_block *blkp; { return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof(des_block))); } /* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */ /* * XDR the MSG_ACCEPTED part of a reply message union */ bool_t xdr_accepted_reply(xdrs, ar) register XDR *xdrs; register struct accepted_reply *ar; { /* personalized union, rather than calling xdr_union */ if (! xdr_opaque_auth(xdrs, &(ar->ar_verf))) return (FALSE); if (! xdr_enum(xdrs, (enum_t *)&(ar->ar_stat))) return (FALSE); switch (ar->ar_stat) { case SUCCESS: return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where)); case PROG_MISMATCH: if (! xdr_u_long(xdrs, &(ar->ar_vers.low))) return (FALSE); return (xdr_u_long(xdrs, &(ar->ar_vers.high))); } return (TRUE); /* TRUE => open ended set of problems */ } /* * XDR the MSG_DENIED part of a reply message union */ bool_t xdr_rejected_reply(xdrs, rr) register XDR *xdrs; register struct rejected_reply *rr; { /* personalized union, rather than calling xdr_union */ if (! xdr_enum(xdrs, (enum_t *)&(rr->rj_stat))) return (FALSE); switch (rr->rj_stat) { case RPC_MISMATCH: if (! xdr_u_long(xdrs, &(rr->rj_vers.low))) return (FALSE); return (xdr_u_long(xdrs, &(rr->rj_vers.high))); case AUTH_ERROR: return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why))); } return (FALSE); } static struct xdr_discrim reply_dscrm[3] = { { (int)MSG_ACCEPTED, xdr_accepted_reply }, { (int)MSG_DENIED, xdr_rejected_reply }, { __dontcare__, NULL_xdrproc_t } }; /* * XDR a reply message */ bool_t xdr_replymsg(xdrs, rmsg) register XDR *xdrs; register struct rpc_msg *rmsg; { if ( xdr_u_long(xdrs, &(rmsg->rm_xid)) && xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)) && (rmsg->rm_direction == REPLY) ) return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat), (caddr_t)&(rmsg->rm_reply.ru), reply_dscrm, NULL_xdrproc_t)); return (FALSE); } /* * Serializes the "static part" of a call message header. * The fields include: rm_xid, rm_direction, rpcvers, prog, and vers. * The rm_xid is not really static, but the user can easily munge on the fly. */ bool_t xdr_callhdr(xdrs, cmsg) register XDR *xdrs; register struct rpc_msg *cmsg; { cmsg->rm_direction = CALL; cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION; if ( (xdrs->x_op == XDR_ENCODE) && xdr_u_long(xdrs, &(cmsg->rm_xid)) && xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) && xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) && xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) ) return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers))); return (FALSE); } /* ************************** Client utility routine ************* */ static void accepted(acpt_stat, error) register enum accept_stat acpt_stat; register struct rpc_err *error; { switch (acpt_stat) { case PROG_UNAVAIL: error->re_status = RPC_PROGUNAVAIL; return; case PROG_MISMATCH: error->re_status = RPC_PROGVERSMISMATCH; return; case PROC_UNAVAIL: error->re_status = RPC_PROCUNAVAIL; return; case GARBAGE_ARGS: error->re_status = RPC_CANTDECODEARGS; return; case SYSTEM_ERR: error->re_status = RPC_SYSTEMERROR; return; case SUCCESS: error->re_status = RPC_SUCCESS; return; } /* something's wrong, but we don't know what ... */ error->re_status = RPC_FAILED; error->re_lb.s1 = (long)MSG_ACCEPTED; error->re_lb.s2 = (long)acpt_stat; } static void rejected(rjct_stat, error) register enum reject_stat rjct_stat; register struct rpc_err *error; { switch (rjct_stat) { case RPC_MISMATCH: error->re_status = RPC_VERSMISMATCH; return; case AUTH_ERROR: error->re_status = RPC_AUTHERROR; return; } /* something's wrong, but we don't know what ... */ error->re_status = RPC_FAILED; error->re_lb.s1 = (long)MSG_DENIED; error->re_lb.s2 = (long)rjct_stat; } /* * given a reply message, fills in the error */ void _seterr_reply(msg, error) register struct rpc_msg *msg; register struct rpc_err *error; { /* optimized for normal, SUCCESSful case */ switch (msg->rm_reply.rp_stat) { case MSG_ACCEPTED: if (msg->acpted_rply.ar_stat == SUCCESS) { error->re_status = RPC_SUCCESS; return; }; accepted(msg->acpted_rply.ar_stat, error); break; case MSG_DENIED: rejected(msg->rjcted_rply.rj_stat, error); break; default: error->re_status = RPC_FAILED; error->re_lb.s1 = (long)(msg->rm_reply.rp_stat); break; } switch (error->re_status) { case RPC_VERSMISMATCH: error->re_vers.low = msg->rjcted_rply.rj_vers.low; error->re_vers.high = msg->rjcted_rply.rj_vers.high; break; case RPC_AUTHERROR: error->re_why = msg->rjcted_rply.rj_why; break; case RPC_PROGVERSMISMATCH: error->re_vers.low = msg->acpted_rply.ar_vers.low; error->re_vers.high = msg->acpted_rply.ar_vers.high; break; } } ./libc-linux/rpc/xdr_float.c100644 1676 334 15776 5350274456 14100 0ustar hjlisl/* @(#)xdr_float.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_float.c 1.12 87/08/11 Copyr 1984 Sun Micro"; #endif /* * xdr_float.c, Generic XDR routines impelmentation. * * Copyright (C) 1984, Sun Microsystems, Inc. * * These are the "floating point" xdr routines used to (de)serialize * most common data items. See xdr.h for more info on the interface to * xdr. */ #include #include #include /* * NB: Not portable. * This routine works on Suns (Sky / 68000's), i386's and Vaxen. */ #if defined(mc68000) || defined(sparc) #define IEEEFP #define BIGENDIAN 1 #endif #if defined(i386) #define IEEEFP #define BIGENDIAN 0 #endif #ifdef vax /* What IEEE single precision floating point looks like on a Vax */ struct ieee_single { unsigned int mantissa: 23; unsigned int exp : 8; unsigned int sign : 1; }; /* Vax single precision floating point */ struct vax_single { unsigned int mantissa1 : 7; unsigned int exp : 8; unsigned int sign : 1; unsigned int mantissa2 : 16; }; #define VAX_SNG_BIAS 0x81 #define IEEE_SNG_BIAS 0x7f static struct sgl_limits { struct vax_single s; struct ieee_single ieee; } sgl_limits[2] = { {{ 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */ { 0x0, 0xff, 0x0 }}, /* Max IEEE */ {{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */ { 0x0, 0x0, 0x0 }} /* Min IEEE */ }; #endif /* vax */ bool_t xdr_float(xdrs, fp) register XDR *xdrs; register float *fp; { #ifndef IEEEFP struct ieee_single is; struct vax_single vs, *vsp; struct sgl_limits *lim; int i; #endif switch (xdrs->x_op) { case XDR_ENCODE: #ifdef IEEEFP return (XDR_PUTLONG(xdrs, (long *)fp)); #else vs = *((struct vax_single *)fp); for (i = 0, lim = sgl_limits; i < sizeof(sgl_limits)/sizeof(struct sgl_limits); i++, lim++) { if ((vs.mantissa2 == lim->s.mantissa2) && (vs.exp == lim->s.exp) && (vs.mantissa1 == lim->s.mantissa1)) { is = lim->ieee; goto shipit; } } is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS; is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2; shipit: is.sign = vs.sign; return (XDR_PUTLONG(xdrs, (long *)&is)); #endif case XDR_DECODE: #ifdef IEEEFP return (XDR_GETLONG(xdrs, (long *)fp)); #else vsp = (struct vax_single *)fp; if (!XDR_GETLONG(xdrs, (long *)&is)) return (FALSE); for (i = 0, lim = sgl_limits; i < sizeof(sgl_limits)/sizeof(struct sgl_limits); i++, lim++) { if ((is.exp == lim->ieee.exp) && (is.mantissa == lim->ieee.mantissa)) { *vsp = lim->s; goto doneit; } } vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS; vsp->mantissa2 = is.mantissa; vsp->mantissa1 = (is.mantissa >> 16); doneit: vsp->sign = is.sign; return (TRUE); #endif case XDR_FREE: return (TRUE); } return (FALSE); } /* * This routine works on Suns (Sky / 68000's), i386's and Vaxen. */ #ifdef vax /* What IEEE double precision floating point looks like on a Vax */ struct ieee_double { unsigned int mantissa1 : 20; unsigned int exp : 11; unsigned int sign : 1; unsigned int mantissa2 : 32; }; /* Vax double precision floating point */ struct vax_double { unsigned int mantissa1 : 7; unsigned int exp : 8; unsigned int sign : 1; unsigned int mantissa2 : 16; unsigned int mantissa3 : 16; unsigned int mantissa4 : 16; }; #define VAX_DBL_BIAS 0x81 #define IEEE_DBL_BIAS 0x3ff #define MASK(nbits) ((1 << nbits) - 1) static struct dbl_limits { struct vax_double d; struct ieee_double ieee; } dbl_limits[2] = { {{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff }, /* Max Vax */ { 0x0, 0x7ff, 0x0, 0x0 }}, /* Max IEEE */ {{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */ { 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */ }; #endif /* vax */ bool_t xdr_double(xdrs, dp) register XDR *xdrs; double *dp; { register long *lp; #ifndef IEEEFP struct ieee_double id; struct vax_double vd; register struct dbl_limits *lim; int i; #endif switch (xdrs->x_op) { case XDR_ENCODE: #ifdef IEEEFP lp = (long *)dp; #if BIGENDIAN return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp)); #else return (XDR_PUTLONG(xdrs, lp+1) && XDR_PUTLONG(xdrs, lp)); #endif #else vd = *((struct vax_double *)dp); for (i = 0, lim = dbl_limits; i < sizeof(dbl_limits)/sizeof(struct dbl_limits); i++, lim++) { if ((vd.mantissa4 == lim->d.mantissa4) && (vd.mantissa3 == lim->d.mantissa3) && (vd.mantissa2 == lim->d.mantissa2) && (vd.mantissa1 == lim->d.mantissa1) && (vd.exp == lim->d.exp)) { id = lim->ieee; goto shipit; } } id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS; id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3); id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) | (vd.mantissa3 << 13) | ((vd.mantissa4 >> 3) & MASK(13)); shipit: id.sign = vd.sign; lp = (long *)&id; return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp)); #endif case XDR_DECODE: #ifdef IEEEFP lp = (long *)dp; #if BIGENDIAN return (XDR_GETLONG(xdrs, lp++) && XDR_GETLONG(xdrs, lp)); #else return (XDR_GETLONG(xdrs, lp+1) && XDR_GETLONG(xdrs, lp)); #endif #else lp = (long *)&id; if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp)) return (FALSE); for (i = 0, lim = dbl_limits; i < sizeof(dbl_limits)/sizeof(struct dbl_limits); i++, lim++) { if ((id.mantissa2 == lim->ieee.mantissa2) && (id.mantissa1 == lim->ieee.mantissa1) && (id.exp == lim->ieee.exp)) { vd = lim->d; goto doneit; } } vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS; vd.mantissa1 = (id.mantissa1 >> 13); vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) | (id.mantissa2 >> 29); vd.mantissa3 = (id.mantissa2 >> 13); vd.mantissa4 = (id.mantissa2 << 3); doneit: vd.sign = id.sign; *dp = *((double *)&vd); return (TRUE); #endif case XDR_FREE: return (TRUE); } return (FALSE); } ./libc-linux/rpc/svc.c100644 1676 334 26430 5320151114 12654 0ustar hjlisl/* @(#)svc.c 2.4 88/08/11 4.0 RPCSRC; from 1.44 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.c 1.41 87/10/13 Copyr 1984 Sun Micro"; #endif /* * svc.c, Server-side remote procedure call interface. * * There are two sets of procedures here. The xprt routines are * for handling transport handles. The svc routines handle the * list of service routines. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include #ifdef linux #include #include #else extern int errno; #endif #ifdef __STDC__ #include #endif #ifdef FD_SETSIZE static SVCXPRT **xports; #else #define NOFILE 32 static SVCXPRT *xports[NOFILE]; #endif /* def FD_SETSIZE */ #define NULL_SVC ((struct svc_callout *)0) #define RQCRED_SIZE 400 /* this size is excessive */ /* * The services list * Each entry represents a set of procedures (an rpc program). * The dispatch routine takes request structs and runs the * apropriate procedure. */ static struct svc_callout { struct svc_callout *sc_next; u_long sc_prog; u_long sc_vers; void (*sc_dispatch)(); } *svc_head; static struct svc_callout *svc_find(); /* *************** SVCXPRT related stuff **************** */ /* * Activate a transport handle. */ void xprt_register(xprt) SVCXPRT *xprt; { register int sock = xprt->xp_sock; #ifdef FD_SETSIZE if (xports == NULL) { xports = (SVCXPRT **) mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *)); } if (sock < _rpc_dtablesize()) { xports[sock] = xprt; FD_SET(sock, &svc_fdset); } #else if (sock < NOFILE) { xports[sock] = xprt; svc_fds |= (1 << sock); } #endif /* def FD_SETSIZE */ } /* * De-activate a transport handle. */ void xprt_unregister(xprt) SVCXPRT *xprt; { register int sock = xprt->xp_sock; #ifdef FD_SETSIZE if ((sock < _rpc_dtablesize()) && (xports[sock] == xprt)) { xports[sock] = (SVCXPRT *)0; FD_CLR(sock, &svc_fdset); } #else if ((sock < NOFILE) && (xports[sock] == xprt)) { xports[sock] = (SVCXPRT *)0; svc_fds &= ~(1 << sock); } #endif /* def FD_SETSIZE */ } /* ********************** CALLOUT list related stuff ************* */ /* * Add a service program to the callout list. * The dispatch routine will be called when a rpc request for this * program number comes in. */ bool_t svc_register(xprt, prog, vers, dispatch, protocol) SVCXPRT *xprt; u_long prog; u_long vers; void (*dispatch)(); u_long protocol; { struct svc_callout *prev; register struct svc_callout *s; if ((s = svc_find(prog, vers, &prev)) != NULL_SVC) { if (s->sc_dispatch == dispatch) goto pmap_it; /* he is registering another xptr */ return (FALSE); } s = (struct svc_callout *)mem_alloc(sizeof(struct svc_callout)); if (s == (struct svc_callout *)0) { return (FALSE); } s->sc_prog = prog; s->sc_vers = vers; s->sc_dispatch = dispatch; s->sc_next = svc_head; svc_head = s; pmap_it: /* now register the information with the local binder service */ if (protocol) { return (pmap_set(prog, vers, protocol, xprt->xp_port)); } return (TRUE); } /* * Remove a service program from the callout list. */ void svc_unregister(prog, vers) u_long prog; u_long vers; { struct svc_callout *prev; register struct svc_callout *s; if ((s = svc_find(prog, vers, &prev)) == NULL_SVC) return; if (prev == NULL_SVC) { svc_head = s->sc_next; } else { prev->sc_next = s->sc_next; } s->sc_next = NULL_SVC; mem_free((char *) s, (u_int) sizeof(struct svc_callout)); /* now unregister the information with the local binder service */ (void)pmap_unset(prog, vers); } /* * Search the callout list for a program number, return the callout * struct. */ static struct svc_callout * svc_find(prog, vers, prev) u_long prog; u_long vers; struct svc_callout **prev; { register struct svc_callout *s, *p; p = NULL_SVC; for (s = svc_head; s != NULL_SVC; s = s->sc_next) { if ((s->sc_prog == prog) && (s->sc_vers == vers)) goto done; p = s; } done: *prev = p; return (s); } /* ******************* REPLY GENERATION ROUTINES ************ */ /* * Send a reply to an rpc request */ bool_t svc_sendreply(xprt, xdr_results, xdr_location) register SVCXPRT *xprt; xdrproc_t xdr_results; caddr_t xdr_location; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = SUCCESS; rply.acpted_rply.ar_results.where = xdr_location; rply.acpted_rply.ar_results.proc = xdr_results; return (SVC_REPLY(xprt, &rply)); } /* * No procedure error reply */ void svcerr_noproc(xprt) register SVCXPRT *xprt; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = PROC_UNAVAIL; SVC_REPLY(xprt, &rply); } /* * Can't decode args error reply */ void svcerr_decode(xprt) register SVCXPRT *xprt; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = GARBAGE_ARGS; SVC_REPLY(xprt, &rply); } /* * Some system error */ void svcerr_systemerr(xprt) register SVCXPRT *xprt; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = SYSTEM_ERR; SVC_REPLY(xprt, &rply); } /* * Authentication error reply */ void svcerr_auth(xprt, why) SVCXPRT *xprt; enum auth_stat why; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_DENIED; rply.rjcted_rply.rj_stat = AUTH_ERROR; rply.rjcted_rply.rj_why = why; SVC_REPLY(xprt, &rply); } /* * Auth too weak error reply */ void svcerr_weakauth(xprt) SVCXPRT *xprt; { svcerr_auth(xprt, AUTH_TOOWEAK); } /* * Program unavailable error reply */ void svcerr_noprog(xprt) register SVCXPRT *xprt; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = PROG_UNAVAIL; SVC_REPLY(xprt, &rply); } /* * Program version mismatch error reply */ void svcerr_progvers(xprt, low_vers, high_vers) register SVCXPRT *xprt; u_long low_vers; u_long high_vers; { struct rpc_msg rply; rply.rm_direction = REPLY; rply.rm_reply.rp_stat = MSG_ACCEPTED; rply.acpted_rply.ar_verf = xprt->xp_verf; rply.acpted_rply.ar_stat = PROG_MISMATCH; rply.acpted_rply.ar_vers.low = low_vers; rply.acpted_rply.ar_vers.high = high_vers; SVC_REPLY(xprt, &rply); } /* ******************* SERVER INPUT STUFF ******************* */ /* * Get server side input from some transport. * * Statement of authentication parameters management: * This function owns and manages all authentication parameters, specifically * the "raw" parameters (msg.rm_call.cb_cred and msg.rm_call.cb_verf) and * the "cooked" credentials (rqst->rq_clntcred). * However, this function does not know the structure of the cooked * credentials, so it make the following assumptions: * a) the structure is contiguous (no pointers), and * b) the cred structure size does not exceed RQCRED_SIZE bytes. * In all events, all three parameters are freed upon exit from this routine. * The storage is trivially management on the call stack in user land, but * is mallocated in kernel land. */ void svc_getreq(rdfds) int rdfds; { #ifdef FD_SETSIZE fd_set readfds; FD_ZERO(&readfds); readfds.fds_bits[0] = rdfds; svc_getreqset(&readfds); #else int readfds = rdfds & svc_fds; svc_getreqset(&readfds); #endif /* def FD_SETSIZE */ } void svc_getreqset(readfds) #ifdef FD_SETSIZE fd_set *readfds; { #else int *readfds; { int readfds_local = *readfds; #endif /* def FD_SETSIZE */ enum xprt_stat stat; struct rpc_msg msg; int prog_found; u_long low_vers; u_long high_vers; struct svc_req r; register SVCXPRT *xprt; register u_long mask; register int bit; register u_long *maskp; register int setsize; register int sock; char cred_area[2*MAX_AUTH_BYTES + RQCRED_SIZE]; msg.rm_call.cb_cred.oa_base = cred_area; msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]); r.rq_clntcred = &(cred_area[2*MAX_AUTH_BYTES]); #ifdef FD_SETSIZE setsize = _rpc_dtablesize(); maskp = (u_long *)readfds->fds_bits; for (sock = 0; sock < setsize; sock += NFDBITS) { for (mask = *maskp++; bit = ffs(mask); mask ^= (1 << (bit - 1))) { /* sock has input waiting */ xprt = xports[sock + bit - 1]; #else for (sock = 0; readfds_local != 0; sock++, readfds_local >>= 1) { if ((readfds_local & 1) != 0) { /* sock has input waiting */ xprt = xports[sock]; #endif /* def FD_SETSIZE */ /* now receive msgs from xprtprt (support batch calls) */ do { if (SVC_RECV(xprt, &msg)) { /* now find the exported program and call it */ register struct svc_callout *s; enum auth_stat why; r.rq_xprt = xprt; r.rq_prog = msg.rm_call.cb_prog; r.rq_vers = msg.rm_call.cb_vers; r.rq_proc = msg.rm_call.cb_proc; r.rq_cred = msg.rm_call.cb_cred; /* first authenticate the message */ if ((why= _authenticate(&r, &msg)) != AUTH_OK) { svcerr_auth(xprt, why); goto call_done; } /* now match message with a registered service*/ prog_found = FALSE; low_vers = 0 - 1; high_vers = 0; for (s = svc_head; s != NULL_SVC; s = s->sc_next) { if (s->sc_prog == r.rq_prog) { if (s->sc_vers == r.rq_vers) { (*s->sc_dispatch)(&r, xprt); goto call_done; } /* found correct version */ prog_found = TRUE; if (s->sc_vers < low_vers) low_vers = s->sc_vers; if (s->sc_vers > high_vers) high_vers = s->sc_vers; } /* found correct program */ } /* * if we got here, the program or version * is not served ... */ if (prog_found) svcerr_progvers(xprt, low_vers, high_vers); else svcerr_noprog(xprt); /* Fall through to ... */ } call_done: if ((stat = SVC_STAT(xprt)) == XPRT_DIED){ SVC_DESTROY(xprt); break; } } while (stat == XPRT_MOREREQS); } } } ./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/getrpcport.c100644 1676 334 3706 5303100615 14234 0ustar hjlisl/* @(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC */ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI"; #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 */ /* * Copyright (c) 1985 by Sun Microsystems, Inc. */ #include #include #include #include #include #include int getrpcport(host, prognum, versnum, proto) u_long prognum; u_long versnum; u_int proto; char *host; { struct sockaddr_in addr; struct hostent *hp; if ((hp = gethostbyname(host)) == NULL) return (0); bcopy(hp->h_addr, (char *) &addr.sin_addr, hp->h_length); addr.sin_family = AF_INET; addr.sin_port = 0; return (pmap_getport(&addr, prognum, versnum, proto)); } ./libc-linux/rpc/pmap_prot.c100644 1676 334 3527 5262760663 14070 0ustar hjlisl/* @(#)pmap_prot.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[] = "@(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro"; #endif /* * pmap_prot.c * Protocol for the local binder service, or pmap. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include bool_t xdr_pmap(xdrs, regs) XDR *xdrs; struct pmap *regs; { if (xdr_u_long(xdrs, ®s->pm_prog) && xdr_u_long(xdrs, ®s->pm_vers) && xdr_u_long(xdrs, ®s->pm_prot)) return (xdr_u_long(xdrs, ®s->pm_port)); return (FALSE); } ./libc-linux/rpc/clnt_generic.c100644 1676 334 6431 5270376031 14507 0ustar hjlisl/* @(#)clnt_generic.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_generic.c 1.4 87/08/11 (C) 1987 SMI"; #endif /* * Copyright (C) 1987, Sun Microsystems, Inc. */ #include #include #include #include #include /* * Generic client creation: takes (hostname, program-number, protocol) and * returns client handle. Default options are set, which the user can * change using the rpc equivalent of ioctl()'s. */ CLIENT * clnt_create(hostname, prog, vers, proto) char *hostname; unsigned long prog; unsigned long vers; char *proto; { struct hostent *h; struct protoent *p; struct sockaddr_in sin; int sock; struct timeval tv; CLIENT *client; h = gethostbyname(hostname); if (h == NULL) { rpc_createerr.cf_stat = RPC_UNKNOWNHOST; return (NULL); } if (h->h_addrtype != AF_INET) { /* * Only support INET for now */ rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = EAFNOSUPPORT; return (NULL); } #ifdef linux bzero((char *) &sin, sizeof(sin)); #endif sin.sin_family = h->h_addrtype; sin.sin_port = 0; #ifndef linux bzero(sin.sin_zero, sizeof(sin.sin_zero)); #endif bcopy(h->h_addr, (char*)&sin.sin_addr, h->h_length); p = getprotobyname(proto); if (p == NULL) { rpc_createerr.cf_stat = RPC_UNKNOWNPROTO; rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; return (NULL); } sock = RPC_ANYSOCK; switch (p->p_proto) { case IPPROTO_UDP: tv.tv_sec = 5; tv.tv_usec = 0; client = clntudp_create(&sin, prog, vers, tv, &sock); if (client == NULL) { return (NULL); } tv.tv_sec = 25; clnt_control(client, CLSET_TIMEOUT, &tv); break; case IPPROTO_TCP: client = clnttcp_create(&sin, prog, vers, &sock, 0, 0); if (client == NULL) { return (NULL); } tv.tv_sec = 25; tv.tv_usec = 0; clnt_control(client, CLSET_TIMEOUT, &tv); break; default: rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = EPFNOSUPPORT; return (NULL); } return (client); } ./libc-linux/rpc/xdr_stdio.c100644 1676 334 11226 5262760663 14101 0ustar hjlisl/* @(#)xdr_stdio.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_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro"; #endif /* * xdr_stdio.c, XDR implementation on standard i/o file. * * Copyright (C) 1984, Sun Microsystems, Inc. * * This set of routines implements a XDR on a stdio stream. * XDR_ENCODE serializes onto the stream, XDR_DECODE de-serializes * from the stream. */ #include #include #include #include static bool_t xdrstdio_getlong(); static bool_t xdrstdio_putlong(); static bool_t xdrstdio_getbytes(); static bool_t xdrstdio_putbytes(); static u_int xdrstdio_getpos(); static bool_t xdrstdio_setpos(); static long * xdrstdio_inline(); static void xdrstdio_destroy(); /* * Ops vector for stdio type XDR */ static struct xdr_ops xdrstdio_ops = { xdrstdio_getlong, /* deseraialize a long int */ xdrstdio_putlong, /* seraialize a long int */ xdrstdio_getbytes, /* deserialize counted bytes */ xdrstdio_putbytes, /* serialize counted bytes */ xdrstdio_getpos, /* get offset in the stream */ xdrstdio_setpos, /* set offset in the stream */ xdrstdio_inline, /* prime stream for inline macros */ xdrstdio_destroy /* destroy stream */ }; /* * Initialize a stdio xdr stream. * Sets the xdr stream handle xdrs for use on the stream file. * Operation flag is set to op. */ void xdrstdio_create(xdrs, file, op) register XDR *xdrs; FILE *file; enum xdr_op op; { xdrs->x_op = op; xdrs->x_ops = &xdrstdio_ops; xdrs->x_private = (caddr_t)file; xdrs->x_handy = 0; xdrs->x_base = 0; } /* * Destroy a stdio xdr stream. * Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create. */ static void xdrstdio_destroy(xdrs) register XDR *xdrs; { (void)fflush((FILE *)xdrs->x_private); /* xx should we close the file ?? */ }; static bool_t xdrstdio_getlong(xdrs, lp) XDR *xdrs; register long *lp; { if (fread((caddr_t)lp, sizeof(long), 1, (FILE *)xdrs->x_private) != 1) return (FALSE); #ifndef mc68000 *lp = ntohl(*lp); #endif return (TRUE); } static bool_t xdrstdio_putlong(xdrs, lp) XDR *xdrs; long *lp; { #ifndef mc68000 long mycopy = htonl(*lp); lp = &mycopy; #endif if (fwrite((caddr_t)lp, sizeof(long), 1, (FILE *)xdrs->x_private) != 1) return (FALSE); return (TRUE); } static bool_t xdrstdio_getbytes(xdrs, addr, len) XDR *xdrs; caddr_t addr; u_int len; { if ((len != 0) && (fread(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1)) return (FALSE); return (TRUE); } static bool_t xdrstdio_putbytes(xdrs, addr, len) XDR *xdrs; caddr_t addr; u_int len; { if ((len != 0) && (fwrite(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1)) return (FALSE); return (TRUE); } static u_int xdrstdio_getpos(xdrs) XDR *xdrs; { return ((u_int) ftell((FILE *)xdrs->x_private)); } static bool_t xdrstdio_setpos(xdrs, pos) XDR *xdrs; u_int pos; { return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ? FALSE : TRUE); } static long * xdrstdio_inline(xdrs, len) XDR *xdrs; u_int len; { /* * Must do some work to implement this: must insure * enough data in the underlying stdio buffer, * that the buffer is aligned so that we can indirect through a * long *, and stuff this pointer in xdrs->x_buf. Doing * a fread or fwrite to a scratch buffer would defeat * most of the gains to be had here and require storage * management on this buffer, so we don't do this. */ return (NULL); } ./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/rpc/rpc_dtblsz.c100644 1676 334 3230 5303100616 14202 0ustar hjlisl/* @(#)rpc_dtablesize.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[] = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro"; #endif #include /* * Cache the result of getdtablesize(), so we don't have to do an * expensive system call every time. */ int _rpc_dtablesize() { static int size; if (size == 0) { size = getdtablesize(); } return (size); } ./libc-linux/rpc/auth_prot.c100644 1676 334 4637 5303100614 14053 0ustar hjlisl/* @(#)authunix_prot.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[] = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro"; #endif /* * authunix_prot.c * XDR for UNIX style authentication parameters for RPC * * Copyright (C) 1984, Sun Microsystems, Inc. */ #include #include #include #include /* * XDR for unix authentication parameters. */ bool_t xdr_authunix_parms(xdrs, p) register XDR *xdrs; register struct authunix_parms *p; { if (xdr_u_long(xdrs, &(p->aup_time)) && xdr_string(xdrs, &(p->aup_machname), MAX_MACHINE_NAME) && (sizeof (uid_t) == sizeof (short) ? xdr_short(xdrs, (short *) &(p->aup_uid)) : xdr_int(xdrs, (int *) &(p->aup_uid))) && (sizeof (gid_t) == sizeof (short) ? xdr_short(xdrs, (short *) &(p->aup_gid)) : xdr_int(xdrs, (int *) &(p->aup_gid))) && (sizeof (gid_t) == sizeof (short) ? xdr_array(xdrs, (caddr_t *)&(p->aup_gids), &(p->aup_len), NGRPS, sizeof (short), xdr_short) : xdr_array(xdrs, (caddr_t *)&(p->aup_gids), &(p->aup_len), NGRPS, sizeof (int), xdr_int))) { return (TRUE); } return (FALSE); } ./libc-linux/rpc/rpc_comdata.c100644 1676 334 3234 5362436267 14337 0ustar hjlisl/* @(#)rpc_commondata.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 */ #include /* * This file should only contain common data (global data) that is exported * by public interfaces */ #ifdef __linux__ fd_set svc_fdset = {0}; #else #ifdef FD_SETSIZE fd_set svc_fdset = 0; #else int svc_fds = 0; #endif /* def FD_SETSIZE */ #endif /* def __linux__*/ struct rpc_createerr rpc_createerr = {0}; struct opaque_auth _null_auth = {0}; ./libc-linux/rpc/pmap_rmt.c.orig100644 1676 334 32223 5473470637 14663 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 "../nls/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... */ { #ifdef linux 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(inet_netof (sin->sin_addr.s_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/inet/ 40755 1676 334 0 5550052026 11755 5ustar hjlisl./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/getnetbyad.c100644 1676 334 2406 5222266366 14360 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[] = "@(#)getnetbyaddr.c 5.6 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include extern int _net_stayopen; struct netent * getnetbyaddr(net, type) register int net; register int type; { register struct netent *p; setnetent(_net_stayopen); while (p = getnetent()) if (p->n_addrtype == type && p->n_net == net) break; if (!_net_stayopen) endnetent(); return (p); } ./libc-linux/inet/getnetbynm.c100644 1676 334 2532 5222402335 14372 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[] = "@(#)getnetbyname.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" extern int _net_stayopen; struct netent * getnetbyname(const char *name) { register struct netent *p; register char **cp; setnetent(_net_stayopen); while (p = getnetent()) { if (strcmp(p->n_name, name) == 0) break; for (cp = p->n_aliases; *cp != 0; cp++) if (strcmp(*cp, name) == 0) goto found; } found: if (!_net_stayopen) endnetent(); return (p); } ./libc-linux/inet/getnetent.c100644 1676 334 4654 5244012730 14222 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[] = "@(#)getnetent.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" #define MAXALIASES 35 static char NETDB[] = _PATH_NETWORKS; static FILE *netf = NULL; static char line[BUFSIZ+1]; static struct netent net; static char *net_aliases[MAXALIASES]; static char *any(char *, char *); int _net_stayopen; void setnetent(f) int f; { if (netf == NULL) netf = fopen(NETDB, "r" ); else rewind(netf); _net_stayopen |= f; } void endnetent() { if (netf) { fclose(netf); netf = NULL; } _net_stayopen = 0; } struct netent * getnetent() { char *p; register char *cp, **q; if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL) return (NULL); again: p = fgets(line, BUFSIZ, netf); if (p == NULL) return (NULL); if (*p == '#') goto again; cp = any(p, "#\n"); if (cp == NULL) goto again; *cp = '\0'; net.n_name = p; cp = any(p, " \t"); if (cp == NULL) goto again; *cp++ = '\0'; while (*cp == ' ' || *cp == '\t') cp++; p = any(cp, " \t"); if (p != NULL) *p++ = '\0'; net.n_net = inet_network(cp); net.n_addrtype = AF_INET; q = net.n_aliases = net_aliases; if (p != NULL) cp = p; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &net_aliases[MAXALIASES - 1]) *q++ = cp; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; } *q = NULL; return (&net); } static char * any(cp, match) register char *cp; char *match; { register char *mp, c; while (c = *cp) { for (mp = match; *mp; mp++) if (*mp == c) return (cp); cp++; } return ((char *)0); } ./libc-linux/inet/getproto.c100644 1676 334 2361 5222402414 14057 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[] = "@(#)getproto.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" extern int _proto_stayopen; struct protoent * getprotobynumber(proto) register int proto; { register struct protoent *p; setprotoent(_proto_stayopen); while (p = getprotoent()) if (p->p_proto == proto) break; if (!_proto_stayopen) endprotoent(); return (p); } ./libc-linux/inet/getprtent.c100644 1676 334 4725 5244012751 14243 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[] = "@(#)getprotoent.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" #define MAXALIASES 35 static char PROTODB[] = _PATH_PROTOCOLS; static FILE *protof = NULL; static char line[BUFSIZ+1]; static struct protoent proto; static char *proto_aliases[MAXALIASES]; static char *any(char *, char*); int _proto_stayopen; void setprotoent(f) int f; { if (protof == NULL) protof = fopen(PROTODB, "r" ); else rewind(protof); _proto_stayopen |= f; } void endprotoent() { if (protof) { fclose(protof); protof = NULL; } _proto_stayopen = 0; } struct protoent * getprotoent() { char *p; register char *cp, **q; if (protof == NULL && (protof = fopen(PROTODB, "r" )) == NULL) return (NULL); again: if ((p = fgets(line, BUFSIZ, protof)) == NULL) return (NULL); if (*p == '#') goto again; cp = any(p, "#\n"); if (cp == NULL) goto again; *cp = '\0'; proto.p_name = p; cp = any(p, " \t"); if (cp == NULL) goto again; *cp++ = '\0'; while (*cp == ' ' || *cp == '\t') cp++; p = any(cp, " \t"); if (p != NULL) *p++ = '\0'; proto.p_proto = atoi(cp); q = proto.p_aliases = proto_aliases; if (p != NULL) { cp = p; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &proto_aliases[MAXALIASES - 1]) *q++ = cp; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; } } *q = NULL; return (&proto); } static char * any(cp, match) register char *cp; char *match; { register char *mp, c; while (c = *cp) { for (mp = match; *mp; mp++) if (*mp == c) return (cp); cp++; } return ((char *)0); } ./libc-linux/inet/getprtname.c100644 1676 334 2554 5222402462 14371 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[] = "@(#)getprotoname.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" extern int _proto_stayopen; struct protoent * getprotobyname(const char *name) { register struct protoent *p; register char **cp; setprotoent(_proto_stayopen); while (p = getprotoent()) { if (strcmp(p->p_name, name) == 0) break; for (cp = p->p_aliases; *cp != 0; cp++) if (strcmp(*cp, name) == 0) goto found; } found: if (!_proto_stayopen) endprotoent(); return (p); } ./libc-linux/inet/getservent.c100644 1676 334 4754 5244012763 14422 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[] = "@(#)getservent.c 5.6 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" #define MAXALIASES 35 static char SERVDB[] = _PATH_SERVICES; static FILE *servf = NULL; static char line[BUFSIZ+1]; static struct servent serv; static char *serv_aliases[MAXALIASES]; static char *any(char *, char*); int _serv_stayopen; void setservent(f) int f; { if (servf == NULL) servf = fopen(SERVDB, "r" ); else rewind(servf); _serv_stayopen |= f; } void endservent() { if (servf) { fclose(servf); servf = NULL; } _serv_stayopen = 0; } struct servent * getservent() { char *p; register char *cp, **q; if (servf == NULL && (servf = fopen(SERVDB, "r" )) == NULL) return (NULL); again: if ((p = fgets(line, BUFSIZ, servf)) == NULL) return (NULL); if (*p == '#') goto again; cp = any(p, "#\n"); if (cp == NULL) goto again; *cp = '\0'; serv.s_name = p; p = any(p, " \t"); if (p == NULL) goto again; *p++ = '\0'; while (*p == ' ' || *p == '\t') p++; cp = any(p, ",/"); if (cp == NULL) goto again; *cp++ = '\0'; serv.s_port = htons((u_short)atoi(p)); serv.s_proto = cp; q = serv.s_aliases = serv_aliases; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; while (cp && *cp) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &serv_aliases[MAXALIASES - 1]) *q++ = cp; cp = any(cp, " \t"); if (cp != NULL) *cp++ = '\0'; } *q = NULL; return (&serv); } static char * any(cp, match) register char *cp; char *match; { register char *mp, c; while (c = *cp) { for (mp = match; *mp; mp++) if (*mp == c) return (cp); cp++; } return ((char *)0); } ./libc-linux/inet/getsrvbynm.c100644 1676 334 2707 5222402534 14423 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[] = "@(#)getservbyname.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" extern int _serv_stayopen; struct servent * getservbyname(const char *name, const char *proto) { register struct servent *p; register char **cp; setservent(_serv_stayopen); while (p = getservent()) { if (strcmp(name, p->s_name) == 0) goto gotname; for (cp = p->s_aliases; *cp; cp++) if (strcmp(name, *cp) == 0) goto gotname; continue; gotname: if (proto == 0 || strcmp(p->s_proto, proto) == 0) break; } if (!_serv_stayopen) endservent(); return (p); } ./libc-linux/inet/getsrvbypt.c100644 1676 334 2460 5222402552 14430 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[] = "@(#)getservbyport.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" extern int _serv_stayopen; struct servent * getservbyport(int port, const char *proto) { register struct servent *p; setservent(_serv_stayopen); while (p = getservent()) { if (p->s_port != port) continue; if (proto == 0 || strcmp(p->s_proto, proto) == 0) break; } if (!_serv_stayopen) endservent(); 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/Makefile100644 1676 334 1240 5515543750 13521 0ustar hjlisl# # This is Makefile of inet lib for Linux # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules ifeq ($(YP),true) VSCFLAGS=-DNIS endif INC_CFLAGS= -I. -I$(TOPDIR) BASE_CFLAGS := $(BASE_CFLAGS) $(VSCFLAGS) DIRS:= SRCS = gethstnmad.c getnetbyad.c getnetbynm.c getnetent.c \ getproto.c getprtent.c getprtname.c getservent.c \ getsrvbynm.c getsrvbypt.c herror.c inet_addr.c \ inet_lnaof.c inet_mkadr.c inet_net.c inet_netof.c \ inet_ntoa.c rcmd.c res_comp.c res_debug.c res_init.c \ res_mkqry.c res_query.c res_send.c rexec.c ruserpass.c \ sethostent.c bindresvport.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/inet/inet_addr.c100644 1676 334 5371 5352746643 14174 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[] = "@(#)inet_addr.c 5.6 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" /* * Internet address interpretation routine. * All the network library routines call this * routine to interpret entries in the data bases * which are expected to be an address. * The value returned is in network order. */ u_long inet_addr(const char *cp) { register u_long val, base, n; register char c; u_long parts[4], *pp = parts; again: /* * Collect number up to ``.''. * Values are specified as for C: * 0x=hex, 0=octal, other=decimal. */ val = 0; base = 10; if (*cp == '0') { if (*++cp == 'x' || *cp == 'X') base = 16, cp++; else base = 8; } while (c = *cp) { if (isdigit(c)) { val = (val * base) + (c - '0'); cp++; continue; } if (base == 16 && isxdigit(c)) { val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A')); cp++; continue; } break; } if (*cp == '.') { /* * Internet format: * a.b.c.d * a.b.c (with c treated as 16-bits) * a.b (with b treated as 24 bits) */ if (pp >= parts + 3) return (INADDR_NONE); *pp++ = val, cp++; goto again; } /* * Check for trailing characters. */ if ((*cp == '\0' && *(cp - 1) == '.') || (*cp && !isspace(*cp))) return (INADDR_NONE); *pp++ = val; /* * Concoct the address according to * the number of parts specified. */ n = pp - parts; switch (n) { case 1: /* a -- 32 bits */ val = parts[0]; break; case 2: /* a.b -- 8.24 bits */ val = (parts[0] << 24) | (parts[1] & 0xffffff); break; case 3: /* a.b.c -- 8.8.16 bits */ val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) | (parts[2] & 0xffff); break; case 4: /* a.b.c.d -- 8.8.8.8 bits */ val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) | ((parts[2] & 0xff) << 8) | (parts[3] & 0xff); break; default: return (INADDR_NONE); } val = htonl(val); return (val); } ./libc-linux/inet/inet_lnaof.c100644 1676 334 2501 5222403010 14317 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[] = "@(#)inet_lnaof.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" /* * Return the local network address portion of an * internet address; handles class a/b/c network * number formats. */ u_long inet_lnaof(in) struct in_addr in; { register u_long i = ntohl(in.s_addr); if (IN_CLASSA(i)) return ((i)&IN_CLASSA_HOST); else if (IN_CLASSB(i)) return ((i)&IN_CLASSB_HOST); else return ((i)&IN_CLASSC_HOST); } ./libc-linux/inet/inet_mkadr.c100644 1676 334 2753 5501703171 14342 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[] = "@(#)inet_makeaddr.c 5.3 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" /* * Formulate an Internet address from network + host. Used in * building addresses stored in the ifnet structure. */ struct in_addr inet_makeaddr(net_i, host) int net_i, host; { u_long net = (u_long) net_i; u_long addr; if (net < 128) addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST); else if (net < 65536) addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST); else addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST); addr = htonl(addr); return (*(struct in_addr *)&addr); } ./libc-linux/inet/inet_net.c100644 1676 334 7455 5500026051 14030 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[] = "@(#)inet_network.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" /* * Internet network address interpretation routine. * The library routines call this routine to interpret * network numbers. */ u_long inet_network(const char *cp) { register u_long val, base, n; register char c; u_long parts[4], *pp = parts; again: /* * Collect number up to ``.''. * Values are specified as for C: * 0x=hex, 0=octal, other=decimal. */ val = 0; base = 10; if (*cp == '0') { if (*++cp == 'x' || *cp == 'X') base = 16, cp++; else base = 8; } while (c = *cp) { if (isdigit(c)) { val = (val * base) + (c - '0'); cp++; continue; } if (base == 16 && isxdigit(c)) { val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A')); cp++; continue; } break; } if (*cp == '.') { /* * Internet format: * a.b.c.d * a.b.c (with c treated as 16-bits) * a.b (with b treated as 24 bits) * * For network format, it is * a.b.c.d (with each treated as 8-bits) * a.b.c (with each treated as 8-bits) * a.b (with each treated as 8 bits) * a (with a treated as 8 bits) * */ if (pp >= parts + 3) return (INADDR_NONE); *pp++ = val, cp++; goto again; } /* * Check for trailing characters. */ if ((*cp == '\0' && *(cp - 1) == '.') || (*cp && !isspace(*cp))) return (INADDR_NONE); *pp++ = val; /* * Concoct the address according to * the number of parts specified. */ n = pp - parts; switch (n) { #if 1 case 1: /* a -- 32 bits */ val = parts[0] & 0xff; break; case 2: /* a.b -- 24.8 bits */ val = ((parts[0] & 0xff) << 8) | (parts[1] & 0xff); break; case 3: /* a.b.c -- 16.8.8 bits */ val = ((parts[0] & 0xff) << 16) | ((parts[1] & 0xff) << 8) | (parts[2] & 0xff); break; case 4: /* a.b.c.d -- 8.8.8.8 bits */ val = ((parts[0] & 0xff) << 24) | ((parts[1] & 0xff) << 16) | ((parts[2] & 0xff) << 8) | (parts[3] & 0xff); break; #else case 1: /* a -- 32 bits */ val = parts[0]; break; case 2: /* a.b -- 8.24 bits */ val = (parts[0] << 24) | (parts[1] & 0xffffff); break; case 3: /* a.b.c -- 8.8.16 bits */ val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) | (parts[2] & 0xffff); break; case 4: /* a.b.c.d -- 8.8.8.8 bits */ val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) | ((parts[2] & 0xff) << 8) | (parts[3] & 0xff); break; #endif default: return (INADDR_NONE); } #if 0 /* I didn't get it. Why doesn't it mask out hostid? * I got it. It is for subnet. H.J. */ if (IN_CLASSA (val)) val &= IN_CLASSA_NET; else if (IN_CLASSB (val)) val &= IN_CLASSB_NET; else val &= IN_CLASSC_NET; #endif #if 0 /* We return the network number. */ if (IN_CLASSA(val)) return (((val)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); else if (IN_CLASSB(val)) return (((val)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT); else return (((val)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT); #endif return (val); } ./libc-linux/inet/inet_netof.c100644 1676 334 2545 5222403102 14345 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[] = "@(#)inet_netof.c 5.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" /* * Return the network number from an internet * address; handles class a/b/c network #'s. */ u_long inet_netof(in) struct in_addr in; { register u_long i = ntohl(in.s_addr); if (IN_CLASSA(i)) return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); else if (IN_CLASSB(i)) return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT); else return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT); } ./libc-linux/inet/inet_ntoa.c100644 1676 334 2417 5222403132 14174 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[] = "@(#)inet_ntoa.c 5.4 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ /* * Convert network-format internet address * to base 256 d.d.d.d representation. */ #include "inetprivate.h" char * inet_ntoa(in) struct in_addr in; { static char b[18]; register char *p; p = (char *)∈ #define UC(b) (((int)b)&0xff) sprintf(b, "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3])); return (b); } ./libc-linux/inet/inetprivate.h100644 1676 334 2634 5457045277 14602 0ustar hjlisl#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern void _sethtent(int f); extern void _endhtent(void); extern struct hostent *_gethtent(void); extern struct hostent *_gethtbyname(const char *name); extern struct hostent *_gethtbyaddr(const char *addr, int len, int type); extern int _validuser(FILE *hostf, const char *rhost, const char *luser, const char *ruser, int baselen); extern int _checkhost(const char *rhost, const char *lhost, int len); extern void putlong(u_long l, u_char *msgp); extern void putshort(u_short l, u_char *msgp); extern u_long _getlong(u_char *msgp); extern u_short _getshort(u_char *msgp); extern void p_query(char *msg); extern void fp_query(char *msg, FILE *file); extern char *p_cdname(char *cp, char *msg, FILE *file); extern char *p_rr(char *cp, char *msg, FILE *file); extern char *p_type(int type); extern char * p_class(int class); extern char *p_time(u_long value); extern char * hostalias(const char *name); extern void sethostfile(char *name); extern void _res_close (void); extern void ruserpass(const char *host, char **aname, char **apass); ./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/res_comp.c100644 1676 334 16167 5222452641 14063 0ustar hjlisl/* * Copyright (c) 1985 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_comp.c 6.18 (Berkeley) 6/27/90"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" static int dn_find(u_char *exp_dn, u_char *msg, u_char **dnptrs, u_char **lastdnptr); /* * Expand compressed domain name 'comp_dn' to full domain name. * 'msg' is a pointer to the begining of the message, * 'eomorig' points to the first location after the message, * 'exp_dn' is a pointer to a buffer of size 'length' for the result. * Return size of compressed name or -1 if there was an error. */ int dn_expand(u_char *msg, u_char *eomorig, u_char *comp_dn, u_char *exp_dn, int length) { register u_char *cp, *dn; register int n, c; u_char *eom; int len = -1, checked = 0; dn = exp_dn; cp = comp_dn; eom = exp_dn + length; /* * fetch next label in domain name */ while (n = *cp++) { /* * Check for indirection */ switch (n & INDIR_MASK) { case 0: if (dn != exp_dn) { if (dn >= eom) return (-1); *dn++ = '.'; } if (dn+n >= eom) return (-1); checked += n + 1; while (--n >= 0) { if ((c = *cp++) == '.') { if (dn + n + 2 >= eom) return (-1); *dn++ = '\\'; } *dn++ = c; if (cp >= eomorig) /* out of range */ return(-1); } break; case INDIR_MASK: if (len < 0) len = cp - comp_dn + 1; cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff)); if (cp < msg || cp >= eomorig) /* out of range */ return(-1); checked += 2; /* * Check for loops in the compressed name; * if we've looked at the whole message, * there must be a loop. */ if (checked >= eomorig - msg) return (-1); break; default: return (-1); /* flag error */ } } *dn = '\0'; if (len < 0) len = cp - comp_dn; return (len); } /* * Compress domain name 'exp_dn' into 'comp_dn'. * Return the size of the compressed name or -1. * 'length' is the size of the array pointed to by 'comp_dn'. * 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0] * is a pointer to the beginning of the message. The list ends with NULL. * 'lastdnptr' is a pointer to the end of the arrary pointed to * by 'dnptrs'. Side effect is to update the list of pointers for * labels inserted into the message as we compress the name. * If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr' * is NULL, we don't update the list. */ int dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr) u_char *exp_dn, *comp_dn; int length; u_char **dnptrs, **lastdnptr; { register u_char *cp, *dn; register int c, l; u_char **cpp, **lpp, *sp, *eob; u_char *msg; dn = exp_dn; cp = comp_dn; eob = cp + length; if (dnptrs != NULL) { if ((msg = *dnptrs++) != NULL) { for (cpp = dnptrs; *cpp != NULL; cpp++) ; lpp = cpp; /* end of list to search */ } } else msg = NULL; for (c = *dn++; c != '\0'; ) { /* look to see if we can use pointers */ if (msg != NULL) { if ((l = dn_find(dn-1, msg, dnptrs, lpp)) >= 0) { if (cp+1 >= eob) return (-1); *cp++ = (l >> 8) | INDIR_MASK; *cp++ = l % 256; return (cp - comp_dn); } /* not found, save it */ if (lastdnptr != NULL && cpp < lastdnptr-1) { *cpp++ = cp; *cpp = NULL; } } sp = cp++; /* save ptr to length byte */ do { if (c == '.') { c = *dn++; break; } if (c == '\\') { if ((c = *dn++) == '\0') break; } if (cp >= eob) { if (msg != NULL) *lpp = NULL; return (-1); } *cp++ = c; } while ((c = *dn++) != '\0'); /* catch trailing '.'s but not '..' */ if ((l = cp - sp - 1) == 0 && c == '\0') { cp--; break; } if (l <= 0 || l > MAXLABEL) { if (msg != NULL) *lpp = NULL; return (-1); } *sp = l; } if (cp >= eob) { if (msg != NULL) *lpp = NULL; return (-1); } *cp++ = '\0'; return (cp - comp_dn); } /* * Skip over a compressed domain name. Return the size or -1. */ int dn_skipname(u_char *comp_dn, u_char *eom) { register u_char *cp; register int n; cp = comp_dn; while (cp < eom && (n = *cp++)) { /* * check for indirection */ switch (n & INDIR_MASK) { case 0: /* normal case, n == len */ cp += n; continue; default: /* illegal type */ return (-1); case INDIR_MASK: /* indirection */ cp++; } break; } return (cp - comp_dn); } /* * Search for expanded name from a list of previously compressed names. * Return the offset from msg if found or -1. * dnptrs is the pointer to the first name on the list, * not the pointer to the start of the message. */ static int dn_find(u_char *exp_dn, u_char *msg, u_char **dnptrs, u_char **lastdnptr) { register u_char *dn, *cp, **cpp; register int n; u_char *sp; for (cpp = dnptrs; cpp < lastdnptr; cpp++) { dn = exp_dn; sp = cp = *cpp; while (n = *cp++) { /* * check for indirection */ switch (n & INDIR_MASK) { case 0: /* normal case, n == len */ while (--n >= 0) { if (*dn == '.') goto next; if (*dn == '\\') dn++; if (*dn++ != *cp++) goto next; } if ((n = *dn++) == '\0' && *cp == '\0') return (sp - msg); if (n == '.') continue; goto next; default: /* illegal type */ return (-1); case INDIR_MASK: /* indirection */ cp = msg + (((n & 0x3f) << 8) | *cp); } } if (*dn == '\0') return (sp - msg); next: ; } return (-1); } /* * Routines to insert/extract short/long's. Must account for byte * order and non-alignment problems. This code at least has the * advantage of being portable. * * used by sendmail. */ u_short _getshort(msgp) u_char *msgp; { register u_char *p = (u_char *) msgp; #ifdef vax /* * vax compiler doesn't put shorts in registers */ register u_long u; #else register u_short u; #endif u = *p++ << 8; return ((u_short)(u | *p)); } u_long _getlong(u_char *msgp) { register u_char *p = (u_char *) msgp; register u_long u; u = *p++; u <<= 8; u |= *p++; u <<= 8; u |= *p++; u <<= 8; return (u | *p); } void putshort(register u_short s, register u_char *msgp) { msgp[1] = s; msgp[0] = s >> 8; } void putlong(register u_long l, register u_char *msgp) { msgp[3] = l; msgp[2] = (l >>= 8); msgp[1] = (l >>= 8); msgp[0] = l >> 8; } ./libc-linux/inet/res_debug.c100644 1676 334 23750 5524037743 14216 0ustar hjlisl/*- * Copyright (c) 1985, 1990 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. * * @(#)res_debug.c 5.30 (Berkeley) 6/27/90 */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_debug.c 5.30 (Berkeley) 6/27/90"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" char *_res_opcodes[] = { "QUERY", "IQUERY", "CQUERYM", "CQUERYU", "4", "5", "6", "7", "8", "UPDATEA", "UPDATED", "UPDATEDA", "UPDATEM", "UPDATEMA", "ZONEINIT", "ZONEREF", }; char *_res_resultcodes[] = { "NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN", "NOTIMP", "REFUSED", "6", "7", "8", "9", "10", "11", "12", "13", "14", "NOCHANGE", }; void p_query(char *msg) { fp_query(msg,stdout); } /* * Print the contents of a query. * This is intended to be primarily a debugging routine. */ void fp_query(char *msg, FILE *file) { register char *cp; register HEADER *hp; register int n; /* * Print header fields. */ hp = (HEADER *)msg; cp = msg + sizeof(HEADER); fprintf(file,"HEADER:\n"); fprintf(file,"\topcode = %s", _res_opcodes[hp->opcode]); fprintf(file,", id = %d", ntohs(hp->id)); fprintf(file,", rcode = %s\n", _res_resultcodes[hp->rcode]); fprintf(file,"\theader flags: "); if (hp->qr) fprintf(file," qr"); if (hp->aa) fprintf(file," aa"); if (hp->tc) fprintf(file," tc"); if (hp->rd) fprintf(file," rd"); if (hp->ra) fprintf(file," ra"); if (hp->pr) fprintf(file," pr"); fprintf(file,"\n\tqdcount = %d", ntohs(hp->qdcount)); fprintf(file,", ancount = %d", ntohs(hp->ancount)); fprintf(file,", nscount = %d", ntohs(hp->nscount)); fprintf(file,", arcount = %d\n\n", ntohs(hp->arcount)); /* * Print question records. */ if (n = ntohs(hp->qdcount)) { fprintf(file,"QUESTIONS:\n"); while (--n >= 0) { fprintf(file,"\t"); cp = p_cdname(cp, msg, file); if (cp == NULL) return; fprintf(file,", type = %s", p_type(_getshort(cp))); cp += sizeof(u_short); fprintf(file,", class = %s\n\n", p_class(_getshort(cp))); cp += sizeof(u_short); } } /* * Print authoritative answer records */ if (n = ntohs(hp->ancount)) { fprintf(file,"ANSWERS:\n"); while (--n >= 0) { fprintf(file,"\t"); cp = p_rr(cp, msg, file); if (cp == NULL) return; } } /* * print name server records */ if (n = ntohs(hp->nscount)) { fprintf(file,"NAME SERVERS:\n"); while (--n >= 0) { fprintf(file,"\t"); cp = p_rr(cp, msg, file); if (cp == NULL) return; } } /* * print additional records */ if (n = ntohs(hp->arcount)) { fprintf(file,"ADDITIONAL RECORDS:\n"); while (--n >= 0) { fprintf(file,"\t"); cp = p_rr(cp, msg, file); if (cp == NULL) return; } } } char * p_cdname(char *cp, char *msg, FILE *file) { char name[MAXDNAME]; int n; if ((n = dn_expand(msg, msg + 512, cp, name, sizeof(name))) < 0) return (NULL); if (name[0] == '\0') { name[0] = '.'; name[1] = '\0'; } fputs(name, file); return (cp + n); } /* * Print resource record fields in human readable form. */ char * p_rr(char *cp, char *msg, FILE *file) { int type, class, dlen, n, c; struct in_addr inaddr; char *cp1, *cp2; if ((cp = p_cdname(cp, msg, file)) == NULL) return (NULL); /* compression error */ fprintf(file,"\n\ttype = %s", p_type(type = _getshort(cp))); cp += sizeof(u_short); fprintf(file,", class = %s", p_class(class = _getshort(cp))); cp += sizeof(u_short); fprintf(file,", ttl = %s", p_time(_getlong(cp))); cp += sizeof(u_long); fprintf(file,", dlen = %d\n", dlen = _getshort(cp)); cp += sizeof(u_short); cp1 = cp; /* * Print type specific data, if appropriate */ switch (type) { case T_A: switch (class) { case C_IN: case C_HS: bcopy(cp, (char *)&inaddr, sizeof(inaddr)); if (dlen == 4) { fprintf(file,"\tinternet address = %s\n", inet_ntoa(inaddr)); cp += dlen; } else if (dlen == 7) { fprintf(file,"\tinternet address = %s", inet_ntoa(inaddr)); fprintf(file,", protocol = %d", cp[4]); fprintf(file,", port = %d\n", (cp[5] << 8) + cp[6]); cp += dlen; } break; default: cp += dlen; } break; case T_CNAME: case T_MB: case T_MG: case T_MR: case T_NS: case T_PTR: fprintf(file,"\tdomain name = "); cp = p_cdname(cp, msg, file); fprintf(file,"\n"); break; case T_HINFO: if (n = *cp++) { fprintf(file,"\tCPU=%.*s\n", n, cp); cp += n; } if (n = *cp++) { fprintf(file,"\tOS=%.*s\n", n, cp); cp += n; } break; case T_SOA: fprintf(file,"\torigin = "); cp = p_cdname(cp, msg, file); fprintf(file,"\n\tmail addr = "); cp = p_cdname(cp, msg, file); fprintf(file,"\n\tserial = %ld", _getlong(cp)); cp += sizeof(u_long); fprintf(file,"\n\trefresh = %s", p_time(_getlong(cp))); cp += sizeof(u_long); fprintf(file,"\n\tretry = %s", p_time(_getlong(cp))); cp += sizeof(u_long); fprintf(file,"\n\texpire = %s", p_time(_getlong(cp))); cp += sizeof(u_long); fprintf(file,"\n\tmin = %s\n", p_time(_getlong(cp))); cp += sizeof(u_long); break; case T_MX: fprintf(file,"\tpreference = %ld,",_getshort(cp)); cp += sizeof(u_short); fprintf(file," name = "); cp = p_cdname(cp, msg, file); break; case T_TXT: (void) fputs("\t\"", file); cp2 = cp1 + dlen; while (cp < cp2) { if (n = (unsigned char) *cp++) { for (c = n; c > 0 && cp < cp2; c--) if (*cp == '\n') { (void) putc('\\', file); (void) putc(*cp++, file); } else (void) putc(*cp++, file); } } (void) fputs("\"\n", file); break; case T_MINFO: fprintf(file,"\trequests = "); cp = p_cdname(cp, msg, file); fprintf(file,"\n\terrors = "); cp = p_cdname(cp, msg, file); break; case T_UINFO: fprintf(file,"\t%s\n", cp); cp += dlen; break; case T_UID: case T_GID: if (dlen == 4) { fprintf(file,"\t%ld\n", _getlong(cp)); cp += sizeof(int); } break; case T_WKS: if (dlen < sizeof(u_long) + 1) break; bcopy(cp, (char *)&inaddr, sizeof(inaddr)); cp += sizeof(u_long); fprintf(file,"\tinternet address = %s, protocol = %d\n\t", inet_ntoa(inaddr), *cp++); n = 0; while (cp < cp1 + dlen) { c = *cp++; do { if (c & 0200) fprintf(file," %d", n); c <<= 1; } while (++n & 07); } putc('\n',file); break; #ifdef ALLOW_T_UNSPEC case T_UNSPEC: { int NumBytes = 8; char *DataPtr; int i; if (dlen < NumBytes) NumBytes = dlen; fprintf(file, "\tFirst %d bytes of hex data:", NumBytes); for (i = 0, DataPtr = cp; i < NumBytes; i++, DataPtr++) fprintf(file, " %x", *DataPtr); fputs("\n", file); cp += dlen; } break; #endif /* ALLOW_T_UNSPEC */ default: fprintf(file,"\t???\n"); cp += dlen; } if (cp != cp1 + dlen) { fprintf(file,"packet size error (%#x != %#x)\n", cp, cp1+dlen); cp = NULL; } fprintf(file,"\n"); return (cp); } static char nbuf[256]; /* * Return a string for the type */ char * p_type(int type) { switch (type) { case T_A: return("A"); case T_NS: /* authoritative server */ return("NS"); case T_CNAME: /* canonical name */ return("CNAME"); case T_SOA: /* start of authority zone */ return("SOA"); case T_MB: /* mailbox domain name */ return("MB"); case T_MG: /* mail group member */ return("MG"); case T_MR: /* mail rename name */ return("MR"); case T_NULL: /* null resource record */ return("NULL"); case T_WKS: /* well known service */ return("WKS"); case T_PTR: /* domain name pointer */ return("PTR"); case T_HINFO: /* host information */ return("HINFO"); case T_MINFO: /* mailbox information */ return("MINFO"); case T_MX: /* mail routing info */ return("MX"); case T_TXT: /* text */ return("TXT"); case T_AXFR: /* zone transfer */ return("AXFR"); case T_MAILB: /* mail box */ return("MAILB"); case T_MAILA: /* mail address */ return("MAILA"); case T_ANY: /* matches any type */ return("ANY"); case T_UINFO: return("UINFO"); case T_UID: return("UID"); case T_GID: return("GID"); #ifdef ALLOW_T_UNSPEC case T_UNSPEC: return("UNSPEC"); #endif /* ALLOW_T_UNSPEC */ default: (void)sprintf(nbuf, "%d", type); return(nbuf); } } /* * Return a mnemonic for class */ char * p_class(int class) { switch (class) { case C_IN: /* internet class */ return("IN"); case C_HS: /* hesiod class */ return("HS"); case C_ANY: /* matches any class */ return("ANY"); default: (void)sprintf(nbuf, "%d", class); return(nbuf); } } /* * Return a mnemonic for a time to live */ char * p_time(u_long value) { int secs, mins, hours; register char *p; if (value == 0) { strcpy(nbuf, "0 secs"); return(nbuf); } secs = value % 60; value /= 60; mins = value % 60; value /= 60; hours = value % 24; value /= 24; #define PLURALIZE(x) x, (x == 1) ? "" : "s" p = nbuf; if (value) { (void)sprintf(p, "%d day%s", PLURALIZE(value)); while (*++p); } if (hours) { if (value) *p++ = ' '; (void)sprintf(p, "%d hour%s", PLURALIZE(hours)); while (*++p); } if (mins) { if (value || hours) *p++ = ' '; (void)sprintf(p, "%d min%s", PLURALIZE(mins)); while (*++p); } if (secs || ! (value || hours || mins)) { if (value || hours || mins) *p++ = ' '; (void)sprintf(p, "%d sec%s", PLURALIZE(secs)); } return(nbuf); } ./libc-linux/inet/res_init.c100644 1676 334 12442 5362343014 14056 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_init.c 6.14 (Berkeley) 6/27/90"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" /* * Resolver state default settings */ struct state _res = { RES_TIMEOUT, /* retransmition time interval */ 4, /* number of times to retransmit */ RES_DEFAULT, /* options flags */ 1, /* number of name servers */ }; /* * Set up default settings. If the configuration file exist, the values * there will have precedence. Otherwise, the server address is set to * INADDR_ANY and the default domain name comes from the gethostname(). * * The configuration file should only be used if you want to redefine your * domain or run without a server on your machine. * * Return 0 if completes successfully, -1 on error */ int res_init() { register FILE *fp; register char *cp, **pp; register int n; char buf[BUFSIZ]; extern u_long inet_addr(); extern char *index(); extern char *strcpy(), *strncpy(); extern char *getenv(); int nserv = 0; /* number of nameserver records read from file */ int haveenv = 0; int havesearch = 0; _res.nsaddr.sin_addr.s_addr = INADDR_ANY; _res.nsaddr.sin_family = AF_INET; _res.nsaddr.sin_port = htons(NAMESERVER_PORT); _res.nscount = 1; /* Allow user to override the local domain definition */ if ((cp = getenv("LOCALDOMAIN")) != NULL) { (void)strncpy(_res.defdname, cp, sizeof(_res.defdname)); haveenv++; } if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { /* read the config file */ while (fgets(buf, sizeof(buf), fp) != NULL) { /* read default domain name */ if (!strncmp(buf, "domain", sizeof("domain") - 1)) { if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("domain") - 1; while (*cp == ' ' || *cp == '\t') cp++; if ((*cp == '\0') || (*cp == '\n')) continue; (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); if ((cp = index(_res.defdname, '\n')) != NULL) *cp = '\0'; havesearch = 0; continue; } /* set search list */ if (!strncmp(buf, "search", sizeof("search") - 1)) { if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("search") - 1; while (*cp == ' ' || *cp == '\t') cp++; if ((*cp == '\0') || (*cp == '\n')) continue; (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); if ((cp = index(_res.defdname, '\n')) != NULL) *cp = '\0'; /* * Set search list to be blank-separated strings * on rest of line. */ cp = _res.defdname; pp = _res.dnsrch; *pp++ = cp; for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) { if (*cp == ' ' || *cp == '\t') { *cp = 0; n = 1; } else if (n) { *pp++ = cp; n = 0; } } /* null terminate last domain if there are excess */ while (*cp != '\0' && *cp != ' ' && *cp != '\t') cp++; *cp = '\0'; *pp++ = 0; havesearch = 1; continue; } /* read nameservers to query */ if (!strncmp(buf, "nameserver", sizeof("nameserver") - 1) && nserv < MAXNS) { cp = buf + sizeof("nameserver") - 1; while (*cp == ' ' || *cp == '\t') cp++; if ((*cp == '\0') || (*cp == '\n')) continue; if ((_res.nsaddr_list[nserv].sin_addr.s_addr = inet_addr(cp)) == (unsigned)-1) { _res.nsaddr_list[nserv].sin_addr.s_addr = INADDR_ANY; continue; } _res.nsaddr_list[nserv].sin_family = AF_INET; _res.nsaddr_list[nserv].sin_port = htons(NAMESERVER_PORT); nserv++; continue; } } if (nserv > 1) _res.nscount = nserv; (void) fclose(fp); } if (_res.defdname[0] == 0) { if (gethostname(buf, sizeof(_res.defdname)) == 0 && (cp = index(buf, '.'))) (void)strcpy(_res.defdname, cp + 1); } /* find components of local domain that might be searched */ if (havesearch == 0) { pp = _res.dnsrch; *pp++ = _res.defdname; for (cp = _res.defdname, n = 0; *cp; cp++) if (*cp == '.') n++; cp = _res.defdname; for (; n >= LOCALDOMAINPARTS && pp < _res.dnsrch + MAXDFLSRCH; n--) { cp = index(cp, '.'); *pp++ = ++cp; } *pp++ = 0; } _res.options |= RES_INIT; return (0); } ./libc-linux/inet/res_mkqry.c100644 1676 334 12115 5222447562 14263 0ustar hjlisl/* * Copyright (c) 1985 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_mkquery.c 6.12 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" /* * Form all types of queries. * Returns the size of the result or -1. */ int res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) int op; /* opcode of query */ const char *dname; /* domain name */ int class, type; /* class and type of query */ char *data; /* resource record data */ int datalen; /* length of data */ struct rrec *newrr; /* new rr for modify or append */ char *buf; /* buffer to put query */ int buflen; /* size of buffer */ { register HEADER *hp; register char *cp; register int n; u_char *dnptrs[10], **dpp, **lastdnptr; #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_mkquery(%d, %s, %d, %d)\n", op, dname, class, type); #endif DEBUG /* * Initialize header fields. */ if ((buf == NULL) || (buflen < sizeof(HEADER))) return(-1); bzero(buf, sizeof(HEADER)); hp = (HEADER *) buf; hp->id = htons(++_res.id); hp->opcode = op; hp->pr = (_res.options & RES_PRIMARY) != 0; hp->rd = (_res.options & RES_RECURSE) != 0; hp->rcode = NOERROR; cp = buf + sizeof(HEADER); buflen -= sizeof(HEADER); dpp = dnptrs; *dpp++ = buf; *dpp++ = NULL; lastdnptr = dnptrs + sizeof(dnptrs)/sizeof(dnptrs[0]); /* * perform opcode specific processing */ switch (op) { case QUERY: if ((buflen -= QFIXEDSZ) < 0) return(-1); if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; buflen -= n; putshort(type, cp); cp += sizeof(u_short); putshort(class, cp); cp += sizeof(u_short); hp->qdcount = htons(1); if (op == QUERY || data == NULL) break; /* * Make an additional record for completion domain. */ buflen -= RRFIXEDSZ; if ((n = dn_comp(data, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; buflen -= n; putshort(T_NULL, cp); cp += sizeof(u_short); putshort(class, cp); cp += sizeof(u_short); putlong(0, cp); cp += sizeof(u_long); putshort(0, cp); cp += sizeof(u_short); hp->arcount = htons(1); break; case IQUERY: /* * Initialize answer section */ if (buflen < 1 + RRFIXEDSZ + datalen) return (-1); *cp++ = '\0'; /* no domain name */ putshort(type, cp); cp += sizeof(u_short); putshort(class, cp); cp += sizeof(u_short); putlong(0, cp); cp += sizeof(u_long); putshort(datalen, cp); cp += sizeof(u_short); if (datalen) { bcopy(data, cp, datalen); cp += datalen; } hp->ancount = htons(1); break; #ifdef ALLOW_UPDATES /* * For UPDATEM/UPDATEMA, do UPDATED/UPDATEDA followed by UPDATEA * (Record to be modified is followed by its replacement in msg.) */ case UPDATEM: case UPDATEMA: case UPDATED: /* * The res code for UPDATED and UPDATEDA is the same; user * calls them differently: specifies data for UPDATED; server * ignores data if specified for UPDATEDA. */ case UPDATEDA: buflen -= RRFIXEDSZ + datalen; if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; putshort(type, cp); cp += sizeof(u_short); putshort(class, cp); cp += sizeof(u_short); putlong(0, cp); cp += sizeof(u_long); putshort(datalen, cp); cp += sizeof(u_short); if (datalen) { bcopy(data, cp, datalen); cp += datalen; } if ( (op == UPDATED) || (op == UPDATEDA) ) { hp->ancount = htons(0); break; } /* Else UPDATEM/UPDATEMA, so drop into code for UPDATEA */ case UPDATEA: /* Add new resource record */ buflen -= RRFIXEDSZ + datalen; if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) return (-1); cp += n; putshort(newrr->r_type, cp); cp += sizeof(u_short); putshort(newrr->r_class, cp); cp += sizeof(u_short); putlong(0, cp); cp += sizeof(u_long); putshort(newrr->r_size, cp); cp += sizeof(u_short); if (newrr->r_size) { bcopy(newrr->r_data, cp, newrr->r_size); cp += newrr->r_size; } hp->ancount = htons(0); break; #endif ALLOW_UPDATES } return (cp - buf); } ./libc-linux/inet/res_query.c100644 1676 334 16323 5222450004 14253 0ustar hjlisl/* * Copyright (c) 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[] = "@(#)res_query.c 5.7 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" #if PACKETSZ > 1024 #define MAXPACKET PACKETSZ #else #define MAXPACKET 1024 #endif extern int errno; /* * Formulate a normal query, send, and await answer. * Returned answer is placed in supplied buffer "answer". * Perform preliminary check of answer, returning success only * if no error is indicated and the answer count is nonzero. * Return the size of the response on success, -1 on error. * Error number is left in h_errno. * Caller must parse answer and determine whether it answers the question. */ int res_query(name, class, type, answer, anslen) const char *name; /* domain name */ int class, type; /* class and type of query */ u_char *answer; /* buffer to put answer */ int anslen; /* size of answer buffer */ { char buf[MAXPACKET]; HEADER *hp; int n; if ((_res.options & RES_INIT) == 0 && res_init() == -1) return (-1); #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_query(%s, %d, %d)\n", name, class, type); #endif n = res_mkquery(QUERY, name, class, type, (char *)NULL, 0, NULL, buf, sizeof(buf)); if (n <= 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_query: mkquery failed\n"); #endif h_errno = NO_RECOVERY; return (n); } n = res_send(buf, n, answer, anslen); if (n < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_query: send error\n"); #endif h_errno = TRY_AGAIN; return(n); } hp = (HEADER *) answer; if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) printf("rcode = %d, ancount=%d\n", hp->rcode, ntohs(hp->ancount)); #endif switch (hp->rcode) { case NXDOMAIN: h_errno = HOST_NOT_FOUND; break; case SERVFAIL: h_errno = TRY_AGAIN; break; case NOERROR: h_errno = NO_DATA; break; case FORMERR: case NOTIMP: case REFUSED: default: h_errno = NO_RECOVERY; break; } return (-1); } return(n); } /* * Formulate a normal query, send, and retrieve answer in supplied buffer. * Return the size of the response on success, -1 on error. * If enabled, implement search rules until answer or unrecoverable failure * is detected. Error number is left in h_errno. * Only useful for queries in the same name hierarchy as the local host * (not, for example, for host address-to-name lookups in domain in-addr.arpa). */ int res_search(name, class, type, answer, anslen) const char *name; /* domain name */ int class, type; /* class and type of query */ u_char *answer; /* buffer to put answer */ int anslen; /* size of answer */ { register char *cp, **domain; int n, ret, got_nodata = 0; char *hostalias(); if ((_res.options & RES_INIT) == 0 && res_init() == -1) return (-1); errno = 0; h_errno = HOST_NOT_FOUND; /* default, if we never query */ for (cp = name, n = 0; *cp; cp++) if (*cp == '.') n++; if (n == 0 && (cp = hostalias(name))) return (res_query(cp, class, type, answer, anslen)); /* * We do at least one level of search if * - there is no dot and RES_DEFNAME is set, or * - there is at least one dot, there is no trailing dot, * and RES_DNSRCH is set. */ if ((n == 0 && _res.options & RES_DEFNAMES) || (n != 0 && *--cp != '.' && _res.options & RES_DNSRCH)) for (domain = _res.dnsrch; *domain; domain++) { ret = res_querydomain(name, *domain, class, type, answer, anslen); if (ret > 0) return (ret); /* * If no server present, give up. * If name isn't found in this domain, * keep trying higher domains in the search list * (if that's enabled). * On a NO_DATA error, keep trying, otherwise * a wildcard entry of another type could keep us * from finding this entry higher in the domain. * If we get some other error (negative answer or * server failure), then stop searching up, * but try the input name below in case it's fully-qualified. */ if (errno == ECONNREFUSED) { h_errno = TRY_AGAIN; return (-1); } if (h_errno == NO_DATA) got_nodata++; if ((h_errno != HOST_NOT_FOUND && h_errno != NO_DATA) || (_res.options & RES_DNSRCH) == 0) break; } /* * If the search/default failed, try the name as fully-qualified, * but only if it contained at least one dot (even trailing). * This is purely a heuristic; we assume that any reasonable query * about a top-level domain (for servers, SOA, etc) will not use * res_search. */ if (n && (ret = res_querydomain(name, (char *)NULL, class, type, answer, anslen)) > 0) return (ret); if (got_nodata) h_errno = NO_DATA; return (-1); } /* * Perform a call on res_query on the concatenation of name and domain, * removing a trailing dot from name if domain is NULL. */ int res_querydomain(name, domain, class, type, answer, anslen) const char *name, *domain; int class, type; /* class and type of query */ u_char *answer; /* buffer to put answer */ int anslen; /* size of answer */ { char nbuf[2*MAXDNAME+2]; char *longname = nbuf; int n; #ifdef DEBUG if (_res.options & RES_DEBUG) printf("res_querydomain(%s, %s, %d, %d)\n", name, domain, class, type); #endif if (domain == NULL) { /* * Check for trailing '.'; * copy without '.' if present. */ n = strlen(name) - 1; if (name[n] == '.' && n < sizeof(nbuf) - 1) { bcopy(name, nbuf, n); nbuf[n] = '\0'; } else longname = name; } else (void)sprintf(nbuf, "%.*s.%.*s", MAXDNAME, name, MAXDNAME, domain); return (res_query(longname, class, type, answer, anslen)); } char * hostalias(const char *name) { register char *C1, *C2; FILE *fp; char *file, *getenv(), *strcpy(), *strncpy(); char buf[BUFSIZ]; static char abuf[MAXDNAME]; file = getenv("HOSTALIASES"); if (file == NULL || (fp = fopen(file, "r")) == NULL) return (NULL); buf[sizeof(buf) - 1] = '\0'; while (fgets(buf, sizeof(buf), fp)) { for (C1 = buf; *C1 && !isspace(*C1); ++C1); if (!*C1) break; *C1 = '\0'; if (!strcasecmp(buf, name)) { while (isspace(*++C1)); if (!*C1) break; for (C2 = C1 + 1; *C2 && !isspace(*C2); ++C2); abuf[sizeof(abuf) - 1] = *C2 = '\0'; (void)strncpy(abuf, C1, sizeof(abuf) - 1); fclose(fp); return (abuf); } } fclose(fp); return (NULL); } ./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/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/inet/sethostent.c100644 1676 334 2323 5234366437 14433 0ustar hjlisl/* * Copyright (c) 1985 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[] = "@(#)sethostent.c 6.5 (Berkeley) 6/27/88"; #endif /* LIBC_SCCS and not lint */ #include "inetprivate.h" void sethostent(int stayopen) { if (stayopen) _res.options |= RES_STAYOPEN | RES_USEVC; } void endhostent() { _res.options &= ~(RES_STAYOPEN | RES_USEVC); _res_close(); } void sethostfile(char *name) { #ifdef lint name = name; #endif } ./libc-linux/inet/bindresvport.c100644 1676 334 4517 5303100614 14737 0ustar hjlisl/* static char sccsid[] = "@(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC 1.8 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 */ /* * Copyright (c) 1987 by Sun Microsystems, Inc. */ #include #include #include #include #include #include /* * Bind a socket to a privileged IP port */ int bindresvport(sd, sin) int sd; struct sockaddr_in *sin; { int res; static short port; struct sockaddr_in myaddr; extern int errno; int i; #define STARTPORT 600 #define ENDPORT (IPPORT_RESERVED - 1) #define NPORTS (ENDPORT - STARTPORT + 1) if (sin == (struct sockaddr_in *)0) { sin = &myaddr; bzero(sin, sizeof (*sin)); sin->sin_family = AF_INET; } else if (sin->sin_family != AF_INET) { errno = EPFNOSUPPORT; return (-1); } if (port == 0) { port = (getpid() % NPORTS) + STARTPORT; } res = -1; errno = EADDRINUSE; for (i = 0; i < NPORTS && res < 0 && errno == EADDRINUSE; i++) { sin->sin_port = htons(port++); if (port > ENDPORT) { port = STARTPORT; } res = bind(sd, (struct sockaddr *) sin, sizeof(struct sockaddr_in)); } return (res); } ./libc-linux/inet/sethostid.c100644 1676 334 164 5372563002 14210 0ustar hjlislint fd; fd = socket(AF_INET, SOCK_RAW, 0); ifreq.ifr_addr = id; return((ioctl(fd, SIOCSIFADDR, &ifr)); ./libc-linux/gcc/ 40755 1676 334 0 5550061516 11556 5ustar hjlisl./libc-linux/gcc/Makefile100644 1676 334 14221 5527714025 13337 0ustar hjlisl# # This is Makefile for libgcc.a # override STATIC=false override DEBUG=false override PROFILE=false #override CHECKER=false JUMP_LIB=libgcc TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules srcdir=. ifeq ($(CHECKER),true) LIBGCC=$(CHECKER_DIR)/libgcc/libgcc3.a else LIBGCC=$(SHARED_DIR)/libgcc/libgcc3.a endif LIBGCC1=#libgcc1.a LIBGCC2=libgcc2.a CFLAGS = $(WFLAGS) $(OPT_CFLAGS) $(INC_CFLAGS) $(XCFLAGS) INCLUDES = -I. -I$(srcdir) -I$(srcdir)/config INC_CFLAGS=$(INCLUDES) CCLIBFLAGS= $(OPT_CFLAGS) LIBGCC2_CFLAGS=$(OPT_CFLAGS) $(DEBUGFLAGS) DIRS= ifeq ($(SHARED_STATIC),true) SHARED=true endif ifeq ($(SHARED),true) SHARED=FALSE include $(TOPDIR)/Maketargets LIB2FUNCS = _eprintf __main _exit _ctors _op_new _op_delete \ _new_handler # _muldi3 _udivdi3 _umoddi3 _udivmoddi4 LIBGCCALIASES=$(SHARED_DIR)/$(SUBDIR)/aliases.o LIBGCC2_CFLAGS=$(BASE_OPTFLAGS) $(DEBUGFLAGS) -B$(JUMPASDIR)/ lib:: @if [ -d $(SHARED_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(SHARED_DIR)/$(SUBDIR); \ $(MKDIR) $(SHARED_DIR)/$(SUBDIR); \ fi $(RM) -f libgcc1.a # safer (it can be the checkered one) lib all:: libgcc else ifeq ($(CHECKER),true) include $(TOPDIR)/Maketargets LIB2FUNCS = _eprintf __main _exit _ctors _op_new _op_delete \ _new_handler # _muldi3 _udivdi3 _umoddi3 _udivmoddi4 LIBGCCALIASES=$(CHECKER_DIR)/$(SUBDIR)/aliases.o LIBGCC2_CFLAGS=$(BASE_OPTFLAGS) $(DEBUGFLAGS) lib:: @if [ -d $(CHECKER_DIR)/$(SUBDIR) ]; then \ true; else \ $(RM) -f $(CHECKER_DIR)/$(SUBDIR); \ $(MKDIR) $(CHECKER_DIR)/$(SUBDIR); \ fi $(RM) -f libgcc1.a # safer (it can be the static one) lib all:: libgcc else lib all: @true endif endif libgcc1.a: libgcc1.c -$(RM) -fr tmplibgcc1.a tmpcopy # Actually build it in tmplibgcc1.a, then rename at end, # so that libgcc1.a itself remains nonexistent if compilation is aborted. # -e causes any failing command to make this rule fail. # -e doesn't work in certain shells, so we test $$? as well. -set -e; \ mkdir tmpcopy; \ for name in .. $(LIB1FUNCS); \ do \ if [ x$${name} != x.. ]; then \ echo $${name}; \ $(CC) $(CCLIBFLAGS) $(INCLUDES) -c -DL$${name} \ $(srcdir)/libgcc1.c -o ./tmpcopy/$${name}.o; \ if [ $$? -eq 0 ] ; then true; else exit 1; fi; \ else true; fi; \ done (cd ./tmpcopy; $(AR) $(AR_FLAGS) ../tmplibgcc1.a *.o) $(RM) -rf ./tmpcopy # Some shells crash when a loop has no items. # So make sure there is always at least one--`..'. # Then ignore it. # We don't use -e here because there are if statements # that should not make the command give up when the if condition is false. # Instead, we test for failure after each command where it matters. -for file in .. $(LIB1FUNCS_EXTRA); \ do \ if [ x$${file} != x.. ]; then \ name=`echo $${file} | sed -e 's/[.]c$$//' -e 's/[.]asm$$//'`; \ echo $${name}; \ if [ $${name}.asm = $${file} ]; then \ cp $${file} $${name}.s || exit 1; file=$${name}.s; \ else true; fi; \ $(CC) $(CCLIBFLAGS) $(INCLUDES) -c $${file}; \ if [ $$? -eq 0 ] ; then true; else exit 1; fi; \ $(AR) $(AR_FLAGS) tmplibgcc1.a $${name}.o; \ if [ $$? -eq 0 ] ; then true; else exit 1; fi; \ rm -f $${name}.[so]; \ else true; \ fi; \ done if [ -f tmplibgcc1.a ]; then \ mv tmplibgcc1.a libgcc1.a; \ else true; fi # Compiling libgcc2.a requires making sure that cc1, etc. have been compiled. # But recompiling cc1 should not force recompilation of libgcc2.a. # If you want to force recompilation, delete libgcc2.a. # Depend on install-cross-tools to make sure we set up properly # to run the assembler before we try compiling anything. # install-cross-tools does nothing if not cross compiling. libgcc2.ready: $(GCC_PASSES) $(CROSS_TOOLS) -if [ -f libgcc2.ready ] ; then \ true; \ else \ touch libgcc2.ready; \ fi libgcc2.a: libgcc2.c #libgcc2.ready $(CONFIG_H) $(LIB2FUNCS_EXTRA) \ # machmode.h longlong.h gbl-ctors.h config.status # Actually build it in tmplibgcc2.a, then rename at end, # so that libgcc2.a itself remains nonexistent if compilation is aborted. -$(RM) -fr tmplibgcc2.a tmpcopy # -e causes any failing command to make this rule fail. # -e doesn't work in certain shells, so we test $$? as well. set -e; \ mkdir tmpcopy; \ for name in $(LIB2FUNCS); \ do \ echo $${name}; \ $(CC) $(LIBGCC2_CFLAGS) $(INCLUDES) -c -DL$${name} \ $(srcdir)/libgcc2.c -o ./tmpcopy/$${name}.o; \ if [ $$? -eq 0 ] ; then true; else exit 1; fi; \ done (cd ./tmpcopy; $(AR) $(AR_FLAGS) ../tmplibgcc2.a *.o) $(RM) -rf ./tmpcopy # Some shells crash when a loop has no items. # So make sure there is always at least one--`..'. # Then ignore it. # We don't use -e here because there are if statements # that should not make the command give up when the if condition is false. # Instead, we test for failure after each command where it matters. -for file in .. $(LIB2FUNCS_EXTRA); \ do \ if [ x$${file} != x.. ]; then \ name=`echo $${file} | sed -e 's/[.]c$$//' -e 's/[.]asm$$//'`; \ echo $${name}; \ if [ $${name}.asm = $${file} ]; then \ cp $${file} $${name}.s || exit 1; file=$${name}.s; \ else true; fi; \ $(CC) $(LIBGCC2_CFLAGS) $(INCLUDES) -c $${file}; \ if [ $$? -eq 0 ] ; then true; else exit 1; fi; \ $(AR) $(AR_FLAGS) tmplibgcc2.a $${name}.o; \ rm -f $${name}.[so]; \ else true; \ fi; \ done mv tmplibgcc2.a libgcc2.a # These lines were deleted from above the mv command # because ranlibing libgcc.a itself should suffice. # -if [ x${HPUX_GAS} = x ] ; then \ # if $(RANLIB_TEST) ; then $(RANLIB) tmplibgcc2.a; else true; fi \ # else true; fi # Combine the various libraries into a single library, libgcc.a. libgcc: $(LIBGCC1) $(LIBGCC2) $(LIBGCCALIASES) -$(RM) -rf tmplibgcc.a $(LIBGCC) tmpcopy mkdir tmpcopy -if [ x$(LIBGCC1) != x ]; \ then (cd tmpcopy; $(AR) x ../$(LIBGCC1)); \ else true; \ fi (cd tmpcopy; $(AR) x ../$(LIBGCC2)) (cd tmpcopy; $(AR) $(AR_FLAGS) ../tmplibgcc.a *.o) $(RM) -rf tmpcopy $(LIBGCC2) # Actually build it in tmplibgcc.a, then rename at end, # so that libgcc.a itself remains nonexistent if compilation is aborted. $(AR) $(AR_FLAGS) tmplibgcc.a $(LIBGCCALIASES) $(REALRANLIB) tmplibgcc.a mv tmplibgcc.a $(LIBGCC) ./libc-linux/gcc/hconfig.h100644 1676 334 1002 5471532750 13437 0ustar hjlisl/* Configuration for GCC for Intel i386 running Linux. * * Written by H.J. Lu (hlu@eecs.wsu.edu) */ #include "i386/xm-i386.h" #include "xm-svr3.h" #undef BSTRING #define BSTRING #undef bcmp #undef bcopy #undef bzero #undef index #undef rindex #if 0 /* These conflict with stdlib.h in protoize, it is said, and there's no evidence they are actually needed. */ #undef malloc(n) #define malloc(n) malloc ((n) ? (n) : 1) #undef calloc(n,e) #define calloc(n,e) calloc (((n) ? (n) : 1), ((e) ? (e) : 1)) #endif ./libc-linux/gcc/tconfig.h100644 1676 334 1002 5471532751 13454 0ustar hjlisl/* Configuration for GCC for Intel i386 running Linux. * * Written by H.J. Lu (hlu@eecs.wsu.edu) */ #include "i386/xm-i386.h" #include "xm-svr3.h" #undef BSTRING #define BSTRING #undef bcmp #undef bcopy #undef bzero #undef index #undef rindex #if 0 /* These conflict with stdlib.h in protoize, it is said, and there's no evidence they are actually needed. */ #undef malloc(n) #define malloc(n) malloc ((n) ? (n) : 1) #undef calloc(n,e) #define calloc(n,e) calloc (((n) ? (n) : 1), ((e) ? (e) : 1)) #endif ./libc-linux/gcc/config/ 40755 1676 334 0 5504466574 13037 5ustar hjlisl./libc-linux/gcc/config/i386/ 40755 1676 334 0 5504466573 13527 5ustar hjlisl./libc-linux/gcc/config/i386/xm-i386.h100644 1676 334 2652 5370313172 15100 0ustar hjlisl/* Configuration for GNU C-compiler for Intel 80386. Copyright (C) 1988 Free Software Foundation, Inc. This file is part of GNU CC. GNU CC 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. GNU CC 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. */ #ifndef i386 #define i386 #endif /* #defines that need visibility everywhere. */ #define FALSE 0 #define TRUE 1 /* This describes the machine the compiler is hosted on. */ #define HOST_BITS_PER_CHAR 8 #define HOST_BITS_PER_SHORT 16 #define HOST_BITS_PER_INT 32 #define HOST_BITS_PER_LONG 32 #define HOST_BITS_PER_LONGLONG 64 /* Arguments to use with `exit'. */ #define SUCCESS_EXIT_CODE 0 #define FATAL_EXIT_CODE 33 /* If compiled with GNU C, use the built-in alloca */ #ifdef __GNUC__ #undef alloca #define alloca __builtin_alloca #endif /* target machine dependencies. tm.h is a symbolic link to the actual target specific file. */ #include "tm.h" ./libc-linux/gcc/config/i386/gas.h100644 1676 334 12066 5370313172 14557 0ustar hjlisl/* Definitions for Intel 386 running system V with gnu tools Copyright (C) 1988 Free Software Foundation, Inc. This file is part of GNU CC. GNU CC 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. GNU CC 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. */ /* Note that i386/seq-gas.h is a GAS configuration that does not use this file. */ #include "i386/i386.h" #ifndef YES_UNDERSCORES /* Define this now, because i386/bsd.h tests it. */ #define NO_UNDERSCORES #endif /* Use the bsd assembler syntax. */ /* we need to do this because gas is really a bsd style assembler, * and so doesn't work well this these att-isms: * * ASM_OUTPUT_SKIP is .set .,.+N, which isn't implemented in gas * ASM_OUTPUT_LOCAL is done with .set .,.+N, but that can't be * used to define bss static space * * Next is the question of whether to uses underscores. RMS didn't * like this idea at first, but since it is now obvious that we * need this separate tm file for use with gas, at least to get * dbx debugging info, I think we should also switch to underscores. * We can keep i386v for real att style output, and the few * people who want both form will have to compile twice. */ #include "i386/bsd.h" /* these come from i386/bsd.h, but are specific to sequent */ #undef DBX_NO_XREFS #undef DBX_CONTIN_LENGTH /* Ask for COFF symbols. */ #define SDB_DEBUGGING_INFO /* Specify predefined symbols in preprocessor. */ #define CPP_PREDEFINES "-Dunix -Di386" #define CPP_SPEC "%{posix:-D_POSIX_SOURCE}" /* Allow #sccs in preprocessor. */ #define SCCS_DIRECTIVE /* Output #ident as a .ident. */ #define ASM_OUTPUT_IDENT(FILE, NAME) fprintf (FILE, "\t.ident \"%s\"\n", NAME); /* Implicit library calls should use memcpy, not bcopy, etc. */ #define TARGET_MEM_FUNCTIONS #if 0 /* People say gas uses the log as the arg to .align. */ /* When using gas, .align N aligns to an N-byte boundary. */ #undef ASM_OUTPUT_ALIGN #define ASM_OUTPUT_ALIGN(FILE,LOG) \ if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG)) #endif /* Align labels, etc. at 4-byte boundaries. For the 486, align to 16-byte boundary for sake of cache. */ #undef ASM_OUTPUT_ALIGN_CODE #define ASM_OUTPUT_ALIGN_CODE(FILE) \ fprintf ((FILE), "\t.align %d,0x90\n", \ TARGET_486 ? 4 : 2); /* Use log of 16 or log of 4 as arg. */ /* Align start of loop at 4-byte boundary. */ #undef ASM_OUTPUT_LOOP_ALIGN #define ASM_OUTPUT_LOOP_ALIGN(FILE) \ fprintf ((FILE), "\t.align 2,0x90\n"); /* Use log of 4 as arg. */ #undef ASM_FILE_START #define ASM_FILE_START(FILE) \ fprintf (FILE, "\t.file\t\"%s\"\n", dump_base_name); /* A C statement or statements which output an assembler instruction opcode to the stdio stream STREAM. The macro-operand PTR is a variable of type `char *' which points to the opcode name in its "internal" form--the form that is written in the machine description. GAS version 1.38.1 doesn't understand the `repz' opcode mnemonic. So use `repe' instead. */ #define ASM_OUTPUT_OPCODE(STREAM, PTR) \ { \ if ((PTR)[0] == 'r' \ && (PTR)[1] == 'e' \ && (PTR)[2] == 'p') \ { \ if ((PTR)[3] == 'z') \ { \ fprintf (STREAM, "repe"); \ (PTR) += 4; \ } \ else if ((PTR)[3] == 'n' && (PTR)[4] == 'z') \ { \ fprintf (STREAM, "repne"); \ (PTR) += 5; \ } \ } \ } /* Define macro used to output shift-double opcodes when the shift count is in %cl. Some assemblers require %cl as an argument; some don't. GAS requires the %cl argument, so override i386/unix.h. */ #undef AS3_SHIFT_DOUBLE #define AS3_SHIFT_DOUBLE(a,b,c,d) AS3 (a,b,c,d) /* Print opcodes the way that GAS expects them. */ #define GAS_MNEMONICS 1 #ifdef NO_UNDERSCORES /* If user-symbols don't have underscores, then it must take more than `L' to identify a label that should be ignored. */ /* This is how to store into the string BUF the symbol_ref name of an internal numbered label where PREFIX is the class of label and NUM is the number within the class. This is suitable for output with `assemble_name'. */ #undef ASM_GENERATE_INTERNAL_LABEL #define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ sprintf ((BUF), ".%s%d", (PREFIX), (NUMBER)) /* This is how to output an internal numbered label where PREFIX is the class of label and NUM is the number within the class. */ #undef ASM_OUTPUT_INTERNAL_LABEL #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ fprintf (FILE, ".%s%d:\n", PREFIX, NUM) #endif /* NO_UNDERSCORES */ ./libc-linux/gcc/config/i386/i386.h100644 1676 334 162012 5370313173 14514 0ustar hjlisl/* Definitions of target machine for GNU compiler for Intel 80386. Copyright (C) 1988, 1992 Free Software Foundation, Inc. This file is part of GNU CC. GNU CC 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. GNU CC 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. */ /* The purpose of this file is to define the characteristics of the i386, independent of assembler syntax or operating system. Three other files build on this one to describe a specific assembler syntax: bsd386.h, att386.h, and sun386.h. The actual tm.h file for a particular system should include this file, and then the file for the appropriate assembler syntax. Many macros that specify assembler syntax are omitted entirely from this file because they really belong in the files for particular assemblers. These include AS1, AS2, AS3, RP, IP, LPREFIX, L_SIZE, PUT_OP_SIZE, USE_STAR, ADDR_BEG, ADDR_END, PRINT_IREG, PRINT_SCALE, PRINT_B_I_S, and many that start with ASM_ or end in ASM_OP. */ /* Names to predefine in the preprocessor for this target machine. */ #define I386 1 /* Stubs for half-pic support if not OSF/1 reference platform. */ #ifndef HALF_PIC_P #define HALF_PIC_P() 0 #define HALF_PIC_NUMBER_PTRS 0 #define HALF_PIC_NUMBER_REFS 0 #define HALF_PIC_ENCODE(DECL) #define HALF_PIC_DECLARE(NAME) #define HALF_PIC_INIT() error ("half-pic init called on systems that don't support it.") #define HALF_PIC_ADDRESS_P(X) 0 #define HALF_PIC_PTR(X) X #define HALF_PIC_FINISH(STREAM) #endif /* Run-time compilation parameters selecting different hardware subsets. */ extern int target_flags; /* Macros used in the machine description to test the flags. */ /* configure can arrage to make this 2, to force a 486. */ #ifndef TARGET_CPU_DEFAULT #define TARGET_CPU_DEFAULT 0 #endif /* Compile 80387 insns for floating point (not library calls). */ #define TARGET_80387 (target_flags & 1) /* Compile code for an i486. */ #define TARGET_486 (target_flags & 2) /* Compile using ret insn that pops args. This will not work unless you use prototypes at least for all functions that can take varying numbers of args. */ #define TARGET_RTD (target_flags & 8) /* Compile passing first two args in regs 0 and 1. This exists only to test compiler features that will be needed for RISC chips. It is not usable and is not intended to be usable on this cpu. */ #define TARGET_REGPARM (target_flags & 020) /* Put uninitialized locals into bss, not data. Meaningful only on svr3. */ #define TARGET_SVR3_SHLIB (target_flags & 040) /* Use IEEE floating point comparisons. These handle correctly the cases where the result of a comparison is unordered. Normally SIGFPE is generated in such cases, in which case this isn't needed. */ #define TARGET_IEEE_FP (target_flags & 0100) /* Functions that return a floating point value may return that value in the 387 FPU or in 386 integer registers. If set, this flag causes the 387 to be used, which is compatible with most calling conventions. */ #define TARGET_FLOAT_RETURNS_IN_80387 (target_flags & 0200) /* Macro to define tables used to set the flags. This is a list in braces of pairs in braces, each pair being { "NAME", VALUE } where VALUE is the bits to set or minus the bits to clear. An empty string NAME is used to identify the default VALUE. */ #define TARGET_SWITCHES \ { { "80387", 1}, \ { "no-80387", -1}, \ { "soft-float", -1}, \ { "no-soft-float", 1}, \ { "486", 2}, \ { "no-486", -2}, \ { "386", -2}, \ { "rtd", 8}, \ { "no-rtd", -8}, \ { "regparm", 020}, \ { "no-regparm", -020}, \ { "svr3-shlib", 040}, \ { "no-svr3-shlib", -040}, \ { "ieee-fp", 0100}, \ { "no-ieee-fp", -0100}, \ { "fp-ret-in-387", 0200}, \ { "no-fp-ret-in-387", -0200}, \ SUBTARGET_SWITCHES \ { "", TARGET_DEFAULT | TARGET_CPU_DEFAULT}} /* This is meant to be redefined in the host dependent files */ #define SUBTARGET_SWITCHES /* target machine storage layout */ /* Define this if most significant byte of a word is the lowest numbered. */ /* That is true on the 80386. */ #define BITS_BIG_ENDIAN 0 /* Define this if most significant byte of a word is the lowest numbered. */ /* That is not true on the 80386. */ #define BYTES_BIG_ENDIAN 0 /* Define this if most significant word of a multiword number is the lowest numbered. */ /* Not true for 80386 */ #define WORDS_BIG_ENDIAN 0 /* number of bits in an addressable storage unit */ #define BITS_PER_UNIT 8 /* Width in bits of a "word", which is the contents of a machine register. Note that this is not necessarily the width of data type `int'; if using 16-bit ints on a 80386, this would still be 32. But on a machine with 16-bit registers, this would be 16. */ #define BITS_PER_WORD 32 /* Width of a word, in units (bytes). */ #define UNITS_PER_WORD 4 /* Width in bits of a pointer. See also the macro `Pmode' defined below. */ #define POINTER_SIZE 32 /* Allocation boundary (in *bits*) for storing arguments in argument list. */ #define PARM_BOUNDARY 32 /* Boundary (in *bits*) on which stack pointer should be aligned. */ #define STACK_BOUNDARY 32 /* Allocation boundary (in *bits*) for the code of a function. For i486, we get better performance by aligning to a cache line (i.e. 16 byte) boundary. */ #define FUNCTION_BOUNDARY (TARGET_486 ? 128 : 32) /* Alignment of field after `int : 0' in a structure. */ #define EMPTY_FIELD_BOUNDARY 32 /* Minimum size in bits of the largest boundary to which any and all fundamental data types supported by the hardware might need to be aligned. No data type wants to be aligned rounder than this. The i386 supports 64-bit floating point quantities, but these can be aligned on any 32-bit boundary. */ #define BIGGEST_ALIGNMENT 32 /* Set this non-zero if move instructions will actually fail to work when given unaligned data. */ #define STRICT_ALIGNMENT 0 /* If bit field type is int, don't let it cross an int, and give entire struct the alignment of an int. */ /* Required on the 386 since it doesn't have bitfield insns. */ #define PCC_BITFIELD_TYPE_MATTERS 1 /* Align loop starts for optimal branching. */ #define ASM_OUTPUT_LOOP_ALIGN(FILE) \ ASM_OUTPUT_ALIGN (FILE, 2) /* This is how to align an instruction for optimal branching. On i486 we'll get better performance by aligning on a cache line (i.e. 16 byte) boundary. */ #define ASM_OUTPUT_ALIGN_CODE(FILE) \ ASM_OUTPUT_ALIGN ((FILE), (TARGET_486 ? 4 : 2)) /* Standard register usage. */ /* This processor has special stack-like registers. See reg-stack.c for details. */ #define STACK_REGS /* Number of actual hardware registers. The hardware registers are assigned numbers for the compiler from 0 to just below FIRST_PSEUDO_REGISTER. All registers that the compiler knows about must be given numbers, even those that are not normally considered general registers. In the 80386 we give the 8 general purpose registers the numbers 0-7. We number the floating point registers 8-15. Note that registers 0-7 can be accessed as a short or int, while only 0-3 may be used with byte `mov' instructions. Reg 16 does not correspond to any hardware register, but instead appears in the RTL as an argument pointer prior to reload, and is eliminated during reloading in favor of either the stack or frame pointer. */ #define FIRST_PSEUDO_REGISTER 17 /* 1 for registers that have pervasive standard uses and are not available for the register allocator. On the 80386, the stack pointer is such, as is the arg pointer. */ #define FIXED_REGISTERS \ /*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 } /* 1 for registers not available across function calls. These must include the FIXED_REGISTERS and also any registers that can be used without being saved. The latter must include the registers where values are returned and the register where structure-value addresses are passed. Aside from that, you can include as many other registers as you like. */ #define CALL_USED_REGISTERS \ /*ax,dx,cx,bx,si,di,bp,sp,st,st1,st2,st3,st4,st5,st6,st7,arg*/ \ { 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } /* Macro to conditionally modify fixed_regs/call_used_regs. */ #define CONDITIONAL_REGISTER_USAGE \ { \ if (flag_pic) \ { \ fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ } \ if (! TARGET_80387 && ! TARGET_FLOAT_RETURNS_IN_80387) \ { \ int i; \ HARD_REG_SET x; \ COPY_HARD_REG_SET (x, reg_class_contents[(int)FLOAT_REGS]); \ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++ ) \ if (TEST_HARD_REG_BIT (x, i)) \ fixed_regs[i] = call_used_regs[i] = 1; \ } \ } /* Return number of consecutive hard regs needed starting at reg REGNO to hold something of mode MODE. This is ordinarily the length in words of a value of mode MODE but can be less for certain modes in special long registers. Actually there are no two word move instructions for consecutive registers. And only registers 0-3 may have mov byte instructions applied to them. */ #define HARD_REGNO_NREGS(REGNO, MODE) \ (FP_REGNO_P (REGNO) ? 1 \ : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. On the 80386, the first 4 cpu registers can hold any mode while the floating point registers may hold only floating point. Make it clear that the fp regs could not hold a 16-byte float. */ /* The casts to int placate a compiler on a microvax, for cross-compiler testing. */ #define HARD_REGNO_MODE_OK(REGNO, MODE) \ ((REGNO) < 2 ? 1 \ : (REGNO) < 4 ? 1 \ : FP_REGNO_P ((REGNO)) \ ? (((int) GET_MODE_CLASS (MODE) == (int) MODE_FLOAT \ || (int) GET_MODE_CLASS (MODE) == (int) MODE_COMPLEX_FLOAT) \ && GET_MODE_UNIT_SIZE (MODE) <= 12) \ : (int) (MODE) != (int) QImode) /* Value is 1 if it is a good idea to tie two pseudo registers when one has mode MODE1 and one has mode MODE2. If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2, for any hard reg, then this must be 0 for correct output. */ #define MODES_TIEABLE_P(MODE1, MODE2) ((MODE1) == (MODE2)) /* A C expression returning the cost of moving data from a register of class CLASS1 to one of CLASS2. On the i386, copying between floating-point and fixed-point registers is expensive. */ #define REGISTER_MOVE_COST(CLASS1, CLASS2) \ (((FLOAT_CLASS_P (CLASS1) && ! FLOAT_CLASS_P (CLASS2)) \ || (! FLOAT_CLASS_P (CLASS1) && FLOAT_CLASS_P (CLASS2))) ? 10 \ : 2) /* Specify the registers used for certain standard purposes. The values of these macros are register numbers. */ /* on the 386 the pc register is %eip, and is not usable as a general register. The ordinary mov instructions won't work */ /* #define PC_REGNUM */ /* Register to use for pushing function arguments. */ #define STACK_POINTER_REGNUM 7 /* Base register for access to local variables of the function. */ #define FRAME_POINTER_REGNUM 6 /* First floating point reg */ #define FIRST_FLOAT_REG 8 /* First & last stack-like regs */ #define FIRST_STACK_REG FIRST_FLOAT_REG #define LAST_STACK_REG (FIRST_FLOAT_REG + 7) /* Value should be nonzero if functions must have frame pointers. Zero means the frame pointer need not be set up (and parms may be accessed via the stack pointer) in functions that seem suitable. This is computed in `reload', in reload1.c. */ #define FRAME_POINTER_REQUIRED 0 /* Base register for access to arguments of the function. */ #define ARG_POINTER_REGNUM 16 /* Register in which static-chain is passed to a function. */ #define STATIC_CHAIN_REGNUM 2 /* Register to hold the addressing base for position independent code access to data items. */ #define PIC_OFFSET_TABLE_REGNUM 3 /* Register in which address to store a structure value arrives in the function. On the 386, the prologue copies this from the stack to register %eax. */ #define STRUCT_VALUE_INCOMING 0 /* Place in which caller passes the structure value address. 0 means push the value on the stack like an argument. */ #define STRUCT_VALUE 0 /* Define the classes of registers for register constraints in the machine description. Also define ranges of constants. One of the classes must always be named ALL_REGS and include all hard regs. If there is more than one class, another class must be named NO_REGS and contain no registers. The name GENERAL_REGS must be the name of a class (or an alias for another name such as ALL_REGS). This is the class of registers that is allowed by "g" or "r" in a register constraint. Also, registers outside this class are allocated only when instructions express preferences for them. The classes must be numbered in nondecreasing order; that is, a larger-numbered class must never be contained completely in a smaller-numbered class. For any two classes, it is very desirable that there be another class that represents their union. It might seem that class BREG is unnecessary, since no useful 386 opcode needs reg %ebx. But some systems pass args to the OS in ebx, and the "b" register constraint is useful in asms for syscalls. */ enum reg_class { NO_REGS, AREG, DREG, CREG, BREG, Q_REGS, /* %eax %ebx %ecx %edx */ SIREG, DIREG, INDEX_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp */ GENERAL_REGS, /* %eax %ebx %ecx %edx %esi %edi %ebp %esp */ FP_TOP_REG, FP_SECOND_REG, /* %st(0) %st(1) */ FLOAT_REGS, ALL_REGS, LIM_REG_CLASSES }; #define N_REG_CLASSES (int) LIM_REG_CLASSES #define FLOAT_CLASS_P(CLASS) (reg_class_subset_p (CLASS, FLOAT_REGS)) /* Give names of register classes as strings for dump file. */ #define REG_CLASS_NAMES \ { "NO_REGS", \ "AREG", "DREG", "CREG", "BREG", \ "Q_REGS", \ "SIREG", "DIREG", \ "INDEX_REGS", \ "GENERAL_REGS", \ "FP_TOP_REG", "FP_SECOND_REG", \ "FLOAT_REGS", \ "ALL_REGS" } /* Define which registers fit in which classes. This is an initializer for a vector of HARD_REG_SET of length N_REG_CLASSES. */ #define REG_CLASS_CONTENTS \ { 0, \ 0x1, 0x2, 0x4, 0x8, /* AREG, DREG, CREG, BREG */ \ 0xf, /* Q_REGS */ \ 0x10, 0x20, /* SIREG, DIREG */ \ 0x1007f, /* INDEX_REGS */ \ 0x100ff, /* GENERAL_REGS */ \ 0x0100, 0x0200, /* FP_TOP_REG, FP_SECOND_REG */ \ 0xff00, /* FLOAT_REGS */ \ 0x1ffff } /* The same information, inverted: Return the class number of the smallest class containing reg number REGNO. This could be a conditional expression or could index an array. */ extern enum reg_class regclass_map[FIRST_PSEUDO_REGISTER]; #define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO]) /* When defined, the compiler allows registers explicitly used in the rtl to be used as spill registers but prevents the compiler from extending the lifetime of these registers. */ #define SMALL_REGISTER_CLASSES #define QI_REG_P(X) \ (REG_P (X) && REGNO (X) < 4) #define NON_QI_REG_P(X) \ (REG_P (X) && REGNO (X) >= 4 && REGNO (X) < FIRST_PSEUDO_REGISTER) #define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X))) #define FP_REGNO_P(n) ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) #define STACK_REG_P(xop) (REG_P (xop) && \ REGNO (xop) >= FIRST_STACK_REG && \ REGNO (xop) <= LAST_STACK_REG) #define NON_STACK_REG_P(xop) (REG_P (xop) && ! STACK_REG_P (xop)) #define STACK_TOP_P(xop) (REG_P (xop) && REGNO (xop) == FIRST_STACK_REG) /* Try to maintain the accuracy of the death notes for regs satisfying the following. Important for stack like regs, to know when to pop. */ /* #define PRESERVE_DEATH_INFO_REGNO_P(x) FP_REGNO_P(x) */ /* 1 if register REGNO can magically overlap other regs. Note that nonzero values work only in very special circumstances. */ /* #define OVERLAPPING_REGNO_P(REGNO) FP_REGNO_P (REGNO) */ /* The class value for index registers, and the one for base regs. */ #define INDEX_REG_CLASS INDEX_REGS #define BASE_REG_CLASS GENERAL_REGS /* Get reg_class from a letter such as appears in the machine description. */ #define REG_CLASS_FROM_LETTER(C) \ ((C) == 'r' ? GENERAL_REGS : \ (C) == 'q' ? Q_REGS : \ (C) == 'f' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \ ? FLOAT_REGS \ : NO_REGS) : \ (C) == 't' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \ ? FP_TOP_REG \ : NO_REGS) : \ (C) == 'u' ? (TARGET_80387 || TARGET_FLOAT_RETURNS_IN_80387 \ ? FP_SECOND_REG \ : NO_REGS) : \ (C) == 'a' ? AREG : \ (C) == 'b' ? BREG : \ (C) == 'c' ? CREG : \ (C) == 'd' ? DREG : \ (C) == 'D' ? DIREG : \ (C) == 'S' ? SIREG : NO_REGS) /* The letters I, J, K, L and M in a register constraint string can be used to stand for particular ranges of immediate operands. This macro defines what the ranges are. C is the letter, and VALUE is a constant value. Return 1 if VALUE is in the range specified by C. I is for non-DImode shifts. J is for DImode shifts. K and L are for an `andsi' optimization. M is for shifts that can be executed by the "lea" opcode. */ #define CONST_OK_FOR_LETTER_P(VALUE, C) \ ((C) == 'I' ? (VALUE) >= 0 && (VALUE) <= 31 : \ (C) == 'J' ? (VALUE) >= 0 && (VALUE) <= 63 : \ (C) == 'K' ? (VALUE) == 0xff : \ (C) == 'L' ? (VALUE) == 0xffff : \ (C) == 'M' ? (VALUE) >= 0 && (VALUE) <= 3 : \ 0) /* Similar, but for floating constants, and defining letters G and H. Here VALUE is the CONST_DOUBLE rtx itself. We allow constants even if TARGET_387 isn't set, because the stack register converter may need to load 0.0 into the function value register. */ #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ ((C) == 'G' ? standard_80387_constant_p (VALUE) : 0) /* Place additional restrictions on the register class to use when it is necessary to be able to hold a value of mode MODE in a reload register for which class CLASS would ordinarily be used. */ #define LIMIT_RELOAD_CLASS(MODE, CLASS) \ ((MODE) == QImode && ((CLASS) == ALL_REGS || (CLASS) == GENERAL_REGS) \ ? Q_REGS : (CLASS)) /* Given an rtx X being reloaded into a reg required to be in class CLASS, return the class of reg to actually use. In general this is just CLASS; but on some machines in some cases it is preferable to use a more restrictive class. On the 80386 series, we prevent floating constants from being reloaded into floating registers (since no move-insn can do that) and we ensure that QImodes aren't reloaded into the esi or edi reg. */ /* Put float CONST_DOUBLE in the constant pool instead of fp regs. QImode must go into class Q_REGS. Narrow ALL_REGS to GENERAL_REGS. This supports allowing movsf and movdf to do mem-to-mem moves through integer regs. */ #define PREFERRED_RELOAD_CLASS(X,CLASS) \ (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) != VOIDmode ? NO_REGS \ : GET_MODE (X) == QImode && ! reg_class_subset_p (CLASS, Q_REGS) ? Q_REGS \ : ((CLASS) == ALL_REGS \ && GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT) ? GENERAL_REGS \ : (CLASS)) /* If we are copying between general and FP registers, we need a memory location. */ #define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) \ ((FLOAT_CLASS_P (CLASS1) && ! FLOAT_CLASS_P (CLASS2)) \ || (! FLOAT_CLASS_P (CLASS1) && FLOAT_CLASS_P (CLASS2))) /* Return the maximum number of consecutive registers needed to represent mode MODE in a register of class CLASS. */ /* On the 80386, this is the size of MODE in words, except in the FP regs, where a single reg is always enough. */ #define CLASS_MAX_NREGS(CLASS, MODE) \ (FLOAT_CLASS_P (CLASS) ? 1 : \ ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)) /* Stack layout; function entry, exit and calling. */ /* Define this if pushing a word on the stack makes the stack pointer a smaller address. */ #define STACK_GROWS_DOWNWARD /* Define this if the nominal address of the stack frame is at the high-address end of the local variables; that is, each additional local variable allocated goes at a more negative offset in the frame. */ #define FRAME_GROWS_DOWNWARD /* Offset within stack frame to start allocating local variables at. If FRAME_GROWS_DOWNWARD, this is the offset to the END of the first local allocated. Otherwise, it is the offset to the BEGINNING of the first local allocated. */ #define STARTING_FRAME_OFFSET 0 /* If we generate an insn to push BYTES bytes, this says how many the stack pointer really advances by. On 386 pushw decrements by exactly 2 no matter what the position was. On the 386 there is no pushb; we use pushw instead, and this has the effect of rounding up to 2. */ #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & (-2)) /* Offset of first parameter from the argument pointer register value. */ #define FIRST_PARM_OFFSET(FNDECL) 0 /* Value is the number of bytes of arguments automatically popped when returning from a subroutine call. FUNTYPE is the data type of the function (as a tree), or for a library call it is an identifier node for the subroutine name. SIZE is the number of bytes of arguments passed on the stack. On the 80386, the RTD insn may be used to pop them if the number of args is fixed, but if the number is variable then the caller must pop them all. RTD can't be used for library calls now because the library is compiled with the Unix compiler. Use of RTD is a selectable option, since it is incompatible with standard Unix calling sequences. If the option is not selected, the caller must always pop the args. */ #define RETURN_POPS_ARGS(FUNTYPE,SIZE) \ (TREE_CODE (FUNTYPE) == IDENTIFIER_NODE ? 0 \ : (TARGET_RTD \ && (TYPE_ARG_TYPES (FUNTYPE) == 0 \ || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \ == void_type_node))) ? (SIZE) \ : (aggregate_value_p (FUNTYPE)) ? GET_MODE_SIZE (Pmode) : 0) /* Define how to find the value returned by a function. VALTYPE is the data type of the value (as a tree). If the precise function being called is known, FUNC is its FUNCTION_DECL; otherwise, FUNC is 0. */ #define FUNCTION_VALUE(VALTYPE, FUNC) \ gen_rtx (REG, TYPE_MODE (VALTYPE), \ VALUE_REGNO (TYPE_MODE (VALTYPE))) /* Define how to find the value returned by a library function assuming the value has mode MODE. */ #define LIBCALL_VALUE(MODE) \ gen_rtx (REG, MODE, VALUE_REGNO (MODE)) /* Define the size of the result block used for communication between untyped_call and untyped_return. The block contains a DImode value followed by the block used by fnsave and frstor. */ #define APPLY_RESULT_SIZE (8+108) /* 1 if N is a possible register number for function argument passing. On the 80386, no registers are used in this way. *NOTE* -mregparm does not work. It exists only to test register calling conventions. */ #define FUNCTION_ARG_REGNO_P(N) 0 /* Define a data type for recording info about an argument list during the scan of that argument list. This data type should hold all necessary information about the function itself and about the args processed so far, enough to enable macros such as FUNCTION_ARG to determine where the next arg should go. On the 80386, this is a single integer, which is a number of bytes of arguments scanned so far. */ #define CUMULATIVE_ARGS int /* Initialize a variable CUM of type CUMULATIVE_ARGS for a call to a function whose data type is FNTYPE. For a library call, FNTYPE is 0. On the 80386, the offset starts at 0. */ #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME) \ ((CUM) = 0) /* Update the data in CUM to advance over an argument of mode MODE and data type TYPE. (TYPE is null for libcalls where that information may not be available.) */ #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ ((CUM) += ((MODE) != BLKmode \ ? (GET_MODE_SIZE (MODE) + 3) & ~3 \ : (int_size_in_bytes (TYPE) + 3) & ~3)) /* Define where to put the arguments to a function. Value is zero to push the argument on the stack, or a hard register in which to store the argument. MODE is the argument's machine mode. TYPE is the data type of the argument (as a tree). This is null for libcalls where that information may not be available. CUM is a variable of type CUMULATIVE_ARGS which gives info about the preceding args and about the function being called. NAMED is nonzero if this argument is a named parameter (otherwise it is an extra parameter matching an ellipsis). */ /* On the 80386 all args are pushed, except if -mregparm is specified then the first two words of arguments are passed in EAX, EDX. *NOTE* -mregparm does not work. It exists only to test register calling conventions. */ #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ ((TARGET_REGPARM && (CUM) < 8) ? gen_rtx (REG, (MODE), (CUM) / 4) : 0) /* For an arg passed partly in registers and partly in memory, this is the number of registers used. For args passed entirely in registers or entirely in memory, zero. */ #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \ ((TARGET_REGPARM && (CUM) < 8 \ && 8 < ((CUM) + ((MODE) == BLKmode \ ? int_size_in_bytes (TYPE) \ : GET_MODE_SIZE (MODE)))) \ ? 2 - (CUM) / 4 : 0) /* This macro generates the assembly code for function entry. FILE is a stdio stream to output the code to. SIZE is an int: how many units of temporary storage to allocate. Refer to the array `regs_ever_live' to determine which registers to save; `regs_ever_live[I]' is nonzero if register number I is ever used in the function. This macro is responsible for knowing which registers should not be saved even if used. */ #define FUNCTION_PROLOGUE(FILE, SIZE) \ function_prologue (FILE, SIZE) /* Output assembler code to FILE to increment profiler label # LABELNO for profiling a function entry. */ #define FUNCTION_PROFILER(FILE, LABELNO) \ { \ if (flag_pic) \ { \ fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ LPREFIX, (LABELNO)); \ fprintf (FILE, "\tcall *_mcount@GOT(%%ebx)\n"); \ } \ else \ { \ fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \ fprintf (FILE, "\tcall _mcount\n"); \ } \ } /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, the stack pointer does not matter. The value is tested only in functions that have frame pointers. No definition is equivalent to always zero. */ /* Note on the 386 it might be more efficient not to define this since we have to restore it ourselves from the frame pointer, in order to use pop */ #define EXIT_IGNORE_STACK 1 /* This macro generates the assembly code for function exit, on machines that need it. If FUNCTION_EPILOGUE is not defined then individual return instructions are generated for each return statement. Args are same as for FUNCTION_PROLOGUE. The function epilogue should not depend on the current stack pointer! It should use the frame pointer only. This is mandatory because of alloca; we also take advantage of it to omit stack adjustments before returning. If the last non-note insn in the function is a BARRIER, then there is no need to emit a function prologue, because control does not fall off the end. This happens if the function ends in an "exit" call, or if a `return' insn is emitted directly into the function. */ #define FUNCTION_EPILOGUE(FILE, SIZE) \ do { \ rtx last = get_last_insn (); \ if (last && GET_CODE (last) == NOTE) \ last = prev_nonnote_insn (last); \ if (! last || GET_CODE (last) != BARRIER) \ function_epilogue (FILE, SIZE); \ } while (0) /* Output assembler code for a block containing the constant parts of a trampoline, leaving space for the variable parts. */ /* On the 386, the trampoline contains three instructions: mov #STATIC,ecx mov #FUNCTION,eax jmp @eax */ #define TRAMPOLINE_TEMPLATE(FILE) \ { \ ASM_OUTPUT_CHAR (FILE, GEN_INT (0xb9)); \ ASM_OUTPUT_SHORT (FILE, const0_rtx); \ ASM_OUTPUT_SHORT (FILE, const0_rtx); \ ASM_OUTPUT_CHAR (FILE, GEN_INT (0xb8)); \ ASM_OUTPUT_SHORT (FILE, const0_rtx); \ ASM_OUTPUT_SHORT (FILE, const0_rtx); \ ASM_OUTPUT_CHAR (FILE, GEN_INT (0xff)); \ ASM_OUTPUT_CHAR (FILE, GEN_INT (0xe0)); \ } /* Length in units of the trampoline for entering a nested function. */ #define TRAMPOLINE_SIZE 12 /* Emit RTL insns to initialize the variable parts of a trampoline. FNADDR is an RTX for the address of the function's pure code. CXT is an RTX for the static chain value for the function. */ #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \ { \ emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 1)), CXT); \ emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 6)), FNADDR); \ } /* Definitions for register eliminations. This is an array of structures. Each structure initializes one pair of eliminable registers. The "from" register number is given first, followed by "to". Eliminations of the same "from" register are listed in order of preference. We have two registers that can be eliminated on the i386. First, the frame pointer register can often be eliminated in favor of the stack pointer register. Secondly, the argument pointer register can always be eliminated; it is replaced with either the stack or frame pointer. */ #define ELIMINABLE_REGS \ {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \ { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}} /* Given FROM and TO register numbers, say whether this elimination is allowed. Frame pointer elimination is automatically handled. For the i386, if frame pointer elimination is being done, we would like to convert ap into sp, not fp. All other eliminations are valid. */ #define CAN_ELIMINATE(FROM, TO) \ ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM \ ? ! frame_pointer_needed \ : 1) /* Define the offset between two registers, one to be eliminated, and the other its replacement, at the start of a routine. */ #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ { \ if ((FROM) == ARG_POINTER_REGNUM && (TO) == FRAME_POINTER_REGNUM) \ (OFFSET) = 8; /* Skip saved PC and previous frame pointer */ \ else \ { \ int regno; \ int offset = 0; \ \ for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) \ if ((regs_ever_live[regno] && ! call_used_regs[regno]) \ || (current_function_uses_pic_offset_table \ && regno == PIC_OFFSET_TABLE_REGNUM)) \ offset += 4; \ \ (OFFSET) = offset + get_frame_size (); \ \ if ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM) \ (OFFSET) += 4; /* Skip saved PC */ \ } \ } /* Addressing modes, and classification of registers for them. */ /* #define HAVE_POST_INCREMENT */ /* #define HAVE_POST_DECREMENT */ /* #define HAVE_PRE_DECREMENT */ /* #define HAVE_PRE_INCREMENT */ /* Macros to check register numbers against specific register classes. */ /* These assume that REGNO is a hard or pseudo reg number. They give nonzero only if REGNO is a hard reg of the suitable class or a pseudo reg currently allocated to a suitable hard reg. Since they use reg_renumber, they are safe only once reg_renumber has been allocated, which happens in local-alloc.c. */ #define REGNO_OK_FOR_INDEX_P(REGNO) \ ((REGNO) < STACK_POINTER_REGNUM \ || (unsigned) reg_renumber[REGNO] < STACK_POINTER_REGNUM) #define REGNO_OK_FOR_BASE_P(REGNO) \ ((REGNO) <= STACK_POINTER_REGNUM \ || (REGNO) == ARG_POINTER_REGNUM \ || (unsigned) reg_renumber[REGNO] <= STACK_POINTER_REGNUM) #define REGNO_OK_FOR_SIREG_P(REGNO) ((REGNO) == 4 || reg_renumber[REGNO] == 4) #define REGNO_OK_FOR_DIREG_P(REGNO) ((REGNO) == 5 || reg_renumber[REGNO] == 5) /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx and check its validity for a certain class. We have two alternate definitions for each of them. The usual definition accepts all pseudo regs; the other rejects them unless they have been allocated suitable hard regs. The symbol REG_OK_STRICT causes the latter definition to be used. Most source files want to accept pseudo regs in the hope that they will get allocated to the class that the insn wants them to be in. Source files for reload pass need to be strict. After reload, it makes no difference, since pseudo regs have been eliminated by then. */ #ifndef REG_OK_STRICT /* Nonzero if X is a hard reg that can be used as an index or if it is a pseudo reg. */ #define REG_OK_FOR_INDEX_P(X) \ (REGNO (X) < STACK_POINTER_REGNUM \ || REGNO (X) >= FIRST_PSEUDO_REGISTER) /* Nonzero if X is a hard reg that can be used as a base reg of if it is a pseudo reg. */ /* ?wfs */ #define REG_OK_FOR_BASE_P(X) \ (REGNO (X) <= STACK_POINTER_REGNUM \ || REGNO (X) == ARG_POINTER_REGNUM \ || REGNO(X) >= FIRST_PSEUDO_REGISTER) #define REG_OK_FOR_STRREG_P(X) \ (REGNO (X) == 4 || REGNO (X) == 5 || REGNO (X) >= FIRST_PSEUDO_REGISTER) #else /* Nonzero if X is a hard reg that can be used as an index. */ #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X)) /* Nonzero if X is a hard reg that can be used as a base reg. */ #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) #define REG_OK_FOR_STRREG_P(X) \ (REGNO_OK_FOR_DIREG_P (REGNO (X)) || REGNO_OK_FOR_SIREG_P (REGNO (X))) #endif /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression that is a valid memory address for an instruction. The MODE argument is the machine mode for the MEM expression that wants to use this address. The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS, except for CONSTANT_ADDRESS_P which is usually machine-independent. See legitimize_pic_address in i386.c for details as to what constitutes a legitimate address when -fpic is used. */ #define MAX_REGS_PER_ADDRESS 2 #define CONSTANT_ADDRESS_P(X) \ (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \ || GET_CODE (X) == HIGH) /* Nonzero if the constant value X is a legitimate general operand. It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ #define LEGITIMATE_CONSTANT_P(X) 1 #define GO_IF_INDEXABLE_BASE(X, ADDR) \ if (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) goto ADDR #define LEGITIMATE_INDEX_REG_P(X) \ (GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) /* Return 1 if X is an index or an index times a scale. */ #define LEGITIMATE_INDEX_P(X) \ (LEGITIMATE_INDEX_REG_P (X) \ || (GET_CODE (X) == MULT \ && LEGITIMATE_INDEX_REG_P (XEXP (X, 0)) \ && GET_CODE (XEXP (X, 1)) == CONST_INT \ && (INTVAL (XEXP (X, 1)) == 2 \ || INTVAL (XEXP (X, 1)) == 4 \ || INTVAL (XEXP (X, 1)) == 8))) /* Go to ADDR if X is an index term, a base reg, or a sum of those. */ #define GO_IF_INDEXING(X, ADDR) \ { if (LEGITIMATE_INDEX_P (X)) goto ADDR; \ GO_IF_INDEXABLE_BASE (X, ADDR); \ if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 0))) \ { GO_IF_INDEXABLE_BASE (XEXP (X, 1), ADDR); } \ if (GET_CODE (X) == PLUS && LEGITIMATE_INDEX_P (XEXP (X, 1))) \ { GO_IF_INDEXABLE_BASE (XEXP (X, 0), ADDR); } } /* We used to allow this, but it isn't ever used. || ((GET_CODE (X) == POST_DEC || GET_CODE (X) == POST_INC) \ && REG_P (XEXP (X, 0)) \ && REG_OK_FOR_STRREG_P (XEXP (X, 0))) \ */ #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ { \ if (CONSTANT_ADDRESS_P (X) \ && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (X))) \ goto ADDR; \ GO_IF_INDEXING (X, ADDR); \ if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \ { \ rtx x0 = XEXP (X, 0); \ if (! flag_pic || ! SYMBOLIC_CONST (XEXP (X, 1))) \ { GO_IF_INDEXING (x0, ADDR); } \ else if (x0 == pic_offset_table_rtx) \ goto ADDR; \ else if (GET_CODE (x0) == PLUS) \ { \ if (XEXP (x0, 0) == pic_offset_table_rtx) \ { GO_IF_INDEXABLE_BASE (XEXP (x0, 1), ADDR); } \ if (XEXP (x0, 1) == pic_offset_table_rtx) \ { GO_IF_INDEXABLE_BASE (XEXP (x0, 0), ADDR); } \ } \ } \ } /* Try machine-dependent ways of modifying an illegitimate address to be legitimate. If we find one, return the new, valid address. This macro is used in only one place: `memory_address' in explow.c. OLDX is the address as it was before break_out_memory_refs was called. In some cases it is useful to look at this to decide what needs to be done. MODE and WIN are passed so that this macro can use GO_IF_LEGITIMATE_ADDRESS. It is always safe for this macro to do nothing. It exists to recognize opportunities to optimize the output. For the 80386, we handle X+REG by loading X into a register R and using R+REG. R will go in a general reg and indexing will be used. However, if REG is a broken-out memory address or multiplication, nothing needs to be done because REG can certainly go in a general reg. When -fpic is used, special handling is needed for symbolic references. See comments by legitimize_pic_address in i386.c for details. */ #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \ { extern rtx legitimize_pic_address (); \ int ch = (X) != (OLDX); \ if (flag_pic && SYMBOLIC_CONST (X)) \ { \ (X) = legitimize_pic_address (X, 0); \ if (memory_address_p (MODE, X)) \ goto WIN; \ } \ if (GET_CODE (X) == PLUS) \ { if (GET_CODE (XEXP (X, 0)) == MULT) \ ch = 1, XEXP (X, 0) = force_operand (XEXP (X, 0), 0); \ if (GET_CODE (XEXP (X, 1)) == MULT) \ ch = 1, XEXP (X, 1) = force_operand (XEXP (X, 1), 0); \ if (ch && GET_CODE (XEXP (X, 1)) == REG \ && GET_CODE (XEXP (X, 0)) == REG) \ goto WIN; \ if (flag_pic && SYMBOLIC_CONST (XEXP (X, 1))) \ ch = 1, (X) = legitimize_pic_address (X, 0); \ if (ch) { GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN); } \ if (GET_CODE (XEXP (X, 0)) == REG) \ { register rtx temp = gen_reg_rtx (Pmode); \ register rtx val = force_operand (XEXP (X, 1), temp); \ if (val != temp) emit_move_insn (temp, val); \ XEXP (X, 1) = temp; \ goto WIN; } \ else if (GET_CODE (XEXP (X, 1)) == REG) \ { register rtx temp = gen_reg_rtx (Pmode); \ register rtx val = force_operand (XEXP (X, 0), temp); \ if (val != temp) emit_move_insn (temp, val); \ XEXP (X, 0) = temp; \ goto WIN; }}} /* Nonzero if the constant value X is a legitimate general operand when generating PIC code. It is given that flag_pic is on and that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ #define LEGITIMATE_PIC_OPERAND_P(X) \ (! SYMBOLIC_CONST (X) \ || (GET_CODE (X) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (X))) #define SYMBOLIC_CONST(X) \ (GET_CODE (X) == SYMBOL_REF \ || GET_CODE (X) == LABEL_REF \ || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X))) /* Go to LABEL if ADDR (a legitimate address expression) has an effect that depends on the machine mode it is used for. On the 80386, only postdecrement and postincrement address depend thus (the amount of decrement or increment being the length of the operand). */ #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \ if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == POST_DEC) goto LABEL /* Define this macro if references to a symbol must be treated differently depending on something about the variable or function named by the symbol (such as what section it is in). On i386, if using PIC, mark a SYMBOL_REF for a non-global symbol so that we may access it directly in the GOT. */ #define ENCODE_SECTION_INFO(DECL) \ do \ { \ if (flag_pic) \ { \ rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \ SYMBOL_REF_FLAG (XEXP (rtl, 0)) \ = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ || ! TREE_PUBLIC (DECL)); \ } \ } \ while (0) /* Initialize data used by insn expanders. This is called from init_emit, once for each function, before code is generated. For 386, clear stack slot assignments remembered from previous functions. */ #define INIT_EXPANDERS clear_386_stack_locals () /* Specify the machine mode that this machine uses for the index in the tablejump instruction. */ #define CASE_VECTOR_MODE Pmode /* Define this if the tablejump instruction expects the table to contain offsets from the address of the table. Do not define this if the table should contain absolute addresses. */ /* #define CASE_VECTOR_PC_RELATIVE */ /* Specify the tree operation to be used to convert reals to integers. This should be changed to take advantage of fist --wfs ?? */ #define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR /* This is the kind of divide that is easiest to do in the general case. */ #define EASY_DIV_EXPR TRUNC_DIV_EXPR /* Define this as 1 if `char' should by default be signed; else as 0. */ #define DEFAULT_SIGNED_CHAR 1 /* Max number of bytes we can move from memory to memory in one reasonably fast instruction. */ #define MOVE_MAX 4 /* MOVE_RATIO is the number of move instructions that is better than a block move. Make this large on i386, since the block move is very inefficient with small blocks, and the hard register needs of the block move require much reload work. */ #define MOVE_RATIO 5 /* Define this if zero-extension is slow (more than one real instruction). */ /* #define SLOW_ZERO_EXTEND */ /* Nonzero if access to memory by bytes is slow and undesirable. */ #define SLOW_BYTE_ACCESS 0 /* Define if shifts truncate the shift count which implies one can omit a sign-extension or zero-extension of a shift count. */ /* One i386, shifts do truncate the count. But bit opcodes don't. */ /* #define SHIFT_COUNT_TRUNCATED */ /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits is done just by pretending it is already truncated. */ #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 /* We assume that the store-condition-codes instructions store 0 for false and some other value for true. This is the value stored for true. */ #define STORE_FLAG_VALUE 1 /* When a prototype says `char' or `short', really pass an `int'. (The 386 can't easily push less than an int.) */ #define PROMOTE_PROTOTYPES /* Specify the machine mode that pointers have. After generation of rtl, the compiler makes no further distinction between pointers and any other objects of this machine mode. */ #define Pmode SImode /* A function address in a call instruction is a byte address (for indexing purposes) so give the MEM rtx a byte's mode. */ #define FUNCTION_MODE QImode /* Define this if addresses of constant functions shouldn't be put through pseudo regs where they can be cse'd. Desirable on the 386 because a CALL with a constant address is not much slower than one with a register address. */ #define NO_FUNCTION_CSE /* Provide the costs of a rtl expression. This is in the body of a switch on CODE. */ #define RTX_COSTS(X,CODE,OUTER_CODE) \ case MULT: \ return COSTS_N_INSNS (10); \ case DIV: \ case UDIV: \ case MOD: \ case UMOD: \ return COSTS_N_INSNS (40); \ case PLUS: \ if (GET_CODE (XEXP (X, 0)) == REG \ && GET_CODE (XEXP (X, 1)) == CONST_INT) \ return 1; \ break; /* Compute the cost of computing a constant rtl expression RTX whose rtx-code is CODE. The body of this macro is a portion of a switch statement. If the code is computed here, return it with a return statement. Otherwise, break from the switch. */ #define CONST_COSTS(RTX,CODE,OUTER_CODE) \ case CONST_INT: \ case CONST: \ case LABEL_REF: \ case SYMBOL_REF: \ return flag_pic && SYMBOLIC_CONST (RTX) ? 2 : 0; \ case CONST_DOUBLE: \ { \ int code; \ if (GET_MODE (RTX) == VOIDmode) \ return 2; \ code = standard_80387_constant_p (RTX); \ return code == 1 ? 0 : \ code == 2 ? 1 : \ 2; \ } /* Compute the cost of an address. This is meant to approximate the size and/or execution delay of an insn using that address. If the cost is approximated by the RTL complexity, including CONST_COSTS above, as is usually the case for CISC machines, this macro should not be defined. For aggressively RISCy machines, only one insn format is allowed, so this macro should be a constant. The value of this macro only matters for valid addresses. For i386, it is better to use a complex address than let gcc copy the address into a reg and make a new pseudo. But not if the address requires to two regs - that would mean more pseudos with longer lifetimes. */ #define ADDRESS_COST(RTX) \ ((CONSTANT_P (RTX) \ || (GET_CODE (RTX) == PLUS && CONSTANT_P (XEXP (RTX, 1)) \ && REG_P (XEXP (RTX, 0)))) ? 0 \ : REG_P (RTX) ? 1 \ : 2) /* Add any extra modes needed to represent the condition code. For the i386, we need separate modes when floating-point equality comparisons are being done. */ #define EXTRA_CC_MODES CCFPEQmode /* Define the names for the modes specified above. */ #define EXTRA_CC_NAMES "CCFPEQ" /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE, return the mode to be used for the comparison. For floating-point equality comparisons, CCFPEQmode should be used. VOIDmode should be used in all other cases. */ #define SELECT_CC_MODE(OP,X,Y) \ (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \ && ((OP) == EQ || (OP) == NE) ? CCFPEQmode : VOIDmode) /* Define the information needed to generate branch and scc insns. This is stored from the compare operation. Note that we can't use "rtx" here since it hasn't been defined! */ extern struct rtx_def *i386_compare_op0, *i386_compare_op1; extern struct rtx_def *(*i386_compare_gen)(), *(*i386_compare_gen_eq)(); /* Tell final.c how to eliminate redundant test instructions. */ /* Here we define machine-dependent flags and fields in cc_status (see `conditions.h'). */ /* Set if the cc value is actually in the 80387, so a floating point conditional branch must be output. */ #define CC_IN_80387 04000 /* Set if the CC value was stored in a nonstandard way, so that the state of equality is indicated by zero in the carry bit. */ #define CC_Z_IN_NOT_C 010000 /* Store in cc_status the expressions that the condition codes will describe after execution of an instruction whose pattern is EXP. Do not alter them if the instruction would not alter the cc's. */ #define NOTICE_UPDATE_CC(EXP, INSN) \ notice_update_cc((EXP)) /* Output a signed jump insn. Use template NORMAL ordinarily, or FLOAT following a floating point comparison. Use NO_OV following an arithmetic insn that set the cc's before a test insn that was deleted. NO_OV may be zero, meaning final should reinsert the test insn because the jump cannot be handled properly without it. */ #define OUTPUT_JUMP(NORMAL, FLOAT, NO_OV) \ { \ if (cc_prev_status.flags & CC_IN_80387) \ return FLOAT; \ if (cc_prev_status.flags & CC_NO_OVERFLOW) \ return NO_OV; \ return NORMAL; \ } /* Control the assembler format that we output, to the extent this does not vary between assemblers. */ /* How to refer to registers in assembler output. This sequence is indexed by compiler's hard-register-number (see above). */ /* In order to refer to the first 8 regs as 32 bit regs prefix an "e" For non floating point regs, the following are the HImode names. For float regs, the stack top is sometimes referred to as "%st(0)" instead of just "%st". PRINT_REG handles this with the "y" code. */ #define HI_REGISTER_NAMES \ {"ax","dx","cx","bx","si","di","bp","sp", \ "st","st(1)","st(2)","st(3)","st(4)","st(5)","st(6)","st(7)","" } #define REGISTER_NAMES HI_REGISTER_NAMES /* Table of additional register names to use in user input. */ #define ADDITIONAL_REGISTER_NAMES \ { "eax", 0, "edx", 1, "ecx", 2, "ebx", 3, \ "esi", 4, "edi", 5, "ebp", 6, "esp", 7, \ "al", 0, "dl", 1, "cl", 2, "bl", 3, \ "ah", 0, "dh", 1, "ch", 2, "bh", 3 } /* Note we are omitting these since currently I don't know how to get gcc to use these, since they want the same but different number as al, and ax. */ /* note the last four are not really qi_registers, but the md will have to never output movb into one of them only a movw . There is no movb into the last four regs */ #define QI_REGISTER_NAMES \ {"al", "dl", "cl", "bl", "si", "di", "bp", "sp",} /* These parallel the array above, and can be used to access bits 8:15 of regs 0 through 3. */ #define QI_HIGH_REGISTER_NAMES \ {"ah", "dh", "ch", "bh", } /* How to renumber registers for dbx and gdb. */ /* {0,2,1,3,6,7,4,5,12,13,14,15,16,17} */ #define DBX_REGISTER_NUMBER(n) \ ((n) == 0 ? 0 : \ (n) == 1 ? 2 : \ (n) == 2 ? 1 : \ (n) == 3 ? 3 : \ (n) == 4 ? 6 : \ (n) == 5 ? 7 : \ (n) == 6 ? 4 : \ (n) == 7 ? 5 : \ (n) + 4) /* This is how to output the definition of a user-level label named NAME, such as the label on a static function or variable NAME. */ #define ASM_OUTPUT_LABEL(FILE,NAME) \ (assemble_name (FILE, NAME), fputs (":\n", FILE)) /* This is how to output an assembler line defining a `double' constant. */ #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \ fprintf (FILE, "%s %.22e\n", ASM_DOUBLE, (VALUE)) /* This is how to output an assembler line defining a `float' constant. */ #define ASM_OUTPUT_FLOAT(FILE,VALUE) \ do { union { float f; long l;} tem; \ tem.f = (VALUE); \ fprintf((FILE), "%s 0x%x\n", ASM_LONG, tem.l); \ } while (0) /* Store in OUTPUT a string (made with alloca) containing an assembler-name for a local static variable named NAME. LABELNO is an integer which is different for each call. */ #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \ sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO))) /* This is how to output an assembler line defining an `int' constant. */ #define ASM_OUTPUT_INT(FILE,VALUE) \ ( fprintf (FILE, "%s ", ASM_LONG), \ output_addr_const (FILE,(VALUE)), \ putc('\n',FILE)) /* Likewise for `char' and `short' constants. */ /* is this supposed to do align too?? */ #define ASM_OUTPUT_SHORT(FILE,VALUE) \ ( fprintf (FILE, "%s ", ASM_SHORT), \ output_addr_const (FILE,(VALUE)), \ putc('\n',FILE)) /* #define ASM_OUTPUT_SHORT(FILE,VALUE) \ ( fprintf (FILE, "%s ", ASM_BYTE_OP), \ output_addr_const (FILE,(VALUE)), \ fputs (",", FILE), \ output_addr_const (FILE,(VALUE)), \ fputs (" >> 8\n",FILE)) */ #define ASM_OUTPUT_CHAR(FILE,VALUE) \ ( fprintf (FILE, "%s ", ASM_BYTE_OP), \ output_addr_const (FILE, (VALUE)), \ putc ('\n', FILE)) /* This is how to output an assembler line for a numeric constant byte. */ #define ASM_OUTPUT_BYTE(FILE,VALUE) \ fprintf ((FILE), "%s 0x%x\n", ASM_BYTE_OP, (VALUE)) /* This is how to output an insn to push a register on the stack. It need not be very fast code. */ #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \ fprintf (FILE, "\tpushl e%s\n", reg_names[REGNO]) /* This is how to output an insn to pop a register from the stack. It need not be very fast code. */ #define ASM_OUTPUT_REG_POP(FILE,REGNO) \ fprintf (FILE, "\tpopl e%s\n", reg_names[REGNO]) /* This is how to output an element of a case-vector that is absolute. */ #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ fprintf (FILE, "%s %s%d\n", ASM_LONG, LPREFIX, VALUE) /* This is how to output an element of a case-vector that is relative. We don't use these on the 386 yet, because the ATT assembler can't do forward reference the differences. */ #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \ fprintf (FILE, "\t.word %s%d-%s%d\n",LPREFIX, VALUE,LPREFIX, REL) /* Define the parentheses used to group arithmetic operations in assembler code. */ #define ASM_OPEN_PAREN "" #define ASM_CLOSE_PAREN "" /* Define results of standard character escape sequences. */ #define TARGET_BELL 007 #define TARGET_BS 010 #define TARGET_TAB 011 #define TARGET_NEWLINE 012 #define TARGET_VT 013 #define TARGET_FF 014 #define TARGET_CR 015 /* Print operand X (an rtx) in assembler syntax to file FILE. CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. The CODE z takes the size of operand from the following digit, and outputs b,w,or l respectively. On the 80386, we use several such letters: f -- float insn (print a CONST_DOUBLE as a float rather than in hex). L,W,B,Q,S -- print the opcode suffix for specified size of operand. R -- print the prefix for register names. z -- print the opcode suffix for the size of the current operand. * -- print a star (in certain assembler syntax) w -- print the operand as if it's a "word" (HImode) even if it isn't. b -- print the operand as if it's a byte (QImode) even if it isn't. c -- don't print special prefixes before constant operands. */ #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \ ((CODE) == '*') /* Print the name of a register based on its machine mode and number. If CODE is 'w', pretend the mode is HImode. If CODE is 'b', pretend the mode is QImode. If CODE is 'k', pretend the mode is SImode. If CODE is 'h', pretend the reg is the `high' byte register. If CODE is 'y', print "st(0)" instead of "st", if the reg is stack op. */ extern char *hi_reg_name[]; extern char *qi_reg_name[]; extern char *qi_high_reg_name[]; #define PRINT_REG(X, CODE, FILE) \ do { if (REGNO (X) == ARG_POINTER_REGNUM) \ abort (); \ fprintf (FILE, "%s", RP); \ switch ((CODE == 'w' ? 2 \ : CODE == 'b' ? 1 \ : CODE == 'k' ? 4 \ : CODE == 'y' ? 3 \ : CODE == 'h' ? 0 \ : GET_MODE_SIZE (GET_MODE (X)))) \ { \ case 3: \ if (STACK_TOP_P (X)) \ { \ fputs ("st(0)", FILE); \ break; \ } \ case 4: \ case 8: \ if (! FP_REG_P (X)) fputs ("e", FILE); \ case 2: \ fputs (hi_reg_name[REGNO (X)], FILE); \ break; \ case 1: \ fputs (qi_reg_name[REGNO (X)], FILE); \ break; \ case 0: \ fputs (qi_high_reg_name[REGNO (X)], FILE); \ break; \ } \ } while (0) #define PRINT_OPERAND(FILE, X, CODE) \ print_operand (FILE, X, CODE) #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \ print_operand_address (FILE, ADDR) /* Print the name of a register for based on its machine mode and number. This macro is used to print debugging output. This macro is different from PRINT_REG in that it may be used in programs that are not linked with aux-output.o. */ #define DEBUG_PRINT_REG(X, CODE, FILE) \ do { static char *hi_name[] = HI_REGISTER_NAMES; \ static char *qi_name[] = QI_REGISTER_NAMES; \ fprintf (FILE, "%d %s", REGNO (X), RP); \ if (REGNO (X) == ARG_POINTER_REGNUM) \ { fputs ("argp", FILE); break; } \ if (STACK_TOP_P (X)) \ { fputs ("st(0)", FILE); break; } \ switch (GET_MODE_SIZE (GET_MODE (X))) \ { \ case 8: \ case 4: \ if (! FP_REG_P (X)) fputs ("e", FILE); \ case 2: \ fputs (hi_name[REGNO (X)], FILE); \ break; \ case 1: \ fputs (qi_name[REGNO (X)], FILE); \ break; \ } \ } while (0) /* Output the prefix for an immediate operand, or for an offset operand. */ #define PRINT_IMMED_PREFIX(FILE) fputs (IP, (FILE)) #define PRINT_OFFSET_PREFIX(FILE) fputs (IP, (FILE)) /* Routines in libgcc that return floats must return them in an fp reg, just as other functions do which return such values. These macros make that happen. */ #define FLOAT_VALUE_TYPE float #define INTIFY(FLOATVAL) FLOATVAL /* Nonzero if INSN magically clobbers register REGNO. */ /* #define INSN_CLOBBERS_REGNO_P(INSN, REGNO) \ (FP_REGNO_P (REGNO) \ && (GET_CODE (INSN) == JUMP_INSN || GET_CODE (INSN) == BARRIER)) */ /* a letter which is not needed by the normal asm syntax, which we can use for operand syntax in the extended asm */ #define ASM_OPERAND_LETTER '#' #define RET return "" #define AT_SP(mode) (gen_rtx (MEM, (mode), stack_pointer_rtx)) /* Local variables: version-control: t End: */ ./libc-linux/gcc/config/i386/bsd.h100644 1676 334 10601 5370313173 14547 0ustar hjlisl/* Definitions for BSD assembler syntax for Intel 386 (actually AT&T syntax for insns and operands, adapted to BSD conventions for symbol names and debugging.) Copyright (C) 1988 Free Software Foundation, Inc. This file is part of GNU CC. GNU CC 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. GNU CC 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. */ /* Include common aspects of all 386 Unix assemblers. */ #include "i386/unix.h" /* Use the Sequent Symmetry assembler syntax. */ #define TARGET_VERSION fprintf (stderr, " (80386, BSD syntax)"); /* Define the syntax of pseudo-ops, labels and comments. */ /* Prefix for internally generated assembler labels. If we aren't using underscores, we are using prefix `.'s to identify labels that should be ignored, as in `i386/gas.h' --karl@cs.umb.edu */ #ifdef NO_UNDERSCORES #define LPREFIX ".L" #else #define LPREFIX "L" #endif /* not NO_UNDERSCORES */ /* Assembler pseudos to introduce constants of various size. */ #define ASM_BYTE_OP "\t.byte" #define ASM_SHORT "\t.word" #define ASM_LONG "\t.long" #define ASM_DOUBLE "\t.double" /* Output at beginning of assembler file. ??? I am skeptical of this -- RMS. */ #define ASM_FILE_START(FILE) \ fprintf (FILE, "\t.file\t\"%s\"\n", dump_base_name); /* This was suggested, but it shouldn't be right for DBX output. -- RMS #define ASM_OUTPUT_SOURCE_FILENAME(FILE, NAME) */ /* Define the syntax of labels and symbol definitions/declarations. */ /* This is how to output an assembler line that says to advance the location counter by SIZE bytes. */ #define ASM_OUTPUT_SKIP(FILE,SIZE) \ fprintf (FILE, "\t.space %u\n", (SIZE)) /* Define the syntax of labels and symbol definitions/declarations. */ /* This says how to output an assembler line to define a global common symbol. */ #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ ( fputs (".comm ", (FILE)), \ assemble_name ((FILE), (NAME)), \ fprintf ((FILE), ",%u\n", (ROUNDED))) /* This says how to output an assembler line to define a local common symbol. */ #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ ( fputs (".lcomm ", (FILE)), \ assemble_name ((FILE), (NAME)), \ fprintf ((FILE), ",%u\n", (ROUNDED))) /* This is how to output an assembler line that says to advance the location counter to a multiple of 2**LOG bytes. */ #define ASM_OUTPUT_ALIGN(FILE,LOG) \ if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", (LOG)) /* This is how to store into the string BUF the symbol_ref name of an internal numbered label where PREFIX is the class of label and NUM is the number within the class. This is suitable for output with `assemble_name'. */ #ifdef NO_UNDERSCORES #define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ sprintf ((BUF), "*.%s%d", (PREFIX), (NUMBER)) #else #define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ sprintf ((BUF), "*%s%d", (PREFIX), (NUMBER)) #endif /* This is how to output an internal numbered label where PREFIX is the class of label and NUM is the number within the class. */ #ifdef NO_UNDERSCORES #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ fprintf (FILE, ".%s%d:\n", PREFIX, NUM) #else #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ fprintf (FILE, "%s%d:\n", PREFIX, NUM) #endif /* This is how to output a reference to a user-level label named NAME. */ #ifdef NO_UNDERSCORES #define ASM_OUTPUT_LABELREF(FILE,NAME) fprintf (FILE, "%s", NAME) #else #define ASM_OUTPUT_LABELREF(FILE,NAME) fprintf (FILE, "_%s", NAME) #endif /* not NO_UNDERSCORES */ /* Sequent has some changes in the format of DBX symbols. */ #define DBX_NO_XREFS 1 /* Don't split DBX symbols into continuations. */ #define DBX_CONTIN_LENGTH 0 /* This is how to output an assembler line defining a `double' constant. */ #undef ASM_OUTPUT_DOUBLE #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \ fprintf (FILE, "\t.double 0d%.20e\n", (VALUE)) ./libc-linux/gcc/config/i386/unix.h100644 1676 334 11137 5370313173 14767 0ustar hjlisl/* Definitions for Unix assembler syntax for the Intel 80386. Copyright (C) 1988 Free Software Foundation, Inc. This file is part of GNU CC. GNU CC 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. GNU CC 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. */ /* This file defines the aspects of assembler syntax that are the same for all the i386 Unix systems (though they may differ in non-Unix systems). */ /* Define some concatenation macros to concatenate an opcode and one, two or three operands. In other assembler syntaxes they may alter the order of ther operands. */ /* Note that the other files fail to use these in some of the places where they should. */ #ifdef __STDC__ #define AS2(a,b,c) #a " " #b "," #c #define AS3(a,b,c,d) #a " " #b "," #c "," #d #define AS1(a,b) #a " " #b #else #define AS1(a,b) "a b" #define AS2(a,b,c) "a b,c" #define AS3(a,b,c,d) "a b,c,d" #endif /* Define macro used to output shift-double opcodes when the shift count is in %cl. Some assemblers require %cl as an argument; some don't. This macro controls what to do: by default, don't print %cl. */ #define AS3_SHIFT_DOUBLE(a,b,c,d) AS2 (a,c,d) /* Output the size-letter for an opcode. CODE is the letter used in an operand spec (L, B, W, S or Q). CH is the corresponding lower case letter (except if CODE is `Q' then CH is `l', unless GAS_MNEMONICS). */ #define PUT_OP_SIZE(CODE,CH,FILE) putc (CH,(FILE)) /* Opcode suffix for fullword insn. */ #define L_SIZE "l" /* Prefix for register names in this syntax. */ #define RP "%" /* Prefix for immediate operands in this syntax. */ #define IP "$" /* Indirect call instructions should use `*'. */ #define USE_STAR 1 /* Prefix for a memory-operand X. */ #define PRINT_PTR(X, FILE) /* Delimiters that surround base reg and index reg. */ #define ADDR_BEG(FILE) putc('(', (FILE)) #define ADDR_END(FILE) putc(')', (FILE)) /* Print an index register (whose rtx is IREG). */ #define PRINT_IREG(FILE,IREG) \ do \ { fputs (",", (FILE)); PRINT_REG ((IREG), 0, (FILE)); } \ while (0) /* Print an index scale factor SCALE. */ #define PRINT_SCALE(FILE,SCALE) \ if ((SCALE) != 1) fprintf ((FILE), ",%d", (SCALE)) /* Print a base/index combination. BREG is the base reg rtx, IREG is the index reg rtx, and SCALE is the index scale factor (an integer). */ #define PRINT_B_I_S(BREG,IREG,SCALE,FILE) \ { ADDR_BEG (FILE); \ if (BREG) PRINT_REG ((BREG), 0, (FILE)); \ if ((IREG) != 0) \ { PRINT_IREG ((FILE), (IREG)); \ PRINT_SCALE ((FILE), (SCALE)); } \ ADDR_END (FILE); } /* Define the syntax of pseudo-ops, labels and comments. */ /* String containing the assembler's comment-starter. */ #define ASM_COMMENT_START "/" #define COMMENT_BEGIN "/" /* Output to assembler file text saying following lines may contain character constants, extra white space, comments, etc. */ #define ASM_APP_ON "/APP\n" /* Output to assembler file text saying following lines no longer contain unusual constructs. */ #define ASM_APP_OFF "/NO_APP\n" /* Output before read-only data. */ #define TEXT_SECTION_ASM_OP ".text" /* Output before writable (initialized) data. */ #define DATA_SECTION_ASM_OP ".data" /* Output before writable (uninitialized) data. */ #define BSS_SECTION_ASM_OP ".bss" /* This is how to output a command to make the user-level label named NAME defined for reference from other files. */ #define ASM_GLOBALIZE_LABEL(FILE,NAME) \ (fputs (".globl ", FILE), assemble_name (FILE, NAME), fputs ("\n", FILE)) /* By default, target has a 80387, uses IEEE compatible arithmetic, and returns float values in the 387, ie, (TARGET_80387 | TARGET_IEEE_FP | TARGET_FLOAT_RETURNS_IN_80387) */ #define TARGET_DEFAULT 0301 /* Floating-point return values come in the FP register. */ #define VALUE_REGNO(MODE) \ (GET_MODE_CLASS (MODE) == MODE_FLOAT \ && TARGET_FLOAT_RETURNS_IN_80387 ? FIRST_FLOAT_REG : 0) /* 1 if N is a possible register number for a function value. */ #define FUNCTION_VALUE_REGNO_P(N) \ ((N) == 0 || ((N)== FIRST_FLOAT_REG && TARGET_FLOAT_RETURNS_IN_80387)) ./libc-linux/gcc/config/i386/xm-svr3.h100644 1676 334 2041 5370313173 15275 0ustar hjlisl/* Configuration for GNU C-compiler for hosts running System V Release 3 Copyright (C) 1991 Free Software Foundation, Inc. This file is part of GNU CC. GNU CC 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. GNU CC 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. */ #define bcopy(src,dst,len) memcpy ((dst),(src),(len)) #define bzero(dst,len) memset ((dst),0,(len)) #define bcmp(left,right,len) memcmp ((left),(right),(len)) #define rindex strrchr #define index strchr #define USG #ifndef SVR3 #define SVR3 #endif ./libc-linux/gcc/config/i386/gstabs.h100644 1676 334 276 5370313173 15231 0ustar hjlisl#include "i386/gas.h" /* We do not want to output SDB debugging information. */ #undef SDB_DEBUGGING_INFO /* We want to output DBX debugging information. */ #define DBX_DEBUGGING_INFO ./libc-linux/gcc/config/i386/linux.h100644 1676 334 5313 5370313174 15123 0ustar hjlisl/* Definitions for Intel 386 running Linux * Copyright (C) 1992 Free Software Foundation, Inc. * * Written by H.J. Lu (hlu@eecs.wsu.edu) * * Linux is a POSIX.1 compatible UNIX clone for i386, which uses GNU * stuffs as the native stuffs. */ #if 0 /* The FSF has fixed the known bugs. But ....... */ /* Linux has a hacked gas 1.38.1, which can handle repz, repnz * and fildll. */ #define GOOD_GAS #endif /* This is tested by i386/gas.h. */ #define YES_UNDERSCORES #include "i386/gstabs.h" /* Specify predefined symbols in preprocessor. */ #undef CPP_PREDEFINES #define CPP_PREDEFINES "-Dunix -Di386 -Dlinux" #undef CPP_SPEC #if TARGET_CPU_DEFAULT == 2 #define CPP_SPEC "%{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE}" #else #define CPP_SPEC "%{m486:-D__i486__} %{posix:-D_POSIX_SOURCE}" #endif #undef SIZE_TYPE #define SIZE_TYPE "unsigned int" #undef PTRDIFF_TYPE #define PTRDIFF_TYPE "int" #undef WCHAR_TYPE #define WCHAR_TYPE "long int" #undef WCHAR_TYPE_SIZE #define WCHAR_TYPE_SIZE BITS_PER_WORD #undef HAVE_ATEXIT #define HAVE_ATEXIT /* Linux uses ctype from glibc.a. I am not sure how complete it is. * For now, we play safe. It may change later. */ #if 0 #undef MULTIBYTE_CHARS #define MULTIBYTE_CHARS 1 #endif #undef LIB_SPEC #define LIB_SPEC "%{g*:-lg} %{!g*:%{!p:%{!pg:-lc}}%{p:-lgmon -lc_p}%{pg:-lgmon -lc_p}}" #undef STARTFILE_SPEC #undef GPLUSPLUS_INCLUDE_DIR #ifdef CROSS_COMPILE /* * For cross-compile, we just need to search `$(tooldir)/lib' */ #define STARTFILE_SPEC \ "%{g*:crt0.o%s -static} %{!g*:%{pg:gcrt0.o%s -static} %{!pg:%{p:gcrt0.o%s -static} %{!p:crt0.o%s %{!static:%{nojump:-nojump}} %{static:-static}}}}" /* *The cross-compile uses this. */ #define GPLUSPLUS_INCLUDE_DIR TOOLDIR"/g++-include" #else #define STARTFILE_SPEC \ "%{g*:crt0.o%s -static} %{!g*:%{pg:gcrt0.o%s -static} %{!pg:%{p:gcrt0.o%s -static} %{!p:crt0.o%s %{!static:%{nojump:-nojump}} %{static:-static}}}}" /* *The native Linux system uses this. */ #define GPLUSPLUS_INCLUDE_DIR "/usr/g++-include" #endif /* There are conflicting reports about whether this system uses a different assembler syntax. wilson@cygnus.com says # is right. */ #undef COMMENT_BEGIN #define COMMENT_BEGIN "#" #undef ASM_APP_ON #define ASM_APP_ON "#APP\n" #undef ASM_APP_OFF #define ASM_APP_OFF "#NO_APP\n" /* Don't default to pcc-struct-return, because gcc is the only compiler, and we want to retain compatibility with older gcc versions. */ #define DEFAULT_PCC_STRUCT_RETURN 0 /* We need that too. */ #define HANDLE_SYSV_PRAGMA #undef LINK_SPEC /* We want to pass -v to linker */ #if TARGET_CPU_DEFAULT == 2 #define LINK_SPEC "%{v:-dll-verbose} %{!m386:-m486}" #else #define LINK_SPEC "%{v:-dll-verbose} %{m486:-m486}" #endif ./libc-linux/gcc/config/i386/xm-linux.h100644 1676 334 1002 5370313174 15534 0ustar hjlisl/* Configuration for GCC for Intel i386 running Linux. * * Written by H.J. Lu (hlu@eecs.wsu.edu) */ #include "i386/xm-i386.h" #include "xm-svr3.h" #undef BSTRING #define BSTRING #undef bcmp #undef bcopy #undef bzero #undef index #undef rindex #if 0 /* These conflict with stdlib.h in protoize, it is said, and there's no evidence they are actually needed. */ #undef malloc(n) #define malloc(n) malloc ((n) ? (n) : 1) #undef calloc(n,e) #define calloc(n,e) calloc (((n) ? (n) : 1), ((e) ? (e) : 1)) #endif ./libc-linux/gcc/config/xm-svr3.h100644 1676 334 2041 5370313174 14605 0ustar hjlisl/* Configuration for GNU C-compiler for hosts running System V Release 3 Copyright (C) 1991 Free Software Foundation, Inc. This file is part of GNU CC. GNU CC 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. GNU CC 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. */ #define bcopy(src,dst,len) memcpy ((dst),(src),(len)) #define bzero(dst,len) memset ((dst),0,(len)) #define bcmp(left,right,len) memcmp ((left),(right),(len)) #define rindex strrchr #define index strchr #define USG #ifndef SVR3 #define SVR3 #endif ./libc-linux/gcc/tm.h100644 1676 334 5443 5471532751 12460 0ustar hjlisl/* Definitions for Intel 386 running Linux * Copyright (C) 1992 Free Software Foundation, Inc. * * Written by H.J. Lu (hlu@eecs.wsu.edu) * * Linux is a POSIX.1 compatible UNIX clone for i386, which uses GNU * stuffs as the native stuffs. */ #if 0 /* The FSF has fixed the known bugs. But ....... */ /* Linux has a hacked gas 1.38.1, which can handle repz, repnz * and fildll. */ #define GOOD_GAS #endif /* This is tested by i386/gas.h. */ #define YES_UNDERSCORES #ifndef LINUX_ELF #include "i386/gstabs.h" #endif /* Specify predefined symbols in preprocessor. */ #undef CPP_PREDEFINES #define CPP_PREDEFINES "-Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)" #undef CPP_SPEC #if TARGET_CPU_DEFAULT == 2 #define CPP_SPEC "%{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE}" #else #define CPP_SPEC "%{m486:-D__i486__} %{posix:-D_POSIX_SOURCE}" #endif #undef SIZE_TYPE #define SIZE_TYPE "unsigned int" #undef PTRDIFF_TYPE #define PTRDIFF_TYPE "int" #undef WCHAR_TYPE #define WCHAR_TYPE "long int" #undef WCHAR_TYPE_SIZE #define WCHAR_TYPE_SIZE BITS_PER_WORD #undef HAVE_ATEXIT #define HAVE_ATEXIT /* Linux uses ctype from glibc.a. I am not sure how complete it is. * For now, we play safe. It may change later. */ #if 0 #undef MULTIBYTE_CHARS #define MULTIBYTE_CHARS 1 #endif #undef LIB_SPEC #define LIB_SPEC "%{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}" #undef STARTFILE_SPEC #undef GPLUSPLUS_INCLUDE_DIR #ifdef CROSS_COMPILE /* * For cross-compile, we just need to search `$(tooldir)/lib' */ #define STARTFILE_SPEC \ "%{pg:gcrt0.o%s -static} %{!pg:%{p:gcrt0.o%s -static} %{!p:crt0.o%s %{g*:-static} %{!static:%{nojump:-nojump}} %{static:-static}}} -L"TOOLDIR"/lib" /* *The cross-compile uses this. */ #define GPLUSPLUS_INCLUDE_DIR TOOLDIR"/g++-include" #else #define STARTFILE_SPEC \ "%{pg:gcrt0.o%s -static} %{!pg:%{p:gcrt0.o%s -static} %{!p:crt0.o%s %{g*:-static}%{!static:%{nojump:-nojump}} %{static:-static}}}" /* *The native Linux system uses this. */ #define GPLUSPLUS_INCLUDE_DIR "/usr/g++-include" #endif /* There are conflicting reports about whether this system uses a different assembler syntax. wilson@cygnus.com says # is right. */ #undef COMMENT_BEGIN #define COMMENT_BEGIN "#" #undef ASM_APP_ON #define ASM_APP_ON "#APP\n" #undef ASM_APP_OFF #define ASM_APP_OFF "#NO_APP\n" /* Don't default to pcc-struct-return, because gcc is the only compiler, and we want to retain compatibility with older gcc versions. */ #define DEFAULT_PCC_STRUCT_RETURN 0 /* We need that too. */ #define HANDLE_SYSV_PRAGMA #undef LINK_SPEC /* We want to pass -v to linker */ #if TARGET_CPU_DEFAULT == 2 #define LINK_SPEC "%{v:-dll-verbose} %{!m386:-m486}" #else #define LINK_SPEC "%{v:-dll-verbose} %{m486:-m486}" #endif ./libc-linux/gcc/config.h100644 1676 334 1002 5471532750 13267 0ustar hjlisl/* Configuration for GCC for Intel i386 running Linux. * * Written by H.J. Lu (hlu@eecs.wsu.edu) */ #include "i386/xm-i386.h" #include "xm-svr3.h" #undef BSTRING #define BSTRING #undef bcmp #undef bcopy #undef bzero #undef index #undef rindex #if 0 /* These conflict with stdlib.h in protoize, it is said, and there's no evidence they are actually needed. */ #undef malloc(n) #define malloc(n) malloc ((n) ? (n) : 1) #undef calloc(n,e) #define calloc(n,e) calloc (((n) ? (n) : 1), ((e) ? (e) : 1)) #endif ./libc-linux/gcc/gbl-ctors.h100644 1676 334 5517 5471532750 13735 0ustar hjlisl/* Definitions relating to the special __do_global_init function used for getting g++ file-scope static objects constructed. This file will get included either by libgcc2.c (for systems that don't support a .init section) or by crtstuff.c (for those that do). Written by Ron Guilmette (rfg@ncd.com) Copyright (C) 1991 Free Software Foundation, Inc. This file is part of GNU CC. GNU CC 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. GNU CC 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. */ /* This file contains definitions and declarations of things relating to the normal start-up-time invocation of C++ file-scope static object constructors. These declarations and definitions are used by *both* libgcc2.c and by crtstuff.c. Note that this file should only be compiled with GCC. */ #ifdef HAVE_ATEXIT extern void atexit (void (*) (void)); #define ON_EXIT(FUNC,ARG) atexit ((FUNC)) #else #ifdef sun extern void on_exit (void*, void*); #define ON_EXIT(FUNC,ARG) on_exit ((FUNC), (ARG)) #endif #endif /* Declare a pointer to void function type. */ typedef void (*func_ptr) (void); /* Declare the set of symbols use as begin and end markers for the lists of global object constructors and global object destructors. */ extern func_ptr __CTOR_LIST__[]; extern func_ptr __DTOR_LIST__[]; /* Declare the routine which need to get invoked at program exit time. */ extern void __do_global_dtors (); /* Define a macro with the code which needs to be executed at program start-up time. This macro is used in two places in crtstuff.c (for systems which support a .init section) and in one place in libgcc2.c (for those system which do *not* support a .init section). For all three places where this code might appear, it must be identical, so we define it once here as a macro to avoid various instances getting out-of-sync with one another. */ /* The first word may or may not contain the number of pointers in the table. In all cases, the table is null-terminated. We ignore the first word and scan up to the null. */ /* Some systems use a different strategy for finding the ctors. For example, svr3. */ #ifndef DO_GLOBAL_CTORS_BODY #define DO_GLOBAL_CTORS_BODY \ do { \ func_ptr *p; \ for (p = __CTOR_LIST__ + 1; *p; ) \ (*p++) (); \ } while (0) #endif ./libc-linux/gcc/glimits.h100644 1676 334 4424 5471532750 13505 0ustar hjlisl#ifndef _LIMITS_H___ #ifndef _MACH_MACHLIMITS_H_ /* _MACH_MACHLIMITS_H_ is used on OSF/1. */ #define _LIMITS_H___ #define _MACH_MACHLIMITS_H_ /* Number of bits in a `char'. */ #undef CHAR_BIT #define CHAR_BIT 8 /* Maximum length of a multibyte character. */ #ifndef MB_LEN_MAX #define MB_LEN_MAX 1 #endif /* Minimum and maximum values a `signed char' can hold. */ #undef SCHAR_MIN #define SCHAR_MIN (-128) #undef SCHAR_MAX #define SCHAR_MAX 127 /* Maximum value an `unsigned char' can hold. (Minimum is 0). */ #undef UCHAR_MAX #define UCHAR_MAX 255 /* Minimum and maximum values a `char' can hold. */ #ifdef __CHAR_UNSIGNED__ #undef CHAR_MIN #define CHAR_MIN 0 #undef CHAR_MAX #define CHAR_MAX 255 #else #undef CHAR_MIN #define CHAR_MIN (-128) #undef CHAR_MAX #define CHAR_MAX 127 #endif /* Minimum and maximum values a `signed short int' can hold. */ #undef SHRT_MIN #define SHRT_MIN (-32768) #undef SHRT_MAX #define SHRT_MAX 32767 /* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ #undef USHRT_MAX #define USHRT_MAX 65535 /* Minimum and maximum values a `signed int' can hold. */ #ifndef __INT_MAX__ #define __INT_MAX__ 2147483647 #endif #undef INT_MIN #define INT_MIN (-INT_MAX-1) #undef INT_MAX #define INT_MAX __INT_MAX__ /* Maximum value an `unsigned int' can hold. (Minimum is 0). */ #undef UINT_MAX #define UINT_MAX (INT_MAX * 2U + 1) /* Minimum and maximum values a `signed long int' can hold. (Same as `int'). */ #ifndef __LONG_MAX__ #define __LONG_MAX__ 2147483647L #endif #undef LONG_MIN #define LONG_MIN (-LONG_MAX-1) #undef LONG_MAX #define LONG_MAX __LONG_MAX__ /* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ #undef ULONG_MAX #define ULONG_MAX (LONG_MAX * 2UL + 1) #if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__) /* Minimum and maximum values a `signed long long int' can hold. */ #ifndef __LONG_LONG_MAX__ #define __LONG_LONG_MAX__ 9223372036854775807LL #endif #undef LONG_LONG_MIN #define LONG_LONG_MIN (-LONG_LONG_MAX-1) #undef LONG_LONG_MAX #define LONG_LONG_MAX __LONG_LONG_MAX__ /* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */ #undef ULONG_LONG_MAX #define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1) #endif #endif /* _MACH_MACHLIMITS_H_ */ #endif /* _LIMITS_H___ */ ./libc-linux/gcc/gstddef.h100644 1676 334 13545 5471532750 13501 0ustar hjlisl#ifndef _STDDEF_H #ifndef _STDDEF_H_ #ifndef _ANSI_STDDEF_H /* Any one of these symbols __need_* means that GNU libc wants us just to define one data type. So don't define the symbols that indicate this file's entire job has been done. */ #if (!defined(__need_wchar_t) && !defined(__need_size_t) \ && !defined(__need_ptrdiff_t) && !defined(__need_NULL)) #define _STDDEF_H #define _STDDEF_H_ /* snaroff@next.com says the NeXT needs this. */ #define _ANSI_STDDEF_H #endif #ifndef __sys_stdtypes_h /* This avoids lossage on SunOS but only if stdtypes.h comes first. There's no way to win with the other order! Sun lossage. */ /* On 4.3bsd-net2, make sure ansi.h is included, so we have one less case to deal with in the following. */ #if defined (__BSD_NET2__) || defined (____386BSD____) #include #endif /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are defined if the corresponding type is *not* defined. */ #ifdef _ANSI_H_ #ifndef _SIZE_T_ #define _SIZE_T #endif #ifndef _PTRDIFF_T_ #define _PTRDIFF_T #endif #ifndef _WCHAR_T_ #define _WCHAR_T #endif /* Undef _FOO_T_ if we are supposed to define foo_t. */ #if defined (__need_ptrdiff_t) || defined (_STDDEF_H_) #undef _PTRDIFF_T_ #endif #if defined (__need_size_t) || defined (_STDDEF_H_) #undef _SIZE_T_ #endif #if defined (__need_wchar_t) || defined (_STDDEF_H_) #undef _WCHAR_T_ #endif #endif /* _ANSI_H_ */ /* Sequent's header files use _PTRDIFF_T_ in some conflicting way. Just ignore it. */ #if defined (__sequent__) && defined (_PTRDIFF_T_) #undef _PTRDIFF_T_ #endif /* In case nobody has defined these types, but we aren't running under GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and __WCHAR_TYPE__ have reasonable values. This can happen if the parts of GCC is compiled by an older compiler, that actually include gstddef.h, such as collect2. */ /* Signed type of difference of two pointers. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ #if defined (_STDDEF_H) || defined (__need_ptrdiff_t) #ifndef _PTRDIFF_T /* in case has defined it. */ #ifndef _T_PTRDIFF_ #ifndef _T_PTRDIFF #ifndef __PTRDIFF_T #ifndef _PTRDIFF_T_ #ifndef ___int_ptrdiff_t_h #ifndef _GCC_PTRDIFF_T #define _PTRDIFF_T #define _T_PTRDIFF_ #define _T_PTRDIFF #define __PTRDIFF_T #define _PTRDIFF_T_ #define ___int_ptrdiff_t_h #define _GCC_PTRDIFF_T #ifndef __PTRDIFF_TYPE__ #define __PTRDIFF_TYPE__ long int #endif typedef __PTRDIFF_TYPE__ ptrdiff_t; #endif /* _GCC_PTRDIFF_T */ #endif /* ___int_ptrdiff_t_h */ #endif /* _PTRDIFF_T_ */ #endif /* __PTRDIFF_T */ #endif /* _T_PTRDIFF */ #endif /* _T_PTRDIFF_ */ #endif /* _PTRDIFF_T */ /* If this symbol has done its job, get rid of it. */ #undef __need_ptrdiff_t #endif /* _STDDEF_H or __need_ptrdiff_t. */ /* Unsigned type of `sizeof' something. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ #if defined (_STDDEF_H) || defined (__need_size_t) #ifndef _SIZE_T /* in case has defined it. */ #ifndef _SYS_SIZE_T_H #ifndef _T_SIZE_ #ifndef _T_SIZE #ifndef __SIZE_T #ifndef _SIZE_T_ #ifndef ___int_size_t_h #ifndef _GCC_SIZE_T #ifndef _SIZET_ #ifndef __size_t #define _SIZE_T #define _SYS_SIZE_T_H #define _T_SIZE_ #define _T_SIZE #define __SIZE_T #define _SIZE_T_ #define ___int_size_t_h #define _GCC_SIZE_T #define _SIZET_ #define __size_t #ifndef __SIZE_TYPE__ #define __SIZE_TYPE__ long unsigned int #endif #if !(defined (__GNUG__) && defined (size_t)) typedef __SIZE_TYPE__ size_t; #endif /* !(defined (__GNUG__) && defined (size_t)) */ #endif /* __size_t */ #endif /* _SIZET_ */ #endif /* _GCC_SIZE_T */ #endif /* ___int_size_t_h */ #endif /* _SIZE_T_ */ #endif /* __SIZE_T */ #endif /* _T_SIZE */ #endif /* _T_SIZE_ */ #endif /* _SYS_SIZE_T_H */ #endif /* _SIZE_T */ #undef __need_size_t #endif /* _STDDEF_H or __need_size_t. */ /* Wide character type. Locale-writers should change this as necessary to be big enough to hold unique values not between 0 and 127, and not (wchar_t) -1, for each defined multibyte character. */ /* Define this type if we are doing the whole job, or if we want this type in particular. */ #if defined (_STDDEF_H) || defined (__need_wchar_t) #ifndef _WCHAR_T #ifndef _T_WCHAR_ #ifndef _T_WCHAR #ifndef __WCHAR_T #ifndef _WCHAR_T_ #ifndef _WCHAR_T_H #ifndef ___int_wchar_t_h #ifndef __INT_WCHAR_T_H #ifndef _GCC_WCHAR_T #define _WCHAR_T #define _T_WCHAR_ #define _T_WCHAR #define __WCHAR_T #define _WCHAR_T_ #define _WCHAR_T_H #define ___int_wchar_t_h #define __INT_WCHAR_T_H #define _GCC_WCHAR_T #ifndef __WCHAR_TYPE__ #define __WCHAR_TYPE__ int #endif #ifdef __GNUG__ /* In C++, wchar_t is a distinct basic type, and we can expect __wchar_t to be defined by cc1plus. */ typedef __wchar_t wchar_t; #else /* In C, cpp tells us which type to make an alias for. */ typedef __WCHAR_TYPE__ wchar_t; #endif #endif #endif #endif #endif #endif #endif #endif #endif #endif #undef __need_wchar_t #endif /* _STDDEF_H or __need_wchar_t. */ /* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. are already defined. */ #ifdef _ANSI_H_ #ifdef _GCC_PTRDIFF_T_ #undef _PTRDIFF_T_ #endif #ifdef _GCC_SIZE_T_ #undef _SIZE_T_ #endif #ifdef _GCC_WCHAR_T_ #undef _WCHAR_T_ #endif #endif /* _ANSI_H_ */ #endif /* __sys_stdtypes_h */ /* A null pointer constant. */ #if defined (_STDDEF_H) || defined (__need_NULL) #undef NULL /* in case has defined it. */ #define NULL ((void *)0) #endif /* NULL not defined and or need NULL. */ #undef __need_NULL #ifdef _STDDEF_H /* Offset of member MEMBER in a struct of type TYPE. */ #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif /* _STDDEF_H was defined this time */ #endif /* _ANSI_STDDEF_H was not defined before */ #endif /* _STDDEF_H_ was not defined before */ #endif /* _STDDEF_H was not defined before */ ./libc-linux/gcc/gvarargs.h100644 1676 334 10756 5471532750 13676 0ustar hjlisl#ifndef __GNUC__ /* Use the system's macros with the system's compiler. */ #include #else /* Record that this is varargs.h; this turns off stdarg.h. */ #ifndef _VARARGS_H #define _VARARGS_H #ifdef __sparc__ #include #else #ifdef __spur__ #include #else #ifdef __mips__ #include #else #ifdef __i860__ #include #else #ifdef __pyr__ #include #else #ifdef __clipper__ #include #else #ifdef __m88k__ #include #else #if defined(__hppa__) || defined(hp800) #include #else #ifdef __i960__ #include #else #ifdef __alpha__ #include #else #if defined (__H8300__) || defined (__H8300H__) #include #else #ifdef __NeXT__ /* On Next, erase any vestiges of stdarg.h. */ #ifdef _ANSI_STDARG_H_ #define _VA_LIST_ #endif #define _ANSI_STDARG_H_ #undef va_alist #undef va_dcl #undef va_list #undef va_start #undef va_end #undef __va_rounded_size #undef va_arg #endif /* __NeXT__ */ /* In GCC version 2, we want an ellipsis at the end of the declaration of the argument list. GCC version 1 can't parse it. */ #if __GNUC__ > 1 #define __va_ellipsis ... #else #define __va_ellipsis #endif /* These macros implement traditional (non-ANSI) varargs for GNU C. */ #define va_alist __builtin_va_alist /* The ... causes current_function_varargs to be set in cc1. */ #define va_dcl int __builtin_va_alist; __va_ellipsis /* Define __gnuc_va_list, just as in gstdarg.h. */ #ifndef __GNUC_VA_LIST #define __GNUC_VA_LIST #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) typedef char *__gnuc_va_list; #else typedef void *__gnuc_va_list; #endif #endif #define va_start(AP) AP=(char *) &__builtin_va_alist #define va_end(AP) #define __va_rounded_size(TYPE) \ (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) #if defined (__arm__) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__) /* This is for little-endian machines; small args are padded upward. */ #define va_arg(AP, TYPE) \ (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \ *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE)))) #else /* big-endian */ /* This is for big-endian machines; small args are padded downward. */ #define va_arg(AP, TYPE) \ (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \ *((TYPE *) (void *) ((char *) (AP) - ((sizeof (TYPE) < 4 \ ? sizeof (TYPE) \ : __va_rounded_size (TYPE)))))) #endif /* big-endian */ #endif /* not h8300 */ #endif /* not alpha */ #endif /* not i960 */ #endif /* not hppa */ #endif /* not m88k */ #endif /* not clipper */ #endif /* not pyr */ #endif /* not i860 */ #endif /* not mips */ #endif /* not spur */ #endif /* not sparc */ #endif /* not _VARARGS_H */ /* Define va_list from __gnuc_va_list. */ #ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */ #undef _VA_LIST #endif #ifdef __svr4__ /* SVR4.2 uses _VA_LIST for an internal alias for va_list, so we must avoid testing it and setting it here. SVR4 uses _VA_LIST as a flag in stdarg.h, but we should have no conflict with that. */ #ifndef _VA_LIST_ #define _VA_LIST_ #ifdef __i860__ #ifndef _VA_LIST #define _VA_LIST va_list #endif #endif /* __i860__ */ typedef __gnuc_va_list va_list; #endif /* _VA_LIST_ */ #else /* not __svr4__ */ /* The macro _VA_LIST_ is the same thing used by this file in Ultrix. But on BSD NET2 we must not test or define or undef it. (Note that the comments in NET 2's ansi.h are incorrect for _VA_LIST_--see stdio.h!) */ /* Michael Eriksson at Thu Sep 30 11:00:57 1993: Sequent defines _VA_LIST_ in to be the type to use for va_list (``typedef _VA_LIST_ va_list'') */ #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__sequent__) /* The macro _VA_LIST is used in SCO Unix 3.2. */ #ifndef _VA_LIST /* The macro _VA_LIST_T_H is used in the Bull dpx2 */ #ifndef _VA_LIST_T_H #define _VA_LIST_T_H #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__sequent__)) #define _VA_LIST_ #endif #define _VA_LIST typedef __gnuc_va_list va_list; #endif /* not _VA_LIST_T_H */ #endif /* not _VA_LIST */ #endif /* not _VA_LIST_, except on certain systems */ #endif /* not __svr4__ */ /* The next BSD release (if there is one) wants this symbol to be undefined instead of _VA_LIST_. */ #ifdef _BSD_VA_LIST #undef _BSD_VA_LIST #endif #endif /* __GNUC__ */ ./libc-linux/gcc/libgcc2.c100644 1676 334 132445 5471532750 13402 0ustar hjlisl/* More subroutines needed by GCC output code on some machines. */ /* Compile this one with gcc. */ /* Copyright (C) 1989, 1992 Free Software Foundation, Inc. This file is part of GNU CC. GNU CC 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. GNU CC 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 GCC 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. */ /* It is incorrect to include config.h here, because this file is being compiled for the target, and hence definitions concerning only the host do not apply. */ #include "tconfig.h" #include "machmode.h" #ifndef L_trampoline #include "gstddef.h" #endif /* Don't use `fancy_abort' here even if config.h says to use it. */ #ifdef abort #undef abort #endif /* In the first part of this file, we are interfacing to calls generated by the compiler itself. These calls pass values into these routines which have very specific modes (rather than very specific types), and these compiler-generated calls also expect any return values to have very specific modes (rather than very specific types). Thus, we need to avoid using regular C language type names in this part of the file because the sizes for those types can be configured to be anything. Instead we use the following special type names. */ typedef unsigned int UQItype __attribute__ ((mode (QI))); typedef int SItype __attribute__ ((mode (SI))); typedef unsigned int USItype __attribute__ ((mode (SI))); typedef int DItype __attribute__ ((mode (DI))); typedef unsigned int UDItype __attribute__ ((mode (DI))); typedef float SFtype __attribute__ ((mode (SF))); typedef float DFtype __attribute__ ((mode (DF))); #if LONG_DOUBLE_TYPE_SIZE == 96 typedef float XFtype __attribute__ ((mode (XF))); #endif #if LONG_DOUBLE_TYPE_SIZE == 128 typedef float TFtype __attribute__ ((mode (TF))); #endif #if BITS_PER_WORD==16 typedef int word_type __attribute__ ((mode (HI))); #endif #if BITS_PER_WORD==32 typedef int word_type __attribute__ ((mode (SI))); #endif #if BITS_PER_WORD==64 typedef int word_type __attribute__ ((mode (DI))); #endif /* Make sure that we don't accidentally use any normal C language built-in type names in the first part of this file. Instead we want to use *only* the type names defined above. The following macro definitions insure that if we *do* accidentally use some normal C language built-in type name, we will get a syntax error. */ #define char bogus_type #define short bogus_type #define int bogus_type #define long bogus_type #define unsigned bogus_type #define float bogus_type #define double bogus_type #define SI_TYPE_SIZE (sizeof (SItype) * BITS_PER_UNIT) /* DIstructs are pairs of SItype values in the order determined by WORDS_BIG_ENDIAN. */ #if WORDS_BIG_ENDIAN struct DIstruct {SItype high, low;}; #else struct DIstruct {SItype low, high;}; #endif /* We need this union to unpack/pack DImode values, since we don't have any arithmetic yet. Incoming DImode parameters are stored into the `ll' field, and the unpacked result is read from the struct `s'. */ typedef union { struct DIstruct s; DItype ll; } DIunion; #if defined (L_udivmoddi4) || defined (L_muldi3) || defined (L_udiv_w_sdiv) #include "longlong.h" #endif /* udiv or mul */ extern DItype __fixunssfdi (SFtype a); extern DItype __fixunsdfdi (DFtype a); #if LONG_DOUBLE_TYPE_SIZE == 96 extern DItype __fixunsxfdi (XFtype a); #endif #if LONG_DOUBLE_TYPE_SIZE == 128 extern DItype __fixunstfdi (TFtype a); #endif #if defined (L_negdi2) || defined (L_divdi3) || defined (L_moddi3) #if defined (L_divdi3) || defined (L_moddi3) static inline #endif DItype __negdi2 (u) DItype u; { DIunion w; DIunion uu; uu.ll = u; w.s.low = -uu.s.low; w.s.high = -uu.s.high - ((USItype) w.s.low > 0); return w.ll; } #endif #ifdef L_lshldi3 DItype __lshldi3 (u, b) DItype u; SItype b; { DIunion w; SItype bm; DIunion uu; if (b == 0) return u; uu.ll = u; bm = (sizeof (SItype) * BITS_PER_UNIT) - b; if (bm <= 0) { w.s.low = 0; w.s.high = (USItype)uu.s.low << -bm; } else { USItype carries = (USItype)uu.s.low >> bm; w.s.low = (USItype)uu.s.low << b; w.s.high = ((USItype)uu.s.high << b) | carries; } return w.ll; } #endif #ifdef L_lshrdi3 DItype __lshrdi3 (u, b) DItype u; SItype b; { DIunion w; SItype bm; DIunion uu; if (b == 0) return u; uu.ll = u; bm = (sizeof (SItype) * BITS_PER_UNIT) - b; if (bm <= 0) { w.s.high = 0; w.s.low = (USItype)uu.s.high >> -bm; } else { USItype carries = (USItype)uu.s.high << bm; w.s.high = (USItype)uu.s.high >> b; w.s.low = ((USItype)uu.s.low >> b) | carries; } return w.ll; } #endif #ifdef L_ashldi3 DItype __ashldi3 (u, b) DItype u; SItype b; { DIunion w; SItype bm; DIunion uu; if (b == 0) return u; uu.ll = u; bm = (sizeof (SItype) * BITS_PER_UNIT) - b; if (bm <= 0) { w.s.low = 0; w.s.high = (USItype)uu.s.low << -bm; } else { USItype carries = (USItype)uu.s.low >> bm; w.s.low = (USItype)uu.s.low << b; w.s.high = ((USItype)uu.s.high << b) | carries; } return w.ll; } #endif #ifdef L_ashrdi3 DItype __ashrdi3 (u, b) DItype u; SItype b; { DIunion w; SItype bm; DIunion uu; if (b == 0) return u; uu.ll = u; bm = (sizeof (SItype) * BITS_PER_UNIT) - b; if (bm <= 0) { /* w.s.high = 1..1 or 0..0 */ w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1); w.s.low = uu.s.high >> -bm; } else { USItype carries = (USItype)uu.s.high << bm; w.s.high = uu.s.high >> b; w.s.low = ((USItype)uu.s.low >> b) | carries; } return w.ll; } #endif #ifdef L_ffsdi2 DItype __ffsdi2 (u) DItype u; { DIunion uu, w; uu.ll = u; w.s.high = 0; w.s.low = ffs (uu.s.low); if (w.s.low != 0) return w.ll; w.s.low = ffs (uu.s.high); if (w.s.low != 0) { w.s.low += BITS_PER_UNIT * sizeof (SItype); return w.ll; } return w.ll; } #endif #ifdef L_muldi3 DItype __muldi3 (u, v) DItype u, v; { DIunion w; DIunion uu, vv; uu.ll = u, vv.ll = v; w.ll = __umulsidi3 (uu.s.low, vv.s.low); w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high + (USItype) uu.s.high * (USItype) vv.s.low); return w.ll; } #endif #ifdef L_udiv_w_sdiv USItype __udiv_w_sdiv (rp, a1, a0, d) USItype *rp, a1, a0, d; { USItype q, r; USItype c0, c1, b1; if ((SItype) d >= 0) { if (a1 < d - a1 - (a0 >> (SI_TYPE_SIZE - 1))) { /* dividend, divisor, and quotient are nonnegative */ sdiv_qrnnd (q, r, a1, a0, d); } else { /* Compute c1*2^32 + c0 = a1*2^32 + a0 - 2^31*d */ sub_ddmmss (c1, c0, a1, a0, d >> 1, d << (SI_TYPE_SIZE - 1)); /* Divide (c1*2^32 + c0) by d */ sdiv_qrnnd (q, r, c1, c0, d); /* Add 2^31 to quotient */ q += (USItype) 1 << (SI_TYPE_SIZE - 1); } } else { b1 = d >> 1; /* d/2, between 2^30 and 2^31 - 1 */ c1 = a1 >> 1; /* A/2 */ c0 = (a1 << (SI_TYPE_SIZE - 1)) + (a0 >> 1); if (a1 < b1) /* A < 2^32*b1, so A/2 < 2^31*b1 */ { sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */ r = 2*r + (a0 & 1); /* Remainder from A/(2*b1) */ if ((d & 1) != 0) { if (r >= q) r = r - q; else if (q - r <= d) { r = r - q + d; q--; } else { r = r - q + 2*d; q -= 2; } } } else if (c1 < b1) /* So 2^31 <= (A/2)/b1 < 2^32 */ { c1 = (b1 - 1) - c1; c0 = ~c0; /* logical NOT */ sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */ q = ~q; /* (A/2)/b1 */ r = (b1 - 1) - r; r = 2*r + (a0 & 1); /* A/(2*b1) */ if ((d & 1) != 0) { if (r >= q) r = r - q; else if (q - r <= d) { r = r - q + d; q--; } else { r = r - q + 2*d; q -= 2; } } } else /* Implies c1 = b1 */ { /* Hence a1 = d - 1 = 2*b1 - 1 */ if (a0 >= -d) { q = -1; r = a0 + d; } else { q = -2; r = a0 + 2*d; } } } *rp = r; return q; } #endif #ifdef L_udivmoddi4 static const UQItype __clz_tab[] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, }; UDItype __udivmoddi4 (n, d, rp) UDItype n, d; UDItype *rp; { DIunion ww; DIunion nn, dd; DIunion rr; USItype d0, d1, n0, n1, n2; USItype q0, q1; USItype b, bm; nn.ll = n; dd.ll = d; d0 = dd.s.low; d1 = dd.s.high; n0 = nn.s.low; n1 = nn.s.high; #if !UDIV_NEEDS_NORMALIZATION if (d1 == 0) { if (d0 > n1) { /* 0q = nn / 0D */ udiv_qrnnd (q0, n0, n1, n0, d0); q1 = 0; /* Remainder in n0. */ } else { /* qq = NN / 0d */ if (d0 == 0) d0 = 1 / d0; /* Divide intentionally by zero. */ udiv_qrnnd (q1, n1, 0, n1, d0); udiv_qrnnd (q0, n0, n1, n0, d0); /* Remainder in n0. */ } if (rp != 0) { rr.s.low = n0; rr.s.high = 0; *rp = rr.ll; } } #else /* UDIV_NEEDS_NORMALIZATION */ if (d1 == 0) { if (d0 > n1) { /* 0q = nn / 0D */ count_leading_zeros (bm, d0); if (bm != 0) { /* Normalize, i.e. make the most significant bit of the denominator set. */ d0 = d0 << bm; n1 = (n1 << bm) | (n0 >> (SI_TYPE_SIZE - bm)); n0 = n0 << bm; } udiv_qrnnd (q0, n0, n1, n0, d0); q1 = 0; /* Remainder in n0 >> bm. */ } else { /* qq = NN / 0d */ if (d0 == 0) d0 = 1 / d0; /* Divide intentionally by zero. */ count_leading_zeros (bm, d0); if (bm == 0) { /* From (n1 >= d0) /\ (the most significant bit of d0 is set), conclude (the most significant bit of n1 is set) /\ (the leading quotient digit q1 = 1). This special case is necessary, not an optimization. (Shifts counts of SI_TYPE_SIZE are undefined.) */ n1 -= d0; q1 = 1; } else { /* Normalize. */ b = SI_TYPE_SIZE - bm; d0 = d0 << bm; n2 = n1 >> b; n1 = (n1 << bm) | (n0 >> b); n0 = n0 << bm; udiv_qrnnd (q1, n1, n2, n1, d0); } /* n1 != d0... */ udiv_qrnnd (q0, n0, n1, n0, d0); /* Remainder in n0 >> bm. */ } if (rp != 0) { rr.s.low = n0 >> bm; rr.s.high = 0; *rp = rr.ll; } } #endif /* UDIV_NEEDS_NORMALIZATION */ else { if (d1 > n1) { /* 00 = nn / DD */ q0 = 0; q1 = 0; /* Remainder in n1n0. */ if (rp != 0) { rr.s.low = n0; rr.s.high = n1; *rp = rr.ll; } } else { /* 0q = NN / dd */ count_leading_zeros (bm, d1); if (bm == 0) { /* From (n1 >= d1) /\ (the most significant bit of d1 is set), conclude (the most significant bit of n1 is set) /\ (the quotient digit q0 = 0 or 1). This special case is necessary, not an optimization. */ /* The condition on the next line takes advantage of that n1 >= d1 (true due to program flow). */ if (n1 > d1 || n0 >= d0) { q0 = 1; sub_ddmmss (n1, n0, n1, n0, d1, d0); } else q0 = 0; q1 = 0; if (rp != 0) { rr.s.low = n0; rr.s.high = n1; *rp = rr.ll; } } else { USItype m1, m0; /* Normalize. */ b = SI_TYPE_SIZE - bm; d1 = (d1 << bm) | (d0 >> b); d0 = d0 << bm; n2 = n1 >> b; n1 = (n1 << bm) | (n0 >> b); n0 = n0 << bm; udiv_qrnnd (q0, n1, n2, n1, d1); umul_ppmm (m1, m0, q0, d0); if (m1 > n1 || (m1 == n1 && m0 > n0)) { q0--; sub_ddmmss (m1, m0, m1, m0, d1, d0); } q1 = 0; /* Remainder in (n1n0 - m1m0) >> bm. */ if (rp != 0) { sub_ddmmss (n1, n0, n1, n0, m1, m0); rr.s.low = (n1 << b) | (n0 >> bm); rr.s.high = n1 >> bm; *rp = rr.ll; } } } } ww.s.low = q0; ww.s.high = q1; return ww.ll; } #endif #ifdef L_divdi3 UDItype __udivmoddi4 (); DItype __divdi3 (u, v) DItype u, v; { SItype c = 0; DIunion uu, vv; DItype w; uu.ll = u; vv.ll = v; if (uu.s.high < 0) c = ~c, uu.ll = __negdi2 (uu.ll); if (vv.s.high < 0) c = ~c, vv.ll = __negdi2 (vv.ll); w = __udivmoddi4 (uu.ll, vv.ll, (UDItype *) 0); if (c) w = __negdi2 (w); return w; } #endif #ifdef L_moddi3 UDItype __udivmoddi4 (); DItype __moddi3 (u, v) DItype u, v; { SItype c = 0; DIunion uu, vv; DItype w; uu.ll = u; vv.ll = v; if (uu.s.high < 0) c = ~c, uu.ll = __negdi2 (uu.ll); if (vv.s.high < 0) vv.ll = __negdi2 (vv.ll); (void) __udivmoddi4 (uu.ll, vv.ll, &w); if (c) w = __negdi2 (w); return w; } #endif #ifdef L_umoddi3 UDItype __udivmoddi4 (); UDItype __umoddi3 (u, v) UDItype u, v; { DItype w; (void) __udivmoddi4 (u, v, &w); return w; } #endif #ifdef L_udivdi3 UDItype __udivmoddi4 (); UDItype __udivdi3 (n, d) UDItype n, d; { return __udivmoddi4 (n, d, (UDItype *) 0); } #endif #ifdef L_cmpdi2 word_type __cmpdi2 (a, b) DItype a, b; { DIunion au, bu; au.ll = a, bu.ll = b; if (au.s.high < bu.s.high) return 0; else if (au.s.high > bu.s.high) return 2; if ((USItype) au.s.low < (USItype) bu.s.low) return 0; else if ((USItype) au.s.low > (USItype) bu.s.low) return 2; return 1; } #endif #ifdef L_ucmpdi2 word_type __ucmpdi2 (a, b) DItype a, b; { DIunion au, bu; au.ll = a, bu.ll = b; if ((USItype) au.s.high < (USItype) bu.s.high) return 0; else if ((USItype) au.s.high > (USItype) bu.s.high) return 2; if ((USItype) au.s.low < (USItype) bu.s.low) return 0; else if ((USItype) au.s.low > (USItype) bu.s.low) return 2; return 1; } #endif #if defined(L_fixunstfdi) && (LONG_DOUBLE_TYPE_SIZE == 128) #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT) #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE) DItype __fixunstfdi (a) TFtype a; { TFtype b; UDItype v; if (a < 0) return 0; /* Compute high word of result, as a flonum. */ b = (a / HIGH_WORD_COEFF); /* Convert that to fixed (but not to DItype!), and shift it into the high word. */ v = (USItype) b; v <<= WORD_SIZE; /* Remove high part from the TFtype, leaving the low part as flonum. */ a -= (TFtype)v; /* Convert that to fixed (but not to DItype!) and add it in. Sometimes A comes out negative. This is significant, since A has more bits than a long int does. */ if (a < 0) v -= (USItype) (- a); else v += (USItype) a; return v; } #endif #if defined(L_fixtfdi) && (LONG_DOUBLE_TYPE_SIZE == 128) DItype __fixtfdi (a) TFtype a; { if (a < 0) return - __fixunstfdi (-a); return __fixunstfdi (a); } #endif #if defined(L_fixunsxfdi) && (LONG_DOUBLE_TYPE_SIZE == 96) #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT) #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE) DItype __fixunsxfdi (a) XFtype a; { XFtype b; UDItype v; if (a < 0) return 0; /* Compute high word of result, as a flonum. */ b = (a / HIGH_WORD_COEFF); /* Convert that to fixed (but not to DItype!), and shift it into the high word. */ v = (USItype) b; v <<= WORD_SIZE; /* Remove high part from the XFtype, leaving the low part as flonum. */ a -= (XFtype)v; /* Convert that to fixed (but not to DItype!) and add it in. Sometimes A comes out negative. This is significant, since A has more bits than a long int does. */ if (a < 0) v -= (USItype) (- a); else v += (USItype) a; return v; } #endif #if defined(L_fixxfdi) && (LONG_DOUBLE_TYPE_SIZE == 96) DItype __fixxfdi (a) XFtype a; { if (a < 0) return - __fixunsxfdi (-a); return __fixunsxfdi (a); } #endif #ifdef L_fixunsdfdi #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT) #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE) DItype __fixunsdfdi (a) DFtype a; { DFtype b; UDItype v; if (a < 0) return 0; /* Compute high word of result, as a flonum. */ b = (a / HIGH_WORD_COEFF); /* Convert that to fixed (but not to DItype!), and shift it into the high word. */ v = (USItype) b; v <<= WORD_SIZE; /* Remove high part from the DFtype, leaving the low part as flonum. */ a -= (DFtype)v; /* Convert that to fixed (but not to DItype!) and add it in. Sometimes A comes out negative. This is significant, since A has more bits than a long int does. */ if (a < 0) v -= (USItype) (- a); else v += (USItype) a; return v; } #endif #ifdef L_fixdfdi DItype __fixdfdi (a) DFtype a; { if (a < 0) return - __fixunsdfdi (-a); return __fixunsdfdi (a); } #endif #ifdef L_fixunssfdi #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT) #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE) DItype __fixunssfdi (SFtype original_a) { /* Convert the SFtype to a DFtype, because that is surely not going to lose any bits. Some day someone else can write a faster version that avoids converting to DFtype, and verify it really works right. */ DFtype a = original_a; DFtype b; UDItype v; if (a < 0) return 0; /* Compute high word of result, as a flonum. */ b = (a / HIGH_WORD_COEFF); /* Convert that to fixed (but not to DItype!), and shift it into the high word. */ v = (USItype) b; v <<= WORD_SIZE; /* Remove high part from the DFtype, leaving the low part as flonum. */ a -= (DFtype)v; /* Convert that to fixed (but not to DItype!) and add it in. Sometimes A comes out negative. This is significant, since A has more bits than a long int does. */ if (a < 0) v -= (USItype) (- a); else v += (USItype) a; return v; } #endif #ifdef L_fixsfdi DItype __fixsfdi (SFtype a) { if (a < 0) return - __fixunssfdi (-a); return __fixunssfdi (a); } #endif #if defined(L_floatdixf) && (LONG_DOUBLE_TYPE_SIZE == 96) #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT) #define HIGH_HALFWORD_COEFF (((UDItype) 1) << (WORD_SIZE / 2)) #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE) XFtype __floatdixf (u) DItype u; { XFtype d; SItype negate = 0; if (u < 0) u = -u, negate = 1; d = (USItype) (u >> WORD_SIZE); d *= HIGH_HALFWORD_COEFF; d *= HIGH_HALFWORD_COEFF; d += (USItype) (u & (HIGH_WORD_COEFF - 1)); return (negate ? -d : d); } #endif #if defined(L_floatditf) && (LONG_DOUBLE_TYPE_SIZE == 128) #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT) #define HIGH_HALFWORD_COEFF (((UDItype) 1) << (WORD_SIZE / 2)) #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE) TFtype __floatditf (u) DItype u; { TFtype d; SItype negate = 0; if (u < 0) u = -u, negate = 1; d = (USItype) (u >> WORD_SIZE); d *= HIGH_HALFWORD_COEFF; d *= HIGH_HALFWORD_COEFF; d += (USItype) (u & (HIGH_WORD_COEFF - 1)); return (negate ? -d : d); } #endif #ifdef L_floatdidf #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT) #define HIGH_HALFWORD_COEFF (((UDItype) 1) << (WORD_SIZE / 2)) #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE) DFtype __floatdidf (u) DItype u; { DFtype d; SItype negate = 0; if (u < 0) u = -u, negate = 1; d = (USItype) (u >> WORD_SIZE); d *= HIGH_HALFWORD_COEFF; d *= HIGH_HALFWORD_COEFF; d += (USItype) (u & (HIGH_WORD_COEFF - 1)); return (negate ? -d : d); } #endif #ifdef L_floatdisf #define WORD_SIZE (sizeof (SItype) * BITS_PER_UNIT) #define HIGH_HALFWORD_COEFF (((UDItype) 1) << (WORD_SIZE / 2)) #define HIGH_WORD_COEFF (((UDItype) 1) << WORD_SIZE) SFtype __floatdisf (u) DItype u; { /* Do the calculation in DFmode so that we don't lose any of the precision of the high word while multiplying it. */ DFtype f; SItype negate = 0; if (u < 0) u = -u, negate = 1; f = (USItype) (u >> WORD_SIZE); f *= HIGH_HALFWORD_COEFF; f *= HIGH_HALFWORD_COEFF; f += (USItype) (u & (HIGH_WORD_COEFF - 1)); return (SFtype) (negate ? -f : f); } #endif #if defined(L_fixunsxfsi) && LONG_DOUBLE_TYPE_SIZE == 96 #include "glimits.h" USItype __fixunsxfsi (a) XFtype a; { if (a >= - (DFtype) LONG_MIN) return (SItype) (a + LONG_MIN) - LONG_MIN; return (SItype) a; } #endif #ifdef L_fixunsdfsi #include "glimits.h" USItype __fixunsdfsi (a) DFtype a; { if (a >= - (DFtype) LONG_MIN) return (SItype) (a + LONG_MIN) - LONG_MIN; return (SItype) a; } #endif #ifdef L_fixunssfsi #include "glimits.h" USItype __fixunssfsi (SFtype a) { if (a >= - (SFtype) LONG_MIN) return (SItype) (a + LONG_MIN) - LONG_MIN; return (SItype) a; } #endif /* From here on down, the routines use normal data types. */ #define SItype bogus_type #define USItype bogus_type #define DItype bogus_type #define UDItype bogus_type #define SFtype bogus_type #define DFtype bogus_type #undef char #undef short #undef int #undef long #undef unsigned #undef float #undef double #ifdef L__gcc_bcmp /* Like bcmp except the sign is meaningful. Reult is negative if S1 is less than S2, positive if S1 is greater, 0 if S1 and S2 are equal. */ int __gcc_bcmp (s1, s2, size) unsigned char *s1, *s2; size_t size; { while (size > 0) { unsigned char c1 = *s1++, c2 = *s2++; if (c1 != c2) return c1 - c2; size--; } return 0; } #endif #ifdef L_varargs #ifdef __i860__ #if defined(__svr4__) || defined(__alliant__) asm (" .text"); asm (" .align 4"); /* The Alliant needs the added underscore. */ asm (".globl __builtin_saveregs"); asm ("__builtin_saveregs:"); asm (".globl ___builtin_saveregs"); asm ("___builtin_saveregs:"); asm (" andnot 0x0f,%sp,%sp"); /* round down to 16-byte boundary */ asm (" adds -96,%sp,%sp"); /* allocate stack space for reg save area and also for a new va_list structure */ /* Save all argument registers in the arg reg save area. The arg reg save area must have the following layout (according to the svr4 ABI): struct { union { float freg[8]; double dreg[4]; } float_regs; long ireg[12]; }; */ asm (" fst.q %f8, 0(%sp)"); /* save floating regs (f8-f15) */ asm (" fst.q %f12,16(%sp)"); asm (" st.l %r16,32(%sp)"); /* save integer regs (r16-r27) */ asm (" st.l %r17,36(%sp)"); asm (" st.l %r18,40(%sp)"); asm (" st.l %r19,44(%sp)"); asm (" st.l %r20,48(%sp)"); asm (" st.l %r21,52(%sp)"); asm (" st.l %r22,56(%sp)"); asm (" st.l %r23,60(%sp)"); asm (" st.l %r24,64(%sp)"); asm (" st.l %r25,68(%sp)"); asm (" st.l %r26,72(%sp)"); asm (" st.l %r27,76(%sp)"); asm (" adds 80,%sp,%r16"); /* compute the address of the new va_list structure. Put in into r16 so that it will be returned to the caller. */ /* Initialize all fields of the new va_list structure. This structure looks like: typedef struct { unsigned long ireg_used; unsigned long freg_used; long *reg_base; long *mem_ptr; } va_list; */ asm (" st.l %r0, 0(%r16)"); /* nfixed */ asm (" st.l %r0, 4(%r16)"); /* nfloating */ asm (" st.l %sp, 8(%r16)"); /* __va_ctl points to __va_struct. */ asm (" bri %r1"); /* delayed return */ asm (" st.l %r28,12(%r16)"); /* pointer to overflow args */ #else /* not __svr4__ */ #if defined(__PARAGON__) /* * we'll use SVR4-ish varargs but need SVR3.2 assembler syntax, * and we stand a better chance of hooking into libraries * compiled by PGI. [andyp@ssd.intel.com] */ asm (" .text"); asm (" .align 4"); asm (".globl __builtin_saveregs"); asm ("__builtin_saveregs:"); asm (".globl ___builtin_saveregs"); asm ("___builtin_saveregs:"); asm (" andnot 0x0f,sp,sp"); /* round down to 16-byte boundary */ asm (" adds -96,sp,sp"); /* allocate stack space for reg save area and also for a new va_list structure */ /* Save all argument registers in the arg reg save area. The arg reg save area must have the following layout (according to the svr4 ABI): struct { union { float freg[8]; double dreg[4]; } float_regs; long ireg[12]; }; */ asm (" fst.q f8, 0(sp)"); asm (" fst.q f12,16(sp)"); asm (" st.l r16,32(sp)"); asm (" st.l r17,36(sp)"); asm (" st.l r18,40(sp)"); asm (" st.l r19,44(sp)"); asm (" st.l r20,48(sp)"); asm (" st.l r21,52(sp)"); asm (" st.l r22,56(sp)"); asm (" st.l r23,60(sp)"); asm (" st.l r24,64(sp)"); asm (" st.l r25,68(sp)"); asm (" st.l r26,72(sp)"); asm (" st.l r27,76(sp)"); asm (" adds 80,sp,r16"); /* compute the address of the new va_list structure. Put in into r16 so that it will be returned to the caller. */ /* Initialize all fields of the new va_list structure. This structure looks like: typedef struct { unsigned long ireg_used; unsigned long freg_used; long *reg_base; long *mem_ptr; } va_list; */ asm (" st.l r0, 0(r16)"); /* nfixed */ asm (" st.l r0, 4(r16)"); /* nfloating */ asm (" st.l sp, 8(r16)"); /* __va_ctl points to __va_struct. */ asm (" bri r1"); /* delayed return */ asm (" st.l r28,12(r16)"); /* pointer to overflow args */ #else /* not __PARAGON__ */ asm (" .text"); asm (" .align 4"); asm (".globl ___builtin_saveregs"); asm ("___builtin_saveregs:"); asm (" mov sp,r30"); asm (" andnot 0x0f,sp,sp"); asm (" adds -96,sp,sp"); /* allocate sufficient space on the stack */ /* Fill in the __va_struct. */ asm (" st.l r16, 0(sp)"); /* save integer regs (r16-r27) */ asm (" st.l r17, 4(sp)"); /* int fixed[12] */ asm (" st.l r18, 8(sp)"); asm (" st.l r19,12(sp)"); asm (" st.l r20,16(sp)"); asm (" st.l r21,20(sp)"); asm (" st.l r22,24(sp)"); asm (" st.l r23,28(sp)"); asm (" st.l r24,32(sp)"); asm (" st.l r25,36(sp)"); asm (" st.l r26,40(sp)"); asm (" st.l r27,44(sp)"); asm (" fst.q f8, 48(sp)"); /* save floating regs (f8-f15) */ asm (" fst.q f12,64(sp)"); /* int floating[8] */ /* Fill in the __va_ctl. */ asm (" st.l sp, 80(sp)"); /* __va_ctl points to __va_struct. */ asm (" st.l r28,84(sp)"); /* pointer to more args */ asm (" st.l r0, 88(sp)"); /* nfixed */ asm (" st.l r0, 92(sp)"); /* nfloating */ asm (" adds 80,sp,r16"); /* return address of the __va_ctl. */ asm (" bri r1"); asm (" mov r30,sp"); /* recover stack and pass address to start of data. */ #endif /* not __PARAGON__ */ #endif /* not __svr4__ */ #else /* not __i860__ */ #ifdef __sparc__ asm (".global __builtin_saveregs"); asm ("__builtin_saveregs:"); asm (".global ___builtin_saveregs"); asm ("___builtin_saveregs:"); #ifdef NEED_PROC_COMMAND asm (".proc 020"); #endif asm ("st %i0,[%fp+68]"); asm ("st %i1,[%fp+72]"); asm ("st %i2,[%fp+76]"); asm ("st %i3,[%fp+80]"); asm ("st %i4,[%fp+84]"); asm ("retl"); asm ("st %i5,[%fp+88]"); #ifdef NEED_TYPE_COMMAND asm (".type __builtin_saveregs,#function"); asm (".size __builtin_saveregs,.-__builtin_saveregs"); #endif #else /* not __sparc__ */ #if defined(__MIPSEL__) | defined(__R3000__) | defined(__R2000__) | defined(__mips__) asm (" .text"); asm (" .ent __builtin_saveregs"); asm (" .globl __builtin_saveregs"); asm ("__builtin_saveregs:"); asm (" sw $4,0($30)"); asm (" sw $5,4($30)"); asm (" sw $6,8($30)"); asm (" sw $7,12($30)"); asm (" j $31"); asm (" .end __builtin_saveregs"); #else /* not __mips__, etc. */ __builtin_saveregs () { abort (); } #endif /* not __mips__ */ #endif /* not __sparc__ */ #endif /* not __i860__ */ #endif #ifdef L_eprintf #ifndef inhibit_libc #undef NULL /* Avoid errors if stdio.h and our stddef.h mismatch. */ #include /* This is used by the `assert' macro. */ void __eprintf (string, expression, line, filename) const char *string; const char *expression; int line; const char *filename; { fprintf (stderr, string, expression, line, filename); fflush (stderr); abort (); } #endif #endif #ifdef L_bb /* Structure emitted by -a */ struct bb { long zero_word; const char *filename; long *counts; long ncounts; struct bb *next; const unsigned long *addresses; /* Older GCC's did not emit these fields. */ long nwords; const char **functions; const long *line_nums; const char **filenames; }; #ifdef BLOCK_PROFILER_CODE BLOCK_PROFILER_CODE #else #ifndef inhibit_libc /* Simple minded basic block profiling output dumper for systems that don't provde tcov support. At present, it requires atexit and stdio. */ #undef NULL /* Avoid errors if stdio.h and our stddef.h mismatch. */ #include #ifdef HAVE_ATEXIT extern void atexit (void (*) (void)); #define ON_EXIT(FUNC,ARG) atexit ((FUNC)) #else #ifdef sun extern void on_exit (void*, void*); #define ON_EXIT(FUNC,ARG) on_exit ((FUNC), (ARG)) #endif #endif static struct bb *bb_head = (struct bb *)0; /* Return the number of digits needed to print a value */ /* __inline__ */ static int num_digits (long value, int base) { int minus = (value < 0 && base != 16); unsigned long v = (minus) ? -value : value; int ret = minus; do { v /= base; ret++; } while (v); return ret; } void __bb_exit_func (void) { FILE *file = fopen ("bb.out", "a"); long time_value; if (!file) perror ("bb.out"); else { struct bb *ptr; /* This is somewhat type incorrect, but it avoids worrying about exactly where time.h is included from. It should be ok unless a void * differs from other pointer formats, or if sizeof(long) is < sizeof (time_t). It would be nice if we could assume the use of rationale standards here. */ time((void *) &time_value); fprintf (file, "Basic block profiling finished on %s\n", ctime ((void *) &time_value)); /* We check the length field explicitly in order to allow compatibility with older GCC's which did not provide it. */ for (ptr = bb_head; ptr != (struct bb *)0; ptr = ptr->next) { int i; int func_p = (ptr->nwords >= sizeof (struct bb) && ptr->nwords <= 1000); int line_p = (func_p && ptr->line_nums); int file_p = (func_p && ptr->filenames); long ncounts = ptr->ncounts; long cnt_max = 0; long line_max = 0; long addr_max = 0; int file_len = 0; int func_len = 0; int blk_len = num_digits (ncounts, 10); int cnt_len; int line_len; int addr_len; fprintf (file, "File %s, %ld basic blocks \n\n", ptr->filename, ncounts); /* Get max values for each field. */ for (i = 0; i < ncounts; i++) { const char *p; int len; if (cnt_max < ptr->counts[i]) cnt_max = ptr->counts[i]; if (addr_max < ptr->addresses[i]) addr_max = ptr->addresses[i]; if (line_p && line_max < ptr->line_nums[i]) line_max = ptr->line_nums[i]; if (func_p) { p = (ptr->functions[i]) ? (ptr->functions[i]) : ""; len = strlen (p); if (func_len < len) func_len = len; } if (file_p) { p = (ptr->filenames[i]) ? (ptr->filenames[i]) : ""; len = strlen (p); if (file_len < len) file_len = len; } } addr_len = num_digits (addr_max, 16); cnt_len = num_digits (cnt_max, 10); line_len = num_digits (line_max, 10); /* Now print out the basic block information. */ for (i = 0; i < ncounts; i++) { fprintf (file, " Block #%*d: executed %*ld time(s) address= 0x%.*lx", blk_len, i+1, cnt_len, ptr->counts[i], addr_len, ptr->addresses[i]); if (func_p) fprintf (file, " function= %-*s", func_len, (ptr->functions[i]) ? ptr->functions[i] : ""); if (line_p) fprintf (file, " line= %*d", line_len, ptr->line_nums[i]); if (file_p) fprintf (file, " file= %s", (ptr->filenames[i]) ? ptr->filenames[i] : ""); fprintf (file, "\n"); } fprintf (file, "\n"); fflush (file); } fprintf (file, "\n\n"); fclose (file); } } void __bb_init_func (struct bb *blocks) { /* User is supposed to check whether the first word is non-0, but just in case.... */ if (blocks->zero_word) return; #ifdef ON_EXIT /* Initialize destructor. */ if (!bb_head) ON_EXIT (__bb_exit_func, 0); #endif /* Set up linked list. */ blocks->zero_word = 1; blocks->next = bb_head; bb_head = blocks; } #endif /* not inhibit_libc */ #endif /* not BLOCK_PROFILER_CODE */ #endif /* L_bb */ /* frills for C++ */ #ifdef L_op_new typedef void (*vfp)(void); extern vfp __new_handler; /* void * operator new (size_t sz) */ void * __builtin_new (size_t sz) { void *p; /* malloc (0) is unpredictable; avoid it. */ if (sz == 0) sz = 1; p = (void *) malloc (sz); if (p == 0) (*__new_handler) (); return p; } #endif /* L_op_new */ #ifdef L_new_handler #ifndef inhibit_libc /* This gets us __GNU_LIBRARY__. */ #undef NULL /* Avoid errors if stdio.h and our stddef.h mismatch. */ #include #ifdef __GNU_LIBRARY__ /* Avoid forcing the library's meaning of `write' on the user program by using the "internal" name (for use within the library) */ #define write(fd, buf, n) __write((fd), (buf), (n)) #endif #endif /* inhibit_libc */ typedef void (*vfp)(void); extern void *__builtin_new (size_t); static void default_new_handler (void); vfp __new_handler = default_new_handler; vfp __set_new_handler (handler) vfp handler; { vfp prev_handler; prev_handler = __new_handler; if (handler == 0) handler = default_new_handler; __new_handler = handler; return prev_handler; } vfp set_new_handler (handler) vfp handler; { return __set_new_handler (handler); } #define MESSAGE "Virtual memory exceeded in `new'\n" static void default_new_handler () { /* don't use fprintf (stderr, ...) because it may need to call malloc. */ /* This should really print the name of the program, but that is hard to do. We need a standard, clean way to get at the name. */ write (2, MESSAGE, sizeof (MESSAGE)); /* don't call exit () because that may call global destructors which may cause a loop. */ _exit (-1); } #endif #ifdef L_op_delete /* void operator delete (void *ptr) */ void __builtin_delete (void *ptr) { if (ptr) free (ptr); } #endif #ifdef L_shtab unsigned int __shtab[] = { 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000020, 0x00000040, 0x00000080, 0x00000100, 0x00000200, 0x00000400, 0x00000800, 0x00001000, 0x00002000, 0x00004000, 0x00008000, 0x00010000, 0x00020000, 0x00040000, 0x00080000, 0x00100000, 0x00200000, 0x00400000, 0x00800000, 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000 }; #endif #ifdef L_clear_cache /* Clear part of an instruction cache. */ #define INSN_CACHE_PLANE_SIZE (INSN_CACHE_SIZE / INSN_CACHE_DEPTH) void __clear_cache (beg, end) char *beg, *end; { #ifdef CLEAR_INSN_CACHE CLEAR_INSN_CACHE (beg, end); #else #ifdef INSN_CACHE_SIZE static char array[INSN_CACHE_SIZE + INSN_CACHE_PLANE_SIZE + INSN_CACHE_LINE_WIDTH]; static int initialized = 0; int offset; void *start_addr void *end_addr; typedef (*function_ptr) (); #if (INSN_CACHE_SIZE / INSN_CACHE_LINE_WIDTH) < 16 /* It's cheaper to clear the whole cache. Put in a series of jump instructions so that calling the beginning of the cache will clear the whole thing. */ if (! initialized) { int ptr = (((int) array + INSN_CACHE_LINE_WIDTH - 1) & -INSN_CACHE_LINE_WIDTH); int end_ptr = ptr + INSN_CACHE_SIZE; while (ptr < end_ptr) { *(INSTRUCTION_TYPE *)ptr = JUMP_AHEAD_INSTRUCTION + INSN_CACHE_LINE_WIDTH; ptr += INSN_CACHE_LINE_WIDTH; } *(INSTRUCTION_TYPE *)(ptr - INSN_CACHE_LINE_WIDTH) = RETURN_INSTRUCTION; initialized = 1; } /* Call the beginning of the sequence. */ (((function_ptr) (((int) array + INSN_CACHE_LINE_WIDTH - 1) & -INSN_CACHE_LINE_WIDTH)) ()); #else /* Cache is large. */ if (! initialized) { int ptr = (((int) array + INSN_CACHE_LINE_WIDTH - 1) & -INSN_CACHE_LINE_WIDTH); while (ptr < (int) array + sizeof array) { *(INSTRUCTION_TYPE *)ptr = RETURN_INSTRUCTION; ptr += INSN_CACHE_LINE_WIDTH; } initialized = 1; } /* Find the location in array that occupies the same cache line as BEG. */ offset = ((int) beg & -INSN_CACHE_LINE_WIDTH) & (INSN_CACHE_PLANE_SIZE - 1); start_addr = (((int) (array + INSN_CACHE_PLANE_SIZE - 1) & -INSN_CACHE_PLANE_SIZE) + offset); /* Compute the cache alignment of the place to stop clearing. */ #if 0 /* This is not needed for gcc's purposes. */ /* If the block to clear is bigger than a cache plane, we clear the entire cache, and OFFSET is already correct. */ if (end < beg + INSN_CACHE_PLANE_SIZE) #endif offset = (((int) (end + INSN_CACHE_LINE_WIDTH - 1) & -INSN_CACHE_LINE_WIDTH) & (INSN_CACHE_PLANE_SIZE - 1)); #if INSN_CACHE_DEPTH > 1 end_addr = (start_addr & -INSN_CACHE_PLANE_SIZE) + offset; if (end_addr <= start_addr) end_addr += INSN_CACHE_PLANE_SIZE; for (plane = 0; plane < INSN_CACHE_DEPTH; plane++) { int addr = start_addr + plane * INSN_CACHE_PLANE_SIZE; int stop = end_addr + plane * INSN_CACHE_PLANE_SIZE; while (addr != stop) { /* Call the return instruction at ADDR. */ ((function_ptr) addr) (); addr += INSN_CACHE_LINE_WIDTH; } } #else /* just one plane */ do { /* Call the return instruction at START_ADDR. */ ((function_ptr) start_addr) (); start_addr += INSN_CACHE_LINE_WIDTH; } while ((start_addr % INSN_CACHE_SIZE) != offset); #endif /* just one plane */ #endif /* Cache is large */ #endif /* Cache exists */ #endif /* CLEAR_INSN_CACHE */ } #endif /* L_clear_cache */ #ifdef L_trampoline /* Jump to a trampoline, loading the static chain address. */ #ifdef TRANSFER_FROM_TRAMPOLINE TRANSFER_FROM_TRAMPOLINE #endif #if defined (NeXT) && defined (__MACH__) /* Make stack executable so we can call trampolines on stack. This is called from INITIALIZE_TRAMPOLINE in next.h. */ #include void __enable_execute_stack (addr) char *addr; { kern_return_t r; char *eaddr = addr + TRAMPOLINE_SIZE; vm_address_t a = (vm_address_t) addr; /* turn on execute access on stack */ r = vm_protect (task_self (), a, TRAMPOLINE_SIZE, FALSE, VM_PROT_ALL); if (r != KERN_SUCCESS) { mach_error("vm_protect VM_PROT_ALL", r); exit(1); } /* We inline the i-cache invalidation for speed */ #ifdef CLEAR_INSN_CACHE CLEAR_INSN_CACHE (addr, eaddr); #else __clear_cache ((int) addr, (int) eaddr); #endif } #endif /* defined (NeXT) && defined (__MACH__) */ #ifdef __convex__ /* Make stack executable so we can call trampolines on stack. This is called from INITIALIZE_TRAMPOLINE in convex.h. */ #include #include #include void __enable_execute_stack () { int fp; static unsigned lowest = USRSTACK; unsigned current = (unsigned) &fp & -NBPG; if (lowest > current) { unsigned len = lowest - current; mremap (current, &len, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE); lowest = current; } /* Clear instruction cache in case an old trampoline is in it. */ asm ("pich"); } #endif /* __convex__ */ #ifdef __pyr__ #undef NULL /* Avoid errors if stdio.h and our stddef.h mismatch. */ #include #include #include #include #include /* Modified from the convex -code above. mremap promises to clear the i-cache. */ void __enable_execute_stack () { int fp; if (mprotect (((unsigned int)&fp/PAGSIZ)*PAGSIZ, PAGSIZ, PROT_READ|PROT_WRITE|PROT_EXEC)) { perror ("mprotect in __enable_execute_stack"); fflush (stderr); abort (); } } #endif /* __pyr__ */ #endif /* L_trampoline */ #ifdef L__main #include "gbl-ctors.h" /* Some systems use __main in a way incompatible with its use in gcc, in these cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to give the same symbol without quotes for an alternative entry point. You must define both, or niether. */ #ifndef NAME__MAIN #define NAME__MAIN "__main" #define SYMBOL__MAIN __main #endif /* Run all the global destructors on exit from the program. */ void __do_global_dtors () { #ifdef DO_GLOBAL_DTORS_BODY DO_GLOBAL_DTORS_BODY; #else unsigned nptrs = (unsigned HOST_WIDE_INT) __DTOR_LIST__[0]; unsigned i; /* Some systems place the number of pointers in the first word of the table. On other systems, that word is -1. In all cases, the table is null-terminated. */ /* If the length is not recorded, count up to the null. */ if (nptrs == -1) for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++); /* GNU LD format. */ for (i = nptrs; i >= 1; i--) __DTOR_LIST__[i] (); #endif } #ifndef INIT_SECTION_ASM_OP /* Run all the global constructors on entry to the program. */ #ifndef ON_EXIT #define ON_EXIT(a, b) #else /* Make sure the exit routine is pulled in to define the globals as bss symbols, just in case the linker does not automatically pull bss definitions from the library. */ extern int _exit_dummy_decl; int *_exit_dummy_ref = &_exit_dummy_decl; #endif /* ON_EXIT */ void __do_global_ctors () { DO_GLOBAL_CTORS_BODY; ON_EXIT (__do_global_dtors, 0); } #endif /* no INIT_SECTION_ASM_OP */ #if !defined (INIT_SECTION_ASM_OP) || defined (INVOKE__main) /* Subroutine called automatically by `main'. Compiling a global function named `main' produces an automatic call to this function at the beginning. For many systems, this routine calls __do_global_ctors. For systems which support a .init section we use the .init section to run __do_global_ctors, so we need not do anything here. */ void SYMBOL__MAIN () { /* Support recursive calls to `main': run initializers just once. */ static int initialized = 0; if (! initialized) { initialized = 1; __do_global_ctors (); } } #endif /* no INIT_SECTION_ASM_OP or INVOKE__main */ #endif /* L__main */ #ifdef L_ctors #include "gbl-ctors.h" /* Provide default definitions for the lists of constructors and destructors, so that we don't get linker errors. These symbols are intentionally bss symbols, so that gld and/or collect will provide the right values. */ /* We declare the lists here with two elements each, so that they are valid empty lists if no other definition is loaded. */ #if !defined(INIT_SECTION_ASM_OP) && !defined(CTOR_LISTS_DEFINED_EXTERNALLY) #ifdef __NeXT__ /* After 2.3, try this definition on all systems. */ func_ptr __CTOR_LIST__[2] = {0, 0}; func_ptr __DTOR_LIST__[2] = {0, 0}; #else func_ptr __CTOR_LIST__[2]; func_ptr __DTOR_LIST__[2]; #endif #endif /* no INIT_SECTION_ASM_OP and not CTOR_LISTS_DEFINED_EXTERNALLY */ #endif /* L_ctors */ #ifdef L_exit #include "gbl-ctors.h" #ifndef ON_EXIT /* If we have no known way of registering our own __do_global_dtors routine so that it will be invoked at program exit time, then we have to define our own exit routine which will get this to happen. */ extern void __do_global_dtors (); extern void _cleanup (); extern void _exit () __attribute__ ((noreturn)); void exit (status) int status; { __do_global_dtors (); #ifdef EXIT_BODY EXIT_BODY; #else _cleanup (); #endif _exit (status); } #else int _exit_dummy_decl = 0; /* prevent compiler & linker warnings */ #endif #endif /* L_exit */ /* In a.out systems, we need to have these dummy constructor and destructor lists in the library. When using `collect', the first link will resolve __CTOR_LIST__ and __DTOR_LIST__ to these symbols. We will then run "nm" on the result, build the correct __CTOR_LIST__ and __DTOR_LIST__, and relink. Since we don't do the second link if no constructors existed, these dummies must be fully functional empty lists. When using `gnu ld', these symbols will be used if there are no constructors. If there are constructors, the N_SETV symbol defined by the linker from the N_SETT's in input files will define __CTOR_LIST__ and __DTOR_LIST__ rather than its being allocated as common storage by the definitions below. When using a linker that supports constructor and destructor segments, these definitions will not be used, since crtbegin.o and crtend.o (from crtstuff.c) will have already defined __CTOR_LIST__ and __DTOR_LIST__. The crt*.o files are passed directly to the linker on its command line, by gcc. */ /* The list needs two elements: one is ignored (the old count); the second is the terminating zero. Since both values are zero, this declaration is not initialized, and it becomes `common'. */ #ifdef L_ctor_list #include "gbl-ctors.h" func_ptr __CTOR_LIST__[2]; #endif #ifdef L_dtor_list #include "gbl-ctors.h" func_ptr __DTOR_LIST__[2]; #endif ./libc-linux/gcc/machmode.def100644 1676 334 11442 5471532750 14137 0ustar hjlisl/* This file contains the definitions and documentation for the machine modes used in the the GNU compiler. Copyright (C) 1987, 1992 Free Software Foundation, Inc. This file is part of GNU CC. GNU CC 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. GNU CC 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. */ /* This file defines all the MACHINE MODES used by GNU CC. A machine mode specifies a size and format of data at the machine level. Each RTL expression has a machine mode. At the syntax tree level, each ..._TYPE and each ..._DECL node has a machine mode which describes data of that type or the data of the variable declared. */ /* The first argument is the internal name of the machine mode used in the C source. By convention these are in UPPER_CASE, except for the word "mode". The second argument is the name of the machine mode in the external ASCII format used for reading and printing RTL and trees. By convention these names in UPPER_CASE. Third argument states the kind of representation: MODE_INT - integer MODE_FLOAT - floating MODE_PARTIAL_INT - PSImode and PDImode MODE_CC - modes used for representing the condition code in a register MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT - complex number MODE_RANDOM - anything else Fourth argument is the relative size of the object, in bytes. It is zero when the size is meaningless or not determined. A byte's size is determined by BITS_PER_UNIT in tm.h. Fifth arg is the relative size of subunits of the object. It is same as the fourth argument except for complexes, since they are really made of two equal size subunits. Sixth arg is next wider natural mode of the same class. 0 if there is none. */ /* VOIDmode is used when no mode needs to be specified, as for example on CONST_INT RTL expressions. */ DEF_MACHMODE (VOIDmode, "VOID", MODE_RANDOM, 0, 0, VOIDmode) DEF_MACHMODE (QImode, "QI", MODE_INT, 1, 1, HImode) /* int types */ DEF_MACHMODE (HImode, "HI", MODE_INT, 2, 2, SImode) /* Pointers on some machines use this type to distinguish them from ints. Useful if a pointer is 4 bytes but has some bits that are not significant, so it is really not quite as wide as an integer. */ DEF_MACHMODE (PSImode, "PSI", MODE_PARTIAL_INT, 4, 4, VOIDmode) DEF_MACHMODE (SImode, "SI", MODE_INT, 4, 4, DImode) DEF_MACHMODE (PDImode, "PDI", MODE_PARTIAL_INT, 8, 8, VOIDmode) DEF_MACHMODE (DImode, "DI", MODE_INT, 8, 8, TImode) DEF_MACHMODE (TImode, "TI", MODE_INT, 16, 16, OImode) DEF_MACHMODE (OImode, "OI", MODE_INT, 32, 32, VOIDmode) DEF_MACHMODE (QFmode, "QF", MODE_FLOAT, 1, 1, HFmode) DEF_MACHMODE (HFmode, "HF", MODE_FLOAT, 2, 2, SFmode) DEF_MACHMODE (SFmode, "SF", MODE_FLOAT, 4, 4, DFmode) DEF_MACHMODE (DFmode, "DF", MODE_FLOAT, 8, 8, XFmode) DEF_MACHMODE (XFmode, "XF", MODE_FLOAT, 12, 12, TFmode) /* IEEE extended */ DEF_MACHMODE (TFmode, "TF", MODE_FLOAT, 16, 16, VOIDmode) /* Complex modes. */ DEF_MACHMODE (SCmode, "SC", MODE_COMPLEX_FLOAT, 8, 4, DCmode) DEF_MACHMODE (DCmode, "DC", MODE_COMPLEX_FLOAT, 16, 8, XCmode) DEF_MACHMODE (XCmode, "XC", MODE_COMPLEX_FLOAT, 24, 12, TCmode) DEF_MACHMODE (TCmode, "TC", MODE_COMPLEX_FLOAT, 32, 16, VOIDmode) DEF_MACHMODE (CQImode, "CQI", MODE_COMPLEX_INT, 2, 1, CHImode) DEF_MACHMODE (CHImode, "CHI", MODE_COMPLEX_INT, 4, 2, CSImode) DEF_MACHMODE (CSImode, "CSI", MODE_COMPLEX_INT, 8, 4, CDImode) DEF_MACHMODE (CDImode, "CDI", MODE_COMPLEX_INT, 16, 8, CTImode) DEF_MACHMODE (CTImode, "CTI", MODE_COMPLEX_INT, 32, 16, COImode) DEF_MACHMODE (COImode, "COI", MODE_COMPLEX_INT, 64, 32, VOIDmode) /* BLKmode is used for structures, arrays, etc. that fit no more specific mode. */ DEF_MACHMODE (BLKmode, "BLK", MODE_RANDOM, 0, 0, VOIDmode) /* The modes for representing the condition codes come last. CCmode is always defined. Additional modes for the condition code can be specified in the EXTRA_CC_MODES macro. Everything but the names of the modes are copied from CCmode. For these modes, GET_MODE_WIDER_MODE points to the next defined CC mode, if any. */ DEF_MACHMODE (CCmode, "CC", MODE_CC, 4, 4, VOIDmode) /* The symbol Pmode stands for one of the above machine modes (usually SImode). The tm file specifies which one. It is not a distinct mode. */ /* Local variables: mode:c version-control: t End: */ ./libc-linux/gcc/machmode.h100644 1676 334 12556 5471532751 13640 0ustar hjlisl/* Machine mode definitions for GNU C-Compiler; included by rtl.h and tree.h. Copyright (C) 1991, 1993 Free Software Foundation, Inc. This file is part of GNU CC. GNU CC 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. GNU CC 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. */ /* Add prototype support. */ #ifndef PROTO #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) #define PROTO(ARGS) ARGS #else #define PROTO(ARGS) () #endif #endif #ifndef HAVE_MACHINE_MODES /* Strictly speaking, this isn't the proper place to include these definitions, but this file is included by every GCC file. Some systems define these in, e.g., param.h. We undefine these names here to avoid the warnings. We prefer to use our definitions since we know they are correct. */ #undef MIN #undef MAX #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) #define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) /* Find the largest host integer type and set its size and type. */ #ifndef HOST_BITS_PER_WIDE_INT #if HOST_BITS_PER_LONG > HOST_BITS_PER_INT #define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG #define HOST_WIDE_INT long #else #define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT #define HOST_WIDE_INT int #endif #endif /* Define the number of entries in an 8-bit `shorts' array needed to represent the largest supported constant, which is twice the width of the largest host integer type. */ #ifndef MAX_SHORTS #define MAX_SHORTS (HOST_BITS_PER_WIDE_INT * 2 / 8) #endif /* Provide a default way to print an address in hex via printf. */ #ifndef HOST_PTR_PRINTF #define HOST_PTR_PRINTF sizeof (int) == sizeof (char *) ? "%x" : "%lx" #endif /* Make an enum class that gives all the machine modes. */ #define DEF_MACHMODE(SYM, NAME, TYPE, SIZE, UNIT, WIDER) SYM, enum machine_mode { #include "machmode.def" #ifdef EXTRA_CC_MODES EXTRA_CC_MODES, #endif MAX_MACHINE_MODE }; #undef DEF_MACHMODE #define HAVE_MACHINE_MODES #ifndef NUM_MACHINE_MODES #define NUM_MACHINE_MODES (int) MAX_MACHINE_MODE #endif /* Get the name of mode MODE as a string. */ extern char *mode_name[]; #define GET_MODE_NAME(MODE) (mode_name[(int)(MODE)]) enum mode_class { MODE_RANDOM, MODE_INT, MODE_FLOAT, MODE_PARTIAL_INT, MODE_CC, MODE_COMPLEX_INT, MODE_COMPLEX_FLOAT, MAX_MODE_CLASS}; /* Get the general kind of object that mode MODE represents (integer, floating, complex, etc.) */ extern enum mode_class mode_class[]; #define GET_MODE_CLASS(MODE) (mode_class[(int)(MODE)]) /* Nonzero if MODE is an integral mode. */ #define INTEGRAL_MODE_P(MODE) \ (GET_MODE_CLASS (MODE) == MODE_INT \ || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \ || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT) /* Nonzero if MODE is a floating-point mode. */ #define FLOAT_MODE_P(MODE) \ (GET_MODE_CLASS (MODE) == MODE_FLOAT \ || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) /* Get the size in bytes of an object of mode MODE. */ extern int mode_size[]; #define GET_MODE_SIZE(MODE) (mode_size[(int)(MODE)]) /* Get the size in bytes of the basic parts of an object of mode MODE. */ extern int mode_unit_size[]; #define GET_MODE_UNIT_SIZE(MODE) (mode_unit_size[(int)(MODE)]) /* Get the number of units in the object. */ #define GET_MODE_NUNITS(MODE) \ ((GET_MODE_UNIT_SIZE ((MODE)) == 0) ? 0 \ : (GET_MODE_SIZE ((MODE)) / GET_MODE_UNIT_SIZE ((MODE)))) /* Get the size in bits of an object of mode MODE. */ #define GET_MODE_BITSIZE(MODE) (BITS_PER_UNIT * mode_size[(int)(MODE)]) /* Get a bitmask containing 1 for all bits in a word that fit within mode MODE. */ #define GET_MODE_MASK(MODE) \ ((GET_MODE_BITSIZE (MODE) >= HOST_BITS_PER_WIDE_INT) \ ?(HOST_WIDE_INT) ~0 : (((HOST_WIDE_INT) 1 << GET_MODE_BITSIZE (MODE)) - 1)) /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */ extern enum machine_mode mode_wider_mode[]; #define GET_MODE_WIDER_MODE(MODE) (mode_wider_mode[(int)(MODE)]) /* Return the mode for data of a given size SIZE and mode class CLASS. If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE. The value is BLKmode if no other mode is found. */ extern enum machine_mode mode_for_size PROTO((unsigned int, enum mode_class, int)); /* Find the best mode to use to access a bit field. */ extern enum machine_mode get_best_mode PROTO((int, int, int, enum machine_mode, int)); /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */ #define GET_MODE_ALIGNMENT(MODE) \ MIN (BIGGEST_ALIGNMENT, \ MAX (1, (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT))) /* For each class, get the narrowest mode in that class. */ extern enum machine_mode class_narrowest_mode[]; #define GET_CLASS_NARROWEST_MODE(CLASS) class_narrowest_mode[(int)(CLASS)] /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD. */ extern enum machine_mode byte_mode; extern enum machine_mode word_mode; #endif /* not HAVE_MACHINE_MODES */ ./libc-linux/gcc/aliases.c100644 1676 334 366 5512712502 13421 0ustar hjlisl#include /* Although we keep those functions in the jump table. But we * have removed the entry point to outside. So we need the * alias to bypass the jump table. */ symbol_alias (__set_new_handler__LOCAL__,__set_new_handler); ./libc-linux/gcc/libgcc1.c100644 1676 334 26404 5471532750 13356 0ustar hjlisl/* Subroutines needed by GCC output code on some machines. */ /* Compile this file with the Unix C compiler! */ /* Copyright (C) 1987, 1988, 1992 Free Software Foundation, Inc. This file 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. In addition to the permissions in the GNU General Public License, the Free Software Foundation gives you unlimited permission to link the compiled version of this file with other programs, and to distribute those programs without any restriction coming from the use of this file. (The General Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into another program.) This file 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 this program; 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 GCC 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 "config.h" /* Don't use `fancy_abort' here even if config.h says to use it. */ #ifdef abort #undef abort #endif /* On some machines, cc is really GCC. For these machines, we can't expect these functions to be properly compiled unless GCC open codes the operation (which is precisely when the function won't be used). So allow tm.h to specify ways of accomplishing the operations by defining the macros perform_*. On a machine where cc is some other compiler, there is usually no reason to define perform_*. The other compiler normally has other ways of implementing all of these operations. In some cases a certain machine may come with GCC installed as cc or may have some other compiler. Then it may make sense for tm.h to define perform_* only if __GNUC__ is defined. */ #ifndef perform_mulsi3 #define perform_mulsi3(a, b) return a * b #endif #ifndef perform_divsi3 #define perform_divsi3(a, b) return a / b #endif #ifndef perform_udivsi3 #define perform_udivsi3(a, b) return a / b #endif #ifndef perform_modsi3 #define perform_modsi3(a, b) return a % b #endif #ifndef perform_umodsi3 #define perform_umodsi3(a, b) return a % b #endif #ifndef perform_lshrsi3 #define perform_lshrsi3(a, b) return a >> b #endif #ifndef perform_lshlsi3 #define perform_lshlsi3(a, b) return a << b #endif #ifndef perform_ashrsi3 #define perform_ashrsi3(a, b) return a >> b #endif #ifndef perform_ashlsi3 #define perform_ashlsi3(a, b) return a << b #endif #ifndef perform_adddf3 #define perform_adddf3(a, b) return a + b #endif #ifndef perform_subdf3 #define perform_subdf3(a, b) return a - b #endif #ifndef perform_muldf3 #define perform_muldf3(a, b) return a * b #endif #ifndef perform_divdf3 #define perform_divdf3(a, b) return a / b #endif #ifndef perform_addsf3 #define perform_addsf3(a, b) return INTIFY (a + b) #endif #ifndef perform_subsf3 #define perform_subsf3(a, b) return INTIFY (a - b) #endif #ifndef perform_mulsf3 #define perform_mulsf3(a, b) return INTIFY (a * b) #endif #ifndef perform_divsf3 #define perform_divsf3(a, b) return INTIFY (a / b) #endif #ifndef perform_negdf2 #define perform_negdf2(a) return -a #endif #ifndef perform_negsf2 #define perform_negsf2(a) return INTIFY (-a) #endif #ifndef perform_fixdfsi #define perform_fixdfsi(a) return (nongcc_SI_type) a; #endif #ifndef perform_fixsfsi #define perform_fixsfsi(a) return (nongcc_SI_type) a #endif #ifndef perform_floatsidf #define perform_floatsidf(a) return (double) a #endif #ifndef perform_floatsisf #define perform_floatsisf(a) return INTIFY ((float) a) #endif #ifndef perform_extendsfdf2 #define perform_extendsfdf2(a) return a #endif #ifndef perform_truncdfsf2 #define perform_truncdfsf2(a) return INTIFY (a) #endif /* Note that eqdf2 returns a value for "true" that is == 0, nedf2 returns a value for "true" that is != 0, gtdf2 returns a value for "true" that is > 0, and so on. */ #ifndef perform_eqdf2 #define perform_eqdf2(a, b) return !(a == b) #endif #ifndef perform_nedf2 #define perform_nedf2(a, b) return a != b #endif #ifndef perform_gtdf2 #define perform_gtdf2(a, b) return a > b #endif #ifndef perform_gedf2 #define perform_gedf2(a, b) return (a >= b) - 1 #endif #ifndef perform_ltdf2 #define perform_ltdf2(a, b) return -(a < b) #endif #ifndef perform_ledf2 #define perform_ledf2(a, b) return 1 - (a <= b) #endif #ifndef perform_eqsf2 #define perform_eqsf2(a, b) return !(a == b) #endif #ifndef perform_nesf2 #define perform_nesf2(a, b) return a != b #endif #ifndef perform_gtsf2 #define perform_gtsf2(a, b) return a > b #endif #ifndef perform_gesf2 #define perform_gesf2(a, b) return (a >= b) - 1 #endif #ifndef perform_ltsf2 #define perform_ltsf2(a, b) return -(a < b) #endif #ifndef perform_lesf2 #define perform_lesf2(a, b) return 1 - (a <= b); #endif /* Define the C data type to use for an SImode value. */ #ifndef nongcc_SI_type #define nongcc_SI_type long int #endif /* Define the C data type to use for a value of word size */ #ifndef nongcc_word_type #define nongcc_word_type nongcc_SI_type #endif /* Define the type to be used for returning an SF mode value and the method for turning a float into that type. These definitions work for machines where an SF value is returned in the same register as an int. */ #ifndef FLOAT_VALUE_TYPE #define FLOAT_VALUE_TYPE int #endif #ifndef INTIFY #define INTIFY(FLOATVAL) (intify.f = (FLOATVAL), intify.i) #endif #ifndef FLOATIFY #define FLOATIFY(INTVAL) ((INTVAL).f) #endif #ifndef FLOAT_ARG_TYPE #define FLOAT_ARG_TYPE union flt_or_int #endif union flt_or_value { FLOAT_VALUE_TYPE i; float f; }; union flt_or_int { int i; float f; }; #ifdef L_mulsi3 nongcc_SI_type __mulsi3 (a, b) nongcc_SI_type a, b; { perform_mulsi3 (a, b); } #endif #ifdef L_udivsi3 nongcc_SI_type __udivsi3 (a, b) unsigned nongcc_SI_type a, b; { perform_udivsi3 (a, b); } #endif #ifdef L_divsi3 nongcc_SI_type __divsi3 (a, b) nongcc_SI_type a, b; { perform_divsi3 (a, b); } #endif #ifdef L_umodsi3 nongcc_SI_type __umodsi3 (a, b) unsigned nongcc_SI_type a, b; { perform_umodsi3 (a, b); } #endif #ifdef L_modsi3 nongcc_SI_type __modsi3 (a, b) nongcc_SI_type a, b; { perform_modsi3 (a, b); } #endif #ifdef L_lshrsi3 nongcc_SI_type __lshrsi3 (a, b) unsigned nongcc_SI_type a, b; { perform_lshrsi3 (a, b); } #endif #ifdef L_lshlsi3 nongcc_SI_type __lshlsi3 (a, b) unsigned nongcc_SI_type a, b; { perform_lshlsi3 (a, b); } #endif #ifdef L_ashrsi3 nongcc_SI_type __ashrsi3 (a, b) nongcc_SI_type a, b; { perform_ashrsi3 (a, b); } #endif #ifdef L_ashlsi3 nongcc_SI_type __ashlsi3 (a, b) nongcc_SI_type a, b; { perform_ashlsi3 (a, b); } #endif #ifdef L_divdf3 double __divdf3 (a, b) double a, b; { perform_divdf3 (a, b); } #endif #ifdef L_muldf3 double __muldf3 (a, b) double a, b; { perform_muldf3 (a, b); } #endif #ifdef L_negdf2 double __negdf2 (a) double a; { perform_negdf2 (a); } #endif #ifdef L_adddf3 double __adddf3 (a, b) double a, b; { perform_adddf3 (a, b); } #endif #ifdef L_subdf3 double __subdf3 (a, b) double a, b; { perform_subdf3 (a, b); } #endif /* Note that eqdf2 returns a value for "true" that is == 0, nedf2 returns a value for "true" that is != 0, gtdf2 returns a value for "true" that is > 0, and so on. */ #ifdef L_eqdf2 nongcc_word_type __eqdf2 (a, b) double a, b; { /* Value == 0 iff a == b. */ perform_eqdf2 (a, b); } #endif #ifdef L_nedf2 nongcc_word_type __nedf2 (a, b) double a, b; { /* Value != 0 iff a != b. */ perform_nedf2 (a, b); } #endif #ifdef L_gtdf2 nongcc_word_type __gtdf2 (a, b) double a, b; { /* Value > 0 iff a > b. */ perform_gtdf2 (a, b); } #endif #ifdef L_gedf2 nongcc_word_type __gedf2 (a, b) double a, b; { /* Value >= 0 iff a >= b. */ perform_gedf2 (a, b); } #endif #ifdef L_ltdf2 nongcc_word_type __ltdf2 (a, b) double a, b; { /* Value < 0 iff a < b. */ perform_ltdf2 (a, b); } #endif #ifdef L_ledf2 nongcc_word_type __ledf2 (a, b) double a, b; { /* Value <= 0 iff a <= b. */ perform_ledf2 (a, b); } #endif #ifdef L_fixdfsi nongcc_SI_type __fixdfsi (a) double a; { perform_fixdfsi (a); } #endif #ifdef L_fixsfsi nongcc_SI_type __fixsfsi (a) FLOAT_ARG_TYPE a; { union flt_or_value intify; perform_fixsfsi (FLOATIFY (a)); } #endif #ifdef L_floatsidf double __floatsidf (a) nongcc_SI_type a; { perform_floatsidf (a); } #endif #ifdef L_floatsisf FLOAT_VALUE_TYPE __floatsisf (a) nongcc_SI_type a; { union flt_or_value intify; perform_floatsisf (a); } #endif #ifdef L_addsf3 FLOAT_VALUE_TYPE __addsf3 (a, b) FLOAT_ARG_TYPE a, b; { union flt_or_value intify; perform_addsf3 (FLOATIFY (a), FLOATIFY (b)); } #endif #ifdef L_negsf2 FLOAT_VALUE_TYPE __negsf2 (a) FLOAT_ARG_TYPE a; { union flt_or_value intify; perform_negsf2 (FLOATIFY (a)); } #endif #ifdef L_subsf3 FLOAT_VALUE_TYPE __subsf3 (a, b) FLOAT_ARG_TYPE a, b; { union flt_or_value intify; perform_subsf3 (FLOATIFY (a), FLOATIFY (b)); } #endif #ifdef L_eqsf2 nongcc_word_type __eqsf2 (a, b) FLOAT_ARG_TYPE a, b; { union flt_or_int intify; /* Value == 0 iff a == b. */ perform_eqsf2 (FLOATIFY (a), FLOATIFY (b)); } #endif #ifdef L_nesf2 nongcc_word_type __nesf2 (a, b) FLOAT_ARG_TYPE a, b; { union flt_or_int intify; /* Value != 0 iff a != b. */ perform_nesf2 (FLOATIFY (a), FLOATIFY (b)); } #endif #ifdef L_gtsf2 nongcc_word_type __gtsf2 (a, b) FLOAT_ARG_TYPE a, b; { union flt_or_int intify; /* Value > 0 iff a > b. */ perform_gtsf2 (FLOATIFY (a), FLOATIFY (b)); } #endif #ifdef L_gesf2 nongcc_word_type __gesf2 (a, b) FLOAT_ARG_TYPE a, b; { union flt_or_int intify; /* Value >= 0 iff a >= b. */ perform_gesf2 (FLOATIFY (a), FLOATIFY (b)); } #endif #ifdef L_ltsf2 nongcc_word_type __ltsf2 (a, b) FLOAT_ARG_TYPE a, b; { union flt_or_int intify; /* Value < 0 iff a < b. */ perform_ltsf2 (FLOATIFY (a), FLOATIFY (b)); } #endif #ifdef L_lesf2 nongcc_word_type __lesf2 (a, b) FLOAT_ARG_TYPE a, b; { union flt_or_int intify; /* Value <= 0 iff a <= b. */ perform_lesf2 (FLOATIFY (a), FLOATIFY (b)); } #endif #ifdef L_mulsf3 FLOAT_VALUE_TYPE __mulsf3 (a, b) FLOAT_ARG_TYPE a, b; { union flt_or_value intify; perform_mulsf3 (FLOATIFY (a), FLOATIFY (b)); } #endif #ifdef L_divsf3 FLOAT_VALUE_TYPE __divsf3 (a, b) FLOAT_ARG_TYPE a, b; { union flt_or_value intify; perform_divsf3 (FLOATIFY (a), FLOATIFY (b)); } #endif #ifdef L_truncdfsf2 FLOAT_VALUE_TYPE __truncdfsf2 (a) double a; { union flt_or_value intify; perform_truncdfsf2 (a); } #endif #ifdef L_extendsfdf2 double __extendsfdf2 (a) FLOAT_ARG_TYPE a; { union flt_or_value intify; perform_extendsfdf2 (FLOATIFY (a)); } #endif ./libc-linux/gcc/longlong.h100644 1676 334 72007 5471532750 13676 0ustar hjlisl/* longlong.h -- definitions for mixed size 32/64 bit arithmetic. Copyright (C) 1991, 1992 Free Software Foundation, Inc. This definition file 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 definition file 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef SI_TYPE_SIZE #define SI_TYPE_SIZE 32 #endif #define __BITS4 (SI_TYPE_SIZE / 4) #define __ll_B (1L << (SI_TYPE_SIZE / 2)) #define __ll_lowpart(t) ((USItype) (t) % __ll_B) #define __ll_highpart(t) ((USItype) (t) / __ll_B) /* Define auxiliary asm macros. 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand) multiplies two USItype integers MULTIPLER and MULTIPLICAND, and generates a two-part USItype product in HIGH_PROD and LOW_PROD. 2) __umulsidi3(a,b) multiplies two USItype integers A and B, and returns a UDItype product. This is just a variant of umul_ppmm. 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator, denominator) divides a two-word unsigned integer, composed by the integers HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less than DENOMINATOR for correct operation. If, in addition, the most significant bit of DENOMINATOR must be 1, then the pre-processor symbol UDIV_NEEDS_NORMALIZATION is defined to 1. 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator, denominator). Like udiv_qrnnd but the numbers are signed. The quotient is rounded towards 0. 5) count_leading_zeros(count, x) counts the number of zero-bits from the msb to the first non-zero bit. This is the number of steps X needs to be shifted left to set the msb. Undefined for X == 0. 6) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1, high_addend_2, low_addend_2) adds two two-word unsigned integers, composed by HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2 respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow (i.e. carry out) is not stored anywhere, and is lost. 7) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend, high_subtrahend, low_subtrahend) subtracts two two-word unsigned integers, composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere, and is lost. If any of these macros are left undefined for a particular CPU, C macros are used. */ /* The CPUs come in alphabetical order below. Please add support for more CPUs here, or improve the current support for the CPUs below! (E.g. WE32100, i960, IBM360.) */ #if defined (__GNUC__) && !defined (NO_ASM) /* We sometimes need to clobber "cc" with gcc2, but that would not be understood by gcc1. Use cpp to avoid major code duplication. */ #if __GNUC__ < 2 #define __CLOBBER_CC #define __AND_CLOBBER_CC #else /* __GNUC__ >= 2 */ #define __CLOBBER_CC : "cc" #define __AND_CLOBBER_CC , "cc" #endif /* __GNUC__ < 2 */ #if defined (__a29k__) || defined (___AM29K__) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %1,%4,%5 addc %0,%2,%3" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "%r" ((USItype)(ah)), \ "rI" ((USItype)(bh)), \ "%r" ((USItype)(al)), \ "rI" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub %1,%4,%5 subc %0,%2,%3" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "r" ((USItype)(ah)), \ "rI" ((USItype)(bh)), \ "r" ((USItype)(al)), \ "rI" ((USItype)(bl))) #define umul_ppmm(xh, xl, m0, m1) \ do { \ USItype __m0 = (m0), __m1 = (m1); \ __asm__ ("multiplu %0,%1,%2" \ : "=r" ((USItype)(xl)) \ : "r" (__m0), \ "r" (__m1)); \ __asm__ ("multmu %0,%1,%2" \ : "=r" ((USItype)(xh)) \ : "r" (__m0), \ "r" (__m1)); \ } while (0) #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("dividu %0,%3,%4" \ : "=r" ((USItype)(q)), \ "=q" ((USItype)(r)) \ : "1" ((USItype)(n1)), \ "r" ((USItype)(n0)), \ "r" ((USItype)(d))) #define count_leading_zeros(count, x) \ __asm__ ("clz %0,%1" \ : "=r" ((USItype)(count)) \ : "r" ((USItype)(x))) #endif /* __a29k__ */ #if defined (__arm__) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("adds %1,%4,%5 adc %0,%2,%3" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "%r" ((USItype)(ah)), \ "rI" ((USItype)(bh)), \ "%r" ((USItype)(al)), \ "rI" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subs %1,%4,%5 sbc %0,%2,%3" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "r" ((USItype)(ah)), \ "rI" ((USItype)(bh)), \ "r" ((USItype)(al)), \ "rI" ((USItype)(bl))) #endif /* __arm__ */ #if defined (__gmicro__) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add.w %5,%1 addx %3,%0" \ : "=g" ((USItype)(sh)), \ "=&g" ((USItype)(sl)) \ : "%0" ((USItype)(ah)), \ "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), \ "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub.w %5,%1 subx %3,%0" \ : "=g" ((USItype)(sh)), \ "=&g" ((USItype)(sl)) \ : "0" ((USItype)(ah)), \ "g" ((USItype)(bh)), \ "1" ((USItype)(al)), \ "g" ((USItype)(bl))) #define umul_ppmm(ph, pl, m0, m1) \ __asm__ ("mulx %3,%0,%1" \ : "=g" ((USItype)(ph)), \ "=r" ((USItype)(pl)) \ : "%0" ((USItype)(m0)), \ "g" ((USItype)(m1))) #define udiv_qrnnd(q, r, nh, nl, d) \ __asm__ ("divx %4,%0,%1" \ : "=g" ((USItype)(q)), \ "=r" ((USItype)(r)) \ : "1" ((USItype)(nh)), \ "0" ((USItype)(nl)), \ "g" ((USItype)(d))) #define count_leading_zeros(count, x) \ __asm__ ("bsch/1 %1,%0" \ : "=g" (count) \ : "g" ((USItype)(x)), \ "0" ((USItype)0)) #endif #if defined (__hppa) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %4,%5,%1 addc %2,%3,%0" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "%rM" ((USItype)(ah)), \ "rM" ((USItype)(bh)), \ "%rM" ((USItype)(al)), \ "rM" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub %4,%5,%1 subb %2,%3,%0" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "rM" ((USItype)(ah)), \ "rM" ((USItype)(bh)), \ "rM" ((USItype)(al)), \ "rM" ((USItype)(bl))) #if defined (_PA_RISC1_1) #define umul_ppmm(w1, w0, u, v) \ do { \ union \ { \ UDItype __f; \ struct {USItype __w1, __w0;} __w1w0; \ } __t; \ __asm__ ("xmpyu %1,%2,%0" \ : "=x" (__t.__f) \ : "x" ((USItype)(u)), \ "x" ((USItype)(v))); \ (w1) = __t.__w1w0.__w1; \ (w0) = __t.__w1w0.__w0; \ } while (0) #define UMUL_TIME 8 #else #define UMUL_TIME 30 #endif #define UDIV_TIME 40 #endif #if defined (__i386__) || defined (__i486__) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addl %5,%1 adcl %3,%0" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "%0" ((USItype)(ah)), \ "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), \ "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subl %5,%1 sbbl %3,%0" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "0" ((USItype)(ah)), \ "g" ((USItype)(bh)), \ "1" ((USItype)(al)), \ "g" ((USItype)(bl))) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("mull %3" \ : "=a" ((USItype)(w0)), \ "=d" ((USItype)(w1)) \ : "%0" ((USItype)(u)), \ "rm" ((USItype)(v))) #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("divl %4" \ : "=a" ((USItype)(q)), \ "=d" ((USItype)(r)) \ : "0" ((USItype)(n0)), \ "1" ((USItype)(n1)), \ "rm" ((USItype)(d))) #define count_leading_zeros(count, x) \ do { \ USItype __cbtmp; \ __asm__ ("bsrl %1,%0" \ : "=r" (__cbtmp) : "rm" ((USItype)(x))); \ (count) = __cbtmp ^ 31; \ } while (0) #define UMUL_TIME 40 #define UDIV_TIME 40 #endif /* 80x86 */ #if defined (__i860__) #if 0 /* Make sure these patterns really improve the code before switching them on. */ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ union \ { \ DItype __ll; \ struct {USItype __l, __h;} __i; \ } __a, __b, __s; \ __a.__i.__l = (al); \ __a.__i.__h = (ah); \ __b.__i.__l = (bl); \ __b.__i.__h = (bh); \ __asm__ ("fiadd.dd %1,%2,%0" \ : "=f" (__s.__ll) \ : "%f" (__a.__ll), "f" (__b.__ll)); \ (sh) = __s.__i.__h; \ (sl) = __s.__i.__l; \ } while (0) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ union \ { \ DItype __ll; \ struct {USItype __l, __h;} __i; \ } __a, __b, __s; \ __a.__i.__l = (al); \ __a.__i.__h = (ah); \ __b.__i.__l = (bl); \ __b.__i.__h = (bh); \ __asm__ ("fisub.dd %1,%2,%0" \ : "=f" (__s.__ll) \ : "%f" (__a.__ll), "f" (__b.__ll)); \ (sh) = __s.__i.__h; \ (sl) = __s.__i.__l; \ } while (0) #endif #endif /* __i860__ */ #if defined (___IBMR2__) /* IBM RS6000 */ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("a%I5 %1,%4,%5 ae %0,%2,%3" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "%r" ((USItype)(ah)), \ "r" ((USItype)(bh)), \ "%r" ((USItype)(al)), \ "rI" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sf%I4 %1,%5,%4 sfe %0,%3,%2" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "r" ((USItype)(ah)), \ "r" ((USItype)(bh)), \ "rI" ((USItype)(al)), \ "r" ((USItype)(bl))) #define umul_ppmm(xh, xl, m0, m1) \ do { \ USItype __m0 = (m0), __m1 = (m1); \ __asm__ ("mul %0,%2,%3" \ : "=r" ((USItype)(xh)), \ "=q" ((USItype)(xl)) \ : "r" (__m0), \ "r" (__m1)); \ (xh) += ((((SItype) __m0 >> 31) & __m1) \ + (((SItype) __m1 >> 31) & __m0)); \ } while (0) #define smul_ppmm(xh, xl, m0, m1) \ __asm__ ("mul %0,%2,%3" \ : "=r" ((USItype)(xh)), \ "=q" ((USItype)(xl)) \ : "r" ((USItype)(m0)), \ "r" ((USItype)(m1))) #define UMUL_TIME 8 #define sdiv_qrnnd(q, r, nh, nl, d) \ __asm__ ("div %0,%2,%4" \ : "=r" ((USItype)(q)), "=q" ((USItype)(r)) \ : "r" ((USItype)(nh)), "1" ((USItype)(nl)), "r" ((USItype)(d))) #define UDIV_TIME 40 #define UDIV_NEEDS_NORMALIZATION 1 #define count_leading_zeros(count, x) \ __asm__ ("cntlz %0,%1" \ : "=r" ((USItype)(count)) \ : "r" ((USItype)(x))) #endif /* ___IBMR2__ */ #if defined (__mc68000__) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add%.l %5,%1 addx%.l %3,%0" \ : "=d" ((USItype)(sh)), \ "=&d" ((USItype)(sl)) \ : "%0" ((USItype)(ah)), \ "d" ((USItype)(bh)), \ "%1" ((USItype)(al)), \ "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub%.l %5,%1 subx%.l %3,%0" \ : "=d" ((USItype)(sh)), \ "=&d" ((USItype)(sl)) \ : "0" ((USItype)(ah)), \ "d" ((USItype)(bh)), \ "1" ((USItype)(al)), \ "g" ((USItype)(bl))) #if defined (__mc68020__) || defined (__NeXT__) || defined(mc68020) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("mulu%.l %3,%1:%0" \ : "=d" ((USItype)(w0)), \ "=d" ((USItype)(w1)) \ : "%0" ((USItype)(u)), \ "dmi" ((USItype)(v))) #define UMUL_TIME 45 #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("divu%.l %4,%1:%0" \ : "=d" ((USItype)(q)), \ "=d" ((USItype)(r)) \ : "0" ((USItype)(n0)), \ "1" ((USItype)(n1)), \ "dmi" ((USItype)(d))) #define UDIV_TIME 90 #define sdiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("divs%.l %4,%1:%0" \ : "=d" ((USItype)(q)), \ "=d" ((USItype)(r)) \ : "0" ((USItype)(n0)), \ "1" ((USItype)(n1)), \ "dmi" ((USItype)(d))) #define count_leading_zeros(count, x) \ __asm__ ("bfffo %1{%b2:%b2},%0" \ : "=d" ((USItype)(count)) \ : "od" ((USItype)(x)), "n" (0)) #else /* not mc68020 */ /* %/ inserts REGISTER_PREFIX. */ #define umul_ppmm(xh, xl, a, b) \ __asm__ ("| Inlined umul_ppmm movel %2,%/d0 movel %3,%/d1 movel %/d0,%/d2 swap %/d0 movel %/d1,%/d3 swap %/d1 movew %/d2,%/d4 mulu %/d3,%/d4 mulu %/d1,%/d2 mulu %/d0,%/d3 mulu %/d0,%/d1 movel %/d4,%/d0 eorw %/d0,%/d0 swap %/d0 addl %/d0,%/d2 addl %/d3,%/d2 jcc 1f addl #65536,%/d1 1: swap %/d2 moveq #0,%/d0 movew %/d2,%/d0 movew %/d4,%/d2 movel %/d2,%1 addl %/d1,%/d0 movel %/d0,%0" \ : "=g" ((USItype)(xh)), \ "=g" ((USItype)(xl)) \ : "g" ((USItype)(a)), \ "g" ((USItype)(b)) \ : "d0", "d1", "d2", "d3", "d4") #define UMUL_TIME 100 #define UDIV_TIME 400 #endif /* not mc68020 */ #endif /* mc68000 */ #if defined (__m88000__) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addu.co %1,%r4,%r5 addu.ci %0,%r2,%r3" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "%rJ" ((USItype)(ah)), \ "rJ" ((USItype)(bh)), \ "%rJ" ((USItype)(al)), \ "rJ" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subu.co %1,%r4,%r5 subu.ci %0,%r2,%r3" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "rJ" ((USItype)(ah)), \ "rJ" ((USItype)(bh)), \ "rJ" ((USItype)(al)), \ "rJ" ((USItype)(bl))) #define UMUL_TIME 17 #define UDIV_TIME 150 #define count_leading_zeros(count, x) \ do { \ USItype __cbtmp; \ __asm__ ("ff1 %0,%1" \ : "=r" (__cbtmp) \ : "r" ((USItype)(x))); \ (count) = __cbtmp ^ 31; \ } while (0) #if defined (__mc88110__) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("mulu.d r10,%2,%3 or %0,r10,0 or %1,r11,0" \ : "=r" (w1), \ "=r" (w0) \ : "r" ((USItype)(u)), \ "r" ((USItype)(v)) \ : "r10", "r11") #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("or r10,%2,0 or r11,%3,0 divu.d r10,r10,%4 mulu %1,%4,r11 subu %1,%3,%1 or %0,r11,0" \ : "=r" (q), \ "=&r" (r) \ : "r" ((USItype)(n1)), \ "r" ((USItype)(n0)), \ "r" ((USItype)(d)) \ : "r10", "r11") #endif #endif /* __m88000__ */ #if defined (__mips__) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("multu %2,%3 mflo %0 mfhi %1" \ : "=d" ((USItype)(w0)), \ "=d" ((USItype)(w1)) \ : "d" ((USItype)(u)), \ "d" ((USItype)(v))) #define UMUL_TIME 5 #define UDIV_TIME 100 #endif /* __mips__ */ #if defined (__ns32000__) #define __umulsidi3(u, v) \ ({UDItype __w; \ __asm__ ("meid %2,%0" \ : "=g" (__w) \ : "%0" ((USItype)(u)), \ "g" ((USItype)(v))); \ __w; }) #define div_qrnnd(q, r, n1, n0, d) \ __asm__ ("movd %2,r0 movd %3,r1 deid %4,r0 movd r1,%0 movd r0,%1" \ : "=g" ((USItype)(q)), \ "=g" ((USItype)(r)) \ : "g" ((USItype)(n0)), \ "g" ((USItype)(n1)), \ "g" ((USItype)(d)) \ : "r0", "r1") #endif /* __ns32000__ */ #if defined (__pyr__) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addw %5,%1 addwc %3,%0" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "%0" ((USItype)(ah)), \ "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), \ "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subw %5,%1 subwb %3,%0" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "0" ((USItype)(ah)), \ "g" ((USItype)(bh)), \ "1" ((USItype)(al)), \ "g" ((USItype)(bl))) /* This insn doesn't work on ancient pyramids. */ #define umul_ppmm(w1, w0, u, v) \ ({union { \ UDItype __ll; \ struct {USItype __h, __l;} __i; \ } __xx; \ __xx.__i.__l = u; \ __asm__ ("uemul %3,%0" \ : "=r" (__xx.__i.__h), \ "=r" (__xx.__i.__l) \ : "1" (__xx.__i.__l), \ "g" ((UDItype)(v))); \ (w1) = __xx.__i.__h; \ (w0) = __xx.__i.__l;}) #endif /* __pyr__ */ #if defined (__ibm032__) /* RT/ROMP */ #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("a %1,%5 ae %0,%3" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "%0" ((USItype)(ah)), \ "r" ((USItype)(bh)), \ "%1" ((USItype)(al)), \ "r" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("s %1,%5 se %0,%3" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "0" ((USItype)(ah)), \ "r" ((USItype)(bh)), \ "1" ((USItype)(al)), \ "r" ((USItype)(bl))) #define umul_ppmm(ph, pl, m0, m1) \ do { \ USItype __m0 = (m0), __m1 = (m1); \ __asm__ ( \ "s r2,r2 mts r10,%2 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 m r2,%3 cas %0,r2,r0 mfs r10,%1" \ : "=r" ((USItype)(ph)), \ "=r" ((USItype)(pl)) \ : "%r" (__m0), \ "r" (__m1) \ : "r2"); \ (ph) += ((((SItype) __m0 >> 31) & __m1) \ + (((SItype) __m1 >> 31) & __m0)); \ } while (0) #define UMUL_TIME 20 #define UDIV_TIME 200 #define count_leading_zeros(count, x) \ do { \ if ((x) >= 0x10000) \ __asm__ ("clz %0,%1" \ : "=r" ((USItype)(count)) \ : "r" ((USItype)(x) >> 16)); \ else \ { \ __asm__ ("clz %0,%1" \ : "=r" ((USItype)(count)) \ : "r" ((USItype)(x))); \ (count) += 16; \ } \ } while (0) #endif #if defined (__sparc__) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addcc %4,%5,%1 addx %2,%3,%0" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "%r" ((USItype)(ah)), \ "rI" ((USItype)(bh)), \ "%r" ((USItype)(al)), \ "rI" ((USItype)(bl)) \ __CLOBBER_CC) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subcc %4,%5,%1 subx %2,%3,%0" \ : "=r" ((USItype)(sh)), \ "=&r" ((USItype)(sl)) \ : "r" ((USItype)(ah)), \ "rI" ((USItype)(bh)), \ "r" ((USItype)(al)), \ "rI" ((USItype)(bl)) \ __CLOBBER_CC) #if defined (__sparc_v8__) #define umul_ppmm(w1, w0, u, v) \ __asm__ ("umul %2,%3,%1;rd %%y,%0" \ : "=r" ((USItype)(w1)), \ "=r" ((USItype)(w0)) \ : "r" ((USItype)(u)), \ "r" ((USItype)(v))) #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("mov %2,%%y;nop;nop;nop;udiv %3,%4,%0;umul %0,%4,%1;sub %3,%1,%1"\ : "=&r" ((USItype)(q)), \ "=&r" ((USItype)(r)) \ : "r" ((USItype)(n1)), \ "r" ((USItype)(n0)), \ "r" ((USItype)(d))) #else #if defined (__sparclite__) /* This has hardware multiply but not divide. It also has two additional instructions scan (ffs from high bit) and divscc. */ #define umul_ppmm(w1, w0, u, v) \ __asm__ ("umul %2,%3,%1;rd %%y,%0" \ : "=r" ((USItype)(w1)), \ "=r" ((USItype)(w0)) \ : "r" ((USItype)(u)), \ "r" ((USItype)(v))) #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("! Inlined udiv_qrnnd wr %%g0,%2,%%y ! Not a delayed write for sparclite tst %%g0 divscc %3,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%%g1 divscc %%g1,%4,%0 rd %%y,%1 bl,a 1f add %1,%4,%1 1: ! End of inline udiv_qrnnd" \ : "=r" ((USItype)(q)), \ "=r" ((USItype)(r)) \ : "r" ((USItype)(n1)), \ "r" ((USItype)(n0)), \ "rI" ((USItype)(d)) \ : "%g1" __AND_CLOBBER_CC) #define UDIV_TIME 37 #define count_leading_zeros(count, x) \ __asm__ ("scan %1,0,%0" \ : "=r" ((USItype)(x)) \ : "r" ((USItype)(count))) #else /* SPARC without integer multiplication and divide instructions. (i.e. at least Sun4/20,40,60,65,75,110,260,280,330,360,380,470,490) */ #define umul_ppmm(w1, w0, u, v) \ __asm__ ("! Inlined umul_ppmm wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr sra %3,31,%%g2 ! Don't move this insn and %2,%%g2,%%g2 ! Don't move this insn andcc %%g0,0,%%g1 ! Don't move this insn mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,%3,%%g1 mulscc %%g1,0,%%g1 add %%g1,%%g2,%0 rd %%y,%1" \ : "=r" ((USItype)(w1)), \ "=r" ((USItype)(w0)) \ : "%rI" ((USItype)(u)), \ "r" ((USItype)(v)) \ : "%g1", "%g2" __AND_CLOBBER_CC) #define UMUL_TIME 39 /* 39 instructions */ /* It's quite necessary to add this much assembler for the sparc. The default udiv_qrnnd (in C) is more than 10 times slower! */ #define udiv_qrnnd(q, r, n1, n0, d) \ __asm__ ("! Inlined udiv_qrnnd mov 32,%%g1 subcc %1,%2,%%g0 1: bcs 5f addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb sub %1,%2,%1 ! this kills msb of n addx %1,%1,%1 ! so this can't give carry subcc %%g1,1,%%g1 2: bne 1b subcc %1,%2,%%g0 bcs 3f addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb b 3f sub %1,%2,%1 ! this kills msb of n 4: sub %1,%2,%1 5: addxcc %1,%1,%1 bcc 2b subcc %%g1,1,%%g1 ! Got carry from n. Subtract next step to cancel this carry. bne 4b addcc %0,%0,%0 ! shift n1n0 and a 0-bit in lsb sub %1,%2,%1 3: xnor %0,0,%0 ! End of inline udiv_qrnnd" \ : "=&r" ((USItype)(q)), \ "=&r" ((USItype)(r)) \ : "r" ((USItype)(d)), \ "1" ((USItype)(n1)), \ "0" ((USItype)(n0)) : "%g1" __AND_CLOBBER_CC) #define UDIV_TIME (3+7*32) /* 7 instructions/iteration. 32 iterations. */ #endif /* __sparclite__ */ #endif /* __sparc_v8__ */ #endif /* __sparc__ */ #if defined (__vax__) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addl2 %5,%1 adwc %3,%0" \ : "=g" ((USItype)(sh)), \ "=&g" ((USItype)(sl)) \ : "%0" ((USItype)(ah)), \ "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), \ "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subl2 %5,%1 sbwc %3,%0" \ : "=g" ((USItype)(sh)), \ "=&g" ((USItype)(sl)) \ : "0" ((USItype)(ah)), \ "g" ((USItype)(bh)), \ "1" ((USItype)(al)), \ "g" ((USItype)(bl))) #define umul_ppmm(xh, xl, m0, m1) \ do { \ union { \ UDItype __ll; \ struct {USItype __l, __h;} __i; \ } __xx; \ USItype __m0 = (m0), __m1 = (m1); \ __asm__ ("emul %1,%2,$0,%0" \ : "=r" (__xx.__ll) \ : "g" (__m0), \ "g" (__m1)); \ (xh) = __xx.__i.__h; \ (xl) = __xx.__i.__l; \ (xh) += ((((SItype) __m0 >> 31) & __m1) \ + (((SItype) __m1 >> 31) & __m0)); \ } while (0) #endif /* __vax__ */ #endif /* __GNUC__ */ /* If this machine has no inline assembler, use C macros. */ #if !defined (add_ssaaaa) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ USItype __x; \ __x = (al) + (bl); \ (sh) = (ah) + (bh) + (__x < (al)); \ (sl) = __x; \ } while (0) #endif #if !defined (sub_ddmmss) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ USItype __x; \ __x = (al) - (bl); \ (sh) = (ah) - (bh) - (__x > (al)); \ (sl) = __x; \ } while (0) #endif #if !defined (umul_ppmm) #define umul_ppmm(w1, w0, u, v) \ do { \ USItype __x0, __x1, __x2, __x3; \ USItype __ul, __vl, __uh, __vh; \ \ __ul = __ll_lowpart (u); \ __uh = __ll_highpart (u); \ __vl = __ll_lowpart (v); \ __vh = __ll_highpart (v); \ \ __x0 = (USItype) __ul * __vl; \ __x1 = (USItype) __ul * __vh; \ __x2 = (USItype) __uh * __vl; \ __x3 = (USItype) __uh * __vh; \ \ __x1 += __ll_highpart (__x0);/* this can't give carry */ \ __x1 += __x2; /* but this indeed can */ \ if (__x1 < __x2) /* did we get it? */ \ __x3 += __ll_B; /* yes, add it in the proper pos. */ \ \ (w1) = __x3 + __ll_highpart (__x1); \ (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \ } while (0) #endif #if !defined (__umulsidi3) #define __umulsidi3(u, v) \ ({DIunion __w; \ umul_ppmm (__w.s.high, __w.s.low, u, v); \ __w.ll; }) #endif /* Define this unconditionally, so it can be used for debugging. */ #define __udiv_qrnnd_c(q, r, n1, n0, d) \ do { \ USItype __d1, __d0, __q1, __q0; \ USItype __r1, __r0, __m; \ __d1 = __ll_highpart (d); \ __d0 = __ll_lowpart (d); \ \ __r1 = (n1) % __d1; \ __q1 = (n1) / __d1; \ __m = (USItype) __q1 * __d0; \ __r1 = __r1 * __ll_B | __ll_highpart (n0); \ if (__r1 < __m) \ { \ __q1--, __r1 += (d); \ if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\ if (__r1 < __m) \ __q1--, __r1 += (d); \ } \ __r1 -= __m; \ \ __r0 = __r1 % __d1; \ __q0 = __r1 / __d1; \ __m = (USItype) __q0 * __d0; \ __r0 = __r0 * __ll_B | __ll_lowpart (n0); \ if (__r0 < __m) \ { \ __q0--, __r0 += (d); \ if (__r0 >= (d)) \ if (__r0 < __m) \ __q0--, __r0 += (d); \ } \ __r0 -= __m; \ \ (q) = (USItype) __q1 * __ll_B | __q0; \ (r) = __r0; \ } while (0) /* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through __udiv_w_sdiv (defined in libgcc or elsewhere). */ #if !defined (udiv_qrnnd) && defined (sdiv_qrnnd) #define udiv_qrnnd(q, r, nh, nl, d) \ do { \ USItype __r; \ (q) = __udiv_w_sdiv (&__r, nh, nl, d); \ (r) = __r; \ } while (0) #endif /* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */ #if !defined (udiv_qrnnd) #define UDIV_NEEDS_NORMALIZATION 1 #define udiv_qrnnd __udiv_qrnnd_c #endif #if !defined (count_leading_zeros) extern const UQItype __clz_tab[]; #define count_leading_zeros(count, x) \ do { \ USItype __xr = (x); \ USItype __a; \ \ if (SI_TYPE_SIZE <= 32) \ { \ __a = __xr < (1<<2*__BITS4) \ ? (__xr < (1<<__BITS4) ? 0 : __BITS4) \ : (__xr < (1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \ } \ else \ { \ for (__a = SI_TYPE_SIZE - 8; __a > 0; __a -= 8) \ if (((__xr >> __a) & 0xff) != 0) \ break; \ } \ \ (count) = SI_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \ } while (0) #endif #ifndef UDIV_NEEDS_NORMALIZATION #define UDIV_NEEDS_NORMALIZATION 0 #endif ./libc-linux/gdbm/ 40755 1676 334 0 5550051606 11732 5ustar hjlisl./libc-linux/gdbm/COPYING100644 1676 334 30313 4747421220 13102 0ustar hjlisl GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program 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 1, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! ./libc-linux/gdbm/ChangeLog100644 1676 334 7213 4763324656 13621 0ustar hjlislThu Feb 28 17:05:09 1991 Phil Nelson (phil at strawberry.cs.wwu.edu) * Added 1991 to copyright lines on all files. * gdbmfetch.c: Fixed a bug introduced by previous changes. * version.c: Updated version to 1.5. Fri Feb 8 12:27:13 1991 Phil Nelson (phil at strawberry.cs.wwu.edu) * Change author's e-mail address in all comments. * gdbmopen.c, systems.h: Changed opening sequence so that a database will not be truncated in NEWDB mode until the write has locked the file. * testgdbm.c: Fixed a bug that caused a segmentation fault on one computer. Also added the flags "-r" for opening the database as a READER and "-n" for opening the database as a NEWDB writer. The default mode remains the WRCREAT mode. * Various source files, changed the data types of various variables from int to long. This should not make any difference to systems where sizeof(int) = sizeof(long). It should make it easier to move to other systems. * gdbmstore.c: Added a check for NULL key or content dptr. Due to NULLs being used as error indications, data cannot be NULL also. * gdbmfetch.c, gdbmseq.c, fetch.c: Added checks for zero sized key and content so malloc will not try to allocate zero bytes. * gdbmconst.h: Added this file so that all constants are in one central place. A few constants can be changed without changing the header sizes. Tue Aug 14 13:08:43 1990 Phil Nelson (phil at unicorn.wwu.edu) * Version 1.4 released. (version.c: Updated to correct version.) * Makefile: Added $(LIBS) to link for conv2gdbm. * README: Updated to version 1.4 and added a 1.0-1.4 change statement. Wed Aug 8 16:57:29 1990 Phil Nelson (phil at unicorn.wwu.edu) * gdbmopen.c: Restructured some code to initialize dbf more completely. * dbm.h: Added a null define to satisfy some versions that require a dbmclose() call. * findkey.c: (_gdbm_findkey) Added a check for the NULL pointer in ...ca_data.dptr. * gdbmdelete.c: Added code to more completely remove the cache entry for a deleted item. * gdbmreorg.c: Added code to finish the transfer of information from the new_dbf to the orginal dbf. Fri May 30 08:29:16 1990 Phil Nelson (phil at unicorn.wwu.edu) * gdbmstore.c: Changed a strncpy to bcopy. Tue May 15 09:55:21 1990 Phil Nelson (phil at unicorn.wwu.edu) * Version 1.3 released. * systems.h: Changed the defines for alloca to use the name builtin_alloca to depend on BUILTIN_ALLOCA instead of __GNUC__. Added a definition of BUILTIN_ALLOCA for GNUC and for sun sparc. Fri May 11 12:15:56 1990 Phil Nelson (phil at unicorn.wwu.edu) * systems.h: Removed the include for and now systems.h requires included before it. * Makefile: Corrected the makefile to include a file that was missing before. Also, switched order of conv2gdbm and alldbm in the all option. * findkey.c (_gdbm_read_entry): Reordered some statements to make the code more readable. * update.c (_gdbm_fatal): Changed fatal message from "dbm fatal:" to "gdbm fatal:". Mon Apr 30 10:18:24 1990 Phil Nelson (phil at unicorn.wwu.edu) * Version 1.2 released. Fri Apr 27 09:49:59 1990 Phil Nelson (phil at unicorn.wwu.edu) * Makefile: Added the dist option. Similar to the addition from hack@ai.mit.edu, but correct. * falloc.c (push_avail_block): Change the avail count to reflect the correct number of entries. * dbminit.c (dbminit): Changed the stat call to stat the ".dir" file as is done in dbmopen.c (dbm_open). Tue Apr 10 12:18:40 1990 Phil Nelson (phil at unicorn.wwu.edu) * Version 1.1. released. * gdbmopen.c (gdbm_open): Clear out bucket cache. ./libc-linux/gdbm/Makefile100644 1676 334 1344 5527714053 13477 0ustar hjlisl# # This is Makefile of gdbm 1.5 for Linux # override DEBUG=false override PROFILE=false #override CHECKER=false JUMP_LIB=libdbm TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules override STATIC_LIB=$(STATIC_DIR)/libdbm.a override SHARED_LIB=$(SHARED_DIR)/libdbm.a override CHECKER_LIB=$(CHECKER_DIR)/libdbm.a INC_CFLAGS= -I. -I$(TOPDIR) DIRS:= SRCS = dbminit.c delete.c fetch.c store.c seq.c dbmopen.c \ dbmdelete.c dbmfetch.c dbmstore.c dbmseq.c dbmclose.c \ dbmdirfno.c dbmpagfno.c gdbmopen.c gdbmdelete.c gdbmfetch.c \ gdbmstore.c gdbmclose.c gdbmreorg.c gdbmseq.c \ bucket.c falloc.c findkey.c hash.c update.c global.c version.c SMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/gdbm/README100644 1676 334 33464 4763324153 12746 0ustar hjlislThis is release 1.5 of GNU dbm. Better documentation will be written soon. For now, this file briefly describes the contents of this release and how to use it. The files are: COPYING - Copying information. README - This file. bucket.c, extern.h, falloc.c, findkey.c, gdbm.proto, gdbmclose.c, gdbmconst.h gdbmdefs.h, gdbmdelete.c, gdbmerrno.h, gdbmfetch.c, gdbmopen.c, gdbmreorg.c, gdbmseq.c, gdbmstore.c, global.c, gndbm.h, hash.c systems.h, update.c, version.c - Source for GNU dbm library. dbm.h dbminit.c, delete.c, fetch.c, seq.c, store.c - Source for the DBM interface. dbmclose.c, dbmdelete.c, dbmdirfno.c, dbmfetch.c, dbmopen.c, dbmpagfno.c dbmseq.c, dbmstore.c, ndbm.h - Source for the NDBM interface. Makefile - Makefile, will make gdbm.a (BSD and SYSV) testgdbm.c - A simple test program. testdbm.c - A simple test program. testndbm.c - A simple test program. conv2gdbm.c - A dbm database conversion program. CHANGES from 1.4 to 1.5: 1. Minor bug fixes. See the ChangeLog. 2. Added gdbmconst.h to allow users to change the size of the bucket cache in the systems.h file. CHANGES from 1.0 to 1.4: 1. Mainly bug fixes. 2. A define for "dbmclose()" was added to dbm.h for those few implementaions that need that call. 3. For details, see the ChangeLog. CHANGES from 0.9 to 1.0: 1. Makefiles were combined into one and a few new things added to it. 2. Several minor bugs were fixed including a cache bug. 3. Two new calls (dbm_pagfno, dbm_dirfno) were added to the NDBM interface. 3. A conversion program from dbm files to gdbm files was added. 4. Reorganize was changed to allow complex file names. (dir/file form) 5. testgdbm, testndbm, and testdbm were modified to return key and data pairs where needed and to take an optional file name as an argument. testgdbm had some command characters changed. 6. The DBM and NDBM interfaces were separated. 7. An include file for dbm users was added. (dbm.h) 8. The include file for ndbm users was renamed ndbm.h. (It was gndbm.h.) CHANGES from 0.8 to 0.9: 1. The hash function changed. 2. The file format changed. 3. There was a complete rewrite of falloc.c. 4. There were added compatiblity routines for ndbm. 5. The file names for dbm compatibility routines were made to look like dbm. 6. Test programs changed. 7. Support for System V. 8. Various other small changes. 9. The need for recovery and associated code was removed. GNU dbm is a set of database routines that use extendible hashing and works similar to the standard UNIX dbm routines. The basic unit of data is the structure typedef struct { char *dptr; int dsize; } datum; The following is a quick list of the routines. After this list, a longer description of each routine will be given. An include file will be produced that can be included by the user. The file is "gdbm.h". The following routines are defined in terms of gdbm.h: GDBM_FILE gdbm_open ( name, block_size, read_write, mode, fatal_func ) void gdbm_close ( dbf ) int gdbm_store ( dbf, key, content, flags ) datum gdbm_fetch ( dbf, key ) int gdbm_delete ( dbf, key ) datum gdbm_firstkey ( dbf ) datum gdbm_nextkey ( dbf, key ) int gdbm_reorganize ( dbf ) For compatibility with the standard dbm, the following routines are defined. There is an include file for dbm users called "dbm.h". int dbminit ( name ) int store ( key, content ) datum fetch ( key ) int delete ( key ) datum firstkey () datum nextkey ( key ) There are also compatibility routines for ndbm. For ndbm compatiblity routines, you need the include file "ndbm.h". The routines are: DBM *dbm_open (name, flags, mode) void dbm_close (file) datum dbm_fetch (file, key) int dbm_store (file, key, content, flags) int dbm_delete (file, key) datum dbm_firstkey (file) datum dbm_nextkey (file) int dbm_error (file) int dbm_clearerr (file) int dbm_pagfno (file) int dbm_dirfno (file) Description of GNU dbm routines. -------------------------------- GNU dbm allows multiple data files. A routine that opens a gdbm file is designated as a "reader" or a "writer". Only one writer may open a gdbm file and many readers may open the file. Readers and writers can not open the gdbm file at the same time. The procedure for opening a gdbm file is: GDBM_FILE dbf; dbf = gdbm_open ( name, block_size, read_write, mode, fatal_func ) The parameters are: char *name - the name of the file (the complete name, gdbm does not append any characters to this name) int block_size - the size of a single transfer from disk to memory. This parameter is ignored unless the file is a new file. The minimum size is 512. If it is less than 512, dbm will use the stat block size for the file system. int read_write - 0 => reader, 1 => writer, 2 => writer (if the database does not exist, create a new one, 3 => writer and create a new database regardless if one exists. (Defined in gdbm.h as GDBM_READER, GDBM_WRITER, GDBM_WRCREAT, GDBM_NEWDB.) int mode - file mode (see chmod(2) and open(2)) if the file is created. void (*fatal_func) () - a function for dbm to call if it detects a fatal error. The only parameter of this function is a string. If the value of 0 is provided, gdbm will use a default function. The return value, dbf, is the pointer needed by all other routines to access that gdbm file. If the return is the NULL pointer, gdbm_open was not successful. The errors can be found in "gdbm_errno" for gdbm errors and in "errno" for file system errors. (For error codes, see gdbmerrno.h.) In all of the following calls, the parameter "dbf" refers to the pointer returned from gdbm_open. It is important that every file opened is also closed. This is needed to update the reader/writer count on the file. This is done by: gdbm_close(dbf); The database is used by 3 primary routines. The first stores data in the database. ret = gdbm_store ( dbf, key, content, flag ) The parameters are: char *dbf - the pointer returned by gdbm_open datum key - the key data datum content - the data to be associated with the key int flag - 0 => insert only, generate an error if key exists. 1 => replace contents if key exists. (Defined in gdbm.h as GDBM_INSERT and GDBM_REPLACE.) If a reader calls store, ret gets -1. If called with GDBM_INSERT and key is in the database, ret gets 1. Otherwise, ret is 0. NOTICE: If you store data for a key that is already in the data base, gdbm replaces the old data with the new data if called with GDBM_REPLACE. You do not get two data items for the same key and you do not get an error from gdbm_store. NOTICE: The size in gdbm is not restricted like dbm or ndbm. Your data can be as large as your "want". NOTICE: Both key and content must have the dptr field be a non-NULL value. Since a NULL dptr field is used by other routines to indicate an error, a NULL field cannot be valid data. If either key or content have a null dptr field, gdbm_open will return an error. To search for some data: content = gdbm_fetch ( dbf, key ) The parameters are: char *dbf - the pointer returned by gdbm_open datum key - the key data The "datum" returned in content is a pointer to the data found. If the dptr is NULL, no data was found. If dptr is not NULL, then it points to data allocated by malloc. gdbm does not automatically free this data. The user must free this storage when done using it. This eliminates the need to copy the result to save it for later use. (You just save the pointer.) To remove some data from the database: ret = gdbm_delete ( dbf, key ) The parameters are: char *dbf - the pointer returned by gdbm_open datum key - the key data The ret value is -1 if the item is not present or the requester is a reader. The ret value is 0 if there was a successful delete. The next two routines allow for accessing all items in the database. This access is not key sequential, but it is guaranteed to visit every key in the database once. (The order has to do with the hash values.) key = gdbm_firstkey ( dbf ) nextkey = gdbm_nextkey ( dbf, key ) The parameters are: char *dbf - the pointer returned by gdbm_open datum key - the key data The return values are both datum. If key.dptr or nextkey.dptr is NULL, there is no first key or next key. Again notice that dptr points to data allocated by malloc and gdbm will not free it for you. The following routine should be used very seldom. ret = gdbm_reorganize ( dbf ) If you have had a lot of deletions and would like to shrink the space used by the gdbm file, the this routine will reorganize the database. gdbm will not shorten the length of a gdbm file except by using this reorganization. (Deleted file space will be reused.) The following two are variables that may need to be used: gdbm_error gdbm_errno - the variable that contains more information about gdbm errors. ( gdbm.h has the definitions of the error values. ) char * gdbm_version - the string containing the version information. There are a few more things of interest. First, gdbm files are not "sparse". You can copy them with the UNIX cp command and they will not expand in the copying process. Also, there is a compatibility mode for use with programs that already use UNIX dbm. In this compatibility mode, no gdbm file pointer is required by the user. Only one file may be opened at a time. All users in compatibility mode are assumed to be writers. If the gdbm file is a read only, it will fail as a writer, but will also try to open it as a reader. All returned pointers in datum structures point to data that gdbm WILL free. They should be treated as static pointers (as standard UNIX dbm does). The compatibility routine names are the same as the UNIX dbm routine names. Their definitions follow: int dbminit ( name ) int store ( key, content ) datum fetch ( key ) int delete ( key ) datum firstkey () datum nextkey ( key ) NOTE: Some implementations have an include file "dbm.h". That file is just a file that defines datum and the above routines. Many original dbm sites do not have a "dbm.h" file. One is included here for those who want it. WARNING: standard UNIX dbm and GNU dbm do not have the same data format in the file. You cannot access a standard UNIX dbm file with GNU dbm! If you want to use an old database with GNU dbm, you must use the convert program. Also, GNU dbm has compatibility routines for ndbm. For ndbm compatiblity routines, you need the include file "ndbm.h". WARNING: If you have ndbm and gdbm, there is a conflict in the names of the include file for the ndbm interface and the original ndbm package. Do not blindly copy "ndbm.h" to your include directory. The routines are: DBM *dbm_open (name, flags, mode) void dbm_close (file) datum dbm_fetch (file, key) int dbm_store (file, key, content, flags) int dbm_delete (file, key) datum dbm_firstkey (file) datum dbm_nextkey (file) int dbm_error (file) int dbm_clearerr (file) int dbm_dirfno (file) int dbm_pagfno (file) Again, just like ndbm, any returned datum can be assumed to be static storage. You do not have to free that memory, the ndbm compatibility routines will do it for you. Notes on making GNU dbm. ------------------------ The "Makefile" will make both "gdbm.a", the collection of gdbm routines and three simple test programs that uses the gdbm routines. Two test programs test the dbm and the ndbm interface routines. The third was use to help debug gdbm and contains "inside knowledge." The first two can be linked using the original dbm and ndbm routines. The makefile also makes the conversion program, conv2gdbm. The make commands are: make gdbm.a makes the gdbm.a archive. make testgdbm makes both gdbm.a and the gdbm test program. make testdbm makes both gdbm.a and the dbm test program with gdbm. make testndbm makes both gdbm.a and the ndbm test program with gdbm. make allgdbm makes all of the above. make tdbm makes the dbm test program linked with dbm, not gdbm. make tndbm makes the ndbm test program linked with ndbm, not gdbm. make alldbm makes the two previous programs. make conv2gdbm makes the conversion program. make all makes all the above. make install installs gdbm.a as /usr/lib/libgdbm.a and gdbm.h. CONV2GDBM --------- The program conv2gdbm has been provided to help you convert from dbm databases to gdbm. The usage is: conv2gdbm [-q] [-b block_size] dbm_file [gdbm_file] The optional "block_size" is the same as in gdbm_open. The dbm_file is the name of the dbm file without the .pag or .dir extensions. The optional gdbm_file is the complete file name. If not included, the gdbm file name is the same as the dbm file name without any extensions. That is "conv2gdbm dbmfile" converts the files "dbmfile.pag" and "dbmfile.dir" into a gdbm file called "dbmfile". The -q option causes conv2gdbm to work quietly. System V support (And other systems.) -------------------------------------- There is now support for System V. This done via the systems.h file. This is the place where all system dependencies should go. The makefile should make gdbm with a few changes. The makefile describes the changes necessary for use with System V. Also, read the makefile and edit it if you use gcc. There are several places where changes are needed to use gcc. 1) uncomment: #CC=gcc 2) change the lines to make the test programs. (See the comments.) If you port gdbm to another system, try to follow the change style used for System V changes. Please send your changes to phil@cs.wwu.edu if you would like your changes included in a future release of gdbm. Please send bug reports to bug-gnu-utils@prep.ai.mit.edu. Thank you. ./libc-linux/gdbm/gdbm.proto100644 1676 334 5414 5203404562 14027 0ustar hjlisl/* gdbm.h - The include file for dbm users. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #ifndef _GDBM_H /* allow multiple inclusions */ #define _GDBM_H /* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who can create the database. */ #define GDBM_READER 0 /* A reader. */ #define GDBM_WRITER 1 /* A writer. */ #define GDBM_WRCREAT 2 /* A writer. Create the db if needed. */ #define GDBM_NEWDB 3 /* A writer. Always create a new db. */ /* Parameters to gdbm_store for simple insertion or replacement in the case that the key is already in the database. */ #define GDBM_INSERT 0 /* Never replace old data with new. */ #define GDBM_REPLACE 1 /* Always replace old data with new. */ /* The data and key structure. This structure is defined for compatibility. */ typedef struct { char *dptr; int dsize; } datum; /* The file information header. This is good enough for most applications. */ typedef struct {int dummy[10];} *GDBM_FILE; /* These are the routines! */ #ifdef __STDC__ #ifdef __cplusplus extern "C" { #endif extern GDBM_FILE gdbm_open(const char *, int, int); extern void gdbm_close(GDBM_FILE ); extern datum gdbm_fetch(GDBM_FILE, datum); extern datum gdbm_firstkey(GDBM_FILE ); extern datum gdbm_nextkey(GDBM_FILE ); extern int gdbm_delete(GDBM_FILE, datum); extern int gdbm_store(GDBM_FILE, datum, datum, int); extern int gdbm_reorganize (GDBM_FILE); #ifdef __cplusplus } #endif #else extern GDBM_FILE gdbm_open (); extern void gdbm_close (); extern datum gdbm_fetch (); extern int gdbm_store (); extern int gdbm_delete (); extern datum gdbm_firstkey (); extern datum gdbm_nextkey (); extern int gdbm_reorganize (); #endif ./libc-linux/gdbm/conv2gdbm.c100644 1676 334 10050 4763323452 14076 0ustar hjlisl/* conv2gdbm.c - This is a program to convert dbm files to gdbm files. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include #include "gdbm.h" extern int dbminit (); extern datum fetch (); extern datum firstkey (); extern datum nextkey (); extern char *optarg; extern int optind; /* Boolean Constants */ #define TRUE 1 #define FALSE 0 main (argc, argv) int argc; char *argv[]; { GDBM_FILE gfile; /* The gdbm file. */ datum key; /* Key and data pairs retrieved. */ datum data; int errors; /* error count. */ int num; /* insert count. */ int block_size; /* gdbm block size. */ char quiet; /* Do work Quietly? */ char option_char; /* The option character. */ char *dbm_file, *gdbm_file; /* pointers to the file names. */ /* Initialize things. */ quiet = FALSE; block_size = 0; /* Check for proper arguments. */ if (argc < 2) usage (argv[0]); /* Check for the options. */ while ( (option_char = getopt (argc, argv, "b:q")) != EOF) { switch (option_char) { case 'b': block_size = atoi (optarg); break; case 'q': quiet = TRUE; break; default: usage (argv[0]); } } /* The required dbm file name. */ if (argc <= optind) { usage (argv[0]); } else { dbm_file = argv[optind]; gdbm_file = argv[optind]; optind += 1; } /* The optional gdbm file name. */ if (argc > optind) { gdbm_file = argv[optind]; optind += 1; } /* No more arguments are legal. */ if (argc > optind) usage (argv[0]); /* Open the dbm file. */ if (dbminit (dbm_file) != 0) { printf ("%s: dbm file not opened\n", argv[0]); exit (2); } /* Open the gdbm file. Since the dbm files have .pag and .dir we will use the file name without any extension. */ gfile = gdbm_open (gdbm_file, block_size, GDBM_WRCREAT, 00664, NULL); if (gfile == NULL) { printf ("%s: gdbm file not opened\n", argv[0]); exit (2); } /* Do the conversion. */ errors = 0; num = 0; if (!quiet) printf ("%s: Converting %s.pag and %s.dir to %s.\n", argv[0], dbm_file, dbm_file, gdbm_file); /* The convert loop - read a key/data pair from the dbm file and insert it into the gdbm file. */ for (key = firstkey (); key.dptr != NULL; key = nextkey (key)) { data = fetch (key); if (gdbm_store (gfile, key, data, GDBM_INSERT) != 0) { errors++; } else { num++; if ( !quiet && ((num % 100) == 0)) { printf ("."); if ( (num % 7000) == 0) printf ("\n"); } } } gdbm_close (gfile); if (!quiet) { /* Final reporting. */ if (errors) printf ("%s: %d items not inserted into %s.\n", argv[0], errors, gdbm_file); printf ("%s: %d items inserted into %s.\n", argv[0], num, gdbm_file); } } usage (name) char *name; { printf ("usage: %s [-q] [-b block_size] dbmfile [gdbmfile]\n", name); exit (2); } ./libc-linux/gdbm/dbminit.c100644 1676 334 7033 4763323455 13635 0ustar hjlisl/* dbminit.c - Open the file for dbm operations. This looks like the DBM interface. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "gdbmerrno.h" #include "extern.h" extern gdbm_error gdbm_errno; /* Initialize dbm system. FILE is a pointer to the file name. In standard dbm, the database is found in files called FILE.pag and FILE.dir. To make gdbm compatable with dbm using the dbminit call, the same file names are used. Specifically, dbminit will use the file name FILE.pag in its call to gdbm open. If the file (FILE.pag) has a size of zero bytes, a file initialization procedure is performed, setting up the initial structure in the file. Any error detected will cause a return value of -1. No errors cause the return value of 0. NOTE: file.dir will be linked to file.pag. */ int dbminit (file) char *file; { char* pag_file; /* Used to construct "file.pag". */ char* dir_file; /* Used to construct "file.dir". */ struct stat dir_stat; /* Stat information for "file.dir". */ /* Prepare the correct names of "file.pag" and "file.dir". */ pag_file = (char *) alloca (strlen (file)+5); dir_file = (char *) alloca (strlen (file)+5); strcpy (pag_file, file); strcat (pag_file, ".pag"); strcpy (dir_file, file); strcat (dir_file, ".dir"); if (_gdbm_file != NULL) gdbm_close (_gdbm_file); /* Try to open the file as a writer. DBM never created a file. */ _gdbm_file = gdbm_open (pag_file, 0, GDBM_WRITER, 0, NULL); /* If it was not opened, try opening it as a reader. */ if (_gdbm_file == NULL) { _gdbm_file = gdbm_open (pag_file, 0, GDBM_READER, 0, NULL); /* Did we successfully open the file? */ if (_gdbm_file == NULL) { gdbm_errno = GDBM_FILE_OPEN_ERROR; return -1; } } /* If the database is new, link "file.dir" to "file.pag". This is done so the time stamp on both files is the same. */ if (stat (dir_file, &dir_stat) == 0) { if (dir_stat.st_size == 0) if (unlink (dir_file) != 0 || link (pag_file, dir_file) != 0) { gdbm_errno = GDBM_FILE_OPEN_ERROR; gdbm_close (_gdbm_file); return -1; } } else { /* Since we can't stat it, we assume it is not there and try to link the dir_file to the pag_file. */ if (link (pag_file, dir_file) != 0) { gdbm_errno = GDBM_FILE_OPEN_ERROR; gdbm_close (_gdbm_file); return -1; } } return 0; } ./libc-linux/gdbm/delete.c100644 1676 334 2701 4763323457 13450 0ustar hjlisl/* delete.c - Remove the key and its associated data from the database. This is the original unix interface name. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "extern.h" /* Remove the KEYed item and the KEY from the database. */ int delete (key) datum key; { return gdbm_delete (_gdbm_file, key); } ./libc-linux/gdbm/fetch.c100644 1676 334 3501 4763323461 13271 0ustar hjlisl/* fetch.c - Find a key and return the associated data. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "extern.h" /* Look up a given KEY and return the information associated with that KEY. The pointer in the structure that is returned is a pointer to dynamically allocated memory block. This DBM interface uses the NDBM interface. */ datum fetch (key) datum key; { datum ret_val; /* The return value. */ /* Free previous dynamic memory, do actual call, and save pointer to new memory. */ ret_val = gdbm_fetch (_gdbm_file, key); if (_gdbm_fetch_val != NULL) free (_gdbm_fetch_val); _gdbm_fetch_val = ret_val.dptr; /* Return the new value. */ return ret_val; } ./libc-linux/gdbm/store.c100644 1676 334 3057 4763323472 13344 0ustar hjlisl/* store.c - Add a new key/data pair to the database. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "extern.h" /* Add a new element to the database. CONTENT is keyed by KEY. The file on disk is updated to reflect the structure of the new database before returning from this procedure. */ int store (key, content) datum key; datum content; { return gdbm_store (_gdbm_file, key, content, GDBM_REPLACE); } ./libc-linux/gdbm/seq.c100644 1676 334 4331 4763323471 12773 0ustar hjlisl/* seq.c - This is the sequential visit of the database. This defines two user-visable routines that are used together. This is the DBM interface. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "extern.h" /* Start the visit of all keys in the database. This produces something in hash order, not in any sorted order. */ datum firstkey () { datum ret_val; /* Free previous dynamic memory, do actual call, and save pointer to new memory. */ ret_val = gdbm_firstkey (_gdbm_file); if (_gdbm_memory.dptr != NULL) free (_gdbm_memory.dptr); _gdbm_memory = ret_val; /* Return the new value. */ return ret_val; } /* Continue visiting all keys. The next key following KEY is returned. */ datum nextkey (key) datum key; { datum ret_val; /* Make sure we have a valid key. */ if (key.dptr == NULL) return key; /* Call gdbm nextkey with supplied value. After that, free the old value. */ ret_val = gdbm_nextkey (_gdbm_file, key); if (_gdbm_memory.dptr != NULL) free (_gdbm_memory.dptr); _gdbm_memory = ret_val; /* Return the new value. */ return ret_val; } ./libc-linux/gdbm/dbmopen.c100644 1676 334 10512 4763323455 13647 0ustar hjlisl/* dbmopen.c - Open the file for dbm operations. This looks like the NDBM interface for dbm use. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "gdbmerrno.h" #include "extern.h" extern gdbm_error gdbm_errno; /* Initialize ndbm system. FILE is a pointer to the file name. In standard dbm, the database is found in files called FILE.pag and FILE.dir. To make gdbm compatable with dbm using the dbminit call, the same file names are used. Specifically, dbminit will use the file name FILE.pag in its call to gdbm open. If the file (FILE.pag) has a size of zero bytes, a file initialization procedure is performed, setting up the initial structure in the file. Any error detected will cause a return value of -1. No errors cause the return value of 0. NOTE: file.dir will be ignored and will always have a size of zero. FLAGS and MODE are the same as the open (2) call. This call will look at the FLAGS and decide what call to make to gdbm_open. For FLAGS == O_RDONLY, it will be a GDBM_READER, if FLAGS == O_RDWR|O_CREAT, it will be a GDBM_WRCREAT (creater and writer) and if the FLAGS == O_RDWR, it will be a GDBM_WRITER and if FLAGS contain O_TRUNC then it will be a GDBM_NEWDB. All other values of FLAGS in the flags are ignored. */ gdbm_file_info * dbm_open (file, flags, mode) char *file; int flags; int mode; { char* pag_file; /* Used to construct "file.pag". */ char* dir_file; /* Used to construct "file.dir". */ struct stat dir_stat; /* Stat information for "file.dir". */ gdbm_file_info *temp_dbf; /* Temporary file pointer storage. */ /* Prepare the correct names of "file.pag" and "file.dir". */ pag_file = (char *) alloca (strlen (file)+5); dir_file = (char *) alloca (strlen (file)+5); strcpy (pag_file, file); strcat (pag_file, ".pag"); strcpy (dir_file, file); strcat (dir_file, ".dir"); /* Call the actual routine, saving the pointer to the file information. */ flags &= O_RDONLY | O_RDWR | O_CREAT | O_TRUNC; if (flags == O_RDONLY) { temp_dbf = gdbm_open (pag_file, 0, GDBM_READER, 0, NULL); } else if (flags == (O_RDWR | O_CREAT)) { temp_dbf = gdbm_open (pag_file, 0, GDBM_WRCREAT, mode, NULL); } else if ( (flags & O_TRUNC) == O_TRUNC) { temp_dbf = gdbm_open (pag_file, 0, GDBM_NEWDB, mode, NULL); } else { temp_dbf = gdbm_open (pag_file, 0, GDBM_WRITER, 0, NULL); } /* Did we successfully open the file? */ if (temp_dbf == NULL) { gdbm_errno = GDBM_FILE_OPEN_ERROR; return NULL; } /* If the database is new, link "file.dir" to "file.pag". This is done so the time stamp on both files is the same. */ if (stat (dir_file, &dir_stat) == 0) { if (dir_stat.st_size == 0) if (unlink (dir_file) != 0 || link (pag_file, dir_file) != 0) { gdbm_errno = GDBM_FILE_OPEN_ERROR; gdbm_close (temp_dbf); return NULL; } } else { /* Since we can't stat it, we assume it is not there and try to link the dir_file to the pag_file. */ if (link (pag_file, dir_file) != 0) { gdbm_errno = GDBM_FILE_OPEN_ERROR; gdbm_close (temp_dbf); return NULL; } } return temp_dbf; } ./libc-linux/gdbm/dbmdelete.c100644 1676 334 2736 4763323453 14137 0ustar hjlisl/* dbmdelete.c - Remove the key and its associated data from the database. This is the NDBM unix interface name. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "extern.h" /* Remove the KEYed item and the KEY from the database DBF. */ int dbm_delete (dbf,key) gdbm_file_info *dbf; datum key; { return gdbm_delete (dbf,key); } ./libc-linux/gdbm/dbmfetch.c100644 1676 334 3471 4763323454 13764 0ustar hjlisl/* dbmfetch.c - Find a key and return the associated data. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "extern.h" /* NDBM Look up a given KEY and return the information associated with that KEY. The pointer in the structure that is returned is a pointer to dynamically allocated memory block. */ datum dbm_fetch (dbf, key) gdbm_file_info *dbf; datum key; { datum ret_val; /* The return value. */ /* Free previous dynamic memory, do actual call, and save pointer to new memory. */ ret_val = gdbm_fetch (dbf, key); if (_gdbm_fetch_val != NULL) free (_gdbm_fetch_val); _gdbm_fetch_val = ret_val.dptr; /* Return the new value. */ return ret_val; } ./libc-linux/gdbm/dbmstore.c100644 1676 334 3142 4763323457 14025 0ustar hjlisl/* dbmstore.c - Add a new key/data pair to the database. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "extern.h" /* NDBM add a new element to the database. CONTENT is keyed by KEY. The file on disk is updated to reflect the structure of the new database before returning from this procedure. */ int dbm_store (dbf, key, content, flags) gdbm_file_info *dbf; datum key; datum content; int flags; { return gdbm_store (dbf, key, content, flags); } ./libc-linux/gdbm/dbmseq.c100644 1676 334 4457 4763323456 13472 0ustar hjlisl/* dbmseq.c - Visit all elements in the database. This is the NDBM interface. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "extern.h" /* NDBM Start the visit of all keys in the database. This produces something in hash order, not in any sorted order. DBF is the dbm file information pointer. */ datum dbm_firstkey (dbf) gdbm_file_info *dbf; { datum ret_val; /* Free previous dynamic memory, do actual call, and save pointer to new memory. */ ret_val = gdbm_firstkey (dbf); if (_gdbm_memory.dptr != NULL) free (_gdbm_memory.dptr); _gdbm_memory = ret_val; /* Return the new value. */ return ret_val; } /* NDBM Continue visiting all keys. The next key in the sequence is returned. DBF is the file information pointer. */ datum dbm_nextkey (dbf) gdbm_file_info *dbf; { datum ret_val; /* Make sure we have a valid key. */ if (_gdbm_memory.dptr == NULL) return _gdbm_memory; /* Call gdbm nextkey with the old value. After that, free the old value. */ ret_val = gdbm_nextkey (dbf,_gdbm_memory); if (_gdbm_memory.dptr != NULL) free (_gdbm_memory.dptr); _gdbm_memory = ret_val; /* Return the new value. */ return ret_val; } ./libc-linux/gdbm/dbmclose.c100644 1676 334 2515 4763323453 13775 0ustar hjlisl/* dbmclose.c - The the dbm file. This is the NDBM interface. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" /* Close the DBF file. */ void dbm_close (dbf) gdbm_file_info *dbf; { gdbm_close (dbf); } ./libc-linux/gdbm/dbmdirfno.c100644 1676 334 2700 4763323454 14146 0ustar hjlisl/* dbmdirfno.c - The .pag file number for NDBM interface. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" /* Return the file number of the DBF file. NDBM original wanted the .dir file number. Since we have only one file number, we return it. */ int dbm_dirfno (dbf) gdbm_file_info *dbf; { return (dbf->desc); } ./libc-linux/gdbm/dbmpagfno.c100644 1676 334 2700 4763323456 14141 0ustar hjlisl/* dbmpagfno.c - The .pag file number for NDBM interface. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" /* Return the file number of the DBF file. NDBM original wanted the .pag file number. Since we have only one file number, we return it. */ int dbm_pagfno (dbf) gdbm_file_info *dbf; { return (dbf->desc); } ./libc-linux/gdbm/gdbmopen.c100644 1676 334 27542 4763323466 14033 0ustar hjlisl/* gdbmopen.c - Open the dbm file and initialize data structures for use. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "gdbmerrno.h" extern gdbm_error gdbm_errno; /* Initialize dbm system. FILE is a pointer to the file name. If the file has a size of zero bytes, a file initialization procedure is performed, setting up the initial structure in the file. BLOCK_SIZE is used during initialization to determine the size of various constructs. If the value is less than 512, the file system blocksize is used, otherwise the value of BLOCK_SIZE is used. BLOCK_SIZE is ignored if the file has previously initialized. If READ_WRITE is set to GDBM_READ the user wants to just read the database and any call to dbm_store or dbm_delete will fail. Many readers can access the database at the same time. If READ_WRITE is set to GDBM_WRITE, the user wants both read and write access to the database and requires exclusive access. If READ_WRITE is GDBM_WRCREAT, the user wants both read and write access to the database and if the database does not exist, create a new one. If READ_WRITE is GDBM_NEWDB, the user want a new database created, regardless of whether one existed, and wants read and write access to the new database. Any error detected will cause a return value of null and an approprate value will be in gdbm_errno. If no errors occur, a pointer to the "gdbm file descriptor" will be returned. */ gdbm_file_info * gdbm_open (file, block_size, read_write, mode, fatal_func) char *file; int block_size; int read_write; int mode; void (*fatal_func) (); { gdbm_file_info *dbf; /* The record to return. */ struct stat file_stat; /* Space for the stat information. */ int len; /* Length of the file name. */ int num_bytes; /* Used in reading and writing. */ long file_pos; /* Used with seeks. */ int lock_val; /* Returned by the flock call. */ int file_block_size; /* Block size to use for a new file. */ int index; /* Used as a loop index. */ char need_trunc; /* Used with GDBM_NEWDB and locking to avoid truncating a file from under a reader. */ /* Allocate new info structure. */ dbf = (gdbm_file_info *) malloc (sizeof (gdbm_file_info)); if (dbf == NULL) { gdbm_errno = GDBM_MALLOC_ERROR; return NULL; } /* Initialize some fields for known values. This is done so gdbm_close will work if called before allocating some structures. */ dbf->dir = NULL; dbf->bucket = NULL; for (index = 0; index < CACHE_SIZE; index++) { dbf->bucket_cache[index].ca_bucket = NULL; dbf->bucket_cache[index].ca_data.dptr = NULL; } /* Save name of file. */ len = strlen (file); dbf->name = (char *) malloc (len + 1); if (dbf->name == NULL) { free (dbf); gdbm_errno = GDBM_MALLOC_ERROR; return NULL; } strcpy (dbf->name, file); /* Initialize the fatal error routine. */ dbf->fatal_err = fatal_func; /* Open the file. */ need_trunc = FALSE; if (read_write == GDBM_READER) { dbf->desc = open (dbf->name, O_RDONLY, 0); } else if (read_write == GDBM_WRITER) { dbf->desc = open (dbf->name, O_RDWR, 0); } else if (read_write == GDBM_NEWDB) { dbf->desc = open (dbf->name, O_RDWR|O_CREAT, mode); read_write = GDBM_WRITER; need_trunc = TRUE; } else { dbf->desc = open (dbf->name, O_RDWR|O_CREAT, mode); read_write = GDBM_WRITER; } if (dbf->desc < 0) { free (dbf->name); free (dbf); gdbm_errno = GDBM_FILE_OPEN_ERROR; return NULL; } /* Get the status of the file. */ fstat (dbf->desc, &file_stat); /* Lock the file in the approprate way. */ if (read_write == GDBM_READER) { if (file_stat.st_size == 0) { close (dbf->desc); free (dbf->name); free (dbf); gdbm_errno = GDBM_EMPTY_DATABASE; return NULL; } /* Sets lock_val to 0 for success. See systems.h. */ READLOCK_FILE(dbf); } else { /* Sets lock_val to 0 for success. See systems.h. */ WRITELOCK_FILE(dbf); } if (lock_val != 0) { close (dbf->desc); free (dbf->name); free (dbf); if (read_write == GDBM_READER) gdbm_errno = GDBM_CANT_BE_READER; else gdbm_errno = GDBM_CANT_BE_WRITER; return NULL; } /* Record the kind of user. */ dbf->read_write = read_write; /* If we do have a write lock and it was a GDBM_NEWDB, it is now time to truncate the file. */ if (need_trunc && file_stat.st_size != 0) { TRUNCATE (dbf); fstat (dbf->desc, &file_stat); } /* Decide if this is a new file or an old file. */ if (file_stat.st_size == 0) { /* This is a new file. Create an empty database. */ /* Start with the blocksize. */ if (block_size < 512) file_block_size = STATBLKSIZE; else file_block_size = block_size; /* Get space for the file header. */ dbf->header = (gdbm_file_header *) malloc (file_block_size); if (dbf->header == NULL) { gdbm_close (dbf); gdbm_errno = GDBM_MALLOC_ERROR; return NULL; } /* Set the magic number and the block_size. */ dbf->header->header_magic = 0x13579ace; dbf->header->block_size = file_block_size; /* Create the initial hash table directory. */ dbf->header->dir_size = 8 * sizeof (int); dbf->header->dir_bits = 3; while (dbf->header->dir_size < dbf->header->block_size) { dbf->header->dir_size <<= 1; dbf->header->dir_bits += 1; } /* Check for correct block_size. */ if (dbf->header->dir_size != dbf->header->block_size) { gdbm_close (dbf); gdbm_errno = GDBM_BLOCK_SIZE_ERROR; return NULL; } /* Allocate the space for the directory. */ dbf->dir = (int *) malloc (dbf->header->dir_size); if (dbf->dir == NULL) { gdbm_close (dbf); gdbm_errno = GDBM_MALLOC_ERROR; return NULL; } dbf->header->dir = dbf->header->block_size; /* Create the first and only hash bucket. */ dbf->header->bucket_elems = (dbf->header->block_size - sizeof (hash_bucket)) / sizeof (bucket_element) + 1; dbf->header->bucket_size = dbf->header->block_size; dbf->bucket = (hash_bucket *) (alloca (dbf->header->bucket_size)); if (dbf->bucket == NULL) { gdbm_close (dbf); gdbm_errno = GDBM_MALLOC_ERROR; return NULL; } _gdbm_new_bucket (dbf, dbf->bucket, 0); dbf->bucket->av_count = 1; dbf->bucket->bucket_avail[0].av_adr = 3*dbf->header->block_size; dbf->bucket->bucket_avail[0].av_size = dbf->header->block_size; /* Set table entries to point to hash buckets. */ for (index = 0; index < dbf->header->dir_size / sizeof (int); index++) dbf->dir[index] = 2*dbf->header->block_size; /* Initialize the active avail block. */ dbf->header->avail.size = ( (dbf->header->block_size - sizeof (gdbm_file_header)) / sizeof (avail_elem)) + 1; dbf->header->avail.count = 0; dbf->header->avail.next_block = 0; dbf->header->next_block = 4*dbf->header->block_size; /* Write initial configuration to the file. */ /* Block 0 is the file header and active avail block. */ num_bytes = write (dbf->desc, dbf->header, dbf->header->block_size); if (num_bytes != dbf->header->block_size) { gdbm_close (dbf); gdbm_errno = GDBM_FILE_WRITE_ERROR; return NULL; } /* Block 1 is the initial bucket directory. */ num_bytes = write (dbf->desc, dbf->dir, dbf->header->dir_size); if (num_bytes != dbf->header->dir_size) { gdbm_close (dbf); gdbm_errno = GDBM_FILE_WRITE_ERROR; return NULL; } /* Block 2 is the only bucket. */ num_bytes = write (dbf->desc, dbf->bucket, dbf->header->bucket_size); if (num_bytes != dbf->header->bucket_size) { gdbm_close (dbf); gdbm_errno = GDBM_FILE_WRITE_ERROR; return NULL; } /* Wait for initial configuration to be written to disk. */ fsync (dbf->desc); } else { /* This is an old database. Read in the information from the file header and initialize the hash directory. */ gdbm_file_header partial_header; /* For the first part of it. */ /* Read the partial file header. */ num_bytes = read (dbf->desc, &partial_header, sizeof (gdbm_file_header)); if (num_bytes != sizeof (gdbm_file_header)) { gdbm_close (dbf); gdbm_errno = GDBM_FILE_READ_ERROR; return NULL; } /* Is the magic number good? */ if (partial_header.header_magic != 0x13579ace) { gdbm_close (dbf); gdbm_errno = GDBM_BAD_MAGIC_NUMBER; return NULL; } /* It is a good database, read the entire header. */ dbf->header = (gdbm_file_header *) malloc (partial_header.block_size); if (dbf->header == NULL) { gdbm_close (dbf); gdbm_errno = GDBM_MALLOC_ERROR; return NULL; } bcopy (&partial_header, dbf->header, sizeof (gdbm_file_header)); num_bytes = read (dbf->desc, &dbf->header->avail.av_table[1], dbf->header->block_size-sizeof (gdbm_file_header)); if (num_bytes != dbf->header->block_size-sizeof (gdbm_file_header)) { gdbm_close (dbf); gdbm_errno = GDBM_FILE_READ_ERROR; return NULL; } /* Allocate space for the hash table directory. */ dbf->dir = (int *) malloc (dbf->header->dir_size); if (dbf->dir == NULL) { gdbm_close (dbf); gdbm_errno = GDBM_MALLOC_ERROR; return NULL; } /* Read the hash table directory. */ file_pos = lseek (dbf->desc, dbf->header->dir, L_SET); if (file_pos != dbf->header->dir) { gdbm_close (dbf); gdbm_errno = GDBM_FILE_SEEK_ERROR; return NULL; } num_bytes = read (dbf->desc, dbf->dir, dbf->header->dir_size); if (num_bytes != dbf->header->dir_size) { gdbm_close (dbf); gdbm_errno = GDBM_FILE_READ_ERROR; return NULL; } } /* Initialize the bucket cache. */ for (index = 0; index < CACHE_SIZE; index++) { dbf->bucket_cache[index].ca_bucket = (hash_bucket *) malloc (dbf->header->bucket_size); if (dbf->bucket_cache[index].ca_bucket == NULL) { gdbm_close (dbf); gdbm_errno = GDBM_MALLOC_ERROR; return NULL; } dbf->bucket_cache[index].ca_adr = 0; dbf->bucket_cache[index].ca_changed = FALSE; dbf->bucket_cache[index].ca_data.hash_val = -1; dbf->bucket_cache[index].ca_data.elem_loc = -1; } /* Finish initializing dbf. */ dbf->last_read = -1; dbf->bucket = dbf->bucket_cache[0].ca_bucket; dbf->bucket_dir = 0; dbf->cache_entry = &dbf->bucket_cache[0]; dbf->header_changed = FALSE; dbf->directory_changed = FALSE; dbf->bucket_changed = FALSE; dbf->second_changed = FALSE; /* Everything is fine, return the pointer to the file information structure. */ return dbf; } ./libc-linux/gdbm/gdbmdelete.c100644 1676 334 7332 4763323464 14305 0ustar hjlisl/* gdbmdelete.c - Remove the key and its associated data from the database. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "gdbmerrno.h" extern gdbm_error gdbm_errno; /* Remove the KEYed item and the KEY from the database DBF. The file on disk is updated to reflect the structure of the new database before returning from this procedure. */ int gdbm_delete (dbf, key) gdbm_file_info *dbf; datum key; { int elem_loc; /* The location in the current hash bucket. */ int last_loc; /* Last location emptied by the delete. */ int home; /* Home position of an item. */ bucket_element elem; /* The element to be deleted. */ char *find_data; /* Return pointer from findkey. */ long hash_val; /* Returned by findkey. */ long free_adr; /* Temporary stroage for address and size. */ int free_size; /* First check to make sure this guy is a writer. */ if (dbf->read_write != GDBM_WRITER) { gdbm_errno = GDBM_READER_CANT_DELETE; return -1; } /* Find the item. */ elem_loc = _gdbm_findkey (dbf, key, &find_data, &hash_val); if (elem_loc == -1) { gdbm_errno = GDBM_ITEM_NOT_FOUND; return -1; } /* Save the element. */ elem = dbf->bucket->h_table[elem_loc]; /* Delete the element. */ dbf->bucket->h_table[elem_loc].hash_value = -1; dbf->bucket->count -= 1; /* Move other elements to guarantee that they can be found. */ last_loc = elem_loc; elem_loc = (elem_loc + 1) % dbf->header->bucket_elems; while (elem_loc != last_loc && dbf->bucket->h_table[elem_loc].hash_value != -1) { home = dbf->bucket->h_table[elem_loc].hash_value % dbf->header->bucket_elems; if ( (last_loc < elem_loc && (home <= last_loc || home > elem_loc)) || (last_loc > elem_loc && home <= last_loc && home > elem_loc)) { dbf->bucket->h_table[last_loc] = dbf->bucket->h_table[elem_loc]; dbf->bucket->h_table[elem_loc].hash_value = -1; last_loc = elem_loc; } elem_loc = (elem_loc + 1) % dbf->header->bucket_elems; } /* Free the file space. */ free_adr = elem.data_pointer; free_size = elem.key_size + elem.data_size; _gdbm_free (dbf, free_adr, free_size); /* Set the flags. */ dbf->bucket_changed = TRUE; /* Clear out the data cache for the current bucket. */ if (dbf->cache_entry->ca_data.dptr != NULL) { free (dbf->cache_entry->ca_data.dptr); dbf->cache_entry->ca_data.dptr = NULL; } dbf->cache_entry->ca_data.hash_val = -1; dbf->cache_entry->ca_data.key_size = 0; dbf->cache_entry->ca_data.elem_loc = -1; /* Do the writes. */ _gdbm_end_update (dbf); return 0; } ./libc-linux/gdbm/gdbmfetch.c100644 1676 334 4772 4763323465 14142 0ustar hjlisl/* gdbmfetch.c - Find a key and return the associated data. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "gdbmerrno.h" extern gdbm_error gdbm_errno; /* Look up a given KEY and return the information associated with that KEY. The pointer in the structure that is returned is a pointer to dynamically allocated memory block. */ datum gdbm_fetch (dbf, key) gdbm_file_info *dbf; datum key; { datum return_val; /* The return value. */ int elem_loc; /* The location in the bucket. */ char *find_data; /* Returned from find_key. */ long hash_val; /* Returned from find_key. */ /* Set the default return value. */ return_val.dptr = NULL; /* Find the key and return a pointer to the data. */ elem_loc = _gdbm_findkey (dbf, key, &find_data, &hash_val); /* Copy the data if the key was found. */ if (elem_loc >= 0) { /* This is the item. Return the associated data. */ return_val.dsize = dbf->bucket->h_table[elem_loc].data_size; if (return_val.dsize == 0) return_val.dptr = (char *) malloc (1); else return_val.dptr = (char *) malloc (return_val.dsize); if (return_val.dptr == NULL) _gdbm_fatal (dbf, "malloc error"); bcopy (find_data, return_val.dptr, return_val.dsize); } /* Check for an error and return. */ if (return_val.dptr == NULL) gdbm_errno = GDBM_ITEM_NOT_FOUND; return return_val; } ./libc-linux/gdbm/gdbmstore.c100644 1676 334 13447 4763323467 14226 0ustar hjlisl/* gdbmstore.c - Add a new key/data pair to the database. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "gdbmerrno.h" extern gdbm_error gdbm_errno; /* gdbm's error variable. */ /* Add a new element to the database. CONTENT is keyed by KEY. The file on disk is updated to reflect the structure of the new database before returning from this procedure. The FLAGS define the action to take when the KEY is already in the database. The value GDBM_REPLACE asks that the old data be replaced by the new CONTENT. The value GDBM_INSERT asks that an error be returned and no action taken. A return value of 0 means no errors. A return value of -1 means that the item was not stored in the data base because the caller was not an official writer. A return value of 0 means that the item was not stored because the argument FLAGS was GDBM_INSERT and the KEY was already in the database. */ int gdbm_store (dbf, key, content, flags) gdbm_file_info *dbf; datum key; datum content; int flags; { long new_hash_val; /* The new hash value. */ int elem_loc; /* The location in hash bucket. */ long file_adr; /* The address of new space in the file. */ long file_pos; /* The position after a lseek. */ int num_bytes; /* Used for error detection. */ long free_adr; /* For keeping track of a freed section. */ int free_size; char *write_data; /* To write both key and data in 1 call. */ char *src; /* Used to prepare write_data. */ char *dst; /* Used to prepare write_data. */ int cnt; /* Counter for loops to fill write_data. */ int new_size; /* Used in allocating space. */ char *temp; /* Used in _gdbm_findkey call. */ /* First check to make sure this guy is a writer. */ if (dbf->read_write != GDBM_WRITER) { gdbm_errno = GDBM_READER_CANT_STORE; return -1; } /* Check for illegal data values. A NULL dptr field is illegal because NULL dptr returned by a lookup procedure indicates an error. */ if ((key.dptr == NULL) || (content.dptr == NULL)) { gdbm_errno = GDBM_ILLEGAL_DATA; return -1; } /* Look for the key in the file. A side effect loads the correct bucket and calculates the hash value. */ elem_loc = _gdbm_findkey (dbf, key, &temp, &new_hash_val); /* Did we find the item? */ if (elem_loc != -1) { if (flags == GDBM_REPLACE) { /* Just replace the data. */ free_adr = dbf->bucket->h_table[elem_loc].data_pointer; free_size = dbf->bucket->h_table[elem_loc].key_size + dbf->bucket->h_table[elem_loc].data_size; _gdbm_free (dbf, free_adr, free_size); } else { gdbm_errno = GDBM_CANNOT_REPLACE; return 1; } } /* Get the file address for the new space. (Current bucket's free space is first place to look.) */ new_size = key.dsize+content.dsize; file_adr = _gdbm_alloc (dbf, new_size); /* If this is a new entry in the bucket, we need to do special things. */ if (elem_loc == -1) { if (dbf->bucket->count == dbf->header->bucket_elems) { /* Split the current bucket. */ _gdbm_split_bucket (dbf, new_hash_val); } /* Find space to insert into bucket and set elem_loc to that place. */ elem_loc = new_hash_val % dbf->header->bucket_elems; while (dbf->bucket->h_table[elem_loc].hash_value != -1) { elem_loc = (elem_loc + 1) % dbf->header->bucket_elems; } /* We now have another element in the bucket. Add the new information.*/ dbf->bucket->count += 1; dbf->bucket->h_table[elem_loc].hash_value = new_hash_val; bcopy (key.dptr, dbf->bucket->h_table[elem_loc].key_start, (SMALL < key.dsize ? SMALL : key.dsize)); } /* Update current bucket data pointer and sizes. */ dbf->bucket->h_table[elem_loc].data_pointer = file_adr; dbf->bucket->h_table[elem_loc].key_size = key.dsize; dbf->bucket->h_table[elem_loc].data_size = content.dsize; /* Prepare write_data. The key is written first. */ write_data = (char *) alloca (key.dsize+content.dsize); dst = write_data; src = key.dptr; for (cnt=0; cnt < key.dsize; cnt++) * (dst++) = * (src++); src = content.dptr; for (cnt=0; cnt < content.dsize; cnt++) * (dst++) = * (src++); /* Write the data to the file. */ file_pos = lseek (dbf->desc, file_adr, L_SET); if (file_pos != file_adr) _gdbm_fatal (dbf, "lseek error"); num_bytes = write (dbf->desc, write_data, key.dsize+content.dsize); if (num_bytes != key.dsize+content.dsize) _gdbm_fatal (dbf, "write error"); /* Current bucket has changed. */ dbf->cache_entry->ca_changed = TRUE; dbf->bucket_changed = TRUE; /* Write everything that is needed to the disk. */ _gdbm_end_update (dbf); return 0; } ./libc-linux/gdbm/gdbmclose.c100644 1676 334 3706 4763323462 14147 0ustar hjlisl/* gdbmclose.c - Close a previously opened dbm file. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" /* Close the dbm file and free all memory associated with the file DBF. Before freeing members of DBF, check and make sure that they were allocated. */ void gdbm_close (dbf) gdbm_file_info *dbf; { int index; /* For freeing the bucket cache. */ /* Close the file and free all malloced memory. */ UNLOCK_FILE(dbf); close (dbf->desc); free (dbf->name); if (dbf->dir != NULL) free (dbf->dir); for (index = 0; index < CACHE_SIZE; index++) { if (dbf->bucket_cache[index].ca_bucket != NULL) free (dbf->bucket_cache[index].ca_bucket); if (dbf->bucket_cache[index].ca_data.dptr != NULL) free (dbf->bucket_cache[index].ca_data.dptr); } if ( dbf->header != NULL ) free (dbf->header); free (dbf); } ./libc-linux/gdbm/gdbmreorg.c100644 1676 334 12645 4763323466 14206 0ustar hjlisl/* gdbmreorg.c - Reorganize the database file. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 ************************************************************************/ #include "gdbmdefs.h" #include "gdbmerrno.h" extern gdbm_error gdbm_errno; #include "extern.h" #ifdef NEED_RENAME /* Rename takes OLD_NAME and renames it as NEW_NAME. If it can not rename the file a non-zero value is returned. OLD_NAME is guaranteed to remain if it can't be renamed. It assumes NEW_NAME always exists (due to being used in gdbm). */ static int rename (old_name, new_name) char* old_name; char* new_name; { if (unlink (new_name) != 0) return -1; if (link (old_name, new_name) != 0) return -1; unlink (old_name); return 0; } #endif /* Reorganize the database. This requires creating a new file and inserting all the elements in the old file DBF into the new file. The new file is then renamed to the same name as the old file and DBF is updated to contain all the correct information about the new file. If an error is detected, the return value is negative. The value zero is returned after a successful reorganization. */ int gdbm_reorganize (dbf) gdbm_file_info *dbf; { gdbm_file_info *new_dbf; /* The new file. */ char *new_name; /* A temporary name. */ int len; /* Used in new_name construction. */ datum key, nextkey, data; /* For the sequential sweep. */ struct stat fileinfo; /* Information about the file. */ int index; /* Use in moving the bucket cache. */ /* Readers can not reorganize! */ if (dbf->read_write == GDBM_READER) { gdbm_errno = GDBM_READER_CANT_REORGANIZE; return -1; } /* Construct new name for temporary file. */ len = strlen (dbf->name); new_name = (char *) malloc (len + 3); if (new_name == NULL) { gdbm_errno = GDBM_MALLOC_ERROR; return -1; } strcpy (&new_name[0], dbf->name); new_name[len+2] = 0; new_name[len+1] = '#'; while ( (len > 0) && new_name[len-1] != '/') { new_name[len] = new_name[len-1]; len -= 1; } new_name[len] = '#'; /* Get the mode for the old file and open the new database. */ fstat (dbf->desc, &fileinfo); new_dbf = gdbm_open (new_name, dbf->header->block_size, GDBM_WRCREAT, fileinfo.st_mode, dbf->fatal_err); if (new_dbf == NULL) { gdbm_errno = GDBM_REORGANIZE_FAILED; free (new_name); return -1; } /* For each item in the old database, add an entry in the new. */ key = gdbm_firstkey (dbf); while (key.dptr != NULL) { data = gdbm_fetch (dbf, key); if (data.dptr != NULL) { /* Add the data to the new file. */ if (gdbm_store (new_dbf, key, data, GDBM_INSERT) != 0) { gdbm_close (new_dbf); gdbm_errno = GDBM_REORGANIZE_FAILED; unlink (new_name); return -1; }; } else { /* ERROR! Abort and don't finish reorganize. */ gdbm_close (new_dbf); gdbm_errno = GDBM_REORGANIZE_FAILED; unlink (new_name); return -1; } nextkey = gdbm_nextkey (dbf, key); free (key.dptr); key = nextkey; } /* Move the new file to old name. */ if (rename (new_name, dbf->name) != 0) { gdbm_errno = GDBM_REORGANIZE_FAILED; gdbm_close (new_dbf); return -1; } /* Fix up DBF to have the correct information for the new file. */ UNLOCK_FILE(dbf); close (dbf->desc); free (dbf->header); free (dbf->dir); for (index = 0; index < CACHE_SIZE; index++) { if (dbf->bucket_cache[index].ca_bucket != NULL) free (dbf->bucket_cache[index].ca_bucket); if (dbf->bucket_cache[index].ca_data.dptr != NULL) free (dbf->bucket_cache[index].ca_data.dptr); } dbf->desc = new_dbf->desc; dbf->header = new_dbf->header; dbf->dir = new_dbf->dir; dbf->bucket = new_dbf->bucket; dbf->bucket_dir = new_dbf->bucket_dir; dbf->cache_entry = new_dbf->cache_entry; dbf->last_read = new_dbf->last_read; for (index = 0; index < CACHE_SIZE; index++) dbf->bucket_cache[index] = new_dbf->bucket_cache[index]; dbf->header_changed = new_dbf->header_changed; dbf->directory_changed = new_dbf->directory_changed; dbf->bucket_changed = new_dbf->bucket_changed; dbf->second_changed = new_dbf->second_changed; free (new_dbf); /* Make sure the new database is all on disk. */ fsync (dbf->desc); return 0; } ./libc-linux/gdbm/gdbmseq.c100644 1676 334 10251 4763323467 13650 0ustar hjlisl/* gdbmseq.c - Routines to visit all keys. Not in sorted order. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" /* Special extern for this file. */ extern char *_gdbm_read_entry (); /* Find and read the next entry in the hash structure for DBF starting at ELEM_LOC of the current bucket and using RETURN_VAL as the place to put the data that is found. */ static void get_next_key (dbf, elem_loc, return_val) gdbm_file_info *dbf; int elem_loc; datum *return_val; { int found; /* Have we found the next key. */ char *find_data; /* Data pointer returned by find_key. */ /* Find the next key. */ found = FALSE; while (!found) { /* Advance to the next location in the bucket. */ elem_loc++; if (elem_loc == dbf->header->bucket_elems) { /* We have finished the current bucket, get the next bucket. */ elem_loc = 0; /* Find the next bucket. It is possible several entries in the bucket directory point to the same bucket. */ while (dbf->bucket_dir < dbf->header->dir_size / sizeof (int) && dbf->cache_entry->ca_adr == dbf->dir[dbf->bucket_dir]) dbf->bucket_dir++; /* Check to see if there was a next bucket. */ if (dbf->bucket_dir < dbf->header->dir_size / sizeof (int)) _gdbm_get_bucket (dbf, dbf->bucket_dir); else /* No next key, just return. */ return ; } found = dbf->bucket->h_table[elem_loc].hash_value != -1; } /* Found the next key, read it into return_val. */ find_data = _gdbm_read_entry (dbf, elem_loc); return_val->dsize = dbf->bucket->h_table[elem_loc].key_size; if (return_val->dsize == 0) return_val->dptr = (char *) malloc (1); else return_val->dptr = (char *) malloc (return_val->dsize); if (return_val->dptr == NULL) _gdbm_fatal (dbf, "malloc error"); bcopy (find_data, return_val->dptr, return_val->dsize); } /* Start the visit of all keys in the database. This produces something in hash order, not in any sorted order. */ datum gdbm_firstkey (dbf) gdbm_file_info *dbf; { datum return_val; /* To return the first key. */ /* Set the default return value for not finding a first entry. */ return_val.dptr = NULL; /* Get the first bucket. */ _gdbm_get_bucket (dbf, 0); /* Look for first entry. */ get_next_key (dbf, -1, &return_val); return return_val; } /* Continue visiting all keys. The next key following KEY is returned. */ datum gdbm_nextkey (dbf, key) gdbm_file_info *dbf; datum key; { datum return_val; /* The return value. */ int elem_loc; /* The location in the bucket. */ char *find_data; /* Data pointer returned by _gdbm_findkey. */ long hash_val; /* Returned by _gdbm_findkey. */ /* Set the default return value for no next entry. */ return_val.dptr = NULL; /* Do we have a valid key? */ if (key.dptr == NULL) return return_val; /* Find the key. */ elem_loc = _gdbm_findkey (dbf, key, &find_data, &hash_val); if (elem_loc == -1) return return_val; /* Find the next key. */ get_next_key (dbf, elem_loc, &return_val); return return_val; } ./libc-linux/gdbm/bucket.c100644 1676 334 25430 4763323451 13501 0ustar hjlisl/* bucket.c - The routines for playing with hash buckets. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" /* Initializing a new hash buckets sets all bucket entries to -1 hash value. */ void _gdbm_new_bucket (dbf, bucket, bits) gdbm_file_info *dbf; hash_bucket *bucket; int bits; { int index; /* Initialize the avail block. */ bucket->av_count = 0; /* Set the information fields first. */ bucket->bucket_bits = bits; bucket->count = 0; /* Initialize all bucket elements. */ for (index = 0; index < dbf->header->bucket_elems; index++) bucket->h_table[index].hash_value = -1; } /* Find a bucket for DBF that is pointed to by the bucket directory from location DIR_INDEX. The bucket cache is first checked to see if it is already in memory. If not, a bucket may be tossed to read the new bucket. In any case, the requested bucket is make the "current" bucket and dbf->bucket points to the correct bucket. */ int _gdbm_get_bucket (dbf, dir_index) gdbm_file_info *dbf; long dir_index; { long bucket_adr; /* The address of the correct hash bucket. */ int num_bytes; /* The number of bytes read. */ long file_pos; /* The return address for lseek. */ int index; /* Loop index. */ /* Initial set up. */ dbf->bucket_dir = dir_index; bucket_adr = dbf->dir [dir_index]; /* Is that one is not alread current, we must find it. */ if (dbf->cache_entry->ca_adr != bucket_adr) { /* Look in the cache. */ for (index = 0; index < CACHE_SIZE; index++) if (dbf->bucket_cache[index].ca_adr == bucket_adr) { dbf->bucket = dbf->bucket_cache[index].ca_bucket; dbf->cache_entry = &dbf->bucket_cache[index]; return; } /* It is not in the cache, read it from the disk. */ dbf->last_read = (dbf->last_read + 1) % CACHE_SIZE; dbf->bucket_cache[dbf->last_read].ca_adr = bucket_adr; dbf->bucket = dbf->bucket_cache[dbf->last_read].ca_bucket; dbf->cache_entry = &dbf->bucket_cache[dbf->last_read]; dbf->cache_entry->ca_data.elem_loc = -1; dbf->cache_entry->ca_changed = FALSE; /* Read the bucket. */ file_pos = lseek (dbf->desc, bucket_adr, L_SET); if (file_pos != bucket_adr) _gdbm_fatal (dbf, "lseek error"); num_bytes = read (dbf->desc, dbf->bucket, dbf->header->bucket_size); if (num_bytes != dbf->header->bucket_size) _gdbm_fatal (dbf, "read error"); } return; } /* Split the current bucket. This includes moving all items in the bucket to a new bucket. This doesn't require any disk reads because all hash values are stored in the buckets. Splitting the current bucket may require doubling the size of the hash directory. */ void _gdbm_split_bucket (dbf, next_insert) gdbm_file_info *dbf; int next_insert; { hash_bucket *bucket[2]; /* Pointers to the new buckets. */ int new_bits; /* The number of bits for the new buckets. */ int cache_0; /* Location in the cache for the buckets. */ int cache_1; long adr_0; /* File address of the new bucket 0. */ long adr_1; /* File address of the new bucket 1. */ avail_elem old_bucket; /* Avail Struct for the old bucket. */ long dir_start0; /* Used in updating the directory. */ long dir_start1; long dir_end; long *new_dir; /* Pointer to the new directory. */ long dir_adr; /* Address of the new directory. */ long dir_size; /* Size of the new directory. */ long old_adr[31]; /* Address of the old directories. */ long old_size[31]; /* Size of the old directories. */ int old_count; /* Number of old directories. */ int index; /* Used in array indexing. */ int index1; /* Used in array indexing. */ int elem_loc; /* Location in new bucket to put element. */ bucket_element *old_el; /* Pointer into the old bucket. */ int select; /* Used to index bucket during movement. */ /* No directories are yet old. */ old_count = 0; while (dbf->bucket->count == dbf->header->bucket_elems) { /* Initialize the "new" buckets in the cache. */ do { dbf->last_read = (dbf->last_read + 1) % CACHE_SIZE; cache_0 = dbf->last_read; } while (dbf->bucket_cache[cache_0].ca_bucket == dbf->bucket); bucket[0] = dbf->bucket_cache[cache_0].ca_bucket; if (dbf->bucket_cache[cache_0].ca_changed) _gdbm_write_bucket (dbf, &dbf->bucket_cache[cache_0]); do { dbf->last_read = (dbf->last_read + 1) % CACHE_SIZE; cache_1 = dbf->last_read; } while (dbf->bucket_cache[cache_1].ca_bucket == dbf->bucket); bucket[1] = dbf->bucket_cache[cache_1].ca_bucket; if (dbf->bucket_cache[cache_1].ca_changed) _gdbm_write_bucket (dbf, &dbf->bucket_cache[cache_1]); new_bits = dbf->bucket->bucket_bits+1; _gdbm_new_bucket (dbf, bucket[0], new_bits); _gdbm_new_bucket (dbf, bucket[1], new_bits); adr_0 = _gdbm_alloc (dbf, dbf->header->bucket_size); dbf->bucket_cache[cache_0].ca_adr = adr_0; adr_1 = _gdbm_alloc (dbf, dbf->header->bucket_size); dbf->bucket_cache[cache_1].ca_adr = adr_1; /* Double the directory size if necessary. */ if (dbf->header->dir_bits == dbf->bucket->bucket_bits) { dir_size = dbf->header->dir_size * 2; dir_adr = _gdbm_alloc (dbf, dir_size); new_dir = (long *) malloc (dir_size); if (new_dir == NULL) _gdbm_fatal (dbf, "malloc error"); for (index = 0; index < dbf->header->dir_size/sizeof (int); index++) { new_dir[2*index] = dbf->dir[index]; new_dir[2*index+1] = dbf->dir[index]; } /* Update header. */ old_adr[old_count] = dbf->header->dir; dbf->header->dir = dir_adr; old_size[old_count] = dbf->header->dir_size; dbf->header->dir_size = dir_size; dbf->header->dir_bits = new_bits; old_count++; /* Now update dbf. */ dbf->header_changed = TRUE; dbf->bucket_dir *= 2; free (dbf->dir); dbf->dir = new_dir; } /* Copy all elements in dbf->bucket into the new buckets. */ for (index = 0; index < dbf->header->bucket_elems; index++) { old_el = & (dbf->bucket->h_table[index]); select = (old_el->hash_value >> (31-new_bits)) & 1; elem_loc = old_el->hash_value % dbf->header->bucket_elems; while (bucket[select]->h_table[elem_loc].hash_value != -1) elem_loc = (elem_loc + 1) % dbf->header->bucket_elems; bucket[select]->h_table[elem_loc] = *old_el; bucket[select]->count += 1; } /* Allocate avail space for the bucket[1]. */ bucket[1]->bucket_avail[0].av_adr = _gdbm_alloc (dbf, dbf->header->block_size); bucket[1]->bucket_avail[0].av_size = dbf->header->block_size; bucket[1]->av_count = 1; /* Copy the avail elements in dbf->bucket to bucket[0]. */ bucket[0]->av_count = dbf->bucket->av_count; index = 0; index1 = 0; if (bucket[0]->av_count == BUCKET_AVAIL) { /* The avail is full, move the first one to bucket[1]. */ _gdbm_put_av_elem (dbf->bucket->bucket_avail[0], bucket[1]->bucket_avail, &bucket[1]->av_count); index = 1; bucket[0]->av_count --; } for (; index < dbf->bucket->av_count; index++) { bucket[0]->bucket_avail[index1++] = dbf->bucket->bucket_avail[index]; } /* Update the directory. We have new file addresses for both buckets. */ dir_start1 = (dbf->bucket_dir >> (dbf->header->dir_bits - new_bits)) | 1; dir_end = (dir_start1 + 1) << (dbf->header->dir_bits - new_bits); dir_start1 = dir_start1 << (dbf->header->dir_bits - new_bits); dir_start0 = dir_start1 - (dir_end - dir_start1); for (index = dir_start0; index < dir_start1; index++) dbf->dir[index] = adr_0; for (index = dir_start1; index < dir_end; index++) dbf->dir[index] = adr_1; /* Set changed flags. */ dbf->bucket_cache[cache_0].ca_changed = TRUE; dbf->bucket_cache[cache_1].ca_changed = TRUE; dbf->bucket_changed = TRUE; dbf->directory_changed = TRUE; dbf->second_changed = TRUE; /* Update the cache! */ dbf->bucket_dir = next_insert >> (31-dbf->header->dir_bits); /* Invalidate old cache entry. */ old_bucket.av_adr = dbf->cache_entry->ca_adr; old_bucket.av_size = dbf->header->bucket_size; dbf->cache_entry->ca_adr = 0; dbf->cache_entry->ca_changed = FALSE; /* Set dbf->bucket to the proper bucket. */ if (dbf->dir[dbf->bucket_dir] == adr_0) { dbf->bucket = bucket[0]; dbf->cache_entry = &dbf->bucket_cache[cache_0]; _gdbm_put_av_elem (old_bucket, bucket[1]->bucket_avail, &bucket[1]->av_count); } else { dbf->bucket = bucket[1]; dbf->cache_entry = &dbf->bucket_cache[cache_1]; _gdbm_put_av_elem (old_bucket, bucket[0]->bucket_avail, &bucket[0]->av_count); } } /* Get rid of old directories. */ for (index = 0; index < old_count; index++) _gdbm_free (dbf, old_adr[index], old_size[index]); } /* The only place where a bucket is written. CA_ENTRY is the cache entry containing the bucket to be written. */ _gdbm_write_bucket (dbf, ca_entry) gdbm_file_info *dbf; cache_elem *ca_entry; { int num_bytes; /* The return value for write. */ long file_pos; /* The return value for lseek. */ file_pos = lseek (dbf->desc, ca_entry->ca_adr, L_SET); if (file_pos != ca_entry->ca_adr) _gdbm_fatal (dbf, "lseek error"); num_bytes = write (dbf->desc, ca_entry->ca_bucket, dbf->header->bucket_size); if (num_bytes != dbf->header->bucket_size) _gdbm_fatal (dbf, "write error"); ca_entry->ca_changed = FALSE; ca_entry->ca_data.hash_val = -1; ca_entry->ca_data.elem_loc = -1; } ./libc-linux/gdbm/falloc.c100644 1676 334 26602 4763323461 13467 0ustar hjlisl/* falloc.c - The file space management routines for dbm. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" /* The forward definitions for this file. See the functions for the definition of the function. */ static avail_elem get_elem (); static avail_elem get_block (); static push_avail_block (); static pop_avail_block (); static adjust_bucket_avail (); /* Allocate space in the file DBF for a block NUM_BYTES in length. Return the file address of the start of the block. Each hash bucket has a fixed size avail table. We first check this avail table to satisfy the request for space. In most cases we can and this causes changes to be only in the current hash bucket. Allocation is done on a first fit basis from the entries. If a request can not be satisfied from the current hash bucket, then it is satisfied from the file header avail block. If nothing is there that has enough space, another block at the end of the file is allocated and the unused portion is returned to the avail block. This routine "guarantees" that an allocation does not cross a block boundary unless the size is larger than a single block. The avail structure is changed by this routine if a change is needed. If an error occurs, the value of 0 will be returned. */ long _gdbm_alloc (dbf, num_bytes) gdbm_file_info *dbf; int num_bytes; { long file_adr; /* The address of the block. */ avail_elem av_el; /* For temporary use. */ /* The current bucket is the first place to look for space. */ av_el = get_elem (num_bytes, dbf->bucket->bucket_avail, &dbf->bucket->av_count); /* If we did not find some space, we have more work to do. */ if (av_el.av_size == 0) { /* Is the header avail block empty and there is something on the stack. */ if (dbf->header->avail.count == 0 && dbf->header->avail.next_block != 0) pop_avail_block (dbf); /* Get another full block from end of file. */ av_el = get_block (num_bytes, dbf); dbf->header_changed = TRUE; } /* We now have the place from which we will allocate the new space. */ file_adr = av_el.av_adr; /* Put the unused space back in the avail block. */ av_el.av_adr += num_bytes; av_el.av_size -= num_bytes; _gdbm_free (dbf, av_el.av_adr, av_el.av_size); /* Return the address. */ return file_adr; } /* Free space of size NUM_BYTES in the file DBF at file address FILE_ADR. Make it avaliable for reuse through _gdbm_alloc. This routine changes the avail structure. The value TRUE is returned if there were errors. If no errors occured, the value FALSE is returned. */ _gdbm_free (dbf, file_adr, num_bytes) gdbm_file_info *dbf; long file_adr; int num_bytes; { avail_elem temp; /* Is it too small to worry about? */ if (num_bytes <= IGNORE_SIZE) return; /* Initialize the avail element. */ temp.av_size = num_bytes; temp.av_adr = file_adr; /* Is the freed space large or small? */ if (num_bytes >= dbf->header->block_size) { if (dbf->header->avail.count == dbf->header->avail.size) { push_avail_block (dbf); } _gdbm_put_av_elem (temp, dbf->header->avail.av_table, &dbf->header->avail.count); dbf->header_changed = TRUE; } else { /* Try to put into the current bucket. */ if (dbf->bucket->av_count < BUCKET_AVAIL) _gdbm_put_av_elem (temp, dbf->bucket->bucket_avail, &dbf->bucket->av_count); else { if (dbf->header->avail.count == dbf->header->avail.size) { push_avail_block (dbf); } _gdbm_put_av_elem (temp, dbf->header->avail.av_table, &dbf->header->avail.count); dbf->header_changed = TRUE; } } if (dbf->header_changed) adjust_bucket_avail (dbf); /* All work is done. */ return; } /* The following are all utility routines needed by the previous two. */ /* Gets the avail block at the top of the stack and loads it into the active avail block. It does a "free" for itself! */ static pop_avail_block (dbf) gdbm_file_info *dbf; { int num_bytes; /* For use with the read system call. */ long file_pos; /* For use with the lseek system call. */ avail_elem temp; /* Set up variables. */ temp.av_adr = dbf->header->avail.next_block; temp.av_size = ( ( (dbf->header->avail.size * sizeof (avail_elem)) >> 1) + sizeof (avail_block)); /* Read the block. */ file_pos = lseek (dbf->desc, temp.av_adr, L_SET); if (file_pos != temp.av_adr) _gdbm_fatal (dbf, "lseek error"); num_bytes = read (dbf->desc, &dbf->header->avail, temp.av_size); if (num_bytes != temp.av_size) _gdbm_fatal (dbf, "read error"); /* We changed the header. */ dbf->header_changed = TRUE; /* Free the previous avail block. */ _gdbm_put_av_elem (temp, dbf->header->avail.av_table, &dbf->header->avail.count); } /* Splits the header avail block and pushes half onto the avail stack. */ static push_avail_block (dbf) gdbm_file_info *dbf; { int num_bytes; int av_size; int av_adr; int index; long file_pos; avail_block *temp; avail_elem new_loc; /* Caclulate the size of the split block. */ av_size = ( (dbf->header->avail.size * sizeof (avail_elem)) >> 1) + sizeof (avail_block); /* Get address in file for new av_size bytes. */ new_loc = get_elem (av_size, dbf->header->avail.av_table, &dbf->header->avail.count); if (new_loc.av_size == 0) new_loc = get_block (av_size, dbf); av_adr = new_loc.av_adr; /* Split the header block. */ temp = (avail_block *) alloca (av_size); /* Set the size to be correct AFTER the pop_avail_block. */ temp->size = dbf->header->avail.size; temp->count = 0; temp->next_block = dbf->header->avail.next_block; dbf->header->avail.next_block = av_adr; for (index = 1; index < dbf->header->avail.count; index++) if ( (index & 0x1) == 1) /* Index is odd. */ temp->av_table[temp->count++] = dbf->header->avail.av_table[index]; else dbf->header->avail.av_table[index>>1] = dbf->header->avail.av_table[index]; /* Update the header avail count to previous size divided by 2. */ dbf->header->avail.count >>= 1; /* Free the unneeded space. */ new_loc.av_adr += av_size; new_loc.av_size -= av_size; _gdbm_free (dbf, new_loc.av_adr, new_loc.av_size); /* Update the disk. */ file_pos = lseek (dbf->desc, av_adr, L_SET); if (file_pos != av_adr) _gdbm_fatal (dbf, "lseek error"); num_bytes = write (dbf->desc, temp, av_size); if (num_bytes != av_size) _gdbm_fatal (dbf, "write error"); } /* Get_elem returns an element in the AV_TABLE block which is larger than SIZE. AV_COUNT is the number of elements in the AV_TABLE. If an item is found, it extracts it from the AV_TABLE and moves the other elements up to fill the space. If no block is found larger than SIZE, get_elem returns a size of zero. This routine does no I/O. */ static avail_elem get_elem (size, av_table, av_count) int size; avail_elem av_table[]; int *av_count; { int index; /* For searching through the avail block. */ avail_elem val; /* The default return value. */ /* Initialize default return value. */ val.av_adr = 0; val.av_size = 0; /* Search for element. List is sorted by size. */ index = 0; while (index < *av_count && av_table[index].av_size < size) { index++; } /* Did we find one of the right size? */ if (index >= *av_count) return val; /* Ok, save that element and move all others up one. */ val = av_table[index]; *av_count -= 1; while (index < *av_count) { av_table[index] = av_table[index+1]; index++; } return val; } /* This routine inserts a single NEW_EL into the AV_TABLE block in sorted order. This routine does no I/O. */ _gdbm_put_av_elem (new_el, av_table, av_count) avail_elem new_el; avail_elem av_table[]; int *av_count; { int index; /* For searching through the avail block. */ int index1; /* Is it too small to deal with? */ if (new_el.av_size <= IGNORE_SIZE) return FALSE; /* Search for place to put element. List is sorted by size. */ index = 0; while (index < *av_count && av_table[index].av_size < new_el.av_size) { index++; } /* Move all others up one. */ index1 = *av_count-1; while (index1 >= index) { av_table[index1+1] = av_table[index1]; index1--; } /* Add the new element. */ av_table[index] = new_el; /* Increment the number of elements. */ *av_count += 1; return TRUE; } /* Get_block "allocates" new file space and the end of the file. This is done in integral block sizes. (This helps insure that data smaller than one block size is in a single block.) Enough blocks are allocated to make sure the number of bytes allocated in the blocks is larger than SIZE. DBF contains the file header that needs updating. This routine does no I/O. */ static avail_elem get_block (size, dbf) int size; gdbm_file_info *dbf; { avail_elem val; /* Need at least one block. */ val.av_adr = dbf->header->next_block; val.av_size = dbf->header->block_size; /* Get enough blocks to fit the need. */ while (val.av_size < size) val.av_size += dbf->header->block_size; /* Update the header and return. */ dbf->header->next_block += val.av_size; /* We changed the header. */ dbf->header_changed = TRUE; return val; } /* When the header already needs writing, we can make sure the current bucket has its avail block as close to 1/2 full as possible. */ static adjust_bucket_avail (dbf) gdbm_file_info *dbf; { int third = BUCKET_AVAIL / 3; avail_elem av_el; /* Can we add more entries to the bucket? */ if (dbf->bucket->av_count < third) { if (dbf->header->avail.count > 0) { dbf->header->avail.count -= 1; av_el = dbf->header->avail.av_table[dbf->header->avail.count]; _gdbm_put_av_elem (av_el, dbf->bucket->bucket_avail, &dbf->bucket->av_count); dbf->bucket_changed = TRUE; } return; } /* Is there too much in the bucket? */ while (dbf->bucket->av_count > BUCKET_AVAIL-third && dbf->header->avail.count < dbf->header->avail.size) { av_el = get_elem (0, dbf->bucket->bucket_avail, &dbf->bucket->av_count); _gdbm_put_av_elem (av_el, dbf->header->avail.av_table, &dbf->header->avail.count); dbf->bucket_changed = TRUE; } } ./libc-linux/gdbm/findkey.c100644 1676 334 12737 4763323462 13665 0ustar hjlisl/* findkey.c - The routine that finds a key entry in the file. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" /* Read the data found in bucket entry ELEM_LOC in file DBF and return a pointer to it. Also, cache the read value. */ char * _gdbm_read_entry (dbf, elem_loc) gdbm_file_info *dbf; int elem_loc; { int num_bytes; /* For seeking and reading. */ int key_size; int data_size; long file_pos; data_cache_elem *data_ca; /* Is it already in the cache? */ if (dbf->cache_entry->ca_data.elem_loc == elem_loc) return dbf->cache_entry->ca_data.dptr; /* Set sizes and pointers. */ key_size = dbf->bucket->h_table[elem_loc].key_size; data_size = dbf->bucket->h_table[elem_loc].data_size; data_ca = &dbf->cache_entry->ca_data; /* Set up the cache. */ if (data_ca->dptr != NULL) free (data_ca->dptr); data_ca->key_size = key_size; data_ca->data_size = data_size; data_ca->elem_loc = elem_loc; data_ca->hash_val = dbf->bucket->h_table[elem_loc].hash_value; if (key_size+data_size == 0) data_ca->dptr = (char *) malloc (1); else data_ca->dptr = (char *) malloc (key_size+data_size); if (data_ca->dptr == NULL) _gdbm_fatal (dbf, "malloc error"); /* Read into the cache. */ file_pos = lseek (dbf->desc, dbf->bucket->h_table[elem_loc].data_pointer, L_SET); if (file_pos != dbf->bucket->h_table[elem_loc].data_pointer) _gdbm_fatal (dbf, "lseek error"); num_bytes = read (dbf->desc, data_ca->dptr, key_size+data_size); if (num_bytes != key_size+data_size) _gdbm_fatal (dbf, "read error"); return data_ca->dptr; } /* Find the KEY in the file and get ready to read the associated data. The return value is the location in the current hash bucket of the KEY's entry. If it is found, a pointer to the data and the key are returned in DPTR. If it is not found, the value -1 is returned. Since find key computes the hash value of key, that value */ int _gdbm_findkey (dbf, key, dptr, new_hash_val) gdbm_file_info *dbf; datum key; char **dptr; long *new_hash_val; /* The new hash value. */ { long bucket_hash_val; /* The hash value from the bucket. */ char *file_key; /* The complete key as stored in the file. */ int elem_loc; /* The location in the bucket. */ int home_loc; /* The home location in the bucket. */ int key_size; /* Size of the key on the file. */ /* Compute hash value and load proper bucket. */ *new_hash_val = _gdbm_hash (key); _gdbm_get_bucket (dbf, *new_hash_val>> (31-dbf->header->dir_bits)); /* Is the element the last one found for this bucket? */ if (*new_hash_val == dbf->cache_entry->ca_data.hash_val && dbf->cache_entry->ca_data.key_size == key.dsize && dbf->cache_entry->ca_data.dptr != NULL && bcmp (dbf->cache_entry->ca_data.dptr, key.dptr, key.dsize) == 0) { /* This is it. Return the cache pointer. */ *dptr = dbf->cache_entry->ca_data.dptr+key.dsize; return dbf->cache_entry->ca_data.elem_loc; } /* It is not the cached value, search for element in the bucket. */ elem_loc = *new_hash_val % dbf->header->bucket_elems; home_loc = elem_loc; bucket_hash_val = dbf->bucket->h_table[elem_loc].hash_value; while (bucket_hash_val != -1) { key_size = dbf->bucket->h_table[elem_loc].key_size; if (bucket_hash_val != *new_hash_val || key_size != key.dsize || bcmp (dbf->bucket->h_table[elem_loc].key_start, key.dptr, (SMALL < key_size ? SMALL : key_size)) != 0) { /* Current elem_loc is not the item, go to next item. */ elem_loc = (elem_loc + 1) % dbf->header->bucket_elems; if (elem_loc == home_loc) return -1; bucket_hash_val = dbf->bucket->h_table[elem_loc].hash_value; } else { /* This may be the one we want. The only way to tell is to read it. */ file_key = _gdbm_read_entry (dbf, elem_loc); if (bcmp (file_key, key.dptr, key_size) == 0) { /* This is the item. */ *dptr = file_key+key.dsize; dbf->cache_entry->ca_data.hash_val = *new_hash_val; return elem_loc; } else { /* Not the item, try the next one. Return if not found. */ elem_loc = (elem_loc + 1) % dbf->header->bucket_elems; if (elem_loc == home_loc) return -1; bucket_hash_val = dbf->bucket->h_table[elem_loc].hash_value; } } } /* If we get here, we never found the key. */ return -1; } ./libc-linux/gdbm/version.c100644 1676 334 2533 4763324245 13672 0ustar hjlisl/* version.c - This is file contains the version number for gdbm source. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ /* Keep a string with the version number in it! */ char * gdbm_version = "This is GDBM version 1.5, as of February 28, 1991."; ./libc-linux/gdbm/hash.c100644 1676 334 3624 4763323470 13131 0ustar hjlisl/* hash.c - The gdbm hash function. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" /* This hash function computes a 31 bit value. The value is used to index the hash directory using the top n bits. It is also used in a hash bucket to find the home position of the element by taking the value modulo the bucket hash table size. */ long _gdbm_hash (key) datum key; { long value; /* Used to compute the hash value. */ int index; /* Used to cycle through random values. */ /* Set the initial value from key. */ value = 0x238F13AF * key.dsize; for (index = 0; index < key.dsize; index++) value = (value + (key.dptr[index] << (index*5 % 24))) & 0x7FFFFFFF; value = (1103515243 * value + 12345) & 0x7FFFFFFF; /* Return the value. */ return value; } ./libc-linux/gdbm/update.c100644 1676 334 6505 4763323475 13476 0ustar hjlisl/* update.c - The routines for updating the file to a consistent state. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" /* This procedure writes the header back to the file described by DBF. */ static write_header (dbf) gdbm_file_info *dbf; { int num_bytes; /* Return value for write. */ long file_pos; /* Return value for lseek. */ file_pos = lseek (dbf->desc, 0, L_SET); if (file_pos != 0) _gdbm_fatal (dbf, "lseek error"); num_bytes = write (dbf->desc, dbf->header, dbf->header->block_size); if (num_bytes != dbf->header->block_size) _gdbm_fatal (dbf, "write error"); /* Wait for all output to be done. */ fsync (dbf->desc); } /* After all changes have been made in memory, we now write them all to disk. */ _gdbm_end_update (dbf) gdbm_file_info *dbf; { int num_bytes; /* Return value for write. */ long file_pos; /* Return value for lseek. */ /* Write the current bucket. */ if (dbf->bucket_changed) { _gdbm_write_bucket (dbf, dbf->cache_entry); dbf->bucket_changed = FALSE; } /* Write the other changed buckets if there are any. */ if (dbf->second_changed) { int index; for (index = 0; index < CACHE_SIZE; index++) if (dbf->bucket_cache[index].ca_changed) { _gdbm_write_bucket (dbf, &dbf->bucket_cache[index]); } dbf->second_changed = FALSE; } /* Write the directory. */ if (dbf->directory_changed) { file_pos = lseek (dbf->desc, dbf->header->dir, L_SET); if (file_pos != dbf->header->dir) _gdbm_fatal (dbf, "lseek error"); num_bytes = write (dbf->desc, dbf->dir, dbf->header->dir_size); if (num_bytes != dbf->header->dir_size) _gdbm_fatal (dbf, "write error"); dbf->directory_changed = FALSE; if (!dbf->header_changed) fsync (dbf->desc); } /* Final write of the header. */ if (dbf->header_changed) { write_header (dbf); dbf->header_changed = FALSE; } } /* If a fatal error is detected, come here and exit. VAL tells which fatal error occured. */ _gdbm_fatal (dbf, val) gdbm_file_info *dbf; char *val; { if (dbf->fatal_err != NULL) (*dbf->fatal_err) (val); else fprintf (stderr, "gdbm fatal: %s.\n", val); exit (-1); } ./libc-linux/gdbm/gdbmdefs.h100644 1676 334 16450 5210300657 13775 0ustar hjlisl/* gdbmdefs.h - The include file for dbm. Defines structure and constants. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ /* Include the standard include files needed for gdbm. */ #include #include #include #include #include "gdbmconst.h" #include "systems.h" /* The type definitions are next. */ /* The data and key structure. This structure is defined for compatibility. */ typedef struct { char *dptr; int dsize; } datum; /* The available file space is stored in an "avail" table. The one with most activity is contained in the file header. (See below.) When that one filles up, it is split in half and half is pushed on an "avail stack." When the active avail table is empty and the "avail stack" is not empty, the top of the stack is popped into the active avail table. */ /* The following structure is the element of the avaliable table. */ typedef struct { int av_size; /* The size of the available block. */ long av_adr; /* The file address of the available block. */ } avail_elem; /* This is the actual table. The in-memory images of the avail blocks are allocated by malloc using a calculated size. */ typedef struct { int size; /* The number of avail elements in the table.*/ int count; /* The number of entries in the table. */ long next_block; /* The file address of the next avail block. */ avail_elem av_table[1]; /* The table. Make it look like an array. */ } avail_block; /* The dbm file header keeps track of the current location of the hash directory and the free space in the file. */ typedef struct { long header_magic; /* 0x13579ace to make sure the header is good. */ int block_size; /* The optimal i/o blocksize from stat. */ long dir; /* File address of hash directory table. */ int dir_size; /* Size in bytes of the table. */ int dir_bits; /* The number of address bits used in the table.*/ int bucket_size; /* Size in bytes of a hash bucket struct. */ int bucket_elems; /* Number of elements in a hash bucket. */ long next_block; /* The next unallocated block address. */ avail_block avail; /* This must be last because of the psuedo array in avail. This avail grows to fill the entire block. */ } gdbm_file_header; /* The dbm hash bucket element contains the full 31 bit hash value, the "pointer" to the key and data (stored together) with their sizes. It also has a small part of the actual key value. It is used to verify the first part of the key has the correct value without having to read the actual key. */ typedef struct { long hash_value; /* The complete 31 bit value. */ char key_start[SMALL]; /* Up to the first SMALL bytes of the key. */ long data_pointer; /* The file address of the key record. The data record directly follows the key. */ int key_size; /* Size of key data in the file. */ int data_size; /* Size of associated data in the file. */ } bucket_element; /* A bucket is a small hash table. This one consists of a number of bucket elements plus some bookkeeping fields. The number of elements depends on the optimum blocksize for the storage device and on a parameter given at file creation time. This bucket takes one block. When one of these tables gets full, it is split into two hash buckets. The contents are split between them by the use of the first few bits of the 31 bit hash function. The location in a bucket is the hash value modulo the size of the bucket. The in-memory images of the buckets are allocated by malloc using a calculated size depending of the file system buffer size. To speed up write, each bucket will have BUCKET_AVAIL avail elements with the bucket. */ typedef struct { int av_count; /* The number of bucket_avail entries. */ avail_elem bucket_avail[BUCKET_AVAIL]; /* Distributed avail. */ int bucket_bits; /* The number of bits used to get here. */ int count; /* The number of element buckets full. */ bucket_element h_table[1]; /* The table. Make it look like an array.*/ } hash_bucket; /* We want to keep from reading buckets as much as possible. The following is to implement a bucket cache. When full, buckets will be dropped in a least recently read from disk order. */ /* To speed up fetching and "sequential" access, we need to implement a data cache for key/data pairs read from the file. To find a key, we must exactly match the key from the file. To reduce overhead, the data will be read at the same time. Both key and data will be stored in a data cache. Each bucket cached will have a one element data cache. */ typedef struct { long hash_val; int data_size; int key_size; char *dptr; int elem_loc; } data_cache_elem; typedef struct { hash_bucket * ca_bucket; long ca_adr; char ca_changed; /* Data in the bucket changed. */ data_cache_elem ca_data; } cache_elem; /* This final structure contains all main memory based information for a gdbm file. This allows multiple gdbm files to be opened at the same time by one program. */ typedef struct { /* Global variables and pointers to dynamic variables used by gdbm. */ /* The file name. */ char *name; /* The reader/writer status. */ int read_write; /* The fatal error handling routine. */ void (*fatal_err) (); /* The gdbm file descriptor which is set in gdbm_open. */ int desc; /* The file header holds information about the database. */ gdbm_file_header *header; /* The hash table directory from extendible hashing. See Fagin et al, ACM Trans on Database Systems, Vol 4, No 3. Sept 1979, 315-344 */ long *dir; /* The bucket cache. */ cache_elem bucket_cache [CACHE_SIZE]; int last_read; /* Points to the current hash bucket in the cache. */ hash_bucket *bucket; /* The directory entry used to get the current hash bucket. */ long bucket_dir; /* Pointer to the current bucket's cache entry. */ cache_elem *cache_entry; /* Bookkeeping of things that need to be written back at the end of an update. */ char header_changed; char directory_changed; char bucket_changed; char second_changed; } gdbm_file_info; ./libc-linux/gdbm/extern.h100644 1676 334 3234 4763323460 13514 0ustar hjlisl/* extern.h - The collection of external definitions needed. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ /* The global variables used for the "original" interface. */ extern gdbm_file_info *_gdbm_file; /* Memory for return data for the "original" interface. */ extern datum _gdbm_memory; extern char *_gdbm_fetch_val; /* External routines used. */ extern gdbm_file_info *gdbm_open (); extern datum gdbm_fetch (); extern datum gdbm_firstkey (); extern datum gdbm_nextkey (); extern int gdbm_delete (); extern int gdbm_store (); extern void gdbm_close (); ./libc-linux/gdbm/gdbmerrno.h100644 1676 334 3443 5203405064 14157 0ustar hjlisl/* gdbmerrno.h - The enumeration type describing all the dbm errors. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #if 1 /* gdbm sends back the following error codes in the variable gdbm_errno. */ typedef enum { GDBM_NO_ERROR, GDBM_MALLOC_ERROR, GDBM_BLOCK_SIZE_ERROR, GDBM_FILE_OPEN_ERROR, GDBM_FILE_WRITE_ERROR, GDBM_FILE_SEEK_ERROR, GDBM_FILE_READ_ERROR, GDBM_BAD_MAGIC_NUMBER, GDBM_EMPTY_DATABASE, GDBM_CANT_BE_READER, GDBM_CANT_BE_WRITER, GDBM_READER_CANT_DELETE, GDBM_READER_CANT_STORE, GDBM_READER_CANT_REORGANIZE, GDBM_UNKNOWN_UPDATE, GDBM_ITEM_NOT_FOUND, GDBM_REORGANIZE_FAILED, GDBM_CANNOT_REPLACE, GDBM_ILLEGAL_DATA} gdbm_error; #endif /* _GDBM_H */ ./libc-linux/gdbm/systems.h100644 1676 334 13236 5431026554 13736 0ustar hjlisl/* systems.h - Most of the system dependant code and defines are here. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ /* System V changes and defines. */ /**************************************************/ #ifdef linux /* !!NOTE: linux doesn't do file locking, so we fake the retval! */ #include #include /* Some files need fcntl.h for locking. */ #include #define UNLOCK_FILE(dbf) \ { \ struct flock flock; \ flock.l_type = F_UNLCK; \ flock.l_whence = 0; \ flock.l_start = flock.l_len = 0L; \ fcntl (dbf->desc, F_SETLK, &flock); \ } #ifdef NO_FILELOCK #define READLOCK_FILE(dbf) \ { \ struct flock flock; \ flock.l_type = F_RDLCK; \ flock.l_whence = 0; \ flock.l_start = flock.l_len = 0L; \ lock_val = fcntl (dbf->desc, F_SETLK, &flock); \ lock_val = 0; \ } #else #define READLOCK_FILE(dbf) \ { \ struct flock flock; \ flock.l_type = F_RDLCK; \ flock.l_whence = 0; \ flock.l_start = flock.l_len = 0L; \ lock_val = fcntl (dbf->desc, F_SETLK, &flock); \ } #endif #ifdef NO_FILELOCK #define WRITELOCK_FILE(dbf) \ { \ struct flock flock; \ flock.l_type = F_WRLCK; \ flock.l_whence = 0; \ flock.l_start = flock.l_len = 0L; \ lock_val = fcntl (dbf->desc, F_SETLK, &flock); \ lock_val = 0; \ } #else #define WRITELOCK_FILE(dbf) \ { \ struct flock flock; \ flock.l_type = F_WRLCK; \ flock.l_whence = 0; \ flock.l_start = flock.l_len = 0L; \ lock_val = fcntl (dbf->desc, F_SETLK, &flock); \ } #endif #if 0 #include #define STATBLKSIZE BLOCK_SIZE #include #define _HAVE_STRING #define bcmp(d1, d2, n) memcmp(d1, d2, n) #define bcopy(d1, d2, n) memcpy(d2, d1, n) #endif #if 0 /* linux does not have fsync. */ #define fsync(f) sync(); sync() #endif #undef SYSV #endif /* linux */ #ifdef SYSV /* File seeking needs L_SET defined .*/ #include #define L_SET SEEK_SET /* Some files need fcntl.h for locking. */ #include #define UNLOCK_FILE(dbf) \ { \ struct flock flock; \ flock.l_type = F_UNLCK; \ flock.l_whence = 0; \ flock.l_start = flock.l_len = 0L; \ fcntl (dbf->desc, F_SETLK, &flock); \ } #define READLOCK_FILE(dbf) \ { \ struct flock flock; \ flock.l_type = F_RDLCK; \ flock.l_whence = 0; \ flock.l_start = flock.l_len = 0L; \ lock_val = fcntl (dbf->desc, F_SETLK, &flock); \ } #define WRITELOCK_FILE(dbf) \ { \ struct flock flock; \ flock.l_type = F_WRLCK; \ flock.l_whence = 0; \ flock.l_start = flock.l_len = 0L; \ lock_val = fcntl (dbf->desc, F_SETLK, &flock); \ } /* Send bcmp to the right place. */ #include #define bcmp(d1, d2, n) memcmp(d1, d2, n) #define bcopy(d1, d2, n) memcpy(d2, d1, n) /* Sys V does not have fsync. */ #define fsync(f) sync(); sync() /* Stat does not have a st_blksize field. */ #define STATBLKSIZE 512 /* Does not have rename(). */ #define NEED_RENAME /* Get string definitions. */ #include #define _HAVE_STRING #endif /* Sys V does not have a truncate call, how primitive. */ #define TRUNCATE(dbf) close( open (dbf->name, O_RDWR|O_TRUNC, mode)); /* End of System V changes and defines. */ /**************************************************/ /* Alloca is builtin in gcc. Use the builtin alloca if compiled with gcc. */ #ifdef __GNUC__ #define BUILTIN_ALLOCA #endif /* Also, if this is a sun spark, use the builtin alloca. */ #ifdef sun #ifdef sparc #define BUILTIN_ALLOCA #endif #endif #ifndef linux /* Define the proper alloca procedure. */ #ifdef BUILTIN_ALLOCA #define alloca(x) __builtin_alloca(x) #else extern char *alloca(); #endif #endif #ifndef linux /* Malloc definition. */ extern char *malloc(); #endif /* String definitions. */ #ifndef _HAVE_STRING #include #endif /* The BSD defines are the default defines. If something is not defined above in the above conditional code, it will be set in the following code to the BSD code. */ /* Default block size. Some systems do not have blocksize in their stat record. This code uses the BSD blocksize from stat. */ #ifndef STATBLKSIZE #define STATBLKSIZE file_stat.st_blksize #endif /* Locking is done differently on different systems. Here is the BSD locking routines. */ #ifndef UNLOCK_FILE #define UNLOCK_FILE(dbf) flock (dbf->desc, LOCK_UN) #define READLOCK_FILE(dbf) lock_val = flock (dbf->desc, LOCK_SH + LOCK_NB) #define WRITELOCK_FILE(dbf) lock_val = flock (dbf->desc, LOCK_EX + LOCK_NB) #endif #ifndef TRUNCATE #define TRUNCATE(dbf) ftruncate (dbf->desc, 0) #endif ./libc-linux/gdbm/dbm.h100644 1676 334 3703 5203403061 12734 0ustar hjlisl/* dbm.h - The include file for dbm users. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #ifndef _DBM_H #define _DBM_H /* The data and key structure. This structure is defined for compatibility. */ typedef struct { char *dptr; int dsize; } datum; /* These are the routines in dbm. */ #ifdef __STDC__ #ifdef __cplusplus extern "C" { #endif extern int dbminit(const char *file); extern int store(datum key, datum content); extern int delete(datum key); extern datum fetch(datum); extern datum firstkey(void); extern datum nextkey(datum); #ifdef __cplusplus } #endif #else /* not __STDC__ */ extern int dbminit (); extern int store (); extern int delete (); extern datum fetch(); extern datum firstkey(); extern datum nextkey(); #endif /* To make some versions work we need the following define. */ #define dbmclose() #endif /* _DBM_H */ ./libc-linux/gdbm/ndbm.h100644 1676 334 4636 5203404240 13120 0ustar hjlisl/* ndbm.h - The include file for ndbm users. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #ifndef _NDBM_H /* allow multiple inclusions */ #define _NDBM_H /* Parameters to dbm_store for simple insertion or replacement. */ #define DBM_INSERT 0 #define DBM_REPLACE 1 /* The data and key structure. This structure is defined for compatibility. */ typedef struct { char *dptr; int dsize; } datum; /* The file information header. This is good enough for most applications. */ typedef struct {int dummy[10];} DBM; /* These are the routines (with some macros defining them!) */ #ifdef __STDC__ #ifdef __cplusplus extern "C" { #endif extern DBM *dbm_open(const char *, int, int); extern void dbm_close(DBM *); extern datum dbm_fetch(DBM *, datum); extern datum dbm_firstkey(DBM *); extern datum dbm_nextkey(DBM *); extern int dbm_delete(DBM *, datum); extern int dbm_store(DBM *, datum, datum, int); extern int dbm_dirfno (DBM *); extern int dbm_pagfno (DBM *); #ifdef __cplusplus } #endif #else extern DBM *dbm_open(); extern void dbm_close(); extern datum dbm_fetch(); extern datum dbm_firstkey(); extern datum dbm_nextkey(); extern int dbm_delete(); extern int dbm_store(); extern int dbm_dirfno (); extern int dbm_pagfno (); #endif #define dbm_error(dbf) 0 #define dbm_clearerr(dbf) #endif /* _NDBM_H */ ./libc-linux/gdbm/gdbmconst.h100644 1676 334 4255 4763323463 14176 0ustar hjlisl/* gdbmconst.h - The constants defined for use in gdbm. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ /* Start with the constant definitions. */ #define TRUE 1 #define FALSE 0 /* Parameters to gdbm_open. */ #define GDBM_READER 0 /* READERS only. */ #define GDBM_WRITER 1 /* READERS and WRITERS. Can not create. */ #define GDBM_WRCREAT 2 /* If not found, create the db. */ #define GDBM_NEWDB 3 /* ALWAYS create a new db. (WRITER) */ /* Parameters to gdbm_store for simple insertion or replacement in the case a key to store is already in the database. */ #define GDBM_INSERT 0 /* Do not overwrite data in the database. */ #define GDBM_REPLACE 1 /* Replace the old value with the new value. */ /* In freeing blocks, we will ignore any blocks smaller (and equal) to IGNORE_SIZE number of bytes. */ #define IGNORE_SIZE 4 /* The number of key bytes kept in a hash bucket. */ #define SMALL 4 /* The number of bucket_avail entries in a hash bucket. */ #define BUCKET_AVAIL 6 /* The size of the bucket cache. */ #ifndef CACHE_SIZE #define CACHE_SIZE 100 #endif ./libc-linux/gdbm/testdbm.c100644 1676 334 11347 4763323473 13674 0ustar hjlisl/* testdbm.c - Driver program to test the dbm interface routines. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include #include #include #include #define TRUE 1 #define FALSE 0 typedef struct { char *dptr; int dsize; } datum; extern datum fetch (); extern datum firstkey (); extern datum nextkey (); /* The test program allows one to call all the routines plus the hash function. The commands are single letter commands. The user is prompted for all other information. The commands are q (quit), f (fetch), s (store), d (delete), 1 (firstkey), n (nextkey) and h (hash function). */ main (argc, argv) int argc; char *argv[]; { char cmd_ch; datum key_data; datum data_data; datum return_data; char key_line[500]; char data_line[1000]; char done = FALSE; char sys[255]; char *file_name; /* Argument checking. */ if (argc > 2) { printf ("Usage: %s [dbm-file] \n",argv[0]); exit (2); } if (argc > 1) { file_name = argv[1]; } else { file_name = "junkdbm"; } /* Initialize */ data_data.dptr = data_line; if (dbminit (file_name) != 0) { sprintf (sys,"touch %s.pag %s.dir", file_name, file_name); system (sys); if (dbminit (file_name) != 0) { printf ("dbminit failed.\n"); exit (2); } } /* Welcome message. */ printf ("\nWelcome to the dbm test program. Type ? for help.\n\n"); while (!done) { printf ("com -> "); cmd_ch = getchar (); while (getchar () != '\n') /* Do nothing. */; switch (cmd_ch) { case 'q': done = TRUE; break; case 'f': printf ("key -> "); gets (key_line); key_data.dptr = key_line; key_data.dsize = strlen (key_line)+1; return_data = fetch (key_data); if (return_data.dptr != NULL) printf ("data is ->%s\n\n", return_data.dptr); else printf ("No such item found.\n\n"); break; case 's': printf ("key -> "); gets (key_line); key_data.dptr = key_line; key_data.dsize = strlen (key_line)+1; printf ("data -> "); gets (data_line); data_data.dsize = strlen (data_line)+1; if (store (key_data, data_data) != 0) printf ("Item not inserted. \n"); printf ("\n"); break; case 'd': printf ("key -> "); gets (key_line); key_data.dptr = key_line; key_data.dsize = strlen (key_line)+1; if (delete (key_data) != 0) printf ("Item not found or deleted\n"); printf ("\n"); break; case '1': key_data = firstkey (); if (key_data.dptr != NULL) { return_data = fetch (key_data); printf ("key is ->%s\n", key_data.dptr); printf ("data is ->%s\n\n", return_data.dptr); } else printf ("No such item found.\n\n"); break; case '2': key_data = nextkey (key_data); if (key_data.dptr != NULL) { return_data = fetch (key_data); printf ("key is ->%s\n", key_data.dptr); printf ("data is ->%s\n\n", return_data.dptr); } else printf ("No such item found.\n\n"); break; case 'c': { int temp; temp = 0; return_data = firstkey (); while (return_data.dptr != NULL) { temp++; return_data = nextkey (return_data); } printf ("There are %d items in the database.\n\n", temp); } break; case '?': printf ("c - count elements\n"); printf ("d - delete\n"); printf ("f - fetch\n"); printf ("q - quit\n"); printf ("s - store\n"); printf ("1 - firstkey\n"); printf ("2 - nextkey on last return value\n\n"); break; default: printf ("What? \n\n"); break; } } /* Quit normally. */ exit (0); } ./libc-linux/gdbm/testndbm.c100644 1676 334 11416 4763323474 14050 0ustar hjlisl/* testndbm.c - Driver program to test the ndbm interface routines. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include #include #include #include #ifdef SYSV #include #endif #ifdef GNU #include "ndbm.h" #else #include #endif #define TRUE 1 #define FALSE 0 /* The test program allows one to call all the routines plus the hash function. The commands are single letter commands. The user is prompted for all other information. The commands are q (quit), f (fetch), s (store), d (delete), 1 (firstkey), n (nextkey) and h (hash function). */ main (argc, argv) int argc; char *argv[]; { char cmd_ch; datum key_data; datum data_data; datum return_data; char key_line[500]; char data_line[1000]; DBM *dbm_file; char done = FALSE; char *file_name; /* Argument checking. */ if (argc > 2) { printf ("Usage: %s [dbm-file] \n",argv[0]); exit (2); } if (argc > 1) { file_name = argv[1]; } else { file_name = "junkndbm"; } /* Initialize. */ data_data.dptr = data_line; dbm_file = dbm_open (file_name, O_RDWR|O_CREAT, 00664); if (dbm_file == NULL) { printf ("dbm_open failed.\n"); exit (2); } /* Welcome message. */ printf ("\nWelcome to the gndbm test program. Type ? for help.\n\n"); while (!done) { printf ("com -> "); cmd_ch = getchar (); while (getchar () != '\n') /* Do nothing. */; switch (cmd_ch) { case 'q': done = TRUE; break; case 'f': printf ("key -> "); gets (key_line); key_data.dptr = key_line; key_data.dsize = strlen (key_line)+1; return_data = dbm_fetch (dbm_file, key_data); if (return_data.dptr != NULL) printf ("data is ->%s\n\n", return_data.dptr); else printf ("No such item found.\n\n"); break; case 's': printf ("key -> "); gets (key_line); key_data.dptr = key_line; key_data.dsize = strlen (key_line)+1; printf ("data -> "); gets (data_line); data_data.dsize = strlen (data_line)+1; if (dbm_store (dbm_file, key_data, data_data, DBM_REPLACE) != 0) printf ("Item not inserted. \n"); printf ("\n"); break; case 'd': printf ("key -> "); gets (key_line); key_data.dptr = key_line; key_data.dsize = strlen (key_line)+1; if (dbm_delete (dbm_file, key_data) != 0) printf ("Item not found or deleted\n"); printf ("\n"); break; case '1': key_data = dbm_firstkey (dbm_file); if (key_data.dptr != NULL) { return_data = dbm_fetch (dbm_file, key_data); printf ("key is ->%s\n", key_data.dptr); printf ("data is ->%s\n\n", return_data.dptr); } else printf ("No such item found.\n\n"); break; case '2': key_data = dbm_nextkey (dbm_file); if (key_data.dptr != NULL) { return_data = dbm_fetch (dbm_file, key_data); printf ("key is ->%s\n", key_data.dptr); printf ("data is ->%s\n\n", return_data.dptr); } else printf ("No such item found.\n\n"); break; case 'c': { int temp; temp = 0; return_data = dbm_firstkey (dbm_file); while (return_data.dptr != NULL) { temp++; return_data = dbm_nextkey (dbm_file); } printf ("There are %d items in the database.\n\n", temp); } break; case '?': printf ("c - count elements\n"); printf ("d - delete\n"); printf ("f - fetch\n"); printf ("q - quit\n"); printf ("s - store\n"); printf ("1 - firstkey\n"); printf ("2 - nextkey on last return value\n\n"); break; default: printf ("What? \n\n"); break; } } /* Quit normally. */ dbm_close (dbm_file); exit (0); } ./libc-linux/gdbm/testgdbm.c100644 1676 334 30525 4763323474 14043 0ustar hjlisl/* testgdbm.c - Driver program to test the database routines and to help debug gdbm. Uses inside information to show "system" information */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "gdbmerrno.h" #include "extern.h" extern gdbm_error gdbm_errno; extern char * gdbm_version; /* For getopt. */ extern char *optarg; extern int optind, opterr; gdbm_file_info *gdbm_file; /* Debug procedure to print the contents of the current hash bucket. */ print_bucket (bucket, mesg) hash_bucket *bucket; char *mesg; { int index; printf ("******* %s **********\n\nbits = %d\ncount= %d\nHash Table:\n", mesg, bucket->bucket_bits, bucket->count); printf (" # hash value key size data size data adr home\n"); for (index = 0; index < gdbm_file->header->bucket_elems; index++) printf (" %4d %12x %11d %11d %11d %5d\n", index, bucket->h_table[index].hash_value, bucket->h_table[index].key_size, bucket->h_table[index].data_size, bucket->h_table[index].data_pointer, bucket->h_table[index].hash_value % gdbm_file->header->bucket_elems); printf ("\nAvail count = %1d\n", bucket->av_count); printf ("Avail adr size\n"); for (index = 0; index < bucket->av_count; index++) printf ("%9d%9d\n", bucket->bucket_avail[index].av_adr, bucket->bucket_avail[index].av_size); } _gdbm_print_avail_list (dbf) gdbm_file_info *dbf; { int temp; int size; avail_block *av_stk; /* Print the the header avail block. */ printf ("\nheader block\nsize = %d\ncount = %d\n", dbf->header->avail.size, dbf->header->avail.count); for (temp = 0; temp < dbf->header->avail.count; temp++) { printf (" %15d %10d \n", dbf->header->avail.av_table[temp].av_size, dbf->header->avail.av_table[temp].av_adr); } /* Initialize the variables for a pass throught the avail stack. */ temp = dbf->header->avail.next_block; size = ( ( (dbf->header->avail.size * sizeof (avail_elem)) >> 1) + sizeof (avail_block)); av_stk = (avail_block *) alloca (size); /* Print the stack. */ while (FALSE) { lseek (dbf->desc, temp, L_SET); read (dbf->desc, av_stk, size); /* Print the block! */ printf ("\nblock = %d\nsize = %d\ncount = %d\n", temp, av_stk->size, av_stk->count); for (temp = 0; temp < av_stk->count; temp++) { printf (" %15d %10d \n", av_stk->av_table[temp].av_size, av_stk->av_table[temp].av_adr); } temp = av_stk->next_block; } } _gdbm_print_bucket_cache (dbf) gdbm_file_info *dbf; { int index; char changed; printf ("Bucket Cache:\n Index: Address Changed Data_Hash \n"); for (index=0; index < CACHE_SIZE; index++) { changed = dbf->bucket_cache[index].ca_changed; printf (" %5d: %7d %7s %x\n", index, dbf->bucket_cache[index].ca_adr, (changed ? "True" : "False"), dbf->bucket_cache[index].ca_data.hash_val); } } void usage (s) char *s; { printf ("Usage: %s [-r or -n] [gdbm-file] \n",s); exit (2); } /* The test program allows one to call all the routines plus the hash function. The commands are single letter commands. The user is prompted for all other information. See the help command (?) for a list of all commands. */ main (argc, argv) int argc; char *argv[]; { char cmd_ch; datum key_data; datum data_data; datum return_data; char key_line[500]; char data_line[1000]; char done = FALSE; char opt; char reader = FALSE; char newdb = FALSE; char *file_name; /* Argument checking. */ while ((opt = getopt (argc, argv, "rn")) != -1) switch (opt) { case 'r': reader = TRUE; if (newdb) usage (argv[0]); break; case 'n': newdb = TRUE; if (reader) usage (argv[0]); break; } if (argc > optind+1) usage (argv[0]); if (optind < argc) { file_name = argv[optind]; } else { file_name = "junk.gdbm"; } /* Initialize variables. */ key_data.dptr = NULL; data_data.dptr = data_line; if (reader) gdbm_file = gdbm_open (file_name, 512, GDBM_READER, 00664, NULL); else if (newdb) gdbm_file = gdbm_open (file_name, 512, GDBM_NEWDB, 00664, NULL); else gdbm_file = gdbm_open (file_name, 512, GDBM_WRCREAT, 00664, NULL); if (gdbm_file == NULL) { if (gdbm_errno != GDBM_CANT_BE_WRITER) printf ("gdbm_open failed.\n"); else printf ("Can't open as a writer. \n"); exit (2); } /* Welcome message. */ printf ("\nWelcome to the gdbm test program. Type ? for help.\n\n"); while (!done) { printf ("com -> "); cmd_ch = getchar (); if (cmd_ch != '\n') { char temp; do temp = getchar (); while (temp != '\n' && temp != EOF); } if (cmd_ch == EOF) cmd_ch = 'q'; switch (cmd_ch) { /* Standard cases found in all test{dbm,ndbm,gdbm} programs. */ case '\n': printf ("\n"); break; case 'c': { int temp; temp = 0; if (key_data.dptr != NULL) free (key_data.dptr); return_data = gdbm_firstkey (gdbm_file); while (return_data.dptr != NULL) { temp++; key_data = return_data; return_data = gdbm_nextkey (gdbm_file, key_data); free (key_data.dptr); } printf ("There are %d items in the database.\n\n", temp); key_data.dptr = NULL; } break; case 'd': if (key_data.dptr != NULL) free (key_data.dptr); printf ("key -> "); gets (key_line); key_data.dptr = key_line; key_data.dsize = strlen (key_line)+1; if (gdbm_delete (gdbm_file, key_data) != 0) printf ("Item not found or deleted\n"); printf ("\n"); key_data.dptr = NULL; break; case 'f': if (key_data.dptr != NULL) free (key_data.dptr); printf ("key -> "); gets (key_line); key_data.dptr = key_line; key_data.dsize = strlen (key_line)+1; return_data = gdbm_fetch (gdbm_file, key_data); if (return_data.dptr != NULL) { printf ("data is ->%s\n\n", return_data.dptr); free (return_data.dptr); } else printf ("No such item found.\n\n"); key_data.dptr = NULL; break; case 'n': if (key_data.dptr != NULL) free (key_data.dptr); printf ("key -> "); gets (key_line); key_data.dptr = key_line; key_data.dsize = strlen (key_line)+1; return_data = gdbm_nextkey (gdbm_file, key_data); if (return_data.dptr != NULL) { key_data = return_data; printf ("key is ->%s\n", key_data.dptr); return_data = gdbm_fetch (gdbm_file, key_data); printf ("data is ->%s\n\n", return_data.dptr); free (return_data.dptr); } else { printf ("No such item found.\n\n"); key_data.dptr = NULL; } break; case 'q': done = TRUE; break; case 's': if (key_data.dptr != NULL) free (key_data.dptr); printf ("key -> "); gets (key_line); key_data.dptr = key_line; key_data.dsize = strlen (key_line)+1; printf ("data -> "); gets (data_line); data_data.dsize = strlen (data_line)+1; if (gdbm_store (gdbm_file, key_data, data_data, GDBM_REPLACE) != 0) printf ("Item not inserted. \n"); printf ("\n"); key_data.dptr = NULL; break; case '1': if (key_data.dptr != NULL) free (key_data.dptr); key_data = gdbm_firstkey (gdbm_file); if (key_data.dptr != NULL) { printf ("key is ->%s\n", key_data.dptr); return_data = gdbm_fetch (gdbm_file, key_data); printf ("data is ->%s\n\n", return_data.dptr); free (return_data.dptr); } else printf ("No such item found.\n\n"); break; case '2': return_data = gdbm_nextkey (gdbm_file, key_data); if (return_data.dptr != NULL) { free (key_data.dptr); key_data = return_data; printf ("key is ->%s\n", key_data.dptr); return_data = gdbm_fetch (gdbm_file, key_data); printf ("data is ->%s\n\n", return_data.dptr); free (return_data.dptr); } else printf ("No such item found.\n\n"); break; /* Special cases for the testgdbm program. */ case 'r': { if (gdbm_reorganize (gdbm_file)) printf ("Reorganization failed. \n\n"); else printf ("Reorganization succeeded. \n\n"); } break; case 'A': _gdbm_print_avail_list (gdbm_file); printf ("\n"); break; case 'B': { int temp; char number[80]; printf ("bucket? "); gets (number); sscanf (number,"%d",&temp); if (temp >= gdbm_file->header->dir_size /4) { printf ("Not a bucket. \n\n"); break; } _gdbm_get_bucket (gdbm_file, temp); } printf ("Your bucket is now "); case 'C': print_bucket (gdbm_file->bucket, "Current bucket"); printf ("\n current directory entry = %d.\n", gdbm_file->bucket_dir); printf (" current bucket address = %d.\n\n", gdbm_file->cache_entry->ca_adr); break; case 'D': printf ("Hash table directory.\n"); printf (" Size = %d. Bits = %d. \n\n",gdbm_file->header->dir_size, gdbm_file->header->dir_bits); { int temp; for (temp = 0; temp < gdbm_file->header->dir_size / 4; temp++) { printf (" %10d: %12d\n", temp, gdbm_file->dir[temp]); if ( (temp+1) % 20 == 0 && isatty (0)) { printf ("*** CR to continue: "); while (getchar () != '\n') /* Do nothing. */; } } } printf ("\n"); break; case 'F': { printf ("\nFile Header: \n\n"); printf (" table = %d\n", gdbm_file->header->dir); printf (" table size = %d\n", gdbm_file->header->dir_size); printf (" table bits = %d\n", gdbm_file->header->dir_bits); printf (" block size = %d\n", gdbm_file->header->block_size); printf (" bucket elems = %d\n", gdbm_file->header->bucket_elems); printf (" bucket size = %d\n", gdbm_file->header->bucket_size); printf (" header magic = %x\n", gdbm_file->header->header_magic); printf (" next block = %d\n", gdbm_file->header->next_block); printf (" avail size = %d\n", gdbm_file->header->avail.size); printf (" avail count = %d\n", gdbm_file->header->avail.count); printf (" avail nx blk = %d\n", gdbm_file->header->avail.next_block); printf ("\n"); } break; case 'H': if (key_data.dptr != NULL) free (key_data.dptr); printf ("key -> "); gets (key_line); key_data.dptr = key_line; key_data.dsize = strlen (key_line)+1; printf ("hash value = %x. \n\n", _gdbm_hash (key_data)); key_data.dptr = NULL; break; case 'K': _gdbm_print_bucket_cache (gdbm_file); break; case 'V': printf ("%s\n\n", gdbm_version); break; case '?': printf ("c - count (number of entries)\n"); printf ("d - delete\n"); printf ("f - fetch\n"); printf ("n - nextkey\n"); printf ("q - quit\n"); printf ("s - store\n"); printf ("1 - firstkey\n"); printf ("2 - nextkey on last key (from n, 1 or 2)\n\n"); printf ("r - reorganize\n"); printf ("A - print avail list\n"); printf ("B - get and print current bucket n\n"); printf ("C - print current bucket\n"); printf ("D - print hash directory\n"); printf ("F - print file header\n"); printf ("H - hash value of key\n"); printf ("K - print the bucket cache\n"); printf ("V - print version of gdbm\n"); break; default: printf ("What? \n\n"); break; } } /* Quit normally. */ exit (0); } ./libc-linux/gdbm/global.c100644 1676 334 3220 5362342350 13430 0ustar hjlisl/* global.c - The external variables needed for "original" interface and error messages. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #include "gdbmdefs.h" #include "gdbmerrno.h" /* The global variables used for the "original" interface. */ gdbm_file_info *_gdbm_file = NULL; /* Memory for return data for the "original" interface. */ datum _gdbm_memory = {NULL, 0}; /* Used by firstkey and nextkey. */ char *_gdbm_fetch_val = NULL; /* Used by fetch. */ /* The dbm error number is placed in the variable GDBM_ERRNO. */ gdbm_error gdbm_errno = 0; ./libc-linux/gdbm/gdbm.h100644 1676 334 6557 5211462646 13132 0ustar hjlisl/* gdbm.h - The include file for dbm users. */ /* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. Copyright (C) 1990, 1991 Free Software Foundation, Inc. GDBM 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 1, or (at your option) any later version. GDBM 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 GDBM; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. You may contact the author by: e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226 phone: (206) 676-3035 *************************************************************************/ #ifndef _GDBM_H /* allow multiple inclusions */ #define _GDBM_H /* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who can create the database. */ #define GDBM_READER 0 /* A reader. */ #define GDBM_WRITER 1 /* A writer. */ #define GDBM_WRCREAT 2 /* A writer. Create the db if needed. */ #define GDBM_NEWDB 3 /* A writer. Always create a new db. */ /* Parameters to gdbm_store for simple insertion or replacement in the case that the key is already in the database. */ #define GDBM_INSERT 0 /* Never replace old data with new. */ #define GDBM_REPLACE 1 /* Always replace old data with new. */ /* The data and key structure. This structure is defined for compatibility. */ typedef struct { char *dptr; int dsize; } datum; /* The file information header. This is good enough for most applications. */ typedef struct {int dummy[10];} *GDBM_FILE; /* These are the routines! */ #ifdef __STDC__ #ifdef __cplusplus extern "C" { #endif extern GDBM_FILE gdbm_open(const char *, int, int, int, void (*fatal_func) ()); extern void gdbm_close(GDBM_FILE); extern datum gdbm_fetch(GDBM_FILE, datum); extern datum gdbm_firstkey(GDBM_FILE); extern datum gdbm_nextkey(GDBM_FILE); extern int gdbm_delete(GDBM_FILE, datum); extern int gdbm_store(GDBM_FILE, datum, datum, int); extern int gdbm_reorganize (GDBM_FILE); #ifdef __cplusplus } #endif #else extern GDBM_FILE gdbm_open (); extern void gdbm_close (); extern datum gdbm_fetch (); extern int gdbm_store (); extern int gdbm_delete (); extern datum gdbm_firstkey (); extern datum gdbm_nextkey (); extern int gdbm_reorganize (); #endif /* gdbm sends back the following error codes in the variable gdbm_errno. */ typedef enum { GDBM_NO_ERROR, GDBM_MALLOC_ERROR, GDBM_BLOCK_SIZE_ERROR, GDBM_FILE_OPEN_ERROR, GDBM_FILE_WRITE_ERROR, GDBM_FILE_SEEK_ERROR, GDBM_FILE_READ_ERROR, GDBM_BAD_MAGIC_NUMBER, GDBM_EMPTY_DATABASE, GDBM_CANT_BE_READER, GDBM_CANT_BE_WRITER, GDBM_READER_CANT_DELETE, GDBM_READER_CANT_STORE, GDBM_READER_CANT_REORGANIZE, GDBM_UNKNOWN_UPDATE, GDBM_ITEM_NOT_FOUND, GDBM_REORGANIZE_FAILED, GDBM_CANNOT_REPLACE, GDBM_ILLEGAL_DATA} gdbm_error; #endif /* _GDBM_H */ ./libc-linux/sysdeps/ 40755 1676 334 0 5516656462 12530 5ustar hjlisl./libc-linux/sysdeps/i386/ 40755 1676 334 0 5550055735 13213 5ustar hjlisl./libc-linux/sysdeps/i386/memcopy.h100644 1676 334 6254 5515066701 15135 0ustar hjlisl/* memcopy.h -- definitions for memory copy functions. i386 version. Copyright (C) 1991 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 #undef OP_T_THRES #define OP_T_THRES 8 #undef BYTE_COPY_FWD #define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \ asm volatile(/* Clear the direction flag, so copying goes forward. */ \ "cld\n" \ /* Copy bytes. */ \ "rep\n" \ "movsb" : \ "=D" (dst_bp), "=S" (src_bp) : \ "0" (dst_bp), "1" (src_bp), "c" (nbytes) : \ "cx") #undef BYTE_COPY_BWD #define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \ do \ { \ asm volatile(/* Set the direction flag, so copying goes backwards. */ \ "std\n" \ /* Copy bytes. */ \ "rep\n" \ "movsb\n" \ /* Clear the dir flag. Convention says it should be 0. */ \ "cld" : \ "=D" (dst_ep), "=S" (src_ep) : \ "0" (dst_ep - 1), "1" (src_ep - 1), "c" (nbytes) : \ "cx"); \ dst_ep += 1; \ src_ep += 1; \ } while (0) #undef WORD_COPY_FWD #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \ do \ { \ asm volatile(/* Clear the direction flag, so copying goes forward. */ \ "cld\n" \ /* Copy longwords. */ \ "rep\n" \ "movsl" : \ "=D" (dst_bp), "=S" (src_bp) : \ "0" (dst_bp), "1" (src_bp), "c" ((nbytes) / 4) : \ "cx"); \ (nbytes_left) = (nbytes) % 4; \ } while (0) #undef WORD_COPY_BWD #define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \ do \ { \ asm volatile(/* Set the direction flag, so copying goes backwards. */ \ "std\n" \ /* Copy longwords. */ \ "rep\n" \ "movsl\n" \ /* Clear the dir flag. Convention says it should be 0. */ \ "cld" : \ "=D" (dst_ep), "=S" (src_ep) : \ "0" (dst_ep - 4), "1" (src_ep - 4), "c" ((nbytes) / 4) : \ "cx"); \ dst_ep += 4; \ src_ep += 4; \ (nbytes_left) = (nbytes) % 4; \ } while (0) ./libc-linux/sysdeps/i386/ntoh.c100644 1676 334 504 5270563657 14411 0ustar hjlisl#include #include #include #undef ntohl #undef ntohs #undef htonl #undef htons function_alias(ntohl, htonl, unsigned long int, (x), DEFUN(htonl, (x), unsigned long int)) function_alias(ntohs, htons, unsigned short int, (x), DEFUN(htons, (x), unsigned short int)) ./libc-linux/sysdeps/i386/hton.c100644 1676 334 365 5270563637 14414 0ustar hjlisl#include #include #undef ntohl #undef ntohs #undef htonl #undef htons unsigned long int htonl(unsigned long int x) { return __htonl (x); } unsigned short int htons(unsigned short int x) { return __htons (x); } ./libc-linux/sysdeps/i386/Makefile100644 1676 334 753 5516115656 14736 0ustar hjlisl# # Makefile for i386 specific functions. # TOPDIR=../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I$(TOPDIR)/string -I$(TOPDIR) -I. DIRS:= setjmp SRC1S= hton.c modf.c bzero.c ffs.c memchr.c memcmp.c memset.c \ strcat.c strchr.c strcmp.c strcspn.c strlen.c strncmp.c \ strpbrk.c strrchr.c strspn.c SRC2S= ntoh.c div.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SCR2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/sysdeps/i386/div.c100644 1676 334 275 5253767035 14225 0ustar hjlisl#include #include #undef div #undef ldiv #include function_alias(div, ldiv, div_t, (num, denom), DEFUN(div, (num, denom), int num AND int denom)) ./libc-linux/sysdeps/i386/crypt.S100644 1676 334 15731 5501704522 14613 0ustar hjlisl .file "crypt.c" gcc2_compiled.: .text #ifdef __i486__ .align 4 #else .align 2 #endif .globl _ufc_doit _ufc_doit: pushl %ebp movl %esp,%ebp subl $4,%esp pushl %edi pushl %esi pushl %ebx movl 8(%ebp),%edi movl 12(%ebp),%esi movl 16(%ebp),%ebx movl 24(%ebp),%ecx decl %ecx movl %ecx,-4(%ebp) cmpl $-1,%ecx je L3 #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif L4: movl %ebx,%edx xorl _ufc_keytab,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%edi xorl _ufc_sb1+4(%eax),%esi shrl $16,%edx xorl _ufc_sb0(%edx),%edi xorl _ufc_sb0+4(%edx),%esi movl 20(%ebp),%edx xorl _ufc_keytab+4,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%edi xorl _ufc_sb3+4(%eax),%esi shrl $16,%edx xorl _ufc_sb2(%edx),%edi xorl _ufc_sb2+4(%edx),%esi movl %edi,%edx xorl _ufc_keytab+8,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%ebx movl _ufc_sb1+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb0(%edx),%ebx movl _ufc_sb0+4(%edx),%edx xorl %edx,20(%ebp) movl %esi,%edx xorl _ufc_keytab+12,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%ebx movl _ufc_sb3+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb2(%edx),%ebx movl _ufc_sb2+4(%edx),%edx xorl %edx,20(%ebp) movl %ebx,%edx xorl _ufc_keytab+16,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%edi xorl _ufc_sb1+4(%eax),%esi shrl $16,%edx xorl _ufc_sb0(%edx),%edi xorl _ufc_sb0+4(%edx),%esi movl 20(%ebp),%edx xorl _ufc_keytab+20,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%edi xorl _ufc_sb3+4(%eax),%esi shrl $16,%edx xorl _ufc_sb2(%edx),%edi xorl _ufc_sb2+4(%edx),%esi movl %edi,%edx xorl _ufc_keytab+24,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%ebx movl _ufc_sb1+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb0(%edx),%ebx movl _ufc_sb0+4(%edx),%edx xorl %edx,20(%ebp) movl %esi,%edx xorl _ufc_keytab+28,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%ebx movl _ufc_sb3+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb2(%edx),%ebx movl _ufc_sb2+4(%edx),%edx xorl %edx,20(%ebp) movl %ebx,%edx xorl _ufc_keytab+32,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%edi xorl _ufc_sb1+4(%eax),%esi shrl $16,%edx xorl _ufc_sb0(%edx),%edi xorl _ufc_sb0+4(%edx),%esi movl 20(%ebp),%edx xorl _ufc_keytab+36,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%edi xorl _ufc_sb3+4(%eax),%esi shrl $16,%edx xorl _ufc_sb2(%edx),%edi xorl _ufc_sb2+4(%edx),%esi movl %edi,%edx xorl _ufc_keytab+40,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%ebx movl _ufc_sb1+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb0(%edx),%ebx movl _ufc_sb0+4(%edx),%edx xorl %edx,20(%ebp) movl %esi,%edx xorl _ufc_keytab+44,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%ebx movl _ufc_sb3+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb2(%edx),%ebx movl _ufc_sb2+4(%edx),%edx xorl %edx,20(%ebp) movl %ebx,%edx xorl _ufc_keytab+48,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%edi xorl _ufc_sb1+4(%eax),%esi shrl $16,%edx xorl _ufc_sb0(%edx),%edi xorl _ufc_sb0+4(%edx),%esi movl 20(%ebp),%edx xorl _ufc_keytab+52,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%edi xorl _ufc_sb3+4(%eax),%esi shrl $16,%edx xorl _ufc_sb2(%edx),%edi xorl _ufc_sb2+4(%edx),%esi movl %edi,%edx xorl _ufc_keytab+56,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%ebx movl _ufc_sb1+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb0(%edx),%ebx movl _ufc_sb0+4(%edx),%edx xorl %edx,20(%ebp) movl %esi,%edx xorl _ufc_keytab+60,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%ebx movl _ufc_sb3+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb2(%edx),%ebx movl _ufc_sb2+4(%edx),%edx xorl %edx,20(%ebp) movl %ebx,%edx xorl _ufc_keytab+64,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%edi xorl _ufc_sb1+4(%eax),%esi shrl $16,%edx xorl _ufc_sb0(%edx),%edi xorl _ufc_sb0+4(%edx),%esi movl 20(%ebp),%edx xorl _ufc_keytab+68,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%edi xorl _ufc_sb3+4(%eax),%esi shrl $16,%edx xorl _ufc_sb2(%edx),%edi xorl _ufc_sb2+4(%edx),%esi movl %edi,%edx xorl _ufc_keytab+72,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%ebx movl _ufc_sb1+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb0(%edx),%ebx movl _ufc_sb0+4(%edx),%edx xorl %edx,20(%ebp) movl %esi,%edx xorl _ufc_keytab+76,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%ebx movl _ufc_sb3+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb2(%edx),%ebx movl _ufc_sb2+4(%edx),%edx xorl %edx,20(%ebp) movl %ebx,%edx xorl _ufc_keytab+80,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%edi xorl _ufc_sb1+4(%eax),%esi shrl $16,%edx xorl _ufc_sb0(%edx),%edi xorl _ufc_sb0+4(%edx),%esi movl 20(%ebp),%edx xorl _ufc_keytab+84,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%edi xorl _ufc_sb3+4(%eax),%esi shrl $16,%edx xorl _ufc_sb2(%edx),%edi xorl _ufc_sb2+4(%edx),%esi movl %edi,%edx xorl _ufc_keytab+88,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%ebx movl _ufc_sb1+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb0(%edx),%ebx movl _ufc_sb0+4(%edx),%edx xorl %edx,20(%ebp) movl %esi,%edx xorl _ufc_keytab+92,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%ebx movl _ufc_sb3+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb2(%edx),%ebx movl _ufc_sb2+4(%edx),%edx xorl %edx,20(%ebp) movl %ebx,%edx xorl _ufc_keytab+96,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%edi xorl _ufc_sb1+4(%eax),%esi shrl $16,%edx xorl _ufc_sb0(%edx),%edi xorl _ufc_sb0+4(%edx),%esi movl 20(%ebp),%edx xorl _ufc_keytab+100,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%edi xorl _ufc_sb3+4(%eax),%esi shrl $16,%edx xorl _ufc_sb2(%edx),%edi xorl _ufc_sb2+4(%edx),%esi movl %edi,%edx xorl _ufc_keytab+104,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%ebx movl _ufc_sb1+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb0(%edx),%ebx movl _ufc_sb0+4(%edx),%edx xorl %edx,20(%ebp) movl %esi,%edx xorl _ufc_keytab+108,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%ebx movl _ufc_sb3+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb2(%edx),%ebx movl _ufc_sb2+4(%edx),%edx xorl %edx,20(%ebp) movl %ebx,%edx xorl _ufc_keytab+112,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%edi xorl _ufc_sb1+4(%eax),%esi shrl $16,%edx xorl _ufc_sb0(%edx),%edi xorl _ufc_sb0+4(%edx),%esi movl 20(%ebp),%edx xorl _ufc_keytab+116,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%edi xorl _ufc_sb3+4(%eax),%esi shrl $16,%edx xorl _ufc_sb2(%edx),%edi xorl _ufc_sb2+4(%edx),%esi movl %edi,%edx xorl _ufc_keytab+120,%edx movzwl %dx,%eax xorl _ufc_sb1(%eax),%ebx movl _ufc_sb1+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb0(%edx),%ebx movl _ufc_sb0+4(%edx),%edx xorl %edx,20(%ebp) movl %esi,%edx xorl _ufc_keytab+124,%edx movzwl %dx,%eax xorl _ufc_sb3(%eax),%ebx movl _ufc_sb3+4(%eax),%eax xorl %eax,20(%ebp) shrl $16,%edx xorl _ufc_sb2(%edx),%ebx movl _ufc_sb2+4(%edx),%edx xorl %edx,20(%ebp) xchg %edi,%ebx xchg %esi,20(%ebp) decl -4(%ebp) cmpl $-1,-4(%ebp) jne L4 L3: pushl 20(%ebp) pushl %ebx pushl %esi pushl %edi call _ufc_dofinalperm leal -16(%ebp),%esp popl %ebx popl %esi popl %edi leave ret ./libc-linux/sysdeps/i386/modf.c100644 1676 334 3237 5341613503 14375 0ustar hjlisl#include #ifndef SOFT_387 double modf(double x, double *iptr) { double tmp; volatile short cw, cwtmp; __asm__ volatile ("fnstcw %0" : "=m" (cw) : ); cwtmp = cw | 0xc00; __asm__ volatile ("fldcw %0" : : "m" (cwtmp)); __asm__ volatile ("frndint" : "=t" (tmp) : "0" (x)); __asm__ volatile ("fldcw %0" : : "m" (cw)); *iptr = tmp; return (x - tmp); } #else #include #define shiftleft(dp,n) { /* n = 0 to 32 */ \ dp->mant1 = ((dp->mant1 << (n)) + (dp->mant2 >> (32-(n)))) \ & 0x0FFFFF; dp->mant2 <<= (n); dp->exp -= (n); } /* Returns fractional part of d, stores integer part in *integ */ double modf(double d, double *integ) { struct bitdouble *dp = (struct bitdouble *)&d; struct bitdouble *ip = (struct bitdouble *)integ; int e = dp->exp - BIAS; if (e < 0) { /* no integer part */ *integ = 0; return d; } /* compute integer: clear fractional part where necessary */ *integ = d; if (e <= 20) { ip->mant1 &= (-1L << (20-e)); /* split in mant1... */ ip->mant2 = 0; } else if (e <= 52) ip->mant2 &= (-1L << (52-e)); /* split in mant2 */ else return 0; /* no fractional part */ /* compute fractional part: shift left over integer part */ if (e) if (e <= 32) shiftleft(dp,e) else { dp->mant1 = (dp->mant2 << (e-32)) & 0x0FFFFF; dp->mant2 = 0; dp->exp -= e; } /* adjust fractional part shifting left... */ if (dp->mant1==0 && dp->mant2==0) /* fraction is zero */ return 0; while (!(dp->mant1 & 0x080000)) /* stack to the left */ shiftleft(dp,1); shiftleft(dp,1); /* lose 'invisible bit' */ return d; } #endif ./libc-linux/sysdeps/i386/setjmp/ 40755 1676 334 0 5550055743 14514 5ustar hjlisl./libc-linux/sysdeps/i386/setjmp/__longjmp.c100644 1676 334 3554 5465557253 16740 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 #include #ifndef __GNUC__ #error This file uses GNU C extensions; you must compile with GCC. #endif #define REGS \ REG (bx);\ REG (si);\ REG (di);\ REG (bp);\ REG (sp) #ifndef linux #define REG(xx) register long int xx asm (#xx) REGS; #undef REG #endif /* Jump to the position specified by ENV, causing the setjmp call there to return VAL, or 1 if VAL is 0. */ void DEFUN(__longjmp, (env, val), CONST jmp_buf env AND int val) { /* We specify explicit registers because, when not optimizing, the compiler will generate code that uses the frame pointer after it's been munged. */ register CONST __typeof (env[0]) *e asm ("cx"); register int v asm ("ax"); e = env; v = val == 0 ? 1 : val; #ifdef linux #define REG(xx) asm volatile ("movl %0,%%e" #xx : : \ "m" ((long int) (e->__##xx))) #else #define REG(xx) xx = (long int) e->__##xx #endif REGS; asm volatile ("jmp %*%0" : : "g" (e->__pc), "a" (v)); /* NOTREACHED */ abort (); } ./libc-linux/sysdeps/i386/setjmp/__setjmp.c100644 1676 334 3034 5362371373 16556 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 #define REGS \ REG (bx);\ REG (si);\ REG (di) #ifndef linux #define REG(xx) register long int xx asm (#xx) REGS; #undef REG #endif /* Save the current program position in ENV and return 0. */ int DEFUN(__setjmp, (env), jmp_buf env) { /* Save the general registers. */ #ifdef linux #define REG(xx) asm volatile ("movl %%e" #xx ",%0" : \ "=m" ((long int) (env[0].__##xx)) : ) #else #define REG(xx) env[0].__##xx = xx #endif REGS; /* Save the return PC. */ env[0].__pc = (PTR) ((PTR *) &env)[-1]; /* Save caller's FP, not our own. */ env[0].__bp = (PTR) ((PTR *) &env)[-2]; /* Save caller's SP, not our own. */ env[0].__sp = (PTR) &env; return 0; } ./libc-linux/sysdeps/i386/setjmp/sigsetjmp.c100644 1676 334 3307 5465534327 16772 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 #include /* Store the calling environment in ENV, also saving the signal mask if SAVEMASK is nonzero. Return 0. */ int DEFUN(sigsetjmp, (env, savemask), sigjmp_buf env AND int savemask) { if (savemask) env[0].__savemask = sigprocmask(SIG_BLOCK, (sigset_t *) NULL, &env[0].__sigmask) == 0; else env[0].__savemask = 0; #define REGS \ REG (bx);\ REG (si);\ REG (di) /* Save the general registers. */ #define REG(xx) asm volatile ("movl %%e" #xx ",%0" : \ "=m" ((long int) ((env[0].__jmpbuf)[0].__##xx)) : ) REGS; /* Save the return PC. */ (env[0].__jmpbuf)[0].__pc = (PTR) ((PTR *) &env)[-1]; /* Save caller's FP, not our own. */ (env[0].__jmpbuf)[0].__bp = (PTR) ((PTR *) &env)[-2]; /* Save caller's SP, not our own. */ (env[0].__jmpbuf)[0].__sp = (PTR) &env; return 0; } ./libc-linux/sysdeps/i386/setjmp/Makefile100644 1676 334 525 5515545366 16241 0ustar hjlisl# # Makefile for i386 specific functions. # TOPDIR=../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I$(TOPDIR)/include -I.. BASE_CFLAGS:=$(BASE_CFLAGS) -fno-omit-frame-pointer DIRS:= SRCS= __longjmp.c __setjmp.c # sigsetjmp.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/sysdeps/i386/memchr.c100644 1676 334 3647 5515061153 14731 0ustar hjlisl/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less than N. For Intel 80x86, x>=3. Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 #ifdef __GNUC__ PTR DEFUN(memchr, (str, c, len), CONST PTR str AND int c AND size_t len) { #if 1 PTR retval __asm__("di"); if (!len) return NULL; __asm__("cld\n\t" "repne\n\t" "scasb\n\t" "je 1f\n\t" "movl $1,%0\n" "1:\tdecl %0" :"=D" (retval):"a" (c),"D" (str),"c" (len) :"cx"); #else PTR retval; asm("cld\n" /* Search forward. */ "testl %1,%1\n" /* Clear Z flag, to handle LEN == 0. */ /* Some old versions of gas need `repne' instead of `repnz'. */ "repnz\n" /* Search for C in al. */ "scasb\n" "movl %2,%0\n" /* Set %0 to 0 (without affecting Z flag). */ "jnz done\n" /* Jump if we found nothing equal to C. */ "leal -1(%1),%0\n" /* edi has been incremented. Return edi-1. */ "done:" : "=a" (retval), "=D" (str), "=c" (len) : "0" (c), "1" (str), "2" (len)); #endif return retval; } #else #include #endif ./libc-linux/sysdeps/i386/memcmp.c100644 1676 334 660 5304265302 14702 0ustar hjlisl#include #ifdef isbcmp #define memcmp bcmp #define size_t int #endif int memcmp(const void * cs,const void * ct,size_t count) { register int __res __asm__("ax"); #ifdef isbcmp if (count <= 0) return 0; #endif __asm__("cld\n\t" "repe\n\t" "cmpsb\n\t" "je 1f\n\t" "movl $1,%%eax\n\t" "jb 1f\n\t" "negl %%eax\n" "1:" :"=a" (__res):"0" (0),"D" (cs),"S" (ct),"c" (count) :"si","di","cx"); return __res; } ./libc-linux/sysdeps/i386/memset.c100644 1676 334 4534 5515054335 14750 0ustar hjlisl/* memset -- set a block of memory to some byte value. For Intel 80x86, x>=3. Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 #ifdef __GNUC__ PTR DEFUN(memset, (dstpp, c, len), PTR dstpp AND int c AND size_t len) { unsigned long int dstp = (unsigned long int) dstpp; /* This explicit register allocation improves code very much indeed. */ register op_t x asm("ax"); x = (unsigned char) c; /* Clear the direction flag, so filling will move forward. */ asm volatile("cld"); /* This threshold value is optimal. */ if (len >= 12) { /* Fill X with four copies of the char we want to fill with. */ x |= (x << 8); x |= (x << 16); /* Adjust LEN for the bytes handled in the first loop. */ len -= (-dstp) % OPSIZ; /* There are at least some bytes to set. No need to test for LEN == 0 in this alignment loop. */ /* Fill bytes until DSTP is aligned on a longword boundary. */ asm volatile("rep\n" "stosb" /* %0, %2, %3 */ : "=D" (dstp) : "0" (dstp), "c" ((-dstp) % OPSIZ), "a" (x) : "cx"); /* Fill longwords. */ asm volatile("rep\n" "stosl" /* %0, %2, %3 */ : "=D" (dstp) : "0" (dstp), "c" (len / OPSIZ), "a" (x) : "cx"); len %= OPSIZ; } /* Write the last few bytes. */ asm volatile("rep\n" "stosb" /* %0, %2, %3 */ : "=D" (dstp) : "0" (dstp), "c" (len), "a" (x) : "cx"); return dstpp; } #else #include #endif ./libc-linux/sysdeps/i386/bzero.c100644 1676 334 4577 5515064045 14605 0ustar hjlisl/* bzero -- set a block of memory to zero. For Intel 80x86, x>=3. Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 #undef bzero #ifdef __GNUC__ #ifdef __linux__ void DEFUN(bzero, (dstpp, len), PTR dstpp AND int len) #else DEFUN(bzero, (dstpp, len), PTR dstpp AND size_t len) #endif { /* N.B.: This code is almost verbatim from memset.c. */ unsigned long int dstp = (unsigned long int) dstpp; /* This explicit register allocation improves code very much indeed. */ register op_t x asm("ax"); #ifdef __linux__ if (len <= 0) return; #endif x = 0; /* Clear the direction flag, so filling will move forward. */ asm volatile("cld"); /* This threshold value is optimal. */ if (len >= 12) { /* Adjust LEN for the bytes handled in the first loop. */ len -= (-dstp) % OPSIZ; /* There are at least some bytes to set. No need to test for LEN == 0 in this alignment loop. */ /* Fill bytes until DSTP is aligned on a longword boundary. */ asm volatile("rep\n" "stosb" /* %0, %2, %3 */ : "=D" (dstp) : "0" (dstp), "c" ((-dstp) % OPSIZ), "a" (x) : "cx"); /* Fill longwords. */ asm volatile("rep\n" "stosl" /* %0, %2, %3 */ : "=D" (dstp) : "0" (dstp), "c" (len / OPSIZ), "a" (x) : "cx"); len %= OPSIZ; } /* Write the last few bytes. */ asm volatile("rep\n" "stosb" /* %0, %2, %3 */ : "=D" (dstp) : "0" (dstp), "c" (len), "a" (x) : "cx"); } #else #include #endif ./libc-linux/sysdeps/i386/strcat.c100644 1676 334 421 5263474425 14733 0ustar hjlisl#include char * strcat(char * dest,const char * src) { __asm__("cld\n\t" "repne\n\t" "scasb\n\t" "decl %1\n" "1:\tlodsb\n\t" "stosb\n\t" "testb %%al,%%al\n\t" "jne 1b" ::"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"si","di","ax","cx"); return dest; } ./libc-linux/sysdeps/i386/strchr.c100644 1676 334 506 5263475541 14744 0ustar hjlisl#include char * strchr(const char * s,int c) { register char * __res __asm__("ax"); __asm__("cld\n\t" "movb %%al,%%ah\n" "1:\tlodsb\n\t" "cmpb %%ah,%%al\n\t" "je 2f\n\t" "testb %%al,%%al\n\t" "jne 1b\n\t" "movl $1,%1\n" "2:\tmovl %1,%0\n\t" "decl %0" :"=a" (__res):"S" (s),"0" (c):"si"); return __res; } ./libc-linux/sysdeps/i386/strcmp.c100644 1676 334 543 5263514625 14745 0ustar hjlisl#include int strcmp(const char * cs,const char * ct) { register int __res __asm__("ax"); __asm__("cld\n" "1:\tlodsb\n\t" "scasb\n\t" "jne 2f\n\t" "testb %%al,%%al\n\t" "jne 1b\n\t" "xorl %%eax,%%eax\n\t" "jmp 3f\n" "2:\tmovl $1,%%eax\n\t" "jb 3f\n\t" "negl %%eax\n" "3:" :"=a" (__res):"D" (cs),"S" (ct):"si","di"); return __res; } ./libc-linux/sysdeps/i386/strcspn.c100644 1676 334 757 5263476531 15143 0ustar hjlisl#include size_t strcspn(const char * cs, const char * ct) { register char * __res __asm__("si"); __asm__("cld\n\t" "movl %4,%%edi\n\t" "repne\n\t" "scasb\n\t" "notl %%ecx\n\t" "decl %%ecx\n\t" "movl %%ecx,%%edx\n" "1:\tlodsb\n\t" "testb %%al,%%al\n\t" "je 2f\n\t" "movl %4,%%edi\n\t" "movl %%edx,%%ecx\n\t" "repne\n\t" "scasb\n\t" "jne 1b\n" "2:\tdecl %0" :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) :"ax","cx","dx","di"); return (size_t) (__res-cs); } ./libc-linux/sysdeps/i386/strlen.c100644 1676 334 2733 5515056251 14763 0ustar hjlisl/* strlen -- determine the length of a string. For Intel 80x86, x>=3. Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 size_t DEFUN(strlen, (str), CONST char *str) { #if 1 register size_t __res __asm__("cx"); __asm__("cld\n\t" "repne\n\t" "scasb\n\t" "notl %0\n\t" "decl %0" :"=c" (__res):"D" (str),"a" (0),"0" (0xffffffff):"di"); return __res; #else int cnt; asm("cld\n" /* Search forward. */ /* Some old versions of gas need `repne' instead of `repnz'. */ "repnz\n" /* Look for a zero byte. */ "scasb" /* %0, %1, %3 */ : "=c" (cnt) : "D" (str), "0" (-1), "a" (0)); return -2 - cnt; #endif } ./libc-linux/sysdeps/i386/strncmp.c100644 1676 334 657 5263515002 15117 0ustar hjlisl#include int strncmp(const char * cs,const char * ct,size_t count) { register int __res __asm__("ax"); __asm__("cld\n\t" "incl %3\n" "1:\tdecl %3\n\t" "je 2f\n\t" "lodsb\n\t" "scasb\n\t" "jne 3f\n\t" "testb %%al,%%al\n\t" "jne 1b\n" "2:\txorl %%eax,%%eax\n\t" "jmp 4f\n" "3:\tmovl $1,%%eax\n\t" "jb 4f\n\t" "negl %%eax\n" "4:" :"=a" (__res):"D" (cs),"S" (ct),"c" (count):"si","di","cx"); return __res; } ./libc-linux/sysdeps/i386/strpbrk.c100644 1676 334 1010 5263477237 15141 0ustar hjlisl#include char * strpbrk(const char * cs,const char * ct) { register char * __res __asm__("si"); __asm__("cld\n\t" "movl %4,%%edi\n\t" "repne\n\t" "scasb\n\t" "notl %%ecx\n\t" "decl %%ecx\n\t" "movl %%ecx,%%edx\n" "1:\tlodsb\n\t" "testb %%al,%%al\n\t" "je 2f\n\t" "movl %4,%%edi\n\t" "movl %%edx,%%ecx\n\t" "repne\n\t" "scasb\n\t" "jne 1b\n\t" "decl %0\n\t" "jmp 3f\n" "2:\txorl %0,%0\n" "3:" :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) :"ax","cx","dx","di"); return __res; } ./libc-linux/sysdeps/i386/strrchr.c100644 1676 334 506 5263475564 15133 0ustar hjlisl#include char * strrchr(const char * s,int c) { register char * __res __asm__("dx"); __asm__("cld\n\t" "movb %%al,%%ah\n" "1:\tlodsb\n\t" "cmpb %%ah,%%al\n\t" "jne 2f\n\t" "movl %%esi,%0\n\t" "decl %0\n" "2:\ttestb %%al,%%al\n\t" "jne 1b" :"=d" (__res):"0" (0),"S" (s),"a" (c):"ax","si"); return __res; } ./libc-linux/sysdeps/i386/strspn.c100644 1676 334 755 5263476563 15003 0ustar hjlisl#include size_t strspn(const char * cs, const char * ct) { register char * __res __asm__("si"); __asm__("cld\n\t" "movl %4,%%edi\n\t" "repne\n\t" "scasb\n\t" "notl %%ecx\n\t" "decl %%ecx\n\t" "movl %%ecx,%%edx\n" "1:\tlodsb\n\t" "testb %%al,%%al\n\t" "je 2f\n\t" "movl %4,%%edi\n\t" "movl %%edx,%%ecx\n\t" "repne\n\t" "scasb\n\t" "je 1b\n" "2:\tdecl %0" :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) :"ax","cx","dx","di"); return (size_t) (__res-cs); } ./libc-linux/sysdeps/i386/ffs.c100644 1676 334 2631 5263454035 14231 0ustar hjlisl/* ffs -- find first set bit in a word, counted from least significant end. For Intel 80x86, x>=3. Copyright (C) 1991, 1992 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 #undef ffs #ifdef __GNUC__ int DEFUN(ffs, (x), int x) { int cnt; int tmp; asm ("xorl %0,%0\n" /* Set CNT to zero. */ "bsfl %2,%1\n" /* Count low bits in X and store in %1. */ "jz 1f\n" /* Jump if OK, i.e. X was non-zero. */ "leal 1(%3),%0\n" /* Return bsfl-result plus one on %0. */ "1:" : "=a" (cnt), "=r" (tmp) : "rm" (x), "1" (tmp)); return cnt; } #else #include #endif ./libc-linux/sysdeps/linux/ 40755 1676 334 0 5550055465 13661 5ustar hjlisl./libc-linux/sysdeps/linux/i386/ 40755 1676 334 0 5550055520 14342 5ustar hjlisl./libc-linux/sysdeps/linux/i386/sysdep.h100644 1676 334 7317 5535776151 16144 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 #if defined(__i486__) || defined(i486) #define ENTRY(name) \ .globl _##name##; \ .align 4; \ _##name##: #else #define ENTRY(name) \ .globl _##name##; \ .align 2; \ _##name##: #endif #if defined(__PIC__) || defined (__pic__) #define PSEUDO(name, syscall_name, args) \ .text; \ ENTRY (name) \ PUSH_##args \ call L4; \ L4: \ popl %ebx; \ addl $_GLOBAL_OFFSET_TABLE_+[.-L4],%ebx; \ pushl %ebx; \ movl $(SYS_##syscall_name), %eax; \ MOVE_##args \ 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; \ Lexit: \ POP_##args #else #define PSEUDO(name, syscall_name, args) \ .text; \ ENTRY (name) \ PUSH_##args \ movl $(SYS_##syscall_name), %eax; \ MOVE_##args \ int $0x80; \ test %eax, %eax; \ jge Lexit; \ negl %eax; \ movl %eax,_errno; \ movl $-1,%eax; \ Lexit: \ POP_##args #endif /* 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 #define MOVE_0 /* No arguments to move. */ #if defined(__PIC__) || defined (__pic__) #define MOVE_1 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 16(%esp),%ebx; movl 20(%esp),%ecx; \ movl 24(%esp),%edx; movl 28(%esp),%esi; #define MOVE_5 movl 20(%esp),%ebx; movl 24(%esp),%ecx; \ movl 28(%esp),%edx; movl 32(%esp),%esi; \ movl 36(%esp),%edi; #else #define MOVE_1 movl 8(%esp),%ebx; #define MOVE_2 MOVE_1 movl 12(%esp),%ecx; #define MOVE_3 MOVE_2 movl 16(%esp),%edx; #define MOVE_4 movl 12(%esp),%ebx; movl 16(%esp),%ecx; \ movl 20(%esp),%edx; movl 24(%esp),%esi; #define MOVE_5 movl 16(%esp),%ebx; movl 20(%esp),%ecx; \ movl 24(%esp),%edx; movl 28(%esp),%esi; \ movl 32(%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; /* Linux doesn't use it. */ #if 0 #define r0 %eax #define r1 %edx #define MOVE(x,y) movl x , y #endif ./libc-linux/sysdeps/linux/i386/readdir.c100644 1676 334 3242 5347227267 16233 0ustar hjlisl#include #include #include /* * readdir fills up the buffer with the readdir system call. it also * gives a third parameter (currently ignored, but should be 1) that * can with a future kernel be enhanced to be the number of entries * to be gotten. * * Right now the readdir system call return the number of characters * in the name - in the future it will probably return the number of * entries gotten. No matter - right now we just check for positive: * that will always work (as we know that it cannot be bigger than 1 * in the future: we just asked for one entry). */ struct dirent *readdir(DIR * dir) { int result; int count = NUMENT; if (!dir) { errno = EBADF; return NULL; } if (dir->dd_size <= dir->dd_loc) { /* read count of directory entries. For now it should be one. */ #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%esi,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (result) :"0" (SYS_readdir),"S" (dir->dd_fd), "c" ((long) dir->dd_buf),"d" (count)); #else __asm__("int $0x80" :"=a" (result) :"0" (SYS_readdir),"b" (dir->dd_fd), "c" ((long) dir->dd_buf),"d" (count)); #endif if (result <= 0) { if (result < 0) errno = -result; return NULL; } /* * Right now the readdir system call return the number of * characters in the name - in the future it will probably return * the number of entries gotten. No matter - right now we just * check for positive: */ #if 0 dir->dd_size = result; #else dir->dd_size = 1; #endif dir->dd_loc = 0; } return &(dir->dd_buf [(dir->dd_loc)++]); } ./libc-linux/sysdeps/linux/i386/__sbrk.c100644 1676 334 1120 5323235427 16040 0ustar hjlisl#include #include #include extern void * ___brk_addr; void * __sbrk(ptrdiff_t increment) { void * tmp = ___brk_addr+increment; #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%ecx,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (___brk_addr) :"0" (SYS_brk),"c" (tmp)); #else __asm__ volatile ("int $0x80" :"=a" (___brk_addr) :"0" (SYS_brk),"b" (tmp)); #endif if (___brk_addr == tmp) return tmp-increment; errno = ENOMEM; return ((void *) -1); } ./libc-linux/sysdeps/linux/i386/__brk.c100644 1676 334 776 5362362402 15652 0ustar hjlisl#include #include #include void * ___brk_addr = 0; int __brk(void * end_data_seg) { #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%ecx,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (___brk_addr) :"0" (SYS_brk),"c" (end_data_seg)); #else __asm__ volatile ("int $0x80" :"=a" (___brk_addr) :"0" (SYS_brk),"b" (end_data_seg)); #endif if (___brk_addr == end_data_seg) return 0; errno = ENOMEM; return -1; } ./libc-linux/sysdeps/linux/i386/getprio.c100644 1676 334 1223 5323235761 16257 0ustar hjlisl#include #include #include #define PZERO 15 int getpriority(int which, int who) { long res; #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%edx,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (res) :"0" (SYS_getpriority),"d" (which), "c" (who)); #else __asm__ volatile ("int $0x80" :"=a" (res) :"0" (SYS_getpriority),"b" (which), "c" (who)); #endif if (res >= 0) { errno = 0; return (int) PZERO - res; } errno = -res; return -1; } ./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/__select.c100644 1676 334 1034 5341177625 16367 0ustar hjlisl#include #include #include int __select(int nd, fd_set * in, fd_set * out, fd_set * ex, struct timeval * tv) { long __res; #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%ecx,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" : "=a" (__res) : "0" (SYS_select),"c" ((long) &nd)); #else __asm__ volatile ("int $0x80" : "=a" (__res) : "0" (SYS_select),"b" ((long) &nd)); #endif if (__res >= 0) return (int) __res; errno = -__res; return -1; } ./libc-linux/sysdeps/linux/i386/sigsuspend.c100644 1676 334 737 5323235610 16754 0ustar hjlisl#include #include int sigsuspend(sigset_t *sigmask) { int res; #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%esi,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (res) :"0" (SYS_sigsuspend), "S" (0), "c" (0), "d" (*sigmask)); #else __asm__("int $0x80" :"=a" (res) :"0" (SYS_sigsuspend), "b" (0), "c" (0), "d" (*sigmask)); #endif if (res >= 0) return res; errno = -res; return -1; } ./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/__sigact.c100644 1676 334 1275 5323234704 16361 0ustar hjlisl#include #include #include extern void ___sig_restore(); extern void ___masksig_restore(); int __sigaction(int sig,struct sigaction * new, struct sigaction * old) { if (new) { if (new->sa_flags & SA_NOMASK) new->sa_restorer=___sig_restore; else new->sa_restorer=___masksig_restore; } #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%edi,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (sig) :"0" (SYS_sigaction),"D" (sig),"c" (new),"d" (old)); #else __asm__("int $0x80":"=a" (sig) :"0" (SYS_sigaction),"b" (sig),"c" (new),"d" (old)); #endif if (sig>=0) return 0; errno = -sig; return -1; } ./libc-linux/sysdeps/linux/i386/ptrace.c100644 1676 334 1304 5323235560 16061 0ustar hjlisl#include #include #include int ptrace(int request, int pid, int addr, int data) { long ret; long res; if (request > 0 && request < 4) (long *)data = &ret; #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%edi,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (res) :"0" (SYS_ptrace),"D" (request), "c" (pid), "d" (addr), "S" (data)); #else __asm__ volatile ("int $0x80" :"=a" (res) :"0" (SYS_ptrace),"b" (request), "c" (pid), "d" (addr), "S" (data)); #endif if (res >= 0) { if (request > 0 && request < 4) { errno = 0; return (ret); } return (int) res; } errno = -res; return -1; } ./libc-linux/sysdeps/linux/i386/____sig.S100644 1676 334 1024 5323237724 16144 0ustar hjlisl.globl ____sig_restore .globl ____masksig_restore ____sig_restore: addl $4,%esp # signr popl %eax popl %ecx popl %edx popfl ret ____masksig_restore: #if defined(__PIC__) || defined(__pic__) pushl %ebx call L3 L3: popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-L3],%ebx addl $8,%esp # signr call ___sigsetmask@PLT # old blocking addl $8,%esp popl %ebx popl %eax popl %ecx popl %edx popfl #else addl $4,%esp # signr call ___sigsetmask # old blocking addl $4,%esp popl %eax popl %ecx popl %edx popfl #endif ret ./libc-linux/sysdeps/linux/i386/__syscall.S100644 1676 334 5356 5537512013 16544 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; .globl _syscall .text #if defined(__i486__) || defined(i486) .align 4 #else .align 2 #endif _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/math/ 40755 1676 334 0 5550055631 15276 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/atan.S100644 1676 334 1323 5342057756 16452 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. */ .file "atan.S" .text .globl _atan #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _atan: fldl 4(%esp) fld1 fpatan ret ./libc-linux/sysdeps/linux/i386/math/cos.S100644 1676 334 1563 5471332244 16310 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. */ .file "cos.S" .text .globl _cos #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _cos: fldl 4(%esp) jmp LL3 LL1: fldpi fld %st(0) /* 2 pi */ faddp %st,%st(1) fxch %st(1) LL2: fprem1 fstsw %ax sahf jp LL2 fxch %st(1) fstp %st(0) LL3: fcos fstsw %ax sahf jp LL1 ret ./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/i386/math/asinh.S100644 1676 334 1443 5342057741 16626 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. */ .file "asinh.S" .text .globl _asinh #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _asinh: fldl 4(%esp) fmull 4(%esp) fld1 faddp %st,%st(1) fsqrt faddl 4(%esp) fldln2 fxch %st(1) fyl2x ret ./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/tan.S100644 1676 334 1520 5342057613 16300 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. */ .file "tan.S" .text .globl _tan #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _tan: fldl 4(%esp) jmp L3 L1: fldpi fxch %st(1) L2: fprem1 fstsw %ax sahf jp L2 fxch %st(1) fstp %st(0) L3: fptan fstsw %ax sahf jp L1 fstp %st(0) ret ./libc-linux/sysdeps/linux/i386/math/asin.c100644 1676 334 1756 5377510517 16510 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(asin, (x), double x) { double y; if (x <= -1.0 ) { if (x == -1.0) { return -M_PI_2; } return __infnan( EDOM); } if (x >= 1.0 ) { if (x == 1.0) { return M_PI_2; } return __infnan( EDOM); } y = sqrt (1.0 - x * x); __asm__ __volatile__ ("fpatan" :"=t" (y) : "0" (y), "u" (x)); return y; } ./libc-linux/sysdeps/linux/i386/math/exp.S100600 1676 334 3212 5524062662 16304 0ustar hjlisl/* ** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 ** ** Modified O.ROBERT 24, Avenue de Verdun 92170 VANVES, FRANCE ** ** E-mail: roberto@germinal.ibp.fr ** ** This file is distributed under the terms listed in the document ** "copying.dj", available from DJ Delorie at the address above. ** A copy of "copying.dj" should accompany this file; if not, a copy ** should be available from where this file was obtained. This file ** may not be distributed without a verbatim copy of "copying.dj". ** ** This file is distributed WITHOUT ANY WARRANTY; without even the implied ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ** ** or 03-Apr-1991 corrected bug about argument zero to pow ** fyl2x didn't like it */ /* Modified by H.J. Lu for Linux, 1992 */ /* Modified by J.-H. Rechtien, 2.2.1994 */ /* History:15,24 */ .file "exp.S" .data #ifdef __i486__ .align 4 #else .align 2 #endif LCW1: .word 0 #ifdef __i486__ .align 4 #else .align 2 #endif LCW2: .word 0 .text #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif LC0: .double 0d1.0000000000000000000e+00 .globl _exp #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _exp: fldl 4(%esp) fldl2e fmulp %st,%st(1) jmp Lpow2 .globl _pow10 #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _pow10: fldl 4(%esp) fldl2t fmulp %st,%st(1) jmp Lpow2 .globl _pow2 #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _pow2: fldl 4(%esp) Lpow2: fstcw LCW1 fstcw LCW2 fwait andw $0xf3ff,LCW1 fldcw LCW1 fldl %st(0) frndint fldcw LCW2 fxch %st(1) fsub %st(1),%st f2xm1 fwait faddl LC0 fscale fstp %st(1) ret ./libc-linux/sysdeps/linux/i386/math/frexp.c100644 1676 334 2035 5341645512 16664 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 /* Stores binary exponent of d in e, and returns whole fraction of d * (with binary exponent of 0) (special case for d=0) */ double frexp(double d, int *e) { union ieee754_double *dp = (union ieee754_double *)&d; if (d == 0.0) /* value is zero, return exponent of 0 */ *e = 0.0; else { *e = dp->ieee.exponent - _IEEE754_DOUBLE_BIAS + 1; dp->ieee.exponent = _IEEE754_DOUBLE_BIAS - 1; } return d; } ./libc-linux/sysdeps/linux/i386/math/log.c100644 1676 334 1752 5377510517 16333 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 static inline double domain ( double x) { /* perror("log"); */ if (x < 0.) return __infnan( EDOM); else /* i.e. x== 0. */ return __infnan(-ERANGE); } double DEFUN(log, (x), double x) { if (x <= 0.0) return domain (x); __asm__ __volatile__ ("fldln2\n\t" "fxch %%st(1)\n\t" "fyl2x" :"=t" (x) : "0" (x)); return x; } ./libc-linux/sysdeps/linux/i386/math/log10.c100644 1676 334 1757 5547125375 16504 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 static inline double domain (double x) { /* perror ("log10"); */ if (x < 0.) return __infnan( EDOM); else /* i.e. x== 0. */ return __infnan( ERANGE); } double DEFUN(log10, (x), double x) { if (x <= 0.0) return domain (x); __asm__ __volatile__ ("fldlg2\n\t" "fxch %%st(1)\n\t" "fyl2x" :"=t" (x) : "0" (x)); return x; } ./libc-linux/sysdeps/linux/i386/math/copying.dj100644 1676 334 4103 5221555074 17361 0ustar hjlislThis is the file "copying.dj". Copyright Information for sources and executables that are marked Copyright (C) DJ Delorie 24 Kirsten Ave Rochester NH 03867-2954 This document is Copyright (C) DJ Delorie and may be distributed verbatim, but changing it is not allowed. Source code and executables copyright DJ Delorie are referred to as "djcode" in this document. Source code copyright DJ Delorie is distributed under the terms of the GNU General Public Licence, with the following exceptions: 1 If the user of this software develops an application that requires djcode to run, and that application is distributed under the terms of the GNU General Public License (GPL), a binary executable of djcode may be distributed with binary executables of the application, and source files for djcode must be available with source files for the application, under the terms of the GNU GPL. 2 If the user of this software develops an application that requires djcode to run, and that application is NOT distributed under the terms of the GNU General Public License (GPL), a binary executable of djcode may be distributed with binary executables of the application, provided a royalty of 5% of the total sale price or $5 (whichever is more) per copy sold is paid to DJ Delorie (at the address above). 3 A person or organization who develops software that requires djcode but does not distribute that software under the terms of the GNU GPL relinquishes all rights to obtain or redistribute the source code for djcode, including any rights granted by the GNU General Public License, and may only distribute executables of djcode under the terms of exception 2, above. Basically, the GNU GPL only applies to my code if it applies to your code. A copy of the file "COPYING" is included with this document. If you did not receive a copy of "COPYING", you may obtain one from whence this document was obtained, or by writing: Free Software Foundation 675 Mass Ave Cambridge, MA 02139 USA ./libc-linux/sysdeps/linux/i386/math/pow.c100644 1676 334 3650 5514056712 16351 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 pow (x,y) double x,y; { int negative; __volatile__ unsigned short cw, saved_cw; /* 80387 control word */ if (y == 0.0) return 1.0; if (x == 0.0) return (y < 0.0) ? __infnan(EDOM) : 0.0; if (y == 1.0) return x; if (x < 0.0) { long long tmp; tmp = (long long) y; /* Even or odd */ negative = tmp & 1; /* That is only valid if |y| < 2^64. */ if (y != (double) tmp) { return __infnan( EDOM); } x = -x; } else { negative = 0; } /* * Inline assembler implements the following algorithm: * * 1 - x' = y *log2(x) * 2 - find x1, x2 where x' = x1 + x2 and |x2| <= 0.5 * 3 - x = 2^x2 scaled by x1 */ __asm__ __volatile__ ("fnstcw %0" : "=m" (cw) : ); saved_cw = cw; cw &= 0xf3ff; /* force round to nearest */ cw |= 0x003f; /* turn off exceptions (see ANSI/ISO 9989 section 7.5.1) */ __asm__ __volatile__ ("fldcw %0" : : "m" (cw)); __asm__ __volatile__ ("fyl2x;fstl %2;frndint;fstl %%st(2);fsubrp;f2xm1;" "fld1;faddp;fscale" : "=t" (x) : "0" (x), "u" (y)); /* Restore the control word */ __asm__ __volatile__ ("fldcw %0" : : "m" (saved_cw)); /* Check for results that can not be represented (kludgy): */ if (__isinf(x) || __isnan(x)) errno = ERANGE; return (negative) ? -x : x; } ./libc-linux/sysdeps/linux/i386/math/README100644 1676 334 431 5341647706 16241 0ustar hjlislThis is the math lib for Linux. Some of them are borrowed from DJ Delorie and BSD 4.3 and are covered by respective copyright notices. The rest is written by me, which is covered by the GNU General Public license version 2, or any later version. H.J. Lu 02/20/93 hlu@eecs.wsu.edu ./libc-linux/sysdeps/linux/i386/math/sqrt.c100644 1676 334 1610 5377510520 16526 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 /* Return the sqrt root of x. */ double DEFUN(sqrt, (x), double x) { const double zero = 0.0; if (x >= zero) { if (x != zero) { __asm__ __volatile__ ("fsqrt" :"=t" (x) : "0" (x)); } return x; } else return __infnan( EDOM); } ./libc-linux/sysdeps/linux/i386/math/acos.c100644 1676 334 1753 5377510517 16500 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(acos, (x), double x) { if (x <= -1.0 ) { if (x == -1.0) { return M_PI; } return __infnan( EDOM); } if (x >= 1.0 ) { if (x == 1.0) { return 0.0; } return __infnan( EDOM); } x = sqrt ((1.0 - x) / (1.0 + x)); __asm__ __volatile__ ("fpatan" :"=t" (x) : "0" (1.0), "u" (x)); return x + x; } ./libc-linux/sysdeps/linux/i386/math/sin.S100644 1676 334 1555 5471332213 16312 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. */ .file "sin.S" .text .globl _sin #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _sin: fldl 4(%esp) jmp L3 L1: fldpi fld %st(0) /* 2 pi */ faddp %st,%st(1) fxch %st(1) L2: fprem1 fstsw %ax sahf jp L2 fxch %st(1) fstp %st(0) L3: fsin fstsw %ax sahf jp L1 ret ./libc-linux/sysdeps/linux/i386/math/hypot.S100644 1676 334 1420 5342060417 16654 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. */ .file "hypot.S" .text .globl _hypot #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _hypot: fldl 4(%esp) fmull 4(%esp) fldl 12(%esp) fmull 12(%esp) faddp %st,%st(1) fsqrt ret ./libc-linux/sysdeps/linux/i386/math/tanh.S100644 1676 334 2430 5342060524 16444 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. */ .file "tanh.S" .data #ifdef __i486__ .align 4 #else .align 2 #endif LCW1: .word 0 #ifdef __i486__ .align 4 #else .align 2 #endif LCW2: .word 0 .text .globl _tanh #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _tanh: fldl 4(%esp) ftst fstsw %ax sahf jna Lneg fchs xorl %eax,%eax incl %eax jmp L1 Lneg: xorl %eax,%eax L1: fld %st(0) faddp %st,%st(1) fldl2e fmulp %st,%st(1) fst %st(1) fstcw LCW1 fstcw LCW2 fwait andw $0xf3ff,LCW1 fldcw LCW1 frndint fldcw LCW2 fst %st(2) fsubrp %st,%st(1) f2xm1 fld1 faddp %st,%st(1) fscale fst %st(1) fld1 faddp %st,%st(1) fxch %st(1) fld1 fsubrp %st,%st(1) fdivp %st,%st(1) testl %eax,%eax jna L2 fchs L2: ret ./libc-linux/sysdeps/linux/i386/math/sinh.S100644 1676 334 2322 5342060463 16455 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. */ .file "sinh.S" .data #ifdef __i486__ .align 4 #else .align 2 #endif LCW1: .word 0 #ifdef __i486__ .align 4 #else .align 2 #endif LCW2: .word 0 .text #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif LC2: .double 0d5.0000000000000000000000e-01 .globl _sinh #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _sinh: fldl 4(%esp) fldl2e fmulp %st,%st(1) fst %st(1) fstcw LCW1 fstcw LCW2 fwait andw $0xf3ff,LCW1 fldcw LCW1 frndint fldcw LCW2 fst %st(2) fsubrp %st,%st(1) f2xm1 fld1 faddp %st,%st(1) fscale fst %st(1) fld1 fdivp %st,%st(1) fsubrp %st,%st(1) fldl LC2 fmulp %st,%st(1) ret ./libc-linux/sysdeps/linux/i386/math/j0.c100644 1676 334 10144 5341614452 16070 0ustar hjlisl#include /* floating point Bessel's function of the first and second kinds of order zero j0(x) returns the value of J0(x) for all real values of x. There are no error returns. Calls sin, cos, sqrt. There is a niggling bug in J0 which causes errors up to 2e-16 for x in the interval [-8,8]. The bug is caused by an inappropriate order of summation of the series. rhm will fix it someday. Coefficients are from Hart & Cheney. #5849 (19.22D) #6549 (19.25D) #6949 (19.41D) y0(x) returns the value of Y0(x) for positive real values of x. For x<=0, error number EDOM is set and a large negative value is returned. Calls sin, cos, sqrt, log, j0. The values of Y0 have not been checked to more than ten places. Coefficients are from Hart & Cheney. #6245 (18.78D) #6549 (19.25D) #6949 (19.41D) */ static void asympt(double); static double pzero, qzero; static double tpi = .6366197723675813430755350535e0; static double pio4 = .7853981633974483096156608458e0; static double p1[] = { 0.4933787251794133561816813446e21, -.1179157629107610536038440800e21, 0.6382059341072356562289432465e19, -.1367620353088171386865416609e18, 0.1434354939140344111664316553e16, -.8085222034853793871199468171e13, 0.2507158285536881945555156435e11, -.4050412371833132706360663322e8, 0.2685786856980014981415848441e5, }; static double q1[] = { 0.4933787251794133562113278438e21, 0.5428918384092285160200195092e19, 0.3024635616709462698627330784e17, 0.1127756739679798507056031594e15, 0.3123043114941213172572469442e12, 0.6699987672982239671814028660e9, 0.1114636098462985378182402543e7, 0.1363063652328970604442810507e4, 1.0 }; static double p2[] = { 0.5393485083869438325262122897e7, 0.1233238476817638145232406055e8, 0.8413041456550439208464315611e7, 0.2016135283049983642487182349e7, 0.1539826532623911470917825993e6, 0.2485271928957404011288128951e4, 0.0, }; static double q2[] = { 0.5393485083869438325560444960e7, 0.1233831022786324960844856182e8, 0.8426449050629797331554404810e7, 0.2025066801570134013891035236e7, 0.1560017276940030940592769933e6, 0.2615700736920839685159081813e4, 1.0, }; static double p3[] = { -.3984617357595222463506790588e4, -.1038141698748464093880530341e5, -.8239066313485606568803548860e4, -.2365956170779108192723612816e4, -.2262630641933704113967255053e3, -.4887199395841261531199129300e1, 0.0, }; static double q3[] = { 0.2550155108860942382983170882e6, 0.6667454239319826986004038103e6, 0.5332913634216897168722255057e6, 0.1560213206679291652539287109e6, 0.1570489191515395519392882766e5, 0.4087714673983499223402830260e3, 1.0, }; static double p4[] = { -.2750286678629109583701933175e20, 0.6587473275719554925999402049e20, -.5247065581112764941297350814e19, 0.1375624316399344078571335453e18, -.1648605817185729473122082537e16, 0.1025520859686394284509167421e14, -.3436371222979040378171030138e11, 0.5915213465686889654273830069e8, -.4137035497933148554125235152e5, }; static double q4[] = { 0.3726458838986165881989980e21, 0.4192417043410839973904769661e19, 0.2392883043499781857439356652e17, 0.9162038034075185262489147968e14, 0.2613065755041081249568482092e12, 0.5795122640700729537480087915e9, 0.1001702641288906265666651753e7, 0.1282452772478993804176329391e4, 1.0, }; double j0(double arg) { double argsq, n, d; int i; if(arg < 0.) arg = -arg; if(arg > 8.){ asympt(arg); n = arg - pio4; return(sqrt(tpi/arg)*(pzero*cos(n) - qzero*sin(n))); } argsq = arg*arg; for(n=0,d=0,i=8;i>=0;i--){ n = n*argsq + p1[i]; d = d*argsq + q1[i]; } return(n/d); } double y0(double arg) { double argsq, n, d; int i; if(arg <= 0.){ return(-HUGE_VAL); } if(arg > 8.){ asympt(arg); n = arg - pio4; return(sqrt(tpi/arg)*(pzero*sin(n) + qzero*cos(n))); } argsq = arg*arg; for(n=0,d=0,i=8;i>=0;i--){ n = n*argsq + p4[i]; d = d*argsq + q4[i]; } return(n/d + tpi*j0(arg)*log(arg)); } static void asympt(double arg) { double zsq, n, d; int i; zsq = 64./(arg*arg); for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p2[i]; d = d*zsq + q2[i]; } pzero = n/d; for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p3[i]; d = d*zsq + q3[i]; } qzero = (8./arg)*(n/d); } ./libc-linux/sysdeps/linux/i386/math/j1.c100644 1676 334 10252 5341614461 16071 0ustar hjlisl#include /* floating point Bessel's function of the first and second kinds of order one j1(x) returns the value of J1(x) for all real values of x. There are no error returns. Calls sin, cos, sqrt. There is a niggling bug in J1 which causes errors up to 2e-16 for x in the interval [-8,8]. The bug is caused by an inappropriate order of summation of the series. rhm will fix it someday. Coefficients are from Hart & Cheney. #6050 (20.98D) #6750 (19.19D) #7150 (19.35D) y1(x) returns the value of Y1(x) for positive real values of x. For x<=0, error number EDOM is set and a large negative value is returned. Calls sin, cos, sqrt, log, j1. The values of Y1 have not been checked to more than ten places. Coefficients are from Hart & Cheney. #6447 (22.18D) #6750 (19.19D) #7150 (19.35D) */ static void asympt(double); static double pzero, qzero; static double tpi = .6366197723675813430755350535e0; static double pio4 = .7853981633974483096156608458e0; static double p1[] = { 0.581199354001606143928050809e21, -.6672106568924916298020941484e20, 0.2316433580634002297931815435e19, -.3588817569910106050743641413e17, 0.2908795263834775409737601689e15, -.1322983480332126453125473247e13, 0.3413234182301700539091292655e10, -.4695753530642995859767162166e7, 0.2701122710892323414856790990e4, }; static double q1[] = { 0.1162398708003212287858529400e22, 0.1185770712190320999837113348e20, 0.6092061398917521746105196863e17, 0.2081661221307607351240184229e15, 0.5243710262167649715406728642e12, 0.1013863514358673989967045588e10, 0.1501793594998585505921097578e7, 0.1606931573481487801970916749e4, 1.0, }; static double p2[] = { -.4435757816794127857114720794e7, -.9942246505077641195658377899e7, -.6603373248364939109255245434e7, -.1523529351181137383255105722e7, -.1098240554345934672737413139e6, -.1611616644324610116477412898e4, 0.0, }; static double q2[] = { -.4435757816794127856828016962e7, -.9934124389934585658967556309e7, -.6585339479723087072826915069e7, -.1511809506634160881644546358e7, -.1072638599110382011903063867e6, -.1455009440190496182453565068e4, 1.0, }; static double p3[] = { 0.3322091340985722351859704442e5, 0.8514516067533570196555001171e5, 0.6617883658127083517939992166e5, 0.1849426287322386679652009819e5, 0.1706375429020768002061283546e4, 0.3526513384663603218592175580e2, 0.0, }; static double q3[] = { 0.7087128194102874357377502472e6, 0.1819458042243997298924553839e7, 0.1419460669603720892855755253e7, 0.4002944358226697511708610813e6, 0.3789022974577220264142952256e5, 0.8638367769604990967475517183e3, 1.0, }; static double p4[] = { -.9963753424306922225996744354e23, 0.2655473831434854326894248968e23, -.1212297555414509577913561535e22, 0.2193107339917797592111427556e20, -.1965887462722140658820322248e18, 0.9569930239921683481121552788e15, -.2580681702194450950541426399e13, 0.3639488548124002058278999428e10, -.2108847540133123652824139923e7, 0.0, }; static double q4[] = { 0.5082067366941243245314424152e24, 0.5435310377188854170800653097e22, 0.2954987935897148674290758119e20, 0.1082258259408819552553850180e18, 0.2976632125647276729292742282e15, 0.6465340881265275571961681500e12, 0.1128686837169442121732366891e10, 0.1563282754899580604737366452e7, 0.1612361029677000859332072312e4, 1.0, }; double j1(double arg) { double xsq, n, d, x; int i; x = arg; if(x < 0.) x = -x; if(x > 8.){ asympt(x); n = x - 3.*pio4; n = sqrt(tpi/x)*(pzero*cos(n) - qzero*sin(n)); if(arg <0.) n = -n; return(n); } xsq = x*x; for(n=0,d=0,i=8;i>=0;i--){ n = n*xsq + p1[i]; d = d*xsq + q1[i]; } return(arg*n/d); } double y1(double arg) { double xsq, n, d, x; int i; x = arg; if(x <= 0.){ return(-HUGE_VAL); } if(x > 8.){ asympt(x); n = x - 3*pio4; return(sqrt(tpi/x)*(pzero*sin(n) + qzero*cos(n))); } xsq = x*x; for(n=0,d=0,i=9;i>=0;i--){ n = n*xsq + p4[i]; d = d*xsq + q4[i]; } return(x*n/d + tpi*(j1(x)*log(x)-1./x)); } static void asympt(double arg) { double zsq, n, d; int i; zsq = 64./(arg*arg); for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p2[i]; d = d*zsq + q2[i]; } pzero = n/d; for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p3[i]; d = d*zsq + q3[i]; } qzero = (8./arg)*(n/d); } ./libc-linux/sysdeps/linux/i386/math/jn.c100644 1676 334 3121 5341614407 16143 0ustar hjlisl#include /* floating point Bessel's function of the first and second kinds and of integer order. int n; double x; jn(n,x); returns the value of Jn(x) for all integer values of n and all real values of x. There are no error returns. Calls j0, j1. For n=0, j0(x) is called, for n=1, j1(x) is called, for nx, a continued fraction approximation to j(n,x)/j(n-1,x) is evaluated and then backward recursion is used starting from a supposed value for j(n,x). The resulting value of j(0,x) is compared with the actual value to correct the supposed value of j(n,x). yn(n,x) is similar in all respects, except that forward recursion is used for all values of n>1. */ double jn(int n, double x) { int i; double a, b, temp; double xsq, t; if(n<0){ n = -n; x = -x; } if(n==0) return(j0(x)); if(n==1) return(j1(x)); if(x == 0.) return(0.); if(n>x) goto recurs; a = j0(x); b = j1(x); for(i=1;in;i--){ t = xsq/(2.*i - t); } t = x/(2.*n-t); a = t; b = 1; for(i=n-1;i>0;i--){ temp = b; b = (2.*i/x)*b - a; a = temp; } return(t*j0(x)/b); } double yn(int n, double x) { int i; int sign; double a, b, temp; if (x <= 0) { return(-HUGE_VAL); } sign = 1; if(n<0){ n = -n; if(n%2 == 1) sign = -1; } if(n==0) return(y0(x)); if(n==1) return(sign*y1(x)); a = y0(x); b = y1(x); for(i=1;i #endif #if defined(vax)||defined(tahoe) #include #endif /* defined(vax)||defined(tahoe) */ int signgam = 0; static const double goobie = 0.9189385332046727417803297; /* log(2*pi)/2 */ static const double pi = 3.1415926535897932384626434; #define M 6 #define N 8 static const double p1[] = { 0.83333333333333101837e-1, -.277777777735865004e-2, 0.793650576493454e-3, -.5951896861197e-3, 0.83645878922e-3, -.1633436431e-2, }; static const double p2[] = { -.42353689509744089647e5, -.20886861789269887364e5, -.87627102978521489560e4, -.20085274013072791214e4, -.43933044406002567613e3, -.50108693752970953015e2, -.67449507245925289918e1, 0.0, }; static const double q2[] = { -.42353689509744090010e5, -.29803853309256649932e4, 0.99403074150827709015e4, -.15286072737795220248e4, -.49902852662143904834e3, 0.18949823415702801641e3, -.23081551524580124562e2, 0.10000000000000000000e1, }; static double pos(double), neg(double), asym(double); double lgamma(double arg) { signgam = 1.; if(arg <= 0.) return(neg(arg)); if(arg > 8.) return(asym(arg)); return(log(pos(arg))); } static double asym(double arg) { double n, argsq; int i; argsq = 1./(arg*arg); for(n=0,i=M-1; i>=0; i--){ n = n*argsq + p1[i]; } return((arg-.5)*log(arg) - arg + goobie + n/arg); } static double neg(double arg) { double t; arg = -arg; /* * to see if arg were a true integer, the old code used the * mathematically correct observation: * sin(n*pi) = 0 <=> n is an integer. * but in finite precision arithmetic, sin(n*PI) will NEVER * be zero simply because n*PI is a rational number. hence * it failed to work with our newer, more accurate sin() * which uses true pi to do the argument reduction... * temp = sin(pi*arg); */ t = floor(arg); if (arg - t > 0.5e0) t += 1.e0; /* t := integer nearest arg */ #if defined(vax)||defined(tahoe) if (arg == t) { return(infnan(ERANGE)); /* +INF */ } #endif /* defined(vax)||defined(tahoe) */ signgam = (int) (t - 2*floor(t/2)); /* signgam = 1 if t was odd, */ /* 0 if t was even */ signgam = signgam - 1 + signgam; /* signgam = 1 if t was odd, */ /* -1 if t was even */ t = arg - t; /* -0.5 <= t <= 0.5 */ if (t < 0.e0) { t = -t; signgam = -signgam; } return(-log(arg*pos(arg)*sin(pi*t)/pi)); } static double pos(double arg) { double n, d, s; register i; if(arg < 2.) return(pos(arg+1.)/arg); if(arg > 3.) return((arg-1.)*pos(arg-1.)); s = arg - 2.; for(n=0,d=0,i=N-1; i>=0; i--){ n = n*s + p2[i]; d = d*s + q2[i]; } return(n/d); } ./libc-linux/sysdeps/linux/i386/math/fmod.S100644 1676 334 1671 5342060365 16450 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. */ .file "fmod.S" .text .globl _fmod #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _fmod: fldl 4(%esp) ftst fnstsw %ax sahf jz zero1 fldl 12(%esp) ftst fnstsw %ax sahf jz zero2 fxch %st(1) loop: fprem fnstsw %ax sahf jpe loop fstp %st(1) ret #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif zero2: fstp %st(0) zero1: ret ./libc-linux/sysdeps/linux/i386/math/ceil.c100644 1676 334 1664 5341615347 16466 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 double ceil (double x) { volatile short cw, cwtmp; __asm__ volatile ("fnstcw %0" : "=m" (cw) : ); /* rounding up */ cwtmp = (cw & 0xf3ff) | 0x0800; __asm__ volatile ("fldcw %0" : : "m" (cwtmp)); /* x = ceil of x */ __asm__ volatile ("frndint" : "=t" (x) : "0" (x)); __asm__ volatile ("fldcw %0" : : "m" (cw)); return (x); } ./libc-linux/sysdeps/linux/i386/math/floor.c100644 1676 334 1670 5341615255 16666 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 double floor (double x) { volatile short cw, cwtmp; __asm__ volatile ("fnstcw %0" : "=m" (cw) : ); /* rounding down */ cwtmp = (cw & 0xf3ff) | 0x0400; __asm__ volatile ("fldcw %0" : : "m" (cwtmp)); /* x = floor of x */ __asm__ volatile ("frndint" : "=t" (x) : "0" (x)); __asm__ volatile ("fldcw %0" : : "m" (cw)); return (x); } ./libc-linux/sysdeps/linux/i386/math/erf.c100644 1676 334 5066 5341644022 16316 0ustar hjlisl/* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if 0 #ifndef lint static char sccsid[] = "@(#)erf.c 5.2 (Berkeley) 4/29/88"; #endif /* not lint */ #endif /* C program for floating point error function erf(x) returns the error function of its argument erfc(x) returns 1.0-erf(x) erf(x) is defined by ${2 over sqrt(pi)} int from 0 to x e sup {-t sup 2} dt$ the entry for erfc is provided because of the extreme loss of relative accuracy if erf(x) is called for large x and the result subtracted from 1. (e.g. for x= 10, 12 places are lost). There are no error returns. Calls exp. Coefficients for large x are #5667 from Hart & Cheney (18.72D). */ #include #define M 7 #define N 9 static double torp = 1.1283791670955125738961589031; static double p1[] = { 0.804373630960840172832162e5, 0.740407142710151470082064e4, 0.301782788536507577809226e4, 0.380140318123903008244444e2, 0.143383842191748205576712e2, -.288805137207594084924010e0, 0.007547728033418631287834e0, }; static double q1[] = { 0.804373630960840172826266e5, 0.342165257924628539769006e5, 0.637960017324428279487120e4, 0.658070155459240506326937e3, 0.380190713951939403753468e2, 0.100000000000000000000000e1, 0.0, }; static double p2[] = { 0.18263348842295112592168999e4, 0.28980293292167655611275846e4, 0.2320439590251635247384768711e4, 0.1143262070703886173606073338e4, 0.3685196154710010637133875746e3, 0.7708161730368428609781633646e2, 0.9675807882987265400604202961e1, 0.5641877825507397413087057563e0, 0.0, }; static double q2[] = { 0.18263348842295112595576438e4, 0.495882756472114071495438422e4, 0.60895424232724435504633068e4, 0.4429612803883682726711528526e4, 0.2094384367789539593790281779e4, 0.6617361207107653469211984771e3, 0.1371255960500622202878443578e3, 0.1714980943627607849376131193e2, 1.0, }; double erf(double arg) { int sign; double argsq; double d, n; int i; sign = 1; if(arg < 0.){ arg = -arg; sign = -1; } if(arg < 0.5){ argsq = arg*arg; for(n=0,d=0,i=M-1; i>=0; i--){ n = n*argsq + p1[i]; d = d*argsq + q1[i]; } return(sign*torp*arg*n/d); } if(arg >= 10.) return(sign*1.); return(sign*(1. - erfc(arg))); } double erfc(double arg) { double n, d; int i; if(arg < 0.) return(2. - erfc(-arg)); /* if(arg < 0.5) return(1. - erf(arg)); */ if(arg >= 10.) return(0.); for(n=0,d=0,i=N-1; i>=0; i--){ n = n*arg + p2[i]; d = d*arg + q2[i]; } return(exp(-arg*arg)*n/d); } ./libc-linux/sysdeps/linux/i386/math/fabs.S100644 1676 334 1314 5342060346 16427 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. */ .file "fabs.S" .text .globl _fabs #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _fabs: fldl 4(%esp) fabs ret ./libc-linux/sysdeps/linux/i386/math/acosh.c100644 1676 334 1617 5377510517 16647 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(acosh, (x), double x) { if (x <= 1.0 ) { if (x == 1.0) return 0.0; return __infnan( EDOM); } x = x + sqrt (x * x - 1.0); __asm__ __volatile__ ("fldln2\n\t" "fxch %%st(1)\n\t" "fyl2x" :"=t" (x) : "0" (x)); return x; } ./libc-linux/sysdeps/linux/i386/math/atan2.S100644 1676 334 1337 5342057771 16536 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. */ .file "atan2.S" .text .globl _atan2 #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _atan2: fldl 4(%esp) fldl 12(%esp) fpatan ret ./libc-linux/sysdeps/linux/i386/math/cosh.S100644 1676 334 2334 5342060066 16452 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. */ .file "cosh.S" .data #ifdef __i486__ .align 4 #else .align 2 #endif LCW1: .word 0 #ifdef __i486__ .align 4 #else .align 2 #endif LCW2: .word 0 .text #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif LC2: .double 0d5.0000000000000000000000e-01 .globl _cosh #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _cosh: fldl 4(%esp) fldl2e fmulp %st,%st(1) fst %st(1) fstcw LCW1 fstcw LCW2 fwait andw $0xf3ff,LCW1 fldcw LCW1 frndint fldcw LCW2 fst %st(2) fsubrp %st,%st(1) f2xm1 fld1 faddp %st,%st(1) fscale fst %st(1) fld1 fdivp %st,%st(1) faddp %st,%st(1) fldl LC2 fmulp %st,%st(1) ret ./libc-linux/sysdeps/linux/i386/math/test-math.c100644 1676 334 3413 5342067007 17445 0ustar hjlisl#include #include #include #include int DEFUN_VOID(main) { CONST char str[] = "123.456"; double x,h,li,lr,a,lrr, y; x = atof (str); printf ("%g %g\n", x, pow (10.0, 3.0)); x = 0.5; y = cos (x); printf("cos (%g) = %g\n", x, y); x = acos (y); printf("acos (%g) = %g\n", y, x); y = sin (x); printf("sin (%g) = %g\n", x, y); x = asin (y); printf("asin (%g) = %g\n", y, x); x = cosh(2.0); printf("cosh(2.0) = %g\n", x); printf("cosh(%g) = 2.0\n", acosh (x)); x = sinh(2.0); printf("sinh(2.0) = %g\n", x); printf("sinh(%g) = 2.0\n", asinh (x)); x = sinh(3.0); printf("sinh(3.0) = %g\n", x); h = hypot(2.0,3.0); printf("h=%g\n", h); a = atan2(3.0, 2.0); printf("atan2(3,2) = %g\n", a); lr = pow(h,4.0); printf("pow(%g,4.0) = %g\n", h, lr); printf("pow2(4.0) = %g\n", pow2 (4.0)); lrr = lr; li = 4.0 * a; lr = lr / exp(a*5.0); printf("%g / exp(%g * 5) = %g\n", lrr, exp(a*5.0), lr); lrr = li; li += 5.0 * log(h); printf("%g + 5*log(%g) = %g\n", lrr, h, li); printf("cos(%g) = %g, sin(%g) = %g\n", li, cos(li), li, sin(li)); x = drem(10.3435,6.2831852); printf("drem(10.3435,6.2831852) = %g\n", x); x = drem(-10.3435,6.2831852); printf("drem(-10.3435,6.2831852) = %g\n", x); x = drem(-10.3435,-6.2831852); printf("drem(-10.3435,-6.2831852) = %g\n", x); x = drem(10.3435,-6.2831852); printf("drem(10.3435,-6.2831852) = %g\n", x); printf("x%8.6gx\n", .5); printf("x%-8.6gx\n", .5); printf("x%6.6gx\n", .5); { double x = atof ("-1e-17-"); printf ("%g %c= %g %s!\n", x, x == -1e-17 ? '=' : '!', -1e-17, x == -1e-17 ? "Worked" : "Failed"); } return 0; } ./libc-linux/sysdeps/linux/i386/math/__copysign.c100644 1676 334 2224 5346331100 17657 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 "ieee754.h" /* Return X with its signed changed to Y's. */ double DEFUN(__copysign, (x, y), double x AND double y) { union ieee754_double *ux = (union ieee754_double *) &x; union ieee754_double *uy = (union ieee754_double *) &y; ux->ieee.negative = uy->ieee.negative; return x; } ./libc-linux/sysdeps/linux/i386/math/__drem.S100644 1676 334 1676 5346331100 16745 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. */ .file "__drem.S" .text .globl ___drem #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif ___drem: fldl 4(%esp) ftst fnstsw %ax sahf je zero1 fldl 12(%esp) ftst fnstsw %ax sahf je zero2 fxch %st(1) loop: fprem1 fnstsw %ax sahf jpe loop fstp %st(1) ret #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif zero2: fstp %st(0) zero1: ret ./libc-linux/sysdeps/linux/i386/math/__infnan.c100644 1676 334 2735 5377515344 17326 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 #include #include "ieee754.h" /* Deal with an infinite or NaN result. If ERROR is ERANGE, result is +Inf; if ERROR is - ERANGE, result is -Inf; otherwise result is NaN. This will set `errno' to either ERANGE or EDOM, and may return an infinity or NaN, or may do something else. */ double DEFUN(__infnan, (error), int error) { switch (error) { case ERANGE: errno = ERANGE; return HUGE_VAL; case - ERANGE: errno = ERANGE; return - HUGE_VAL; default: errno = EDOM; #ifdef _SNAN return _SNAN; #else return NAN; #endif } } ./libc-linux/sysdeps/linux/i386/math/__isinf.c100644 1676 334 2525 5346331101 17141 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 "ieee754.h" #undef __isinf /* Return 0 if VALUE is finite or NaN, +1 if it is +Infinity, -1 if it is -Infinity. */ int DEFUN(__isinf, (value), double value) { union ieee754_double *u = (union ieee754_double *) &value; /* An IEEE 754 infinity has an exponent with the maximum possible value and a zero mantissa. */ if ((u->ieee.exponent & 0x7ff) == 0x7ff && u->ieee.mantissa0 == 0 && u->ieee.mantissa1 == 0) return u->ieee.negative ? -1 : 1; return 0; } ./libc-linux/sysdeps/linux/i386/math/__isnan.c100644 1676 334 2352 5346331101 17137 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 "ieee754.h" #undef __isnan /* Return nonzero if VALUE is not a number. */ int DEFUN(__isnan, (value), double value) { union ieee754_double *u = (union ieee754_double *) &value; /* IEEE 754 NaN's have the maximum possible exponent and a nonzero mantissa. */ return ((u->ieee.exponent & 0x7ff) == 0x7ff && (u->ieee.mantissa0 != 0 || u->ieee.mantissa1 != 0)); } ./libc-linux/sysdeps/linux/i386/math/__rint.c100644 1676 334 1411 5346331101 16776 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 /* Return integer nearest x in direction of prevailing rounding * mode. */ double __rint (double x) { __asm__ volatile ("frndint" : "=t" (x) : "0" (x)); return (x); } ./libc-linux/sysdeps/linux/i386/math/expm1.S100644 1676 334 2464 5465070700 16556 0ustar hjlisl/* ** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 ** ** Modified O.ROBERT 24, Avenue de Verdun 92170 VANVES, FRANCE ** ** E-mail: roberto@germinal.ibp.fr ** ** This file is distributed under the terms listed in the document ** "copying.dj", available from DJ Delorie at the address above. ** A copy of "copying.dj" should accompany this file; if not, a copy ** should be available from where this file was obtained. This file ** may not be distributed without a verbatim copy of "copying.dj". ** ** This file is distributed WITHOUT ANY WARRANTY; without even the implied ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ** ** or 03-Apr-1991 corrected bug about argument zero to pow ** fyl2x didn't like it */ /* Modified by H.J. Lu for Linux, 1992 */ /* History:15,24 */ .file "expm1.S" .data #ifdef __i486__ .align 4 #else .align 2 #endif LCW1: .word 0 #ifdef __i486__ .align 4 #else .align 2 #endif LCW2: .word 0 .text .globl _expm1 #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif _expm1: fldl 4(%esp) fldl2e fmulp %st,%st(1) fstcw LCW1 fstcw LCW2 andw $0xf3ff,LCW1 fldcw LCW1 fldl %st(0) frndint fldcw LCW2 fxch %st(1) fsub %st(1),%st f2xm1 fscale fxch %st(1) fld1 fscale fld1 fsubp %st,%st(1) fstp %st(1) fsubrp %st,%st(1) ret ./libc-linux/sysdeps/linux/i386/math/log1p.c100644 1676 334 2413 5501724331 16555 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 static inline double domain ( double x) { /* perror("log"); */ if (x < -1.0) return __infnan( EDOM); else /* i.e. x == -1.0 */ return __infnan(-ERANGE); } double DEFUN(log1p, (x), double x) { if (x <= -1.0) return domain (x); #ifndef CYRIX_83D87 /* lousy 387 can only handle abs(x) < 1-sqrt(2)/2 in fly2xp1. */ if (fabs (x) < 0.2929) { #endif __asm__ __volatile__ ("fldln2\n\t" "fxch %%st(1)\n\t" "fyl2xp1" :"=t" (x) : "0" (x)); #ifndef CYRIX_83D87 } else { x += 1.0; __asm__ __volatile__ ("fldln2\n\t" "fxch %%st(1)\n\t" "fyl2x" :"=t" (x) : "0" (x)); } #endif return x; } ./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/__setfpucw.c100644 1676 334 2034 5443671071 16746 0ustar hjlisl/* Copyright (C) 1993 Olaf Flebbe 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 void __setfpucw(unsigned short fpu_control) { volatile unsigned short cw; /* If user supplied _fpu_control, use it ! */ if (!fpu_control) { /* use linux defaults */ fpu_control = _FPU_DEFAULT; } /* Get Control Word */ __asm__ volatile ("fnstcw %0" : "=m" (cw) : ); /* mask in */ cw &= _FPU_RESERVED; cw = cw | (fpu_control & ~_FPU_RESERVED); /* set cw */ __asm__ volatile ("fldcw %0" :: "m" (cw)); } ./libc-linux/sysdeps/linux/i386/__fpu_control.c100644 1676 334 42 5443666571 17406 0ustar hjlislunsigned short __fpu_control = 0; ./libc-linux/sysdeps/linux/i386/ieee.c100644 1676 334 104 5443672131 15471 0ustar hjlisl#include unsigned short __fpu_control = _FPU_IEEE; ./libc-linux/sysdeps/linux/i386/crt/ 40755 1676 334 0 5527716350 15143 5ustar hjlisl./libc-linux/sysdeps/linux/i386/crt/Makefile100644 1676 334 1044 5527713102 16667 0ustar hjlisl# # Makefile for crt0.o of Linux # # LD=true MV=true override STATIC_SHARED=false override SHARED=false override DEBUG=false TOPDIR=../../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules CFLAGS= DEBUG_CFLAGS= PROFILE_CFLAGS= CHECKER_CFLAGS= ifeq ($(CHECKER),true) lib:: $(CHECKER_DIR)/chkrcrt0.o endif ifeq ($(PROFILE),true) lib:: $(PROFILE_DIR)/gcrt0.o endif ifeq ($(STATIC),true) lib:: $(STATIC_DIR)/crt0.o endif lib:: @true realclean clean: $(RM) -f core *.s *.o *.a tmp_make foo depend: @echo No dependency in `pwd`. ./libc-linux/sysdeps/linux/i386/crt/gcrt0.S100644 1676 334 7576 5523014674 16416 0ustar hjlisl/* * Copyright (c) 1993 Eric Youngdale, Peter MacDonald, David Engel * and Hongjiu Lu. * * 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Eric Youngdale, * Peter MacDonald, David Engel and Hongjiu Lu. * 3. The name of the above contributors may not be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 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. */ /* Notice of general intent: * * The linux operating system generally contains large amounts of code * that fall under the GNU General Public License, or GPL for short. * This file contains source code that by it's very nature would always * be linked with an application program, and because of this a GPL type * of copyright on this file would place restrictions upon the * distribution of binary-only commercial software. Since the goal of the * Linux project as a whole is not to discourage the development and * distribution of commercial software for Linux, this file has been placed * under a more relaxed BSD-style of copyright. * * It is the general understanding of the above contributors that a * program executable linked to a library containing code that falls * under the GPL or GLPL style of license is not subject to the terms of * the GPL or GLPL license if the program executable(s) that are supplied * are linked to a shared library form of the GPL or GLPL library, and as long * as the form of the shared library is such that it is possible for * the end user to modify and rebuild the library and use it in * conjunction with the program executable. */ .file "gcrt0.S" .text __entry: /* * The first thing we do is try to load the shared library. If that * fails, it won't return. */ call ___load_shared_libraries /* * This is important, and was missing from the new version... */ movl $45,%eax movl $0,%ebx int $0x80 movl %eax,____brk_addr /* * Setup profiling */ pushl $__mcleanup call _atexit addl $4,%esp pushl $_etext pushl $__entry call _monstartup addl $8,%esp /* * Setup ___environ and call _main */ movl 8(%esp),%eax movl %eax,___environ movzwl ___fpu_control,%eax pushl %eax call ___setfpucw addl $4,%esp /* Some functions may be needed. */ call ___libc_init call _main pushl %eax call _exit /* * Just in case _exit fails... We use int $0x80 for __exit(). */ popl %ebx done: movl $1,%eax int $0x80 jmp done #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif ___shared_dummy__: .asciz "" .stabs "___SHARED_LIBRARIES__",25,0,0,___shared_dummy__ .data #ifdef __i486__ .align 4 #else .align 2 #endif ___shared_dummy1__: .long 0xfeeb1ed3 /* Magic number used by DLL code to make sure this is a real list */ .stabs "__SHARABLE_CONFLICTS__",25,0,0,___shared_dummy1__ ./libc-linux/sysdeps/linux/i386/crt/crt0.S100644 1676 334 7374 5523014650 16235 0ustar hjlisl/* * Copyright (c) 1993 Eric Youngdale, Peter MacDonald, David Engel * and Hongjiu Lu. * * 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Eric Youngdale, * Peter MacDonald, David Engel and Hongjiu Lu. * 3. The name of the above contributors may not be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 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. */ /* Notice of general intent: * * The linux operating system generally contains large amounts of code * that fall under the GNU General Public License, or GPL for short. * This file contains source code that by it's very nature would always * be linked with an application program, and because of this a GPL type * of copyright on this file would place restrictions upon the * distribution of binary-only commercial software. Since the goal of the * Linux project as a whole is not to discourage the development and * distribution of commercial software for Linux, this file has been placed * under a more relaxed BSD-style of copyright. * * It is the general understanding of the above contributors that a * program executable linked to a library containing code that falls * under the GPL or GLPL style of license is not subject to the terms of * the GPL or GLPL license if the program executable(s) that are supplied * are linked to a shared library form of the GPL or GLPL library, and as long * as the form of the shared library is such that it is possible for * the end user to modify and rebuild the library and use it in * conjunction with the program executable. */ .file "crt0.S" .text __entry: /* * The first thing we do is try to load the shared library. If that * fails, it won't return. */ call ___load_shared_libraries /* * This is important, and was missing from the new version... */ movl $45,%eax movl $0,%ebx int $0x80 movl %eax,____brk_addr /* * ok, set up the ___environ and call _main */ movl 8(%esp),%eax movl %eax,___environ movzwl ___fpu_control,%eax pushl %eax call ___setfpucw addl $4,%esp /* Some functions may be needed. */ call ___libc_init call _main pushl %eax call _exit /* * Just in case _exit fails... We use int $0x80 for __exit(). */ popl %ebx done: movl $1,%eax int $0x80 jmp done #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif ___shared_dummy__: .asciz "" .stabs "___SHARED_LIBRARIES__",25,0,0,___shared_dummy__ .data #ifdef __i486__ .align 4 #else .align 2 #endif ___shared_dummy1__: .long 0xfeeb1ed3 /* Magic number used by DLL code to make sure this is a real list */ .stabs "__SHARABLE_CONFLICTS__",25,0,0,___shared_dummy1__ ./libc-linux/sysdeps/linux/i386/crt/chkrcrt0.S100644 1676 334 7214 5523014735 17102 0ustar hjlisl/* * Copyright (c) 1993 Eric Youngdale, Peter MacDonald, David Engel * and Hongjiu Lu. * * 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Eric Youngdale, * Peter MacDonald, David Engel and Hongjiu Lu. * 3. The name of the above contributors may not be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 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. */ /* Notice of general intent: * * The linux operating system generally contains large amounts of code * that fall under the GNU General Public License, or GPL for short. * This file contains source code that by it's very nature would always * be linked with an application program, and because of this a GPL type * of copyright on this file would place restrictions upon the * distribution of binary-only commercial software. Since the goal of the * Linux project as a whole is not to discourage the development and * distribution of commercial software for Linux, this file has been placed * under a more relaxed BSD-style of copyright. * * It is the general understanding of the above contributors that a * program executable linked to a library containing code that falls * under the GPL or GLPL style of license is not subject to the terms of * the GPL or GLPL license if the program executable(s) that are supplied * are linked to a shared library form of the GPL or GLPL library, and as long * as the form of the shared library is such that it is possible for * the end user to modify and rebuild the library and use it in * conjunction with the program executable. */ /* Changes by Tristan Gingold * does not handle the shared libraries * call __chkr_init_chkr before main */ .file "chkrcrt0.S" .text __entry: /* * This is important, and was missing from the new version... */ movl $45,%eax movl $0,%ebx int $0x80 movl %eax,____brk_addr /* * ok, set up the 387 flags and ___environ. */ fldcw init_cw movl 8(%esp),%eax movl %eax,___environ /* * The next thing we do is initialize Checker. * Because 387 flags are set, Checker can use the FPU. */ call ___chkr_init_chkr /* * Now we can call __setfpucw and _main */ movzwl ___fpu_control,%eax pushl %eax call ___setfpucw addl $4,%esp /* Some functions may be needed. */ call ___libc_init call _main pushl %eax call _exit /* * Just in case _exit fails... We use int $0x80 for __exit(). */ popl %ebx done: movl $1,%eax int $0x80 jmp done #ifdef __i486__ .align 4,0x90 #else .align 2,0x90 #endif init_cw: .word 0x1372 ./libc-linux/sysdeps/linux/i386/gmon/ 40755 1676 334 0 5533715362 15312 5ustar hjlisl./libc-linux/sysdeps/linux/i386/gmon/Makefile100644 1676 334 654 5533716027 17033 0ustar hjlisl# # This is Makefile of gmon for Linux # # TOPDIR=../../../.. override STATIC=false override SHARED=false override DEBUG=false override CHECKER=false # That is fake for SUBDIR. JUMP_LIB=libgmon PROFILE_OPT_CFLAGS=-O6 include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules PROFILE_LIB=$(TOPDIR)/profile/libgmon.a DIRS= SRCS=gmon.c profil.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/sysdeps/linux/i386/gmon/README100644 1676 334 2076 5217410535 16265 0ustar hjlislHere is a package to use profiling on Linux. It contains the following files: -rw-r--r-- 1 jrs user 3410 Jun 14 00:52 profil.patch patches to Linux v0.96a patchlevel 2 kernel for profiling -rw-r--r-- 1 jrs user 236 Jun 14 01:21 Makefile sample makefile for using profiling with an earlier version of GCC. -rw-r--r-- 1 jrs user 1721 Jun 14 00:45 gcrt0.s -rw-r--r-- 1 jrs user 542 Jun 14 01:21 gcrt0.o source and object of the startup file for programs using -pg profiling -rw-r--r-- 1 jrs user 9050 Jun 14 00:45 gmon.c -rw-r--r-- 1 jrs user 3582 Jun 14 00:45 gmon.h -rw-r--r-- 1 jrs user 107 Jun 14 00:45 profil.c -rw-r--r-- 1 jrs user 2932 Jun 14 01:21 libgmon.a profile assist code which belongs in libc.a and libc_p.a -rw-r--r-- 1 jrs user 965 Jun 14 00:56 gprof.patch -rwxr-xr-x 1 jrs user 78848 Jun 14 01:12 gprof* small patches and a binary of GNU gprof as found in binutils-1.9.tar.Z Rick Sladkey jrs@world.std.com ./libc-linux/sysdeps/linux/i386/gmon/gmon.c100644 1676 334 21601 5270352402 16521 0ustar hjlisl/*- * Copyright (c) 1991 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 0 #ifndef lint static char sccsid[] = "@(#)gmon.c 5.3 (Berkeley) 5/22/91"; #endif /* not lint */ #endif #include #include #include #ifdef DEBUG #include #endif #include "gmon.h" extern void mcount(); /* asm ("mcount"); */ /* extern */ char *minbrk; /* asm ("_minbrk"); */ /* * froms is actually a bunch of unsigned shorts indexing tos */ static int profiling = 3; static unsigned short *froms; static struct tostruct *tos = 0; static long tolimit = 0; static char *s_lowpc = 0; static char *s_highpc = 0; static unsigned long s_textsize = 0; static int ssiz; static char *sbuf; static int s_scale; /* see profil(2) where this is describe (incorrectly) */ #define SCALE_1_TO_1 0x10000L /* * Control profiling * profiling is what mcount checks to see if * all the data structures are ready. */ void moncontrol(mode) int mode; { int ret; static int warned = 0; if (mode) { /* start */ ret = profil(sbuf + sizeof(struct phdr), ssiz - sizeof(struct phdr), (int)s_lowpc, s_scale); if (ret < 0 && errno == ENOSYS && !warned) { # define PROFIL_WARN "warning: kernel does not support profiling\n" write(2, PROFIL_WARN, sizeof(PROFIL_WARN)); warned = 1; } profiling = 0; } else { /* stop */ profil((char *)0, 0, 0, 0); profiling = 3; } } #define MSG "No space for profiling buffer(s)\n" void monstartup(lowpc, highpc) char *lowpc; char *highpc; { int monsize; char *buffer; register int o; /* * round lowpc and highpc to multiples of the density we're using * so the rest of the scaling (here and in gprof) stays in ints. */ lowpc = (char *) ROUNDDOWN((unsigned)lowpc, HISTFRACTION*sizeof(HISTCOUNTER)); s_lowpc = lowpc; highpc = (char *) ROUNDUP((unsigned)highpc, HISTFRACTION*sizeof(HISTCOUNTER)); s_highpc = highpc; s_textsize = highpc - lowpc; monsize = (s_textsize / HISTFRACTION) + sizeof(struct phdr); buffer = (char *) sbrk( monsize ); if ( buffer == (char *) -1 ) { write( 2 , MSG , sizeof(MSG) ); return; } froms = (unsigned short *) sbrk( s_textsize / HASHFRACTION ); if ( froms == (unsigned short *) -1 ) { write( 2 , MSG , sizeof(MSG) ); froms = 0; return; } tolimit = s_textsize * ARCDENSITY / 100; if ( tolimit < MINARCS ) { tolimit = MINARCS; } else if ( tolimit > 65534 ) { tolimit = 65534; } tos = (struct tostruct *) sbrk( tolimit * sizeof( struct tostruct ) ); if ( tos == (struct tostruct *) -1 ) { write( 2 , MSG , sizeof(MSG) ); froms = 0; tos = 0; return; } minbrk = (char *) sbrk(0); tos[0].link = 0; sbuf = buffer; ssiz = monsize; ( (struct phdr *) buffer ) -> lpc = lowpc; ( (struct phdr *) buffer ) -> hpc = highpc; ( (struct phdr *) buffer ) -> ncnt = ssiz; monsize -= sizeof(struct phdr); if ( monsize <= 0 ) return; o = highpc - lowpc; if( monsize < o ) #ifndef hp300 s_scale = ( (float) monsize / o ) * SCALE_1_TO_1; #else /* avoid floating point */ { int quot = o / monsize; if (quot >= 0x10000) s_scale = 1; else if (quot >= 0x100) s_scale = 0x10000 / quot; else if (o >= 0x800000) s_scale = 0x1000000 / (o / (monsize >> 8)); else s_scale = 0x1000000 / ((o << 8) / monsize); } #endif else s_scale = SCALE_1_TO_1; moncontrol(1); } void _mcleanup() { int fd; int fromindex; int endfrom; char *frompc; int toindex; struct rawarc rawarc; moncontrol(0); fd = creat( "gmon.out" , 0666 ); if ( fd < 0 ) { perror( "mcount: gmon.out" ); return; } # ifdef DEBUG fprintf( stderr , "[mcleanup] sbuf 0x%x ssiz %d\n" , sbuf , ssiz ); # endif DEBUG write( fd , sbuf , ssiz ); endfrom = s_textsize / (HASHFRACTION * sizeof(*froms)); for ( fromindex = 0 ; fromindex < endfrom ; fromindex++ ) { if ( froms[fromindex] == 0 ) { continue; } frompc = s_lowpc + (fromindex * HASHFRACTION * sizeof(*froms)); for (toindex=froms[fromindex]; toindex!=0; toindex=tos[toindex].link) { # ifdef DEBUG fprintf( stderr , "[mcleanup] frompc 0x%x selfpc 0x%x count %d\n" , frompc , tos[toindex].selfpc , tos[toindex].count ); # endif DEBUG rawarc.raw_frompc = (unsigned long) frompc; rawarc.raw_selfpc = (unsigned long) tos[toindex].selfpc; rawarc.raw_count = tos[toindex].count; write( fd , (char *) &rawarc , sizeof rawarc ); } } close( fd ); } void mcount() { register char *selfpc; register unsigned short *frompcindex; register struct tostruct *top; register struct tostruct *prevtop; register long toindex; /* * find the return address for mcount, * and the return address for mcount's caller. */ /* selfpc = pc pushed by mcount call. This identifies the function that was just entered. */ selfpc = (void *) __builtin_return_address (0); /* frompcindex = pc in preceding frame. This identifies the caller of the function just entered. */ frompcindex = (void *) __builtin_return_address (1); /* * check that we are profiling * and that we aren't recursively invoked. */ if (profiling) { goto out; } profiling++; /* * check that frompcindex is a reasonable pc value. * for example: signal catchers get called from the stack, * not from text space. too bad. */ frompcindex = (unsigned short *)((long)frompcindex - (long)s_lowpc); if ((unsigned long)frompcindex > s_textsize) { goto done; } frompcindex = &froms[((long)frompcindex) / (HASHFRACTION * sizeof(*froms))]; toindex = *frompcindex; if (toindex == 0) { /* * first time traversing this arc */ toindex = ++tos[0].link; if (toindex >= tolimit) { goto overflow; } *frompcindex = toindex; top = &tos[toindex]; top->selfpc = selfpc; top->count = 1; top->link = 0; goto done; } top = &tos[toindex]; if (top->selfpc == selfpc) { /* * arc at front of chain; usual case. */ top->count++; goto done; } /* * have to go looking down chain for it. * top points to what we are looking at, * prevtop points to previous top. * we know it is not at the head of the chain. */ for (; /* goto done */; ) { if (top->link == 0) { /* * top is end of the chain and none of the chain * had top->selfpc == selfpc. * so we allocate a new tostruct * and link it to the head of the chain. */ toindex = ++tos[0].link; if (toindex >= tolimit) { goto overflow; } top = &tos[toindex]; top->selfpc = selfpc; top->count = 1; top->link = *frompcindex; *frompcindex = toindex; goto done; } /* * otherwise, check the next arc on the chain. */ prevtop = top; top = &tos[top->link]; if (top->selfpc == selfpc) { /* * there it is. * increment its count * move it to the head of the chain. */ top->count++; toindex = prevtop->link; prevtop->link = top->link; top->link = *frompcindex; *frompcindex = toindex; goto done; } } done: profiling--; /* and fall through */ out: return; /* normal return restores saved registers */ overflow: profiling++; /* halt further profiling */ # define TOLIMIT "mcount: tos overflow\n" write(2, TOLIMIT, sizeof(TOLIMIT)); goto out; } ./libc-linux/sysdeps/linux/i386/gmon/profil.c100644 1676 334 5414 5465530700 17045 0ustar hjlisl/* * profil.c -- user space version of the profil(2) system call * Copyright (C) 1992, 1993 Rick Sladkey * * This file 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. */ /* * IMPORTANT: * * This file should never be compiled with -p or -pg! * It will need special consideration in the Makefile for libc_p.a * to ensure that it is not compiled with any profiling flags. * * Limitations: * * - Any program that tries to use SIGPROF itimers and profil at the * same time won't work. * * - The user's program is free to trash our handler with a call to * signal or sigaction. * * - Calling profil with an invalid buffer will cause a core dump instead * of just disabling profiling. * * - The precision of the histogram is worse than with true kernel * profiling. * */ #include #include #include #include #include static struct sigaction old_sa; static struct itimerval old_it; static unsigned long prof_buf; static int prof_bufsiz; static int prof_offset; static int prof_scale = 0; /* * This depends a lot on the stack at the time the signal handler * is invoked. For Linux-0.99.8 and before eip was the seventh * argument. For Linux-0.99.9 and later it is the fourteenth. * I think. For Linux-0.99.13 it is the sixteenth. It's a * continuing mystery. */ static void _profil_handler(int signr) { unsigned long pc, spot; unsigned long eip = ((unsigned long *) &signr)[15]; #ifdef PROFIL_DEBUG printf("eip = %#x\n", eip); #endif pc = eip - prof_offset; spot = (prof_scale*(pc >> 16) + ((prof_scale*(pc & (0x10000 - 1))) >> 16)) & ~1; if (spot < prof_bufsiz) ++*((unsigned short *) (spot + prof_buf)); } int profil(char *buf, int bufsiz, int offset, int scale) { struct sigaction new_sa; struct itimerval new_it; int old_scale = prof_scale; if (!buf || bufsiz == 0 || scale < 2) { if (prof_scale) { setitimer(ITIMER_PROF, &old_it, &new_it); sigaction(SIGPROF, &old_sa, &new_sa); } prof_scale = 0; } else { prof_buf = (unsigned long) buf; prof_bufsiz = bufsiz; prof_offset = offset; prof_scale = scale; if (!old_scale) { prof_scale = scale; new_sa.sa_handler = (void (*)(int)) _profil_handler; new_sa.sa_mask = 0; #ifdef SA_RESTART new_sa.sa_flags = SA_RESTART; #else new_sa.sa_flags = 0; #endif new_it.it_interval.tv_sec = 0; new_it.it_interval.tv_usec = 1; new_it.it_value.tv_sec = 0; new_it.it_value.tv_usec = 1; sigaction(SIGPROF, &new_sa, &old_sa); setitimer(ITIMER_PROF, &new_it, &old_it); } } return 0; } ./libc-linux/sysdeps/linux/i386/gmon/gmon.h100644 1676 334 7065 5220224575 16522 0ustar hjlisl/*- * Copyright (c) 1991 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. * * @(#)gmon.h 5.2 (Berkeley) 5/6/91 */ #ifndef _GMON_H #define _GMON_H struct phdr { char *lpc; char *hpc; int ncnt; }; /* * histogram counters are unsigned shorts (according to the kernel). */ #define HISTCOUNTER unsigned short /* * fraction of text space to allocate for histogram counters * here, 1/2 */ #define HISTFRACTION 2 /* * Fraction of text space to allocate for from hash buckets. * The value of HASHFRACTION is based on the minimum number of bytes * of separation between two subroutine call points in the object code. * Given MIN_SUBR_SEPARATION bytes of separation the value of * HASHFRACTION is calculated as: * * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1); * * For the VAX, the shortest two call sequence is: * * calls $0,(r0) * calls $0,(r0) * * which is separated by only three bytes, thus HASHFRACTION is * calculated as: * * HASHFRACTION = 3 / (2 * 2 - 1) = 1 * * Note that the division above rounds down, thus if MIN_SUBR_FRACTION * is less than three, this algorithm will not work! */ #define HASHFRACTION 1 /* * percent of text space to allocate for tostructs * with a minimum. */ #define ARCDENSITY 2 #define MINARCS 50 struct tostruct { char *selfpc; long count; unsigned short link; }; /* * a raw arc, * with pointers to the calling site and the called site * and a count. */ struct rawarc { unsigned long raw_frompc; unsigned long raw_selfpc; long raw_count; }; /* * general rounding functions. */ #define ROUNDDOWN(x,y) (((x)/(y))*(y)) #define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y)) #endif /* _GMON_H */ ./libc-linux/sysdeps/linux/sysdep.h100644 1676 334 3044 5266215651 15436 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 /* Not that using a `PASTE' macro loses. */ #ifdef __STDC__ #define SYSCALL__(name,args) PSEUDO (__##name, name, args) #else #define SYSCALL__(name,args) PSEUDO (__/**/name, name, args) #endif #define SYSCALL(name,args) PSEUDO (name, name, args) /* Machine-dependent sysdep.h files are expected to define the macro PSEUDO (function_name, syscall_name) to emit assembly code to define the C-callable function FUNCTION_NAME to do system call SYSCALL_NAME. r0 and r1 are the system call outputs. movl should be defined as an instruction such that "movl r1, r0" works. ret should be defined as the return instruction. */ #ifndef HAVE_GNU_LD #define ___errno _errno #endif #define HAVE_SYSCALLS ./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/__access.S100644 1676 334 1557 5263155562 15651 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__ (access, 2) ret ./libc-linux/sysdeps/linux/__chdir.S100644 1676 334 1556 5263145322 15471 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__ (chdir, 1) ret ./libc-linux/sysdeps/linux/__chmod.S100644 1676 334 1556 5263145322 15472 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__ (chmod, 2) ret ./libc-linux/sysdeps/linux/__chown.S100644 1676 334 1556 5263145322 15516 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__ (chown, 3) ret ./libc-linux/sysdeps/linux/__close.S100644 1676 334 1556 5263145322 15505 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__ (close, 1) ret ./libc-linux/sysdeps/linux/__dup.S100644 1676 334 1554 5263145322 15166 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__ (dup, 2) ret ./libc-linux/sysdeps/linux/__dup2.S100644 1676 334 1555 5263155464 15261 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__ (dup2, 2) ret ./libc-linux/sysdeps/linux/__execve.S100644 1676 334 1557 5263145322 15660 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__ (execve, 3) ret ./libc-linux/sysdeps/linux/__fchmod.S100644 1676 334 1557 5263157416 15650 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__ (fchmod, 2) ret ./libc-linux/sysdeps/linux/__fchown.S100644 1676 334 1557 5263157416 15674 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__ (fchown, 3) ret ./libc-linux/sysdeps/linux/__fork.S100644 1676 334 1555 5263163107 15341 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__ (fork, 0) ret ./libc-linux/sysdeps/linux/__fstat.S100644 1676 334 1556 5263145322 15521 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__ (fstat, 2) ret ./libc-linux/sysdeps/linux/__getegid.S100644 1676 334 1674 5270572212 16011 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 #ifdef SYS_getegid SYSCALL__ (getegid, 0) #else PSEUDO (__getegid, getgid, 2) MOVE(r1, r0) #endif ret ./libc-linux/sysdeps/linux/__geteuid.S100644 1676 334 1674 5270572344 16035 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 #ifdef SYS_geteuid SYSCALL__ (geteuid, 0) #else PSEUDO (__geteuid, getuid, 2) MOVE(r1, r0) #endif ret ./libc-linux/sysdeps/linux/__getgid.S100644 1676 334 1557 5263145323 15645 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__ (getgid, 1) ret ./libc-linux/sysdeps/linux/__getitmr.S100644 1676 334 1562 5263160733 16053 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__ (getitimer, 2) ret ./libc-linux/sysdeps/linux/setpgid.S100644 1676 334 1556 5267073152 15546 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 (setpgid, 2) ret ./libc-linux/sysdeps/linux/__getpid.S100644 1676 334 1557 5263145323 15656 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__ (getpid, 1) ret ./libc-linux/sysdeps/linux/__getppid.S100644 1676 334 1674 5263145323 16036 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 #ifdef SYS_getppid SYSCALL__ (getppid, 0) #else PSEUDO (__getppid, getpid, 0) MOVE(r1, r0) #endif ret ./libc-linux/sysdeps/linux/__getrusag.S100644 1676 334 1562 5263164563 16226 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__ (getrusage, 2) ret ./libc-linux/sysdeps/linux/__gettod.S100644 1676 334 1565 5263163636 15676 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__ (gettimeofday, 2) ret ./libc-linux/sysdeps/linux/__getuid.S100644 1676 334 1557 5263145323 15663 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__ (getuid, 1) ret ./libc-linux/sysdeps/linux/__kill.S100644 1676 334 1555 5263145323 15333 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__ (kill, 2) ret ./libc-linux/sysdeps/linux/__link.S100644 1676 334 1555 5263145323 15335 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__ (link, 2) ret ./libc-linux/sysdeps/linux/__lseek.S100644 1676 334 1556 5263145323 15504 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__ (lseek, 3) ret ./libc-linux/sysdeps/linux/__lstat.S100644 1676 334 1556 5263157502 15532 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__ (lstat, 2) ret ./libc-linux/sysdeps/linux/__mkdir.S100644 1676 334 1556 5263161216 15506 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__ (mkdir, 2) ret ./libc-linux/sysdeps/linux/__mknod.S100644 1676 334 1556 5263145323 15511 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__ (mknod, 3) ret ./libc-linux/sysdeps/linux/__read.S100644 1676 334 1555 5263145323 15313 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__ (read, 3) ret ./libc-linux/sysdeps/linux/__readlink.S100644 1676 334 1561 5263160575 16174 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__ (readlink, 3) ret ./libc-linux/sysdeps/linux/__rmdir.S100644 1676 334 1556 5263160775 15526 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__ (rmdir, 1) ret ./libc-linux/sysdeps/linux/__setgid.S100644 1676 334 1557 5263145324 15662 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__ (setgid, 1) ret ./libc-linux/sysdeps/linux/signal.c100644 1676 334 603 5371032155 15346 0ustar hjlisl#include __sighandler_t signal (int sig, __sighandler_t handler) { int ret; struct sigaction action, oaction; action.sa_handler = handler; __sigemptyset (&action.sa_mask); action.sa_flags = SA_ONESHOT | SA_NOMASK | SA_INTERRUPT; action.sa_flags &= ~SA_RESTART; ret = __sigaction (sig, &action, &oaction); return (ret == -1) ? SIG_ERR : oaction.sa_handler; } ./libc-linux/sysdeps/linux/__setitmr.S100644 1676 334 1562 5263160733 16067 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__ (setitimer, 3) ret ./libc-linux/sysdeps/linux/__setregid.S100644 1676 334 1561 5263161306 16202 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__ (setregid, 2) ret ./libc-linux/sysdeps/linux/__setreuid.S100644 1676 334 1561 5263161306 16220 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__ (setreuid, 2) ret ./libc-linux/sysdeps/linux/__settod.S100644 1676 334 1565 5263163636 15712 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__ (settimeofday, 2) ret ./libc-linux/sysdeps/linux/__setuid.S100644 1676 334 1557 5263145324 15700 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__ (setuid, 1) ret ./libc-linux/sysdeps/linux/__stat.S100644 1676 334 1555 5263145324 15354 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__ (stat, 2) ret ./libc-linux/sysdeps/linux/__symlink.S100644 1676 334 1560 5263161374 16066 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__ (symlink, 2) ret ./libc-linux/sysdeps/linux/__times.S100644 1676 334 1556 5263165166 15531 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__ (times, 1) ret ./libc-linux/sysdeps/linux/__umask.S100644 1676 334 1556 5263145324 15522 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__ (umask, 1) ret ./libc-linux/sysdeps/linux/__unlink.S100644 1676 334 1557 5263145324 15703 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__ (unlink, 1) ret ./libc-linux/sysdeps/linux/__wait4.S100644 1676 334 1550 5263161605 15424 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 SYSCALL__ (wait4, 4) ret ./libc-linux/sysdeps/linux/__write.S100644 1676 334 1556 5263145324 15534 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__ (write, 3) ret ./libc-linux/sysdeps/linux/acct.S100644 1676 334 1553 5263145324 15013 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 (acct, 1) ret ./libc-linux/sysdeps/linux/alarm.S100644 1676 334 1554 5263155727 15206 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 (alarm, 1) ret ./libc-linux/sysdeps/linux/chroot.S100644 1676 334 1555 5263145324 15401 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 (chroot, 1) ret ./libc-linux/sysdeps/linux/creat.S100644 1676 334 1554 5263167207 15204 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 (creat, 2) ret ./libc-linux/sysdeps/linux/uname.c100644 1676 334 1764 5367557001 15236 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 #undef uname function_alias(uname, __uname, int, (buf), DEFUN(uname, (buf), struct utsname *buf)) ./libc-linux/sysdeps/linux/ftruncate.S100644 1676 334 1560 5263162141 16066 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 (ftruncate, 2) ret ./libc-linux/sysdeps/linux/getrlimit.S100644 1676 334 1560 5263161131 16071 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 (getrlimit, 2) ret ./libc-linux/sysdeps/linux/nice.S100644 1676 334 1545 5263164421 15017 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 SYSCALL (nice, 1) ret ./libc-linux/sysdeps/linux/__getpgsz.c100644 1676 334 2223 5266166763 16112 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 General Public License as published by the Free Software Foundation; either version 2, 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 General Public License for more details. You should have received a copy of the GNU General Public License along with the GNU C Library; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include /* Return the system page size. */ size_t DEFUN_VOID(__getpagesize) { #ifdef EXEC_PAGESIZE return EXEC_PAGESIZE; #else /* No EXEC_PAGESIZE. */ #ifdef NBPG #ifndef CLSIZE #define CLSIZE 1 #endif /* No CLSIZE. */ return NBPG * CLSIZE; #else /* No NBPG. */ return NBPC; #endif /* NBPG. */ #endif /* EXEC_PAGESIZE. */ } ./libc-linux/sysdeps/linux/pause.S100644 1676 334 1554 5263166055 15223 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 (pause, 0) ret ./libc-linux/sysdeps/linux/rename.S100644 1676 334 1555 5263160534 15352 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 (rename, 2) ret ./libc-linux/sysdeps/linux/setgroups.S100644 1676 334 1552 5263165343 16136 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 SYSCALL (setgroups, 2) ret ./libc-linux/sysdeps/linux/setprio.S100644 1676 334 1562 5263163307 15567 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 (setpriority, 3) ret ./libc-linux/sysdeps/linux/setrlimit.S100644 1676 334 1560 5263161131 16105 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 (setrlimit, 2) ret ./libc-linux/sysdeps/linux/stime.S100644 1676 334 1546 5263162411 15220 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 SYSCALL (stime, 1) ret ./libc-linux/sysdeps/linux/swapon.S100644 1676 334 1555 5263145324 15412 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 (swapon, 1) ret ./libc-linux/sysdeps/linux/sync.S100644 1676 334 1553 5263145325 15056 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 (sync, 0) ret ./libc-linux/sysdeps/linux/time.S100644 1676 334 1553 5263165757 15053 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 (time, 1) ret ./libc-linux/sysdeps/linux/truncate.S100644 1676 334 1557 5263161755 15740 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 (truncate, 2) ret ./libc-linux/sysdeps/linux/__getgrps.S100644 1676 334 1554 5272356436 16063 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 SYSCALL__ (getgroups, 2) ret ./libc-linux/sysdeps/linux/utime.S100644 1676 334 1546 5263162316 15226 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 SYSCALL (utime, 2) ret ./libc-linux/sysdeps/linux/morecore.c100644 1676 334 2462 5270367346 15744 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 General Public License as published by the Free Software Foundation; either version 2, 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 General Public License for more details. You should have received a copy of the GNU General Public License along with the GNU C Library; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _MALLOC_INTERNAL #define _MALLOC_INTERNAL #include #endif #ifndef __GNU_LIBRARY__ #define __sbrk sbrk #endif extern __ptr_t __sbrk __P ((int increment)); #ifndef NULL #define NULL 0 #endif /* Allocate INCREMENT more bytes of data space, and return the start of data space, or NULL on errors. If INCREMENT is negative, shrink data space. */ __ptr_t __default_morecore (increment) ptrdiff_t increment; { __ptr_t result = __sbrk ((int) increment); if (result == (__ptr_t) -1) return NULL; return result; } ./libc-linux/sysdeps/linux/__setsid.S100644 1676 334 1557 5263227000 15666 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__ (setsid, 0) ret ./libc-linux/sysdeps/linux/__statfs.S100644 1676 334 1557 5361702424 15706 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__ (statfs, 2) ret ./libc-linux/sysdeps/linux/fstatfs.c100644 1676 334 2012 5361704375 15570 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 #undef fstatfs function_alias(fstatfs, __fstatfs, int, (fd, buf), DEFUN(fstatfs, (fd, buf), int fd AND struct statfs *buf)) ./libc-linux/sysdeps/linux/ustat.S100644 1676 334 1554 5263227336 15246 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 (ustat, 2) ret ./libc-linux/sysdeps/linux/__fpathconf.c100644 1676 334 4655 5361702227 16375 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 #include #ifdef __linux__ #include #endif /* Get file-specific information about descriptor FD. */ long int DEFUN(__fpathconf, (fd, name), int fd AND int name) { if (fd < 0) { errno = EBADF; return -1; } switch (name) { default: errno = EINVAL; return -1; case _PC_LINK_MAX: #ifdef LINK_MAX return LINK_MAX; #else errno = ENOSYS; return -1; #endif case _PC_MAX_CANON: #ifdef MAX_CANON return MAX_CANON; #else errno = ENOSYS; return -1; #endif case _PC_MAX_INPUT: #ifdef MAX_INPUT return MAX_INPUT; #else errno = ENOSYS; return -1; #endif case _PC_NAME_MAX: #ifdef __linux__ { struct statfs buf; if (__fstatfs (fd, &buf) < 0) return -1; else return buf.f_namelen; } #else #ifdef NAME_MAX return NAME_MAX; #else errno = ENOSYS; return -1; #endif #endif case _PC_PATH_MAX: #ifdef PATH_MAX return PATH_MAX; #else errno = ENOSYS; return -1; #endif case _PC_PIPE_BUF: #ifdef PIPE_BUF return PIPE_BUF; #else errno = ENOSYS; return -1; #endif case _PC_CHOWN_RESTRICTED: #ifdef _POSIX_CHOWN_RESTRICTED return _POSIX_CHOWN_RESTRICTED; #else return -1; #endif case _PC_NO_TRUNC: #ifdef _POSIX_NO_TRUNC return _POSIX_NO_TRUNC; #else return -1; #endif case _PC_VDISABLE: #ifdef _POSIX_VDISABLE return _POSIX_VDISABLE; #else return -1; #endif } errno = ENOSYS; return -1; } ./libc-linux/sysdeps/linux/__pathconf.c100644 1676 334 2623 5361702215 16215 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 #ifdef __linux__ #include #endif /* Get file-specific information about PATH. */ long int DEFUN(__pathconf, (path, name), CONST char *path AND int name) { if (path == NULL) { errno = EINVAL; return -1; } #ifdef __linux__ switch (name) { default: return __fpathconf (0, name); case _PC_NAME_MAX: { struct statfs buf; if (__statfs (path, &buf) < 0) return -1; else return buf.f_namelen; } } #else return __fpathconf (0, name); #endif } ./libc-linux/sysdeps/linux/__sysconf.c100644 1676 334 7243 5263736711 16113 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 /* Get the value of the system variable NAME. */ long int DEFUN(__sysconf, (name), int name) { switch (name) { default: errno = EINVAL; return -1; case _SC_ARG_MAX: #ifdef ARG_MAX return ARG_MAX; #else return -1; #endif case _SC_CHILD_MAX: #ifdef CHILD_MAX return CHILD_MAX; #else return -1; #endif case _SC_CLK_TCK: return CLK_TCK; case _SC_NGROUPS_MAX: #ifdef NGROUPS_MAX return NGROUPS_MAX; #else return -1; #endif case _SC_OPEN_MAX: return OPEN_MAX; case _SC_STREAM_MAX: return STREAM_MAX; case _SC_TZNAME_MAX: #ifdef linux return TZNAME_MAX; #else return __tzname_max (); #endif case _SC_JOB_CONTROL: #ifdef _POSIX_JOB_CONTROL return 1; #else return -1; #endif case _SC_SAVED_IDS: #ifdef _POSIX_SAVED_IDS return 1; #else return -1; #endif case _SC_VERSION: return _POSIX_VERSION; #ifdef _SC_BC_BASE_MAX case _SC_BC_BASE_MAX: #ifdef BC_BASE_MAX return BC_BASE_MAX; #else return -1; #endif #endif #ifdef _SC_BC_DIM_MAX case _SC_BC_DIM_MAX: #ifdef BC_DIM_MAX return BC_DIM_MAX; #else return -1; #endif #endif #ifdef _SC_BC_SCALE_MAX case _SC_BC_SCALE_MAX #ifdef BC_SCALE_MAX return BC_SCALE_MAX; #else return -1; #endif #endif #ifdef _SC_BC_STRING_MAX case _SC_BC_STRING_MAX: #ifdef BC_STRING_MAX return BC_STRING_MAX; #else return -1; #endif #endif #ifdef _SC_EQUIV_CLASS_MAX case _SC_EQUIV_CLASS_MAX: #ifdef EQUIV_CLASS_MAX return EQUIV_CLASS_MAX; #else return -1; #endif #endif #ifdef _SC_EXPR_NEST_MAX case _SC_EXPR_NEST_MAX: #ifdef EXPR_NEST_MAX return EXPR_NEST_MAX; #else return -1; #endif #endif #ifdef _SC_LINE_MAX case _SC_LINE_MAX: #ifdef LINE_MAX return LINE_MAX; #else return -1; #endif #endif #ifdef _SC_RE_DUP_MAX case _SC_RE_DUP_MAX: #ifdef RE_DUP_MAX return RE_DUP_MAX; #else return -1; #endif #endif #ifdef _SC_2_VERSION case _SC_2_VERSION: /* This is actually supposed to return the version of the 1003.2 utilities on the system {POSIX2_VERSION}. */ #ifdef _POSIX2_C_VERSION return _POSIX2_C_VERSION; #else return -1; #endif #endif #ifdef _SC_2_C_BIND case _SC_2_C_BIND: #ifdef _POSIX2_C_BIND return _POSIX2_C_BIND; #else return -1; #endif #endif #ifdef _SC_2_C_DEV case _SC_2_C_DEV: #ifdef _POSIX2_C_DEV return _POSIX2_C_DEV; #else return -1; #endif #endif #ifdef _SC_2_FORT_DEV case _SC_2_FORT_DEV: #ifdef _POSIX2_FORT_DEV return _POSIX2_FORT_DEV; #else return -1; #endif #endif #ifdef _SC_2_SW_DEV case _SC_2_SW_DEV: #ifdef _POSIX2_SW_DEV return _POSIX2_SW_DEV; #else return -1; #endif #endif } } ./libc-linux/sysdeps/linux/nlist.c100644 1676 334 4643 5353035525 15256 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 General Public License as published by the Free Software Foundation; either version 2, 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 General Public License for more details. You should have received a copy of the GNU General Public License along with the GNU C Library; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include /* Search the executable FILE for symbols matching those in NL, which is terminated by an element with a NULL `n_un.n_name' member, and fill in the elements of NL. */ int DEFUN(nlist, (file, nl), CONST char *file AND struct nlist *nl) { FILE *f; struct exec header; size_t nsymbols; struct nlist *symbols; unsigned long int string_table_size; char *string_table; register size_t i; if (nl == NULL) { errno = EINVAL; return -1; } f = fopen(file, "r"); if (f == NULL) return -1; if (fread((PTR) &header, sizeof(header), 1, f) != 1) goto lose; if (fseek(f, N_SYMOFF(header), SEEK_SET) != 0) goto lose; symbols = (struct nlist *) __alloca(header.a_syms); nsymbols = header.a_syms / sizeof(symbols[0]); if (fread((PTR) symbols, sizeof(symbols[0]), nsymbols, f) != nsymbols) goto lose; if (fread((PTR) &string_table_size, sizeof(string_table_size), 1, f) != 1) goto lose; string_table_size -= sizeof(string_table_size); string_table = (char *) __alloca(string_table_size); if (fread((PTR) string_table, string_table_size, 1, f) != 1) goto lose; for (i = 0; i < nsymbols; ++i) { register struct nlist *nlp; for (nlp = nl; nlp->n_un.n_name != NULL; ++nlp) if (!strcmp(nlp->n_un.n_name, &string_table[symbols[i].n_un.n_strx - sizeof(string_table_size)])) { char *CONST name = nlp->n_un.n_name; *nlp = symbols[i]; nlp->n_un.n_name = name; } } (void) fclose(f); return 0; lose:; (void) fclose(f); return -1; } ./libc-linux/sysdeps/linux/__isatty.c100644 1676 334 2155 5266147660 15743 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 1 if FD is a terminal, 0 if not. */ int DEFUN(__isatty, (fd), int fd) { int save; int is_tty; struct termios term; save = errno; is_tty = __tcgetattr(fd, &term) == 0; errno = save; return is_tty; } ./libc-linux/sysdeps/linux/__getdtsz.c100644 1676 334 2340 5266150105 16072 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 maximum number of file descriptors the current process could possibly have. */ int DEFUN_VOID(__getdtablesize) { #ifdef OPEN_MAX return OPEN_MAX; #else errno = ENOSYS; return -1; #endif } #ifndef OPEN_MAX #ifdef HAVE_GNU_LD #include stub_warning(__getdtablesize); #endif /* GNU stabs. */ #endif ./libc-linux/sysdeps/linux/__sigblock.c100644 1676 334 2737 5266152212 16216 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 /* Block signals in MASK, returning the old mask. */ int DEFUN(__sigblock, (mask), int mask) { register int sig; sigset_t set, oset; if (__sigemptyset(&set) < 0) return -1; if (sizeof (mask) == sizeof (set)) set = mask; else for (sig = 1; sig < NSIG; ++sig) if ((mask & sigmask(sig)) && __sigaddset(&set, sig) < 0) return -1; if (sigprocmask(SIG_BLOCK, &set, &oset) < 0) return -1; mask = 0; if (sizeof (mask) == sizeof (oset)) mask = oset; else for (sig = 1; sig < NSIG; ++sig) if (__sigismember(&oset, sig)) mask |= sigmask(sig); return mask; } ./libc-linux/sysdeps/linux/__sigpause.c100644 1676 334 2107 5266152212 16230 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 /* Set the mask of blocked signals to MASK, wait for a signal to arrive, and then restore the mask. */ int DEFUN(__sigpause, (mask), int mask) { sigset_t set = mask; return sigsuspend (&set); } ./libc-linux/sysdeps/linux/mprotect.S100644 1676 334 1551 5465551540 15741 0ustar hjlisl/* Copyright (C) 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 SYSCALL (mprotect, 3) ret ./libc-linux/sysdeps/linux/sethstnm.S100644 1676 334 1562 5273032225 15742 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 (sethostname, 2) ret ./libc-linux/sysdeps/linux/sigpending.S100644 1676 334 1561 5272352757 16241 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 (sigpending, 1) ret ./libc-linux/sysdeps/linux/__tcgetatr.c100644 1676 334 224 5270575573 16221 0ustar hjlisl#include #include int __tcgetattr(int fildes, struct termios *termios_p) { return __ioctl(fildes, TCGETS, termios_p); } ./libc-linux/sysdeps/linux/idle.S100644 1676 334 1553 5266172437 15026 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 (idle, 0) ret ./libc-linux/sysdeps/linux/ioperm.S100644 1676 334 1555 5266172534 15404 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 (ioperm, 3) ret ./libc-linux/sysdeps/linux/iopl.S100644 1676 334 1553 5266172620 15046 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 (iopl, 1) ret ./libc-linux/sysdeps/linux/munmap.S100644 1676 334 1555 5266173004 15377 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 (munmap, 2) ret ./libc-linux/sysdeps/linux/mount.S100644 1676 334 1554 5266173066 15253 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 (mount, 5) ret ./libc-linux/sysdeps/linux/reboot.S100644 1676 334 1555 5266173153 15401 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 (reboot, 3) ret ./libc-linux/sysdeps/linux/swapoff.S100644 1676 334 1556 5266173260 15554 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 (swapoff, 1) ret ./libc-linux/sysdeps/linux/umount.S100644 1676 334 1555 5266173327 15441 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 (umount, 1) ret ./libc-linux/sysdeps/linux/vm86.S100644 1676 334 1553 5266173517 14711 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 (vm86, 1) ret ./libc-linux/sysdeps/linux/uselib.S100644 1676 334 1555 5266173420 15367 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 (uselib, 1) ret ./libc-linux/sysdeps/linux/mkfifo.c100644 1676 334 2051 5270577115 15373 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 General Public License as published by the Free Software Foundation; either version 2, 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 General Public License for more details. You should have received a copy of the GNU General Public License along with the GNU C Library; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include /* Create a named pipe (FIFO) named PATH with protections MODE. */ int DEFUN(mkfifo, (path, mode), CONST char *path AND mode_t mode) { return __mknod (path, mode | S_IFIFO, 0); } ./libc-linux/sysdeps/linux/__gethstnm.c100644 1676 334 566 5367556331 16244 0ustar hjlisl#include #include #include #include int __gethostname(char *name, size_t len) { struct utsname uts; if (name == NULL) { errno = EINVAL; return -1; } if (__uname(&uts) == -1) return -1; if (strlen(uts.nodename)+1 > len) { errno = EINVAL; return -1; } strcpy(name, uts.nodename); return 0; } ./libc-linux/sysdeps/linux/__pipe.S100644 1676 334 1555 5272351302 15331 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__ (pipe, 1) ret ./libc-linux/sysdeps/linux/setegid.c100644 1676 334 115 5266574606 15532 0ustar hjlisl#include int setegid(gid_t gid) { return __setregid(-1, gid); } ./libc-linux/sysdeps/linux/__utimes.c100644 1676 334 416 5270576016 15706 0ustar hjlisl#include #include int __utimes(char *path, struct timeval *tvp) { struct utimbuf buf, *times; if (tvp) { times = &buf; times->actime = tvp[0].tv_sec; times->modtime = tvp[1].tv_sec; } else times = NULL; return utime(path, times); } ./libc-linux/sysdeps/linux/seteuid.c100644 1676 334 115 5266574615 15550 0ustar hjlisl#include int seteuid(uid_t uid) { return __setreuid(-1, uid); } ./libc-linux/sysdeps/linux/__flock.c100644 1676 334 3156 5334113336 15513 0ustar hjlisl/* Copyright (C) 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 /* Apply or remove an advisory lock, according to OPERATION, on the file FD refers to. */ int DEFUN(__flock, (fd, operation), int fd AND int operation) { struct flock flock; int cmd; switch (operation & ~LOCK_NB) { case LOCK_SH: #ifdef __linux__ flock.l_type = F_SHLCK; #else flock.l_type = F_RDLCK; #endif break; case LOCK_EX: #ifdef __linux__ flock.l_type = F_EXLCK; #else flock.l_type = F_WRLCK; #endif break; case LOCK_UN: flock.l_type = F_UNLCK; break; default: errno = EINVAL; return -1; } flock.l_whence = SEEK_SET; flock.l_start = flock.l_len = 0L; cmd = (operation & LOCK_NB) ? F_SETLK : F_SETLKW; return (__fcntl (fd, cmd, &flock)); } ./libc-linux/sysdeps/linux/vhangup.S100644 1676 334 1556 5266477276 15575 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 (vhangup, 0) ret ./libc-linux/sysdeps/linux/getpgrp.S100644 1676 334 1556 5267072555 15565 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 (getpgrp, 0) ret ./libc-linux/sysdeps/linux/__ioctl.S100644 1676 334 1556 5323244245 15513 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__ (ioctl, 3) ret ./libc-linux/sysdeps/linux/__fcntl.S100644 1676 334 1556 5323244207 15505 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__ (fcntl, 3) ret ./libc-linux/sysdeps/linux/__open.S100644 1676 334 1555 5323244163 15340 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__ (open, 3) ret ./libc-linux/sysdeps/linux/__fstatfs.S100644 1676 334 1560 5361702416 16047 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__ (fstatfs, 2) ret ./libc-linux/sysdeps/linux/statfs.c100644 1676 334 2024 5361704350 15416 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 #undef statfs function_alias(statfs, __statfs, int, (path, buf), DEFUN(statfs, (path, buf), CONST char *path AND struct statfs *buf)) ./libc-linux/sysdeps/linux/__uname.S100644 1676 334 1550 5367556304 15512 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 SYSCALL__ (uname, 1) ret ./libc-linux/sysdeps/linux/setdnnm.S100644 1676 334 1564 5367606574 15571 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 (setdomainname, 2) ret ./libc-linux/sysdeps/linux/getdnnm.c100644 1676 334 572 5367610151 15535 0ustar hjlisl#include #include #include #include int getdomainname(char *name, size_t len) { struct utsname uts; if (name == NULL) { errno = EINVAL; return -1; } if (__uname(&uts) == -1) return -1; if (strlen(uts.domainname)+1 > len) { errno = EINVAL; return -1; } strcpy(name, uts.domainname); return 0; } ./libc-linux/sysdeps/linux/__bsd_sig.c100644 1676 334 1267 5372530362 16034 0ustar hjlisl#define __USE_BSD_SIGNAL #include #undef signal /* The `sig' bit is set if the interrupt on it * is enabled via siginterrupt (). */ extern sigset_t _sigintr; __sighandler_t __bsd_signal (int sig, __sighandler_t handler) { int ret; struct sigaction action, oaction; action.sa_handler = handler; __sigemptyset (&action.sa_mask); if (!__sigismember (&_sigintr, sig)) { #ifdef SA_RESTART action.sa_flags = SA_RESTART; #else action.sa_flags = 0; #endif } else { #ifdef SA_INTERRUPT action.sa_flags = SA_INTERRUPT; #else action.sa_flags = 0; #endif } ret = __sigaction (sig, &action, &oaction); return (ret == -1) ? SIG_ERR : oaction.sa_handler; } ./libc-linux/sysdeps/linux/_errlist.c100644 1676 334 12761 5363010214 15755 0ustar hjlisl#include #include #if 0 #include #endif /* This is a list of all known signal numbers. */ CONST char *CONST _sys_errlist[] = { "Unknown error", /* 0 */ "Operation not permitted", /* EPERM */ "No such file or directory", /* ENOENT */ "No such process", /* ESRCH */ "Interrupted system call", /* EINTR */ "I/O error", /* EIO */ "No such device or address", /* ENXIO */ "Arg list too long", /* E2BIG */ "Exec format error", /* ENOEXEC */ "Bad file number", /* EBADF */ "No child processes", /* ECHILD */ "Try again", /* EAGAIN */ "Out of memory", /* ENOMEM */ "Permission denied", /* EACCES */ "Bad address", /* EFAULT */ "Block device required", /* ENOTBLK */ "Device or resource busy", /* EBUSY */ "File exists", /* EEXIST */ "Cross-device link", /* EXDEV */ "No such device", /* ENODEV */ "Not a directory", /* ENOTDIR */ "Is a directory", /* EISDIR */ "Invalid argument", /* EINVAL */ "File table overflow", /* ENFILE */ "Too many open files", /* EMFILE */ "Not a typewriter", /* ENOTTY */ "Text file busy", /* ETXTBSY */ "File too large", /* EFBIG */ "No space left on device", /* ENOSPC */ "Illegal seek", /* ESPIPE */ "Read-only file system", /* EROFS */ "Too many links", /* EMLINK */ "Broken pipe", /* EPIPE */ "Math argument out of domain of func", /* EDOM */ "Math result not representable", /* ERANGE */ "Resource deadlock would occur", /* EDEADLK */ "File name too long", /* ENAMETOOLONG */ "No record locks available", /* ENOLCK */ "Function not implemented", /* ENOSYS */ "Directory not empty", /* ENOTEMPTY */ "Too many symbolic links encountered", /* ELOOP */ "Operation would block", /* EWOULDBLOCK */ "No message of desired type", /* ENOMSG */ "Identifier removed", /* EIDRM */ "Channel number out of range", /* ECHRNG */ "Level 2 not synchronized", /* EL2NSYNC */ "Level 3 halted", /* EL3HLT */ "Level 3 reset", /* EL3RST */ "Link number out of range", /* ELNRNG */ "Protocol driver not attached", /* EUNATCH */ "No CSI structure available", /* ENOCSI */ "Level 2 halted", /* EL2HLT */ "Invalid exchange", /* EBADE */ "Invalid request descriptor", /* EBADR */ "Exchange full", /* EXFULL */ "No anode", /* ENOANO */ "Invalid request code", /* EBADRQC */ "Invalid slot", /* EBADSLT */ "File locking deadlock error", /* EDEADLOCK */ "Bad font file format", /* EBFONT */ "Device not a stream", /* ENOSTR */ "No data available", /* ENODATA */ "Timer expired", /* ETIME */ "Out of streams resources", /* ENOSR */ "Machine is not on the network", /* ENONET */ "Package not installed", /* ENOPKG */ "Object is remote", /* EREMOTE */ "Link has been severed", /* ENOLINK */ "Advertise error", /* EADV */ "Srmount error", /* ESRMNT */ "Communication error on send", /* ECOMM */ "Protocol error", /* EPROTO */ "Multihop attempted", /* EMULTIHOP */ "RFS specific error", /* EDOTDOT */ "Not a data message", /* EBADMSG */ "Value too large for defined data type", /* EOVERFLOW */ "Name not unique on network", /* ENOTUNIQ */ "File descriptor in bad state", /* EBADFD */ "Remote address changed", /* EREMCHG */ "Can not access a needed shared library", /* ELIBACC */ "Accessing a corrupted shared library", /* ELIBBAD */ ".lib section in a.out corrupted", /* ELIBSCN */ "Attempting to link in too many shared libraries", /* ELIBMAX */ "Cannot exec a shared library directly", /* ELIBEXEC */ "Illegal byte sequence", /* EILSEQ */ "Interrupted system call should be restarted", /* ERESTART */ "Streams pipe error", /* ESTRPIPE */ "Too many users", /* EUSERS */ "Socket operation on non-socket", /* ENOTSOCK */ "Destination address required", /* EDESTADDRREQ */ "Message too long", /* EMSGSIZE */ "Protocol wrong type for socket", /* EPROTOTYPE */ "Protocol not available", /* ENOPROTOOPT */ "Protocol not supported", /* EPROTONOSUPPORT */ "Socket type not supported", /* ESOCKTNOSUPPORT */ "Operation not supported on transport endpoint", /* EOPNOTSUPP */ "Protocol family not supported", /* EPFNOSUPPORT */ "Address family not supported by protocol", /* EAFNOSUPPORT */ "Address already in use", /* EADDRINUSE */ "Cannot assign requested address", /* EADDRNOTAVAIL */ "Network is down", /* ENETDOWN */ "Network is unreachable", /* ENETUNREACH */ "Network dropped connection because of reset", /* ENETRESET */ "Software caused connection abort", /* ECONNABORTED */ "Connection reset by peer", /* ECONNRESET */ "No buffer space available", /* ENOBUFS */ "Transport endpoint is already connected", /* EISCONN */ "Transport endpoint is not connected", /* ENOTCONN */ "Cannot send after transport endpoint shutdown", /* ESHUTDOWN */ "Too many references: cannot splice", /* ETOOMANYREFS */ "Connection timed out", /* ETIMEDOUT */ "Connection refused", /* ECONNREFUSED */ "Host is down", /* EHOSTDOWN */ "No route to host", /* EHOSTUNREACH */ "Operation already in progress", /* EALREADY */ "Operation now in progress", /* EINPROGRESS */ "Stale NFS file handle", /* ESTALE */ "Structure needs cleaning", /* EUCLEAN */ "Not a XENIX named type file", /* ENOTNAM */ "No XENIX semaphores available", /* ENAVAIL */ "Is a named type file", /* EISNAM */ "Remote I/O error", /* EREMOTEIO */ NULL }; #define NR_ERRORS ((sizeof (_sys_errlist))/(sizeof(char *))-1) CONST int _sys_nerr = NR_ERRORS; ./libc-linux/sysdeps/linux/_siglist.c100644 1676 334 1573 5303254440 15733 0ustar hjlisl#include #include #include /* This is a list of all known signal numbers. */ CONST char *CONST _sys_siglist[] = { "Unknown signal", "Hangup", "Interrupt", "Quit", "Illegal instruction", "Trace/breakpoint trap", "IOT trap/Abort", "Unused signal", "Floating point exception", "Killed", "User defined signal 1", "Segmentation fault", "User defined signal 2", "Broken pipe", "Alarm clock", "Terminated", "Stack fault", "Child exited", "Continued", "Stopped (signal)", "Stopped", "Stopped (tty input)", "Stopped (tty output)", "Possible I/O", "CPU time limit exceeded", "File size limit exceeded", "Virtual time alarm", "Profile signal", "Window size changed", "File lock lost", "Unused signal", "Unused signal", NULL }; ./libc-linux/sysdeps/linux/fsync.S100644 1676 334 1546 5403674064 15231 0ustar hjlisl/* Copyright (C) 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 SYSCALL (fsync, 1) ret ./libc-linux/sysdeps/linux/__siggtmsk.c100644 1676 334 2402 5465555464 16257 0ustar hjlisl/* Copyright (C) 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 /* Get the mask of blocked signals. */ int DEFUN_VOID(__siggetmask) { sigset_t oset; register int sig; int mask; if (sigprocmask(SIG_SETMASK, NULL, &oset) < 0) return -1; if (sizeof (mask) == sizeof (oset)) mask = oset; else { mask = 0; for (sig = 1; sig < NSIG; ++sig) if (__sigismember(&oset, sig) == 1) mask |= sigmask(sig); } return mask; } ./libc-linux/sysdeps/linux/__sigproc.S100644 1676 334 1556 5465531772 16062 0ustar hjlisl/* Copyright (C) 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 SYSCALL__ (sigprocmask, 3) ret ./libc-linux/sysdeps/linux/__sigstmsk.c100644 1676 334 3036 5465531773 16274 0ustar hjlisl/* Copyright (C) 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 /* Set the mask of blocked signals to MASK, returning the old mask. */ int DEFUN(__sigsetmask, (mask), int mask) { register int sig; sigset_t set, oset; if (sizeof (mask) == sizeof (set)) set = mask; else { if (__sigemptyset(&set) < 0) return -1; for (sig = 1; sig < NSIG; ++sig) if ((mask & sigmask(sig)) && __sigaddset(&set, sig) < 0) return -1; } if (sigprocmask(SIG_SETMASK, &set, &oset) < 0) return -1; if (sizeof (mask) == sizeof (oset)) mask = oset; else { mask = 0; for (sig = 1; sig < NSIG; ++sig) if (__sigismember(&oset, sig) == 1) mask |= sigmask(sig); } return mask; } ./libc-linux/sysdeps/linux/m68k/ 40755 1676 334 0 5542403265 14442 5ustar hjlisl./libc-linux/sysdeps/linux/m68k/crt/ 40755 1676 334 0 5521073010 15216 5ustar hjlisl./libc-linux/sysdeps/linux/m68k/crt/crt0.S100644 1676 334 7207 5523015021 16315 0ustar hjlisl/* * Copyright (c) 1993 Eric Youngdale, Peter MacDonald, David Engel * and Hongjiu Lu. * * 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Eric Youngdale, * Peter MacDonald, David Engel and Hongjiu Lu. * 3. The name of the above contributors may not be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 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. */ /* Notice of general intent: * * The linux operating system generally contains large amounts of code * that fall under the GNU General Public License, or GPL for short. * This file contains source code that by it's very nature would always * be linked with an application program, and because of this a GPL type * of copyright on this file would place restrictions upon the * distribution of binary-only commercial software. Since the goal of the * Linux project as a whole is not to discourage the development and * distribution of commercial software for Linux, this file has been placed * under a more relaxed BSD-style of copyright. * * It is the general understanding of the above contributors that a * program executable linked to a library containing code that falls * under the GPL or GLPL style of license is not subject to the terms of * the GPL or GLPL license if the program executable(s) that are supplied * are linked to a shared library form of the GPL or GLPL library, and as long * as the form of the shared library is such that it is possible for * the end user to modify and rebuild the library and use it in * conjunction with the program executable. */ .file "crt0.S" .text __entry: /* * The first thing we do is try to load the shared library. If that * fails, it won't return. */ jbsr ___load_shared_libraries /* * This is important, and was missing from the new version... */ moveq #45,d0 moveq #0,d1 trap #0 movel d0,____brk_addr /* * ok, set up the ___environ and call _main */ movel sp@(8),___environ movel ___fpu_control,sp@- jbsr ___setfpucw addql #4,sp /* Some functions may be needed. */ jbsr ___libc_init jbsr _main movel d0,sp@- jbsr _exit /* * Just in case _exit fails... We use trap #0 for __exit(). */ addql #4,sp done: moveq #1,d0 trap #0 bras done .align 4 ___shared_dummy__: .asciz "" .stabs "___SHARED_LIBRARIES__",25,0,0,___shared_dummy__ .data .align 4 ___shared_dummy1__: .long 0xfeeb1ed3 /* Magic number used by DLL code to make sure this is a real list */ .stabs "__SHARABLE_CONFLICTS__",25,0,0,___shared_dummy1__ ./libc-linux/sysdeps/linux/m68k/crt/gcrt0.S100644 1676 334 7403 5523015045 16470 0ustar hjlisl/* * Copyright (c) 1993 Eric Youngdale, Peter MacDonald, David Engel * and Hongjiu Lu. * * 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Eric Youngdale, * Peter MacDonald, David Engel and Hongjiu Lu. * 3. The name of the above contributors may not be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 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. */ /* Notice of general intent: * * The linux operating system generally contains large amounts of code * that fall under the GNU General Public License, or GPL for short. * This file contains source code that by it's very nature would always * be linked with an application program, and because of this a GPL type * of copyright on this file would place restrictions upon the * distribution of binary-only commercial software. Since the goal of the * Linux project as a whole is not to discourage the development and * distribution of commercial software for Linux, this file has been placed * under a more relaxed BSD-style of copyright. * * It is the general understanding of the above contributors that a * program executable linked to a library containing code that falls * under the GPL or GLPL style of license is not subject to the terms of * the GPL or GLPL license if the program executable(s) that are supplied * are linked to a shared library form of the GPL or GLPL library, and as long * as the form of the shared library is such that it is possible for * the end user to modify and rebuild the library and use it in * conjunction with the program executable. */ .file "gcrt0.S" .text __entry: /* * The first thing we do is try to load the shared library. If that * fails, it won't return. */ jbsr ___load_shared_libraries /* * This is important, and was missing from the new version... */ moveq #45,d0 moveq #0,d1 trap #0 movel d0,____brk_addr /* * Setup profiling */ pea __mcleanup jbsr _atexit addql #4,sp pea _etext pea __entry jbsr _monstartup addql #8,sp /* * Setup ___environ and call _main */ movel sp@(8),___environ movel ___fpu_control,sp@- jbsr ___setfpucw addql #4,sp /* Some functions may be needed. */ jbsr ___libc_init jbsr _main movel d0,sp@- jbsr _exit /* * Just in case _exit fails... We use trap #0 for __exit(). */ addql #4,sp done: moveq #1,d0 trap #0 bras done .align 4 ___shared_dummy__: .asciz "" .stabs "___SHARED_LIBRARIES__",25,0,0,___shared_dummy__ .data .align 4 ___shared_dummy1__: .long 0xfeeb1ed3 /* Magic number used by DLL code to make sure this is a real list */ .stabs "__SHARABLE_CONFLICTS__",25,0,0,___shared_dummy1__ ./libc-linux/sysdeps/linux/m68k/crt/Makefile100644 1676 334 1044 5521072117 16761 0ustar hjlisl# # Makefile for crt0.o of Linux # # LD=true MV=true override STATIC_SHARED=false override SHARED=false override DEBUG=false TOPDIR=../../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules CFLAGS= DEBUG_CFLAGS= PROFILE_CFLAGS= CHECKER_CFLAGS= ifeq ($CHECKER),true) lib::: $(CHECKER_DIR)/chkrcrt0.o endif ifeq ($(PROFILE),true) lib:: $(PROFILE_DIR)/gcrt0.o endif ifeq ($(STATIC),true) lib:: $(STATIC_DIR)/crt0.o endif lib:: @true realclean clean: $(RM) -f core *.s *.o *.a tmp_make foo depend: @echo No dependency in `pwd`. ./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.h.orig100644 1676 334 4435 5521072204 17154 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; \ bcc Lexit; \ 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/linux/m68k/____sig.S100644 1676 334 1053 5521072115 16231 0ustar hjlisl.globl ____sig_restore .globl ____masksig_restore ____sig_restore: addql #4,sp | signr /* popl %eax popl %ecx popl %edx popfl*/ rts ____masksig_restore: #if defined(__PIC__) || defined(__pic__) pushl %ebx call L3 L3: popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-L3],%ebx addl $8,%esp # signr call ___sigsetmask@PLT # old blocking addl $8,%esp popl %ebx popl %eax popl %ecx popl %edx popfl #else addql #4,sp | signr jbsr ___sigsetmask | old blocking addql #4,sp /* popl %eax popl %ecx popl %edx popfl */ #endif rts ./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/linux/m68k/__brk.c100644 1676 334 564 5521072115 15735 0ustar hjlisl#include #include #include void * ___brk_addr = 0; int __brk(void * end_data_seg) { __asm__ volatile ("movel %2,d1\n\t" "moveq %1,d0\n\t" "trap #0\n\t" "movel d0,%0" :"=g" (___brk_addr) :"i" (SYS_brk),"g" (end_data_seg) : "d0", "d1"); if (___brk_addr == end_data_seg) return 0; errno = ENOMEM; return -1; } ./libc-linux/sysdeps/linux/m68k/__fcntl.c100644 1676 334 1010 5521072115 16270 0ustar hjlisl#include #include #include #include int __fcntl(int fildes, int cmd, ...) { register int res asm ("d0") = SYS_fcntl; va_list arg; va_start(arg,cmd); __asm__("movel %2,d1\n\t" "movel %3,d2\n\t" "movel %4,d3\n\t" "trap #0\n\t" :"=g" (res) :"0" (SYS_fcntl),"g" (fildes),"g" (cmd), "d" (va_arg(arg,int)) : "d1", "d2", "d3"); if (res>=0) return res; errno = -res; va_end (arg); return -1; } /* */ ./libc-linux/sysdeps/linux/m68k/__fpu_control.c100644 1676 334 41 5521072115 17457 0ustar hjlislunsigned long __fpu_control = 0; ./libc-linux/sysdeps/linux/m68k/__ioctl.c100644 1676 334 1004 5521072115 16277 0ustar hjlisl#include #include #include #include int __ioctl(int fildes, int cmd, ...) { register int res asm ("d0") = SYS_ioctl; va_list arg; va_start(arg,cmd); __asm__("movel %2,d1\n\t" "movel %3,d2\n\t" "movel %4,d3\n\t" "trap #0\n\t" :"=g" (res) :"0" (SYS_ioctl),"g" (fildes),"g" (cmd), "d" (va_arg(arg,int)) : "d1", "d2", "d3"); if (res>=0) return res; errno = -res; va_end(arg); return -1; } ./libc-linux/sysdeps/linux/m68k/__open.c100644 1676 334 1036 5521072116 16134 0ustar hjlisl#include #include #include #include int __open(const char * filename, int flag, ...) { register int res asm ("d0") = SYS_open; va_list arg; va_start(arg,flag); __asm__("movel %2,d1\n\t" "movel %3,d2\n\t" "movel %4,d3\n\t" "trap #0\n\t" :"=g" (res) :"0" (SYS_open),"g" (filename),"g" (flag), "d" (va_arg(arg,int)) : "d1", "d2", "d3"); if (res>=0) return res; errno = -res; va_end(arg); return -1; } ./libc-linux/sysdeps/linux/m68k/__sbrk.c100644 1676 334 623 5521072116 16115 0ustar hjlisl#include #include #include extern void * ___brk_addr; void * __sbrk(ptrdiff_t increment) { void * tmp asm ("d1") = ___brk_addr+increment; __asm__ volatile ("movel %1,d0\n\t" "trap #0\n\t" "movel d0,%0" :"=g" (___brk_addr) :"i" (SYS_brk),"g" (tmp) : "d0"); if (___brk_addr == tmp) return tmp-increment; errno = ENOMEM; return ((void *) -1); } ./libc-linux/sysdeps/linux/m68k/__select.c100644 1676 334 1124 5521072116 16450 0ustar hjlisl#include #include #include int __select(int nd, fd_set * in, fd_set * out, fd_set * ex, struct timeval * tv) { long __res asm ("d0") = SYS_select; #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%ecx,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" : "=a" (__res) : "0" (SYS_select),"c" ((long) &nd)); #else __asm__ volatile ("movel %2,d1\n\t" "trap #0\n\t" : "=g" (__res) : "0" (SYS_select),"g" ((long) &nd) : "d1"); #endif if (__res >= 0) return (int) __res; errno = -__res; return -1; } ./libc-linux/sysdeps/linux/m68k/__setfpucw.c100644 1676 334 2123 5521072116 17031 0ustar hjlisl/* Copyright (C) 1993 Olaf Flebbe 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 void __setfpucw(unsigned long fpu_control) { volatile unsigned long fpcr; /* If user supplied _fpu_control, use it ! */ if (!fpu_control) { /* use linux defaults */ fpu_control = _FPU_DEFAULT; } /* Get Floating Point Control Register */ __asm__ volatile ("fmovel fpcr,%0" : "=g" (fpcr) : ); /* mask in */ fpcr &= _FPU_RESERVED; fpcr = fpcr | (fpu_control & ~_FPU_RESERVED); /* set Control Register */ __asm__ volatile ("fmovel %0,fpcr" : : "g" (fpcr)); } ./libc-linux/sysdeps/linux/m68k/__sigact.c100644 1676 334 1502 5521072116 16443 0ustar hjlisl#include #include #include extern void ___sig_restore(); extern void ___masksig_restore(); int __sigaction(int sig,struct sigaction * new, struct sigaction * old) { if (new) { if (new->sa_flags & SA_NOMASK) new->sa_restorer=___sig_restore; else new->sa_restorer=___masksig_restore; } #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%edi,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (sig) :"0" (SYS_sigaction),"D" (sig),"c" (new),"d" (old)); #else __asm__("movel %1,d0\n\t" "movel %2,d1\n\t" "movel %3,d2\n\t" "movel %4,d3\n\t" "trap #0\n\t" "movel d0,%0" : "=g" (sig) :"i" (SYS_sigaction), "g" (sig), "g" (new), "g" (old) : "d0", "d1", "d2", "d3"); #endif if (sig>=0) return 0; errno = -sig; return -1; } ./libc-linux/sysdeps/linux/m68k/getprio.c100644 1676 334 1201 5521072117 16341 0ustar hjlisl#include #include #include #define PZERO 15 int getpriority(int which, int who) { long res asm ("d0") = SYS_getpriority; #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%edx,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (res) :"0" (SYS_getpriority),"d" (which), "c" (who)); #else __asm__ volatile ("movel %2,d1\n\t" "movel %3,d2\n\t" "trap #0\n\t" :"=g" (res) :"0" (SYS_getpriority), "g" (which), "g" (who) : "d1", "d2"); #endif if (res >= 0) { errno = 0; return (int) PZERO - res; } errno = -res; return -1; } ./libc-linux/sysdeps/linux/m68k/ieee.c100644 1676 334 103 5521072117 15557 0ustar hjlisl#include unsigned long __fpu_control = _FPU_IEEE; ./libc-linux/sysdeps/linux/m68k/libc_exit.c100644 1676 334 306 5521072120 16611 0ustar hjlisl#include #include void _exit(int exit_code) { __asm__ volatile ("moveq %0,d0;movel %1,d1;trap #0" ::"i" (SYS_exit),"g" (exit_code) : "d0", "d1"); } ./libc-linux/sysdeps/linux/m68k/math/ 40755 1676 334 0 5525262645 15401 5ustar hjlisl./libc-linux/sysdeps/linux/m68k/math/Makefile100644 1676 334 1327 5525262703 17134 0ustar hjlisl# # This is Makefile of the math lib for Linux for the m68k # MATH=true override DEBUG=false override PROFILE=false TOPDIR=../../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS = -I. MATHFLAGS=-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 \ __drem.c asinh.c atan.c atan2.c cos.c cosh.c exp.c \ expm1.c fabs.c fmod.c hypot.c sin.c sinh.c tan.c tanh.c SRC2S= 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/m68k/math/__copysign.c100644 1676 334 2224 5521072120 17752 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 "ieee754.h" /* Return X with its signed changed to Y's. */ double DEFUN(__copysign, (x, y), double x AND double y) { union ieee754_double *ux = (union ieee754_double *) &x; union ieee754_double *uy = (union ieee754_double *) &y; ux->ieee.negative = uy->ieee.negative; return x; } ./libc-linux/sysdeps/linux/m68k/math/__drem.c100644 1676 334 1740 5521072120 17050 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 #define __NO_MATH_INLINES #include #undef drem double DEFUN(__drem, (x, y), double x AND double y) { return ____drem(x, y); } ./libc-linux/sysdeps/linux/m68k/math/__expm1.c100644 1676 334 70 5521072121 17107 0ustar hjlisl#define FUNC __expm1 #define OP expm1 #include ./libc-linux/sysdeps/linux/m68k/math/__infnan.c100644 1676 334 2735 5521072121 17400 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 #include #include "ieee754.h" /* Deal with an infinite or NaN result. If ERROR is ERANGE, result is +Inf; if ERROR is - ERANGE, result is -Inf; otherwise result is NaN. This will set `errno' to either ERANGE or EDOM, and may return an infinity or NaN, or may do something else. */ double DEFUN(__infnan, (error), int error) { switch (error) { case ERANGE: errno = ERANGE; return HUGE_VAL; case - ERANGE: errno = ERANGE; return - HUGE_VAL; default: errno = EDOM; #ifdef _SNAN return _SNAN; #else return NAN; #endif } } ./libc-linux/sysdeps/linux/m68k/math/__isinf.c100644 1676 334 2525 5521072121 17234 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 "ieee754.h" #undef __isinf /* Return 0 if VALUE is finite or NaN, +1 if it is +Infinity, -1 if it is -Infinity. */ int DEFUN(__isinf, (value), double value) { union ieee754_double *u = (union ieee754_double *) &value; /* An IEEE 754 infinity has an exponent with the maximum possible value and a zero mantissa. */ if ((u->ieee.exponent & 0x7ff) == 0x7ff && u->ieee.mantissa0 == 0 && u->ieee.mantissa1 == 0) return u->ieee.negative ? -1 : 1; return 0; } ./libc-linux/sysdeps/linux/m68k/math/__isnan.c100644 1676 334 2352 5521072121 17232 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 "ieee754.h" #undef __isnan /* Return nonzero if VALUE is not a number. */ int DEFUN(__isnan, (value), double value) { union ieee754_double *u = (union ieee754_double *) &value; /* IEEE 754 NaN's have the maximum possible exponent and a nonzero mantissa. */ return ((u->ieee.exponent & 0x7ff) == 0x7ff && (u->ieee.mantissa0 != 0 || u->ieee.mantissa1 != 0)); } ./libc-linux/sysdeps/linux/m68k/math/__rint.c100644 1676 334 66 5521072121 17036 0ustar hjlisl#define FUNC __rint #define OP intr #include ./libc-linux/sysdeps/linux/m68k/math/acos.c100644 1676 334 1745 5521072122 16557 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 #define __NO_MATH_INLINES #include #ifndef FUNC #define FUNC acos #endif double DEFUN(FUNC, (x), double x) { return __m81_u(FUNC)(x); } ./libc-linux/sysdeps/linux/m68k/math/acosh.c100644 1676 334 7402 5521072122 16723 0ustar hjlisl/* * Copyright (c) 1985 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. */ #ifndef lint static char sccsid[] = "@(#)acosh.c 5.6 (Berkeley) 10/9/90"; #endif /* not lint */ /* ACOSH(X) * RETURN THE INVERSE HYPERBOLIC COSINE OF X * DOUBLE PRECISION (VAX D FORMAT 56 BITS, IEEE DOUBLE 53 BITS) * CODED IN C BY K.C. NG, 2/16/85; * REVISED BY K.C. NG on 3/6/85, 3/24/85, 4/16/85, 8/17/85. * * Required system supported functions : * sqrt(x) * * Required kernel function: * log1p(x) ...return log(1+x) * * Method : * Based on * acosh(x) = log [ x + sqrt(x*x-1) ] * we have * acosh(x) := log1p(x)+ln2, if (x > 1.0E20); else * acosh(x) := log1p( sqrt(x-1) * (sqrt(x-1) + sqrt(x+1)) ) . * These formulae avoid the over/underflow complication. * * Special cases: * acosh(x) is NaN with signal if x<1. * acosh(NaN) is NaN without signal. * * Accuracy: * acosh(x) returns the exact inverse hyperbolic cosine of x nearly * rounded. In a test run with 512,000 random arguments on a VAX, the * maximum observed error was 3.30 ulps (units of the last place) at * x=1.0070493753568216 . * * Constants: * The hexadecimal values are the intended ones for the following constants. * The decimal values may be used, provided that the compiler will convert * from decimal to binary accurately enough to produce the hexadecimal values * shown. */ #include "mathimpl.h" vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76) #ifdef vccast #define ln2hi vccast(ln2hi) #define ln2lo vccast(ln2lo) #endif double acosh(x) double x; { double t,big=1.E20; /* big+1==big */ #if !defined(vax)&&!defined(tahoe) if(x!=x) return(x); /* x is NaN */ #endif /* !defined(vax)&&!defined(tahoe) */ /* return log1p(x) + log(2) if x is large */ if(x>big) {t=log1p(x)+ln2lo; return(t+ln2hi);} t=sqrt(x-1.0); return(log1p(t*(t+sqrt(x+1.0)))); } ./libc-linux/sysdeps/linux/m68k/math/asin.c100644 1676 334 44 5521072122 16513 0ustar hjlisl#define FUNC asin #include ./libc-linux/sysdeps/linux/m68k/math/asinh.c100644 1676 334 7473 5521072122 16740 0ustar hjlisl/* * Copyright (c) 1985 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. */ #ifndef lint static char sccsid[] = "@(#)asinh.c 5.6 (Berkeley) 10/9/90"; #endif /* not lint */ /* ASINH(X) * RETURN THE INVERSE HYPERBOLIC SINE OF X * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS) * CODED IN C BY K.C. NG, 2/16/85; * REVISED BY K.C. NG on 3/7/85, 3/24/85, 4/16/85. * * Required system supported functions : * copysign(x,y) * sqrt(x) * * Required kernel function: * log1p(x) ...return log(1+x) * * Method : * Based on * asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ] * we have * asinh(x) := x if 1+x*x=1, * := sign(x)*(log1p(x)+ln2)) if sqrt(1+x*x)=x, else * := sign(x)*log1p(|x| + |x|/(1/|x| + sqrt(1+(1/|x|)^2)) ) * * Accuracy: * asinh(x) returns the exact inverse hyperbolic sine of x nearly rounded. * In a test run with 52,000 random arguments on a VAX, the maximum * observed error was 1.58 ulps (units in the last place). * * Constants: * The hexadecimal values are the intended ones for the following constants. * The decimal values may be used, provided that the compiler will convert * from decimal to binary accurately enough to produce the hexadecimal values * shown. */ #include "mathimpl.h" vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000) vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC) ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000) ic(ln2lo, 1.9082149292705877000E-10, -33, 1.A39EF35793C76) #ifdef vccast #define ln2hi vccast(ln2hi) #define ln2lo vccast(ln2lo) #endif double asinh(x) double x; { double t,s; static const double small=1.0E-10, /* fl(1+small*small) == 1 */ big =1.0E20, /* fl(1+big) == big */ one =1.0 ; #if !defined(vax)&&!defined(tahoe) if(x!=x) return(x); /* x is NaN */ #endif /* !defined(vax)&&!defined(tahoe) */ if((t=copysign(x,one))>small) if(t big */ {s=log1p(t)+ln2lo; return(copysign(s+ln2hi,x));} else /* if |x| < small */ return(x); } ./libc-linux/sysdeps/linux/m68k/math/atan.c100644 1676 334 44 5521072122 16504 0ustar hjlisl#define FUNC atan #include ./libc-linux/sysdeps/linux/m68k/math/atan2.c100644 1676 334 3412 5521072123 16631 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 #ifdef __GNUC__ double DEFUN(atan2, (y, x), double y AND double x) { static CONST double one = 1.0, zero = 0.0; double signx, signy; double pi, PIo4, PIo2; if (__isnan(x)) return x; if (__isnan(y)) return y; signy = __copysign(one, y); signx = __copysign(one, x); asm("fmovecr%.x %1, %0" : "=f" (pi) : "i" (0)); PIo2 = pi / 2; PIo4 = pi / 4; if (y == zero) return signx == one ? y : __copysign(pi, signy); if (x == zero) return __copysign(PIo2, signy); if (__isinf(x)) { if (__isinf(y)) return __copysign(signx == one ? PIo4 : 3 * PIo4, signy); else return __copysign(signx == one ? zero : pi, signy); } if (__isinf(y)) return __copysign(PIo2, signy); y = fabs(y); if (x < 0.0) /* X is negative. */ return __copysign(pi - atan(y / -x), signy); return __copysign(atan(y / x), signy); } #else #include #endif ./libc-linux/sysdeps/linux/m68k/math/atanh.c100644 1676 334 45 5521072123 16656 0ustar hjlisl#define FUNC atanh #include ./libc-linux/sysdeps/linux/m68k/math/ceil.c100644 1676 334 46 5521072123 16500 0ustar hjlisl #define FUNC ceil #include ./libc-linux/sysdeps/linux/m68k/math/cos.c100644 1676 334 43 5521072123 16345 0ustar hjlisl#define FUNC cos #include ./libc-linux/sysdeps/linux/m68k/math/cosh.c100644 1676 334 44 5521072123 16516 0ustar hjlisl#define FUNC cosh #include ./libc-linux/sysdeps/linux/m68k/math/erf.c100644 1676 334 5066 5521072124 16410 0ustar hjlisl/* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ #if 0 #ifndef lint static char sccsid[] = "@(#)erf.c 5.2 (Berkeley) 4/29/88"; #endif /* not lint */ #endif /* C program for floating point error function erf(x) returns the error function of its argument erfc(x) returns 1.0-erf(x) erf(x) is defined by ${2 over sqrt(pi)} int from 0 to x e sup {-t sup 2} dt$ the entry for erfc is provided because of the extreme loss of relative accuracy if erf(x) is called for large x and the result subtracted from 1. (e.g. for x= 10, 12 places are lost). There are no error returns. Calls exp. Coefficients for large x are #5667 from Hart & Cheney (18.72D). */ #include #define M 7 #define N 9 static double torp = 1.1283791670955125738961589031; static double p1[] = { 0.804373630960840172832162e5, 0.740407142710151470082064e4, 0.301782788536507577809226e4, 0.380140318123903008244444e2, 0.143383842191748205576712e2, -.288805137207594084924010e0, 0.007547728033418631287834e0, }; static double q1[] = { 0.804373630960840172826266e5, 0.342165257924628539769006e5, 0.637960017324428279487120e4, 0.658070155459240506326937e3, 0.380190713951939403753468e2, 0.100000000000000000000000e1, 0.0, }; static double p2[] = { 0.18263348842295112592168999e4, 0.28980293292167655611275846e4, 0.2320439590251635247384768711e4, 0.1143262070703886173606073338e4, 0.3685196154710010637133875746e3, 0.7708161730368428609781633646e2, 0.9675807882987265400604202961e1, 0.5641877825507397413087057563e0, 0.0, }; static double q2[] = { 0.18263348842295112595576438e4, 0.495882756472114071495438422e4, 0.60895424232724435504633068e4, 0.4429612803883682726711528526e4, 0.2094384367789539593790281779e4, 0.6617361207107653469211984771e3, 0.1371255960500622202878443578e3, 0.1714980943627607849376131193e2, 1.0, }; double erf(double arg) { int sign; double argsq; double d, n; int i; sign = 1; if(arg < 0.){ arg = -arg; sign = -1; } if(arg < 0.5){ argsq = arg*arg; for(n=0,d=0,i=M-1; i>=0; i--){ n = n*argsq + p1[i]; d = d*argsq + q1[i]; } return(sign*torp*arg*n/d); } if(arg >= 10.) return(sign*1.); return(sign*(1. - erfc(arg))); } double erfc(double arg) { double n, d; int i; if(arg < 0.) return(2. - erfc(-arg)); /* if(arg < 0.5) return(1. - erf(arg)); */ if(arg >= 10.) return(0.); for(n=0,d=0,i=N-1; i>=0; i--){ n = n*arg + p2[i]; d = d*arg + q2[i]; } return(exp(-arg*arg)*n/d); } ./libc-linux/sysdeps/linux/m68k/math/exp.c100644 1676 334 500 5521072124 16374 0ustar hjlisl#define FUNC exp #define OP etox #include double pow10(double __y) { double __result; __asm("ftentox%.x %1, %0" : "=f" (__result) : "f" (__y)); return __result; } double pow2(double __y) { double __result; __asm("ftwotox%.x %1, %0" : "=f" (__result) : "f" (__y)); return __result; } ./libc-linux/sysdeps/linux/m68k/math/expm1.c100644 1676 334 1557 5521072124 16667 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. */ #define FUNC expm1 #define OP expm1 #include ./libc-linux/sysdeps/linux/m68k/math/fabs.c100644 1676 334 63 5521072142 16477 0ustar hjlisl#define FUNC fabs #define OP abs #include ./libc-linux/sysdeps/linux/m68k/math/floor.c100644 1676 334 66 5521072142 16710 0ustar hjlisl#define FUNC floor #define OP intrz #include ./libc-linux/sysdeps/linux/m68k/math/fmod.c100644 1676 334 1711 5521072142 16552 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 #define __NO_MATH_INLINES #include double DEFUN(fmod, (x, y), double x AND double y) { return __fmod(x, y); } ./libc-linux/sysdeps/linux/m68k/math/frexp.c100644 1676 334 2035 5521072142 16751 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 /* Stores binary exponent of d in e, and returns whole fraction of d * (with binary exponent of 0) (special case for d=0) */ double frexp(double d, int *e) { union ieee754_double *dp = (union ieee754_double *)&d; if (d == 0.0) /* value is zero, return exponent of 0 */ *e = 0.0; else { *e = dp->ieee.exponent - _IEEE754_DOUBLE_BIAS + 1; dp->ieee.exponent = _IEEE754_DOUBLE_BIAS - 1; } return d; } ./libc-linux/sysdeps/linux/m68k/math/hypot.c100644 1676 334 1724 5521072142 16774 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 /* Return `sqrt(x*x + y*y)'. */ double DEFUN(hypot, (x, y), double x AND double y) { return sqrt(x*x + y*y); } ./libc-linux/sysdeps/linux/m68k/math/j0.c100644 1676 334 10144 5521072143 16157 0ustar hjlisl#include /* floating point Bessel's function of the first and second kinds of order zero j0(x) returns the value of J0(x) for all real values of x. There are no error returns. Calls sin, cos, sqrt. There is a niggling bug in J0 which causes errors up to 2e-16 for x in the interval [-8,8]. The bug is caused by an inappropriate order of summation of the series. rhm will fix it someday. Coefficients are from Hart & Cheney. #5849 (19.22D) #6549 (19.25D) #6949 (19.41D) y0(x) returns the value of Y0(x) for positive real values of x. For x<=0, error number EDOM is set and a large negative value is returned. Calls sin, cos, sqrt, log, j0. The values of Y0 have not been checked to more than ten places. Coefficients are from Hart & Cheney. #6245 (18.78D) #6549 (19.25D) #6949 (19.41D) */ static void asympt(double); static double pzero, qzero; static double tpi = .6366197723675813430755350535e0; static double pio4 = .7853981633974483096156608458e0; static double p1[] = { 0.4933787251794133561816813446e21, -.1179157629107610536038440800e21, 0.6382059341072356562289432465e19, -.1367620353088171386865416609e18, 0.1434354939140344111664316553e16, -.8085222034853793871199468171e13, 0.2507158285536881945555156435e11, -.4050412371833132706360663322e8, 0.2685786856980014981415848441e5, }; static double q1[] = { 0.4933787251794133562113278438e21, 0.5428918384092285160200195092e19, 0.3024635616709462698627330784e17, 0.1127756739679798507056031594e15, 0.3123043114941213172572469442e12, 0.6699987672982239671814028660e9, 0.1114636098462985378182402543e7, 0.1363063652328970604442810507e4, 1.0 }; static double p2[] = { 0.5393485083869438325262122897e7, 0.1233238476817638145232406055e8, 0.8413041456550439208464315611e7, 0.2016135283049983642487182349e7, 0.1539826532623911470917825993e6, 0.2485271928957404011288128951e4, 0.0, }; static double q2[] = { 0.5393485083869438325560444960e7, 0.1233831022786324960844856182e8, 0.8426449050629797331554404810e7, 0.2025066801570134013891035236e7, 0.1560017276940030940592769933e6, 0.2615700736920839685159081813e4, 1.0, }; static double p3[] = { -.3984617357595222463506790588e4, -.1038141698748464093880530341e5, -.8239066313485606568803548860e4, -.2365956170779108192723612816e4, -.2262630641933704113967255053e3, -.4887199395841261531199129300e1, 0.0, }; static double q3[] = { 0.2550155108860942382983170882e6, 0.6667454239319826986004038103e6, 0.5332913634216897168722255057e6, 0.1560213206679291652539287109e6, 0.1570489191515395519392882766e5, 0.4087714673983499223402830260e3, 1.0, }; static double p4[] = { -.2750286678629109583701933175e20, 0.6587473275719554925999402049e20, -.5247065581112764941297350814e19, 0.1375624316399344078571335453e18, -.1648605817185729473122082537e16, 0.1025520859686394284509167421e14, -.3436371222979040378171030138e11, 0.5915213465686889654273830069e8, -.4137035497933148554125235152e5, }; static double q4[] = { 0.3726458838986165881989980e21, 0.4192417043410839973904769661e19, 0.2392883043499781857439356652e17, 0.9162038034075185262489147968e14, 0.2613065755041081249568482092e12, 0.5795122640700729537480087915e9, 0.1001702641288906265666651753e7, 0.1282452772478993804176329391e4, 1.0, }; double j0(double arg) { double argsq, n, d; int i; if(arg < 0.) arg = -arg; if(arg > 8.){ asympt(arg); n = arg - pio4; return(sqrt(tpi/arg)*(pzero*cos(n) - qzero*sin(n))); } argsq = arg*arg; for(n=0,d=0,i=8;i>=0;i--){ n = n*argsq + p1[i]; d = d*argsq + q1[i]; } return(n/d); } double y0(double arg) { double argsq, n, d; int i; if(arg <= 0.){ return(-HUGE_VAL); } if(arg > 8.){ asympt(arg); n = arg - pio4; return(sqrt(tpi/arg)*(pzero*sin(n) + qzero*cos(n))); } argsq = arg*arg; for(n=0,d=0,i=8;i>=0;i--){ n = n*argsq + p4[i]; d = d*argsq + q4[i]; } return(n/d + tpi*j0(arg)*log(arg)); } static void asympt(double arg) { double zsq, n, d; int i; zsq = 64./(arg*arg); for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p2[i]; d = d*zsq + q2[i]; } pzero = n/d; for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p3[i]; d = d*zsq + q3[i]; } qzero = (8./arg)*(n/d); } ./libc-linux/sysdeps/linux/m68k/math/j1.c100644 1676 334 10252 5521072143 16160 0ustar hjlisl#include /* floating point Bessel's function of the first and second kinds of order one j1(x) returns the value of J1(x) for all real values of x. There are no error returns. Calls sin, cos, sqrt. There is a niggling bug in J1 which causes errors up to 2e-16 for x in the interval [-8,8]. The bug is caused by an inappropriate order of summation of the series. rhm will fix it someday. Coefficients are from Hart & Cheney. #6050 (20.98D) #6750 (19.19D) #7150 (19.35D) y1(x) returns the value of Y1(x) for positive real values of x. For x<=0, error number EDOM is set and a large negative value is returned. Calls sin, cos, sqrt, log, j1. The values of Y1 have not been checked to more than ten places. Coefficients are from Hart & Cheney. #6447 (22.18D) #6750 (19.19D) #7150 (19.35D) */ static void asympt(double); static double pzero, qzero; static double tpi = .6366197723675813430755350535e0; static double pio4 = .7853981633974483096156608458e0; static double p1[] = { 0.581199354001606143928050809e21, -.6672106568924916298020941484e20, 0.2316433580634002297931815435e19, -.3588817569910106050743641413e17, 0.2908795263834775409737601689e15, -.1322983480332126453125473247e13, 0.3413234182301700539091292655e10, -.4695753530642995859767162166e7, 0.2701122710892323414856790990e4, }; static double q1[] = { 0.1162398708003212287858529400e22, 0.1185770712190320999837113348e20, 0.6092061398917521746105196863e17, 0.2081661221307607351240184229e15, 0.5243710262167649715406728642e12, 0.1013863514358673989967045588e10, 0.1501793594998585505921097578e7, 0.1606931573481487801970916749e4, 1.0, }; static double p2[] = { -.4435757816794127857114720794e7, -.9942246505077641195658377899e7, -.6603373248364939109255245434e7, -.1523529351181137383255105722e7, -.1098240554345934672737413139e6, -.1611616644324610116477412898e4, 0.0, }; static double q2[] = { -.4435757816794127856828016962e7, -.9934124389934585658967556309e7, -.6585339479723087072826915069e7, -.1511809506634160881644546358e7, -.1072638599110382011903063867e6, -.1455009440190496182453565068e4, 1.0, }; static double p3[] = { 0.3322091340985722351859704442e5, 0.8514516067533570196555001171e5, 0.6617883658127083517939992166e5, 0.1849426287322386679652009819e5, 0.1706375429020768002061283546e4, 0.3526513384663603218592175580e2, 0.0, }; static double q3[] = { 0.7087128194102874357377502472e6, 0.1819458042243997298924553839e7, 0.1419460669603720892855755253e7, 0.4002944358226697511708610813e6, 0.3789022974577220264142952256e5, 0.8638367769604990967475517183e3, 1.0, }; static double p4[] = { -.9963753424306922225996744354e23, 0.2655473831434854326894248968e23, -.1212297555414509577913561535e22, 0.2193107339917797592111427556e20, -.1965887462722140658820322248e18, 0.9569930239921683481121552788e15, -.2580681702194450950541426399e13, 0.3639488548124002058278999428e10, -.2108847540133123652824139923e7, 0.0, }; static double q4[] = { 0.5082067366941243245314424152e24, 0.5435310377188854170800653097e22, 0.2954987935897148674290758119e20, 0.1082258259408819552553850180e18, 0.2976632125647276729292742282e15, 0.6465340881265275571961681500e12, 0.1128686837169442121732366891e10, 0.1563282754899580604737366452e7, 0.1612361029677000859332072312e4, 1.0, }; double j1(double arg) { double xsq, n, d, x; int i; x = arg; if(x < 0.) x = -x; if(x > 8.){ asympt(x); n = x - 3.*pio4; n = sqrt(tpi/x)*(pzero*cos(n) - qzero*sin(n)); if(arg <0.) n = -n; return(n); } xsq = x*x; for(n=0,d=0,i=8;i>=0;i--){ n = n*xsq + p1[i]; d = d*xsq + q1[i]; } return(arg*n/d); } double y1(double arg) { double xsq, n, d, x; int i; x = arg; if(x <= 0.){ return(-HUGE_VAL); } if(x > 8.){ asympt(x); n = x - 3*pio4; return(sqrt(tpi/x)*(pzero*sin(n) + qzero*cos(n))); } xsq = x*x; for(n=0,d=0,i=9;i>=0;i--){ n = n*xsq + p4[i]; d = d*xsq + q4[i]; } return(x*n/d + tpi*(j1(x)*log(x)-1./x)); } static void asympt(double arg) { double zsq, n, d; int i; zsq = 64./(arg*arg); for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p2[i]; d = d*zsq + q2[i]; } pzero = n/d; for(n=0,d=0,i=6;i>=0;i--){ n = n*zsq + p3[i]; d = d*zsq + q3[i]; } qzero = (8./arg)*(n/d); } ./libc-linux/sysdeps/linux/m68k/math/jn.c100644 1676 334 3121 5521072143 16232 0ustar hjlisl#include /* floating point Bessel's function of the first and second kinds and of integer order. int n; double x; jn(n,x); returns the value of Jn(x) for all integer values of n and all real values of x. There are no error returns. Calls j0, j1. For n=0, j0(x) is called, for n=1, j1(x) is called, for nx, a continued fraction approximation to j(n,x)/j(n-1,x) is evaluated and then backward recursion is used starting from a supposed value for j(n,x). The resulting value of j(0,x) is compared with the actual value to correct the supposed value of j(n,x). yn(n,x) is similar in all respects, except that forward recursion is used for all values of n>1. */ double jn(int n, double x) { int i; double a, b, temp; double xsq, t; if(n<0){ n = -n; x = -x; } if(n==0) return(j0(x)); if(n==1) return(j1(x)); if(x == 0.) return(0.); if(n>x) goto recurs; a = j0(x); b = j1(x); for(i=1;in;i--){ t = xsq/(2.*i - t); } t = x/(2.*n-t); a = t; b = 1; for(i=n-1;i>0;i--){ temp = b; b = (2.*i/x)*b - a; a = temp; } return(t*j0(x)/b); } double yn(int n, double x) { int i; int sign; double a, b, temp; if (x <= 0) { return(-HUGE_VAL); } sign = 1; if(n<0){ n = -n; if(n%2 == 1) sign = -1; } if(n==0) return(y0(x)); if(n==1) return(sign*y1(x)); a = y0(x); b = y1(x); for(i=1;i #endif #if defined(vax)||defined(tahoe) #include #endif /* defined(vax)||defined(tahoe) */ int signgam = 0; static const double goobie = 0.9189385332046727417803297; /* log(2*pi)/2 */ static const double pi = 3.1415926535897932384626434; #define M 6 #define N 8 static const double p1[] = { 0.83333333333333101837e-1, -.277777777735865004e-2, 0.793650576493454e-3, -.5951896861197e-3, 0.83645878922e-3, -.1633436431e-2, }; static const double p2[] = { -.42353689509744089647e5, -.20886861789269887364e5, -.87627102978521489560e4, -.20085274013072791214e4, -.43933044406002567613e3, -.50108693752970953015e2, -.67449507245925289918e1, 0.0, }; static const double q2[] = { -.42353689509744090010e5, -.29803853309256649932e4, 0.99403074150827709015e4, -.15286072737795220248e4, -.49902852662143904834e3, 0.18949823415702801641e3, -.23081551524580124562e2, 0.10000000000000000000e1, }; static double pos(double), neg(double), asym(double); double lgamma(double arg) { signgam = 1.; if(arg <= 0.) return(neg(arg)); if(arg > 8.) return(asym(arg)); return(log(pos(arg))); } static double asym(double arg) { double n, argsq; int i; argsq = 1./(arg*arg); for(n=0,i=M-1; i>=0; i--){ n = n*argsq + p1[i]; } return((arg-.5)*log(arg) - arg + goobie + n/arg); } static double neg(double arg) { double t; arg = -arg; /* * to see if arg were a true integer, the old code used the * mathematically correct observation: * sin(n*pi) = 0 <=> n is an integer. * but in finite precision arithmetic, sin(n*PI) will NEVER * be zero simply because n*PI is a rational number. hence * it failed to work with our newer, more accurate sin() * which uses true pi to do the argument reduction... * temp = sin(pi*arg); */ t = floor(arg); if (arg - t > 0.5e0) t += 1.e0; /* t := integer nearest arg */ #if defined(vax)||defined(tahoe) if (arg == t) { return(infnan(ERANGE)); /* +INF */ } #endif /* defined(vax)||defined(tahoe) */ signgam = (int) (t - 2*floor(t/2)); /* signgam = 1 if t was odd, */ /* 0 if t was even */ signgam = signgam - 1 + signgam; /* signgam = 1 if t was odd, */ /* -1 if t was even */ t = arg - t; /* -0.5 <= t <= 0.5 */ if (t < 0.e0) { t = -t; signgam = -signgam; } return(-log(arg*pos(arg)*sin(pi*t)/pi)); } static double pos(double arg) { double n, d, s; register i; if(arg < 2.) return(pos(arg+1.)/arg); if(arg > 3.) return((arg-1.)*pos(arg-1.)); s = arg - 2.; for(n=0,d=0,i=N-1; i>=0; i--){ n = n*s + p2[i]; d = d*s + q2[i]; } return(n/d); } ./libc-linux/sysdeps/linux/m68k/math/log.c100644 1676 334 63 5521072164 16351 0ustar hjlisl#define FUNC log #define OP logn #include ./libc-linux/sysdeps/linux/m68k/math/log10.c100644 1676 334 45 5521072164 16512 0ustar hjlisl#define FUNC log10 #include ./libc-linux/sysdeps/linux/m68k/math/log1p.c100644 1676 334 45 5521072164 16612 0ustar hjlisl#define FUNC log1p #include ./libc-linux/sysdeps/linux/m68k/math/mathimpl.h100644 1676 334 10142 5521072164 17467 0ustar hjlisl/* This part here added by roland@prep.ai.mit.edu for the GNU C library. */ #include /* Done first so we can #undef. */ #include #if __BYTE_ORDER == __LITTLE_ENDIAN #undef national #define national #endif #undef isinf #define isinf __isinf #undef isnan #define isnan __isnan #undef infnan #define infnan __infnan #undef copysign #define copysign __copysign #undef scalb #define scalb __scalb #undef drem #define drem __drem #undef logb #define logb __logb #undef __finite #undef finite #define finite __finite #undef expm1 #define expm1 __expm1 #define exp__E __exp__E #define log__L __log__L /* * 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. * * @(#)mathimpl.h 5.4 (Berkeley) 3/5/91 */ #include #include #if defined(vax)||defined(tahoe) /* Deal with different ways to concatenate in cpp */ # ifdef __STDC__ # define cat3(a,b,c) a ## b ## c # else # define cat3(a,b,c) a/**/b/**/c # endif /* Deal with vax/tahoe byte order issues */ # ifdef vax # define cat3t(a,b,c) cat3(a,b,c) # else # define cat3t(a,b,c) cat3(a,c,b) # endif # define vccast(name) (*(const double *)(cat3(name,,x))) /* * Define a constant to high precision on a Vax or Tahoe. * * Args are the name to define, the decimal floating point value, * four 16-bit chunks of the float value in hex * (because the vax and tahoe differ in float format!), the power * of 2 of the hex-float exponent, and the hex-float mantissa. * Most of these arguments are not used at compile time; they are * used in a post-check to make sure the constants were compiled * correctly. * * People who want to use the constant will have to do their own * #define foo vccast(foo) * since CPP cannot do this for them from inside another macro (sigh). * We define "vccast" if this needs doing. */ # define vc(name, value, x1,x2,x3,x4, bexp, xval) \ static const long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)}; # define ic(name, value, bexp, xval) ; #else /* vax or tahoe */ /* Hooray, we have an IEEE machine */ # undef vccast # define vc(name, value, x1,x2,x3,x4, bexp, xval) ; # define ic(name, value, bexp, xval) \ static const double name = value; #endif /* defined(vax)||defined(tahoe) */ /* * Functions internal to the math package, yet not static. */ extern double exp__E(); extern double log__L(); ./libc-linux/sysdeps/linux/m68k/math/pow.c100644 1676 334 1707 5521072164 16443 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 #define __NO_MATH_INLINES #include double DEFUN(pow, (x, y), double x AND double y) { return __pow(x, y); } ./libc-linux/sysdeps/linux/m68k/math/sin.c100644 1676 334 43 5521072165 16360 0ustar hjlisl#define FUNC sin #include ./libc-linux/sysdeps/linux/m68k/math/sinh.c100644 1676 334 44 5521072165 16531 0ustar hjlisl#define FUNC sinh #include ./libc-linux/sysdeps/linux/m68k/math/sqrt.c100644 1676 334 44 5521072165 16561 0ustar hjlisl#define FUNC sqrt #include ./libc-linux/sysdeps/linux/m68k/math/tan.c100644 1676 334 43 5521072165 16351 0ustar hjlisl#define FUNC tan #include ./libc-linux/sysdeps/linux/m68k/math/tanh.c100644 1676 334 44 5521072165 16522 0ustar hjlisl#define FUNC tanh #include ./libc-linux/sysdeps/linux/m68k/math/test-math.c100644 1676 334 3413 5521072203 17532 0ustar hjlisl#include #include #include #include int DEFUN_VOID(main) { CONST char str[] = "123.456"; double x,h,li,lr,a,lrr, y; x = atof (str); printf ("%g %g\n", x, pow (10.0, 3.0)); x = 0.5; y = cos (x); printf("cos (%g) = %g\n", x, y); x = acos (y); printf("acos (%g) = %g\n", y, x); y = sin (x); printf("sin (%g) = %g\n", x, y); x = asin (y); printf("asin (%g) = %g\n", y, x); x = cosh(2.0); printf("cosh(2.0) = %g\n", x); printf("cosh(%g) = 2.0\n", acosh (x)); x = sinh(2.0); printf("sinh(2.0) = %g\n", x); printf("sinh(%g) = 2.0\n", asinh (x)); x = sinh(3.0); printf("sinh(3.0) = %g\n", x); h = hypot(2.0,3.0); printf("h=%g\n", h); a = atan2(3.0, 2.0); printf("atan2(3,2) = %g\n", a); lr = pow(h,4.0); printf("pow(%g,4.0) = %g\n", h, lr); printf("pow2(4.0) = %g\n", pow2 (4.0)); lrr = lr; li = 4.0 * a; lr = lr / exp(a*5.0); printf("%g / exp(%g * 5) = %g\n", lrr, exp(a*5.0), lr); lrr = li; li += 5.0 * log(h); printf("%g + 5*log(%g) = %g\n", lrr, h, li); printf("cos(%g) = %g, sin(%g) = %g\n", li, cos(li), li, sin(li)); x = drem(10.3435,6.2831852); printf("drem(10.3435,6.2831852) = %g\n", x); x = drem(-10.3435,6.2831852); printf("drem(-10.3435,6.2831852) = %g\n", x); x = drem(-10.3435,-6.2831852); printf("drem(-10.3435,-6.2831852) = %g\n", x); x = drem(10.3435,-6.2831852); printf("drem(10.3435,-6.2831852) = %g\n", x); printf("x%8.6gx\n", .5); printf("x%-8.6gx\n", .5); printf("x%6.6gx\n", .5); { double x = atof ("-1e-17-"); printf ("%g %c= %g %s!\n", x, x == -1e-17 ? '=' : '!', -1e-17, x == -1e-17 ? "Worked" : "Failed"); } return 0; } ./libc-linux/sysdeps/linux/m68k/ptrace.c100644 1676 334 1555 5521072203 16156 0ustar hjlisl#include #include #include int ptrace(int request, int pid, int addr, int data) { long ret; long res; if (request > 0 && request < 4) (long *)data = &ret; #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%edi,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (res) :"0" (SYS_ptrace),"D" (request), "c" (pid), "d" (addr), "S" (data)); #else __asm__ volatile ("movel %1,d0\n\t" "movel %2,d1\n\t" "movel %3,d2\n\t" "movel %4,d3\n\t" "movel %5,d4\n\t" "trap #0\n\t" "movel d0,%0" :"=g" (res) :"i" (SYS_ptrace), "g" (request), "g" (pid), "g" (addr), "g" (data) : "d0", "d1", "d2", "d3", "d4"); #endif if (res >= 0) { if (request > 0 && request < 4) { errno = 0; return (ret); } return (int) res; } errno = -res; return -1; } ./libc-linux/sysdeps/linux/m68k/readdir.c100644 1676 334 3507 5521072203 16311 0ustar hjlisl#include #include #include /* * readdir fills up the buffer with the readdir system call. it also * gives a third parameter (currently ignored, but should be 1) that * can with a future kernel be enhanced to be the number of entries * to be gotten. * * Right now the readdir system call return the number of characters * in the name - in the future it will probably return the number of * entries gotten. No matter - right now we just check for positive: * that will always work (as we know that it cannot be bigger than 1 * in the future: we just asked for one entry). */ struct dirent *readdir(DIR * dir) { int result; int count = NUMENT; if (!dir) { errno = EBADF; return NULL; } if (dir->dd_size <= dir->dd_loc) { /* read count of directory entries. For now it should be one. */ #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%esi,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (result) :"0" (SYS_readdir),"S" (dir->dd_fd), "c" ((long) dir->dd_buf),"d" (count)); #else __asm__ ("movel %2,d1\n\t" "movel %3,d2\n\t" "movel %4,d3\n\t" "movel %1,d0\n\t" "trap #0\n\t" "movel d0,%0" : "=g" (result) : "i" (SYS_readdir), "g" (dir->dd_fd), "g" (dir->dd_buf), "g" (count) : "d0", "d1", "d2", "d3" ); #endif if (result <= 0) { if (result < 0) errno = -result; return NULL; } /* * Right now the readdir system call return the number of * characters in the name - in the future it will probably return * the number of entries gotten. No matter - right now we just * check for positive: */ #if 0 dir->dd_size = result; #else dir->dd_size = 1; #endif dir->dd_loc = 0; } return &(dir->dd_buf [(dir->dd_loc)++]); } ./libc-linux/sysdeps/linux/m68k/sigsuspend.c100644 1676 334 1105 5521072204 17054 0ustar hjlisl#include #include int sigsuspend(sigset_t *sigmask) { int res; #if defined(__PIC__) || defined (__pic__) __asm__ volatile ("pushl %%ebx\n\t" "movl %%esi,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (res) :"0" (SYS_sigsuspend), "S" (0), "c" (0), "d" (*sigmask)); #else __asm__("movel %1,d0\n\t" "clrl d1\n\t" "clrl d2\n\t" "movel %2,d3\n\t" "trap #0\n\t" "movel d0,%0" :"=g" (res) :"i" (SYS_sigsuspend), "g" (*sigmask) : "d0", "d1", "d2", "d3"); #endif if (res >= 0) return res; errno = -res; return -1; } ./libc-linux/sysdeps/linux/m68k/syscall.c100644 1676 334 1245 5521072204 16347 0ustar hjlisl/* syscall.c - generalized linux system call interface - rick sladkey */ #include #include #include int syscall(int number, ...) { long res asm ("d0") = number; register long d1 asm("d1"), d2 asm("d2"), d3 asm("d3"), d4 asm("d4"), d5 asm("d5"); va_list args; va_start(args, number); d1 = va_arg(args, int); d2 = va_arg(args, int); d3 = va_arg(args, int); d4 = va_arg(args, int); d5 = va_arg(args, int); va_end(args); __asm__ volatile ("trap #0\n\t" : "=g" (res) : "0" (number), "g" (d1), "g" (d2), "g" (d3), "g" (d4), "g" (d5)); if (res < 0) { errno = -res; res = -1; } return res; } ./libc-linux/sysdeps/linux/__adjtime.c100644 1676 334 5057 5544123326 16037 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/__adjtimex.S100644 1676 334 1561 5465013512 16200 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__ (adjtimex, 1) ret ./libc-linux/sysdeps/linux/__load.c100644 1676 334 7776 5523013760 15350 0ustar hjlisl/* * Copyright (c) 1993 Eric Youngdale, Peter MacDonald, David Engel * and Hongjiu Lu. * * 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Eric Youngdale, * Peter MacDonald, David Engel and Hongjiu Lu. * 3. The name of the above contributors may not be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 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. */ /* Notice of general intent: * * The linux operating system generally contains large amounts of code * that fall under the GNU General Public License, or GPL for short. * This file contains source code that by it's very nature would always * be linked with an application program, and because of this a GPL type * of copyright on this file would place restrictions upon the * distribution of binary-only commercial software. Since the goal of the * Linux project as a whole is not to discourage the development and * distribution of commercial software for Linux, this file has been placed * under a more relaxed BSD-style of copyright. * * It is the general understanding of the above contributors that a * program executable linked to a library containing code that falls * under the GPL or GLPL style of license is not subject to the terms of * the GPL or GLPL license if the program executable(s) that are supplied * are linked to a shared library form of the GPL or GLPL library, and as long * as the form of the shared library is such that it is possible for * the end user to modify and rebuild the library and use it in * conjunction with the program executable. */ #include #include #include #include #include #include #include "config.h" #include "fixups.h" static int errno = 0; static _syscall1(int,exit,int,code) static _syscall1(int,uselib,const char *,filename) static _syscall3(ssize_t,write,int,fd,const void *,buf,size_t,count) static _syscall2(int,munmap,caddr_t,addr,size_t,len) extern struct libentry * __SHARED_LIBRARIES__[]; extern struct fixuplist _SHARABLE_CONFLICTS__; void __load_shared_libraries (int argc, char **argv, char **envp) { if (__SHARED_LIBRARIES__[2]) { unsigned mapinfo[2]; /* this must be volatile to work with -O, GCC bug? */ volatile loadptr loader = (loadptr)LDSO_ADDR; if (uselib(LDSO_IMAGE)) { char *p = argv[0]; char errmsg[] = ": can't load dynamic linker '" LDSO_IMAGE "'\n"; if (p) { while (*p) p++; write(2, argv[0], p-argv[0]); } write(2, errmsg, sizeof errmsg); while (1) exit(128); } loader((argc <= 0) ? FUNC_LDD : FUNC_LINK, mapinfo, argv[0], envp, __SHARED_LIBRARIES__, &_SHARABLE_CONFLICTS__); munmap((caddr_t)mapinfo[0], mapinfo[1]); } else { char msg[] = "\tstatically linked\n"; if (argc<=0) write (2, msg, sizeof msg); } if (argc <= 0) while (1) exit(0); } ./libc-linux/sysdeps/linux/config.h100644 1676 334 654 5457277021 15361 0ustar hjlisl#ifdef DEBUG # define LDSO_IMAGE "ld.so" # define LDSO_CONF "ld.so.conf" #else # define LDSO_IMAGE "/lib/ld.so" # define LDSO_CONF "/etc/ld.so.conf" #endif #define VERSION "1.3" #define LDD_ARGV0 "__LDD_ARGV0" #define DIR_SEP ":, \t\n" #define MAX_DIRS 32 #define DEFAULT_PATH "/usr/lib:/lib" typedef void (*loadptr)(int func, ...); #define FUNC_VERS 0 #define FUNC_LDD 1 #define FUNC_LINK 2 ./libc-linux/sysdeps/linux/fixups.h100644 1676 334 13343 5457277021 15471 0ustar hjlisl#ifndef _FIXUPS_H #define _FIXUPS_H /* * Copyright (c) 1993 Eric Youngdale, Peter MacDonald, David Engel * and Hongjiu Lu. * * 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Eric Youngdale, * Peter MacDonald, David Engel and Hongjiu Lu. * 3. The name of the above contributors may not be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE 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 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. */ /* Notice of general intent: * * The linux operating system generally contains large amounts of code * that fall under the GNU General Public License, or GPL for short. * This file contains source code that by it's very nature would always * be linked with an application program, and because of this a GPL type * of copyright on this file would place restrictions upon the * distribution of binary-only commercial software. Since the goal of the * Linux project as a whole is not to discourage the development and * distribution of commercial software for Linux, this file has been placed * under a more relaxed BSD-style of copyright. * * It is the general understanding of the above contributors that a * program executable linked to a library containing code that falls * under the GPL or GLPL style of license is not subject to the terms of * the GPL or GLPL license if the program executable(s) that are supplied * are linked to a shared library form of the GPL or GLPL library, and as long * as the form of the shared library is such that it is possible for * the end user to modify and rebuild the library and use it in * conjunction with the program executable. */ /* This list is generated by the linker - it corresponds to the SETD list generated in conjunction with the variable __SHARABLE_CONFLICTS__. The linker does not do anything special with this symbol - it simply puts together the pieces that are needed. The list of fixups to local variables is generated internally by the linker, and ld fills in this one field as a special case before writing the image. The array size is listed as 1, but it would actually be ->size - 2. __load.c will pick up this pointer and pass it to __dynamic_resolve() and __do_fixups(). */ struct fixuplist { /* This list is generated by the linker */ int size; int * magic; /* Used for verification purposes */ struct image_fixuplist * list; /* Fixups to local variables */ struct fixuplist *** shrlib_list[1]; /* One for each sharable library this program is linked to. The sharable libraries are linked to other sharable libraries, so we have to walk this tree and resolve all of the fixups. */ }; /* This is a linker-generated list of fixups. The linker essentially watches for multiple definitions of symbols, and if there is a __GOT__ symbol then it does not flag an error condition. Instead, it adds a fixup to the fixuplist which will correct the __GOT__ that appears later on the link command line. The number of pointer pairs is always specified by the size field, and after the last pointer pair is the pointer to the builtin_fixups. */ struct image_fixuplist { int size; struct elemental_fixup { union { int newaddr; struct builtin_fixup* bifu; }un; int * fixaddr; } fix[1]; }; /* Each link image (sharable libraries are each considered a sharable link image) will have a list of builtin fixups as well, as many as one for each source file that went into the link image. These lists are generated by jumpas as needed (perhaps one per source file), and a SETD symbol __BUILTIN_FIXUPS__. These will never appear in a user program - only in a shared library. This structure contains a series of pointers to these different lists, and we need to walk through and apply all of the fixups. The array size is listed as 1, but it can be any number */ struct builtin_fixup { int len; struct file_fixup * fixpnt[1]; /* Potentially one for every source file that was linked */ }; /* Each source file can potentially have one of these beasts. There are a series of pointer pairs, terminated by a NULL. The idea here is that we are supposed to copy the number out of gotaddr and store it at fixaddr. This is the list that is generated by the jumpas tool. This is listed with an array size of 1, but it can be any number. */ struct file_fixup { struct builtin_elemental_fixup { int * gotaddr; int * fixaddr; } fixup[1]; }; int __reset_magic(struct fixuplist * xpnt); int __do_fixups(struct fixuplist * xpnt, int flag); int __dynamic_resolve(struct fixuplist * xpnt); #endif /* _FIXUPS_H */ ./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/__vfork.c100644 1676 334 1732 5323226466 15551 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 #undef __vfork function_alias(__vfork, __fork, __pid_t, (), DEFUN_VOID(__vfork)) ./libc-linux/sysdeps/linux/vfork.c100644 1676 334 1724 5323226470 15247 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 #undef vfork function_alias(vfork, __fork, __pid_t, (), DEFUN_VOID(vfork)) ./libc-linux/sysdeps/linux/__wait.c100644 1676 334 404 5430360261 15330 0ustar hjlisl#include #include #include static inline _syscall4(__pid_t,wait4,__pid_t,pid,__WAIT_STATUS,status,int,options,struct rusage *,ru) __pid_t __wait(__WAIT_STATUS wait_stat) { return wait4(WAIT_ANY, wait_stat, 0, NULL); } ./libc-linux/sysdeps/linux/__wait3.c100644 1676 334 465 5430360300 15414 0ustar hjlisl#include #include #include static inline _syscall4(__pid_t,wait4,__pid_t,pid,__WAIT_STATUS,status,int,options,struct rusage *,ru) __pid_t __wait3(__WAIT_STATUS wait_stat, int options, struct rusage *reserved) { return wait4(WAIT_ANY, wait_stat, options, reserved); } ./libc-linux/sysdeps/linux/__waitpid.c100644 1676 334 451 5430360516 16032 0ustar hjlisl#include #include #include static inline _syscall4(__pid_t,wait4,__pid_t,pid,__WAIT_STATUS,status,int,options,struct rusage *,ru) __pid_t __waitpid(__pid_t pid, int *wait_stat, int options) { return wait4(pid, (__WAIT_STATUS) wait_stat, options, NULL); } ./libc-linux/sysdeps/linux/accept.c100644 1676 334 552 5323226466 15342 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); int accept(int sockfd, struct sockaddr *peer, int *paddrlen) { unsigned long args[3]; args[0] = sockfd; args[1] = (unsigned long)peer; args[2] = (unsigned long)paddrlen; return socketcall(SYS_ACCEPT, args); } ./libc-linux/sysdeps/linux/bind.c100644 1676 334 530 5323226466 15013 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); int bind(int sockfd, struct sockaddr *myaddr, int addrlen) { unsigned long args[3]; args[0] = sockfd; args[1] = (unsigned long)myaddr; args[2] = addrlen; return socketcall(SYS_BIND, args); } ./libc-linux/sysdeps/linux/connect.c100644 1676 334 534 5323226467 15535 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); int connect(int sockfd, struct sockaddr *saddr, int addrlen) { unsigned long args[3]; args[0] = sockfd; args[1] = (unsigned long)saddr; args[2] = addrlen; return socketcall(SYS_CONNECT, args); } ./libc-linux/sysdeps/linux/getpeernam.c100644 1676 334 564 5323226467 16236 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); int getpeername(int sockfd, struct sockaddr *addr, int *paddrlen) { unsigned long args[3]; args[0] = sockfd; args[1] = (unsigned long)addr; args[2] = (unsigned long)paddrlen; return socketcall(SYS_GETPEERNAME, args); } ./libc-linux/sysdeps/linux/getsocknam.c100644 1676 334 564 5323226467 16242 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); int getsockname(int sockfd, struct sockaddr *addr, int *paddrlen) { unsigned long args[3]; args[0] = sockfd; args[1] = (unsigned long)addr; args[2] = (unsigned long)paddrlen; return socketcall(SYS_GETSOCKNAME, args); } ./libc-linux/sysdeps/linux/getsockopt.c100644 1676 334 626 5323226467 16270 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); int getsockopt (int fd, int level, int optname, void *optval, int *optlen) { unsigned long args[5]; args[0]=fd; args[1]=level; args[2]=optname; args[3]=(unsigned long)optval; args[4]=(unsigned long)optlen; return (socketcall (SYS_GETSOCKOPT, args)); } ./libc-linux/sysdeps/linux/listen.c100644 1676 334 441 5323226467 15377 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); int listen(int sockfd, int backlog) { unsigned long args[2]; args[0] = sockfd; args[1] = backlog; return socketcall(SYS_LISTEN, args); } ./libc-linux/sysdeps/linux/mmap.c100644 1676 334 1020 5375747702 15054 0ustar hjlisl#define __CHECK_RETURN_ADDR #include #include #include #define SYS__mmap SYS_mmap static inline _syscall1(long,_mmap,unsigned long *,buffer); caddr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t off) { unsigned long buffer[6]; buffer[0] = (unsigned long)addr; buffer[1] = (unsigned long)len; buffer[2] = (unsigned long)prot; buffer[3] = (unsigned long)flags; buffer[4] = (unsigned long)fd; buffer[5] = (unsigned long)off; return (caddr_t) _mmap(buffer); } ./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/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/recv.c100644 1676 334 651 5341131213 15023 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); /* recv, recvfrom added by bir7@leland.stanford.edu */ int recv (int sockfd, void *buffer, int len, unsigned flags) { unsigned long args[4]; args[0] = sockfd; args[1] = (unsigned long) buffer; args[2] = len; args[3] = flags; return (socketcall (SYS_RECV, args)); } ./libc-linux/sysdeps/linux/revcfrom.c100644 1676 334 1026 5323226467 15744 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); /* recv, recvfrom added by bir7@leland.stanford.edu */ int recvfrom (int sockfd, void *buffer, int len, unsigned flags, struct sockaddr *to, int *tolen) { unsigned long args[6]; args[0] = sockfd; args[1] = (unsigned long) buffer; args[2] = len; args[3] = flags; args[4] = (unsigned long) to; args[5] = (unsigned long) tolen; return (socketcall (SYS_RECVFROM, args)); } ./libc-linux/sysdeps/linux/send.c100644 1676 334 655 5323226467 15041 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); /* send, sendto added by bir7@leland.stanford.edu */ int send (int sockfd, const void *buffer, int len, unsigned flags) { unsigned long args[4]; args[0] = sockfd; args[1] = (unsigned long) buffer; args[2] = len; args[3] = flags; return (socketcall (SYS_SEND, args)); } ./libc-linux/sysdeps/linux/sendto.c100644 1676 334 1013 5323226467 15411 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); /* send, sendto added by bir7@leland.stanford.edu */ int sendto (int sockfd, const void *buffer, int len, unsigned flags, const struct sockaddr *to, int tolen) { unsigned long args[6]; args[0] = sockfd; args[1] = (unsigned long) buffer; args[2] = len; args[3] = flags; args[4] = (unsigned long) to; args[5] = tolen; return (socketcall (SYS_SENDTO, args)); } ./libc-linux/sysdeps/linux/setpgrp.c100644 1676 334 221 5323226470 15553 0ustar hjlisl#include #include static inline _syscall2(int,setpgid,pid_t,pid,pid_t,pgid) int setpgrp(void) { return setpgid(0,0); } ./libc-linux/sysdeps/linux/setsockopt.c100644 1676 334 701 5323226470 16270 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); /* [sg]etsockoptions by bir7@leland.stanford.edu */ int setsockopt (int fd, int level, int optname, const void *optval, int optlen) { unsigned long args[5]; args[0]=fd; args[1]=level; args[2]=optname; args[3]=(unsigned long)optval; args[4]=optlen; return (socketcall (SYS_SETSOCKOPT, args)); } ./libc-linux/sysdeps/linux/shutdown.c100644 1676 334 517 5323226470 15752 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); /* shutdown by bir7@leland.stanford.edu */ int shutdown (int sockfd, int how) { unsigned long args[2]; args[0] = sockfd; args[1] = how; return (socketcall (SYS_SHUTDOWN, args)); } ./libc-linux/sysdeps/linux/socket.c100644 1676 334 476 5323226470 15373 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); int socket(int family, int type, int protocol) { unsigned long args[3]; args[0] = family; args[1] = type; args[2] = protocol; return socketcall(SYS_SOCKET, args); } ./libc-linux/sysdeps/linux/socketpair.c100644 1676 334 571 5323226470 16243 0ustar hjlisl#include #include #include static inline _syscall2(long,socketcall,int,call,unsigned long *,args); int socketpair(int family, int type, int protocol, int sockvec[2]) { unsigned long args[4]; args[0] = family; args[1] = type; args[2] = protocol; args[3] = (unsigned long)sockvec; return socketcall(SYS_SOCKETPAIR, args); } ./libc-linux/sysdeps/linux/ulimit.c100644 1676 334 5014 5365065247 15430 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 #ifdef __linux__ #include #else #include #endif #include #include #include #include #ifndef linux #ifndef HAVE_GNU_LD #define _etext etext #endif extern char _etext; #endif /* Function depends on CMD: 1 = Return the limit on the size of a file, in units of 512 bytes. 2 = Set the limit on the size of a file to NEWLIMIT. Only the super-user can increase the limit. 3 = Return the maximum possible address of the data segment. 4 = Return the maximum number of files that the calling process can open. Returns -1 on errors. */ long DEFUN(ulimit, (cmd), int cmd DOTS) { int status; switch (cmd) { case UL_GETFSIZE: { /* Get limit on file size. */ struct rlimit fsize; status = getrlimit(RLIMIT_FSIZE, &fsize); if (status < 0) return -1; /* Convert from bytes to 512 byte units. */ return fsize.rlim_cur / 512; } case UL_SETFSIZE: /* Set limit on file size. */ { va_list arg; long newlimit; struct rlimit fsize; va_start (arg, cmd); newlimit = va_arg (arg, long); va_end (arg); fsize.rlim_cur = newlimit * 512; fsize.rlim_max = newlimit * 512; return setrlimit(RLIMIT_FSIZE, &fsize); } case 3: #ifdef __linux__ /* Get maximum address for `brk'. */ /* Due to the shared library, we cannot do this. */ errno = EINVAL; return -1; #else { struct rlimit dsize; status = getrlimit(RLIMIT_DATA, &dsize); if (status < 0) return -1; return ((long int) &_etext) + dsize.rlim_cur; } #endif case 4: return __sysconf(_SC_OPEN_MAX); default: errno = EINVAL; return -1; } } ./libc-linux/sysdeps/linux/tell.c100644 1676 334 267 5323226470 15041 0ustar hjlisl#include #include static inline _syscall3(off_t,lseek,int,fildes,off_t,offset,int,origin) off_t tell (int fildes) { return __lseek (fildes, 0, SEEK_CUR); } ./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/set-init.c100644 1676 334 2244 5525570333 15656 0ustar hjlisl/* Copyright (C) 1991, 1992, 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 struct { size_t n; void EXFUN((*fn[0]), (int argc, char **argv, char **envp)); } __libc_subinit; void DEFUN(__libc_init, (argc, argv, envp), int argc AND char **argv AND char **envp) { size_t i; for (i = 0; i < __libc_subinit.n; ++i) (*__libc_subinit.fn[i]) (argc, argv, envp); } ./libc-linux/sysdeps/linux/getpgid.S100644 1676 334 1556 5527573137 15541 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 (getpgid, 1) ret ./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/sysdeps/generic/ 40755 1676 334 0 5515066711 14133 5ustar hjlisl./libc-linux/sysdeps/generic/modf.c100644 1676 334 2074 5514370046 15322 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 #undef modf /* Break VALUE into integral and fractional parts. */ double DEFUN(modf, (value, iptr), double value AND double *iptr) { register double ipart = floor(value); *iptr = ipart; return value - ipart; } ./libc-linux/sysdeps/generic/memchr.c100644 1676 334 12717 5515053164 15675 0ustar hjlisl/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. Based on strlen implemention by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and commentary by Jim Blandy (jimb@ai.mit.edu); adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), and implemented by Roland McGrath (roland@ai.mit.edu). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as 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 /* Search no more than N bytes of S for C. */ PTR DEFUN(memchr, (s, c, n), CONST PTR s AND int c AND size_t n) { CONST unsigned char *char_ptr; CONST unsigned long int *longword_ptr; unsigned long int longword, magic_bits, charmask; c = (unsigned char) c; /* Handle the first few characters by reading one character at a time. Do this until CHAR_PTR is aligned on a longword boundary. */ for (char_ptr = s; n > 0 && ((unsigned long int) char_ptr & (sizeof (longword) - 1)) != 0; --n, ++char_ptr) if (*char_ptr == c) return (PTR) char_ptr; /* All these elucidatory comments refer to 4-byte longwords, but the theory applies equally well to 8-byte longwords. */ longword_ptr = (unsigned long int *) char_ptr; /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits the "holes." Note that there is a hole just to the left of each byte, with an extra at the end: bits: 01111110 11111110 11111110 11111111 bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ switch (sizeof (longword)) { case 4: magic_bits = 0x7efefeffL; break; case 8: magic_bits = (0x7efefefeL << 32) | 0xfefefeffL; break; default: abort (); } /* Set up a longword, each of whose bytes is C. */ charmask = c | (c << 8); charmask |= charmask << 16; if (sizeof (longword) > 4) charmask |= charmask << 32; if (sizeof (longword) > 8) abort (); /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing if *any of the four* bytes in the longword in question are zero. */ while (n >= sizeof (longword)) { /* We tentatively exit the loop if adding MAGIC_BITS to LONGWORD fails to change any of the hole bits of LONGWORD. 1) Is this safe? Will it catch all the zero bytes? Suppose there is a byte with all zeros. Any carry bits propagating from its left will fall into the hole at its least significant bit and stop. Since there will be no carry from its most significant bit, the LSB of the byte to the left will be unchanged, and the zero will be detected. 2) Is this worthwhile? Will it ignore everything except zero bytes? Suppose every byte of LONGWORD has a bit set somewhere. There will be a carry into bit 8. If bit 8 is set, this will carry into bit 16. If bit 8 is clear, one of bits 9-15 must be set, so there will be a carry into bit 16. Similarly, there will be a carry into bit 24. If one of bits 24-30 is set, there will be a carry into bit 31, so all of the hole bits will be changed. The one misfire occurs when bits 24-30 are clear and bit 31 is set; in this case, the hole at bit 31 is not changed. If we had access to the processor carry flag, we could close this loophole by putting the fourth hole at bit 32! So it ignores everything except 128's, when they're aligned properly. 3) But wait! Aren't we looking for C, not zero? Good point. So what we do is XOR LONGWORD with a longword, each of whose bytes is C. This turns each byte that is C into a zero. */ longword = *longword_ptr++ ^ charmask; /* Add MAGIC_BITS to LONGWORD. */ if ((((longword + magic_bits) /* Set those bits that were unchanged by the addition. */ ^ ~longword) /* Look at only the hole bits. If any of the hole bits are unchanged, most likely one of the bytes was a zero. */ & ~magic_bits) != 0) { /* Which of the bytes was C? If none of them were, it was a misfire; continue the search. */ CONST unsigned char *cp = (CONST unsigned char *) (longword_ptr - 1); if (cp[0] == c) return (PTR) cp; if (cp[1] == c) return (PTR) &cp[1]; if (cp[2] == c) return (PTR) &cp[2]; if (cp[3] == c) return (PTR) &cp[3]; if (sizeof (longword) > 4) { if (cp[4] == c) return (PTR) &cp[4]; if (cp[5] == c) return (PTR) &cp[5]; if (cp[6] == c) return (PTR) &cp[6]; if (cp[7] == c) return (PTR) &cp[7]; } } n -= sizeof (longword); } char_ptr = (CONST unsigned char *) longword_ptr; while (n-- > 0) { if (*char_ptr == c) return (PTR) char_ptr; else ++char_ptr; } return NULL; } ./libc-linux/sysdeps/generic/memcmp.c100644 1676 334 21665 5515053607 15704 0ustar hjlisl/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 #undef __ptr_t #if defined (__cplusplus) || (defined (__STDC__) && __STDC__) #define __ptr_t void * #else /* Not C++ or ANSI C. */ #undef const #define const #define __ptr_t char * #endif /* C++ or ANSI C. */ #if defined (HAVE_STRING_H) || defined (_LIBC) #include #endif #ifdef _LIBC #include #else /* Not in the GNU C library. */ /* Type to use for aligned memory operations. This should normally be the biggest type supported by a single load and store. Must be an unsigned type. */ #define op_t unsigned long int #define OPSIZ (sizeof(op_t)) /* Threshold value for when to enter the unrolled loops. */ #define OP_T_THRES 16 /* Type to use for unaligned operations. */ typedef unsigned char byte; #ifndef WORDS_BIGENDIAN #define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2))) #else #define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2))) #endif #endif /* In the GNU C library. */ /* BE VERY CAREFUL IF YOU CHANGE THIS CODE! */ /* The strategy of this memcmp is: 1. Compare bytes until one of the block pointers is aligned. 2. Compare using memcmp_common_alignment or memcmp_not_common_alignment, regarding the alignment of the other block after the initial byte operations. The maximum number of full words (of type op_t) are compared in this way. 3. Compare the few remaining bytes. */ #ifndef WORDS_BIGENDIAN /* memcmp_bytes -- Compare A and B bytewise in the byte order of the machine. A and B are known to be different. This is needed only on little-endian machines. */ #ifdef __GNUC__ __inline #endif static int memcmp_bytes (a, b) op_t a, b; { long int srcp1 = (long int) &a; long int srcp2 = (long int) &b; op_t a0, b0; do { a0 = ((byte *) srcp1)[0]; b0 = ((byte *) srcp2)[0]; srcp1 += 1; srcp2 += 1; } while (a0 == b0); return a0 - b0; } #endif /* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t' objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for memory operations on `op_t's. */ #ifdef __GNUC__ __inline #endif static int memcmp_common_alignment (srcp1, srcp2, len) long int srcp1; long int srcp2; size_t len; { op_t a0, a1; op_t b0, b1; switch (len % 4) { case 2: a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; srcp1 -= 2 * OPSIZ; srcp2 -= 2 * OPSIZ; len += 2; goto do1; case 3: a1 = ((op_t *) srcp1)[0]; b1 = ((op_t *) srcp2)[0]; srcp1 -= OPSIZ; srcp2 -= OPSIZ; len += 1; goto do2; case 0: if (OP_T_THRES <= 3 * OPSIZ && len == 0) return 0; a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; goto do3; case 1: a1 = ((op_t *) srcp1)[0]; b1 = ((op_t *) srcp2)[0]; srcp1 += OPSIZ; srcp2 += OPSIZ; len -= 1; if (OP_T_THRES <= 3 * OPSIZ && len == 0) goto do0; /* Fall through. */ } do { a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; if (a1 != b1) #ifdef WORDS_BIGENDIAN return a1 > b1 ? 1 : -1; #else return memcmp_bytes (a1, b1); #endif do3: a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[1]; if (a0 != b0) #ifdef WORDS_BIGENDIAN return a0 > b0 ? 1 : -1; #else return memcmp_bytes (a0, b0); #endif do2: a0 = ((op_t *) srcp1)[2]; b0 = ((op_t *) srcp2)[2]; if (a1 != b1) #ifdef WORDS_BIGENDIAN return a1 > b1 ? 1 : -1; #else return memcmp_bytes (a1, b1); #endif do1: a1 = ((op_t *) srcp1)[3]; b1 = ((op_t *) srcp2)[3]; if (a0 != b0) #ifdef WORDS_BIGENDIAN return a0 > b0 ? 1 : -1; #else return memcmp_bytes (a0, b0); #endif srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; len -= 4; } while (len != 0); /* This is the right position for do0. Please don't move it into the loop. */ do0: if (a1 != b1) #ifdef WORDS_BIGENDIAN return a1 > b1 ? 1 : -1; #else return memcmp_bytes (a1, b1); #endif return 0; } /* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory operations on `op_t', but SRCP1 *should be unaligned*. */ #ifdef __GNUC__ __inline #endif static int memcmp_not_common_alignment (srcp1, srcp2, len) long int srcp1; long int srcp2; size_t len; { op_t a0, a1, a2, a3; op_t b0, b1, b2, b3; op_t x; int shl, shr; /* Calculate how to shift a word read at the memory operation aligned srcp1 to make it aligned for comparison. */ shl = 8 * (srcp1 % OPSIZ); shr = 8 * OPSIZ - shl; /* Make SRCP1 aligned by rounding it down to the beginning of the `op_t' it points in the middle of. */ srcp1 &= -OPSIZ; switch (len % 4) { case 2: a1 = ((op_t *) srcp1)[0]; a2 = ((op_t *) srcp1)[1]; b2 = ((op_t *) srcp2)[0]; srcp1 -= 1 * OPSIZ; srcp2 -= 2 * OPSIZ; len += 2; goto do1; case 3: a0 = ((op_t *) srcp1)[0]; a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[0]; srcp2 -= 1 * OPSIZ; len += 1; goto do2; case 0: if (OP_T_THRES <= 3 * OPSIZ && len == 0) return 0; a3 = ((op_t *) srcp1)[0]; a0 = ((op_t *) srcp1)[1]; b0 = ((op_t *) srcp2)[0]; srcp1 += 1 * OPSIZ; goto do3; case 1: a2 = ((op_t *) srcp1)[0]; a3 = ((op_t *) srcp1)[1]; b3 = ((op_t *) srcp2)[0]; srcp1 += 2 * OPSIZ; srcp2 += 1 * OPSIZ; len -= 1; if (OP_T_THRES <= 3 * OPSIZ && len == 0) goto do0; /* Fall through. */ } do { a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; x = MERGE(a2, shl, a3, shr); if (x != b3) #ifdef WORDS_BIGENDIAN return x > b3 ? 1 : -1; #else return memcmp_bytes (x, b3); #endif do3: a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[1]; x = MERGE(a3, shl, a0, shr); if (x != b0) #ifdef WORDS_BIGENDIAN return x > b0 ? 1 : -1; #else return memcmp_bytes (x, b0); #endif do2: a2 = ((op_t *) srcp1)[2]; b2 = ((op_t *) srcp2)[2]; x = MERGE(a0, shl, a1, shr); if (x != b1) #ifdef WORDS_BIGENDIAN return x > b1 ? 1 : -1; #else return memcmp_bytes (x, b1); #endif do1: a3 = ((op_t *) srcp1)[3]; b3 = ((op_t *) srcp2)[3]; x = MERGE(a1, shl, a2, shr); if (x != b2) #ifdef WORDS_BIGENDIAN return x > b2 ? 1 : -1; #else return memcmp_bytes (x, b2); #endif srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; len -= 4; } while (len != 0); /* This is the right position for do0. Please don't move it into the loop. */ do0: x = MERGE(a2, shl, a3, shr); if (x != b3) #ifdef WORDS_BIGENDIAN return x > b3 ? 1 : -1; #else return memcmp_bytes (x, b3); #endif return 0; } int memcmp (s1, s2, len) const __ptr_t s1; const __ptr_t s2; size_t len; { op_t a0; op_t b0; long int srcp1 = (long int) s1; long int srcp2 = (long int) s2; op_t res; if (len >= OP_T_THRES) { /* There are at least some bytes to compare. No need to test for LEN == 0 in this alignment loop. */ while (srcp2 % OPSIZ != 0) { a0 = ((byte *) srcp1)[0]; b0 = ((byte *) srcp2)[0]; srcp1 += 1; srcp2 += 1; res = a0 - b0; if (res != 0) return res; len -= 1; } /* SRCP2 is now aligned for memory operations on `op_t'. SRCP1 alignment determines if we can do a simple, aligned compare or need to shuffle bits. */ if (srcp1 % OPSIZ == 0) res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ); else res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ); if (res != 0) return res; /* Number of bytes remaining in the interval [0..OPSIZ-1]. */ srcp1 += len & -OPSIZ; srcp2 += len & -OPSIZ; len %= OPSIZ; } /* There are just a few bytes to compare. Use byte memory operations. */ while (len != 0) { a0 = ((byte *) srcp1)[0]; b0 = ((byte *) srcp2)[0]; srcp1 += 1; srcp2 += 1; res = a0 - b0; if (res != 0) return res; len -= 1; } return 0; } ./libc-linux/sysdeps/generic/memset.c100644 1676 334 4215 5515054026 15664 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 PTR DEFUN(memset, (dstpp, c, len), PTR dstpp AND int c AND size_t len) { long int dstp = (long int) dstpp; if (len >= 8) { size_t xlen; op_t cccc; cccc = (unsigned char) c; cccc |= cccc << 8; cccc |= cccc << 16; if (OPSIZ > 4) cccc |= cccc << 32; /* There are at least some bytes to set. No need to test for LEN == 0 in this alignment loop. */ while (dstp % OPSIZ != 0) { ((byte *) dstp)[0] = c; dstp += 1; len -= 1; } /* Write 8 `op_t' per iteration until less than 8 `op_t' remain. */ xlen = len / (OPSIZ * 8); while (xlen > 0) { ((op_t *) dstp)[0] = cccc; ((op_t *) dstp)[1] = cccc; ((op_t *) dstp)[2] = cccc; ((op_t *) dstp)[3] = cccc; ((op_t *) dstp)[4] = cccc; ((op_t *) dstp)[5] = cccc; ((op_t *) dstp)[6] = cccc; ((op_t *) dstp)[7] = cccc; dstp += 8 * OPSIZ; xlen -= 1; } len %= OPSIZ * 8; /* Write 1 `op_t' per iteration until less than OPSIZ bytes remain. */ xlen = len / OPSIZ; while (xlen > 0) { ((op_t *) dstp)[0] = cccc; dstp += OPSIZ; xlen -= 1; } len %= OPSIZ; } /* Write the last few bytes. */ while (len > 0) { ((byte *) dstp)[0] = c; dstp += 1; len -= 1; } return dstpp; } ./libc-linux/sysdeps/generic/strcat.c100644 1676 334 2541 5515055154 15675 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 /* Append SRC on the end of DEST. */ char * DEFUN(strcat, (dest, src), char *dest AND CONST char *src) { register char *s1 = dest; register CONST char *s2 = src; reg_char c; /* Find the end of the string. */ do c = *s1++; while (c != '\0'); /* Make S1 point before the next character, so we can increment it while memory is read (wins on pipelined cpus). */ s1 -= 2; do { c = *s2++; *++s1 = c; } while (c != '\0'); return dest; } ./libc-linux/sysdeps/generic/strchr.c100644 1676 334 13402 5515055331 15715 0ustar hjlisl/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. Based on strlen implemention by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and bug fix and commentary by Jim Blandy (jimb@ai.mit.edu); adaptation to strchr suggested by Dick Karpinski (dick@cca.ucsf.edu), and implemented by Roland McGrath (roland@ai.mit.edu). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as 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 /* Find the first ocurrence of C in S. */ char * DEFUN(strchr, (s, c), CONST char *s AND int c) { CONST unsigned char *char_ptr; CONST unsigned long int *longword_ptr; unsigned long int longword, magic_bits, charmask; c = (unsigned char) c; /* Handle the first few characters by reading one character at a time. Do this until CHAR_PTR is aligned on a longword boundary. */ for (char_ptr = s; ((unsigned long int) char_ptr & (sizeof (longword) - 1)) != 0; ++char_ptr) if (*char_ptr == c) return (PTR) char_ptr; else if (*char_ptr == '\0') return NULL; /* All these elucidatory comments refer to 4-byte longwords, but the theory applies equally well to 8-byte longwords. */ longword_ptr = (unsigned long int *) char_ptr; /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits the "holes." Note that there is a hole just to the left of each byte, with an extra at the end: bits: 01111110 11111110 11111110 11111111 bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ switch (sizeof (longword)) { case 4: magic_bits = 0x7efefeffL; break; case 8: magic_bits = (0x7efefefeL << 32) | 0xfefefeffL; break; default: abort (); } /* Set up a longword, each of whose bytes is C. */ charmask = c | (c << 8); charmask |= charmask << 16; if (sizeof (longword) > 4) charmask |= charmask << 32; if (sizeof (longword) > 8) abort (); /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing if *any of the four* bytes in the longword in question are zero. */ for (;;) { /* We tentatively exit the loop if adding MAGIC_BITS to LONGWORD fails to change any of the hole bits of LONGWORD. 1) Is this safe? Will it catch all the zero bytes? Suppose there is a byte with all zeros. Any carry bits propagating from its left will fall into the hole at its least significant bit and stop. Since there will be no carry from its most significant bit, the LSB of the byte to the left will be unchanged, and the zero will be detected. 2) Is this worthwhile? Will it ignore everything except zero bytes? Suppose every byte of LONGWORD has a bit set somewhere. There will be a carry into bit 8. If bit 8 is set, this will carry into bit 16. If bit 8 is clear, one of bits 9-15 must be set, so there will be a carry into bit 16. Similarly, there will be a carry into bit 24. If one of bits 24-30 is set, there will be a carry into bit 31, so all of the hole bits will be changed. The one misfire occurs when bits 24-30 are clear and bit 31 is set; in this case, the hole at bit 31 is not changed. If we had access to the processor carry flag, we could close this loophole by putting the fourth hole at bit 32! So it ignores everything except 128's, when they're aligned properly. 3) But wait! Aren't we looking for C as well as zero? Good point. So what we do is XOR LONGWORD with a longword, each of whose bytes is C. This turns each byte that is C into a zero. */ longword = *longword_ptr++; /* Add MAGIC_BITS to LONGWORD. */ if ((((longword + magic_bits) /* Set those bits that were unchanged by the addition. */ ^ ~longword) /* Look at only the hole bits. If any of the hole bits are unchanged, most likely one of the bytes was a zero. */ & ~magic_bits) != 0 || /* That caught zeroes. Now test for C. */ ((((longword ^ charmask) + magic_bits) ^ ~(longword ^ charmask)) & ~magic_bits) != 0) { /* Which of the bytes was C or zero? If none of them were, it was a misfire; continue the search. */ CONST unsigned char *cp = (CONST unsigned char *) (longword_ptr - 1); if (*cp == c) return (char *) cp; else if (*cp == '\0') return NULL; if (*++cp == c) return (char *) cp; else if (*cp == '\0') return NULL; if (*++cp == c) return (char *) cp; else if (*cp == '\0') return NULL; if (*++cp == c) return (char *) cp; else if (*cp == '\0') return NULL; if (sizeof (longword) > 4) { if (*cp == c) return (char *) cp; else if (*cp == '\0') return NULL; if (*++cp == c) return (char *) cp; else if (*cp == '\0') return NULL; if (*++cp == c) return (char *) cp; else if (*cp == '\0') return NULL; if (*++cp == c) return (char *) cp; else if (*cp == '\0') return NULL; } } } return NULL; } ./libc-linux/sysdeps/generic/strcmp.c100644 1676 334 2623 5515055451 15706 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 /* Compare S1 and S2, returning less than, equal to or greater than zero if S1 is lexiographically less than, equal to or greater than S2. */ int DEFUN(strcmp, (p1, p2), CONST char *p1 AND CONST char *p2) { register CONST unsigned char *s1 = (CONST unsigned char *) p1; register CONST unsigned char *s2 = (CONST unsigned char *) p2; unsigned reg_char c1, c2; do { c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0') return c1 - c2; } while (c1 == c2); return c1 - c2; } ./libc-linux/sysdeps/generic/strcspn.c100644 1676 334 2311 5515055546 16071 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 /* Return the length of the maximum inital segment of S which contains no characters from REJECT. */ size_t DEFUN(strcspn, (s, reject), register CONST char *s AND register CONST char *reject) { register size_t count = 0; while (*s != '\0') if (strchr(reject, *s++) == NULL) ++count; else return count; return count; } ./libc-linux/sysdeps/generic/strlen.c100644 1676 334 11623 5515055642 15727 0ustar hjlisl/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. Written by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se); commentary by Jim Blandy (jimb@ai.mit.edu). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as 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 /* Return the length of the null-terminated string STR. Scan for the null terminator quickly by testing four bytes at a time. */ size_t DEFUN(strlen, (str), CONST char *str) { CONST char *char_ptr; CONST unsigned long int *longword_ptr; unsigned long int longword, magic_bits, himagic, lomagic; /* Handle the first few characters by reading one character at a time. Do this until CHAR_PTR is aligned on a longword boundary. */ for (char_ptr = str; ((unsigned long int) char_ptr & (sizeof (longword) - 1)) != 0; ++char_ptr) if (*char_ptr == '\0') return char_ptr - str; /* All these elucidatory comments refer to 4-byte longwords, but the theory applies equally well to 8-byte longwords. */ longword_ptr = (unsigned long int *) char_ptr; /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits the "holes." Note that there is a hole just to the left of each byte, with an extra at the end: bits: 01111110 11111110 11111110 11111111 bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ magic_bits = 0x7efefeffL; himagic = 0x80808080L; lomagic = 0x01010101L; if (sizeof (longword) > 4) { /* 64-bit version of the magic. */ magic_bits = (0x7efefefeL << 32) | 0xfefefeffL; himagic = (himagic << 32) | himagic; lomagic = (lomagic << 32) | lomagic; } if (sizeof (longword) > 8) abort (); /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing if *any of the four* bytes in the longword in question are zero. */ for (;;) { /* We tentatively exit the loop if adding MAGIC_BITS to LONGWORD fails to change any of the hole bits of LONGWORD. 1) Is this safe? Will it catch all the zero bytes? Suppose there is a byte with all zeros. Any carry bits propagating from its left will fall into the hole at its least significant bit and stop. Since there will be no carry from its most significant bit, the LSB of the byte to the left will be unchanged, and the zero will be detected. 2) Is this worthwhile? Will it ignore everything except zero bytes? Suppose every byte of LONGWORD has a bit set somewhere. There will be a carry into bit 8. If bit 8 is set, this will carry into bit 16. If bit 8 is clear, one of bits 9-15 must be set, so there will be a carry into bit 16. Similarly, there will be a carry into bit 24. If one of bits 24-30 is set, there will be a carry into bit 31, so all of the hole bits will be changed. The one misfire occurs when bits 24-30 are clear and bit 31 is set; in this case, the hole at bit 31 is not changed. If we had access to the processor carry flag, we could close this loophole by putting the fourth hole at bit 32! So it ignores everything except 128's, when they're aligned properly. */ longword = *longword_ptr++; if ( #if 0 /* Add MAGIC_BITS to LONGWORD. */ (((longword + magic_bits) /* Set those bits that were unchanged by the addition. */ ^ ~longword) /* Look at only the hole bits. If any of the hole bits are unchanged, most likely one of the bytes was a zero. */ & ~magic_bits) #else ((longword - lomagic) & himagic) #endif != 0) { /* Which of the bytes was the zero? If none of them were, it was a misfire; continue the search. */ CONST char *cp = (CONST char *) (longword_ptr - 1); if (cp[0] == 0) return cp - str; if (cp[1] == 0) return cp - str + 1; if (cp[2] == 0) return cp - str + 2; if (cp[3] == 0) return cp - str + 3; if (sizeof (longword) > 4) { if (cp[4] == 0) return cp - str + 4; if (cp[5] == 0) return cp - str + 5; if (cp[6] == 0) return cp - str + 6; if (cp[7] == 0) return cp - str + 7; } } } } ./libc-linux/sysdeps/generic/strncmp.c100644 1676 334 3644 5515056341 16067 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 /* Compare no more than N characters of S1 and S2, returning less than, equal to or greater than zero if S1 is lexiographically less than, equal to or greater than S2. */ int DEFUN(strncmp, (s1, s2, n), CONST char *s1 AND CONST char *s2 AND size_t n) { unsigned reg_char c1 = '\0'; unsigned reg_char c2 = '\0'; if (n >= 4) { size_t n4 = n >> 2; do { c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0' || c1 != c2) return c1 - c2; c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0' || c1 != c2) return c1 - c2; c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0' || c1 != c2) return c1 - c2; c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0' || c1 != c2) return c1 - c2; } while (--n4 > 0); n &= 3; } while (n > 0) { c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0' || c1 != c2) return c1 - c2; n--; } return c1 - c2; } ./libc-linux/sysdeps/generic/strpbrk.c100644 1676 334 2201 5515056450 16055 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 /* Find the first ocurrence in S of any character in ACCEPT. */ char * DEFUN(strpbrk, (s, accept), register CONST char *s AND register CONST char *accept) { while (*s != '\0') if (strchr(accept, *s) == NULL) ++s; else return (char *) s; return NULL; } ./libc-linux/sysdeps/generic/strrchr.c100644 1676 334 2374 5515056543 16073 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 /* Find the last ocurrence of C in S. */ char * DEFUN(strrchr, (s, c), CONST char *s AND int c) { register CONST char *found, *p; c = (unsigned char) c; /* Since strchr is fast, we use it rather than the obvious loop. */ if (c == '\0') return strchr(s, '\0'); found = NULL; while ((p = strchr(s, c)) != NULL) { found = p; s = p + 1; } return (char *) found; } ./libc-linux/sysdeps/generic/strspn.c100644 1676 334 2444 5515056543 15733 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 /* Return the length of the maximum initial segment of S which contains only characters in ACCEPT. */ size_t DEFUN(strspn, (s, accept), CONST char *s AND CONST char *accept) { register CONST char *p; register CONST char *a; register size_t count = 0; for (p = s; *p != '\0'; ++p) { for (a = accept; *a != '\0'; ++a) if (*p == *a) break; if (*a == '\0') return count; else ++count; } return count; } ./libc-linux/sysdeps/generic/ffs.c100644 1676 334 3340 5515056543 15154 0ustar hjlisl/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 #undef ffs /* Find the first bit set in I. */ int DEFUN(ffs, (i), int i) { static CONST unsigned char table[] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 }; unsigned long int a; unsigned long int x = i & -i; a = x <= 0xffff ? (x <= 0xff ? 0 : 8) : (x <= 0xffffff ? 16 : 24); return table[x >> a] + a; } ./libc-linux/sysdeps/generic/Makefile100644 1676 334 661 5516115713 15651 0ustar hjlisl# # Makefile for i386 specific functions. # TOPDIR=../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I$(TOPDIR)/string -I$(TOPDIR) -I. SRC1S= modf.c bzero.c ffs.c memchr.c memcmp.c memset.c \ strcat.c strchr.c strcmp.c strcspn.c strlen.c strncmp.c \ strpbrk.c strrchr.c strspn.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SCR2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/sysdeps/generic/bzero.c100644 1676 334 4266 5515064104 15517 0ustar hjlisl/* Copyright (C) 1991 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 /* Set N bytes of S to 0. */ #ifdef __linux__ void DEFUN(bzero, (s, len), PTR s AND int len) #else void DEFUN(bzero, (s, n), PTR s AND size_t len) #endif { long int dstp = (long int) s; CONST op_t zero = 0; #ifdef __linux__ if (len <= 0) return; #endif if (len >= 8) { size_t xlen; /* There are at least some bytes to zero. No need to test for LEN == 0 in this alignment loop. */ while (dstp % OPSIZ != 0) { ((byte *) dstp)[0] = 0; dstp += 1; len -= 1; } /* Write 8 op_t per iteration until less than 8 op_t remain. */ xlen = len / (OPSIZ * 8); while (xlen != 0) { ((op_t *) dstp)[0] = zero; ((op_t *) dstp)[1] = zero; ((op_t *) dstp)[2] = zero; ((op_t *) dstp)[3] = zero; ((op_t *) dstp)[4] = zero; ((op_t *) dstp)[5] = zero; ((op_t *) dstp)[6] = zero; ((op_t *) dstp)[7] = zero; dstp += 8 * OPSIZ; xlen -= 1; } len %= OPSIZ * 8; /* Write 1 op_t per iteration until less than op_t remain. */ xlen = len / OPSIZ; while (xlen != 0) { ((op_t *) dstp)[0] = zero; dstp += OPSIZ; xlen -= 1; } len %= OPSIZ; } /* Write the last few bytes. */ while (len != 0) { ((byte *) dstp)[0] = 0; dstp += 1; len -= 1; } } ./libc-linux/sysdeps/generic/memcopy.h100644 1676 334 13243 5515065457 16103 0ustar hjlisl/* memcopy.h -- definitions for memory copy functions. Generic C version. Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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. */ /* The strategy of the memory functions is: 1. Copy bytes until the destination pointer is aligned. 2. Copy words in unrolled loops. If the source and destination are not aligned in the same way, use word memory operations, but shift and merge two read words before writing. 3. Copy the few remaining bytes. This is fast on processors that have at least 10 registers for allocation by GCC, and that can access memory at reg+const in one instruction. I made an "exhaustive" test of this memmove when I wrote it, exhaustive in the sense that I tried all alignment and length combinations, with and without overlap. */ #include #include /* The macros defined in this file are: BYTE_COPY_FWD(dst_beg_ptr, src_beg_ptr, nbytes_to_copy) BYTE_COPY_BWD(dst_end_ptr, src_end_ptr, nbytes_to_copy) WORD_COPY_FWD(dst_beg_ptr, src_beg_ptr, nbytes_remaining, nbytes_to_copy) WORD_COPY_BWD(dst_end_ptr, src_end_ptr, nbytes_remaining, nbytes_to_copy) MERGE(old_word, sh_1, new_word, sh_2) [I fail to understand. I feel stupid. --roland] */ /* Type to use for aligned memory operations. This should normally be the biggest type supported by a single load and store. */ #define op_t unsigned long int #define OPSIZ (sizeof(op_t)) /* Type to use for unaligned operations. */ typedef unsigned char byte; /* Optimal type for storing bytes in registers. */ #define reg_char char #if __BYTE_ORDER == __LITTLE_ENDIAN #define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2))) #endif #if __BYTE_ORDER == __BIG_ENDIAN #define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2))) #endif /* Copy exactly NBYTES bytes from SRC_BP to DST_BP, without any assumptions about alignment of the pointers. */ #define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \ do \ { \ size_t __nbytes = (nbytes); \ while (__nbytes > 0) \ { \ byte __x = ((byte *) src_bp)[0]; \ src_bp += 1; \ __nbytes -= 1; \ ((byte *) dst_bp)[0] = __x; \ dst_bp += 1; \ } \ } while (0) /* Copy exactly NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR, beginning at the bytes right before the pointers and continuing towards smaller addresses. Don't assume anything about alignment of the pointers. */ #define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \ do \ { \ size_t __nbytes = (nbytes); \ while (__nbytes > 0) \ { \ byte __x; \ src_ep -= 1; \ __x = ((byte *) src_ep)[0]; \ dst_ep -= 1; \ __nbytes -= 1; \ ((byte *) dst_ep)[0] = __x; \ } \ } while (0) /* Copy *up to* NBYTES bytes from SRC_BP to DST_BP, with the assumption that DST_BP is aligned on an OPSIZ multiple. If not all bytes could be easily copied, store remaining number of bytes in NBYTES_LEFT, otherwise store 0. */ extern void _wordcopy_fwd_aligned __P ((long int, long int, size_t)); extern void _wordcopy_fwd_dest_aligned __P ((long int, long int, size_t)); #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \ do \ { \ if (src_bp % OPSIZ == 0) \ _wordcopy_fwd_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \ else \ _wordcopy_fwd_dest_aligned (dst_bp, src_bp, (nbytes) / OPSIZ); \ src_bp += (nbytes) & -OPSIZ; \ dst_bp += (nbytes) & -OPSIZ; \ (nbytes_left) = (nbytes) % OPSIZ; \ } while (0) /* Copy *up to* NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR, beginning at the words (of type op_t) right before the pointers and continuing towards smaller addresses. May take advantage of that DST_END_PTR is aligned on an OPSIZ multiple. If not all bytes could be easily copied, store remaining number of bytes in NBYTES_REMAINING, otherwise store 0. */ extern void _wordcopy_bwd_aligned __P ((long int, long int, size_t)); extern void _wordcopy_bwd_dest_aligned __P ((long int, long int, size_t)); #define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \ do \ { \ if (src_ep % OPSIZ == 0) \ _wordcopy_bwd_aligned (dst_ep, src_ep, (nbytes) / OPSIZ); \ else \ _wordcopy_bwd_dest_aligned (dst_ep, src_ep, (nbytes) / OPSIZ); \ src_ep -= (nbytes) & -OPSIZ; \ dst_ep -= (nbytes) & -OPSIZ; \ (nbytes_left) = (nbytes) % OPSIZ; \ } while (0) /* Threshold value for when to enter the unrolled loops. */ #define OP_T_THRES 16 ./libc-linux/sysdeps/m68k/ 40755 1676 334 0 5521072642 13301 5ustar hjlisl./libc-linux/sysdeps/m68k/Makefile100644 1676 334 753 5521072204 15015 0ustar hjlisl# # Makefile for m68k specific functions. # TOPDIR=../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I$(TOPDIR)/string -I$(TOPDIR) -I. DIRS:= setjmp SRC1S= hton.c modf.c bzero.c ffs.c memchr.c memcmp.c memset.c \ strcat.c strchr.c strcmp.c strcspn.c strlen.c strncmp.c \ strpbrk.c strrchr.c strspn.c SRC2S= ntoh.c div.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRC1S:.c=.s) $(SCR2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/sysdeps/m68k/bzero.c100644 1676 334 4172 5521072225 14664 0ustar hjlisl/* Copyright (C) 1991 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 /* Set N bytes of S to 0. */ void #ifdef linux DEFUN(bzero, (s, n), PTR s AND int len) #else DEFUN(bzero, (s, n), PTR s AND size_t len) #endif { long int dstp = (long int) s; CONST op_t zero = 0; if (len >= 8) { size_t xlen; /* There are at least some bytes to zero. No need to test for LEN == 0 in this alignment loop. */ while (dstp % OPSIZ != 0) { ((byte *) dstp)[0] = 0; dstp += 1; len -= 1; } /* Write 8 op_t per iteration until less than 8 op_t remain. */ xlen = len / (OPSIZ * 8); while (xlen != 0) { ((op_t *) dstp)[0] = zero; ((op_t *) dstp)[1] = zero; ((op_t *) dstp)[2] = zero; ((op_t *) dstp)[3] = zero; ((op_t *) dstp)[4] = zero; ((op_t *) dstp)[5] = zero; ((op_t *) dstp)[6] = zero; ((op_t *) dstp)[7] = zero; dstp += 8 * OPSIZ; xlen -= 1; } len %= OPSIZ * 8; /* Write 1 op_t per iteration until less than op_t remain. */ xlen = len / OPSIZ; while (xlen != 0) { ((op_t *) dstp)[0] = zero; dstp += OPSIZ; xlen -= 1; } len %= OPSIZ; } /* Write the last few bytes. */ while (len != 0) { ((byte *) dstp)[0] = 0; dstp += 1; len -= 1; } } ./libc-linux/sysdeps/m68k/crypt.S100644 1676 334 4252 5521072225 14663 0ustar hjlisl| | UFC-crypt: ultra fast crypt(3) implementation | Copyright (C) 1991, 1992, Michael Glad, email: glad@daimi.aau.dk | | This library is free software, you can redistribute it and/or | modify it under the terms of the GNU Library General Public | License as published by the Free Software Foundation, either | version 2 of the License, or (at your option) any later version. | | This library is distributed in the hope that it will be useful, | but WITHOUT ANY WARRANTY, without even the implied warranty of | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | Library General Public License for more details. | | You should have received a copy of the GNU Library General Public | License along with this library, if not, write to the Free | Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | | @(#)crypt.sun3.S 2.8 01/11/92 | | Assembly code for SUN3 68000 based workstations. | #define L1 d0 #define L2 d1 #define R1 d2 #define R2 d3 #define SCR1 d4 #define SCR2 d5 #define I d7 #define ITR a6@(24) #define SB0 a0 #define SB1 a1 #define SB2 a2 #define SB3 a3 #define KPTR a4 #define F(I,O1,O2,SBX,SBY) \ movl KPTR@+,SCR1 ; eorl I,SCR1 ; \ movl SBX@(0,SCR1:w),SCR2 ; eorl SCR2,O1 ; \ movl SBX@(4,SCR1:w),SCR2 ; eorl SCR2,O2 ; \ swap SCR1 ; \ movl SBY@(0,SCR1:w),SCR2 ; eorl SCR2,O1 ; \ movl SBY@(4,SCR1:w),SCR2 ; eorl SCR2,O2 ; #define G(I1,I2,O1,O2) \ F(I1,O1,O2,SB1,SB0) F(I2,O1,O2,SB3,SB2) #define H G(R1,R2,L1,L2) ; G(L1,L2,R1,R2) .text .proc .globl _ufc_doit _ufc_doit: | | Preamble | link a6,#-56 moveml #15612,sp@ movl a6@(20),R2 movl a6@(16),R1 movl a6@(12),L2 movl a6@(8),L1 | | Setup address registers with sb pointers | movl #_ufc_sb0,SB0 ; movl #_ufc_sb1,SB1 movl #_ufc_sb2,SB2 ; movl #_ufc_sb3,SB3 | | And loop... | Lagain: movl #_ufc_keytab,KPTR moveq #8,I Lagain1: H subql #1,I tstl I jne Lagain1 | Permute movl L1,SCR1 ; movl R1,L1 ; movl SCR1,R1 movl L2,SCR1 ; movl R2,L2 ; movl SCR1,R2 | subql #1,ITR jne Lagain | | Output conversion | movl R2,sp@- ; movl R1,sp@- movl L2,sp@- ; movl L1,sp@- jbsr _ufc_dofinalperm ; addl #16,sp | | Postamble | moveml a6@(-56),#15612 ; unlk a6 ; rts ./libc-linux/sysdeps/m68k/div.c100644 1676 334 275 5521072226 14306 0ustar hjlisl#include #include #undef div #undef ldiv #include function_alias(div, ldiv, div_t, (num, denom), DEFUN(div, (num, denom), int num AND int denom)) ./libc-linux/sysdeps/m68k/ffs.c100644 1676 334 2314 5521072226 14316 0ustar hjlisl/* ffs -- find first set bit in a word, counted from least significant end. For mc68020, mc68030, mc68040. Copyright (C) 1991, 1992 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 #undef ffs #if defined (__GNUC__) && defined (__mc68020__) int DEFUN(ffs, (x), int x) { int cnt; asm("bfffo %1{#0:#0},%0" : "=d" (cnt) : "rm" (x & -x)); return 32 - cnt; } #else #include #endif ./libc-linux/sysdeps/m68k/hton.c100644 1676 334 365 5521072226 14474 0ustar hjlisl#include #include #undef ntohl #undef ntohs #undef htonl #undef htons unsigned long int htonl(unsigned long int x) { return __htonl (x); } unsigned short int htons(unsigned short int x) { return __htons (x); } ./libc-linux/sysdeps/m68k/memchr.c100644 1676 334 11434 5521072226 15036 0ustar hjlisl/* Copyright (C) 1991 Free Software Foundation, Inc. Based on strlen implemention by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and commentary by Jim Blandy (jimb@ai.mit.edu); adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), and implemented by Roland McGrath (roland@ai.mit.edu). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as 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 /* Search no more than N bytes of S for C. */ PTR DEFUN(memchr, (s, c, n), CONST PTR s AND int c AND size_t n) { CONST unsigned char *char_ptr; CONST unsigned long int *longword_ptr; unsigned long int longword, magic_bits, charmask; c = (unsigned char) c; /* Handle the first few characters by reading one character at a time. Do this until CHAR_PTR is aligned on a 4-byte border. */ for (char_ptr = s; n > 0 && ((unsigned long int) char_ptr & 3) != 0; --n, ++char_ptr) if (*char_ptr == c) return (PTR) char_ptr; longword_ptr = (unsigned long int *) char_ptr; /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits the "holes." Note that there is a hole just to the left of each byte, with an extra at the end: bits: 01111110 11111110 11111110 11111111 bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ magic_bits = 0x7efefeff; /* Set up a longword, each of whose bytes is C. */ charmask = c | (c << 8); charmask |= charmask << 16; /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing if *any of the four* bytes in the longword in question are zero. */ while (n >= 4) { /* We tentatively exit the loop if adding MAGIC_BITS to LONGWORD fails to change any of the hole bits of LONGWORD. 1) Is this safe? Will it catch all the zero bytes? Suppose there is a byte with all zeros. Any carry bits propagating from its left will fall into the hole at its least significant bit and stop. Since there will be no carry from its most significant bit, the LSB of the byte to the left will be unchanged, and the zero will be detected. 2) Is this worthwhile? Will it ignore everything except zero bytes? Suppose every byte of LONGWORD has a bit set somewhere. There will be a carry into bit 8. If bit 8 is set, this will carry into bit 16. If bit 8 is clear, one of bits 9-15 must be set, so there will be a carry into bit 16. Similarly, there will be a carry into bit 24. If one of bits 24-30 is set, there will be a carry into bit 31, so all of the hole bits will be changed. The one misfire occurs when bits 24-30 are clear and bit 31 is set; in this case, the hole at bit 31 is not changed. If we had access to the processor carry flag, we could close this loophole by putting the fourth hole at bit 32! So it ignores everything except 128's, when they're aligned properly. 3) But wait! Aren't we looking for C, not zero? Good point. So what we do is XOR LONGWORD with a longword, each of whose bytes is C. This turns each byte that is C into a zero. */ longword = *longword_ptr++ ^ charmask; /* Add MAGIC_BITS to LONGWORD. */ if ((((longword + magic_bits) /* Set those bits that were unchanged by the addition. */ ^ ~longword) /* Look at only the hole bits. If any of the hole bits are unchanged, most likely one of the bytes was a zero. */ & ~magic_bits) != 0) { /* Which of the bytes was C? If none of them were, it was a misfire; continue the search. */ CONST unsigned char *cp = (CONST unsigned char *) (longword_ptr - 1); if (cp[0] == c) return (PTR) cp; if (cp[1] == c) return (PTR) &cp[1]; if (cp[2] == c) return (PTR) &cp[2]; if (cp[3] == c) return (PTR) &cp[3]; } n -= 4; } char_ptr = (CONST unsigned char *) longword_ptr; while (n-- > 0) { if (*char_ptr == c) return (PTR) char_ptr; else ++char_ptr; } return NULL; } ./libc-linux/sysdeps/m68k/memcmp.c100644 1676 334 15460 5521072242 15042 0ustar hjlisl/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 #ifdef isbcmp #define memcmp bcmp #define size_t int #endif /* BE VERY CAREFUL IF YOU CHANGE THIS CODE! */ /* The strategy of this memcmp is: 1. Compare bytes until one of the block pointers is aligned. 2. Compare using memcmp_common_alignment or memcmp_not_common_alignment, regarding the alignment of the other block after the initial byte operations. The maximum number of full words (of type op_t) are compared in this way. 3. Compare the few remaining bytes. */ /* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t' objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for memory operations on `op_t's. */ #ifdef __GNUC__ __inline #endif static int memcmp_common_alignment (srcp1, srcp2, len) long int srcp1; long int srcp2; size_t len; { op_t a0, a1; op_t b0, b1; op_t res; switch (len % 4) { case 2: a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; srcp1 -= 2 * OPSIZ; srcp2 -= 2 * OPSIZ; len += 2; goto do1; case 3: a1 = ((op_t *) srcp1)[0]; b1 = ((op_t *) srcp2)[0]; srcp1 -= OPSIZ; srcp2 -= OPSIZ; len += 1; goto do2; case 0: if (OP_T_THRES <= 3 * OPSIZ && len == 0) return 0; a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; goto do3; case 1: a1 = ((op_t *) srcp1)[0]; b1 = ((op_t *) srcp2)[0]; srcp1 += OPSIZ; srcp2 += OPSIZ; len -= 1; if (OP_T_THRES <= 3 * OPSIZ && len == 0) goto do0; /* Fall through. */ } do { a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; res = a1 - b1; if (res != 0) return res; do3: a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[1]; res = a0 - b0; if (res != 0) return res; do2: a0 = ((op_t *) srcp1)[2]; b0 = ((op_t *) srcp2)[2]; res = a1 - b1; if (res != 0) return res; do1: a1 = ((op_t *) srcp1)[3]; b1 = ((op_t *) srcp2)[3]; res = a0 - b0; if (res != 0) return res; srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; len -= 4; } while (len != 0); /* This is the right position for do0. Please don't move it into the loop. */ do0: return a1 - b1; } /* SRCP2 should be aligned for memory operations on `op_t', but SRCP1 *should be unaligned*. */ #ifdef __GNUC__ __inline #endif static int memcmp_not_common_alignment (srcp1, srcp2, len) long int srcp1; long int srcp2; size_t len; { op_t a0, a1, a2, a3; op_t b0, b1, b2, b3; op_t res; op_t x; int shl, shr; /* Calculate how to shift a word read at the memory operation aligned srcp1 to make it aligned for comparison. */ shl = 8 * (srcp1 % OPSIZ); shr = 8 * OPSIZ - shl; /* Make SRCP1 aligned by rounding it down to the beginning of the `op_t' it points in the middle of. */ srcp1 &= -OPSIZ; switch (len % 4) { case 2: a1 = ((op_t *) srcp1)[0]; a2 = ((op_t *) srcp1)[1]; b2 = ((op_t *) srcp2)[0]; srcp1 -= 1 * OPSIZ; srcp2 -= 2 * OPSIZ; len += 2; goto do1; case 3: a0 = ((op_t *) srcp1)[0]; a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[0]; srcp2 -= 1 * OPSIZ; len += 1; goto do2; case 0: if (OP_T_THRES <= 3 * OPSIZ && len == 0) return 0; a3 = ((op_t *) srcp1)[0]; a0 = ((op_t *) srcp1)[1]; b0 = ((op_t *) srcp2)[0]; srcp1 += 1 * OPSIZ; goto do3; case 1: a2 = ((op_t *) srcp1)[0]; a3 = ((op_t *) srcp1)[1]; b3 = ((op_t *) srcp2)[0]; srcp1 += 2 * OPSIZ; srcp2 += 1 * OPSIZ; len -= 1; if (OP_T_THRES <= 3 * OPSIZ && len == 0) goto do0; /* Fall through. */ } do { a0 = ((op_t *) srcp1)[0]; b0 = ((op_t *) srcp2)[0]; x = MERGE(a2, shl, a3, shr); res = x - b3; if (res != 0) return res; do3: a1 = ((op_t *) srcp1)[1]; b1 = ((op_t *) srcp2)[1]; x = MERGE(a3, shl, a0, shr); res = x - b0; if (res != 0) return res; do2: a2 = ((op_t *) srcp1)[2]; b2 = ((op_t *) srcp2)[2]; x = MERGE(a0, shl, a1, shr); res = x - b1; if (res != 0) return res; do1: a3 = ((op_t *) srcp1)[3]; b3 = ((op_t *) srcp2)[3]; x = MERGE(a1, shl, a2, shr); res = x - b2; if (res != 0) return res; srcp1 += 4 * OPSIZ; srcp2 += 4 * OPSIZ; len -= 4; } while (len != 0); /* This is the right position for do0. Please don't move it into the loop. */ do0: x = MERGE(a2, shl, a3, shr); return x - b3; } int memcmp (s1, s2, len) const __ptr_t s1; const __ptr_t s2; size_t len; { op_t a0; op_t b0; long int srcp1 = (long int) s1; long int srcp2 = (long int) s2; op_t res; if (len >= OP_T_THRES) { /* There are at least some bytes to compare. No need to test for LEN == 0 in this alignment loop. */ while (srcp2 % OPSIZ != 0) { a0 = ((byte *) srcp1)[0]; b0 = ((byte *) srcp2)[0]; srcp1 += 1; srcp2 += 1; res = a0 - b0; if (res != 0) return res; len -= 1; } /* SRCP2 is now aligned for memory operations on `op_t'. SRCP1 alignment determines if we can do a simple, aligned compare or need to shuffle bits. */ if (srcp1 % OPSIZ == 0) res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ); else res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ); if (res != 0) return res; /* Number of bytes remaining in the interval [0..OPSIZ-1]. */ srcp1 += len & -OPSIZ; srcp2 += len & -OPSIZ; len %= OPSIZ; } /* There are just a few bytes to compare. Use byte memory operations. */ while (len != 0) { a0 = ((byte *) srcp1)[0]; b0 = ((byte *) srcp2)[0]; srcp1 += 1; srcp2 += 1; res = a0 - b0; if (res != 0) return res; len -= 1; } return 0; } ./libc-linux/sysdeps/m68k/memcopy.h100644 1676 334 7027 5521072243 15223 0ustar hjlisl/* memcopy.h -- definitions for memory copy functions. Motorola 68020 version. Copyright (C) 1991 Free Software Foundation, Inc. Contributed by Torbjorn Granlund (tege@sics.se). 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 #undef OP_T_THRES #define OP_T_THRES 16 /* WORD_COPY_FWD and WORD_COPY_BWD are not symmetric on the 68020, because of its weird instruction overlap characteristics. */ #undef WORD_COPY_FWD #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \ do \ { \ size_t __nwords = (nbytes) / sizeof (op_t); \ size_t __nblocks = __nwords / 8 + 1; \ dst_bp -= (8 - __nwords % 8) * sizeof (op_t); \ src_bp -= (8 - __nwords % 8) * sizeof (op_t); \ switch (__nwords % 8) \ do \ { \ ((op_t *) dst_bp)[0] = ((op_t *) src_bp)[0]; \ case 7: \ ((op_t *) dst_bp)[1] = ((op_t *) src_bp)[1]; \ case 6: \ ((op_t *) dst_bp)[2] = ((op_t *) src_bp)[2]; \ case 5: \ ((op_t *) dst_bp)[3] = ((op_t *) src_bp)[3]; \ case 4: \ ((op_t *) dst_bp)[4] = ((op_t *) src_bp)[4]; \ case 3: \ ((op_t *) dst_bp)[5] = ((op_t *) src_bp)[5]; \ case 2: \ ((op_t *) dst_bp)[6] = ((op_t *) src_bp)[6]; \ case 1: \ ((op_t *) dst_bp)[7] = ((op_t *) src_bp)[7]; \ case 0: \ src_bp += 32; \ dst_bp += 32; \ __nblocks--; \ } \ while (__nblocks != 0); \ (nbytes_left) = (nbytes) % sizeof (op_t); \ } while (0) #undef WORD_COPY_BWD #define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \ do \ { \ size_t __nblocks = (nbytes) / 32 + 1; \ switch ((nbytes) / sizeof (op_t) % 8) \ do \ { \ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \ case 7: \ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \ case 6: \ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \ case 5: \ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \ case 4: \ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \ case 3: \ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \ case 2: \ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \ case 1: \ *--((op_t *) dst_ep) = *--((op_t *) src_ep); \ case 0: \ __nblocks--; \ } \ while (__nblocks != 0); \ (nbytes_left) = (nbytes) % sizeof (op_t); \ } while (0) ./libc-linux/sysdeps/m68k/memset.c100644 1676 334 4215 5521072243 15033 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 PTR DEFUN(memset, (dstpp, c, len), PTR dstpp AND int c AND size_t len) { long int dstp = (long int) dstpp; if (len >= 8) { size_t xlen; op_t cccc; cccc = (unsigned char) c; cccc |= cccc << 8; cccc |= cccc << 16; if (OPSIZ > 4) cccc |= cccc << 32; /* There are at least some bytes to set. No need to test for LEN == 0 in this alignment loop. */ while (dstp % OPSIZ != 0) { ((byte *) dstp)[0] = c; dstp += 1; len -= 1; } /* Write 8 `op_t' per iteration until less than 8 `op_t' remain. */ xlen = len / (OPSIZ * 8); while (xlen > 0) { ((op_t *) dstp)[0] = cccc; ((op_t *) dstp)[1] = cccc; ((op_t *) dstp)[2] = cccc; ((op_t *) dstp)[3] = cccc; ((op_t *) dstp)[4] = cccc; ((op_t *) dstp)[5] = cccc; ((op_t *) dstp)[6] = cccc; ((op_t *) dstp)[7] = cccc; dstp += 8 * OPSIZ; xlen -= 1; } len %= OPSIZ * 8; /* Write 1 `op_t' per iteration until less than OPSIZ bytes remain. */ xlen = len / OPSIZ; while (xlen > 0) { ((op_t *) dstp)[0] = cccc; dstp += OPSIZ; xlen -= 1; } len %= OPSIZ; } /* Write the last few bytes. */ while (len > 0) { ((byte *) dstp)[0] = c; dstp += 1; len -= 1; } return dstpp; } ./libc-linux/sysdeps/m68k/modf.c100644 1676 334 1744 5521072243 14472 0ustar hjlisl/* Copyright (C) 1991 Free Software Foundation, Inc. This section of 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 __NO_MATH_INLINES #include double DEFUN(modf, (x, iptr), double x AND double *iptr) { return __modf(x, iptr); } ./libc-linux/sysdeps/m68k/ntoh.c100644 1676 334 504 5521072243 14466 0ustar hjlisl#include #include #include #undef ntohl #undef ntohs #undef htonl #undef htons function_alias(ntohl, htonl, unsigned long int, (x), DEFUN(htonl, (x), unsigned long int)) function_alias(ntohs, htons, unsigned short int, (x), DEFUN(htons, (x), unsigned short int)) ./libc-linux/sysdeps/m68k/setjmp/ 40755 1676 334 0 5521072657 14611 5ustar hjlisl./libc-linux/sysdeps/m68k/setjmp/Makefile100644 1676 334 525 5521072244 16320 0ustar hjlisl# # Makefile for m68k specific functions. # TOPDIR=../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I$(TOPDIR)/include -I.. BASE_CFLAGS:=$(BASE_CFLAGS) -fno-omit-frame-pointer DIRS:= SRCS= __longjmp.c __setjmp.c # sigsetjmp.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/sysdeps/m68k/setjmp/__longjmp.c100644 1676 334 4060 5521072244 17006 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 __GNUC__ #error This file uses GNU C extensions; you must compile with GCC. #endif /* Jump to the position specified by ENV, causing the setjmp call there to return VAL, or 1 if VAL is 0. */ __NORETURN void DEFUN(__longjmp, (env, val), CONST jmp_buf env AND int val) { /* This restores the FP and SP that setjmp's caller had, and puts the return address into A0 and VAL into D0. */ #if defined(__HAVE_68881__) || defined(__HAVE_FPU__) /* Restore the floating-point registers. */ asm volatile("fmovem%.x %0, fp0-fp7" : /* No outputs. */ : "g" (env[0].__fpregs[0]) : "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7"); #endif /* Put VAL in D0. */ asm volatile("move%.l %0, d0" : /* No outputs. */ : "g" (val == 0 ? 1 : val) : "d0"); asm volatile(/* Restore the data and address registers. */ "movem%.l %0, d1-d7/a0-a7\n" /* Return to setjmp's caller. */ "jmp a0@" : /* No outputs. */ : "g" (env[0].__dregs[0]) /* We don't bother with the clobbers, because this code always jumps out anyway. */ ); /* This call avoids `volatile function does return' warnings. */ abort (); } ./libc-linux/sysdeps/m68k/setjmp/__setjmp.c100644 1676 334 4305 5521072244 16644 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 #ifndef __GNUC__ #error This file uses GNU C extensions; you must compile with GCC. #endif /* Save the current program position in ENV and return 0. */ int DEFUN(__setjmp, (env), jmp_buf env) { /* Save data registers D1 through D7. */ asm volatile("movem%.l d1-d7, %0" : : "m" (env[0].__dregs[0])); /* Save return address in place of register A0. */ env[0].__aregs[0] = (PTR) ((PTR *) &env)[-1]; /* Save address registers A1 through A5. */ asm volatile("movem%.l a1-a5, %0" : : "m" (env[0].__aregs[1])); /* Save caller's FP, not our own. */ env[0].__fp = (PTR) ((PTR *) &env)[-2]; /* XXX FIX ME */ /* * The Amiga GCC uses A5 as the frame pointer, rather than A6, so this * code loses on that compiler, since this code expects A6 to be the * frame pointer. * This change fix will only be compiled occur if __amiga__ is defined. * * The long term solution is to create a "linux/68k" gcc which uses a6 * as the frame pointer. */ #ifdef __amiga__ env[0].__aregs[5] = env[0].__fp; asm volatile ("move%.l a6, %0" : : "m" (env[0].__fp)); #endif /* XXX */ /* Save caller's SP, not our own. */ env[0].__sp = (PTR) &env; #if defined(__HAVE_68881__) || defined(__HAVE_FPU__) /* Save floating-point (68881) registers FP0 through FP7. */ asm volatile("fmovem%.x fp0-fp7, %0" : : "m" (env[0].__fpregs[0])); #endif return 0; } ./libc-linux/sysdeps/m68k/setjmp/sigsetjmp.c100644 1676 334 3437 5521072262 17056 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 #include /* Store the calling environment in ENV, also saving the signal mask if SAVEMASK is nonzero. Return 0. */ int DEFUN(sigsetjmp, (env, savemask), sigjmp_buf env AND int savemask) { if (savemask) #ifdef linux env[0].__sigmask = __siggetmask(), env[0].__savemask = 1; #else env[0].__savemask = sigprocmask(SIG_BLOCK, (sigset_t *) NULL, &env[0].__sigmask) == 0; #endif else env[0].__savemask = 0; #define REGS \ REG (bx);\ REG (si);\ REG (di) /* Save the general registers. */ #define REG(xx) asm volatile ("movl %%e" #xx ",%0" : \ "=m" ((long int) ((env[0].__jmpbuf)[0].__##xx)) : ) REGS; /* Save the return PC. */ (env[0].__jmpbuf)[0].__pc = (PTR) ((PTR *) &env)[-1]; /* Save caller's FP, not our own. */ (env[0].__jmpbuf)[0].__bp = (PTR) ((PTR *) &env)[-2]; /* Save caller's SP, not our own. */ (env[0].__jmpbuf)[0].__sp = (PTR) &env; return 0; } ./libc-linux/sysdeps/m68k/strcat.c100644 1676 334 2541 5521072262 15042 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 /* Append SRC on the end of DEST. */ char * DEFUN(strcat, (dest, src), char *dest AND CONST char *src) { register char *s1 = dest; register CONST char *s2 = src; reg_char c; /* Find the end of the string. */ do c = *s1++; while (c != '\0'); /* Make S1 point before the next character, so we can increment it while memory is read (wins on pipelined cpus). */ s1 -= 2; do { c = *s2++; *++s1 = c; } while (c != '\0'); return dest; } ./libc-linux/sysdeps/m68k/strchr.c100644 1676 334 11742 5521072263 15073 0ustar hjlisl/* Copyright (C) 1991 Free Software Foundation, Inc. Based on strlen implemention by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and bug fix and commentary by Jim Blandy (jimb@ai.mit.edu); adaptation to strchr suggested by Dick Karpinski (dick@cca.ucsf.edu), and implemented by Roland McGrath (roland@ai.mit.edu). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as 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 /* Find the first ocurrence of C in S. */ char * DEFUN(strchr, (s, c), CONST char *s AND int c) { CONST unsigned char *char_ptr; CONST unsigned long int *longword_ptr; unsigned long int longword, magic_bits, charmask; c = (unsigned char) c; /* Handle the first few characters by reading one character at a time. Do this until CHAR_PTR is aligned on a 4-byte border. */ for (char_ptr = (CONST unsigned char *) s; ((unsigned long int) char_ptr & 3) != 0; ++char_ptr) { if (*char_ptr == c) return (char *) char_ptr; else if (*char_ptr == '\0') return NULL; } longword_ptr = (unsigned long int *) char_ptr; /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits the "holes." Note that there is a hole just to the left of each byte, with an extra at the end: bits: 01111110 11111110 11111110 11111111 bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ magic_bits = 0x7efefeff; /* Set up a longword, each of whose bytes is C. */ charmask = (c << 24) | (c << 16) | (c << 8) | c; /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing if *any of the four* bytes in the longword in question are zero. */ for (;;) { /* We tentatively exit the loop if adding MAGIC_BITS to LONGWORD fails to change any of the hole bits of LONGWORD. 1) Is this safe? Will it catch all the zero bytes? Suppose there is a byte with all zeros. Any carry bits propagating from its left will fall into the hole at its least significant bit and stop. Since there will be no carry from its most significant bit, the LSB of the byte to the left will be unchanged, and the zero will be detected. 2) Is this worthwhile? Will it ignore everything except zero bytes? Suppose every byte of LONGWORD has a bit set somewhere. There will be a carry into bit 8. If bit 8 is set, this will carry into bit 16. If bit 8 is clear, one of bits 9-15 must be set, so there will be a carry into bit 16. Similarly, there will be a carry into bit 24. If one of bits 24-30 is set, there will be a carry into bit 31, so all of the hole bits will be changed. The one misfire occurs when bits 24-30 are clear and bit 31 is set; in this case, the hole at bit 31 is not changed. If we had access to the processor carry flag, we could close this loophole by putting the fourth hole at bit 32! So it ignores everything except 128's, when they're aligned properly. 3) But wait! Aren't we looking for C as well as zero? Good point. So what we do is XOR LONGWORD with a longword, each of whose bytes is C. This turns each byte that is C into a zero. */ longword = *longword_ptr++; /* Add MAGIC_BITS to LONGWORD. */ if ((((longword + magic_bits) /* Set those bits that were unchanged by the addition. */ ^ ~longword) /* Look at only the hole bits. If any of the hole bits are unchanged, most likely one of the bytes was a zero. */ & ~magic_bits) != 0 || /* That caught zeroes. Now test for C. */ ((((longword ^ charmask) + magic_bits) ^ ~(longword ^ charmask)) & ~magic_bits) != 0) { /* Which of the bytes was C or zero? If none of them were, it was a misfire; continue the search. */ CONST unsigned char *cp = (CONST unsigned char *) (longword_ptr - 1); if (*cp == c) return (char *) cp; else if (*cp == '\0') return NULL; if (*++cp == c) return (char *) cp; else if (*cp == '\0') return NULL; if (*++cp == c) return (char *) cp; else if (*cp == '\0') return NULL; if (*++cp == c) return (char *) cp; else if (*cp == '\0') return NULL; } } return NULL; } ./libc-linux/sysdeps/m68k/strcmp.c100644 1676 334 2623 5521072263 15054 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 /* Compare S1 and S2, returning less than, equal to or greater than zero if S1 is lexiographically less than, equal to or greater than S2. */ int DEFUN(strcmp, (p1, p2), CONST char *p1 AND CONST char *p2) { register CONST unsigned char *s1 = (CONST unsigned char *) p1; register CONST unsigned char *s2 = (CONST unsigned char *) p2; unsigned reg_char c1, c2; do { c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0') return c1 - c2; } while (c1 == c2); return c1 - c2; } ./libc-linux/sysdeps/m68k/strcspn.c100644 1676 334 2311 5521072263 15232 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 /* Return the length of the maximum inital segment of S which contains no characters from REJECT. */ size_t DEFUN(strcspn, (s, reject), register CONST char *s AND register CONST char *reject) { register size_t count = 0; while (*s != '\0') if (strchr(reject, *s++) == NULL) ++count; else return count; return count; } ./libc-linux/sysdeps/m68k/strlen.c100644 1676 334 10352 5521072263 15071 0ustar hjlisl/* Copyright (C) 1991 Free Software Foundation, Inc. Written by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se); commentary by Jim Blandy (jimb@ai.mit.edu). The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as 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 /* Return the length of the null-terminated string STR. Scan for the null terminator quickly by testing four bytes at a time. */ size_t DEFUN(strlen, (str), CONST char *str) { CONST char *char_ptr; CONST unsigned long int *longword_ptr; unsigned long int longword, magic_bits, himagic, lomagic; /* Handle the first few characters by reading one character at a time. Do this until STR is aligned on a 4-byte border. */ for (char_ptr = str; ((unsigned long int) char_ptr & 3) != 0; ++char_ptr) if (*char_ptr == 0) return char_ptr - str; longword_ptr = (unsigned long int *) char_ptr; /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits the "holes." Note that there is a hole just to the left of each byte, with an extra at the end: bits: 01111110 11111110 11111110 11111111 bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ magic_bits = 0x7efefeff; himagic = 0x80808080; lomagic = 0x01010101; /* Instead of the traditional loop which tests each character, we will test a longword at a time. The tricky part is testing if *any of the four* bytes in the longword in question are zero. */ for (;;) { /* We tentatively exit the loop if adding MAGIC_BITS to LONGWORD fails to change any of the hole bits of LONGWORD. 1) Is this safe? Will it catch all the zero bytes? Suppose there is a byte with all zeros. Any carry bits propagating from its left will fall into the hole at its least significant bit and stop. Since there will be no carry from its most significant bit, the LSB of the byte to the left will be unchanged, and the zero will be detected. 2) Is this worthwhile? Will it ignore everything except zero bytes? Suppose every byte of LONGWORD has a bit set somewhere. There will be a carry into bit 8. If bit 8 is set, this will carry into bit 16. If bit 8 is clear, one of bits 9-15 must be set, so there will be a carry into bit 16. Similarly, there will be a carry into bit 24. If one of bits 24-30 is set, there will be a carry into bit 31, so all of the hole bits will be changed. The one misfire occurs when bits 24-30 are clear and bit 31 is set; in this case, the hole at bit 31 is not changed. If we had access to the processor carry flag, we could close this loophole by putting the fourth hole at bit 32! So it ignores everything except 128's, when they're aligned properly. */ longword = *longword_ptr++; if ( #if 0 /* Add MAGIC_BITS to LONGWORD. */ (((longword + magic_bits) /* Set those bits that were unchanged by the addition. */ ^ ~longword) /* Look at only the hole bits. If any of the hole bits are unchanged, most likely one of the bytes was a zero. */ & ~magic_bits) #else ((longword - lomagic) & himagic) #endif != 0) { /* Which of the bytes was the zero? If none of them were, it was a misfire; continue the search. */ CONST char *cp = (CONST char *) (longword_ptr - 1); if (cp[0] == 0) return cp - str; if (cp[1] == 0) return cp - str + 1; if (cp[2] == 0) return cp - str + 2; if (cp[3] == 0) return cp - str + 3; } } } ./libc-linux/sysdeps/m68k/strncmp.c100644 1676 334 3644 5521072304 15232 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 /* Compare no more than N characters of S1 and S2, returning less than, equal to or greater than zero if S1 is lexiographically less than, equal to or greater than S2. */ int DEFUN(strncmp, (s1, s2, n), CONST char *s1 AND CONST char *s2 AND size_t n) { unsigned reg_char c1 = '\0'; unsigned reg_char c2 = '\0'; if (n >= 4) { size_t n4 = n >> 2; do { c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0' || c1 != c2) return c1 - c2; c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0' || c1 != c2) return c1 - c2; c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0' || c1 != c2) return c1 - c2; c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0' || c1 != c2) return c1 - c2; } while (--n4 > 0); n &= 3; } while (n > 0) { c1 = (unsigned char) *s1++; c2 = (unsigned char) *s2++; if (c1 == '\0' || c1 != c2) return c1 - c2; n--; } return c1 - c2; } ./libc-linux/sysdeps/m68k/strpbrk.c100644 1676 334 2201 5521072304 15217 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 /* Find the first ocurrence in S of any character in ACCEPT. */ char * DEFUN(strpbrk, (s, accept), register CONST char *s AND register CONST char *accept) { while (*s != '\0') if (strchr(accept, *s) == NULL) ++s; else return (char *) s; return NULL; } ./libc-linux/sysdeps/m68k/strrchr.c100644 1676 334 2374 5521072304 15232 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 /* Find the last ocurrence of C in S. */ char * DEFUN(strrchr, (s, c), CONST char *s AND int c) { register CONST char *found, *p; c = (unsigned char) c; /* Since strchr is fast, we use it rather than the obvious loop. */ if (c == '\0') return strchr(s, '\0'); found = NULL; while ((p = strchr(s, c)) != NULL) { found = p; s = p + 1; } return (char *) found; } ./libc-linux/sysdeps/m68k/strspn.c100644 1676 334 2444 5521072304 15072 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 /* Return the length of the maximum initial segment of S which contains only characters in ACCEPT. */ size_t DEFUN(strspn, (s, accept), CONST char *s AND CONST char *accept) { register CONST char *p; register CONST char *a; register size_t count = 0; for (p = s; *p != '\0'; ++p) { for (a = accept; *a != '\0'; ++a) if (*p == *a) break; if (*a == '\0') return count; else ++count; } return count; } ./libc-linux/jump/ 40755 1676 334 0 5514705546 12005 5ustar hjlisl./libc-linux/jump/libc/ 40755 1676 334 0 5550056542 12711 5ustar hjlisl./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/jump.ignore100644 1676 334 45371 5426074265 15224 0ustar hjlisl00000000 T _fgoto libc cr_put 00000000 T _plodput libc cr_put 00000000 T _plod libc cr_put 00000000 T _tabcol libc cr_put 00000000 T _zap libc cr_tty 00000000 C __tspace libc cr_tty 00000000 T _fullname libc fullname 00000000 T __id_subwins libc id_subwins 00000000 T __set_subwin_ libc newwin 00000000 T __swflags_ libc newwin 00000000 T __sprintw libc printw 00000000 T __putchar libc putchar 00000000 T __sscans libc scanw 00000000 T _touchoverlap libc toucholap 00000000 T _tstp libc tstp 00000000 T __gdbm_new_bucket libc bucket 00000000 T __gdbm_get_bucket libc bucket 00000000 T __gdbm_split_bucket libc bucket 00000000 T __gdbm_write_bucket libc bucket 00000000 T __gdbm_alloc libc falloc 00000000 T __gdbm_free libc falloc 00000000 T __gdbm_put_av_elem libc falloc 00000000 T __gdbm_read_entry libc findkey 00000000 T __gdbm_findkey libc findkey 00000000 T __gdbm_hash libc hash 00000000 T __gdbm_end_update libc update 00000000 T __gdbm_fatal libc update 00000000 T __sethtent libc gethstnmad 00000000 T __endhtent libc gethstnmad 00000000 T __gethtent libc gethstnmad 00000000 T __gethtbyname libc gethstnmad 00000000 T __gethtbyaddr libc gethstnmad 00000000 C __net_stayopen libc getnetent 00000000 C __proto_stayopen libc getprtent 00000000 C __serv_stayopen libc getservent 00000000 T __checkhost libc rcmd 00000000 T _p_query libc res_debug 00000000 T _p_cdname libc res_debug 00000000 T _p_rr libc res_debug 00000000 T __res_close libc res_send 00000000 T _sethostfile libc sethostent 00000000 T ___8PlotFilei libc PlotFile 00000000 T ___8PlotFileii libc PlotFile 00000000 T ___8PlotFileiPCcii libc PlotFile 00000000 T __$_8PlotFile libc PlotFile 00000000 T _cmd__8PlotFilec libc PlotFile 00000000 T ___ls__8PlotFilei libc PlotFile 00000000 T ___ls__8PlotFilePCc libc PlotFile 00000000 T _arc__8PlotFileiiiiii libc PlotFile 00000000 T _box__8PlotFileiiii libc PlotFile 00000000 T _circle__8PlotFileiii libc PlotFile 00000000 T _cont__8PlotFileii libc PlotFile 00000000 T _dot__8PlotFileiiiiPCi libc PlotFile 00000000 T _erase__8PlotFile libc PlotFile 00000000 T _label__8PlotFilePCc libc PlotFile 00000000 T _line__8PlotFileiiii libc PlotFile 00000000 T _linemod__8PlotFilePCc libc PlotFile 00000000 T _move__8PlotFileii libc PlotFile 00000000 T _point__8PlotFileii libc PlotFile 00000000 T _space__8PlotFileiiii libc PlotFile 00000000 T ___5SFilei libc SFile 00000000 T _size__5SFile libc SFile 00000000 T _setsize__5SFilei libc SFile 00000000 T __$_5SFile libc SFile 00000000 T ___5SFileiPCciii libc SFile 00000000 T ___5SFileiii libc SFile 00000000 T _open__5SFilePCciii libc SFile 00000000 T _get__5SFilePv libc SFile 00000000 T _put__5SFilePv libc SFile 00000000 T ___vc__5SFilel libc SFile 00000000 T ___11edit_stringP11edit_bufferP9edit_markT2 libc editbuf 00000000 T _inserting__14edit_streambuf libc editbuf 00000000 T _inserting__14edit_streambufi libc editbuf 00000000 T _is_reading__14edit_streambuf libc editbuf 00000000 T _current__14edit_streambuf libc editbuf 00000000 T _insert_before__9edit_mark libc editbuf 00000000 T _index_in_buffer__9edit_markP11edit_buffer libc editbuf 00000000 T ___9edit_mark libc editbuf 00000000 T _gap_start__11edit_buffer libc editbuf 00000000 T _gap_end_pos__11edit_buffer libc editbuf 00000000 T _start_marker__11edit_buffer libc editbuf 00000000 T _end_marker__11edit_buffer libc editbuf 00000000 T _gap_end__11edit_buffer libc editbuf 00000000 T _gap_size__11edit_buffer libc editbuf 00000000 T _size1__11edit_buffer libc editbuf 00000000 T _size2__11edit_buffer libc editbuf 00000000 T _mark_list__11edit_buffer libc editbuf 00000000 T _move_gap__11edit_bufferPc libc editbuf 00000000 T __$_11edit_buffer libc editbuf 00000000 T _ptr__9edit_markP11edit_buffer libc editbuf 00000000 T _flush_to_buffer__14edit_streambuf libc editbuf 00000000 T _truncate__14edit_streambuf libc editbuf 00000000 T _flush_to_buffer__14edit_streambufP11edit_buffer libc editbuf 00000000 T _disconnect_gap_from_file__14edit_streambufP11edit_buffer libc editbuf 00000000 T _tell__11edit_bufferPc libc editbuf 00000000 T _tell__11edit_bufferP9edit_mark libc editbuf 00000000 T _move_gap__11edit_bufferl libc editbuf 00000000 T _gap_left__11edit_bufferi libc editbuf 00000000 T _gap_right__11edit_bufferi libc editbuf 00000000 T _make_gap__11edit_bufferl libc editbuf 00000000 T _adjust_markers__11edit_bufferUlUliPc libc editbuf 00000000 T _underflow__14edit_streambuf libc editbuf 00000000 T _overflow__14edit_streambufi libc editbuf 00000000 T _set_current__14edit_streambufPci libc editbuf 00000000 T _seekoff__14edit_streambuflQ23ios8seek_diri libc editbuf 00000000 T _delete_range__11edit_bufferll libc editbuf 00000000 T _delete_range__11edit_bufferP9edit_markT1 libc editbuf 00000000 T _buf_delete_chars__FP11edit_bufferP9edit_markUi libc editbuf 00000000 T ___14edit_streambufP11edit_stringi libc editbuf 00000000 T __$_14edit_streambuf libc editbuf 00000000 T ___11edit_buffer libc editbuf 00000000 T ___9edit_markP11edit_stringl libc editbuf 00000000 T _buffer__9edit_mark libc editbuf 00000000 T __$_9edit_mark libc editbuf 00000000 T _length__C11edit_string libc editbuf 00000000 T _copy_bytes__C11edit_stringPi libc editbuf 00000000 T _assign__11edit_stringPT0 libc editbuf 00000000 T __sb_readline__FP9streambufRlc libc igetline 00000000 T _get_stream__11indirectbuf libc indstream 00000000 T _put_stream__11indirectbuf libc indstream 00000000 T _lookup_stream__11indirectbufi libc indstream 00000000 T ___11indirectbufP9streambufT1i libc indstream 00000000 T __$_11indirectbuf libc indstream 00000000 T _xsputn__11indirectbufPCci libc indstream 00000000 T _xsgetn__11indirectbufPci libc indstream 00000000 T _overflow__11indirectbufi libc indstream 00000000 T _underflow__11indirectbuf libc indstream 00000000 T _seekoff__11indirectbuflQ23ios8seek_diri libc indstream 00000000 T _seekpos__11indirectbufli libc indstream 00000000 T _sync__11indirectbuf libc indstream 00000000 T _pbackfail__11indirectbufi libc indstream 00000000 T _line_number__8parsebuf libc parsestream 00000000 T _line_length__8parsebuf libc parsestream 00000000 T ___8parsebuf libc parsestream 00000000 T __$_8parsebuf libc parsestream 00000000 T _left__C15string_parsebuf libc parsestream 00000000 T _right__C15string_parsebuf libc parsestream 00000000 T __$_15string_parsebuf libc parsestream 00000000 T __$_13func_parsebuf libc parsestream 00000000 T _setbuf__8parsebufPci libc parsestream 00000000 T _tell_in_line__8parsebuf libc parsestream 00000000 T _pbackfail__8parsebufi libc parsestream 00000000 T _current_line__8parsebuf libc parsestream 00000000 T _seekoff__8parsebuflQ23ios8seek_diri libc parsestream 00000000 T ___15string_parsebufPcii libc parsestream 00000000 T _underflow__15string_parsebuf libc parsestream 00000000 T _current_line__15string_parsebuf libc parsestream 00000000 T _tell_in_line__15string_parsebuf libc parsestream 00000000 T _seek_in_line__15string_parsebufi libc parsestream 00000000 T ___16general_parsebufP9streambufi libc parsestream 00000000 T __$_16general_parsebuf libc parsestream 00000000 T _underflow__16general_parsebuf libc parsestream 00000000 T _current_line__16general_parsebuf libc parsestream 00000000 T _tell_in_line__16general_parsebuf libc parsestream 00000000 T _seek_in_line__16general_parsebufi libc parsestream 00000000 T ___13func_parsebufPFPv_PcPv libc parsestream 00000000 T _tell_in_line__13func_parsebuf libc parsestream 00000000 T _current_line__13func_parsebuf libc parsestream 00000000 T _seek_in_line__13func_parsebufi libc parsestream 00000000 T _underflow__13func_parsebuf libc parsestream 00000000 T _seek_in_line__8parsebufi libc parsestream 00000000 T ___libc_fatal libc emulate 00000000 T ___emulate_dummy libc emulate 00000000 C __heapbase libc malloc 00000000 C __heapinfo libc malloc 00000000 C __heapindex libc malloc 00000000 C __heaplimit libc malloc 00000000 C __fraghead libc malloc 00000000 C __chunks_used libc malloc 00000000 C __bytes_used libc malloc 00000000 C __chunks_free libc malloc 00000000 C __bytes_free libc malloc 00000000 C ___malloc_initialized libc malloc 00000000 C ___malloc_hook libc malloc 00000000 C ___free_hook libc free 00000000 C ___realloc_hook libc realloc 00000000 T _tr_break libc mtrace 00000000 C _mallwatch libc mtrace 00000000 T ___default_morecore libc morecore 00000000 T ____masksig_restore libc ____sig 00000000 T ___load_shared_libraries libc __load 00000000 T _tzsetwall libc bsdtime 00000000 T _ufc_doit libc crypt 00000000 T _ufc_dofinalperm libc crypt_util 00000000 C _ufc_keytab libc crypt_util 00000000 C _ufc_sb0 libc crypt_util 00000000 C _ufc_sb1 libc crypt_util 00000000 C _ufc_sb2 libc crypt_util 00000000 C _ufc_sb3 libc crypt_util 00000000 C ___CTOR_LIST__ libgcc _ctors 00000000 C ___DTOR_LIST__ libgcc _ctors 00000000 T _init__7filebuf libc filebuf 00000000 T _do_write__7filebufPCci libc filebuf 00000000 T _sys_read__7filebufPcUi libc filebuf 00000000 T _sys_seek__7filebuflQ23ios8seek_dir libc filebuf 00000000 T _sys_write__7filebufPCvl libc filebuf 00000000 T _sys_stat__7filebufPv libc filebuf 00000000 T _sys_close__7filebuf libc filebuf 00000000 T ___outfloat__FdP9streambufciiUlcc libc outfloat 00000000 T ___7procbufPCci libc procbuf 00000000 T _open__7procbufPCci libc procbuf 00000000 T _sys_close__7procbuf libc procbuf 00000000 T __$_7procbuf libc procbuf 00000000 T _overflow__14help_streambufi libc sbufvform 00000000 T __$_14help_streambuf libc sbufvform 00000000 T _help_vform__FP9streambufPCcPv libc sbufvform 00000000 T _set_streampos__12streammarkerl libc streambuf 00000000 T _set_offset__12streammarkeri libc streambuf 00000000 T _saving__12streammarker libc streambuf 00000000 T _xchain__9streambuf libc streambuf 00000000 T _gptr__C9streambuf libc streambuf 00000000 T _pptr__C9streambuf libc streambuf 00000000 T _egptr__C9streambuf libc streambuf 00000000 T _epptr__C9streambuf libc streambuf 00000000 T _pbase__C9streambuf libc streambuf 00000000 T _eback__C9streambuf libc streambuf 00000000 T _base__C9streambuf libc streambuf 00000000 T _ebuf__C9streambuf libc streambuf 00000000 T _blen__C9streambuf libc streambuf 00000000 T _xput_char__9streambufc libc streambuf 00000000 T _xflags__9streambuf libc streambuf 00000000 T _xflags__9streambufi libc streambuf 00000000 T _xsetflags__9streambufi libc streambuf 00000000 T _xsetflags__9streambufii libc streambuf 00000000 T _gbump__9streambufi libc streambuf 00000000 T _pbump__9streambufi libc streambuf 00000000 T _setp__9streambufPcT1 libc streambuf 00000000 T _setg__9streambufPcN21 libc streambuf 00000000 T _shortbuf__9streambuf libc streambuf 00000000 T _in_backup__9streambuf libc streambuf 00000000 T _Gbase__9streambuf libc streambuf 00000000 T _eGptr__9streambuf libc streambuf 00000000 T _Bbase__9streambuf libc streambuf 00000000 T _Bptr__9streambuf libc streambuf 00000000 T _eBptr__9streambuf libc streambuf 00000000 T _Nbase__9streambuf libc streambuf 00000000 T _eNptr__9streambuf libc streambuf 00000000 T _have_backup__9streambuf libc streambuf 00000000 T _have_markers__9streambuf libc streambuf 00000000 T _put_mode__9streambuf libc streambuf 00000000 T ___9backupbufi libc streambuf 00000000 T __$_9backupbuf libc streambuf 00000000 T _is_reading__7filebuf libc streambuf 00000000 T _cur_ptr__7filebuf libc streambuf 00000000 T _file_ptr__7filebuf libc streambuf 00000000 T _do_flush__7filebuf libc streambuf 00000000 T __un_link__9streambuf libc streambuf 00000000 T __link_in__9streambuf libc streambuf 00000000 T __least_marker__9streambuf libc streambuf 00000000 T _switch_to_main_get_area__9streambuf libc streambuf 00000000 T _switch_to_backup_area__9streambuf libc streambuf 00000000 T _switch_to_get_mode__9streambuf libc streambuf 00000000 T _free_backup_area__9streambuf libc streambuf 00000000 T _underflow__9backupbuf libc streambuf 00000000 T _overflow__9backupbufi libc streambuf 00000000 T ___12streammarkerP9streambuf libc streambuf 00000000 T __$_12streammarker libc streambuf 00000000 T _delta__12streammarkerRT0 libc streambuf 00000000 T _delta__12streammarker libc streambuf 00000000 T _unsave_markers__9streambuf libc streambuf 00000000 T ___adjust_column__FUiPCci libc streambuf 000000c0 D __vt$filebuf libc streambuf 000000c0 D __vt$backupbuf libc streambuf 000000c0 D __vt$streambuf libc streambuf 00000040 D __vt$ios libc streambuf 00000040 D __vt$9strstream$3ios libc strstream 00000040 D __vt$10ostrstream$3ios libc strstream 00000040 D __vt$10istrstream$3ios libc strstream 00000040 D __vt$13strstreambase$3ios libc strstream 000000c0 D __vt$strstreambuf libc strstream 00000000 C __REG_SAVE2__ libc res_init 00000000 D __vt$8PlotFile$3ios libc PlotFile 00000000 D __vt$5SFile$3ios libc SFile 00000000 D __vt$edit_streambuf libc editbuf 00000000 D __vt$indirectbuf libc indstream 00000000 D __vt$general_parsebuf libc parsestream 00000000 D __vt$func_parsebuf libc parsestream 00000000 D __vt$string_parsebuf libc parsestream 00000000 D __vt$parsebuf libc parsestream 00000000 D __vt$stdiobuf libc stdiostream 00000000 K ___collate_C libc C-collate 00000000 K ___ctype_C libc C-ctype 00000000 K ___ctype_b_C libc C-ctype_ct 00000000 K ___ctype_tolower_C libc C-ctype_ct 00000000 K ___ctype_toupper_C libc C-ctype_ct 00000000 K ___ctype_ctype_C libc C-ctype_ct 00000000 K ___ctype_mbchar_C libc C-ctype_mb 00000000 K ___monetary_C libc C-monetary 00000000 K ___numeric_C libc C-numeric 00000000 K ___response_C libc C-response 00000000 K ___time_C libc C-time 00000000 i ___SHARED_LIBRARIES__ libc __load 00000000 i _environ libc ruserpass 00000000 i _sys_errlist libc clnt_perror 00000000 i _sys_nerr libc clnt_perror 00000000 i ____sig_restore libc __sigact 00000000 D __aligned_blocks libc free 00000000 D ___morecore libc malloc 00000000 D __mb_shift libc mbtowc 00000000 D ___do_global_ctors libgcc __main 00000000 D ___do_global_dtors libgcc __main 00000000 D ___main libgcc __main 00000000 D __exit_dummy_decl libgcc _exit 00000000 D ___yplib_timeout libc yplib 00000000 D ___yplib_cache libc yplib 00000000 C ___ypbindlist libc yplib 00000000 T ___grpopen libc grpopen 00000000 T ___yp_setgrflag libc grpread 00000000 T ___yp_cleargrflag libc grpread 00000000 T ___yp_getgrmode libc grpread 00000000 T ___ypparsegrp libc grpread 00000000 T ___grpalloc libc grpread 00000000 T ___grpread libc grpread 00000000 T ___grpread_noyp libc grpread 00000000 T ___pwdopen libc pwdopen 00000000 T ___yp_setpwflag libc pwdread 00000000 T ___yp_clearpwflag libc pwdread 00000000 T ___yp_getpwmode libc pwdread 00000000 T ___yp_getdomain libc pwdread 00000000 T ___ypparsepwd libc pwdread 00000000 T ___pwdalloc libc pwdread 00000000 T ___pwdread libc pwdread 00000000 T ___pwdread_noyp libc pwdread 00000000 T ___yp_dobind libc yplib 00000000 C _ypresp_allfn libc yplib 00000000 C _ypresp_data libc yplib ./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.undefs100644 1676 334 0 5550056264 15076 0ustar hjlisl./libc-linux/jump/libc/jump.vars100644 1676 334 24315 5520361070 14673 0ustar hjlisl00000098 K _h_errlist libc herror 0000023c K __sys_errlist libc _errlist 00000004 K __sys_nerr libc _errlist 000000c4 K __sys_siglist libc _siglist 00000004 D __DUMMY__ libgcc _new_handler 00000004 D ___ctype_b libc ctype-info 00000004 D ___ctype_tolower libc ctype-info 00000008 D ___ctype_toupper libc ctype-info 00000001 D __echoit libcurses curses 00000001 D __rawmode libcurses curses 00000001 D _My_term libcurses curses 00000001 D __endwin libcurses curses 00000034 D _ttytype libcurses curses 00000004 D _Def_term libcurses curses 00000004 D __tty_ch libcurses curses 00000004 D _LINES libcurses curses 00000004 D _COLS libcurses curses 00000004 D __res_iflg libcurses curses 00000004 D __res_lflg libcurses curses 00000004 D _stdscr libcurses curses 00000004 D _curscr libcurses curses 00000024 D __tty libcurses curses 00000001 D _AM libcurses curses 00000001 D _BS libcurses curses 00000001 D _CA libcurses curses 00000001 D _DA libcurses curses 00000001 D _DB libcurses curses 00000001 D _EO libcurses curses 00000001 D _HC libcurses curses 00000001 D _HZ libcurses curses 00000001 D _IN libcurses curses 00000001 D _MI libcurses curses 00000001 D _MS libcurses curses 00000001 D _NC libcurses curses 00000001 D _NS libcurses curses 00000001 D _OS libcurses curses 00000001 D _UL libcurses curses 00000001 D _XB libcurses curses 00000001 D _XN libcurses curses 00000001 D _XT libcurses curses 00000001 D _XS libcurses curses 00000001 D _XX libcurses curses 00000004 D _AL libcurses curses 00000004 C _BC libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D _BT libcurses curses 00000004 D _CD libcurses curses 00000004 D _CE libcurses curses 00000004 D _CL libcurses curses 00000004 D _CM libcurses curses 00000004 D _CR libcurses curses 00000004 D _CS libcurses curses 00000004 D _DC libcurses curses 00000004 D _DL libcurses curses 00000004 D _DM libcurses curses 00000004 D _DO libcurses curses 00000004 D _ED libcurses curses 00000004 D _EI libcurses curses 00000004 D _K0 libcurses curses 00000004 D _K1 libcurses curses 00000004 D _K2 libcurses curses 00000004 D _K3 libcurses curses 00000004 D _K4 libcurses curses 00000004 D _K5 libcurses curses 00000004 D _K6 libcurses curses 00000004 D _K7 libcurses curses 00000004 D _K8 libcurses curses 00000004 D _K9 libcurses curses 00000004 D _HO libcurses curses 00000004 D _IC libcurses curses 00000004 D _IM libcurses curses 00000004 D _IP libcurses curses 00000004 D _KD libcurses curses 00000004 D _KE libcurses curses 00000004 D _KH libcurses curses 00000004 D _KL libcurses curses 00000004 D _KR libcurses curses 00000004 D _KS libcurses curses 00000004 D _KU libcurses curses 00000004 D _LL libcurses curses 00000004 D _MA libcurses curses 00000004 D _ND libcurses curses 00000004 D _NL libcurses curses 00000004 D _RC libcurses curses 00000004 D _SC libcurses curses 00000004 D _SE libcurses curses 00000004 D _SF libcurses curses 00000004 D _SO libcurses curses 00000004 D _SR libcurses curses 00000004 D _TA libcurses curses 00000004 D _TE libcurses curses 00000004 D _TI libcurses curses 00000004 D _UC libcurses curses 00000004 D _UE libcurses curses 00000004 C _UP libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D _US libcurses curses 00000004 D _VB libcurses curses 00000004 D _VS libcurses curses 00000004 D _VE libcurses curses 00000004 D _AL_PARM libcurses curses 00000004 D _DL_PARM libcurses curses 00000004 D _UP_PARM libcurses curses 00000004 D _DOWN_PARM libcurses curses 00000004 D _LEFT_PARM libcurses curses 00000004 D _RIGHT_PARM libcurses curses 00000001 C _PC libtermcap,libcurses termcap 00000000 D __DUMMY__ libtermcap curses 00000001 D _GT libcurses curses 00000001 D _NONL libcurses curses 00000001 D _UPPERCASE libcurses curses 00000001 D _normtty libcurses curses 00000003 D __pfast libcurses curses 00000200 D __unctrl libcurses unctrl 00000008 C _gdbm_errno libdbm global 00000000 C __DUMMY__ libdbm global 00000008 D _h_errno libc herror 00000180 D __res libc res_init 00000008 D _rexecoptions libc rexec 0000014c D __IO_stdin_ libc stdfiles 0000014c D __IO_stdout_ libc stdfiles 0000014c D __IO_stderr_ libc stdfiles 0000014c D __DUMMY__ libc stdstrbufs 00000008 D __IO_list_all libc stdfiles 000000c0 D __DUMMY__ libc emulate 00000008 D ___environ libc __environ 00000008 D _errno libc errno 00000004 D _optarg libc getopt 00000004 D _optind libc getopt 00000008 D _opterr libc getopt 00000008 D _re_syntax_options libc regex 00000008 D ____brk_addr libc __brk 00000004 D _ospeed libtermcap termcap 00000004 D _tputs_baud_rate libtermcap termcap 00000008 D _tzname libc bsdtime 00000004 D _timezone libc bsdtime 00000004 D _daylight libc bsdtime 00000004 D __DUMMY__ libc rpc_comdata 00000020 D _rpc_createerr libc rpc_comdata 0000000c D __null_auth libc rpc_comdata 00000008 D __collate_info libc C-collate 00000008 D __ctype_info libc C-ctype 00000008 D __monetary_info libc C-monetary 00000008 D __numeric_info libc C-numeric 00000008 D __response_info libc C-response 00000290 D __time_info libc C-time 00001120 D ___exit_funcs libc atexit 00000004 D _stdin libc stdio 00000004 D _stdout libc stdio 00000008 D _stderr libc stdio 000001c0 D __DUMMY__ libc free 00000008 D __DUMMY__ libc malloc 000003f8 D __DUMMY__ libc mbtowc 00000008 D _re_max_failures libc regex 00000040 D __res_opcodes libc res_debug 00000a30 D __res_resultcodes libc res_debug 00000768 D ___ttyname libc ttyname 000000fc D __win libcurses refresh 00000004 D __gdbm_file libdbm global 00000008 D __gdbm_memory libdbm global 00000004 D __gdbm_fetch_val libdbm global 00000004 D _gdbm_version libdbm version 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000004 D _h_nerr libc herrlist 000000a0 D __IO_file_jumps libc fileops 000000a0 D __IO_proc_jumps libc iopopen 000000a0 D __IO_str_jumps libc strops 000000d8 D __DUMMY__ libc streambuf 000000b0 D __DUMMY__ libc streambuf 000000b0 D __DUMMY__ libc streambuf 00000000 D __DUMMY__ libc strstream 00000000 D __DUMMY__ libc strstream 00000000 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc strstream 000000b0 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000004 D _optopt libc getopt 00000040 D _svc_fdset libc rpc_comdata 00000004 D __obstack libc obstack 00000004 C ___glob_closedir_hook libc glob 00000004 C ___glob_opendir_hook libc glob 00000004 C ___glob_readdir_hook libc glob 00000004 D __sigintr libc sigint 00000004 D _MCAppPath libc msgcat ./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/libc/jump.vars.iostream100644 1676 334 24362 5466061636 16535 0ustar hjlisl00000098 K _h_errlist libc herror 0000023c K __sys_errlist libc _errlist 00000004 K __sys_nerr libc _errlist 000000c4 K __sys_siglist libc _siglist 00000004 D ___new_handler libgcc _new_handler 00000004 D ___ctype_b libc ctype-info 00000004 D ___ctype_tolower libc ctype-info 00000008 D ___ctype_toupper libc ctype-info 00000001 D __echoit libcurses curses 00000001 D __rawmode libcurses curses 00000001 D _My_term libcurses curses 00000001 D __endwin libcurses curses 00000034 D _ttytype libcurses curses 00000004 D _Def_term libcurses curses 00000004 D __tty_ch libcurses curses 00000004 D _LINES libcurses curses 00000004 D _COLS libcurses curses 00000004 D __res_iflg libcurses curses 00000004 D __res_lflg libcurses curses 00000004 D _stdscr libcurses curses 00000004 D _curscr libcurses curses 00000024 D __tty libcurses curses 00000001 D _AM libcurses curses 00000001 D _BS libcurses curses 00000001 D _CA libcurses curses 00000001 D _DA libcurses curses 00000001 D _DB libcurses curses 00000001 D _EO libcurses curses 00000001 D _HC libcurses curses 00000001 D _HZ libcurses curses 00000001 D _IN libcurses curses 00000001 D _MI libcurses curses 00000001 D _MS libcurses curses 00000001 D _NC libcurses curses 00000001 D _NS libcurses curses 00000001 D _OS libcurses curses 00000001 D _UL libcurses curses 00000001 D _XB libcurses curses 00000001 D _XN libcurses curses 00000001 D _XT libcurses curses 00000001 D _XS libcurses curses 00000001 D _XX libcurses curses 00000004 D _AL libcurses curses 00000004 C _BC libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D _BT libcurses curses 00000004 D _CD libcurses curses 00000004 D _CE libcurses curses 00000004 D _CL libcurses curses 00000004 D _CM libcurses curses 00000004 D _CR libcurses curses 00000004 D _CS libcurses curses 00000004 D _DC libcurses curses 00000004 D _DL libcurses curses 00000004 D _DM libcurses curses 00000004 D _DO libcurses curses 00000004 D _ED libcurses curses 00000004 D _EI libcurses curses 00000004 D _K0 libcurses curses 00000004 D _K1 libcurses curses 00000004 D _K2 libcurses curses 00000004 D _K3 libcurses curses 00000004 D _K4 libcurses curses 00000004 D _K5 libcurses curses 00000004 D _K6 libcurses curses 00000004 D _K7 libcurses curses 00000004 D _K8 libcurses curses 00000004 D _K9 libcurses curses 00000004 D _HO libcurses curses 00000004 D _IC libcurses curses 00000004 D _IM libcurses curses 00000004 D _IP libcurses curses 00000004 D _KD libcurses curses 00000004 D _KE libcurses curses 00000004 D _KH libcurses curses 00000004 D _KL libcurses curses 00000004 D _KR libcurses curses 00000004 D _KS libcurses curses 00000004 D _KU libcurses curses 00000004 D _LL libcurses curses 00000004 D _MA libcurses curses 00000004 D _ND libcurses curses 00000004 D _NL libcurses curses 00000004 D _RC libcurses curses 00000004 D _SC libcurses curses 00000004 D _SE libcurses curses 00000004 D _SF libcurses curses 00000004 D _SO libcurses curses 00000004 D _SR libcurses curses 00000004 D _TA libcurses curses 00000004 D _TE libcurses curses 00000004 D _TI libcurses curses 00000004 D _UC libcurses curses 00000004 D _UE libcurses curses 00000004 C _UP libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D _US libcurses curses 00000004 D _VB libcurses curses 00000004 D _VS libcurses curses 00000004 D _VE libcurses curses 00000004 D _AL_PARM libcurses curses 00000004 D _DL_PARM libcurses curses 00000004 D _UP_PARM libcurses curses 00000004 D _DOWN_PARM libcurses curses 00000004 D _LEFT_PARM libcurses curses 00000004 D _RIGHT_PARM libcurses curses 00000001 C _PC libtermcap,libcurses termcap 00000000 D __DUMMY__ libtermcap curses 00000001 D _GT libcurses curses 00000001 D _NONL libcurses curses 00000001 D _UPPERCASE libcurses curses 00000001 D _normtty libcurses curses 00000003 D __pfast libcurses curses 00000200 D __unctrl libcurses unctrl 00000008 C _gdbm_errno libdbm global 00000000 C __DUMMY__ libdbm global 00000008 D _h_errno libc herror 00000180 D __res libc res_init 00000008 D _rexecoptions libc rexec 0000014c D ___std_filebuf_0 libc stdstrbufs 0000014c D ___std_filebuf_1 libc stdstrbufs 0000014c D ___std_filebuf_2 libc stdstrbufs 0000014c D __DUMMY__ libc stdstrbufs 00000008 D __9streambuf$_list_all libc stdstrbufs 000000c0 D __iob libc emulate 00000008 D ___environ libc __environ 00000008 D _errno libc errno 00000004 D _optarg libc getopt 00000004 D _optind libc getopt 00000008 D _opterr libc getopt 00000008 D _re_syntax_options libc regex 00000008 D ____brk_addr libc __brk 00000004 D _ospeed libtermcap termcap 00000004 D _tputs_baud_rate libtermcap termcap 00000008 D _tzname libc bsdtime 00000004 D _timezone libc bsdtime 00000004 D _daylight libc bsdtime 00000004 D __DUMMY__ libc rpc_comdata 00000020 D _rpc_createerr libc rpc_comdata 0000000c D __null_auth libc rpc_comdata 00000008 D __collate_info libc C-collate 00000008 D __ctype_info libc C-ctype 00000008 D __monetary_info libc C-monetary 00000008 D __numeric_info libc C-numeric 00000008 D __response_info libc C-response 00000290 D __time_info libc C-time 00001120 D ___exit_funcs libc atexit 00000004 D _stdin libc fprintf 00000004 D _stdout libc fprintf 00000008 D _stderr libc fprintf 000001c0 D __DUMMY__ libc free 00000008 D __DUMMY__ libc malloc 000003f8 D __DUMMY__ libc mbtowc 00000008 D _re_max_failures libc regex 00000040 D __res_opcodes libc res_debug 00000a30 D __res_resultcodes libc res_debug 00000768 D ___ttyname libc ttyname 000000fc D __win libcurses refresh 00000004 D __gdbm_file libdbm global 00000008 D __gdbm_memory libdbm global 00000004 D __gdbm_fetch_val libdbm global 00000004 D _gdbm_version libdbm version 00000080 D _cout libc stdstreams 00000080 D _cerr libc stdstreams 00000080 D _cin libc stdstreams 00000080 D _clog libc stdstreams 00000004 D _h_nerr libc herrlist 00000050 D __vt$8iostream$3ios libc iostream 00000050 D __vt$istream$3ios libc iostream 00000050 D __vt$7ostream$3ios libc iostream 000000d8 D __vt$7filebuf libc streambuf 000000b0 D __vt$9backupbuf libc streambuf 000000b0 D __vt$9streambuf libc streambuf 00000050 D __vt$3ios libc streambuf 00000050 D __vt$9strstream$3ios libc strstream 00000050 D __vt$10ostrstream$3ios libc strstream 00000050 D __vt$10istrstream$3ios libc strstream 00000050 D __vt$13strstreambase$3ios libc strstream 000000b0 D __vt$12strstreambuf libc strstream 00000050 D __vt$7fstream$3ios libc fstream 00000050 D __vt$8ofstream$3ios libc fstream 00000050 D __vt$8ifstream$3ios libc fstream 00000050 D __vt$11fstreambase$3ios libc fstream 00000004 D _optopt libc getopt 00000040 D _svc_fdset libc rpc_comdata 00000004 D __obstack libc obstack 00000004 C ___glob_closedir_hook libc glob 00000004 C ___glob_opendir_hook libc glob 00000004 C ___glob_readdir_hook libc glob 00000004 D __sigintr libc sigint 00000004 D _MCAppPath libc msgcat ./libc-linux/jump/libc/jump.funcs.iostream100644 1676 334 164756 5470605746 16735 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 T ___fillbf libc emulate 00000000 T ___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 streambuf 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 streambuf 00000000 T __cleanup libc stdio 00000000 T __exit libc libc_exit 00000000 T __filbuf libc emulate 00000000 T __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 _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 _fclose libc fclose 00000000 T ___fcntl libc __fcntl 00000000 T _fcvt libc cvt 00000000 T _fdopen libc fdopen 00000000 T _feof libc feof 00000000 T _ferror libc ferror 00000000 T _fetch libdbm fetch 00000000 T _fflush libc fflush 00000000 T _ffs libc ffs 00000000 T _fgetc libc fgetc 00000000 T _fgetgrent libc fgetgrent 00000000 T _fgetpos libc fgetpos 00000000 T _fgetpwent libc fgetpwent 00000000 T _fgets libc fgets 00000000 T _fileno libc fileno 00000000 T _firstkey libdbm seq 00000000 T _fnmatch libc fnmatch 00000000 T _fopen libc fopen 00000000 T ___fork libc __fork 00000000 T ___fpathconf libc __fpathconf 00000000 T _fprintf libc fprintf 00000000 T _fputc libc fputc 00000000 T _fputs libc fputs 00000000 T _fread libc fread 00000000 T _free libc free 00000000 T _freopen libc freopen 00000000 T _fscanf libc fscanf 00000000 T _fseek libc fseek 00000000 T _fsetpos libc fsetpos 00000000 T ___fstat libc __fstat 00000000 T ___fstatfs libc __fstatfs 00000000 T _ftell libc ftell 00000000 T _ftime libc ftime 00000000 T _ftruncate libc ftruncate 00000000 T _ftw libc ftw 00000000 T _fwrite libc fwrite 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 macros 00000000 T _getcap libcurses cr_tty 00000000 T _getchar libc macros 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 _gets libc gets 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 _perror libc perror 00000000 T ___pipe libc __pipe 00000000 T _popen libc popen 00000000 T _printf libc printf 00000000 T _printw libcurses printw 00000000 T _psignal libc psignal 00000000 T _ptrace libc ptrace 00000000 T _putc libc macros 00000000 T _putchar libc macros 00000000 T _putenv libc putenv 00000000 T _putlong libc res_comp 00000000 T _putpwent libc putpwent 00000000 T _puts libc puts 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 revcfrom 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 _scanf libc scanf 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 _setbuffer libc setbuffer 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 _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 _setvbuf libc setvbuf 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 _sprintf libc sprintf 00000000 t ___srandom libcompat 00000000 T _srand48 libc drand48 00000000 t ___srandom libcompat 00000000 T _sscanf libc sscanf 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 _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 _ungetc libc ungetc 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 _vfprintf libc vfprintf 00000000 T _vfscanf libc vfscanf 00000000 T _vhangup libc vhangup 00000000 T _vprintf libc vprintf 00000000 T _vscanf libc vscanf 00000000 T _vsprintf libc vsprintf 00000000 T _vsscanf libc vsscanf 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 T ___muldi3 libgcc _muldi3 00000000 T ___udivdi3 libgcc _udivdi3 00000000 T ___udivmoddi4 libgcc _udivmoddi4 00000000 T ___umoddi3 libgcc _umoddi3 00000000 T ___stdio_gen_tempname libc tempname 00000000 T ___7filebuf libc filebuf 00000000 T ___7filebufi libc filebuf 00000000 T ___7filebufiPci libc filebuf 00000000 T __$_7filebuf libc filebuf 00000000 T _open__7filebufPCcii libc filebuf 00000000 T _open__7filebufPCcT1 libc filebuf 00000000 T _attach__7filebufi libc filebuf 00000000 T _setbuf__7filebufPci libc filebuf 00000000 T _overflow__7filebufi libc filebuf 00000000 T _underflow__7filebuf libc filebuf 00000000 T _sync__7filebuf libc filebuf 00000000 T _seekoff__7filebuflQ23ios8seek_diri libc filebuf 00000000 T _close__7filebuf libc filebuf 00000000 T _xsputn__7filebufPCci libc filebuf 00000000 T _xsgetn__7filebufPci libc filebuf 00000000 T _doallocate__7filebuf libc makebuf 00000000 T _vform__9streambufPCcPv libc sbufvform 00000000 T _form__9streambufPCce libc sbufvform 00000000 T _vscan__9streambufPCcPvP3ios libc sbufvscan 00000000 T _scan__9streambufPCce libc sbufvscan 00000000 T _sgetline__9streambufPcUici libc sgetline 00000000 T _tie__C3ios libc streambuf 00000000 T _tie__3iosP7ostream libc streambuf 00000000 T _fill__C3ios libc streambuf 00000000 T _fill__3iosl libc streambuf 00000000 T _flags__C3ios libc streambuf 00000000 T _flags__3iosUl libc streambuf 00000000 T _precision__C3ios libc streambuf 00000000 T _precision__3iosi libc streambuf 00000000 T _setf__3iosUl libc streambuf 00000000 T _setf__3iosUlUl libc streambuf 00000000 T _unsetf__3iosUl libc streambuf 00000000 T _width__C3ios libc streambuf 00000000 T _width__3iosi libc streambuf 00000000 T __throw_failure__3ios libc streambuf 00000000 T _rdbuf__C3ios libc streambuf 00000000 T _clear__3iosi libc streambuf 00000000 T _set__3iosi libc streambuf 00000000 T _good__C3ios libc streambuf 00000000 T _eof__C3ios libc streambuf 00000000 T _fail__C3ios libc streambuf 00000000 T _bad__C3ios libc streambuf 00000000 T _rdstate__C3ios libc streambuf 00000000 T ___opPv__C3ios libc streambuf 00000000 T ___nt__C3ios libc streambuf 00000000 T _exceptions__3iosi libc streambuf 00000000 T _sync_with_stdio__3ios libc streambuf 00000000 T _unset__3ios11state_value libc streambuf 00000000 T _init__3iosP9streambuf libc streambuf 00000000 T _unbuffered__9streambuf libc streambuf 00000000 T _linebuffered__9streambuf libc streambuf 00000000 T _unbuffered__9streambufi libc streambuf 00000000 T _linebuffered__9streambufi libc streambuf 00000000 T _allocate__9streambuf libc streambuf 00000000 T _allocbuf__9streambuf libc streambuf 00000000 T _in_avail__9streambuf libc streambuf 00000000 T _out_waiting__9streambuf libc streambuf 00000000 T _sputn__9streambufPCci libc streambuf 00000000 T _sgetn__9streambufPci libc streambuf 00000000 T _sbumpc__9streambuf libc streambuf 00000000 T _sgetc__9streambuf libc streambuf 00000000 T _snextc__9streambuf libc streambuf 00000000 T _sputc__9streambufi libc streambuf 00000000 T _stossc__9streambuf libc streambuf 00000000 T _is_open__C7filebuf libc streambuf 00000000 T _fd__C7filebuf libc streambuf 00000000 T ___3iosP9streambufP7ostream libc streambuf 00000000 T __$_3ios libc streambuf 00000000 T _xsputn__9streambufPCci libc streambuf 00000000 T _padn__9streambufci libc streambuf 00000000 T _xsgetn__9streambufPci libc streambuf 00000000 T _ignore__9streambufi libc streambuf 00000000 T _sync__9streambuf libc streambuf 00000000 T _pbackfail__9streambufi libc streambuf 00000000 T _setbuf__9streambufPci libc streambuf 00000000 T _seekpos__9streambufli libc streambuf 00000000 T _setb__9streambufPcT1i libc streambuf 00000000 T _doallocate__9streambuf libc streambuf 00000000 T _doallocbuf__9streambuf libc streambuf 00000000 T ___9streambufi libc streambuf 00000000 T __$_9streambuf libc streambuf 00000000 T _seekoff__9streambuflQ23ios8seek_diri libc streambuf 00000000 T _sputbackc__9streambufc libc streambuf 00000000 T _sungetc__9streambuf libc streambuf 00000000 T _get_column__9streambuf libc streambuf 00000000 T _set_column__9streambufi libc streambuf 00000000 T _flush_all__9streambuf libc streambuf 00000000 T _flush_all_linebuffered__9streambuf libc streambuf 00000000 T _seekmark__9streambufR12streammarkeri libc streambuf 00000000 T _pbackfail__9backupbufi libc streambuf 00000000 T _readable__3ios libc streambuf 00000000 T _writable__3ios libc streambuf 00000000 T _is_open__3ios libc streambuf 00000000 U _init_const__12strstreambuf libc strstream 00000000 T ___12strstreambuf libc strstream 00000000 T ___12strstreambufi libc strstream 00000000 T ___12strstreambufPFUi_PvPFPv_v libc strstream 00000000 T ___12strstreambufPciT1 libc strstream 00000000 T ___12strstreambufPUciT1 libc strstream 00000000 T ___12strstreambufPCci libc strstream 00000000 T ___12strstreambufPCUci libc strstream 00000000 T ___12strstreambufPSciT1 libc strstream 00000000 T ___12strstreambufPCSci libc strstream 00000000 T _frozen__12strstreambuf libc strstream 00000000 T _freeze__12strstreambufi libc strstream 00000000 T _rdbuf__13strstreambase libc strstream 00000000 T ___13strstreambasei libc strstream 00000000 T __$_13strstreambase libc strstream 00000000 T __$_10istrstream libc strstream 00000000 T ___10ostrstreamiPcii libc strstream 00000000 T _pcount__10ostrstream libc strstream 00000000 T _str__10ostrstream libc strstream 00000000 T _freeze__10ostrstreami libc strstream 00000000 T _frozen__10ostrstream libc strstream 00000000 T __$_10ostrstream libc strstream 00000000 T ___9strstreami libc strstream 00000000 T ___9strstreamiPcii libc strstream 00000000 T _pcount__9strstream libc strstream 00000000 T _str__9strstream libc strstream 00000000 T _freeze__9strstreami libc strstream 00000000 T _frozen__9strstream libc strstream 00000000 T __$_9strstream libc strstream 00000000 T ___10istrstreamiPCci libc strstream 00000000 T ___10ostrstreami libc strstream 00000000 T ___13strstreambaseiPcii libc strstream 00000000 T _str__12strstreambuf libc strstream 00000000 T _pcount__12strstreambuf libc strstream 00000000 T _overflow__12strstreambufi libc strstream 00000000 T _underflow__12strstreambuf libc strstream 00000000 T _init_dynamic__12strstreambufPFUi_PvPFPv_vi libc strstream 00000000 T _init_static__12strstreambufPciT1 libc strstream 00000000 T __$_12strstreambuf libc strstream 00000000 T _seekoff__12strstreambuflQ23ios8seek_diri libc strstream 00000000 T _pbackfail__12strstreambufi libc strstream 00000000 T _rdbuf__C11fstreambase libc fstream 00000000 T _is_open__C11fstreambase libc fstream 00000000 T _setbuf__11fstreambasePci libc fstream 00000000 T _filedesc__11fstreambase libc fstream 00000000 T _raw__11fstreambase libc fstream 00000000 T __$_11fstreambase libc fstream 00000000 T ___8ifstreami libc fstream 00000000 T ___8ifstreamii libc fstream 00000000 T ___8ifstreamiPCcii libc fstream 00000000 T _open__8ifstreamPCcii libc fstream 00000000 T __$_8ifstream libc fstream 00000000 T ___8ofstreami libc fstream 00000000 T ___8ofstreamii libc fstream 00000000 T ___8ofstreamiPCcii libc fstream 00000000 T _open__8ofstreamPCcii libc fstream 00000000 T __$_8ofstream libc fstream 00000000 T ___7fstreami libc fstream 00000000 T ___7fstreamii libc fstream 00000000 T ___7fstreamiPCcii libc fstream 00000000 T _open__7fstreamPCcii libc fstream 00000000 T __$_7fstream libc fstream 00000000 T ___11fstreambasei libc fstream 00000000 T ___11fstreambaseii libc fstream 00000000 T ___11fstreambaseiPCcii libc fstream 00000000 T _open__11fstreambasePCcii libc fstream 00000000 T _close__11fstreambase libc fstream 00000000 T _getline__7istreamPcic libc igetline 00000000 T _get__7istreamPcic libc igetline 00000000 T _gets__7istreamPPcc libc igetline 00000000 T _get__7istreamR9streambufc libc igetsb 00000000 T ___iomanip_setbase__FR3iosi libc iomanip 00000000 T ___iomanip_setfill__FR3iosi libc iomanip 00000000 T ___iomanip_setprecision__FR3iosi libc iomanip 00000000 T ___iomanip_setw__FR3iosi libc iomanip 00000000 T ___iomanip_setiosflags__FR3iosUl libc iomanip 00000000 T ___iomanip_resetiosflags__FR3iosUl libc iomanip 00000000 T ___7ostreami libc iostream 00000000 T _opfx__7ostream libc iostream 00000000 T _osfx__7ostream libc iostream 00000000 T _ostreambuf__C7ostream libc iostream 00000000 T _put__7ostreamc libc iostream 00000000 T _put__7ostreamUc libc iostream 00000000 T _write__7ostreamPCUci libc iostream 00000000 T _put__7ostreamSc libc iostream 00000000 T _write__7ostreamPCSci libc iostream 00000000 T _write__7ostreamPCvi libc iostream 00000000 T ___ls__7ostreamUc libc iostream 00000000 T ___ls__7ostreamSc libc iostream 00000000 T ___ls__7ostreamPCUc libc iostream 00000000 T ___ls__7ostreamPCSc libc iostream 00000000 T ___ls__7ostreams libc iostream 00000000 T ___ls__7ostreamUs libc iostream 00000000 T ___ls__7ostreamf libc iostream 00000000 T ___ls__7ostreamPFR7ostream_R7ostream libc iostream 00000000 T ___ls__7ostreamPFR3ios_R3ios libc iostream 00000000 T __$_7ostream libc iostream 00000000 T ___7istreami libc iostream 00000000 T _istreambuf__C7istream libc iostream 00000000 T _get__7istreamPUcic libc iostream 00000000 T _get__7istreamRUc libc iostream 00000000 T _getline__7istreamPUcic libc iostream 00000000 T _get__7istreamRSc libc iostream 00000000 T _get__7istreamPScic libc iostream 00000000 T _getline__7istreamPScic libc iostream 00000000 T _read__7istreamPUci libc iostream 00000000 T _read__7istreamPSci libc iostream 00000000 T _read__7istreamPvi libc iostream 00000000 T _ipfx__7istreami libc iostream 00000000 T _ipfx0__7istream libc iostream 00000000 T _ipfx1__7istream libc iostream 00000000 T _get__7istream libc iostream 00000000 T _peek__7istream libc iostream 00000000 T _gcount__7istream libc iostream 00000000 T _putback__7istreamc libc iostream 00000000 T _unget__7istream libc iostream 00000000 T _unget__7istreamc libc iostream 00000000 T ___rs__7istreamPUc libc iostream 00000000 T ___rs__7istreamPSc libc iostream 00000000 T ___rs__7istreamRUc libc iostream 00000000 T ___rs__7istreamRSc libc iostream 00000000 T ___rs__7istreamPFR3ios_R3ios libc iostream 00000000 T ___rs__7istreamPFR7istream_R7istream libc iostream 00000000 T __$_7istream libc iostream 00000000 T ___8iostreami libc iostream 00000000 T __$_8iostream libc iostream 00000000 T _dec__FR3ios libc iostream 00000000 T _hex__FR3ios libc iostream 00000000 T _oct__FR3ios libc iostream 00000000 T ___7istreamiP9streambufP7ostream libc iostream 00000000 T _skip_ws__FP9streambuf libc iostream 00000000 T _get__7istreamRc libc iostream 00000000 T _ignore__7istreamii libc iostream 00000000 T _read__7istreamPci libc iostream 00000000 T _seekg__7istreaml libc iostream 00000000 T _seekg__7istreamlQ23ios8seek_dir libc iostream 00000000 T _tellg__7istream libc iostream 00000000 T _scan__7istreamPCce libc iostream 00000000 T _vscan__7istreamPCcPv libc iostream 00000000 T ___rs__7istreamRc libc iostream 00000000 T ___rs__7istreamPc libc iostream 00000000 T ___rs__7istreamRs libc iostream 00000000 T ___rs__7istreamRUs libc iostream 00000000 T ___rs__7istreamRi libc iostream 00000000 T ___rs__7istreamRUi libc iostream 00000000 T ___rs__7istreamRl libc iostream 00000000 T ___rs__7istreamRUl libc iostream 00000000 T ___rs__7istreamRx libc iostream 00000000 T ___rs__7istreamRUx libc iostream 00000000 T ___rs__7istreamRd libc iostream 00000000 T ___rs__7istreamRf libc iostream 00000000 T ___rs__7istreamP9streambuf libc iostream 00000000 T ___ls__7ostreamc libc iostream 00000000 T ___ls__7ostreami libc iostream 00000000 T ___ls__7ostreamUi libc iostream 00000000 T ___ls__7ostreaml libc iostream 00000000 T ___ls__7ostreamUl libc iostream 00000000 T ___ls__7ostreamx libc iostream 00000000 T ___ls__7ostreamUx libc iostream 00000000 T ___ls__7ostreamd libc iostream 00000000 T ___ls__7ostreamPCc libc iostream 00000000 T ___ls__7ostreamPCv libc iostream 00000000 T ___ls__7ostreamP9streambuf libc iostream 00000000 T ___7ostreamiP9streambufPT0 libc iostream 00000000 T _seekp__7ostreaml libc iostream 00000000 T _seekp__7ostreamlQ23ios8seek_dir libc iostream 00000000 T _tellp__7ostream libc iostream 00000000 T _form__7ostreamPCce libc iostream 00000000 T _vform__7ostreamPCcPv libc iostream 00000000 T _flush__7ostream libc iostream 00000000 T _flush__FR7ostream libc iostream 00000000 T _ws__FR7istream libc iostream 00000000 T __skip_ws__7istream libc iostream 00000000 T _ends__FR7ostream libc iostream 00000000 T _endl__FR7ostream libc iostream 00000000 T _write__7ostreamPCci libc iostream 00000000 T _do_osfx__7ostream libc iostream 00000000 T ___8iostreamiP9streambufP7ostream libc iostream 00000000 T _close__3ios libc iostream 00000000 T _skip__7istreami libc iostream 00000000 T _stdiofile__C8stdiobuf libc stdiostream 00000000 T __$_8stdiobuf libc stdiostream 00000000 T ___8stdiobufP6__FILE libc stdiostream 00000000 T _sys_read__8stdiobufPcUi libc stdiostream 00000000 T _sys_write__8stdiobufPCvl libc stdiostream 00000000 T _sys_seek__8stdiobuflQ23ios8seek_dir libc stdiostream 00000000 T _sys_close__8stdiobuf libc stdiostream 00000000 T _sync__8stdiobuf libc stdiostream 00000000 T _overflow__8stdiobufi libc stdiostream 00000000 T _xsputn__8stdiobufPCci libc stdiostream 00000000 T _sync_with_stdio__3iosi libc stdstreams 00000000 T _form__FPCce libc stream 00000000 T _dec__Fli libc stream 00000000 T _dec__Fii libc stream 00000000 T _dec__FUli libc stream 00000000 T _dec__FUii libc stream 00000000 T _hex__Fli libc stream 00000000 T _hex__Fii libc stream 00000000 T _hex__FUli libc stream 00000000 T _hex__FUii libc stream 00000000 T _oct__Fli libc stream 00000000 T _oct__Fii libc stream 00000000 T _oct__FUli libc stream 00000000 T _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/jump.funcs.rx100644 1676 334 164236 5517624450 15527 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 rx 00000000 t ___old_re_compile_fastmap libcompat regex 00000000 t ___old_re_compile_pattern libcompat regex 00000000 T _re_exec libc rx 00000000 t ___old_re_match libcompat regex 00000000 t ___old_re_match_2 libcompat regex 00000000 t ___old_re_search libcompat regex 00000000 t ___old_re_search_2 libcompat regex 00000000 T _re_set_syntax libc rx 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 revcfrom 00000000 t ___old_regcomp libcompat regex 00000000 t ___old_regerror libcompat regex 00000000 t ___old_regexec libcompat regex 00000000 t ___old_regfree libcompat 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 ___old_re_set_registers libcompat 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 T _rx_compile libc rx 00000000 T _re_compile_fastmap libc rx 00000000 T _re_compile_pattern libc rx 00000000 T _re_match libc rx 00000000 T _re_match_2 libc rx 00000000 T _re_search libc rx 00000000 T _re_search_2 libc rx 00000000 T _re_set_registers libc rx 00000000 T _regcomp libc rx 00000000 T _regerror libc rx 00000000 T _regexec libc rx 00000000 T _regfree libc rx 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/jump.vars.rx100644 1676 334 24312 5517546014 15331 0ustar hjlisl00000098 K _h_errlist libc herror 0000023c K __sys_errlist libc _errlist 00000004 K __sys_nerr libc _errlist 000000c4 K __sys_siglist libc _siglist 00000004 D __DUMMY__ libgcc _new_handler 00000004 D ___ctype_b libc ctype-info 00000004 D ___ctype_tolower libc ctype-info 00000008 D ___ctype_toupper libc ctype-info 00000001 D __echoit libcurses curses 00000001 D __rawmode libcurses curses 00000001 D _My_term libcurses curses 00000001 D __endwin libcurses curses 00000034 D _ttytype libcurses curses 00000004 D _Def_term libcurses curses 00000004 D __tty_ch libcurses curses 00000004 D _LINES libcurses curses 00000004 D _COLS libcurses curses 00000004 D __res_iflg libcurses curses 00000004 D __res_lflg libcurses curses 00000004 D _stdscr libcurses curses 00000004 D _curscr libcurses curses 00000024 D __tty libcurses curses 00000001 D _AM libcurses curses 00000001 D _BS libcurses curses 00000001 D _CA libcurses curses 00000001 D _DA libcurses curses 00000001 D _DB libcurses curses 00000001 D _EO libcurses curses 00000001 D _HC libcurses curses 00000001 D _HZ libcurses curses 00000001 D _IN libcurses curses 00000001 D _MI libcurses curses 00000001 D _MS libcurses curses 00000001 D _NC libcurses curses 00000001 D _NS libcurses curses 00000001 D _OS libcurses curses 00000001 D _UL libcurses curses 00000001 D _XB libcurses curses 00000001 D _XN libcurses curses 00000001 D _XT libcurses curses 00000001 D _XS libcurses curses 00000001 D _XX libcurses curses 00000004 D _AL libcurses curses 00000004 C _BC libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D _BT libcurses curses 00000004 D _CD libcurses curses 00000004 D _CE libcurses curses 00000004 D _CL libcurses curses 00000004 D _CM libcurses curses 00000004 D _CR libcurses curses 00000004 D _CS libcurses curses 00000004 D _DC libcurses curses 00000004 D _DL libcurses curses 00000004 D _DM libcurses curses 00000004 D _DO libcurses curses 00000004 D _ED libcurses curses 00000004 D _EI libcurses curses 00000004 D _K0 libcurses curses 00000004 D _K1 libcurses curses 00000004 D _K2 libcurses curses 00000004 D _K3 libcurses curses 00000004 D _K4 libcurses curses 00000004 D _K5 libcurses curses 00000004 D _K6 libcurses curses 00000004 D _K7 libcurses curses 00000004 D _K8 libcurses curses 00000004 D _K9 libcurses curses 00000004 D _HO libcurses curses 00000004 D _IC libcurses curses 00000004 D _IM libcurses curses 00000004 D _IP libcurses curses 00000004 D _KD libcurses curses 00000004 D _KE libcurses curses 00000004 D _KH libcurses curses 00000004 D _KL libcurses curses 00000004 D _KR libcurses curses 00000004 D _KS libcurses curses 00000004 D _KU libcurses curses 00000004 D _LL libcurses curses 00000004 D _MA libcurses curses 00000004 D _ND libcurses curses 00000004 D _NL libcurses curses 00000004 D _RC libcurses curses 00000004 D _SC libcurses curses 00000004 D _SE libcurses curses 00000004 D _SF libcurses curses 00000004 D _SO libcurses curses 00000004 D _SR libcurses curses 00000004 D _TA libcurses curses 00000004 D _TE libcurses curses 00000004 D _TI libcurses curses 00000004 D _UC libcurses curses 00000004 D _UE libcurses curses 00000004 C _UP libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D _US libcurses curses 00000004 D _VB libcurses curses 00000004 D _VS libcurses curses 00000004 D _VE libcurses curses 00000004 D _AL_PARM libcurses curses 00000004 D _DL_PARM libcurses curses 00000004 D _UP_PARM libcurses curses 00000004 D _DOWN_PARM libcurses curses 00000004 D _LEFT_PARM libcurses curses 00000004 D _RIGHT_PARM libcurses curses 00000001 C _PC libtermcap,libcurses termcap 00000000 D __DUMMY__ libtermcap curses 00000001 D _GT libcurses curses 00000001 D _NONL libcurses curses 00000001 D _UPPERCASE libcurses curses 00000001 D _normtty libcurses curses 00000003 D __pfast libcurses curses 00000200 D __unctrl libcurses unctrl 00000008 C _gdbm_errno libdbm global 00000000 C __DUMMY__ libdbm global 00000008 D _h_errno libc herror 00000180 D __res libc res_init 00000008 D _rexecoptions libc rexec 0000014c D __IO_stdin_ libc stdfiles 0000014c D __IO_stdout_ libc stdfiles 0000014c D __IO_stderr_ libc stdfiles 0000014c D __DUMMY__ libc stdstrbufs 00000008 D __IO_list_all libc stdfiles 000000c0 D __DUMMY__ libc emulate 00000008 D ___environ libc __environ 00000008 D _errno libc errno 00000004 D _optarg libc getopt 00000004 D _optind libc getopt 00000008 D _opterr libc getopt 00000008 D _re_syntax_options libc rx 00000008 D ____brk_addr libc __brk 00000004 D _ospeed libtermcap termcap 00000004 D _tputs_baud_rate libtermcap termcap 00000008 D _tzname libc bsdtime 00000004 D _timezone libc bsdtime 00000004 D _daylight libc bsdtime 00000004 D __DUMMY__ libc rpc_comdata 00000020 D _rpc_createerr libc rpc_comdata 0000000c D __null_auth libc rpc_comdata 00000008 D __collate_info libc C-collate 00000008 D __ctype_info libc C-ctype 00000008 D __monetary_info libc C-monetary 00000008 D __numeric_info libc C-numeric 00000008 D __response_info libc C-response 00000290 D __time_info libc C-time 00001120 D ___exit_funcs libc atexit 00000004 D _stdin libc stdio 00000004 D _stdout libc stdio 00000008 D _stderr libc stdio 000001c0 D __DUMMY__ libc free 00000008 D __DUMMY__ libc malloc 000003f8 D __DUMMY__ libc mbtowc 00000008 D __DUMMY__ libc regex 00000040 D __res_opcodes libc res_debug 00000a30 D __res_resultcodes libc res_debug 00000768 D ___ttyname libc ttyname 000000fc D __win libcurses refresh 00000004 D __gdbm_file libdbm global 00000008 D __gdbm_memory libdbm global 00000004 D __gdbm_fetch_val libdbm global 00000004 D _gdbm_version libdbm version 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000004 D _h_nerr libc herrlist 000000a0 D __IO_file_jumps libc fileops 000000a0 D __IO_proc_jumps libc iopopen 000000a0 D __IO_str_jumps libc strops 000000d8 D __DUMMY__ libc streambuf 000000b0 D __DUMMY__ libc streambuf 000000b0 D __DUMMY__ libc streambuf 00000000 D __DUMMY__ libc strstream 00000000 D __DUMMY__ libc strstream 00000000 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc strstream 000000b0 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000004 D _optopt libc getopt 00000040 D _svc_fdset libc rpc_comdata 00000004 D __obstack libc obstack 00000004 C ___glob_closedir_hook libc glob 00000004 C ___glob_opendir_hook libc glob 00000004 C ___glob_readdir_hook libc glob 00000004 D __sigintr libc sigint 00000004 D _MCAppPath libc msgcat ./libc-linux/jump/libc.lite/ 40755 1676 334 0 5550061526 13643 5ustar hjlisl./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/jump.ignore100644 1676 334 45371 5426074304 16152 0ustar hjlisl00000000 T _fgoto libc cr_put 00000000 T _plodput libc cr_put 00000000 T _plod libc cr_put 00000000 T _tabcol libc cr_put 00000000 T _zap libc cr_tty 00000000 C __tspace libc cr_tty 00000000 T _fullname libc fullname 00000000 T __id_subwins libc id_subwins 00000000 T __set_subwin_ libc newwin 00000000 T __swflags_ libc newwin 00000000 T __sprintw libc printw 00000000 T __putchar libc putchar 00000000 T __sscans libc scanw 00000000 T _touchoverlap libc toucholap 00000000 T _tstp libc tstp 00000000 T __gdbm_new_bucket libc bucket 00000000 T __gdbm_get_bucket libc bucket 00000000 T __gdbm_split_bucket libc bucket 00000000 T __gdbm_write_bucket libc bucket 00000000 T __gdbm_alloc libc falloc 00000000 T __gdbm_free libc falloc 00000000 T __gdbm_put_av_elem libc falloc 00000000 T __gdbm_read_entry libc findkey 00000000 T __gdbm_findkey libc findkey 00000000 T __gdbm_hash libc hash 00000000 T __gdbm_end_update libc update 00000000 T __gdbm_fatal libc update 00000000 T __sethtent libc gethstnmad 00000000 T __endhtent libc gethstnmad 00000000 T __gethtent libc gethstnmad 00000000 T __gethtbyname libc gethstnmad 00000000 T __gethtbyaddr libc gethstnmad 00000000 C __net_stayopen libc getnetent 00000000 C __proto_stayopen libc getprtent 00000000 C __serv_stayopen libc getservent 00000000 T __checkhost libc rcmd 00000000 T _p_query libc res_debug 00000000 T _p_cdname libc res_debug 00000000 T _p_rr libc res_debug 00000000 T __res_close libc res_send 00000000 T _sethostfile libc sethostent 00000000 T ___8PlotFilei libc PlotFile 00000000 T ___8PlotFileii libc PlotFile 00000000 T ___8PlotFileiPCcii libc PlotFile 00000000 T __$_8PlotFile libc PlotFile 00000000 T _cmd__8PlotFilec libc PlotFile 00000000 T ___ls__8PlotFilei libc PlotFile 00000000 T ___ls__8PlotFilePCc libc PlotFile 00000000 T _arc__8PlotFileiiiiii libc PlotFile 00000000 T _box__8PlotFileiiii libc PlotFile 00000000 T _circle__8PlotFileiii libc PlotFile 00000000 T _cont__8PlotFileii libc PlotFile 00000000 T _dot__8PlotFileiiiiPCi libc PlotFile 00000000 T _erase__8PlotFile libc PlotFile 00000000 T _label__8PlotFilePCc libc PlotFile 00000000 T _line__8PlotFileiiii libc PlotFile 00000000 T _linemod__8PlotFilePCc libc PlotFile 00000000 T _move__8PlotFileii libc PlotFile 00000000 T _point__8PlotFileii libc PlotFile 00000000 T _space__8PlotFileiiii libc PlotFile 00000000 T ___5SFilei libc SFile 00000000 T _size__5SFile libc SFile 00000000 T _setsize__5SFilei libc SFile 00000000 T __$_5SFile libc SFile 00000000 T ___5SFileiPCciii libc SFile 00000000 T ___5SFileiii libc SFile 00000000 T _open__5SFilePCciii libc SFile 00000000 T _get__5SFilePv libc SFile 00000000 T _put__5SFilePv libc SFile 00000000 T ___vc__5SFilel libc SFile 00000000 T ___11edit_stringP11edit_bufferP9edit_markT2 libc editbuf 00000000 T _inserting__14edit_streambuf libc editbuf 00000000 T _inserting__14edit_streambufi libc editbuf 00000000 T _is_reading__14edit_streambuf libc editbuf 00000000 T _current__14edit_streambuf libc editbuf 00000000 T _insert_before__9edit_mark libc editbuf 00000000 T _index_in_buffer__9edit_markP11edit_buffer libc editbuf 00000000 T ___9edit_mark libc editbuf 00000000 T _gap_start__11edit_buffer libc editbuf 00000000 T _gap_end_pos__11edit_buffer libc editbuf 00000000 T _start_marker__11edit_buffer libc editbuf 00000000 T _end_marker__11edit_buffer libc editbuf 00000000 T _gap_end__11edit_buffer libc editbuf 00000000 T _gap_size__11edit_buffer libc editbuf 00000000 T _size1__11edit_buffer libc editbuf 00000000 T _size2__11edit_buffer libc editbuf 00000000 T _mark_list__11edit_buffer libc editbuf 00000000 T _move_gap__11edit_bufferPc libc editbuf 00000000 T __$_11edit_buffer libc editbuf 00000000 T _ptr__9edit_markP11edit_buffer libc editbuf 00000000 T _flush_to_buffer__14edit_streambuf libc editbuf 00000000 T _truncate__14edit_streambuf libc editbuf 00000000 T _flush_to_buffer__14edit_streambufP11edit_buffer libc editbuf 00000000 T _disconnect_gap_from_file__14edit_streambufP11edit_buffer libc editbuf 00000000 T _tell__11edit_bufferPc libc editbuf 00000000 T _tell__11edit_bufferP9edit_mark libc editbuf 00000000 T _move_gap__11edit_bufferl libc editbuf 00000000 T _gap_left__11edit_bufferi libc editbuf 00000000 T _gap_right__11edit_bufferi libc editbuf 00000000 T _make_gap__11edit_bufferl libc editbuf 00000000 T _adjust_markers__11edit_bufferUlUliPc libc editbuf 00000000 T _underflow__14edit_streambuf libc editbuf 00000000 T _overflow__14edit_streambufi libc editbuf 00000000 T _set_current__14edit_streambufPci libc editbuf 00000000 T _seekoff__14edit_streambuflQ23ios8seek_diri libc editbuf 00000000 T _delete_range__11edit_bufferll libc editbuf 00000000 T _delete_range__11edit_bufferP9edit_markT1 libc editbuf 00000000 T _buf_delete_chars__FP11edit_bufferP9edit_markUi libc editbuf 00000000 T ___14edit_streambufP11edit_stringi libc editbuf 00000000 T __$_14edit_streambuf libc editbuf 00000000 T ___11edit_buffer libc editbuf 00000000 T ___9edit_markP11edit_stringl libc editbuf 00000000 T _buffer__9edit_mark libc editbuf 00000000 T __$_9edit_mark libc editbuf 00000000 T _length__C11edit_string libc editbuf 00000000 T _copy_bytes__C11edit_stringPi libc editbuf 00000000 T _assign__11edit_stringPT0 libc editbuf 00000000 T __sb_readline__FP9streambufRlc libc igetline 00000000 T _get_stream__11indirectbuf libc indstream 00000000 T _put_stream__11indirectbuf libc indstream 00000000 T _lookup_stream__11indirectbufi libc indstream 00000000 T ___11indirectbufP9streambufT1i libc indstream 00000000 T __$_11indirectbuf libc indstream 00000000 T _xsputn__11indirectbufPCci libc indstream 00000000 T _xsgetn__11indirectbufPci libc indstream 00000000 T _overflow__11indirectbufi libc indstream 00000000 T _underflow__11indirectbuf libc indstream 00000000 T _seekoff__11indirectbuflQ23ios8seek_diri libc indstream 00000000 T _seekpos__11indirectbufli libc indstream 00000000 T _sync__11indirectbuf libc indstream 00000000 T _pbackfail__11indirectbufi libc indstream 00000000 T _line_number__8parsebuf libc parsestream 00000000 T _line_length__8parsebuf libc parsestream 00000000 T ___8parsebuf libc parsestream 00000000 T __$_8parsebuf libc parsestream 00000000 T _left__C15string_parsebuf libc parsestream 00000000 T _right__C15string_parsebuf libc parsestream 00000000 T __$_15string_parsebuf libc parsestream 00000000 T __$_13func_parsebuf libc parsestream 00000000 T _setbuf__8parsebufPci libc parsestream 00000000 T _tell_in_line__8parsebuf libc parsestream 00000000 T _pbackfail__8parsebufi libc parsestream 00000000 T _current_line__8parsebuf libc parsestream 00000000 T _seekoff__8parsebuflQ23ios8seek_diri libc parsestream 00000000 T ___15string_parsebufPcii libc parsestream 00000000 T _underflow__15string_parsebuf libc parsestream 00000000 T _current_line__15string_parsebuf libc parsestream 00000000 T _tell_in_line__15string_parsebuf libc parsestream 00000000 T _seek_in_line__15string_parsebufi libc parsestream 00000000 T ___16general_parsebufP9streambufi libc parsestream 00000000 T __$_16general_parsebuf libc parsestream 00000000 T _underflow__16general_parsebuf libc parsestream 00000000 T _current_line__16general_parsebuf libc parsestream 00000000 T _tell_in_line__16general_parsebuf libc parsestream 00000000 T _seek_in_line__16general_parsebufi libc parsestream 00000000 T ___13func_parsebufPFPv_PcPv libc parsestream 00000000 T _tell_in_line__13func_parsebuf libc parsestream 00000000 T _current_line__13func_parsebuf libc parsestream 00000000 T _seek_in_line__13func_parsebufi libc parsestream 00000000 T _underflow__13func_parsebuf libc parsestream 00000000 T _seek_in_line__8parsebufi libc parsestream 00000000 T ___libc_fatal libc emulate 00000000 T ___emulate_dummy libc emulate 00000000 C __heapbase libc malloc 00000000 C __heapinfo libc malloc 00000000 C __heapindex libc malloc 00000000 C __heaplimit libc malloc 00000000 C __fraghead libc malloc 00000000 C __chunks_used libc malloc 00000000 C __bytes_used libc malloc 00000000 C __chunks_free libc malloc 00000000 C __bytes_free libc malloc 00000000 C ___malloc_initialized libc malloc 00000000 C ___malloc_hook libc malloc 00000000 C ___free_hook libc free 00000000 C ___realloc_hook libc realloc 00000000 T _tr_break libc mtrace 00000000 C _mallwatch libc mtrace 00000000 T ___default_morecore libc morecore 00000000 T ____masksig_restore libc ____sig 00000000 T ___load_shared_libraries libc __load 00000000 T _tzsetwall libc bsdtime 00000000 T _ufc_doit libc crypt 00000000 T _ufc_dofinalperm libc crypt_util 00000000 C _ufc_keytab libc crypt_util 00000000 C _ufc_sb0 libc crypt_util 00000000 C _ufc_sb1 libc crypt_util 00000000 C _ufc_sb2 libc crypt_util 00000000 C _ufc_sb3 libc crypt_util 00000000 C ___CTOR_LIST__ libgcc _ctors 00000000 C ___DTOR_LIST__ libgcc _ctors 00000000 T _init__7filebuf libc filebuf 00000000 T _do_write__7filebufPCci libc filebuf 00000000 T _sys_read__7filebufPcUi libc filebuf 00000000 T _sys_seek__7filebuflQ23ios8seek_dir libc filebuf 00000000 T _sys_write__7filebufPCvl libc filebuf 00000000 T _sys_stat__7filebufPv libc filebuf 00000000 T _sys_close__7filebuf libc filebuf 00000000 T ___outfloat__FdP9streambufciiUlcc libc outfloat 00000000 T ___7procbufPCci libc procbuf 00000000 T _open__7procbufPCci libc procbuf 00000000 T _sys_close__7procbuf libc procbuf 00000000 T __$_7procbuf libc procbuf 00000000 T _overflow__14help_streambufi libc sbufvform 00000000 T __$_14help_streambuf libc sbufvform 00000000 T _help_vform__FP9streambufPCcPv libc sbufvform 00000000 T _set_streampos__12streammarkerl libc streambuf 00000000 T _set_offset__12streammarkeri libc streambuf 00000000 T _saving__12streammarker libc streambuf 00000000 T _xchain__9streambuf libc streambuf 00000000 T _gptr__C9streambuf libc streambuf 00000000 T _pptr__C9streambuf libc streambuf 00000000 T _egptr__C9streambuf libc streambuf 00000000 T _epptr__C9streambuf libc streambuf 00000000 T _pbase__C9streambuf libc streambuf 00000000 T _eback__C9streambuf libc streambuf 00000000 T _base__C9streambuf libc streambuf 00000000 T _ebuf__C9streambuf libc streambuf 00000000 T _blen__C9streambuf libc streambuf 00000000 T _xput_char__9streambufc libc streambuf 00000000 T _xflags__9streambuf libc streambuf 00000000 T _xflags__9streambufi libc streambuf 00000000 T _xsetflags__9streambufi libc streambuf 00000000 T _xsetflags__9streambufii libc streambuf 00000000 T _gbump__9streambufi libc streambuf 00000000 T _pbump__9streambufi libc streambuf 00000000 T _setp__9streambufPcT1 libc streambuf 00000000 T _setg__9streambufPcN21 libc streambuf 00000000 T _shortbuf__9streambuf libc streambuf 00000000 T _in_backup__9streambuf libc streambuf 00000000 T _Gbase__9streambuf libc streambuf 00000000 T _eGptr__9streambuf libc streambuf 00000000 T _Bbase__9streambuf libc streambuf 00000000 T _Bptr__9streambuf libc streambuf 00000000 T _eBptr__9streambuf libc streambuf 00000000 T _Nbase__9streambuf libc streambuf 00000000 T _eNptr__9streambuf libc streambuf 00000000 T _have_backup__9streambuf libc streambuf 00000000 T _have_markers__9streambuf libc streambuf 00000000 T _put_mode__9streambuf libc streambuf 00000000 T ___9backupbufi libc streambuf 00000000 T __$_9backupbuf libc streambuf 00000000 T _is_reading__7filebuf libc streambuf 00000000 T _cur_ptr__7filebuf libc streambuf 00000000 T _file_ptr__7filebuf libc streambuf 00000000 T _do_flush__7filebuf libc streambuf 00000000 T __un_link__9streambuf libc streambuf 00000000 T __link_in__9streambuf libc streambuf 00000000 T __least_marker__9streambuf libc streambuf 00000000 T _switch_to_main_get_area__9streambuf libc streambuf 00000000 T _switch_to_backup_area__9streambuf libc streambuf 00000000 T _switch_to_get_mode__9streambuf libc streambuf 00000000 T _free_backup_area__9streambuf libc streambuf 00000000 T _underflow__9backupbuf libc streambuf 00000000 T _overflow__9backupbufi libc streambuf 00000000 T ___12streammarkerP9streambuf libc streambuf 00000000 T __$_12streammarker libc streambuf 00000000 T _delta__12streammarkerRT0 libc streambuf 00000000 T _delta__12streammarker libc streambuf 00000000 T _unsave_markers__9streambuf libc streambuf 00000000 T ___adjust_column__FUiPCci libc streambuf 000000c0 D __vt$filebuf libc streambuf 000000c0 D __vt$backupbuf libc streambuf 000000c0 D __vt$streambuf libc streambuf 00000040 D __vt$ios libc streambuf 00000040 D __vt$9strstream$3ios libc strstream 00000040 D __vt$10ostrstream$3ios libc strstream 00000040 D __vt$10istrstream$3ios libc strstream 00000040 D __vt$13strstreambase$3ios libc strstream 000000c0 D __vt$strstreambuf libc strstream 00000000 C __REG_SAVE2__ libc res_init 00000000 D __vt$8PlotFile$3ios libc PlotFile 00000000 D __vt$5SFile$3ios libc SFile 00000000 D __vt$edit_streambuf libc editbuf 00000000 D __vt$indirectbuf libc indstream 00000000 D __vt$general_parsebuf libc parsestream 00000000 D __vt$func_parsebuf libc parsestream 00000000 D __vt$string_parsebuf libc parsestream 00000000 D __vt$parsebuf libc parsestream 00000000 D __vt$stdiobuf libc stdiostream 00000000 K ___collate_C libc C-collate 00000000 K ___ctype_C libc C-ctype 00000000 K ___ctype_b_C libc C-ctype_ct 00000000 K ___ctype_tolower_C libc C-ctype_ct 00000000 K ___ctype_toupper_C libc C-ctype_ct 00000000 K ___ctype_ctype_C libc C-ctype_ct 00000000 K ___ctype_mbchar_C libc C-ctype_mb 00000000 K ___monetary_C libc C-monetary 00000000 K ___numeric_C libc C-numeric 00000000 K ___response_C libc C-response 00000000 K ___time_C libc C-time 00000000 i ___SHARED_LIBRARIES__ libc __load 00000000 i _environ libc ruserpass 00000000 i _sys_errlist libc clnt_perror 00000000 i _sys_nerr libc clnt_perror 00000000 i ____sig_restore libc __sigact 00000000 D __aligned_blocks libc free 00000000 D ___morecore libc malloc 00000000 D __mb_shift libc mbtowc 00000000 D ___do_global_ctors libgcc __main 00000000 D ___do_global_dtors libgcc __main 00000000 D ___main libgcc __main 00000000 D __exit_dummy_decl libgcc _exit 00000000 D ___yplib_timeout libc yplib 00000000 D ___yplib_cache libc yplib 00000000 C ___ypbindlist libc yplib 00000000 T ___grpopen libc grpopen 00000000 T ___yp_setgrflag libc grpread 00000000 T ___yp_cleargrflag libc grpread 00000000 T ___yp_getgrmode libc grpread 00000000 T ___ypparsegrp libc grpread 00000000 T ___grpalloc libc grpread 00000000 T ___grpread libc grpread 00000000 T ___grpread_noyp libc grpread 00000000 T ___pwdopen libc pwdopen 00000000 T ___yp_setpwflag libc pwdread 00000000 T ___yp_clearpwflag libc pwdread 00000000 T ___yp_getpwmode libc pwdread 00000000 T ___yp_getdomain libc pwdread 00000000 T ___ypparsepwd libc pwdread 00000000 T ___pwdalloc libc pwdread 00000000 T ___pwdread libc pwdread 00000000 T ___pwdread_noyp libc pwdread 00000000 T ___yp_dobind libc yplib 00000000 C _ypresp_allfn libc yplib 00000000 C _ypresp_data libc yplib ./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.undefs100644 1676 334 0 5550061525 16026 0ustar hjlisl./libc-linux/jump/libc.lite/jump.vars100644 1676 334 24323 5520361070 15626 0ustar hjlisl00000098 K _h_errlist libc herror 0000023c K __sys_errlist libc _errlist 00000004 K __sys_nerr libc _errlist 000000c4 K __sys_siglist libc _siglist 00000004 D __DUMMY__ libgcc _new_handler 00000004 D ___ctype_b libc ctype-info 00000004 D ___ctype_tolower libc ctype-info 00000008 D ___ctype_toupper libc ctype-info 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000034 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000024 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 C _BC libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 C _UP libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000001 C _PC libtermcap,libcurses termcap 00000000 D __DUMMY__ libtermcap curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000003 D __DUMMY__ libcurses curses 00000200 D __DUMMY__ libcurses unctrl 00000008 C __DUMMY__ libdbm global 00000000 C __DUMMY__ libdbm global 00000008 D _h_errno libc herror 00000180 D __res libc res_init 00000008 D _rexecoptions libc rexec 0000014c D __IO_stdin_ libc stdfiles 0000014c D __IO_stdout_ libc stdfiles 0000014c D __IO_stderr_ libc stdfiles 0000014c D __DUMMY__ libc stdstrbufs 00000008 D __IO_list_all libc stdfiles 000000c0 D __DUMMY__ libc emulate 00000008 D ___environ libc __environ 00000008 D _errno libc errno 00000004 D _optarg libc getopt 00000004 D _optind libc getopt 00000008 D _opterr libc getopt 00000008 D _re_syntax_options libc regex 00000008 D ____brk_addr libc __brk 00000004 D _ospeed libtermcap termcap 00000004 D _tputs_baud_rate libtermcap termcap 00000008 D _tzname libc bsdtime 00000004 D _timezone libc bsdtime 00000004 D _daylight libc bsdtime 00000004 D __DUMMY__ libc rpc_comdata 00000020 D _rpc_createerr libc rpc_comdata 0000000c D __null_auth libc rpc_comdata 00000008 D __collate_info libc C-collate 00000008 D __ctype_info libc C-ctype 00000008 D __monetary_info libc C-monetary 00000008 D __numeric_info libc C-numeric 00000008 D __response_info libc C-response 00000290 D __time_info libc C-time 00001120 D ___exit_funcs libc atexit 00000004 D _stdin libc stdio 00000004 D _stdout libc stdio 00000008 D _stderr libc stdio 000001c0 D __DUMMY__ libc free 00000008 D __DUMMY__ libc malloc 000003f8 D __DUMMY__ libc mbtowc 00000008 D _re_max_failures libc regex 00000040 D __res_opcodes libc res_debug 00000a30 D __res_resultcodes libc res_debug 00000768 D ___ttyname libc ttyname 000000fc D __DUMMY__ libcurses refresh 00000004 D __DUMMY__ libdbm global 00000008 D __DUMMY__ libdbm global 00000004 D __DUMMY__ libdbm global 00000004 D __DUMMY__ libdbm version 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000004 D _h_nerr libc herrlist 000000a0 D __IO_file_jumps libc fileops 000000a0 D __IO_proc_jumps libc iopopen 000000a0 D __IO_str_jumps libc strops 000000d8 D __DUMMY__ libc streambuf 000000b0 D __DUMMY__ libc streambuf 000000b0 D __DUMMY__ libc streambuf 00000000 D __DUMMY__ libc strstream 00000000 D __DUMMY__ libc strstream 00000000 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc strstream 000000b0 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000004 D _optopt libc getopt 00000040 D _svc_fdset libc rpc_comdata 00000004 D __obstack libc obstack 00000004 C ___glob_closedir_hook libc glob 00000004 C ___glob_opendir_hook libc glob 00000004 C ___glob_readdir_hook libc glob 00000004 D __sigintr libc sigint 00000004 D __DUMMY__ libc msgcat ./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.lite/jump.vars.iostream100644 1676 334 24362 5473753416 17473 0ustar hjlisl00000098 K _h_errlist libc herror 0000023c K __sys_errlist libc _errlist 00000004 K __sys_nerr libc _errlist 000000c4 K __sys_siglist libc _siglist 00000004 D ___new_handler libgcc _new_handler 00000004 D ___ctype_b libc ctype-info 00000004 D ___ctype_tolower libc ctype-info 00000008 D ___ctype_toupper libc ctype-info 00000001 D __echoit libcurses curses 00000001 D __rawmode libcurses curses 00000001 D _My_term libcurses curses 00000001 D __endwin libcurses curses 00000034 D _ttytype libcurses curses 00000004 D _Def_term libcurses curses 00000004 D __tty_ch libcurses curses 00000004 D _LINES libcurses curses 00000004 D _COLS libcurses curses 00000004 D __res_iflg libcurses curses 00000004 D __res_lflg libcurses curses 00000004 D _stdscr libcurses curses 00000004 D _curscr libcurses curses 00000024 D __tty libcurses curses 00000001 D _AM libcurses curses 00000001 D _BS libcurses curses 00000001 D _CA libcurses curses 00000001 D _DA libcurses curses 00000001 D _DB libcurses curses 00000001 D _EO libcurses curses 00000001 D _HC libcurses curses 00000001 D _HZ libcurses curses 00000001 D _IN libcurses curses 00000001 D _MI libcurses curses 00000001 D _MS libcurses curses 00000001 D _NC libcurses curses 00000001 D _NS libcurses curses 00000001 D _OS libcurses curses 00000001 D _UL libcurses curses 00000001 D _XB libcurses curses 00000001 D _XN libcurses curses 00000001 D _XT libcurses curses 00000001 D _XS libcurses curses 00000001 D _XX libcurses curses 00000004 D _AL libcurses curses 00000004 C _BC libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D _BT libcurses curses 00000004 D _CD libcurses curses 00000004 D _CE libcurses curses 00000004 D _CL libcurses curses 00000004 D _CM libcurses curses 00000004 D _CR libcurses curses 00000004 D _CS libcurses curses 00000004 D _DC libcurses curses 00000004 D _DL libcurses curses 00000004 D _DM libcurses curses 00000004 D _DO libcurses curses 00000004 D _ED libcurses curses 00000004 D _EI libcurses curses 00000004 D _K0 libcurses curses 00000004 D _K1 libcurses curses 00000004 D _K2 libcurses curses 00000004 D _K3 libcurses curses 00000004 D _K4 libcurses curses 00000004 D _K5 libcurses curses 00000004 D _K6 libcurses curses 00000004 D _K7 libcurses curses 00000004 D _K8 libcurses curses 00000004 D _K9 libcurses curses 00000004 D _HO libcurses curses 00000004 D _IC libcurses curses 00000004 D _IM libcurses curses 00000004 D _IP libcurses curses 00000004 D _KD libcurses curses 00000004 D _KE libcurses curses 00000004 D _KH libcurses curses 00000004 D _KL libcurses curses 00000004 D _KR libcurses curses 00000004 D _KS libcurses curses 00000004 D _KU libcurses curses 00000004 D _LL libcurses curses 00000004 D _MA libcurses curses 00000004 D _ND libcurses curses 00000004 D _NL libcurses curses 00000004 D _RC libcurses curses 00000004 D _SC libcurses curses 00000004 D _SE libcurses curses 00000004 D _SF libcurses curses 00000004 D _SO libcurses curses 00000004 D _SR libcurses curses 00000004 D _TA libcurses curses 00000004 D _TE libcurses curses 00000004 D _TI libcurses curses 00000004 D _UC libcurses curses 00000004 D _UE libcurses curses 00000004 C _UP libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D _US libcurses curses 00000004 D _VB libcurses curses 00000004 D _VS libcurses curses 00000004 D _VE libcurses curses 00000004 D _AL_PARM libcurses curses 00000004 D _DL_PARM libcurses curses 00000004 D _UP_PARM libcurses curses 00000004 D _DOWN_PARM libcurses curses 00000004 D _LEFT_PARM libcurses curses 00000004 D _RIGHT_PARM libcurses curses 00000001 C _PC libtermcap,libcurses termcap 00000000 D __DUMMY__ libtermcap curses 00000001 D _GT libcurses curses 00000001 D _NONL libcurses curses 00000001 D _UPPERCASE libcurses curses 00000001 D _normtty libcurses curses 00000003 D __pfast libcurses curses 00000200 D __unctrl libcurses unctrl 00000008 C _gdbm_errno libdbm global 00000000 C __DUMMY__ libdbm global 00000008 D _h_errno libc herror 00000180 D __res libc res_init 00000008 D _rexecoptions libc rexec 0000014c D ___std_filebuf_0 libc stdstrbufs 0000014c D ___std_filebuf_1 libc stdstrbufs 0000014c D ___std_filebuf_2 libc stdstrbufs 0000014c D __DUMMY__ libc stdstrbufs 00000008 D __9streambuf$_list_all libc stdstrbufs 000000c0 D __iob libc emulate 00000008 D ___environ libc __environ 00000008 D _errno libc errno 00000004 D _optarg libc getopt 00000004 D _optind libc getopt 00000008 D _opterr libc getopt 00000008 D _re_syntax_options libc regex 00000008 D ____brk_addr libc __brk 00000004 D _ospeed libtermcap termcap 00000004 D _tputs_baud_rate libtermcap termcap 00000008 D _tzname libc bsdtime 00000004 D _timezone libc bsdtime 00000004 D _daylight libc bsdtime 00000004 D __DUMMY__ libc rpc_comdata 00000020 D _rpc_createerr libc rpc_comdata 0000000c D __null_auth libc rpc_comdata 00000008 D __collate_info libc C-collate 00000008 D __ctype_info libc C-ctype 00000008 D __monetary_info libc C-monetary 00000008 D __numeric_info libc C-numeric 00000008 D __response_info libc C-response 00000290 D __time_info libc C-time 00001120 D ___exit_funcs libc atexit 00000004 D _stdin libc fprintf 00000004 D _stdout libc fprintf 00000008 D _stderr libc fprintf 000001c0 D __DUMMY__ libc free 00000008 D __DUMMY__ libc malloc 000003f8 D __DUMMY__ libc mbtowc 00000008 D _re_max_failures libc regex 00000040 D __res_opcodes libc res_debug 00000a30 D __res_resultcodes libc res_debug 00000768 D ___ttyname libc ttyname 000000fc D __win libcurses refresh 00000004 D __gdbm_file libdbm global 00000008 D __gdbm_memory libdbm global 00000004 D __gdbm_fetch_val libdbm global 00000004 D _gdbm_version libdbm version 00000080 D _cout libc stdstreams 00000080 D _cerr libc stdstreams 00000080 D _cin libc stdstreams 00000080 D _clog libc stdstreams 00000004 D _h_nerr libc herrlist 00000050 D __vt$8iostream$3ios libc iostream 00000050 D __vt$istream$3ios libc iostream 00000050 D __vt$7ostream$3ios libc iostream 000000d8 D __vt$7filebuf libc streambuf 000000b0 D __vt$9backupbuf libc streambuf 000000b0 D __vt$9streambuf libc streambuf 00000050 D __vt$3ios libc streambuf 00000050 D __vt$9strstream$3ios libc strstream 00000050 D __vt$10ostrstream$3ios libc strstream 00000050 D __vt$10istrstream$3ios libc strstream 00000050 D __vt$13strstreambase$3ios libc strstream 000000b0 D __vt$12strstreambuf libc strstream 00000050 D __vt$7fstream$3ios libc fstream 00000050 D __vt$8ofstream$3ios libc fstream 00000050 D __vt$8ifstream$3ios libc fstream 00000050 D __vt$11fstreambase$3ios libc fstream 00000004 D _optopt libc getopt 00000040 D _svc_fdset libc rpc_comdata 00000004 D __obstack libc obstack 00000004 C ___glob_closedir_hook libc glob 00000004 C ___glob_opendir_hook libc glob 00000004 C ___glob_readdir_hook libc glob 00000004 D __sigintr libc sigint 00000004 D _MCAppPath libc msgcat ./libc-linux/jump/libc.lite/jump.funcs.iostream100644 1676 334 164756 5473753430 17666 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 T ___fillbf libc emulate 00000000 T ___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 streambuf 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 streambuf 00000000 T __cleanup libc stdio 00000000 T __exit libc libc_exit 00000000 T __filbuf libc emulate 00000000 T __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 _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 _fclose libc fclose 00000000 T ___fcntl libc __fcntl 00000000 T _fcvt libc cvt 00000000 T _fdopen libc fdopen 00000000 T _feof libc feof 00000000 T _ferror libc ferror 00000000 T _fetch libdbm fetch 00000000 T _fflush libc fflush 00000000 T _ffs libc ffs 00000000 T _fgetc libc fgetc 00000000 T _fgetgrent libc fgetgrent 00000000 T _fgetpos libc fgetpos 00000000 T _fgetpwent libc fgetpwent 00000000 T _fgets libc fgets 00000000 T _fileno libc fileno 00000000 T _firstkey libdbm seq 00000000 T _fnmatch libc fnmatch 00000000 T _fopen libc fopen 00000000 T ___fork libc __fork 00000000 T ___fpathconf libc __fpathconf 00000000 T _fprintf libc fprintf 00000000 T _fputc libc fputc 00000000 T _fputs libc fputs 00000000 T _fread libc fread 00000000 T _free libc free 00000000 T _freopen libc freopen 00000000 T _fscanf libc fscanf 00000000 T _fseek libc fseek 00000000 T _fsetpos libc fsetpos 00000000 T ___fstat libc __fstat 00000000 T ___fstatfs libc __fstatfs 00000000 T _ftell libc ftell 00000000 T _ftime libc ftime 00000000 T _ftruncate libc ftruncate 00000000 T _ftw libc ftw 00000000 T _fwrite libc fwrite 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 macros 00000000 T _getcap libcurses cr_tty 00000000 T _getchar libc macros 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 _gets libc gets 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 _perror libc perror 00000000 T ___pipe libc __pipe 00000000 T _popen libc popen 00000000 T _printf libc printf 00000000 T _printw libcurses printw 00000000 T _psignal libc psignal 00000000 T _ptrace libc ptrace 00000000 T _putc libc macros 00000000 T _putchar libc macros 00000000 T _putenv libc putenv 00000000 T _putlong libc res_comp 00000000 T _putpwent libc putpwent 00000000 T _puts libc puts 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 revcfrom 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 _scanf libc scanf 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 _setbuffer libc setbuffer 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 _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 _setvbuf libc setvbuf 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 _sprintf libc sprintf 00000000 t ___srandom libcompat 00000000 T _srand48 libc drand48 00000000 t ___srandom libcompat 00000000 T _sscanf libc sscanf 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 _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 _ungetc libc ungetc 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 _vfprintf libc vfprintf 00000000 T _vfscanf libc vfscanf 00000000 T _vhangup libc vhangup 00000000 T _vprintf libc vprintf 00000000 T _vscanf libc vscanf 00000000 T _vsprintf libc vsprintf 00000000 T _vsscanf libc vsscanf 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 T ___muldi3 libgcc _muldi3 00000000 T ___udivdi3 libgcc _udivdi3 00000000 T ___udivmoddi4 libgcc _udivmoddi4 00000000 T ___umoddi3 libgcc _umoddi3 00000000 T ___stdio_gen_tempname libc tempname 00000000 T ___7filebuf libc filebuf 00000000 T ___7filebufi libc filebuf 00000000 T ___7filebufiPci libc filebuf 00000000 T __$_7filebuf libc filebuf 00000000 T _open__7filebufPCcii libc filebuf 00000000 T _open__7filebufPCcT1 libc filebuf 00000000 T _attach__7filebufi libc filebuf 00000000 T _setbuf__7filebufPci libc filebuf 00000000 T _overflow__7filebufi libc filebuf 00000000 T _underflow__7filebuf libc filebuf 00000000 T _sync__7filebuf libc filebuf 00000000 T _seekoff__7filebuflQ23ios8seek_diri libc filebuf 00000000 T _close__7filebuf libc filebuf 00000000 T _xsputn__7filebufPCci libc filebuf 00000000 T _xsgetn__7filebufPci libc filebuf 00000000 T _doallocate__7filebuf libc makebuf 00000000 T _vform__9streambufPCcPv libc sbufvform 00000000 T _form__9streambufPCce libc sbufvform 00000000 T _vscan__9streambufPCcPvP3ios libc sbufvscan 00000000 T _scan__9streambufPCce libc sbufvscan 00000000 T _sgetline__9streambufPcUici libc sgetline 00000000 T _tie__C3ios libc streambuf 00000000 T _tie__3iosP7ostream libc streambuf 00000000 T _fill__C3ios libc streambuf 00000000 T _fill__3iosl libc streambuf 00000000 T _flags__C3ios libc streambuf 00000000 T _flags__3iosUl libc streambuf 00000000 T _precision__C3ios libc streambuf 00000000 T _precision__3iosi libc streambuf 00000000 T _setf__3iosUl libc streambuf 00000000 T _setf__3iosUlUl libc streambuf 00000000 T _unsetf__3iosUl libc streambuf 00000000 T _width__C3ios libc streambuf 00000000 T _width__3iosi libc streambuf 00000000 T __throw_failure__3ios libc streambuf 00000000 T _rdbuf__C3ios libc streambuf 00000000 T _clear__3iosi libc streambuf 00000000 T _set__3iosi libc streambuf 00000000 T _good__C3ios libc streambuf 00000000 T _eof__C3ios libc streambuf 00000000 T _fail__C3ios libc streambuf 00000000 T _bad__C3ios libc streambuf 00000000 T _rdstate__C3ios libc streambuf 00000000 T ___opPv__C3ios libc streambuf 00000000 T ___nt__C3ios libc streambuf 00000000 T _exceptions__3iosi libc streambuf 00000000 T _sync_with_stdio__3ios libc streambuf 00000000 T _unset__3ios11state_value libc streambuf 00000000 T _init__3iosP9streambuf libc streambuf 00000000 T _unbuffered__9streambuf libc streambuf 00000000 T _linebuffered__9streambuf libc streambuf 00000000 T _unbuffered__9streambufi libc streambuf 00000000 T _linebuffered__9streambufi libc streambuf 00000000 T _allocate__9streambuf libc streambuf 00000000 T _allocbuf__9streambuf libc streambuf 00000000 T _in_avail__9streambuf libc streambuf 00000000 T _out_waiting__9streambuf libc streambuf 00000000 T _sputn__9streambufPCci libc streambuf 00000000 T _sgetn__9streambufPci libc streambuf 00000000 T _sbumpc__9streambuf libc streambuf 00000000 T _sgetc__9streambuf libc streambuf 00000000 T _snextc__9streambuf libc streambuf 00000000 T _sputc__9streambufi libc streambuf 00000000 T _stossc__9streambuf libc streambuf 00000000 T _is_open__C7filebuf libc streambuf 00000000 T _fd__C7filebuf libc streambuf 00000000 T ___3iosP9streambufP7ostream libc streambuf 00000000 T __$_3ios libc streambuf 00000000 T _xsputn__9streambufPCci libc streambuf 00000000 T _padn__9streambufci libc streambuf 00000000 T _xsgetn__9streambufPci libc streambuf 00000000 T _ignore__9streambufi libc streambuf 00000000 T _sync__9streambuf libc streambuf 00000000 T _pbackfail__9streambufi libc streambuf 00000000 T _setbuf__9streambufPci libc streambuf 00000000 T _seekpos__9streambufli libc streambuf 00000000 T _setb__9streambufPcT1i libc streambuf 00000000 T _doallocate__9streambuf libc streambuf 00000000 T _doallocbuf__9streambuf libc streambuf 00000000 T ___9streambufi libc streambuf 00000000 T __$_9streambuf libc streambuf 00000000 T _seekoff__9streambuflQ23ios8seek_diri libc streambuf 00000000 T _sputbackc__9streambufc libc streambuf 00000000 T _sungetc__9streambuf libc streambuf 00000000 T _get_column__9streambuf libc streambuf 00000000 T _set_column__9streambufi libc streambuf 00000000 T _flush_all__9streambuf libc streambuf 00000000 T _flush_all_linebuffered__9streambuf libc streambuf 00000000 T _seekmark__9streambufR12streammarkeri libc streambuf 00000000 T _pbackfail__9backupbufi libc streambuf 00000000 T _readable__3ios libc streambuf 00000000 T _writable__3ios libc streambuf 00000000 T _is_open__3ios libc streambuf 00000000 U _init_const__12strstreambuf libc strstream 00000000 T ___12strstreambuf libc strstream 00000000 T ___12strstreambufi libc strstream 00000000 T ___12strstreambufPFUi_PvPFPv_v libc strstream 00000000 T ___12strstreambufPciT1 libc strstream 00000000 T ___12strstreambufPUciT1 libc strstream 00000000 T ___12strstreambufPCci libc strstream 00000000 T ___12strstreambufPCUci libc strstream 00000000 T ___12strstreambufPSciT1 libc strstream 00000000 T ___12strstreambufPCSci libc strstream 00000000 T _frozen__12strstreambuf libc strstream 00000000 T _freeze__12strstreambufi libc strstream 00000000 T _rdbuf__13strstreambase libc strstream 00000000 T ___13strstreambasei libc strstream 00000000 T __$_13strstreambase libc strstream 00000000 T __$_10istrstream libc strstream 00000000 T ___10ostrstreamiPcii libc strstream 00000000 T _pcount__10ostrstream libc strstream 00000000 T _str__10ostrstream libc strstream 00000000 T _freeze__10ostrstreami libc strstream 00000000 T _frozen__10ostrstream libc strstream 00000000 T __$_10ostrstream libc strstream 00000000 T ___9strstreami libc strstream 00000000 T ___9strstreamiPcii libc strstream 00000000 T _pcount__9strstream libc strstream 00000000 T _str__9strstream libc strstream 00000000 T _freeze__9strstreami libc strstream 00000000 T _frozen__9strstream libc strstream 00000000 T __$_9strstream libc strstream 00000000 T ___10istrstreamiPCci libc strstream 00000000 T ___10ostrstreami libc strstream 00000000 T ___13strstreambaseiPcii libc strstream 00000000 T _str__12strstreambuf libc strstream 00000000 T _pcount__12strstreambuf libc strstream 00000000 T _overflow__12strstreambufi libc strstream 00000000 T _underflow__12strstreambuf libc strstream 00000000 T _init_dynamic__12strstreambufPFUi_PvPFPv_vi libc strstream 00000000 T _init_static__12strstreambufPciT1 libc strstream 00000000 T __$_12strstreambuf libc strstream 00000000 T _seekoff__12strstreambuflQ23ios8seek_diri libc strstream 00000000 T _pbackfail__12strstreambufi libc strstream 00000000 T _rdbuf__C11fstreambase libc fstream 00000000 T _is_open__C11fstreambase libc fstream 00000000 T _setbuf__11fstreambasePci libc fstream 00000000 T _filedesc__11fstreambase libc fstream 00000000 T _raw__11fstreambase libc fstream 00000000 T __$_11fstreambase libc fstream 00000000 T ___8ifstreami libc fstream 00000000 T ___8ifstreamii libc fstream 00000000 T ___8ifstreamiPCcii libc fstream 00000000 T _open__8ifstreamPCcii libc fstream 00000000 T __$_8ifstream libc fstream 00000000 T ___8ofstreami libc fstream 00000000 T ___8ofstreamii libc fstream 00000000 T ___8ofstreamiPCcii libc fstream 00000000 T _open__8ofstreamPCcii libc fstream 00000000 T __$_8ofstream libc fstream 00000000 T ___7fstreami libc fstream 00000000 T ___7fstreamii libc fstream 00000000 T ___7fstreamiPCcii libc fstream 00000000 T _open__7fstreamPCcii libc fstream 00000000 T __$_7fstream libc fstream 00000000 T ___11fstreambasei libc fstream 00000000 T ___11fstreambaseii libc fstream 00000000 T ___11fstreambaseiPCcii libc fstream 00000000 T _open__11fstreambasePCcii libc fstream 00000000 T _close__11fstreambase libc fstream 00000000 T _getline__7istreamPcic libc igetline 00000000 T _get__7istreamPcic libc igetline 00000000 T _gets__7istreamPPcc libc igetline 00000000 T _get__7istreamR9streambufc libc igetsb 00000000 T ___iomanip_setbase__FR3iosi libc iomanip 00000000 T ___iomanip_setfill__FR3iosi libc iomanip 00000000 T ___iomanip_setprecision__FR3iosi libc iomanip 00000000 T ___iomanip_setw__FR3iosi libc iomanip 00000000 T ___iomanip_setiosflags__FR3iosUl libc iomanip 00000000 T ___iomanip_resetiosflags__FR3iosUl libc iomanip 00000000 T ___7ostreami libc iostream 00000000 T _opfx__7ostream libc iostream 00000000 T _osfx__7ostream libc iostream 00000000 T _ostreambuf__C7ostream libc iostream 00000000 T _put__7ostreamc libc iostream 00000000 T _put__7ostreamUc libc iostream 00000000 T _write__7ostreamPCUci libc iostream 00000000 T _put__7ostreamSc libc iostream 00000000 T _write__7ostreamPCSci libc iostream 00000000 T _write__7ostreamPCvi libc iostream 00000000 T ___ls__7ostreamUc libc iostream 00000000 T ___ls__7ostreamSc libc iostream 00000000 T ___ls__7ostreamPCUc libc iostream 00000000 T ___ls__7ostreamPCSc libc iostream 00000000 T ___ls__7ostreams libc iostream 00000000 T ___ls__7ostreamUs libc iostream 00000000 T ___ls__7ostreamf libc iostream 00000000 T ___ls__7ostreamPFR7ostream_R7ostream libc iostream 00000000 T ___ls__7ostreamPFR3ios_R3ios libc iostream 00000000 T __$_7ostream libc iostream 00000000 T ___7istreami libc iostream 00000000 T _istreambuf__C7istream libc iostream 00000000 T _get__7istreamPUcic libc iostream 00000000 T _get__7istreamRUc libc iostream 00000000 T _getline__7istreamPUcic libc iostream 00000000 T _get__7istreamRSc libc iostream 00000000 T _get__7istreamPScic libc iostream 00000000 T _getline__7istreamPScic libc iostream 00000000 T _read__7istreamPUci libc iostream 00000000 T _read__7istreamPSci libc iostream 00000000 T _read__7istreamPvi libc iostream 00000000 T _ipfx__7istreami libc iostream 00000000 T _ipfx0__7istream libc iostream 00000000 T _ipfx1__7istream libc iostream 00000000 T _get__7istream libc iostream 00000000 T _peek__7istream libc iostream 00000000 T _gcount__7istream libc iostream 00000000 T _putback__7istreamc libc iostream 00000000 T _unget__7istream libc iostream 00000000 T _unget__7istreamc libc iostream 00000000 T ___rs__7istreamPUc libc iostream 00000000 T ___rs__7istreamPSc libc iostream 00000000 T ___rs__7istreamRUc libc iostream 00000000 T ___rs__7istreamRSc libc iostream 00000000 T ___rs__7istreamPFR3ios_R3ios libc iostream 00000000 T ___rs__7istreamPFR7istream_R7istream libc iostream 00000000 T __$_7istream libc iostream 00000000 T ___8iostreami libc iostream 00000000 T __$_8iostream libc iostream 00000000 T _dec__FR3ios libc iostream 00000000 T _hex__FR3ios libc iostream 00000000 T _oct__FR3ios libc iostream 00000000 T ___7istreamiP9streambufP7ostream libc iostream 00000000 T _skip_ws__FP9streambuf libc iostream 00000000 T _get__7istreamRc libc iostream 00000000 T _ignore__7istreamii libc iostream 00000000 T _read__7istreamPci libc iostream 00000000 T _seekg__7istreaml libc iostream 00000000 T _seekg__7istreamlQ23ios8seek_dir libc iostream 00000000 T _tellg__7istream libc iostream 00000000 T _scan__7istreamPCce libc iostream 00000000 T _vscan__7istreamPCcPv libc iostream 00000000 T ___rs__7istreamRc libc iostream 00000000 T ___rs__7istreamPc libc iostream 00000000 T ___rs__7istreamRs libc iostream 00000000 T ___rs__7istreamRUs libc iostream 00000000 T ___rs__7istreamRi libc iostream 00000000 T ___rs__7istreamRUi libc iostream 00000000 T ___rs__7istreamRl libc iostream 00000000 T ___rs__7istreamRUl libc iostream 00000000 T ___rs__7istreamRx libc iostream 00000000 T ___rs__7istreamRUx libc iostream 00000000 T ___rs__7istreamRd libc iostream 00000000 T ___rs__7istreamRf libc iostream 00000000 T ___rs__7istreamP9streambuf libc iostream 00000000 T ___ls__7ostreamc libc iostream 00000000 T ___ls__7ostreami libc iostream 00000000 T ___ls__7ostreamUi libc iostream 00000000 T ___ls__7ostreaml libc iostream 00000000 T ___ls__7ostreamUl libc iostream 00000000 T ___ls__7ostreamx libc iostream 00000000 T ___ls__7ostreamUx libc iostream 00000000 T ___ls__7ostreamd libc iostream 00000000 T ___ls__7ostreamPCc libc iostream 00000000 T ___ls__7ostreamPCv libc iostream 00000000 T ___ls__7ostreamP9streambuf libc iostream 00000000 T ___7ostreamiP9streambufPT0 libc iostream 00000000 T _seekp__7ostreaml libc iostream 00000000 T _seekp__7ostreamlQ23ios8seek_dir libc iostream 00000000 T _tellp__7ostream libc iostream 00000000 T _form__7ostreamPCce libc iostream 00000000 T _vform__7ostreamPCcPv libc iostream 00000000 T _flush__7ostream libc iostream 00000000 T _flush__FR7ostream libc iostream 00000000 T _ws__FR7istream libc iostream 00000000 T __skip_ws__7istream libc iostream 00000000 T _ends__FR7ostream libc iostream 00000000 T _endl__FR7ostream libc iostream 00000000 T _write__7ostreamPCci libc iostream 00000000 T _do_osfx__7ostream libc iostream 00000000 T ___8iostreamiP9streambufP7ostream libc iostream 00000000 T _close__3ios libc iostream 00000000 T _skip__7istreami libc iostream 00000000 T _stdiofile__C8stdiobuf libc stdiostream 00000000 T __$_8stdiobuf libc stdiostream 00000000 T ___8stdiobufP6__FILE libc stdiostream 00000000 T _sys_read__8stdiobufPcUi libc stdiostream 00000000 T _sys_write__8stdiobufPCvl libc stdiostream 00000000 T _sys_seek__8stdiobuflQ23ios8seek_dir libc stdiostream 00000000 T _sys_close__8stdiobuf libc stdiostream 00000000 T _sync__8stdiobuf libc stdiostream 00000000 T _overflow__8stdiobufi libc stdiostream 00000000 T _xsputn__8stdiobufPCci libc stdiostream 00000000 T _sync_with_stdio__3iosi libc stdstreams 00000000 T _form__FPCce libc stream 00000000 T _dec__Fli libc stream 00000000 T _dec__Fii libc stream 00000000 T _dec__FUli libc stream 00000000 T _dec__FUii libc stream 00000000 T _hex__Fli libc stream 00000000 T _hex__Fii libc stream 00000000 T _hex__FUli libc stream 00000000 T _hex__FUii libc stream 00000000 T _oct__Fli libc stream 00000000 T _oct__Fii libc stream 00000000 T _oct__FUli libc stream 00000000 T _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.lite/jump.funcs.rx100644 1676 334 164122 5517624424 16456 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 rx 00000000 t ___old_re_compile_fastmap libcompat regex 00000000 t ___old_re_compile_pattern libcompat regex 00000000 T _re_exec libc rx 00000000 t ___old_re_match libcompat regex 00000000 t ___old_re_match_2 libcompat regex 00000000 t ___old_re_search libcompat regex 00000000 t ___old_re_search_2 libcompat regex 00000000 T _re_set_syntax libc rx 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 revcfrom 00000000 t ___old_regcomp libcompat regex 00000000 t ___old_regerror libcompat regex 00000000 t ___old_regexec libcompat regex 00000000 t ___old_regfree libcompat 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 ___old_re_set_registers libcompat 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 T _rx_compile libc rx 00000000 T _re_compile_fastmap libc rx 00000000 T _re_compile_pattern libc rx 00000000 T _re_match libc rx 00000000 T _re_match_2 libc rx 00000000 T _re_search libc rx 00000000 T _re_search_2 libc rx 00000000 T _re_set_registers libc rx 00000000 T _regcomp libc rx 00000000 T _regerror libc rx 00000000 T _regexec libc rx 00000000 T _regfree libc rx 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/jump.vars.rx100644 1676 334 24320 5517546166 16274 0ustar hjlisl00000098 K _h_errlist libc herror 0000023c K __sys_errlist libc _errlist 00000004 K __sys_nerr libc _errlist 000000c4 K __sys_siglist libc _siglist 00000004 D __DUMMY__ libgcc _new_handler 00000004 D ___ctype_b libc ctype-info 00000004 D ___ctype_tolower libc ctype-info 00000008 D ___ctype_toupper libc ctype-info 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000034 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000024 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 C _BC libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 C _UP libtermcap,libcurses tparam 00000000 D __DUMMY__ libtermcap curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000004 D __DUMMY__ libcurses curses 00000001 C _PC libtermcap,libcurses termcap 00000000 D __DUMMY__ libtermcap curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000001 D __DUMMY__ libcurses curses 00000003 D __DUMMY__ libcurses curses 00000200 D __DUMMY__ libcurses unctrl 00000008 C __DUMMY__ libdbm global 00000000 C __DUMMY__ libdbm global 00000008 D _h_errno libc herror 00000180 D __res libc res_init 00000008 D _rexecoptions libc rexec 0000014c D __IO_stdin_ libc stdfiles 0000014c D __IO_stdout_ libc stdfiles 0000014c D __IO_stderr_ libc stdfiles 0000014c D __DUMMY__ libc stdstrbufs 00000008 D __IO_list_all libc stdfiles 000000c0 D __DUMMY__ libc emulate 00000008 D ___environ libc __environ 00000008 D _errno libc errno 00000004 D _optarg libc getopt 00000004 D _optind libc getopt 00000008 D _opterr libc getopt 00000008 D _re_syntax_options libc rx 00000008 D ____brk_addr libc __brk 00000004 D _ospeed libtermcap termcap 00000004 D _tputs_baud_rate libtermcap termcap 00000008 D _tzname libc bsdtime 00000004 D _timezone libc bsdtime 00000004 D _daylight libc bsdtime 00000004 D __DUMMY__ libc rpc_comdata 00000020 D _rpc_createerr libc rpc_comdata 0000000c D __null_auth libc rpc_comdata 00000008 D __collate_info libc C-collate 00000008 D __ctype_info libc C-ctype 00000008 D __monetary_info libc C-monetary 00000008 D __numeric_info libc C-numeric 00000008 D __response_info libc C-response 00000290 D __time_info libc C-time 00001120 D ___exit_funcs libc atexit 00000004 D _stdin libc stdio 00000004 D _stdout libc stdio 00000008 D _stderr libc stdio 000001c0 D __DUMMY__ libc free 00000008 D __DUMMY__ libc malloc 000003f8 D __DUMMY__ libc mbtowc 00000008 D __DUMMY__ libc regex 00000040 D __res_opcodes libc res_debug 00000a30 D __res_resultcodes libc res_debug 00000768 D ___ttyname libc ttyname 000000fc D __DUMMY__ libcurses refresh 00000004 D __DUMMY__ libdbm global 00000008 D __DUMMY__ libdbm global 00000004 D __DUMMY__ libdbm global 00000004 D __DUMMY__ libdbm version 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000080 D __DUMMY__ libc stdstreams 00000004 D _h_nerr libc herrlist 000000a0 D __IO_file_jumps libc fileops 000000a0 D __IO_proc_jumps libc iopopen 000000a0 D __IO_str_jumps libc strops 000000d8 D __DUMMY__ libc streambuf 000000b0 D __DUMMY__ libc streambuf 000000b0 D __DUMMY__ libc streambuf 00000000 D __DUMMY__ libc strstream 00000000 D __DUMMY__ libc strstream 00000000 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc strstream 000000b0 D __DUMMY__ libc strstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000050 D __DUMMY__ libc fstream 00000004 D _optopt libc getopt 00000040 D _svc_fdset libc rpc_comdata 00000004 D __obstack libc obstack 00000004 C ___glob_closedir_hook libc glob 00000004 C ___glob_opendir_hook libc glob 00000004 C ___glob_readdir_hook libc glob 00000004 D __sigintr libc sigint 00000004 D __DUMMY__ libc msgcat ./libc-linux/jump/libm/ 40755 1676 334 0 5550056566 12731 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.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/libm/jump.ignore100644 1676 334 0 5341737321 15105 0ustar hjlisl./libc-linux/jump/libm/jump.vars100644 1676 334 66 5362350207 14626 0ustar hjlisl00000004 D _signgam libm lgamma ./libc-linux/jump/libm/jump.import100644 1676 334 27 5341737663 15176 0ustar hjlisl6008f200 A _errno libc ./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.undefs100644 1676 334 41 5550056550 15133 0ustar hjlisl600f95a8 D __NEEDS_SHRLIB_libc_4 ./libc-linux/jump/Makefile100644 1676 334 634 5544120047 13513 0ustar hjlisl# TOPDIR=.. include $(TOPDIR)/Makeconfig CLEAN_DIRS=libc libc.lite libm ifeq ($(MATH),true) DIRS=libm else ifeq ($(LITE),true) DIRS=libc.lite else DIRS=libc libm endif 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/math/ 40755 1676 334 0 5550053211 11744 5ustar hjlisl./libc-linux/math/Makefile100644 1676 334 637 5515544314 13501 0ustar hjlisl# # Makefile for som generic math functions. # override MATH=true override DEBUG=false override PROFILE=false TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I. DIRS:= SRC1S= __finite.c SRC2S = infnan.c isinf.c isnan.c rint.c copysign.c \ finite.c drem.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRCS:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/math/__finite.c100644 1676 334 2015 5344071321 13762 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 #undef __finite /* Return nonzero if VALUE is finite and not NaN. */ int DEFUN(__finite, (value), double value) { return !__isinf (value) && !__isnan (value); } ./libc-linux/math/copysign.c100644 1676 334 1766 5344071321 14055 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 #undef copysign function_alias(copysign, __copysign, double, (x, y), DEFUN(copysign, (x, y), double x AND double y)) ./libc-linux/math/finite.c100644 1676 334 1744 5344071322 13475 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 #undef finite function_alias(finite, __finite, int, (value), DEFUN(finite, (value), double value)) ./libc-linux/math/infnan.c100644 1676 334 1744 5344071322 13470 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 #undef infnan function_alias(infnan, __infnan, double, (error), DEFUN(infnan, (error), int error)) ./libc-linux/math/isinf.c100644 1676 334 1740 5344071322 13323 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 #undef isinf function_alias(isinf, __isinf, int, (value), DEFUN(isinf, (value), double value)) ./libc-linux/math/isnan.c100644 1676 334 1740 5344071322 13323 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 #undef isnan function_alias(isnan, __isnan, int, (value), DEFUN(isnan, (value), double value)) ./libc-linux/math/rint.c100644 1676 334 1723 5344071323 13171 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 #include #include #undef rint function_alias(rint, __rint, double, (x), DEFUN(rint, (x), double x)) ./libc-linux/math/drem.c100644 1676 334 1754 5346325056 13157 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 #undef drem function_alias(drem, __drem, double, (x, y), DEFUN(drem, (x, y), double x AND double y)) ./libc-linux/compat/ 40755 1676 334 0 5550056067 12312 5ustar hjlisl./libc-linux/compat/Makefile100644 1676 334 1122 5520361173 14035 0ustar hjlisl# # This is Makefile for some misc functions. # override SHARED=true override STATIC=false override DEBUG=false override PROFILE=false JUMP_LIB = libcompat TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules SHARED_LIB=$(SHARED_DIR)/libcompat/libcompat.a .PHONY: $(SHARED_LIB) INC_CFLAGS= -I. -I. -I$(TOPDIR)/misc DIRS=$(TARGET_ARCH) math SRC1S= __old_sel.c __old_glob.c __old_gdtbsz.c __undefined.c \ __warning.c # __old_regex.c aliases.c SRC2S=__old_libc.c ASMS= $(SRC1S:.c=.s) $(SRC2S:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/compat/__old_gdtbsz.c100644 1676 334 461 5340543214 15155 0ustar hjlisl#include #include #include "warning.h" /* Return the maximum number of file descriptors the current process could possibly have. Very old one. */ int DEFUN_VOID(____old_getdtablesize) { __LIBC_WARNING (getdtablesize); /* Very old value. We have now 256. */ return 32; } ./libc-linux/compat/__old_glob.c100644 1676 334 33140 5340543215 14644 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. */ /* IGNORE(@ */ #include /* @) */ #include "glob.h" #include #ifdef SHELL #include "config.h" #endif #include "warning.h" #include #ifdef __GNU_LIBRARY__ #include #endif #if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) extern int errno; #endif #if defined (USGr3) && !defined (DIRENT) #define DIRENT #endif /* USGr3 and not DIRENT. */ #if defined (Xenix) && !defined (SYSNDIR) #define SYSNDIR #endif /* Xenix and not SYSNDIR. */ #if defined (POSIX) || defined (DIRENT) || defined (__GNU_LIBRARY__) #ifdef USG #include #endif #include #else #if defined (USG) && !defined (sgi) #ifdef SYSNDIR #include #else /* not SYSNDIR */ #include "ndir.h" #endif /* SYSNDIR */ #else /* not USG */ #include #include #endif /* USG */ #undef dirent #define dirent direct #endif /* POSIX or DIRENT or __GNU_LIBRARY__ */ #if defined(__GNU_LIBRARY__) || !defined(POSIX) && !defined(USG) #ifdef linux #define D_NAMLEN(d) strlen((d)->d_name) #else #define D_NAMLEN(d) ((d)->d_namlen) #endif #else #define D_NAMLEN(d) strlen((d)->d_name) #endif #ifndef NULL #define NULL 0 #endif #if defined(POSIX) && !defined(__GNU_LIBRARY__) /* Posix does not require that the d_ino field be present, and some systems do not provide it. */ #define REAL_DIR_ENTRY(dp) 1 #else #define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0) #endif #if defined(__GNU_LIBRARY__) || defined(POSIX) #include #endif #if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__) #include #include #define STDC_STRINGS #else /* Not STDC_HEADERS and not __GNU_LIBRARY__. */ #ifdef USG #include #ifndef POSIX #include #endif /* Not POSIX. */ #define STDC_STRINGS #else /* Not USG. */ #ifdef NeXT #include #else /* Not NeXT. */ #include #endif /* NeXT. */ /* Declaring bcopy causes errors on systems whose declarations are different. If the declaration is omitted, everything works fine. */ #endif /* Not USG. */ extern char *malloc (); extern char *realloc (); extern void free (); extern void qsort (); #ifdef __GNUC__ __inline #endif static char * my_realloc (p, n) char *p; unsigned int n; { if (p == NULL) return malloc (n); return realloc (p, n); } #define realloc my_realloc #define strcoll strcmp #endif /* Not STDC_HEADERS or __GNU_LIBRARY__. */ #ifndef STDC_STRINGS #define memcpy(d, s, n) bcopy((s), (d), (n)) #define strrchr rindex /* memset is only used for zero here, but let's be paranoid. */ #define memset(s, better_be_zero, n) \ ((void) ((better_be_zero) == 0 ? (bzero((s), (n)), 0) : (abort(), 0))) #endif #if !defined(__alloca) && !defined(__GNU_LIBRARY__) #ifdef __GNUC__ #define alloca __builtin_alloca #else /* Not GCC. */ #ifdef sparc #include #else /* Not sparc. */ extern char *alloca (); #endif /* sparc. */ #endif /* GCC. */ #define __alloca alloca #endif #ifndef __STDC__ #undef size_t #define size_t unsigned int #endif static int EXFUN(glob_pattern_p, (CONST char *pattern, int quote)); static int EXFUN(glob_in_dir, (CONST char *pattern, CONST char *directory, int flags, int EXFUN((*errfunc), (CONST char *, int)), glob_t *pglob)); static int EXFUN(prefix_array, (CONST char *prefix, char **array, size_t n)); static int EXFUN(collated_compare, (CONST PTR, CONST PTR)); /* Do glob searching for PATTERN, placing results in PGLOB. The bits defined above may be set in FLAGS. If a directory cannot be opened or read and ERRFUNC is not nil, it is called with the pathname that caused the error, and the `errno' value from the failing call; if it returns non-zero `glob' returns GLOB_ABEND; if it returns zero, the error is ignored. If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned. Otherwise, `glob' returns zero. */ int DEFUN(__old_glob, (pattern, flags, errfunc, pglob), CONST char *pattern AND int flags AND int EXFUN((*errfunc), (CONST char *, int)) AND glob_t *pglob) { CONST char *filename; char *dirname; size_t dirlen; int status; int oldcount; __LIBC_WARNING (glob); if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0) { errno = EINVAL; return -1; } /* Find the filename. */ filename = strrchr(pattern, '/'); if (filename == NULL) { filename = pattern; dirname = (char *) "."; dirlen = 0; } else if (filename == pattern) { /* "/pattern". */ dirname = (char *) "/"; dirlen = 1; ++filename; } else { dirlen = filename - pattern; dirname = (char *) __alloca(dirlen + 1); memcpy(dirname, pattern, dirlen); dirname[dirlen] = '\0'; ++filename; } if (filename[0] == '\0' && dirlen > 1) /* "pattern/". Expand "pattern", appending slashes. */ return glob(dirname, flags|GLOB_MARK, errfunc, pglob); if (!(flags & GLOB_APPEND)) { pglob->gl_pathc = 0; pglob->gl_pathv = NULL; } oldcount = pglob->gl_pathc; if (glob_pattern_p(dirname, !(flags & GLOB_NOESCAPE))) { /* The directory name contains metacharacters, so we have to glob for the directory, and then glob for the pattern in each directory found. */ glob_t dirs; register int i; status = glob(dirname, ((flags & (GLOB_ERR|GLOB_NOCHECK|GLOB_NOESCAPE)) | GLOB_NOSORT), errfunc, &dirs); if (status != 0) return status; /* We have successfully globbed the preceding directory name. For each name we found, call glob_in_dir on it and FILENAME, appending the results to PGLOB. */ for (i = 0; i < dirs.gl_pathc; ++i) { int oldcount; #ifdef SHELL { /* Make globbing interruptible in the bash shell. */ extern int interrupt_state; if (interrupt_state) { globfree (&dirs); globfree (&files); return GLOB_ABEND; } } #endif /* SHELL. */ oldcount = pglob->gl_pathc; status = glob_in_dir(filename, dirs.gl_pathv[i], (flags | GLOB_APPEND) & ~GLOB_NOCHECK, errfunc, pglob); if (status == GLOB_NOMATCH) /* No matches in this directory. Try the next. */ continue; if (status != 0) { globfree (&dirs); globfree (pglob); return status; } /* Stick the directory on the front of each name. */ if (prefix_array(dirs.gl_pathv[i], &pglob->gl_pathv[oldcount], pglob->gl_pathc - oldcount)) { globfree (&dirs); globfree (pglob); return GLOB_NOSPACE; } } if (pglob->gl_pathc == oldcount) /* No matches. */ if (flags & GLOB_NOCHECK) { CONST size_t len = strlen (pattern) + 1; char *patcopy = (char *) malloc (len); if (patcopy == NULL) return GLOB_NOSPACE; memcpy (patcopy, pattern, len); pglob->gl_pathv = (char **) realloc(pglob->gl_pathv, (pglob->gl_pathc + ((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) + 1 + 1) * sizeof(char *)); if (pglob->gl_pathv == NULL) { free (patcopy); return GLOB_NOSPACE; } if (flags & GLOB_DOOFFS) while (pglob->gl_pathc < pglob->gl_offs) pglob->gl_pathv[pglob->gl_pathc++] = NULL; pglob->gl_pathv[pglob->gl_pathc++] = patcopy; return 0; } else return GLOB_NOMATCH; } else { status = glob_in_dir(filename, dirname, flags, errfunc, pglob); if (status != 0) return status; if (dirlen > 0) { /* Stick the directory on the front of each name. */ if (prefix_array(dirname, &pglob->gl_pathv[oldcount], pglob->gl_pathc - oldcount)) { globfree (pglob); return GLOB_NOSPACE; } } } if (!(flags & GLOB_NOSORT)) qsort((PTR) &pglob->gl_pathv[oldcount], pglob->gl_pathc - oldcount, sizeof(char *), collated_compare); return 0; } /* Free storage allocated in PGLOB by a previous `glob' call. */ void DEFUN(__old_globfree, (pglob), register glob_t *pglob) { __LIBC_WARNING (globfree); if (pglob->gl_pathv != NULL) { register int i; for (i = 0; i < pglob->gl_pathc; ++i) if (pglob->gl_pathv[i] != NULL) free((PTR) pglob->gl_pathv[i]); free((PTR) pglob->gl_pathv); } } /* Do a collated comparison of A and B. */ static int DEFUN(collated_compare, (a, b), CONST PTR a AND CONST PTR b) { CONST char *CONST s1 = *(CONST char *CONST *CONST) a; CONST char *CONST s2 = *(CONST char *CONST *CONST) b; if (s1 == s2) return 0; if (s1 == NULL) return 1; if (s2 == NULL) return -1; return strcoll (s1, s2); } /* Prepend PREFIX to each of N members of ARRAY, replacing ARRAY's elements in place. Return nonzero if out of memory, zero if successful. A slash is inserted between PREFIX and each elt of ARRAY. Each old element of ARRAY is freed. */ static int DEFUN(prefix_array, (prefix, array, n), CONST char *prefix AND char **array AND CONST size_t n) { register size_t i; CONST size_t prelen = strlen(prefix); for (i = 0; i < n; ++i) { CONST size_t eltlen = strlen(array[i]) + 1; char *new = (char *) malloc(prelen + 1 + eltlen); if (new == NULL) { while (i > 0) free((PTR) array[--i]); return 1; } memcpy(new, prefix, prelen); new[prelen] = '/'; memcpy(&new[prelen + 1], array[i], eltlen); free((PTR) array[i]); array[i] = new; } return 0; } /* Return nonzero if PATTERN contains any metacharacters. Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ static int DEFUN(glob_pattern_p, (pattern, quote), CONST char *pattern AND CONST int quote) { register CONST char *p; int open = 0; for (p = pattern; *p != '\0'; ++p) switch (*p) { case '?': case '*': return 1; case '\\': if (quote) ++p; break; case '[': open = 1; break; case ']': if (open) return 1; break; } return 0; } /* Like `glob', but PATTERN is a final pathname component, and matches are searched for in DIRECTORY. The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done. The GLOB_APPEND flag is assumed to be set (always appends). */ static int DEFUN(glob_in_dir, (pattern, directory, flags, errfunc, pglob), CONST char *pattern AND CONST char *directory AND int flags AND int EXFUN((*errfunc), (CONST char *, int)) AND glob_t *pglob) { register DIR *stream; register struct dirent *d; struct globlink { struct globlink *next; char *name; }; struct globlink *names = NULL; size_t nfound = 0; if (!glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE))) { stream = NULL; flags |= GLOB_NOCHECK; } else { stream = opendir(directory); if (stream == NULL) { if ((errfunc != NULL && (*errfunc)(directory, errno)) || (flags & GLOB_ERR)) return GLOB_ABEND; } else while ((d = readdir(stream)) != NULL) if (REAL_DIR_ENTRY (d) && fnmatch(pattern, d->d_name, (!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)) == 0) { struct globlink *new = (struct globlink *) __alloca(sizeof (struct globlink)); size_t len = D_NAMLEN (d); new->name = (char *) malloc(len + ((flags & GLOB_MARK) ? 1 : 0) + 1); if (new->name == NULL) goto memory_error; memcpy ((PTR) new->name, d->d_name, len); if (flags & GLOB_MARK) new->name[len++] = '/'; new->name[len] = '\0'; new->next = names; names = new; ++nfound; } } if (nfound == 0 && (flags & GLOB_NOCHECK)) { size_t len = strlen (pattern); nfound = 1; names = (struct globlink *) __alloca (sizeof (struct globlink)); names->next = NULL; names->name = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1); if (names->name == NULL) goto memory_error; memcpy (names->name, pattern, len); if (flags & GLOB_MARK) names->name[len++] = '/'; names->name[len] = '\0'; } pglob->gl_pathv = (char **) realloc(pglob->gl_pathv, (pglob->gl_pathc + ((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) + nfound + 1) * sizeof(char *)); if (pglob->gl_pathv == NULL) goto memory_error; if (flags & GLOB_DOOFFS) while (pglob->gl_pathc < pglob->gl_offs) pglob->gl_pathv[pglob->gl_pathc++] = NULL; for (; names != NULL; names = names->next) pglob->gl_pathv[pglob->gl_pathc++] = names->name; pglob->gl_pathv[pglob->gl_pathc] = NULL; if (stream != NULL) { int save = errno; (void) closedir (stream); errno = save; } return nfound == 0 ? GLOB_NOMATCH : 0; memory_error: { int save = errno; (void) closedir (stream); errno = save; } while (names != NULL) { if (names->name != NULL) free((PTR) names->name); names = names->next; } return GLOB_NOSPACE; } ./libc-linux/compat/__old_sel.c100644 1676 334 346 5340543215 14446 0ustar hjlisl#include #include "warning.h" int __old_select (int nd, fd_set * in, fd_set * out, fd_set * ex, struct timeval * tv) { __LIBC_WARNING (select); if (nd > 32) nd = 32; return __select (nd, in, out, ex, tv); } ./libc-linux/compat/__undefined.c100644 1676 334 1110 5340543215 14774 0ustar hjlisl#include #include #ifdef USE_CONSOLE #define OUT_FILE_PTR fp #else #define OUT_FILE_PTR stderr #endif /* USE_CONSOLE */ void __libc_undefined () { #ifdef USE_CONSOLE static FILE *fp = NULL; if (!fp) fp = fopen ("/dev/console", "w"); if (!fp) fp = stderr; else setbuf (fp, NULL); #endif /* USE_CONSOLE */ fprintf (OUT_FILE_PTR, "Undefined C library functions:\n"); fprintf (OUT_FILE_PTR, "\t1. light C shared image (Use the real one instead.)\n"); #if 0 \t2. libnet.a (Relink with -lnet.) \t3. librpc.a (Relink with -lrpc.) #endif exit (-1); } ./libc-linux/compat/__warning.c100644 1676 334 661 5340543215 14472 0ustar hjlisl#include #ifdef USE_CONSOLE #define OUT_FILE_PTR fp #else #define OUT_FILE_PTR stderr #endif /* USE_CONSOLE */ void __libc_warning (const char *name) { #if 0 #ifdef USE_CONSOLE static FILE *fp = NULL; if (!fp) fp = fopen ("/dev/console", "w"); if (!fp) fp = stderr; else setbuf (fp, NULL); #endif /* USE_CONSOLE */ fprintf (OUT_FILE_PTR, "Old version of C library function is used: `%s'.\n", name); #endif } ./libc-linux/compat/glob.h100644 1676 334 5337 5340543215 13504 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. */ #ifndef _GLOB_H #define _GLOB_H 1 #include /* Bits set in the FLAGS argument to `glob'. */ #define GLOB_ERR (1 << 0)/* Return on read errors. */ #define GLOB_MARK (1 << 1)/* Append a slash to each name. */ #define GLOB_NOSORT (1 << 2)/* Don't sort the names. */ #define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */ #define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */ #define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */ #define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */ #define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */ #define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \ GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND|GLOB_PERIOD) /* Error returns from `glob'. */ #define GLOB_NOSPACE 1 /* Ran out of memory. */ #define GLOB_ABEND 2 /* Read error. */ #define GLOB_NOMATCH 3 /* No matches found. */ /* Structure describing a globbing run. */ typedef struct { int gl_pathc; /* Count of paths matched by the pattern. */ char **gl_pathv; /* List of matched pathnames. */ int gl_offs; /* Slots to reserve in `gl_pathv'. */ } glob_t; __BEGIN_DECLS /* Do glob searching for PATTERN, placing results in PGLOB. The bits defined above may be set in FLAGS. If a directory cannot be opened or read and ERRFUNC is not nil, it is called with the pathname that caused the error, and the `errno' value from the failing call; if it returns non-zero `glob' returns GLOB_ABEND; if it returns zero, the error is ignored. If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned. Otherwise, `glob' returns zero. */ extern int glob __P ((const char *__pattern, int __flags, int (*__errfunc)(const char *, int), glob_t *__pglob)); /* Free storage allocated in PGLOB by a previous `glob' call. */ extern void globfree __P ((glob_t *__pglob)); __END_DECLS #endif /* glob.h */ ./libc-linux/compat/warning.h100644 1676 334 433 5340543217 14200 0ustar hjlisl#ifndef WARNING_H #define WARNING_H extern void __libc_warning (const char *); #define __LIBC_WARNING(name) { \ static int __old_##name##_warned = 0; \ if (!__old_##name##_warned) { \ __old_##name##_warned++; \ __libc_warning (#name); \ } \ } #endif /* WARNING_H */ ./libc-linux/compat/i386/ 40755 1676 334 0 5524047004 12773 5ustar hjlisl./libc-linux/compat/i386/Makefile100644 1676 334 702 5516331105 14506 0ustar hjlisl# # This is Makefile for some misc functions. # override SHARED=true override STATIC=false override DEBUG=false override PROFILE=false JUMP_LIB = libcompat TOPDIR=../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules SHARED_LIB=$(SHARED_DIR)/libcompat/libcompat.a .PHONY: $(SHARED_LIB) INC_CFLAGS= DIRS:= SRCS= __old_sigjmp.c __old__uname.c __old__ghn.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/compat/i386/__old_sigsj.c100644 1676 334 3315 5465534401 15517 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 #include /* Store the calling environment in ENV, also saving the signal mask if SAVEMASK is nonzero. Return 0. */ int DEFUN(__old_sigsetjmp, (env, savemask), sigjmp_buf env AND int savemask) { if (savemask) env[0].__savemask = sigprocmask(SIG_BLOCK, (sigset_t *) NULL, &env[0].__sigmask) == 0; else env[0].__savemask = 0; #define REGS \ REG (bx);\ REG (si);\ REG (di) /* Save the general registers. */ #define REG(xx) asm volatile ("movl %%e" #xx ",%0" : \ "=m" ((long int) ((env[0].__jmpbuf)[0].__##xx)) : ) REGS; /* Save the return PC. */ (env[0].__jmpbuf)[0].__pc = (PTR) ((PTR *) &env)[-1]; /* Save caller's FP, not our own. */ (env[0].__jmpbuf)[0].__bp = (PTR) ((PTR *) &env)[-2]; /* Save caller's SP, not our own. */ (env[0].__jmpbuf)[0].__sp = (PTR) &env; return 0; } ./libc-linux/compat/i386/__old__uname.c100644 1676 334 701 5536013040 15606 0ustar hjlisl#include #include #include int __old__uname (struct old_utsname *buf) { register int res; #if defined(__PIC__) || defined(__pic__) __asm__("pushl %%ebx\n\t" "movl %%ecx,%%ebx\n\t" "int $0x80\n\t" "popl %%ebx" :"=a" (res) :"0" (SYS_olduname),"c" (buf)); #else __asm__("int $0x80" :"=a" (res) :"0" (SYS_olduname),"b" (buf)); #endif if (res>=0) return res; errno = -res; return -1; } ./libc-linux/compat/i386/__old__ghn.c100644 1676 334 606 5372250372 15272 0ustar hjlisl#include #include #include #include int __old__gethostname(char *name, size_t len) { struct old_utsname uts; if (name == NULL) { errno = EINVAL; return -1; } if (__old__uname(&uts) == -1) return -1; if (strlen(uts.nodename)+1 > len) { errno = EINVAL; return -1; } strcpy(name, uts.nodename); return 0; } ./libc-linux/compat/i386/__old_sigjmp.c100644 1676 334 3334 5465534363 15701 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 #include /* Store the calling environment in ENV, also saving the signal mask if SAVEMASK is nonzero. Return 0. */ int DEFUN(__old_sigsetjmp, (env, savemask), sigjmp_buf env AND int savemask) { if (savemask) env[0].__mask_was_saved = sigprocmask(SIG_BLOCK, (sigset_t *) NULL, &env[0].__saved_mask) == 0; else env[0].__mask_was_saved = 0; #define REGS \ REG (bx);\ REG (si);\ REG (di) /* Save the general registers. */ #define REG(xx) asm volatile ("movl %%e" #xx ",%0" : \ "=m" ((long int) ((env[0].__jmpbuf)[0].__##xx)) : ) REGS; /* Save the return PC. */ (env[0].__jmpbuf)[0].__pc = (PTR) ((PTR *) &env)[-1]; /* Save caller's FP, not our own. */ (env[0].__jmpbuf)[0].__bp = (PTR) ((PTR *) &env)[-2]; /* Save caller's SP, not our own. */ (env[0].__jmpbuf)[0].__sp = (PTR) &env; return 0; } ./libc-linux/compat/__old_libc.c100644 1676 334 114 5354446124 14573 0ustar hjlisl#include symbol_alias(_NEEDS_SHRLIB_libc_4, __jump_libc_v4); ./libc-linux/compat/math/ 40755 1676 334 0 5550056077 13244 5ustar hjlisl./libc-linux/compat/math/__old_libm.c100644 1676 334 114 5354446124 15536 0ustar hjlisl#include symbol_alias(_NEEDS_SHRLIB_libm_4, __jump_libm_v4); ./libc-linux/compat/math/Makefile100644 1676 334 570 5516537722 14766 0ustar hjlisl# # This is Makefile of the math lib for Linux # MATH=true override STATIC=false override SHARED=false override DEBUG=false override PROFILE=false TOPDIR=../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules DIRS:= SRC1S= SRC2S= __old_libm.c SRCS=$(SRC1S) $(SRC2S) ASMS= $(SRCS:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES:=$(SRC2S:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/compat/m68k/ 40755 1676 334 0 5521072113 13063 5ustar hjlisl./libc-linux/compat/m68k/Makefile100644 1676 334 702 5521072113 14577 0ustar hjlisl# # This is Makefile for some misc functions. # override SHARED=true override STATIC=false override DEBUG=false override PROFILE=false JUMP_LIB = libcompat TOPDIR=../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules SHARED_LIB=$(SHARED_DIR)/libcompat/libcompat.a .PHONY: $(SHARED_LIB) INC_CFLAGS= DIRS:= SRCS= __old_sigjmp.c __old__uname.c __old__ghn.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets ./libc-linux/compat/m68k/Makefile.orig100644 1676 334 0 5521072113 15465 0ustar hjlisl./libc-linux/compat/m68k/__old__ghn.c100644 1676 334 606 5521072113 15355 0ustar hjlisl#include #include #include #include int __old__gethostname(char *name, size_t len) { struct old_utsname uts; if (name == NULL) { errno = EINVAL; return -1; } if (__old__uname(&uts) == -1) return -1; if (strlen(uts.nodename)+1 > len) { errno = EINVAL; return -1; } strcpy(name, uts.nodename); return 0; } ./libc-linux/compat/m68k/__old__ghn.c.orig100644 1676 334 0 5521072113 16240 0ustar hjlisl./libc-linux/compat/m68k/__old__uname.c100644 1676 334 527 5521072113 15710 0ustar hjlisl#include #include #include int __old__uname (struct old_utsname *buf) { register int res asm ("d0") = SYS_olduname; __asm__("movel %2,d1\n\t" "trap #0" :"=g" (res) :"0" (SYS_olduname),"g" (buf) : "d1"); if (res>=0) return res; errno = -res; return -1; } ./libc-linux/compat/m68k/__old__uname.c.orig100644 1676 334 0 5521072113 16571 0ustar hjlisl./libc-linux/compat/m68k/__old_sigjmp.c100644 1676 334 4764 5521072113 15764 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 #include /* Store the calling environment in ENV, also saving the signal mask if SAVEMASK is nonzero. Return 0. */ int DEFUN(__old_sigsetjmp, (env, savemask), sigjmp_buf env AND int savemask) { if (savemask) env[0].__mask_was_saved = sigprocmask(SIG_BLOCK, (sigset_t *) NULL, &env[0].__saved_mask) == 0; else env[0].__mask_was_saved = 0; /* Save data registers D1 through D7. */ asm volatile("movem%.l d1-d7, %0" : : "m" (env[0].__jmpbuf[0].__dregs[0])); /* Save return address in place of register A0. */ env[0].__jmpbuf[0].__aregs[0] = (PTR) ((PTR *) &env)[-1]; /* Save address registers A1 through A5. */ asm volatile("movem%.l a1-a5, %0" : : "m" (env[0].__jmpbuf[0].__aregs[1])); /* Save caller's FP, not our own. */ env[0].__jmpbuf[0].__fp = (PTR) ((PTR *) &env)[-2]; /* XXX FIX ME */ /* * The Amiga GCC uses A5 as the frame pointer, rather than A6, so this * code loses on that compiler, since this code expects A6 to be the * frame pointer. * This change fix will only be compiled occur if __amiga__ is defined. * * The long term solution is to create a "linux/68k" gcc which uses a6 * as the frame pointer. */ #ifdef __amiga__ env[0].__jmpbuf[0].__aregs[5] = env[0].__jmpbuf[0].__fp; asm volatile ("move%.l a6, %0" : : "m" (env[0].__jmpbuf[0].__fp)); #endif /* XXX */ /* Save caller's SP, not our own. */ env[0].__jmpbuf[0].__sp = (PTR) &env; #if defined(__HAVE_68881__) || defined(__HAVE_FPU__) /* Save floating-point (68881) registers FP0 through FP7. */ asm volatile("fmovem%.x fp0-fp7, %0" : : "m" (env[0].__jmpbuf[0].__fpregs[0])); #endif return 0; } ./libc-linux/compat/m68k/__old_sigjmp.c.orig100644 1676 334 0 5521072113 16616 0ustar hjlisl./libc-linux/compat/regex.diff100644 1676 334 2440 5372570402 14347 0ustar hjlisl*** regex.c.orig Fri May 7 14:43:30 1993 --- regex.c Fri May 7 14:44:41 1993 *************** *** 24,30 **** --- 24,32 ---- #pragma alloca #endif + #ifndef _GNU_SOURCE #define _GNU_SOURCE + #endif /* We need this for `regex.h', and perhaps for the Emacs include files. */ #include *************** *** 4679,4685 **** /* Entry points compatible with 4.2 BSD regex library. We don't define them if this is an Emacs or POSIX compilation. */ ! #if !defined (emacs) && !defined (_POSIX_SOURCE) /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer re_comp_buf; --- 4681,4687 ---- /* Entry points compatible with 4.2 BSD regex library. We don't define them if this is an Emacs or POSIX compilation. */ ! #if (!defined (emacs) && !defined (_POSIX_SOURCE)) || defined(USE_BSD_REGEX) /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer re_comp_buf; *************** *** 4784,4789 **** --- 4786,4792 ---- /* regex_compile will allocate the space for the compiled pattern. */ preg->buffer = 0; preg->allocated = 0; + preg->used = 0; /* Don't bother to use a fastmap when searching. This simplifies the REG_NEWLINE case: if we used a fastmap, we'd have to put all the ./libc-linux/compat/regex.h100644 1676 334 43754 5372550300 13716 0ustar hjlisl/* Definitions for data structures and routines for the regular expression library, version 0.12. Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. This program 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 program 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __REGEXP_LIBRARY_H__ #define __REGEXP_LIBRARY_H__ #include __BEGIN_DECLS /* POSIX says that must be included before . */ /* The following bits are used to determine the regexp syntax we recognize. The set/not-set meanings are chosen so that Emacs syntax remains the value 0. The bits are given in alphabetical order, and the definitions shifted by one from the previous bit; thus, when we add or remove a bit, only one other definition need change. */ typedef unsigned reg_syntax_t; /* If this bit is not set, then \ inside a bracket expression is literal. If set, then such a \ quotes the following character. */ #define RE_BACKSLASH_ESCAPE_IN_LISTS (1) /* If this bit is not set, then + and ? are operators, and \+ and \? are literals. If set, then \+ and \? are operators and + and ? are literals. */ #define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) /* If this bit is set, then character classes are supported. They are: [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. If not set, then character classes are not supported. */ #define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) /* If this bit is set, then ^ and $ are always anchors (outside bracket expressions, of course). If this bit is not set, then it depends: ^ is an anchor if it is at the beginning of a regular expression or after an open-group or an alternation operator; $ is an anchor if it is at the end of a regular expression, or before a close-group or an alternation operator. This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because POSIX draft 11.2 says that * etc. in leading positions is undefined. We already implemented a previous draft which made those constructs invalid, though, so we haven't changed the code back. */ #define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) /* If this bit is set, then special characters are always special regardless of where they are in the pattern. If this bit is not set, then special characters are special only in some contexts; otherwise they are ordinary. Specifically, * + ? and intervals are only special when not after the beginning, open-group, or alternation operator. */ #define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) /* If this bit is set, then *, +, ?, and { cannot be first in an re or immediately after an alternation or begin-group operator. */ #define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) /* If this bit is set, then . matches newline. If not set, then it doesn't. */ #define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) /* If this bit is set, then . doesn't match NUL. If not set, then it does. */ #define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) /* If this bit is set, nonmatching lists [^...] do not match newline. If not set, they do. */ #define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) /* If this bit is set, either \{...\} or {...} defines an interval, depending on RE_NO_BK_BRACES. If not set, \{, \}, {, and } are literals. */ #define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) /* If this bit is set, +, ? and | aren't recognized as operators. If not set, they are. */ #define RE_LIMITED_OPS (RE_INTERVALS << 1) /* If this bit is set, newline is an alternation operator. If not set, newline is literal. */ #define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) /* If this bit is set, then `{...}' defines an interval, and \{ and \} are literals. If not set, then `\{...\}' defines an interval. */ #define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) /* If this bit is set, (...) defines a group, and \( and \) are literals. If not set, \(...\) defines a group, and ( and ) are literals. */ #define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) /* If this bit is set, then \ matches . If not set, then \ is a back-reference. */ #define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) /* If this bit is set, then | is an alternation operator, and \| is literal. If not set, then \| is an alternation operator, and | is literal. */ #define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) /* If this bit is set, then an ending range point collating higher than the starting range point, as in [z-a], is invalid. If not set, then when ending range point collates higher than the starting range point, the range is ignored. */ #define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) /* If this bit is set, then an unmatched ) is ordinary. If not set, then an unmatched ) is invalid. */ #define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) /* This global variable defines the particular regexp syntax to use (for some interfaces). When a regexp is compiled, the syntax used is stored in the pattern buffer, so changing this does not affect already-compiled regexps. */ extern reg_syntax_t re_syntax_options; /* Define combinations of the above bits for the standard possibilities. (The [[[ comments delimit what gets put into the Texinfo file, so don't delete them!) */ /* [[[begin syntaxes]]] */ #define RE_SYNTAX_EMACS 0 #define RE_SYNTAX_AWK \ (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ | RE_NO_BK_PARENS | RE_NO_BK_REFS \ | RE_NO_BK_VAR | RE_NO_EMPTY_RANGES \ | RE_UNMATCHED_RIGHT_PAREN_ORD) #define RE_SYNTAX_POSIX_AWK \ (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) #define RE_SYNTAX_GREP \ (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ | RE_NEWLINE_ALT) #define RE_SYNTAX_EGREP \ (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ | RE_NO_BK_VBAR) #define RE_SYNTAX_POSIX_EGREP \ (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) #define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC /* Syntax bits common to both basic and extended POSIX regex syntax. */ #define _RE_SYNTAX_POSIX_COMMON \ (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ | RE_INTERVALS | RE_NO_EMPTY_RANGES) #define RE_SYNTAX_POSIX_BASIC \ (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) /* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this isn't minimal, since other operators, such as \`, aren't disabled. */ #define RE_SYNTAX_POSIX_MINIMAL_BASIC \ (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) #define RE_SYNTAX_POSIX_EXTENDED \ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ | RE_UNMATCHED_RIGHT_PAREN_ORD) /* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ #define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ | RE_NO_BK_PARENS | RE_NO_BK_REFS \ | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) /* [[[end syntaxes]]] */ /* Maximum number of duplicates an interval can allow. Some systems (erroneously) define this in other header files, but we want our value, so remove any previous define. */ #ifdef RE_DUP_MAX #undef RE_DUP_MAX #endif #define RE_DUP_MAX ((1 << 15) - 1) /* POSIX `cflags' bits (i.e., information for `regcomp'). */ /* If this bit is set, then use extended regular expression syntax. If not set, then use basic regular expression syntax. */ #define REG_EXTENDED 1 /* If this bit is set, then ignore case when matching. If not set, then case is significant. */ #define REG_ICASE (REG_EXTENDED << 1) /* If this bit is set, then anchors do not match at newline characters in the string. If not set, then anchors do match at newlines. */ #define REG_NEWLINE (REG_ICASE << 1) /* If this bit is set, then report only success or fail in regexec. If not set, then returns differ between not matching and errors. */ #define REG_NOSUB (REG_NEWLINE << 1) /* POSIX `eflags' bits (i.e., information for regexec). */ /* If this bit is set, then the beginning-of-line operator doesn't match the beginning of the string (presumably because it's not the beginning of a line). If not set, then the beginning-of-line operator does match the beginning of the string. */ #define REG_NOTBOL 1 /* Like REG_NOTBOL, except for the end-of-line. */ #define REG_NOTEOL (1 << 1) /* If any error codes are removed, changed, or added, update the `re_error_msg' table in regex.c. */ typedef enum { REG_NOERROR = 0, /* Success. */ REG_NOMATCH, /* Didn't find a match (for regexec). */ /* POSIX regcomp return error codes. (In the order listed in the standard.) */ REG_BADPAT, /* Invalid pattern. */ REG_ECOLLATE, /* Not implemented. */ REG_ECTYPE, /* Invalid character class name. */ REG_EESCAPE, /* Trailing backslash. */ REG_ESUBREG, /* Invalid back reference. */ REG_EBRACK, /* Unmatched left bracket. */ REG_EPAREN, /* Parenthesis imbalance. */ REG_EBRACE, /* Unmatched \{. */ REG_BADBR, /* Invalid contents of \{\}. */ REG_ERANGE, /* Invalid range end. */ REG_ESPACE, /* Ran out of memory. */ REG_BADRPT, /* No preceding re for repetition op. */ /* Error codes we've added. */ REG_EEND, /* Premature end. */ REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ } reg_errcode_t; /* This data structure represents a compiled pattern. Before calling the pattern compiler, the fields `buffer', `allocated', `fastmap', `translate', and `no_sub' can be set. After the pattern has been compiled, the `re_nsub' field is available. All other fields are private to the regex routines. */ struct re_pattern_buffer { /* [[[begin pattern_buffer]]] */ /* Space that holds the compiled pattern. It is declared as `unsigned char *' because its elements are sometimes used as array indexes. */ unsigned char *buffer; /* Number of bytes to which `buffer' points. */ unsigned long allocated; /* Number of bytes actually used in `buffer'. */ unsigned long used; /* Syntax setting with which the pattern was compiled. */ reg_syntax_t syntax; /* Pointer to a fastmap, if any, otherwise zero. re_search uses the fastmap, if there is one, to skip over impossible starting points for matches. */ char *fastmap; /* Either a translate table to apply to all characters before comparing them, or zero for no translation. The translation is applied to a pattern when it is compiled and to a string when it is matched. */ char *translate; /* Number of subexpressions found by the compiler. */ size_t re_nsub; /* Zero if this pattern cannot match the empty string, one else. Well, in truth it's used only in `re_search_2', to see whether or not we should use the fastmap, so we don't set this absolutely perfectly; see `re_compile_fastmap' (the `duplicate' case). */ unsigned can_be_null : 1; /* If REGS_UNALLOCATED, allocate space in the `regs' structure for `max (RE_NREGS, re_nsub + 1)' groups. If REGS_REALLOCATE, reallocate space if necessary. If REGS_FIXED, use what's there. */ #define REGS_UNALLOCATED 0 #define REGS_REALLOCATE 1 #define REGS_FIXED 2 unsigned regs_allocated : 2; /* Set to zero when regex_compile compiles a pattern; set to one by re_compile_fastmap when it updates the fastmap, if any. */ unsigned fastmap_accurate : 1; /* If set, regexec reports only success or failure and does not return anything in pmatch. */ unsigned no_sub : 1; /* If set, a beginning-of-line anchor doesn't match at the beginning of the string. */ unsigned not_bol : 1; /* Similarly for an end-of-line anchor. */ unsigned not_eol : 1; /* If true, an anchor at a newline matches. */ unsigned newline_anchor : 1; /* [[[end pattern_buffer]]] */ }; typedef struct re_pattern_buffer regex_t; /* search.c (search_buffer) in Emacs needs this one opcode value. It is defined both in `regex.c' and here. */ #define RE_EXACTN_VALUE 1 /* Type for byte offsets within the string. POSIX mandates this. */ typedef int regoff_t; /* This is the structure we store register match data in. See regex.texinfo for a full description of what registers match. */ struct re_registers { unsigned num_regs; regoff_t *start; regoff_t *end; }; /* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, `re_match_2' returns information about at least this many registers the first time a `regs' structure is passed. */ #ifndef RE_NREGS #define RE_NREGS 30 #endif /* POSIX specification for registers. Aside from the different names than `re_registers', POSIX uses an array of structures, instead of a structure of arrays. */ typedef struct { regoff_t rm_so; /* Byte offset from string's start to substring's start. */ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ } regmatch_t; /* Declarations for routines. */ /* To avoid duplicating every routine declaration -- once with a prototype (if we are ANSI), and once without (if we aren't) -- we use the following macro to declare argument types. This unfortunately clutters up the declarations a bit, but I think it's worth it. We also have to undo `const' if we are not ANSI. */ /* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ extern reg_syntax_t re_set_syntax __P ((reg_syntax_t syntax)); /* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ extern __const char *re_compile_pattern __P ((__const char *pattern, int length, struct re_pattern_buffer *buffer)); /* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ extern int re_compile_fastmap __P ((struct re_pattern_buffer *buffer)); /* Search in the string STRING (with length LENGTH) for the pattern compiled into BUFFER. Start searching at position START, for RANGE characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ extern int re_search __P ((struct re_pattern_buffer *buffer, __const char *string, int length, int start, int range, struct re_registers *regs)); /* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ extern int re_search_2 __P ((struct re_pattern_buffer *buffer, __const char *string1, int length1, __const char *string2, int length2, int start, int range, struct re_registers *regs, int stop)); /* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ extern int re_match __P ((struct re_pattern_buffer *buffer, __const char *string, int length, int start, struct re_registers *regs)); /* Relates to `re_match' as `re_search_2' relates to `re_search'. */ extern int re_match_2 __P ((struct re_pattern_buffer *buffer, __const char *string1, int length1, __const char *string2, int length2, int start, struct re_registers *regs, int stop)); /* Set REGS to hold NUM_REGS registers, storing them in STARTS and ENDS. Subsequent matches using BUFFER and REGS will use this memory for recording register information. STARTS and ENDS must be allocated with malloc, and must each be at least `NUM_REGS * sizeof (regoff_t)' bytes long. If NUM_REGS == 0, then subsequent matches should allocate their own register data. Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ extern void re_set_registers __P ((struct re_pattern_buffer *buffer, struct re_registers *regs, unsigned num_regs, regoff_t *starts, regoff_t *ends)); /* 4.2 bsd compatibility. */ extern char *re_comp __P ((__const char *)); extern int re_exec __P ((__const char *)); /* POSIX compatibility. */ extern int regcomp __P ((regex_t *preg, __const char *pattern, int cflags)); extern int regexec __P ((__const regex_t *preg, __const char *string, size_t nmatch, regmatch_t pmatch[], int eflags)); extern size_t regerror __P ((int errcode, __const regex_t *preg, char *errbuf, size_t errbuf_size)); extern void regfree __P ((regex_t *preg)); __END_DECLS #endif /* not __REGEXP_LIBRARY_H__ */ /* Local variables: make-backup-files: t version-control: t trim-versions-without-asking: nil End: */ ./libc-linux/compat/__old_regex.c100644 1676 334 477176 5517624370 15110 0ustar hjlisl/* Extended regular expression matching and search library, version 0.12. (Implements POSIX draft P10003.2/D11.2, except for internationalization features.) Copyright (C) 1993 Free Software Foundation, Inc. This program 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 program 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* AIX requires this to be the first thing in the file. */ #if defined (_AIX) && !defined (REGEX_MALLOC) #pragma alloca #endif #define re_set_registers __old_re_set_registers #define re_compile_fastmap __old_re_compile_fastmap #define re_compile_pattern __old_re_compile_pattern #define re_match __old_re_match #define re_match_2 __old_re_match_2 #define re_search __old_re_search #define re_search_2 __old_re_search_2 #define regcomp __old_regcomp #define regerror __old_regerror #define regexec __old_regexec #define regfree __old_regfree #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif /* We need this for `regex.h', and perhaps for the Emacs include files. */ #include #ifdef HAVE_CONFIG_H #include "config.h" #endif /* The `emacs' switch turns on certain matching commands that make sense only in Emacs. */ #ifdef emacs #include "lisp.h" #include "buffer.h" #include "syntax.h" /* Emacs uses `NULL' as a predicate. */ #undef NULL #else /* not emacs */ /* We used to test for `BSTRING' here, but only GCC and Emacs define `BSTRING', as far as I know, and neither of them use this code. */ #if HAVE_STRING_H || STDC_HEADERS #include #ifndef bcmp #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n)) #endif #ifndef bcopy #define bcopy(s, d, n) memcpy ((d), (s), (n)) #endif #ifndef bzero #define bzero(s, n) memset ((s), 0, (n)) #endif #else #include #endif #ifdef STDC_HEADERS #include #else char *malloc (); char *realloc (); #endif /* Define the syntax stuff for \<, \>, etc. */ /* This must be nonzero for the wordchar and notwordchar pattern commands in re_match_2. */ #ifndef Sword #define Sword 1 #endif #ifdef SYNTAX_TABLE extern char *re_syntax_table; #else /* not SYNTAX_TABLE */ /* How many characters in the character set. */ #define CHAR_SET_SIZE 256 static char re_syntax_table[CHAR_SET_SIZE]; static void init_syntax_once () { register int c; static int done = 0; if (done) return; bzero (re_syntax_table, sizeof re_syntax_table); for (c = 'a'; c <= 'z'; c++) re_syntax_table[c] = Sword; for (c = 'A'; c <= 'Z'; c++) re_syntax_table[c] = Sword; for (c = '0'; c <= '9'; c++) re_syntax_table[c] = Sword; re_syntax_table['_'] = Sword; done = 1; } #endif /* not SYNTAX_TABLE */ #define SYNTAX(c) re_syntax_table[c] #endif /* not emacs */ /* Get the interface, including the syntax bits. */ #include "regex.h" /* isalpha etc. are used for the character classes. */ #include /* Jim Meyering writes: "... Some ctype macros are valid only for character codes that isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when using /bin/cc or gcc but without giving an ansi option). So, all ctype uses should be through macros like ISPRINT... If STDC_HEADERS is defined, then autoconf has verified that the ctype macros don't need to be guarded with references to isascii. ... Defining isascii to 1 should let any compiler worth its salt eliminate the && through constant folding." */ #if ! defined (isascii) || defined (STDC_HEADERS) #undef isascii #define isascii(c) 1 #endif #ifdef isblank #define ISBLANK(c) (isascii (c) && isblank (c)) #else #define ISBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef isgraph #define ISGRAPH(c) (isascii (c) && isgraph (c)) #else #define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c)) #endif #define ISPRINT(c) (isascii (c) && isprint (c)) #define ISDIGIT(c) (isascii (c) && isdigit (c)) #define ISALNUM(c) (isascii (c) && isalnum (c)) #define ISALPHA(c) (isascii (c) && isalpha (c)) #define ISCNTRL(c) (isascii (c) && iscntrl (c)) #define ISLOWER(c) (isascii (c) && islower (c)) #define ISPUNCT(c) (isascii (c) && ispunct (c)) #define ISSPACE(c) (isascii (c) && isspace (c)) #define ISUPPER(c) (isascii (c) && isupper (c)) #define ISXDIGIT(c) (isascii (c) && isxdigit (c)) #ifndef NULL #define NULL 0 #endif /* We remove any previous definition of `SIGN_EXTEND_CHAR', since ours (we hope) works properly with all combinations of machines, compilers, `char' and `unsigned char' argument types. (Per Bothner suggested the basic approach.) */ #undef SIGN_EXTEND_CHAR #if __STDC__ #define SIGN_EXTEND_CHAR(c) ((signed char) (c)) #else /* not __STDC__ */ /* As in Harbison and Steele. */ #define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) #endif /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we use `alloca' instead of `malloc'. This is because using malloc in re_search* or re_match* could cause memory leaks when C-g is used in Emacs; also, malloc is slower and causes storage fragmentation. On the other hand, malloc is more portable, and easier to debug. Because we sometimes use alloca, some routines have to be macros, not functions -- `alloca'-allocated space disappears at the end of the function it is called in. */ #ifdef REGEX_MALLOC #define REGEX_ALLOCATE malloc #define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize) #else /* not REGEX_MALLOC */ /* Emacs already defines alloca, sometimes. */ #ifndef alloca /* Make alloca work the best possible way. */ #ifdef __GNUC__ #define alloca __builtin_alloca #else /* not __GNUC__ */ #if HAVE_ALLOCA_H #include #else /* not __GNUC__ or HAVE_ALLOCA_H */ #ifndef _AIX /* Already did AIX, up at the top. */ char *alloca (); #endif /* not _AIX */ #endif /* not HAVE_ALLOCA_H */ #endif /* not __GNUC__ */ #endif /* not alloca */ #define REGEX_ALLOCATE alloca /* Assumes a `char *destination' variable. */ #define REGEX_REALLOCATE(source, osize, nsize) \ (destination = (char *) alloca (nsize), \ bcopy (source, destination, osize), \ destination) #endif /* not REGEX_MALLOC */ /* True if `size1' is non-NULL and PTR is pointing anywhere inside `string1' or just past its end. This works if PTR is NULL, which is a good thing. */ #define FIRST_STRING_P(ptr) \ (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) /* (Re)Allocate N items of type T using malloc, or fail. */ #define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) #define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) #define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t))) #define BYTEWIDTH 8 /* In bits. */ #define STREQ(s1, s2) ((strcmp (s1, s2) == 0)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) typedef char boolean; #define false 0 #define true 1 /* These are the command codes that appear in compiled regular expressions. Some opcodes are followed by argument bytes. A command code can specify any interpretation whatsoever for its arguments. Zero bytes may appear in the compiled regular expression. The value of `exactn' is needed in search.c (search_buffer) in Emacs. So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of `exactn' we use here must also be 1. */ typedef enum { no_op = 0, /* Followed by one byte giving n, then by n literal bytes. */ exactn = 1, /* Matches any (more or less) character. */ anychar, /* Matches any one char belonging to specified set. First following byte is number of bitmap bytes. Then come bytes for a bitmap saying which chars are in. Bits in each byte are ordered low-bit-first. A character is in the set if its bit is 1. A character too large to have a bit in the map is automatically not in the set. */ charset, /* Same parameters as charset, but match any character that is not one of those specified. */ charset_not, /* Start remembering the text that is matched, for storing in a register. Followed by one byte with the register number, in the range 0 to one less than the pattern buffer's re_nsub field. Then followed by one byte with the number of groups inner to this one. (This last has to be part of the start_memory only because we need it in the on_failure_jump of re_match_2.) */ start_memory, /* Stop remembering the text that is matched and store it in a memory register. Followed by one byte with the register number, in the range 0 to one less than `re_nsub' in the pattern buffer, and one byte with the number of inner groups, just like `start_memory'. (We need the number of inner groups here because we don't have any easy way of finding the corresponding start_memory when we're at a stop_memory.) */ stop_memory, /* Match a duplicate of something remembered. Followed by one byte containing the register number. */ duplicate, /* Fail unless at beginning of line. */ begline, /* Fail unless at end of line. */ endline, /* Succeeds if at beginning of buffer (if emacs) or at beginning of string to be matched (if not). */ begbuf, /* Analogously, for end of buffer/string. */ endbuf, /* Followed by two byte relative address to which to jump. */ jump, /* Same as jump, but marks the end of an alternative. */ jump_past_alt, /* Followed by two-byte relative address of place to resume at in case of failure. */ on_failure_jump, /* Like on_failure_jump, but pushes a placeholder instead of the current string position when executed. */ on_failure_keep_string_jump, /* Throw away latest failure point and then jump to following two-byte relative address. */ pop_failure_jump, /* Change to pop_failure_jump if know won't have to backtrack to match; otherwise change to jump. This is used to jump back to the beginning of a repeat. If what follows this jump clearly won't match what the repeat does, such that we can be sure that there is no use backtracking out of repetitions already matched, then we change it to a pop_failure_jump. Followed by two-byte address. */ maybe_pop_jump, /* Jump to following two-byte address, and push a dummy failure point. This failure point will be thrown away if an attempt is made to use it for a failure. A `+' construct makes this before the first repeat. Also used as an intermediary kind of jump when compiling an alternative. */ dummy_failure_jump, /* Push a dummy failure point and continue. Used at the end of alternatives. */ push_dummy_failure, /* Followed by two-byte relative address and two-byte number n. After matching N times, jump to the address upon failure. */ succeed_n, /* Followed by two-byte relative address, and two-byte number n. Jump to the address N times, then fail. */ jump_n, /* Set the following two-byte relative address to the subsequent two-byte number. The address *includes* the two bytes of number. */ set_number_at, wordchar, /* Matches any word-constituent character. */ notwordchar, /* Matches any char that is not a word-constituent. */ wordbeg, /* Succeeds if at word beginning. */ wordend, /* Succeeds if at word end. */ wordbound, /* Succeeds if at a word boundary. */ notwordbound /* Succeeds if not at a word boundary. */ #ifdef emacs ,before_dot, /* Succeeds if before point. */ at_dot, /* Succeeds if at point. */ after_dot, /* Succeeds if after point. */ /* Matches any character whose syntax is specified. Followed by a byte which contains a syntax code, e.g., Sword. */ syntaxspec, /* Matches any character whose syntax is not that specified. */ notsyntaxspec #endif /* emacs */ } re_opcode_t; /* Common operations on the compiled pattern. */ /* Store NUMBER in two contiguous bytes starting at DESTINATION. */ #define STORE_NUMBER(destination, number) \ do { \ (destination)[0] = (number) & 0377; \ (destination)[1] = (number) >> 8; \ } while (0) /* Same as STORE_NUMBER, except increment DESTINATION to the byte after where the number is stored. Therefore, DESTINATION must be an lvalue. */ #define STORE_NUMBER_AND_INCR(destination, number) \ do { \ STORE_NUMBER (destination, number); \ (destination) += 2; \ } while (0) /* Put into DESTINATION a number stored in two contiguous bytes starting at SOURCE. */ #define EXTRACT_NUMBER(destination, source) \ do { \ (destination) = *(source) & 0377; \ (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \ } while (0) #ifdef DEBUG static void extract_number (dest, source) int *dest; unsigned char *source; { int temp = SIGN_EXTEND_CHAR (*(source + 1)); *dest = *source & 0377; *dest += temp << 8; } #ifndef EXTRACT_MACROS /* To debug the macros. */ #undef EXTRACT_NUMBER #define EXTRACT_NUMBER(dest, src) extract_number (&dest, src) #endif /* not EXTRACT_MACROS */ #endif /* DEBUG */ /* Same as EXTRACT_NUMBER, except increment SOURCE to after the number. SOURCE must be an lvalue. */ #define EXTRACT_NUMBER_AND_INCR(destination, source) \ do { \ EXTRACT_NUMBER (destination, source); \ (source) += 2; \ } while (0) #ifdef DEBUG static void extract_number_and_incr (destination, source) int *destination; unsigned char **source; { extract_number (destination, *source); *source += 2; } #ifndef EXTRACT_MACROS #undef EXTRACT_NUMBER_AND_INCR #define EXTRACT_NUMBER_AND_INCR(dest, src) \ extract_number_and_incr (&dest, &src) #endif /* not EXTRACT_MACROS */ #endif /* DEBUG */ /* If DEBUG is defined, Regex prints many voluminous messages about what it is doing (if the variable `debug' is nonzero). If linked with the main program in `iregex.c', you can enter patterns and strings interactively. And if linked with the main program in `main.c' and the other test files, you can run the already-written tests. */ #ifdef DEBUG /* We use standard I/O for debugging. */ #include /* It is useful to test things that ``must'' be true when debugging. */ #include static int debug = 0; #define DEBUG_STATEMENT(e) e #define DEBUG_PRINT1(x) if (debug) printf (x) #define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2) #define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3) #define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4) #define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \ if (debug) print_partial_compiled_pattern (s, e) #define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \ if (debug) print_double_string (w, s1, sz1, s2, sz2) extern void printchar (); /* Print the fastmap in human-readable form. */ void print_fastmap (fastmap) char *fastmap; { unsigned was_a_range = 0; unsigned i = 0; while (i < (1 << BYTEWIDTH)) { if (fastmap[i++]) { was_a_range = 0; printchar (i - 1); while (i < (1 << BYTEWIDTH) && fastmap[i]) { was_a_range = 1; i++; } if (was_a_range) { printf ("-"); printchar (i - 1); } } } putchar ('\n'); } /* Print a compiled pattern string in human-readable form, starting at the START pointer into it and ending just before the pointer END. */ void print_partial_compiled_pattern (start, end) unsigned char *start; unsigned char *end; { int mcnt, mcnt2; unsigned char *p = start; unsigned char *pend = end; if (start == NULL) { printf ("(null)\n"); return; } /* Loop over pattern commands. */ while (p < pend) { printf ("%d:\t", p - start); switch ((re_opcode_t) *p++) { case no_op: printf ("/no_op"); break; case exactn: mcnt = *p++; printf ("/exactn/%d", mcnt); do { putchar ('/'); printchar (*p++); } while (--mcnt); break; case start_memory: mcnt = *p++; printf ("/start_memory/%d/%d", mcnt, *p++); break; case stop_memory: mcnt = *p++; printf ("/stop_memory/%d/%d", mcnt, *p++); break; case duplicate: printf ("/duplicate/%d", *p++); break; case anychar: printf ("/anychar"); break; case charset: case charset_not: { register int c, last = -100; register int in_range = 0; printf ("/charset [%s", (re_opcode_t) *(p - 1) == charset_not ? "^" : ""); assert (p + *p < pend); for (c = 0; c < 256; c++) if (c / 8 < *p && (p[1 + (c/8)] & (1 << (c % 8)))) { /* Are we starting a range? */ if (last + 1 == c && ! in_range) { putchar ('-'); in_range = 1; } /* Have we broken a range? */ else if (last + 1 != c && in_range) { printchar (last); in_range = 0; } if (! in_range) printchar (c); last = c; } if (in_range) printchar (last); putchar (']'); p += 1 + *p; } break; case begline: printf ("/begline"); break; case endline: printf ("/endline"); break; case on_failure_jump: extract_number_and_incr (&mcnt, &p); printf ("/on_failure_jump to %d", p + mcnt - start); break; case on_failure_keep_string_jump: extract_number_and_incr (&mcnt, &p); printf ("/on_failure_keep_string_jump to %d", p + mcnt - start); break; case dummy_failure_jump: extract_number_and_incr (&mcnt, &p); printf ("/dummy_failure_jump to %d", p + mcnt - start); break; case push_dummy_failure: printf ("/push_dummy_failure"); break; case maybe_pop_jump: extract_number_and_incr (&mcnt, &p); printf ("/maybe_pop_jump to %d", p + mcnt - start); break; case pop_failure_jump: extract_number_and_incr (&mcnt, &p); printf ("/pop_failure_jump to %d", p + mcnt - start); break; case jump_past_alt: extract_number_and_incr (&mcnt, &p); printf ("/jump_past_alt to %d", p + mcnt - start); break; case jump: extract_number_and_incr (&mcnt, &p); printf ("/jump to %d", p + mcnt - start); break; case succeed_n: extract_number_and_incr (&mcnt, &p); extract_number_and_incr (&mcnt2, &p); printf ("/succeed_n to %d, %d times", p + mcnt - start, mcnt2); break; case jump_n: extract_number_and_incr (&mcnt, &p); extract_number_and_incr (&mcnt2, &p); printf ("/jump_n to %d, %d times", p + mcnt - start, mcnt2); break; case set_number_at: extract_number_and_incr (&mcnt, &p); extract_number_and_incr (&mcnt2, &p); printf ("/set_number_at location %d to %d", p + mcnt - start, mcnt2); break; case wordbound: printf ("/wordbound"); break; case notwordbound: printf ("/notwordbound"); break; case wordbeg: printf ("/wordbeg"); break; case wordend: printf ("/wordend"); #ifdef emacs case before_dot: printf ("/before_dot"); break; case at_dot: printf ("/at_dot"); break; case after_dot: printf ("/after_dot"); break; case syntaxspec: printf ("/syntaxspec"); mcnt = *p++; printf ("/%d", mcnt); break; case notsyntaxspec: printf ("/notsyntaxspec"); mcnt = *p++; printf ("/%d", mcnt); break; #endif /* emacs */ case wordchar: printf ("/wordchar"); break; case notwordchar: printf ("/notwordchar"); break; case begbuf: printf ("/begbuf"); break; case endbuf: printf ("/endbuf"); break; default: printf ("?%d", *(p-1)); } putchar ('\n'); } printf ("%d:\tend of pattern.\n", p - start); } void print_compiled_pattern (bufp) struct re_pattern_buffer *bufp; { unsigned char *buffer = bufp->buffer; print_partial_compiled_pattern (buffer, buffer + bufp->used); printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated); if (bufp->fastmap_accurate && bufp->fastmap) { printf ("fastmap: "); print_fastmap (bufp->fastmap); } printf ("re_nsub: %d\t", bufp->re_nsub); printf ("regs_alloc: %d\t", bufp->regs_allocated); printf ("can_be_null: %d\t", bufp->can_be_null); printf ("newline_anchor: %d\n", bufp->newline_anchor); printf ("no_sub: %d\t", bufp->no_sub); printf ("not_bol: %d\t", bufp->not_bol); printf ("not_eol: %d\t", bufp->not_eol); printf ("syntax: %d\n", bufp->syntax); /* Perhaps we should print the translate table? */ } void print_double_string (where, string1, size1, string2, size2) const char *where; const char *string1; const char *string2; int size1; int size2; { unsigned this_char; if (where == NULL) printf ("(null)"); else { if (FIRST_STRING_P (where)) { for (this_char = where - string1; this_char < size1; this_char++) printchar (string1[this_char]); where = string2; } for (this_char = where - string2; this_char < size2; this_char++) printchar (string2[this_char]); } } #else /* not DEBUG */ #undef assert #define assert(e) #define DEBUG_STATEMENT(e) #define DEBUG_PRINT1(x) #define DEBUG_PRINT2(x1, x2) #define DEBUG_PRINT3(x1, x2, x3) #define DEBUG_PRINT4(x1, x2, x3, x4) #define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) #define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) #endif /* not DEBUG */ /* Set by `re_set_syntax' to the current regexp syntax to recognize. Can also be assigned to arbitrarily: each pattern buffer stores its own syntax, so it can be changed between regex compilations. */ reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS; /* Specify the precise syntax of regexps for compilation. This provides for compatibility for various utilities which historically have different, incompatible syntaxes. The argument SYNTAX is a bit mask comprised of the various bits defined in regex.h. We return the old syntax. */ #if 0 /* We use the one in rx.c. H.J. Lu. */ reg_syntax_t re_set_syntax (syntax) reg_syntax_t syntax; { reg_syntax_t ret = re_syntax_options; re_syntax_options = syntax; return ret; } #endif /* This table gives an error message for each of the error codes listed in regex.h. Obviously the order here has to be same as there. */ static const char *re_error_msg[] = { NULL, /* REG_NOERROR */ "No match", /* REG_NOMATCH */ "Invalid regular expression", /* REG_BADPAT */ "Invalid collation character", /* REG_ECOLLATE */ "Invalid character class name", /* REG_ECTYPE */ "Trailing backslash", /* REG_EESCAPE */ "Invalid back reference", /* REG_ESUBREG */ "Unmatched [ or [^", /* REG_EBRACK */ "Unmatched ( or \\(", /* REG_EPAREN */ "Unmatched \\{", /* REG_EBRACE */ "Invalid content of \\{\\}", /* REG_BADBR */ "Invalid range end", /* REG_ERANGE */ "Memory exhausted", /* REG_ESPACE */ "Invalid preceding regular expression", /* REG_BADRPT */ "Premature end of regular expression", /* REG_EEND */ "Regular expression too big", /* REG_ESIZE */ "Unmatched ) or \\)", /* REG_ERPAREN */ }; /* Subroutine declarations and macros for regex_compile. */ static void store_op1 (), store_op2 (); static void insert_op1 (), insert_op2 (); static boolean at_begline_loc_p (), at_endline_loc_p (); static boolean group_in_compile_stack (); static reg_errcode_t compile_range (); /* Fetch the next character in the uncompiled pattern---translating it if necessary. Also cast from a signed character in the constant string passed to us by the user to an unsigned char that we can use as an array index (in, e.g., `translate'). */ #define PATFETCH(c) \ do {if (p == pend) return REG_EEND; \ c = (unsigned char) *p++; \ if (translate) c = translate[c]; \ } while (0) /* Fetch the next character in the uncompiled pattern, with no translation. */ #define PATFETCH_RAW(c) \ do {if (p == pend) return REG_EEND; \ c = (unsigned char) *p++; \ } while (0) /* Go backwards one character in the pattern. */ #define PATUNFETCH p-- /* If `translate' is non-null, return translate[D], else just D. We cast the subscript to translate because some data is declared as `char *', to avoid warnings when a string constant is passed. But when we use a character as a subscript we must make it unsigned. */ #define TRANSLATE(d) (translate ? translate[(unsigned char) (d)] : (d)) /* Macros for outputting the compiled pattern into `buffer'. */ /* If the buffer isn't allocated when it comes in, use this. */ #define INIT_BUF_SIZE 32 /* Make sure we have at least N more bytes of space in buffer. */ #define GET_BUFFER_SPACE(n) \ while (b - bufp->buffer + (n) > bufp->allocated) \ EXTEND_BUFFER () /* Make sure we have one more byte of buffer space and then add C to it. */ #define BUF_PUSH(c) \ do { \ GET_BUFFER_SPACE (1); \ *b++ = (unsigned char) (c); \ } while (0) /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ #define BUF_PUSH_2(c1, c2) \ do { \ GET_BUFFER_SPACE (2); \ *b++ = (unsigned char) (c1); \ *b++ = (unsigned char) (c2); \ } while (0) /* As with BUF_PUSH_2, except for three bytes. */ #define BUF_PUSH_3(c1, c2, c3) \ do { \ GET_BUFFER_SPACE (3); \ *b++ = (unsigned char) (c1); \ *b++ = (unsigned char) (c2); \ *b++ = (unsigned char) (c3); \ } while (0) /* Store a jump with opcode OP at LOC to location TO. We store a relative address offset by the three bytes the jump itself occupies. */ #define STORE_JUMP(op, loc, to) \ store_op1 (op, loc, (to) - (loc) - 3) /* Likewise, for a two-argument jump. */ #define STORE_JUMP2(op, loc, to, arg) \ store_op2 (op, loc, (to) - (loc) - 3, arg) /* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */ #define INSERT_JUMP(op, loc, to) \ insert_op1 (op, loc, (to) - (loc) - 3, b) /* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */ #define INSERT_JUMP2(op, loc, to, arg) \ insert_op2 (op, loc, (to) - (loc) - 3, arg, b) /* This is not an arbitrary limit: the arguments which represent offsets into the pattern are two bytes long. So if 2^16 bytes turns out to be too small, many things would have to change. */ #define MAX_BUF_SIZE (1L << 16) /* Extend the buffer by twice its current size via realloc and reset the pointers that pointed into the old block to point to the correct places in the new one. If extending the buffer results in it being larger than MAX_BUF_SIZE, then flag memory exhausted. */ #define EXTEND_BUFFER() \ do { \ unsigned char *old_buffer = bufp->buffer; \ if (bufp->allocated == MAX_BUF_SIZE) \ return REG_ESIZE; \ bufp->allocated <<= 1; \ if (bufp->allocated > MAX_BUF_SIZE) \ bufp->allocated = MAX_BUF_SIZE; \ bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\ if (bufp->buffer == NULL) \ return REG_ESPACE; \ /* If the buffer moved, move all the pointers into it. */ \ if (old_buffer != bufp->buffer) \ { \ b = (b - old_buffer) + bufp->buffer; \ begalt = (begalt - old_buffer) + bufp->buffer; \ if (fixup_alt_jump) \ fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\ if (laststart) \ laststart = (laststart - old_buffer) + bufp->buffer; \ if (pending_exact) \ pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ } \ } while (0) /* Since we have one byte reserved for the register number argument to {start,stop}_memory, the maximum number of groups we can report things about is what fits in that byte. */ #define MAX_REGNUM 255 /* But patterns can have more than `MAX_REGNUM' registers. We just ignore the excess. */ typedef unsigned regnum_t; /* Macros for the compile stack. */ /* Since offsets can go either forwards or backwards, this type needs to be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ typedef int pattern_offset_t; typedef struct { pattern_offset_t begalt_offset; pattern_offset_t fixup_alt_jump; pattern_offset_t inner_group_offset; pattern_offset_t laststart_offset; regnum_t regnum; } compile_stack_elt_t; typedef struct { compile_stack_elt_t *stack; unsigned size; unsigned avail; /* Offset of next open position. */ } compile_stack_type; #define INIT_COMPILE_STACK_SIZE 32 #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) /* The next available element. */ #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) /* Set the bit for character C in a list. */ #define SET_LIST_BIT(c) \ (b[((unsigned char) (c)) / BYTEWIDTH] \ |= 1 << (((unsigned char) c) % BYTEWIDTH)) /* Get the next unsigned number in the uncompiled pattern. */ #define GET_UNSIGNED_NUMBER(num) \ { if (p != pend) \ { \ PATFETCH (c); \ while (ISDIGIT (c)) \ { \ if (num < 0) \ num = 0; \ num = num * 10 + c - '0'; \ if (p == pend) \ break; \ PATFETCH (c); \ } \ } \ } #define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */ #define IS_CHAR_CLASS(string) \ (STREQ (string, "alpha") || STREQ (string, "upper") \ || STREQ (string, "lower") || STREQ (string, "digit") \ || STREQ (string, "alnum") || STREQ (string, "xdigit") \ || STREQ (string, "space") || STREQ (string, "print") \ || STREQ (string, "punct") || STREQ (string, "graph") \ || STREQ (string, "cntrl") || STREQ (string, "blank")) /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. Returns one of error codes defined in `regex.h', or zero for success. Assumes the `allocated' (and perhaps `buffer') and `translate' fields are set in BUFP on entry. If it succeeds, results are put in BUFP (if it returns an error, the contents of BUFP are undefined): `buffer' is the compiled pattern; `syntax' is set to SYNTAX; `used' is set to the length of the compiled pattern; `fastmap_accurate' is zero; `re_nsub' is the number of subexpressions in PATTERN; `not_bol' and `not_eol' are zero; The `fastmap' and `newline_anchor' fields are neither examined nor set. */ static reg_errcode_t regex_compile (pattern, size, syntax, bufp) const char *pattern; int size; reg_syntax_t syntax; struct re_pattern_buffer *bufp; { /* We fetch characters from PATTERN here. Even though PATTERN is `char *' (i.e., signed), we declare these variables as unsigned, so they can be reliably used as array indices. */ register unsigned char c, c1; /* A random tempory spot in PATTERN. */ const char *p1; /* Points to the end of the buffer, where we should append. */ register unsigned char *b; /* Keeps track of unclosed groups. */ compile_stack_type compile_stack; /* Points to the current (ending) position in the pattern. */ const char *p = pattern; const char *pend = pattern + size; /* How to translate the characters in the pattern. */ char *translate = bufp->translate; /* Address of the count-byte of the most recently inserted `exactn' command. This makes it possible to tell if a new exact-match character can be added to that command or if the character requires a new `exactn' command. */ unsigned char *pending_exact = 0; /* Address of start of the most recently finished expression. This tells, e.g., postfix * where to find the start of its operand. Reset at the beginning of groups and alternatives. */ unsigned char *laststart = 0; /* Address of beginning of regexp, or inside of last group. */ unsigned char *begalt; /* Place in the uncompiled pattern (i.e., the {) to which to go back if the interval is invalid. */ const char *beg_interval; /* Address of the place where a forward jump should go to the end of the containing expression. Each alternative of an `or' -- except the last -- ends with a forward jump of this sort. */ unsigned char *fixup_alt_jump = 0; /* Counts open-groups as they are encountered. Remembered for the matching close-group on the compile stack, so the same register number is put in the stop_memory as the start_memory. */ regnum_t regnum = 0; #ifdef DEBUG DEBUG_PRINT1 ("\nCompiling pattern: "); if (debug) { unsigned debug_count; for (debug_count = 0; debug_count < size; debug_count++) printchar (pattern[debug_count]); putchar ('\n'); } #endif /* DEBUG */ /* Initialize the compile stack. */ compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); if (compile_stack.stack == NULL) return REG_ESPACE; compile_stack.size = INIT_COMPILE_STACK_SIZE; compile_stack.avail = 0; /* Initialize the pattern buffer. */ bufp->syntax = syntax; bufp->fastmap_accurate = 0; bufp->not_bol = bufp->not_eol = 0; /* Set `used' to zero, so that if we return an error, the pattern printer (for debugging) will think there's no pattern. We reset it at the end. */ bufp->used = 0; /* Always count groups, whether or not bufp->no_sub is set. */ bufp->re_nsub = 0; #if !defined (emacs) && !defined (SYNTAX_TABLE) /* Initialize the syntax table. */ init_syntax_once (); #endif if (bufp->allocated == 0) { if (bufp->buffer) { /* If zero allocated, but buffer is non-null, try to realloc enough space. This loses if buffer's address is bogus, but that is the user's responsibility. */ RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); } else { /* Caller did not allocate a buffer. Do it for them. */ bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); } if (!bufp->buffer) return REG_ESPACE; bufp->allocated = INIT_BUF_SIZE; } begalt = b = bufp->buffer; /* Loop through the uncompiled pattern until we're at the end. */ while (p != pend) { PATFETCH (c); switch (c) { case '^': { if ( /* If at start of pattern, it's an operator. */ p == pattern + 1 /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS /* Otherwise, depends on what's come before. */ || at_begline_loc_p (pattern, p, syntax)) BUF_PUSH (begline); else goto normal_char; } break; case '$': { if ( /* If at end of pattern, it's an operator. */ p == pend /* If context independent, it's an operator. */ || syntax & RE_CONTEXT_INDEP_ANCHORS /* Otherwise, depends on what's next. */ || at_endline_loc_p (p, pend, syntax)) BUF_PUSH (endline); else goto normal_char; } break; case '+': case '?': if ((syntax & RE_BK_PLUS_QM) || (syntax & RE_LIMITED_OPS)) goto normal_char; handle_plus: case '*': /* If there is no previous pattern... */ if (!laststart) { if (syntax & RE_CONTEXT_INVALID_OPS) return REG_BADRPT; else if (!(syntax & RE_CONTEXT_INDEP_OPS)) goto normal_char; } { /* Are we optimizing this jump? */ boolean keep_string_p = false; /* 1 means zero (many) matches is allowed. */ char zero_times_ok = 0, many_times_ok = 0; /* If there is a sequence of repetition chars, collapse it down to just one (the right one). We can't combine interval operators with these because of, e.g., `a{2}*', which should only match an even number of `a's. */ for (;;) { zero_times_ok |= c != '+'; many_times_ok |= c != '?'; if (p == pend) break; PATFETCH (c); if (c == '*' || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?'))) ; else if (syntax & RE_BK_PLUS_QM && c == '\\') { if (p == pend) return REG_EESCAPE; PATFETCH (c1); if (!(c1 == '+' || c1 == '?')) { PATUNFETCH; PATUNFETCH; break; } c = c1; } else { PATUNFETCH; break; } /* If we get here, we found another repeat character. */ } /* Star, etc. applied to an empty pattern is equivalent to an empty pattern. */ if (!laststart) break; /* Now we know whether or not zero matches is allowed and also whether or not two or more matches is allowed. */ if (many_times_ok) { /* More than one repetition is allowed, so put in at the end a backward relative jump from `b' to before the next jump we're going to put in below (which jumps from laststart to after this jump). But if we are at the `*' in the exact sequence `.*\n', insert an unconditional jump backwards to the ., instead of the beginning of the loop. This way we only push a failure point once, instead of every time through the loop. */ assert (p - 1 > pattern); /* Allocate the space for the jump. */ GET_BUFFER_SPACE (3); /* We know we are not at the first character of the pattern, because laststart was nonzero. And we've already incremented `p', by the way, to be the character after the `*'. Do we have to do something analogous here for null bytes, because of RE_DOT_NOT_NULL? */ if (TRANSLATE (*(p - 2)) == TRANSLATE ('.') && zero_times_ok && p < pend && TRANSLATE (*p) == TRANSLATE ('\n') && !(syntax & RE_DOT_NEWLINE)) { /* We have .*\n. */ STORE_JUMP (jump, b, laststart); keep_string_p = true; } else /* Anything else. */ STORE_JUMP (maybe_pop_jump, b, laststart - 3); /* We've added more stuff to the buffer. */ b += 3; } /* On failure, jump from laststart to b + 3, which will be the end of the buffer after this jump is inserted. */ GET_BUFFER_SPACE (3); INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump : on_failure_jump, laststart, b + 3); pending_exact = 0; b += 3; if (!zero_times_ok) { /* At least one repetition is required, so insert a `dummy_failure_jump' before the initial `on_failure_jump' instruction of the loop. This effects a skip over that instruction the first time we hit that loop. */ GET_BUFFER_SPACE (3); INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); b += 3; } } break; case '.': laststart = b; BUF_PUSH (anychar); break; case '[': { boolean had_char_class = false; if (p == pend) return REG_EBRACK; /* Ensure that we have enough space to push a charset: the opcode, the length count, and the bitset; 34 bytes in all. */ GET_BUFFER_SPACE (34); laststart = b; /* We test `*p == '^' twice, instead of using an if statement, so we only need one BUF_PUSH. */ BUF_PUSH (*p == '^' ? charset_not : charset); if (*p == '^') p++; /* Remember the first position in the bracket expression. */ p1 = p; /* Push the number of bytes in the bitmap. */ BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); /* Clear the whole map. */ bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); /* charset_not matches newline according to a syntax bit. */ if ((re_opcode_t) b[-2] == charset_not && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) SET_LIST_BIT ('\n'); /* Read in characters and ranges, setting map bits. */ for (;;) { if (p == pend) return REG_EBRACK; PATFETCH (c); /* \ might escape characters inside [...] and [^...]. */ if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') { if (p == pend) return REG_EESCAPE; PATFETCH (c1); SET_LIST_BIT (c1); continue; } /* Could be the end of the bracket expression. If it's not (i.e., when the bracket expression is `[]' so far), the ']' character bit gets set way below. */ if (c == ']' && p != p1 + 1) break; /* Look ahead to see if it's a range when the last thing was a character class. */ if (had_char_class && c == '-' && *p != ']') return REG_ERANGE; /* Look ahead to see if it's a range when the last thing was a character: if this is a hyphen not at the beginning or the end of a list, then it's the range operator. */ if (c == '-' && !(p - 2 >= pattern && p[-2] == '[') && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') && *p != ']') { reg_errcode_t ret = compile_range (&p, pend, translate, syntax, b); if (ret != REG_NOERROR) return ret; } else if (p[0] == '-' && p[1] != ']') { /* This handles ranges made up of characters only. */ reg_errcode_t ret; /* Move past the `-'. */ PATFETCH (c1); ret = compile_range (&p, pend, translate, syntax, b); if (ret != REG_NOERROR) return ret; } /* See if we're at the beginning of a possible character class. */ else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') { /* Leave room for the null. */ char str[CHAR_CLASS_MAX_LENGTH + 1]; PATFETCH (c); c1 = 0; /* If pattern is `[[:'. */ if (p == pend) return REG_EBRACK; for (;;) { PATFETCH (c); if (c == ':' || c == ']' || p == pend || c1 == CHAR_CLASS_MAX_LENGTH) break; str[c1++] = c; } str[c1] = '\0'; /* If isn't a word bracketed by `[:' and:`]': undo the ending character, the letters, and leave the leading `:' and `[' (but set bits for them). */ if (c == ':' && *p == ']') { int ch; boolean is_alnum = STREQ (str, "alnum"); boolean is_alpha = STREQ (str, "alpha"); boolean is_blank = STREQ (str, "blank"); boolean is_cntrl = STREQ (str, "cntrl"); boolean is_digit = STREQ (str, "digit"); boolean is_graph = STREQ (str, "graph"); boolean is_lower = STREQ (str, "lower"); boolean is_print = STREQ (str, "print"); boolean is_punct = STREQ (str, "punct"); boolean is_space = STREQ (str, "space"); boolean is_upper = STREQ (str, "upper"); boolean is_xdigit = STREQ (str, "xdigit"); if (!IS_CHAR_CLASS (str)) return REG_ECTYPE; /* Throw away the ] at the end of the character class. */ PATFETCH (c); if (p == pend) return REG_EBRACK; for (ch = 0; ch < 1 << BYTEWIDTH; ch++) { if ( (is_alnum && ISALNUM (ch)) || (is_alpha && ISALPHA (ch)) || (is_blank && ISBLANK (ch)) || (is_cntrl && ISCNTRL (ch)) || (is_digit && ISDIGIT (ch)) || (is_graph && ISGRAPH (ch)) || (is_lower && ISLOWER (ch)) || (is_print && ISPRINT (ch)) || (is_punct && ISPUNCT (ch)) || (is_space && ISSPACE (ch)) || (is_upper && ISUPPER (ch)) || (is_xdigit && ISXDIGIT (ch))) SET_LIST_BIT (ch); } had_char_class = true; } else { c1++; while (c1--) PATUNFETCH; SET_LIST_BIT ('['); SET_LIST_BIT (':'); had_char_class = false; } } else { had_char_class = false; SET_LIST_BIT (c); } } /* Discard any (non)matching list bytes that are all 0 at the end of the map. Decrease the map-length byte too. */ while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) b[-1]--; b += b[-1]; } break; case '(': if (syntax & RE_NO_BK_PARENS) goto handle_open; else goto normal_char; case ')': if (syntax & RE_NO_BK_PARENS) goto handle_close; else goto normal_char; case '\n': if (syntax & RE_NEWLINE_ALT) goto handle_alt; else goto normal_char; case '|': if (syntax & RE_NO_BK_VBAR) goto handle_alt; else goto normal_char; case '{': if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) goto handle_interval; else goto normal_char; case '\\': if (p == pend) return REG_EESCAPE; /* Do not translate the character after the \, so that we can distinguish, e.g., \B from \b, even if we normally would translate, e.g., B to b. */ PATFETCH_RAW (c); switch (c) { case '(': if (syntax & RE_NO_BK_PARENS) goto normal_backslash; handle_open: bufp->re_nsub++; regnum++; if (COMPILE_STACK_FULL) { RETALLOC (compile_stack.stack, compile_stack.size << 1, compile_stack_elt_t); if (compile_stack.stack == NULL) return REG_ESPACE; compile_stack.size <<= 1; } /* These are the values to restore when we hit end of this group. They are all relative offsets, so that if the whole pattern moves because of realloc, they will still be valid. */ COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; COMPILE_STACK_TOP.fixup_alt_jump = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer; COMPILE_STACK_TOP.regnum = regnum; /* We will eventually replace the 0 with the number of groups inner to this one. But do not push a start_memory for groups beyond the last one we can represent in the compiled pattern. */ if (regnum <= MAX_REGNUM) { COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2; BUF_PUSH_3 (start_memory, regnum, 0); } compile_stack.avail++; fixup_alt_jump = 0; laststart = 0; begalt = b; /* If we've reached MAX_REGNUM groups, then this open won't actually generate any code, so we'll have to clear pending_exact explicitly. */ pending_exact = 0; break; case ')': if (syntax & RE_NO_BK_PARENS) goto normal_backslash; if (COMPILE_STACK_EMPTY) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_backslash; else return REG_ERPAREN; handle_close: if (fixup_alt_jump) { /* Push a dummy failure point at the end of the alternative for a possible future `pop_failure_jump' to pop. See comments at `push_dummy_failure' in `re_match_2'. */ BUF_PUSH (push_dummy_failure); /* We allocated space for this jump when we assigned to `fixup_alt_jump', in the `handle_alt' case below. */ STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1); } /* See similar code for backslashed left paren above. */ if (COMPILE_STACK_EMPTY) if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) goto normal_char; else return REG_ERPAREN; /* Since we just checked for an empty stack above, this ``can't happen''. */ assert (compile_stack.avail != 0); { /* We don't just want to restore into `regnum', because later groups should continue to be numbered higher, as in `(ab)c(de)' -- the second group is #2. */ regnum_t this_group_regnum; compile_stack.avail--; begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; fixup_alt_jump = COMPILE_STACK_TOP.fixup_alt_jump ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 : 0; laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; this_group_regnum = COMPILE_STACK_TOP.regnum; /* If we've reached MAX_REGNUM groups, then this open won't actually generate any code, so we'll have to clear pending_exact explicitly. */ pending_exact = 0; /* We're at the end of the group, so now we know how many groups were inside this one. */ if (this_group_regnum <= MAX_REGNUM) { unsigned char *inner_group_loc = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; *inner_group_loc = regnum - this_group_regnum; BUF_PUSH_3 (stop_memory, this_group_regnum, regnum - this_group_regnum); } } break; case '|': /* `\|'. */ if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) goto normal_backslash; handle_alt: if (syntax & RE_LIMITED_OPS) goto normal_char; /* Insert before the previous alternative a jump which jumps to this alternative if the former fails. */ GET_BUFFER_SPACE (3); INSERT_JUMP (on_failure_jump, begalt, b + 6); pending_exact = 0; b += 3; /* The alternative before this one has a jump after it which gets executed if it gets matched. Adjust that jump so it will jump to this alternative's analogous jump (put in below, which in turn will jump to the next (if any) alternative's such jump, etc.). The last such jump jumps to the correct final destination. A picture: _____ _____ | | | | | v | v a | b | c If we are at `b', then fixup_alt_jump right now points to a three-byte space after `a'. We'll put in the jump, set fixup_alt_jump to right after `b', and leave behind three bytes which we'll fill in when we get to after `c'. */ if (fixup_alt_jump) STORE_JUMP (jump_past_alt, fixup_alt_jump, b); /* Mark and leave space for a jump after this alternative, to be filled in later either by next alternative or when know we're at the end of a series of alternatives. */ fixup_alt_jump = b; GET_BUFFER_SPACE (3); b += 3; laststart = 0; begalt = b; break; case '{': /* If \{ is a literal. */ if (!(syntax & RE_INTERVALS) /* If we're at `\{' and it's not the open-interval operator. */ || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) || (p - 2 == pattern && p == pend)) goto normal_backslash; handle_interval: { /* If got here, then the syntax allows intervals. */ /* At least (most) this many matches must be made. */ int lower_bound = -1, upper_bound = -1; beg_interval = p - 1; if (p == pend) { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_EBRACE; } GET_UNSIGNED_NUMBER (lower_bound); if (c == ',') { GET_UNSIGNED_NUMBER (upper_bound); if (upper_bound < 0) upper_bound = RE_DUP_MAX; } else /* Interval such as `{1}' => match exactly once. */ upper_bound = lower_bound; if (lower_bound < 0 || upper_bound > RE_DUP_MAX || lower_bound > upper_bound) { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_BADBR; } if (!(syntax & RE_NO_BK_BRACES)) { if (c != '\\') return REG_EBRACE; PATFETCH (c); } if (c != '}') { if (syntax & RE_NO_BK_BRACES) goto unfetch_interval; else return REG_BADBR; } /* We just parsed a valid interval. */ /* If it's invalid to have no preceding re. */ if (!laststart) { if (syntax & RE_CONTEXT_INVALID_OPS) return REG_BADRPT; else if (syntax & RE_CONTEXT_INDEP_OPS) laststart = b; else goto unfetch_interval; } /* If the upper bound is zero, don't want to succeed at all; jump from `laststart' to `b + 3', which will be the end of the buffer after we insert the jump. */ if (upper_bound == 0) { GET_BUFFER_SPACE (3); INSERT_JUMP (jump, laststart, b + 3); b += 3; } /* Otherwise, we have a nontrivial interval. When we're all done, the pattern will look like: set_number_at set_number_at succeed_n jump_n (The upper bound and `jump_n' are omitted if `upper_bound' is 1, though.) */ else { /* If the upper bound is > 1, we need to insert more at the end of the loop. */ unsigned nbytes = 10 + (upper_bound > 1) * 10; GET_BUFFER_SPACE (nbytes); /* Initialize lower bound of the `succeed_n', even though it will be set during matching by its attendant `set_number_at' (inserted next), because `re_compile_fastmap' needs to know. Jump to the `jump_n' we might insert below. */ INSERT_JUMP2 (succeed_n, laststart, b + 5 + (upper_bound > 1) * 5, lower_bound); b += 5; /* Code to initialize the lower bound. Insert before the `succeed_n'. The `5' is the last two bytes of this `set_number_at', plus 3 bytes of the following `succeed_n'. */ insert_op2 (set_number_at, laststart, 5, lower_bound, b); b += 5; if (upper_bound > 1) { /* More than one repetition is allowed, so append a backward jump to the `succeed_n' that starts this interval. When we've reached this during matching, we'll have matched the interval once, so jump back only `upper_bound - 1' times. */ STORE_JUMP2 (jump_n, b, laststart + 5, upper_bound - 1); b += 5; /* The location we want to set is the second parameter of the `jump_n'; that is `b-2' as an absolute address. `laststart' will be the `set_number_at' we're about to insert; `laststart+3' the number to set, the source for the relative address. But we are inserting into the middle of the pattern -- so everything is getting moved up by 5. Conclusion: (b - 2) - (laststart + 3) + 5, i.e., b - laststart. We insert this at the beginning of the loop so that if we fail during matching, we'll reinitialize the bounds. */ insert_op2 (set_number_at, laststart, b - laststart, upper_bound - 1, b); b += 5; } } pending_exact = 0; beg_interval = NULL; } break; unfetch_interval: /* If an invalid interval, match the characters as literals. */ assert (beg_interval); p = beg_interval; beg_interval = NULL; /* normal_char and normal_backslash need `c'. */ PATFETCH (c); if (!(syntax & RE_NO_BK_BRACES)) { if (p > pattern && p[-1] == '\\') goto normal_backslash; } goto normal_char; #ifdef emacs /* There is no way to specify the before_dot and after_dot operators. rms says this is ok. --karl */ case '=': BUF_PUSH (at_dot); break; case 's': laststart = b; PATFETCH (c); BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); break; case 'S': laststart = b; PATFETCH (c); BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); break; #endif /* emacs */ case 'w': laststart = b; BUF_PUSH (wordchar); break; case 'W': laststart = b; BUF_PUSH (notwordchar); break; case '<': BUF_PUSH (wordbeg); break; case '>': BUF_PUSH (wordend); break; case 'b': BUF_PUSH (wordbound); break; case 'B': BUF_PUSH (notwordbound); break; case '`': BUF_PUSH (begbuf); break; case '\'': BUF_PUSH (endbuf); break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (syntax & RE_NO_BK_REFS) goto normal_char; c1 = c - '0'; if (c1 > regnum) return REG_ESUBREG; /* Can't back reference to a subexpression if inside of it. */ if (group_in_compile_stack (compile_stack, c1)) goto normal_char; laststart = b; BUF_PUSH_2 (duplicate, c1); break; case '+': case '?': if (syntax & RE_BK_PLUS_QM) goto handle_plus; else goto normal_backslash; default: normal_backslash: /* You might think it would be useful for \ to mean not to translate; but if we don't translate it it will never match anything. */ c = TRANSLATE (c); goto normal_char; } break; default: /* Expects the character in `c'. */ normal_char: /* If no exactn currently being built. */ if (!pending_exact /* If last exactn not at current position. */ || pending_exact + *pending_exact + 1 != b /* We have only one byte following the exactn for the count. */ || *pending_exact == (1 << BYTEWIDTH) - 1 /* If followed by a repetition operator. */ || *p == '*' || *p == '^' || ((syntax & RE_BK_PLUS_QM) ? *p == '\\' && (p[1] == '+' || p[1] == '?') : (*p == '+' || *p == '?')) || ((syntax & RE_INTERVALS) && ((syntax & RE_NO_BK_BRACES) ? *p == '{' : (p[0] == '\\' && p[1] == '{')))) { /* Start building a new exactn. */ laststart = b; BUF_PUSH_2 (exactn, 0); pending_exact = b - 1; } BUF_PUSH (c); (*pending_exact)++; break; } /* switch (c) */ } /* while p != pend */ /* Through the pattern now. */ if (fixup_alt_jump) STORE_JUMP (jump_past_alt, fixup_alt_jump, b); if (!COMPILE_STACK_EMPTY) return REG_EPAREN; free (compile_stack.stack); /* We have succeeded; set the length of the buffer. */ bufp->used = b - bufp->buffer; #ifdef DEBUG if (debug) { DEBUG_PRINT1 ("\nCompiled pattern: \n"); print_compiled_pattern (bufp); } #endif /* DEBUG */ return REG_NOERROR; } /* regex_compile */ /* Subroutines for `regex_compile'. */ /* Store OP at LOC followed by two-byte integer parameter ARG. */ static void store_op1 (op, loc, arg) re_opcode_t op; unsigned char *loc; int arg; { *loc = (unsigned char) op; STORE_NUMBER (loc + 1, arg); } /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ static void store_op2 (op, loc, arg1, arg2) re_opcode_t op; unsigned char *loc; int arg1, arg2; { *loc = (unsigned char) op; STORE_NUMBER (loc + 1, arg1); STORE_NUMBER (loc + 3, arg2); } /* Copy the bytes from LOC to END to open up three bytes of space at LOC for OP followed by two-byte integer parameter ARG. */ static void insert_op1 (op, loc, arg, end) re_opcode_t op; unsigned char *loc; int arg; unsigned char *end; { register unsigned char *pfrom = end; register unsigned char *pto = end + 3; while (pfrom != loc) *--pto = *--pfrom; store_op1 (op, loc, arg); } /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ static void insert_op2 (op, loc, arg1, arg2, end) re_opcode_t op; unsigned char *loc; int arg1, arg2; unsigned char *end; { register unsigned char *pfrom = end; register unsigned char *pto = end + 5; while (pfrom != loc) *--pto = *--pfrom; store_op2 (op, loc, arg1, arg2); } /* P points to just after a ^ in PATTERN. Return true if that ^ comes after an alternative or a begin-subexpression. We assume there is at least one character before the ^. */ static boolean at_begline_loc_p (pattern, p, syntax) const char *pattern, *p; reg_syntax_t syntax; { const char *prev = p - 2; boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; return /* After a subexpression? */ (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) /* After an alternative? */ || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); } /* The dual of at_begline_loc_p. This one is for $. We assume there is at least one character after the $, i.e., `P < PEND'. */ static boolean at_endline_loc_p (p, pend, syntax) const char *p, *pend; int syntax; { const char *next = p; boolean next_backslash = *next == '\\'; const char *next_next = p + 1 < pend ? p + 1 : NULL; return /* Before a subexpression? */ (syntax & RE_NO_BK_PARENS ? *next == ')' : next_backslash && next_next && *next_next == ')') /* Before an alternative? */ || (syntax & RE_NO_BK_VBAR ? *next == '|' : next_backslash && next_next && *next_next == '|'); } /* Returns true if REGNUM is in one of COMPILE_STACK's elements and false if it's not. */ static boolean group_in_compile_stack (compile_stack, regnum) compile_stack_type compile_stack; regnum_t regnum; { int this_element; for (this_element = compile_stack.avail - 1; this_element >= 0; this_element--) if (compile_stack.stack[this_element].regnum == regnum) return true; return false; } /* Read the ending character of a range (in a bracket expression) from the uncompiled pattern *P_PTR (which ends at PEND). We assume the starting character is in `P[-2]'. (`P[-1]' is the character `-'.) Then we set the translation of all bits between the starting and ending characters (inclusive) in the compiled pattern B. Return an error code. We use these short variable names so we can use the same macros as `regex_compile' itself. */ static reg_errcode_t compile_range (p_ptr, pend, translate, syntax, b) const char **p_ptr, *pend; char *translate; reg_syntax_t syntax; unsigned char *b; { unsigned this_char; const char *p = *p_ptr; int range_start, range_end; if (p == pend) return REG_ERANGE; /* Even though the pattern is a signed `char *', we need to fetch with unsigned char *'s; if the high bit of the pattern character is set, the range endpoints will be negative if we fetch using a signed char *. We also want to fetch the endpoints without translating them; the appropriate translation is done in the bit-setting loop below. */ range_start = ((unsigned char *) p)[-2]; range_end = ((unsigned char *) p)[0]; /* Have to increment the pointer into the pattern string, so the caller isn't still at the ending character. */ (*p_ptr)++; /* If the start is after the end, the range is empty. */ if (range_start > range_end) return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; /* Here we see why `this_char' has to be larger than an `unsigned char' -- the range is inclusive, so if `range_end' == 0xff (assuming 8-bit characters), we would otherwise go into an infinite loop, since all characters <= 0xff. */ for (this_char = range_start; this_char <= range_end; this_char++) { SET_LIST_BIT (TRANSLATE (this_char)); } return REG_NOERROR; } /* Failure stack declarations and macros; both re_compile_fastmap and re_match_2 use a failure stack. These have to be macros because of REGEX_ALLOCATE. */ /* Number of failure points for which to initially allocate space when matching. If this number is exceeded, we allocate more space, so it is not a hard limit. */ #ifndef INIT_FAILURE_ALLOC #define INIT_FAILURE_ALLOC 5 #endif /* Roughly the maximum number of failure points on the stack. Would be exactly that if always used MAX_FAILURE_SPACE each time we failed. This is a variable only so users of regex can assign to it; we never change it ourselves. */ int re_max_failures = 2000; typedef const unsigned char *fail_stack_elt_t; typedef struct { fail_stack_elt_t *stack; unsigned size; unsigned avail; /* Offset of next open position. */ } fail_stack_type; #define FAIL_STACK_EMPTY() (fail_stack.avail == 0) #define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) #define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) #define FAIL_STACK_TOP() (fail_stack.stack[fail_stack.avail]) /* Initialize `fail_stack'. Do `return -2' if the alloc fails. */ #define INIT_FAIL_STACK() \ do { \ fail_stack.stack = (fail_stack_elt_t *) \ REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \ \ if (fail_stack.stack == NULL) \ return -2; \ \ fail_stack.size = INIT_FAILURE_ALLOC; \ fail_stack.avail = 0; \ } while (0) /* Double the size of FAIL_STACK, up to approximately `re_max_failures' items. Return 1 if succeeds, and 0 if either ran out of memory allocating space for it or it was already too large. REGEX_REALLOCATE requires `destination' be declared. */ #define DOUBLE_FAIL_STACK(fail_stack) \ ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \ ? 0 \ : ((fail_stack).stack = (fail_stack_elt_t *) \ REGEX_REALLOCATE ((fail_stack).stack, \ (fail_stack).size * sizeof (fail_stack_elt_t), \ ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \ \ (fail_stack).stack == NULL \ ? 0 \ : ((fail_stack).size <<= 1, \ 1))) /* Push PATTERN_OP on FAIL_STACK. Return 1 if was able to do so and 0 if ran out of memory allocating space to do so. */ #define PUSH_PATTERN_OP(pattern_op, fail_stack) \ ((FAIL_STACK_FULL () \ && !DOUBLE_FAIL_STACK (fail_stack)) \ ? 0 \ : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \ 1)) /* This pushes an item onto the failure stack. Must be a four-byte value. Assumes the variable `fail_stack'. Probably should only be called from within `PUSH_FAILURE_POINT'. */ #define PUSH_FAILURE_ITEM(item) \ fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item /* The complement operation. Assumes `fail_stack' is nonempty. */ #define POP_FAILURE_ITEM() fail_stack.stack[--fail_stack.avail] /* Used to omit pushing failure point id's when we're not debugging. */ #ifdef DEBUG #define DEBUG_PUSH PUSH_FAILURE_ITEM #define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_ITEM () #else #define DEBUG_PUSH(item) #define DEBUG_POP(item_addr) #endif /* Push the information about the state we will need if we ever fail back to it. Requires variables fail_stack, regstart, regend, reg_info, and num_regs be declared. DOUBLE_FAIL_STACK requires `destination' be declared. Does `return FAILURE_CODE' if runs out of memory. */ #define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \ do { \ char *destination; \ /* Must be int, so when we don't save any registers, the arithmetic \ of 0 + -1 isn't done as unsigned. */ \ int this_reg; \ \ DEBUG_STATEMENT (failure_id++); \ DEBUG_STATEMENT (nfailure_points_pushed++); \ DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \ DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\ DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\ \ DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \ DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \ \ /* Ensure we have enough space allocated for what we will push. */ \ while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \ { \ if (!DOUBLE_FAIL_STACK (fail_stack)) \ return failure_code; \ \ DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \ (fail_stack).size); \ DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\ } \ \ /* Push the info, starting with the registers. */ \ DEBUG_PRINT1 ("\n"); \ \ for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \ this_reg++) \ { \ DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \ DEBUG_STATEMENT (num_regs_pushed++); \ \ DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ PUSH_FAILURE_ITEM (regstart[this_reg]); \ \ DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ PUSH_FAILURE_ITEM (regend[this_reg]); \ \ DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \ DEBUG_PRINT2 (" match_null=%d", \ REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \ DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \ DEBUG_PRINT2 (" matched_something=%d", \ MATCHED_SOMETHING (reg_info[this_reg])); \ DEBUG_PRINT2 (" ever_matched=%d", \ EVER_MATCHED_SOMETHING (reg_info[this_reg])); \ DEBUG_PRINT1 ("\n"); \ PUSH_FAILURE_ITEM (reg_info[this_reg].word); \ } \ \ DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\ PUSH_FAILURE_ITEM (lowest_active_reg); \ \ DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\ PUSH_FAILURE_ITEM (highest_active_reg); \ \ DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \ DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ PUSH_FAILURE_ITEM (pattern_place); \ \ DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \ DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \ size2); \ DEBUG_PRINT1 ("'\n"); \ PUSH_FAILURE_ITEM (string_place); \ \ DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \ DEBUG_PUSH (failure_id); \ } while (0) /* This is the number of items that are pushed and popped on the stack for each register. */ #define NUM_REG_ITEMS 3 /* Individual items aside from the registers. */ #ifdef DEBUG #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ #else #define NUM_NONREG_ITEMS 4 #endif /* We push at most this many items on the stack. */ #define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS) /* We actually push this many items. */ #define NUM_FAILURE_ITEMS \ ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ + NUM_NONREG_ITEMS) /* How many items can still be added to the stack without overflowing it. */ #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) /* Pops what PUSH_FAIL_STACK pushes. We restore into the parameters, all of which should be lvalues: STR -- the saved data position. PAT -- the saved pattern position. LOW_REG, HIGH_REG -- the highest and lowest active registers. REGSTART, REGEND -- arrays of string positions. REG_INFO -- array of information about each subexpression. Also assumes the variables `fail_stack' and (if debugging), `bufp', `pend', `string1', `size1', `string2', and `size2'. */ #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\ { \ DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \ int this_reg; \ const unsigned char *string_temp; \ \ assert (!FAIL_STACK_EMPTY ()); \ \ /* Remove failure points and point to how many regs pushed. */ \ DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \ DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \ DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \ \ assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ \ DEBUG_POP (&failure_id); \ DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \ \ /* If the saved string location is NULL, it came from an \ on_failure_keep_string_jump opcode, and we want to throw away the \ saved NULL, thus retaining our current position in the string. */ \ string_temp = POP_FAILURE_ITEM (); \ if (string_temp != NULL) \ str = (const char *) string_temp; \ \ DEBUG_PRINT2 (" Popping string 0x%x: `", str); \ DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \ DEBUG_PRINT1 ("'\n"); \ \ pat = (unsigned char *) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \ DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ \ /* Restore register info. */ \ high_reg = (unsigned) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ \ low_reg = (unsigned) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ \ for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ { \ DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \ \ reg_info[this_reg].word = POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \ \ regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \ \ regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \ DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \ } \ \ DEBUG_STATEMENT (nfailure_points_popped++); \ } /* POP_FAILURE_POINT */ /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible characters can start a string that matches the pattern. This fastmap is used by re_search to skip quickly over impossible starting points. The caller must supply the address of a (1 << BYTEWIDTH)-byte data area as BUFP->fastmap. We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in the pattern buffer. Returns 0 if we succeed, -2 if an internal error. */ int re_compile_fastmap (bufp) struct re_pattern_buffer *bufp; { int j, k; fail_stack_type fail_stack; #ifndef REGEX_MALLOC char *destination; #endif /* We don't push any register information onto the failure stack. */ unsigned num_regs = 0; register char *fastmap = bufp->fastmap; unsigned char *pattern = bufp->buffer; unsigned long size = bufp->used; const unsigned char *p = pattern; register unsigned char *pend = pattern + size; /* Assume that each path through the pattern can be null until proven otherwise. We set this false at the bottom of switch statement, to which we get only if a particular path doesn't match the empty string. */ boolean path_can_be_null = true; /* We aren't doing a `succeed_n' to begin with. */ boolean succeed_n_p = false; assert (fastmap != NULL && p != NULL); INIT_FAIL_STACK (); bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */ bufp->fastmap_accurate = 1; /* It will be when we're done. */ bufp->can_be_null = 0; while (p != pend || !FAIL_STACK_EMPTY ()) { if (p == pend) { bufp->can_be_null |= path_can_be_null; /* Reset for next path. */ path_can_be_null = true; p = fail_stack.stack[--fail_stack.avail]; } /* We should never be about to go beyond the end of the pattern. */ assert (p < pend); #ifdef SWITCH_ENUM_BUG switch ((int) ((re_opcode_t) *p++)) #else switch ((re_opcode_t) *p++) #endif { /* I guess the idea here is to simply not bother with a fastmap if a backreference is used, since it's too hard to figure out the fastmap for the corresponding group. Setting `can_be_null' stops `re_search_2' from using the fastmap, so that is all we do. */ case duplicate: bufp->can_be_null = 1; return 0; /* Following are the cases which match a character. These end with `break'. */ case exactn: fastmap[p[1]] = 1; break; case charset: for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) fastmap[j] = 1; break; case charset_not: /* Chars beyond end of map must be allowed. */ for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) fastmap[j] = 1; for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) fastmap[j] = 1; break; case wordchar: for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) == Sword) fastmap[j] = 1; break; case notwordchar: for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) != Sword) fastmap[j] = 1; break; case anychar: /* `.' matches anything ... */ for (j = 0; j < (1 << BYTEWIDTH); j++) fastmap[j] = 1; /* ... except perhaps newline. */ if (!(bufp->syntax & RE_DOT_NEWLINE)) fastmap['\n'] = 0; /* Return if we have already set `can_be_null'; if we have, then the fastmap is irrelevant. Something's wrong here. */ else if (bufp->can_be_null) return 0; /* Otherwise, have to check alternative paths. */ break; #ifdef emacs case syntaxspec: k = *p++; for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) == (enum syntaxcode) k) fastmap[j] = 1; break; case notsyntaxspec: k = *p++; for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) != (enum syntaxcode) k) fastmap[j] = 1; break; /* All cases after this match the empty string. These end with `continue'. */ case before_dot: case at_dot: case after_dot: continue; #endif /* not emacs */ case no_op: case begline: case endline: case begbuf: case endbuf: case wordbound: case notwordbound: case wordbeg: case wordend: case push_dummy_failure: continue; case jump_n: case pop_failure_jump: case maybe_pop_jump: case jump: case jump_past_alt: case dummy_failure_jump: EXTRACT_NUMBER_AND_INCR (j, p); p += j; if (j > 0) continue; /* Jump backward implies we just went through the body of a loop and matched nothing. Opcode jumped to should be `on_failure_jump' or `succeed_n'. Just treat it like an ordinary jump. For a * loop, it has pushed its failure point already; if so, discard that as redundant. */ if ((re_opcode_t) *p != on_failure_jump && (re_opcode_t) *p != succeed_n) continue; p++; EXTRACT_NUMBER_AND_INCR (j, p); p += j; /* If what's on the stack is where we are now, pop it. */ if (!FAIL_STACK_EMPTY () && fail_stack.stack[fail_stack.avail - 1] == p) fail_stack.avail--; continue; case on_failure_jump: case on_failure_keep_string_jump: handle_on_failure_jump: EXTRACT_NUMBER_AND_INCR (j, p); /* For some patterns, e.g., `(a?)?', `p+j' here points to the end of the pattern. We don't want to push such a point, since when we restore it above, entering the switch will increment `p' past the end of the pattern. We don't need to push such a point since we obviously won't find any more fastmap entries beyond `pend'. Such a pattern can match the null string, though. */ if (p + j < pend) { if (!PUSH_PATTERN_OP (p + j, fail_stack)) return -2; } else bufp->can_be_null = 1; if (succeed_n_p) { EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ succeed_n_p = false; } continue; case succeed_n: /* Get to the number of times to succeed. */ p += 2; /* Increment p past the n for when k != 0. */ EXTRACT_NUMBER_AND_INCR (k, p); if (k == 0) { p -= 4; succeed_n_p = true; /* Spaghetti code alert. */ goto handle_on_failure_jump; } continue; case set_number_at: p += 4; continue; case start_memory: case stop_memory: p += 2; continue; default: abort (); /* We have listed all the cases. */ } /* switch *p++ */ /* Getting here means we have found the possible starting characters for one path of the pattern -- and that the empty string does not match. We need not follow this path further. Instead, look at the next alternative (remembered on the stack), or quit if no more. The test at the top of the loop does these things. */ path_can_be_null = false; p = pend; } /* while p */ /* Set `can_be_null' for the last path (also the first path, if the pattern is empty). */ bufp->can_be_null |= path_can_be_null; return 0; } /* re_compile_fastmap */ /* Set REGS to hold NUM_REGS registers, storing them in STARTS and ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use this memory for recording register information. STARTS and ENDS must be allocated using the malloc library routine, and must each be at least NUM_REGS * sizeof (regoff_t) bytes long. If NUM_REGS == 0, then subsequent matches should allocate their own register data. Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ void re_set_registers (bufp, regs, num_regs, starts, ends) struct re_pattern_buffer *bufp; struct re_registers *regs; unsigned num_regs; regoff_t *starts, *ends; { if (num_regs) { bufp->regs_allocated = REGS_REALLOCATE; regs->num_regs = num_regs; regs->start = starts; regs->end = ends; } else { bufp->regs_allocated = REGS_UNALLOCATED; regs->num_regs = 0; regs->start = regs->end = (regoff_t) 0; } } /* Searching routines. */ /* Like re_search_2, below, but only one string is specified, and doesn't let you say where to stop matching. */ int re_search (bufp, string, size, startpos, range, regs) struct re_pattern_buffer *bufp; const char *string; int size, startpos, range; struct re_registers *regs; { return re_search_2 (bufp, NULL, 0, string, size, startpos, range, regs, size); } /* Using the compiled pattern in BUFP->buffer, first tries to match the virtual concatenation of STRING1 and STRING2, starting first at index STARTPOS, then at STARTPOS + 1, and so on. STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. RANGE is how far to scan while trying to match. RANGE = 0 means try only at STARTPOS; in general, the last start tried is STARTPOS + RANGE. In REGS, return the indices of the virtual concatenation of STRING1 and STRING2 that matched the entire BUFP->buffer and its contained subexpressions. Do not consider matching one past the index STOP in the virtual concatenation of STRING1 and STRING2. We return either the position in the strings at which the match was found, -1 if no match, or -2 if error (such as failure stack overflow). */ int re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) struct re_pattern_buffer *bufp; const char *string1, *string2; int size1, size2; int startpos; int range; struct re_registers *regs; int stop; { int val; register char *fastmap = bufp->fastmap; register char *translate = bufp->translate; int total_size = size1 + size2; int endpos = startpos + range; /* Check for out-of-range STARTPOS. */ if (startpos < 0 || startpos > total_size) return -1; /* Fix up RANGE if it might eventually take us outside the virtual concatenation of STRING1 and STRING2. */ if (endpos < -1) range = -1 - startpos; else if (endpos > total_size) range = total_size - startpos; /* If the search isn't to be a backwards one, don't waste time in a search for a pattern that must be anchored. */ if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) { if (startpos > 0) return -1; else range = 1; } /* Update the fastmap now if not correct already. */ if (fastmap && !bufp->fastmap_accurate) if (re_compile_fastmap (bufp) == -2) return -2; /* Loop through the string, looking for a place to start matching. */ for (;;) { /* If a fastmap is supplied, skip quickly over characters that cannot be the start of a match. If the pattern can match the null string, however, we don't need to skip characters; we want the first null string. */ if (fastmap && startpos < total_size && !bufp->can_be_null) { if (range > 0) /* Searching forwards. */ { register const char *d; register int lim = 0; int irange = range; if (startpos < size1 && startpos + range >= size1) lim = range - (size1 - startpos); d = (startpos >= size1 ? string2 - size1 : string1) + startpos; /* Written out as an if-else to avoid testing `translate' inside the loop. */ if (translate) while (range > lim && !fastmap[(unsigned char) translate[(unsigned char) *d++]]) range--; else while (range > lim && !fastmap[(unsigned char) *d++]) range--; startpos += irange - range; } else /* Searching backwards. */ { register char c = (size1 == 0 || startpos >= size1 ? string2[startpos - size1] : string1[startpos]); if (!fastmap[(unsigned char) TRANSLATE (c)]) goto advance; } } /* If can't match the null string, and that's all we have left, fail. */ if (range >= 0 && startpos == total_size && fastmap && !bufp->can_be_null) return -1; val = re_match_2 (bufp, string1, size1, string2, size2, startpos, regs, stop); if (val >= 0) return startpos; if (val == -2) return -2; advance: if (!range) break; else if (range > 0) { range--; startpos++; } else { range++; startpos--; } } return -1; } /* re_search_2 */ /* Declarations and macros for re_match_2. */ static int bcmp_translate (); static boolean alt_match_null_string_p (), common_op_match_null_string_p (), group_match_null_string_p (); /* Structure for per-register (a.k.a. per-group) information. This must not be longer than one word, because we push this value onto the failure stack. Other register information, such as the starting and ending positions (which are addresses), and the list of inner groups (which is a bits list) are maintained in separate variables. We are making a (strictly speaking) nonportable assumption here: that the compiler will pack our bit fields into something that fits into the type of `word', i.e., is something that fits into one item on the failure stack. */ typedef union { fail_stack_elt_t word; struct { /* This field is one if this group can match the empty string, zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ #define MATCH_NULL_UNSET_VALUE 3 unsigned match_null_string_p : 2; unsigned is_active : 1; unsigned matched_something : 1; unsigned ever_matched_something : 1; } bits; } register_info_type; #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) #define IS_ACTIVE(R) ((R).bits.is_active) #define MATCHED_SOMETHING(R) ((R).bits.matched_something) #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) /* Call this when have matched a real character; it sets `matched' flags for the subexpressions which we are currently inside. Also records that those subexprs have matched. */ #define SET_REGS_MATCHED() \ do \ { \ unsigned r; \ for (r = lowest_active_reg; r <= highest_active_reg; r++) \ { \ MATCHED_SOMETHING (reg_info[r]) \ = EVER_MATCHED_SOMETHING (reg_info[r]) \ = 1; \ } \ } \ while (0) /* This converts PTR, a pointer into one of the search strings `string1' and `string2' into an offset from the beginning of that string. */ #define POINTER_TO_OFFSET(ptr) \ (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1) /* Registers are set to a sentinel when they haven't yet matched. */ #define REG_UNSET_VALUE ((char *) -1) #define REG_UNSET(e) ((e) == REG_UNSET_VALUE) /* Macros for dealing with the split strings in re_match_2. */ #define MATCHING_IN_FIRST_STRING (dend == end_match_1) /* Call before fetching a character with *d. This switches over to string2 if necessary. */ #define PREFETCH() \ while (d == dend) \ { \ /* End of string2 => fail. */ \ if (dend == end_match_2) \ goto fail; \ /* End of string1 => advance to string2. */ \ d = string2; \ dend = end_match_2; \ } /* Test if at very beginning or at very end of the virtual concatenation of `string1' and `string2'. If only one string, it's `string2'. */ #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) #define AT_STRINGS_END(d) ((d) == end2) /* Test if D points to a character which is word-constituent. We have two special cases to check for: if past the end of string1, look at the first character in string2; and if before the beginning of string2, look at the last character in string1. */ #define WORDCHAR_P(d) \ (SYNTAX ((d) == end1 ? *string2 \ : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ == Sword) /* Test if the character before D and the one at D differ with respect to being word-constituent. */ #define AT_WORD_BOUNDARY(d) \ (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \ || WORDCHAR_P (d - 1) != WORDCHAR_P (d)) /* Free everything we malloc. */ #ifdef REGEX_MALLOC #define FREE_VAR(var) if (var) free (var); var = NULL #define FREE_VARIABLES() \ do { \ FREE_VAR (fail_stack.stack); \ FREE_VAR (regstart); \ FREE_VAR (regend); \ FREE_VAR (old_regstart); \ FREE_VAR (old_regend); \ FREE_VAR (best_regstart); \ FREE_VAR (best_regend); \ FREE_VAR (reg_info); \ FREE_VAR (reg_dummy); \ FREE_VAR (reg_info_dummy); \ } while (0) #else /* not REGEX_MALLOC */ /* Some MIPS systems (at least) want this to free alloca'd storage. */ #define FREE_VARIABLES() alloca (0) #endif /* not REGEX_MALLOC */ /* These values must meet several constraints. They must not be valid register values; since we have a limit of 255 registers (because we use only one byte in the pattern for the register number), we can use numbers larger than 255. They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value for the lowest register must be larger than the value for the highest register, so we do not try to actually save any registers when none are active. */ #define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH) #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) /* Matching routines. */ #ifndef emacs /* Emacs never uses this. */ /* re_match is like re_match_2 except it takes only a single string. */ int re_match (bufp, string, size, pos, regs) struct re_pattern_buffer *bufp; const char *string; int size, pos; struct re_registers *regs; { return re_match_2 (bufp, NULL, 0, string, size, pos, regs, size); } #endif /* not emacs */ /* re_match_2 matches the compiled pattern in BUFP against the the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and SIZE2, respectively). We start matching at POS, and stop matching at STOP. If REGS is non-null and the `no_sub' field of BUFP is nonzero, we store offsets for the substring each group matched in REGS. See the documentation for exactly how many groups we fill. We return -1 if no match, -2 if an internal error (such as the failure stack overflowing). Otherwise, we return the length of the matched substring. */ int re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) struct re_pattern_buffer *bufp; const char *string1, *string2; int size1, size2; int pos; struct re_registers *regs; int stop; { /* General temporaries. */ int mcnt; unsigned char *p1; /* Just past the end of the corresponding string. */ const char *end1, *end2; /* Pointers into string1 and string2, just past the last characters in each to consider matching. */ const char *end_match_1, *end_match_2; /* Where we are in the data, and the end of the current string. */ const char *d, *dend; /* Where we are in the pattern, and the end of the pattern. */ unsigned char *p = bufp->buffer; register unsigned char *pend = p + bufp->used; /* We use this to map every character in the string. */ char *translate = bufp->translate; /* Failure point stack. Each place that can handle a failure further down the line pushes a failure point on this stack. It consists of restart, regend, and reg_info for all registers corresponding to the subexpressions we're currently inside, plus the number of such registers, and, finally, two char *'s. The first char * is where to resume scanning the pattern; the second one is where to resume scanning the strings. If the latter is zero, the failure point is a ``dummy''; if a failure happens and the failure point is a dummy, it gets discarded and the next next one is tried. */ fail_stack_type fail_stack; #ifdef DEBUG static unsigned failure_id = 0; unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; #endif /* We fill all the registers internally, independent of what we return, for use in backreferences. The number here includes an element for register zero. */ unsigned num_regs = bufp->re_nsub + 1; /* The currently active registers. */ unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG; unsigned highest_active_reg = NO_HIGHEST_ACTIVE_REG; /* Information on the contents of registers. These are pointers into the input strings; they record just what was matched (on this attempt) by a subexpression part of the pattern, that is, the regnum-th regstart pointer points to where in the pattern we began matching and the regnum-th regend points to right after where we stopped matching the regnum-th subexpression. (The zeroth register keeps track of what the whole pattern matches.) */ const char **regstart, **regend; /* If a group that's operated upon by a repetition operator fails to match anything, then the register for its start will need to be restored because it will have been set to wherever in the string we are when we last see its open-group operator. Similarly for a register's end. */ const char **old_regstart, **old_regend; /* The is_active field of reg_info helps us keep track of which (possibly nested) subexpressions we are currently in. The matched_something field of reg_info[reg_num] helps us tell whether or not we have matched any of the pattern so far this time through the reg_num-th subexpression. These two fields get reset each time through any loop their register is in. */ register_info_type *reg_info; /* The following record the register info as found in the above variables when we find a match better than any we've seen before. This happens as we backtrack through the failure points, which in turn happens only if we have not yet matched the entire string. */ unsigned best_regs_set = false; const char **best_regstart, **best_regend; /* Logically, this is `best_regend[0]'. But we don't want to have to allocate space for that if we're not allocating space for anything else (see below). Also, we never need info about register 0 for any of the other register vectors, and it seems rather a kludge to treat `best_regend' differently than the rest. So we keep track of the end of the best match so far in a separate variable. We initialize this to NULL so that when we backtrack the first time and need to test it, it's not garbage. */ const char *match_end = NULL; /* Used when we pop values we don't care about. */ const char **reg_dummy; register_info_type *reg_info_dummy; #ifdef DEBUG /* Counts the total number of registers pushed. */ unsigned num_regs_pushed = 0; #endif DEBUG_PRINT1 ("\n\nEntering re_match_2.\n"); INIT_FAIL_STACK (); /* Do not bother to initialize all the register variables if there are no groups in the pattern, as it takes a fair amount of time. If there are groups, we include space for register 0 (the whole pattern), even though we never use it, since it simplifies the array indexing. We should fix this. */ if (bufp->re_nsub) { regstart = REGEX_TALLOC (num_regs, const char *); regend = REGEX_TALLOC (num_regs, const char *); old_regstart = REGEX_TALLOC (num_regs, const char *); old_regend = REGEX_TALLOC (num_regs, const char *); best_regstart = REGEX_TALLOC (num_regs, const char *); best_regend = REGEX_TALLOC (num_regs, const char *); reg_info = REGEX_TALLOC (num_regs, register_info_type); reg_dummy = REGEX_TALLOC (num_regs, const char *); reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); if (!(regstart && regend && old_regstart && old_regend && reg_info && best_regstart && best_regend && reg_dummy && reg_info_dummy)) { FREE_VARIABLES (); return -2; } } #ifdef REGEX_MALLOC else { /* We must initialize all our variables to NULL, so that `FREE_VARIABLES' doesn't try to free them. */ regstart = regend = old_regstart = old_regend = best_regstart = best_regend = reg_dummy = NULL; reg_info = reg_info_dummy = (register_info_type *) NULL; } #endif /* REGEX_MALLOC */ /* The starting position is bogus. */ if (pos < 0 || pos > size1 + size2) { FREE_VARIABLES (); return -1; } /* Initialize subexpression text positions to -1 to mark ones that no start_memory/stop_memory has been seen for. Also initialize the register information struct. */ for (mcnt = 1; mcnt < num_regs; mcnt++) { regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE; REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; IS_ACTIVE (reg_info[mcnt]) = 0; MATCHED_SOMETHING (reg_info[mcnt]) = 0; EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; } /* We move `string1' into `string2' if the latter's empty -- but not if `string1' is null. */ if (size2 == 0 && string1 != NULL) { string2 = string1; size2 = size1; string1 = 0; size1 = 0; } end1 = string1 + size1; end2 = string2 + size2; /* Compute where to stop matching, within the two strings. */ if (stop <= size1) { end_match_1 = string1 + stop; end_match_2 = string2; } else { end_match_1 = end1; end_match_2 = string2 + stop - size1; } /* `p' scans through the pattern as `d' scans through the data. `dend' is the end of the input string that `d' points within. `d' is advanced into the following input string whenever necessary, but this happens before fetching; therefore, at the beginning of the loop, `d' can be pointing at the end of a string, but it cannot equal `string2'. */ if (size1 > 0 && pos <= size1) { d = string1 + pos; dend = end_match_1; } else { d = string2 + pos - size1; dend = end_match_2; } DEBUG_PRINT1 ("The compiled pattern is: "); DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend); DEBUG_PRINT1 ("The string to match is: `"); DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); DEBUG_PRINT1 ("'\n"); /* This loops over pattern commands. It exits by returning from the function if the match is complete, or it drops through if the match fails at this starting point in the input data. */ for (;;) { DEBUG_PRINT2 ("\n0x%x: ", p); if (p == pend) { /* End of pattern means we might have succeeded. */ DEBUG_PRINT1 ("end of pattern ... "); /* If we haven't matched the entire string, and we want the longest match, try backtracking. */ if (d != end_match_2) { DEBUG_PRINT1 ("backtracking.\n"); if (!FAIL_STACK_EMPTY ()) { /* More failure points to try. */ boolean same_str_p = (FIRST_STRING_P (match_end) == MATCHING_IN_FIRST_STRING); /* If exceeds best match so far, save it. */ if (!best_regs_set || (same_str_p && d > match_end) || (!same_str_p && !MATCHING_IN_FIRST_STRING)) { best_regs_set = true; match_end = d; DEBUG_PRINT1 ("\nSAVING match as best so far.\n"); for (mcnt = 1; mcnt < num_regs; mcnt++) { best_regstart[mcnt] = regstart[mcnt]; best_regend[mcnt] = regend[mcnt]; } } goto fail; } /* If no failure points, don't restore garbage. */ else if (best_regs_set) { restore_best_regs: /* Restore best match. It may happen that `dend == end_match_1' while the restored d is in string2. For example, the pattern `x.*y.*z' against the strings `x-' and `y-z-', if the two strings are not consecutive in memory. */ DEBUG_PRINT1 ("Restoring best registers.\n"); d = match_end; dend = ((d >= string1 && d <= end1) ? end_match_1 : end_match_2); for (mcnt = 1; mcnt < num_regs; mcnt++) { regstart[mcnt] = best_regstart[mcnt]; regend[mcnt] = best_regend[mcnt]; } } } /* d != end_match_2 */ DEBUG_PRINT1 ("Accepting match.\n"); /* If caller wants register contents data back, do it. */ if (regs && !bufp->no_sub) { /* Have the register data arrays been allocated? */ if (bufp->regs_allocated == REGS_UNALLOCATED) { /* No. So allocate them with malloc. We need one extra element beyond `num_regs' for the `-1' marker GNU code uses. */ regs->num_regs = MAX (RE_NREGS, num_regs + 1); regs->start = TALLOC (regs->num_regs, regoff_t); regs->end = TALLOC (regs->num_regs, regoff_t); if (regs->start == NULL || regs->end == NULL) return -2; bufp->regs_allocated = REGS_REALLOCATE; } else if (bufp->regs_allocated == REGS_REALLOCATE) { /* Yes. If we need more elements than were already allocated, reallocate them. If we need fewer, just leave it alone. */ if (regs->num_regs < num_regs + 1) { regs->num_regs = num_regs + 1; RETALLOC (regs->start, regs->num_regs, regoff_t); RETALLOC (regs->end, regs->num_regs, regoff_t); if (regs->start == NULL || regs->end == NULL) return -2; } } else { /* These braces fend off a "empty body in an else-statement" warning under GCC when assert expands to nothing. */ assert (bufp->regs_allocated == REGS_FIXED); } /* Convert the pointer data in `regstart' and `regend' to indices. Register zero has to be set differently, since we haven't kept track of any info for it. */ if (regs->num_regs > 0) { regs->start[0] = pos; regs->end[0] = (MATCHING_IN_FIRST_STRING ? d - string1 : d - string2 + size1); } /* Go through the first `min (num_regs, regs->num_regs)' registers, since that is all we initialized. */ for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++) { if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt])) regs->start[mcnt] = regs->end[mcnt] = -1; else { regs->start[mcnt] = POINTER_TO_OFFSET (regstart[mcnt]); regs->end[mcnt] = POINTER_TO_OFFSET (regend[mcnt]); } } /* If the regs structure we return has more elements than were in the pattern, set the extra elements to -1. If we (re)allocated the registers, this is the case, because we always allocate enough to have at least one -1 at the end. */ for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++) regs->start[mcnt] = regs->end[mcnt] = -1; } /* regs && !bufp->no_sub */ FREE_VARIABLES (); DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", nfailure_points_pushed, nfailure_points_popped, nfailure_points_pushed - nfailure_points_popped); DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed); mcnt = d - pos - (MATCHING_IN_FIRST_STRING ? string1 : string2 - size1); DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt); return mcnt; } /* Otherwise match next pattern command. */ #ifdef SWITCH_ENUM_BUG switch ((int) ((re_opcode_t) *p++)) #else switch ((re_opcode_t) *p++) #endif { /* Ignore these. Used to ignore the n of succeed_n's which currently have n == 0. */ case no_op: DEBUG_PRINT1 ("EXECUTING no_op.\n"); break; /* Match the next n pattern characters exactly. The following byte in the pattern defines n, and the n bytes after that are the characters to match. */ case exactn: mcnt = *p++; DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt); /* This is written out as an if-else so we don't waste time testing `translate' inside the loop. */ if (translate) { do { PREFETCH (); if (translate[(unsigned char) *d++] != (char) *p++) goto fail; } while (--mcnt); } else { do { PREFETCH (); if (*d++ != (char) *p++) goto fail; } while (--mcnt); } SET_REGS_MATCHED (); break; /* Match any character except possibly a newline or a null. */ case anychar: DEBUG_PRINT1 ("EXECUTING anychar.\n"); PREFETCH (); if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n') || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000')) goto fail; SET_REGS_MATCHED (); DEBUG_PRINT2 (" Matched `%d'.\n", *d); d++; break; case charset: case charset_not: { register unsigned char c; boolean not = (re_opcode_t) *(p - 1) == charset_not; DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : ""); PREFETCH (); c = TRANSLATE (*d); /* The character to match. */ /* Cast to `unsigned' instead of `unsigned char' in case the bit list is a full 32 bytes long. */ if (c < (unsigned) (*p * BYTEWIDTH) && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) not = !not; p += 1 + *p; if (!not) goto fail; SET_REGS_MATCHED (); d++; break; } /* The beginning of a group is represented by start_memory. The arguments are the register number in the next byte, and the number of groups inner to this one in the next. The text matched within the group is recorded (in the internal registers data structure) under the register number. */ case start_memory: DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]); /* Find out if this group can match the empty string. */ p1 = p; /* To send to group_match_null_string_p. */ if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE) REG_MATCH_NULL_STRING_P (reg_info[*p]) = group_match_null_string_p (&p1, pend, reg_info); /* Save the position in the string where we were the last time we were at this open-group operator in case the group is operated upon by a repetition operator, e.g., with `(a*)*b' against `ab'; then we want to ignore where we are now in the string in case this attempt to match fails. */ old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) ? REG_UNSET (regstart[*p]) ? d : regstart[*p] : regstart[*p]; DEBUG_PRINT2 (" old_regstart: %d\n", POINTER_TO_OFFSET (old_regstart[*p])); regstart[*p] = d; DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p])); IS_ACTIVE (reg_info[*p]) = 1; MATCHED_SOMETHING (reg_info[*p]) = 0; /* This is the new highest active register. */ highest_active_reg = *p; /* If nothing was active before, this is the new lowest active register. */ if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) lowest_active_reg = *p; /* Move past the register number and inner group count. */ p += 2; break; /* The stop_memory opcode represents the end of a group. Its arguments are the same as start_memory's: the register number, and the number of inner groups. */ case stop_memory: DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]); /* We need to save the string position the last time we were at this close-group operator in case the group is operated upon by a repetition operator, e.g., with `((a*)*(b*)*)*' against `aba'; then we want to ignore where we are now in the string in case this attempt to match fails. */ old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p]) ? REG_UNSET (regend[*p]) ? d : regend[*p] : regend[*p]; DEBUG_PRINT2 (" old_regend: %d\n", POINTER_TO_OFFSET (old_regend[*p])); regend[*p] = d; DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p])); /* This register isn't active anymore. */ IS_ACTIVE (reg_info[*p]) = 0; /* If this was the only register active, nothing is active anymore. */ if (lowest_active_reg == highest_active_reg) { lowest_active_reg = NO_LOWEST_ACTIVE_REG; highest_active_reg = NO_HIGHEST_ACTIVE_REG; } else { /* We must scan for the new highest active register, since it isn't necessarily one less than now: consider (a(b)c(d(e)f)g). When group 3 ends, after the f), the new highest active register is 1. */ unsigned char r = *p - 1; while (r > 0 && !IS_ACTIVE (reg_info[r])) r--; /* If we end up at register zero, that means that we saved the registers as the result of an `on_failure_jump', not a `start_memory', and we jumped to past the innermost `stop_memory'. For example, in ((.)*) we save registers 1 and 2 as a result of the *, but when we pop back to the second ), we are at the stop_memory 1. Thus, nothing is active. */ if (r == 0) { lowest_active_reg = NO_LOWEST_ACTIVE_REG; highest_active_reg = NO_HIGHEST_ACTIVE_REG; } else highest_active_reg = r; } /* If just failed to match something this time around with a group that's operated on by a repetition operator, try to force exit from the ``loop'', and restore the register information for this group that we had before trying this last match. */ if ((!MATCHED_SOMETHING (reg_info[*p]) || (re_opcode_t) p[-3] == start_memory) && (p + 2) < pend) { boolean is_a_jump_n = false; p1 = p + 2; mcnt = 0; switch ((re_opcode_t) *p1++) { case jump_n: is_a_jump_n = true; case pop_failure_jump: case maybe_pop_jump: case jump: case dummy_failure_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p1); if (is_a_jump_n) p1 += 2; break; default: /* do nothing */ ; } p1 += mcnt; /* If the next operation is a jump backwards in the pattern to an on_failure_jump right before the start_memory corresponding to this stop_memory, exit from the loop by forcing a failure after pushing on the stack the on_failure_jump's jump in the pattern, and d. */ if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump && (re_opcode_t) p1[3] == start_memory && p1[4] == *p) { /* If this group ever matched anything, then restore what its registers were before trying this last failed match, e.g., with `(a*)*b' against `ab' for regstart[1], and, e.g., with `((a*)*(b*)*)*' against `aba' for regend[3]. Also restore the registers for inner groups for, e.g., `((a*)(b*))*' against `aba' (register 3 would otherwise get trashed). */ if (EVER_MATCHED_SOMETHING (reg_info[*p])) { unsigned r; EVER_MATCHED_SOMETHING (reg_info[*p]) = 0; /* Restore this and inner groups' (if any) registers. */ for (r = *p; r < *p + *(p + 1); r++) { regstart[r] = old_regstart[r]; /* xx why this test? */ if ((int) old_regend[r] >= (int) regstart[r]) regend[r] = old_regend[r]; } } p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); PUSH_FAILURE_POINT (p1 + mcnt, d, -2); goto fail; } } /* Move past the register number and the inner group count. */ p += 2; break; /* \ has been turned into a `duplicate' command which is followed by the numeric value of as the register number. */ case duplicate: { register const char *d2, *dend2; int regno = *p++; /* Get which register to match against. */ DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno); /* Can't back reference a group which we've never matched. */ if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) goto fail; /* Where in input to try to start matching. */ d2 = regstart[regno]; /* Where to stop matching; if both the place to start and the place to stop matching are in the same string, then set to the place to stop, otherwise, for now have to use the end of the first string. */ dend2 = ((FIRST_STRING_P (regstart[regno]) == FIRST_STRING_P (regend[regno])) ? regend[regno] : end_match_1); for (;;) { /* If necessary, advance to next segment in register contents. */ while (d2 == dend2) { if (dend2 == end_match_2) break; if (dend2 == regend[regno]) break; /* End of string1 => advance to string2. */ d2 = string2; dend2 = regend[regno]; } /* At end of register contents => success */ if (d2 == dend2) break; /* If necessary, advance to next segment in data. */ PREFETCH (); /* How many characters left in this segment to match. */ mcnt = dend - d; /* Want how many consecutive characters we can match in one shot, so, if necessary, adjust the count. */ if (mcnt > dend2 - d2) mcnt = dend2 - d2; /* Compare that many; failure if mismatch, else move past them. */ if (translate ? bcmp_translate (d, d2, mcnt, translate) : bcmp (d, d2, mcnt)) goto fail; d += mcnt, d2 += mcnt; } } break; /* begline matches the empty string at the beginning of the string (unless `not_bol' is set in `bufp'), and, if `newline_anchor' is set, after newlines. */ case begline: DEBUG_PRINT1 ("EXECUTING begline.\n"); if (AT_STRINGS_BEG (d)) { if (!bufp->not_bol) break; } else if (d[-1] == '\n' && bufp->newline_anchor) { break; } /* In all other cases, we fail. */ goto fail; /* endline is the dual of begline. */ case endline: DEBUG_PRINT1 ("EXECUTING endline.\n"); if (AT_STRINGS_END (d)) { if (!bufp->not_eol) break; } /* We have to ``prefetch'' the next character. */ else if ((d == end1 ? *string2 : *d) == '\n' && bufp->newline_anchor) { break; } goto fail; /* Match at the very beginning of the data. */ case begbuf: DEBUG_PRINT1 ("EXECUTING begbuf.\n"); if (AT_STRINGS_BEG (d)) break; goto fail; /* Match at the very end of the data. */ case endbuf: DEBUG_PRINT1 ("EXECUTING endbuf.\n"); if (AT_STRINGS_END (d)) break; goto fail; /* on_failure_keep_string_jump is used to optimize `.*\n'. It pushes NULL as the value for the string on the stack. Then `pop_failure_point' will keep the current value for the string, instead of restoring it. To see why, consider matching `foo\nbar' against `.*\n'. The .* matches the foo; then the . fails against the \n. But the next thing we want to do is match the \n against the \n; if we restored the string value, we would be back at the foo. Because this is used only in specific cases, we don't need to check all the things that `on_failure_jump' does, to make sure the right things get saved on the stack. Hence we don't share its code. The only reason to push anything on the stack at all is that otherwise we would have to change `anychar's code to do something besides goto fail in this case; that seems worse than this. */ case on_failure_keep_string_jump: DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump"); EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt); PUSH_FAILURE_POINT (p + mcnt, NULL, -2); break; /* Uses of on_failure_jump: Each alternative starts with an on_failure_jump that points to the beginning of the next alternative. Each alternative except the last ends with a jump that in effect jumps past the rest of the alternatives. (They really jump to the ending jump of the following alternative, because tensioning these jumps is a hassle.) Repeats start with an on_failure_jump that points past both the repetition text and either the following jump or pop_failure_jump back to this on_failure_jump. */ case on_failure_jump: on_failure: DEBUG_PRINT1 ("EXECUTING on_failure_jump"); EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt); /* If this on_failure_jump comes right before a group (i.e., the original * applied to a group), save the information for that group and all inner ones, so that if we fail back to this point, the group's information will be correct. For example, in \(a*\)*\1, we need the preceding group, and in \(\(a*\)b*\)\2, we need the inner group. */ /* We can't use `p' to check ahead because we push a failure point to `p + mcnt' after we do this. */ p1 = p; /* We need to skip no_op's before we look for the start_memory in case this on_failure_jump is happening as the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 against aba. */ while (p1 < pend && (re_opcode_t) *p1 == no_op) p1++; if (p1 < pend && (re_opcode_t) *p1 == start_memory) { /* We have a new highest active register now. This will get reset at the start_memory we are about to get to, but we will have saved all the registers relevant to this repetition op, as described above. */ highest_active_reg = *(p1 + 1) + *(p1 + 2); if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) lowest_active_reg = *(p1 + 1); } DEBUG_PRINT1 (":\n"); PUSH_FAILURE_POINT (p + mcnt, d, -2); break; /* A smart repeat ends with `maybe_pop_jump'. We change it to either `pop_failure_jump' or `jump'. */ case maybe_pop_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); { register unsigned char *p2 = p; /* Compare the beginning of the repeat with what in the pattern follows its end. If we can establish that there is nothing that they would both match, i.e., that we would have to backtrack because of (as in, e.g., `a*a') then we can change to pop_failure_jump, because we'll never have to backtrack. This is not true in the case of alternatives: in `(a|ab)*' we do need to backtrack to the `ab' alternative (e.g., if the string was `ab'). But instead of trying to detect that here, the alternative has put on a dummy failure point which is what we will end up popping. */ /* Skip over open/close-group commands. */ while (p2 + 2 < pend && ((re_opcode_t) *p2 == stop_memory || (re_opcode_t) *p2 == start_memory)) p2 += 3; /* Skip over args, too. */ /* If we're at the end of the pattern, we can change. */ if (p2 == pend) { /* Consider what happens when matching ":\(.*\)" against ":/". I don't really understand this code yet. */ p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT1 (" End of pattern: change to `pop_failure_jump'.\n"); } else if ((re_opcode_t) *p2 == exactn || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) { register unsigned char c = *p2 == (unsigned char) endline ? '\n' : p2[2]; p1 = p + mcnt; /* p1[0] ... p1[2] are the `on_failure_jump' corresponding to the `maybe_finalize_jump' of this case. Examine what follows. */ if ((re_opcode_t) p1[3] == exactn && p1[5] != c) { p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", c, p1[5]); } else if ((re_opcode_t) p1[3] == charset || (re_opcode_t) p1[3] == charset_not) { int not = (re_opcode_t) p1[3] == charset_not; if (c < (unsigned char) (p1[4] * BYTEWIDTH) && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) not = !not; /* `not' is equal to 1 if c would match, which means that we can't change to pop_failure_jump. */ if (!not) { p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT1 (" No match => pop_failure_jump.\n"); } } } } p -= 2; /* Point at relative address again. */ if ((re_opcode_t) p[-1] != pop_failure_jump) { p[-1] = (unsigned char) jump; DEBUG_PRINT1 (" Match => jump.\n"); goto unconditional_jump; } /* Note fall through. */ /* The end of a simple repeat has a pop_failure_jump back to its matching on_failure_jump, where the latter will push a failure point. The pop_failure_jump takes off failure points put on by this pop_failure_jump's matching on_failure_jump; we got through the pattern to here from the matching on_failure_jump, so didn't fail. */ case pop_failure_jump: { /* We need to pass separate storage for the lowest and highest registers, even though we don't care about the actual values. Otherwise, we will restore only one register from the stack, since lowest will == highest in `pop_failure_point'. */ unsigned dummy_low_reg, dummy_high_reg; unsigned char *pdummy; const char *sdummy; DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n"); POP_FAILURE_POINT (sdummy, pdummy, dummy_low_reg, dummy_high_reg, reg_dummy, reg_dummy, reg_info_dummy); } /* Note fall through. */ /* Unconditionally jump (without popping any failure points). */ case jump: unconditional_jump: EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt); p += mcnt; /* Do the jump. */ DEBUG_PRINT2 ("(to 0x%x).\n", p); break; /* We need this opcode so we can detect where alternatives end in `group_match_null_string_p' et al. */ case jump_past_alt: DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n"); goto unconditional_jump; /* Normally, the on_failure_jump pushes a failure point, which then gets popped at pop_failure_jump. We will end up at pop_failure_jump, also, and with a pattern of, say, `a+', we are skipping over the on_failure_jump, so we have to push something meaningless for pop_failure_jump to pop. */ case dummy_failure_jump: DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n"); /* It doesn't matter what we push for the string here. What the code at `fail' tests is the value for the pattern. */ PUSH_FAILURE_POINT (0, 0, -2); goto unconditional_jump; /* At the end of an alternative, we need to push a dummy failure point in case we are followed by a `pop_failure_jump', because we don't want the failure point for the alternative to be popped. For example, matching `(a|ab)*' against `aab' requires that we match the `ab' alternative. */ case push_dummy_failure: DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n"); /* See comments just above at `dummy_failure_jump' about the two zeroes. */ PUSH_FAILURE_POINT (0, 0, -2); break; /* Have to succeed matching what follows at least n times. After that, handle like `on_failure_jump'. */ case succeed_n: EXTRACT_NUMBER (mcnt, p + 2); DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); assert (mcnt >= 0); /* Originally, this is how many times we HAVE to succeed. */ if (mcnt > 0) { mcnt--; p += 2; STORE_NUMBER_AND_INCR (p, mcnt); DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p, mcnt); } else if (mcnt == 0) { DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", p+2); p[2] = (unsigned char) no_op; p[3] = (unsigned char) no_op; goto on_failure; } break; case jump_n: EXTRACT_NUMBER (mcnt, p + 2); DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); /* Originally, this is how many times we CAN jump. */ if (mcnt) { mcnt--; STORE_NUMBER (p + 2, mcnt); goto unconditional_jump; } /* If don't have to jump any more, skip over the rest of command. */ else p += 4; break; case set_number_at: { DEBUG_PRINT1 ("EXECUTING set_number_at.\n"); EXTRACT_NUMBER_AND_INCR (mcnt, p); p1 = p + mcnt; EXTRACT_NUMBER_AND_INCR (mcnt, p); DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt); STORE_NUMBER (p1, mcnt); break; } case wordbound: DEBUG_PRINT1 ("EXECUTING wordbound.\n"); if (AT_WORD_BOUNDARY (d)) break; goto fail; case notwordbound: DEBUG_PRINT1 ("EXECUTING notwordbound.\n"); if (AT_WORD_BOUNDARY (d)) goto fail; break; case wordbeg: DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) break; goto fail; case wordend: DEBUG_PRINT1 ("EXECUTING wordend.\n"); if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1) && (!WORDCHAR_P (d) || AT_STRINGS_END (d))) break; goto fail; #ifdef emacs #ifdef emacs19 case before_dot: DEBUG_PRINT1 ("EXECUTING before_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) >= point) goto fail; break; case at_dot: DEBUG_PRINT1 ("EXECUTING at_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) != point) goto fail; break; case after_dot: DEBUG_PRINT1 ("EXECUTING after_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) <= point) goto fail; break; #else /* not emacs19 */ case at_dot: DEBUG_PRINT1 ("EXECUTING at_dot.\n"); if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point) goto fail; break; #endif /* not emacs19 */ case syntaxspec: DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); mcnt = *p++; goto matchsyntax; case wordchar: DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n"); mcnt = (int) Sword; matchsyntax: PREFETCH (); if (SYNTAX (*d++) != (enum syntaxcode) mcnt) goto fail; SET_REGS_MATCHED (); break; case notsyntaxspec: DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt); mcnt = *p++; goto matchnotsyntax; case notwordchar: DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n"); mcnt = (int) Sword; matchnotsyntax: PREFETCH (); if (SYNTAX (*d++) == (enum syntaxcode) mcnt) goto fail; SET_REGS_MATCHED (); break; #else /* not emacs */ case wordchar: DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); PREFETCH (); if (!WORDCHAR_P (d)) goto fail; SET_REGS_MATCHED (); d++; break; case notwordchar: DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); PREFETCH (); if (WORDCHAR_P (d)) goto fail; SET_REGS_MATCHED (); d++; break; #endif /* not emacs */ default: abort (); } continue; /* Successfully executed one pattern command; keep going. */ /* We goto here if a matching operation fails. */ fail: if (!FAIL_STACK_EMPTY ()) { /* A restart point is known. Restore to that state. */ DEBUG_PRINT1 ("\nFAIL:\n"); POP_FAILURE_POINT (d, p, lowest_active_reg, highest_active_reg, regstart, regend, reg_info); /* If this failure point is a dummy, try the next one. */ if (!p) goto fail; /* If we failed to the end of the pattern, don't examine *p. */ assert (p <= pend); if (p < pend) { boolean is_a_jump_n = false; /* If failed to a backwards jump that's part of a repetition loop, need to pop this failure point and use the next one. */ switch ((re_opcode_t) *p) { case jump_n: is_a_jump_n = true; case maybe_pop_jump: case pop_failure_jump: case jump: p1 = p + 1; EXTRACT_NUMBER_AND_INCR (mcnt, p1); p1 += mcnt; if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n) || (!is_a_jump_n && (re_opcode_t) *p1 == on_failure_jump)) goto fail; break; default: /* do nothing */ ; } } if (d >= string1 && d <= end1) dend = end_match_1; } else break; /* Matching at this starting point really fails. */ } /* for (;;) */ if (best_regs_set) goto restore_best_regs; FREE_VARIABLES (); return -1; /* Failure to match. */ } /* re_match_2 */ /* Subroutine definitions for re_match_2. */ /* We are passed P pointing to a register number after a start_memory. Return true if the pattern up to the corresponding stop_memory can match the empty string, and false otherwise. If we find the matching stop_memory, sets P to point to one past its number. Otherwise, sets P to an undefined byte less than or equal to END. We don't handle duplicates properly (yet). */ static boolean group_match_null_string_p (p, end, reg_info) unsigned char **p, *end; register_info_type *reg_info; { int mcnt; /* Point to after the args to the start_memory. */ unsigned char *p1 = *p + 2; while (p1 < end) { /* Skip over opcodes that can match nothing, and return true or false, as appropriate, when we get to one that can't, or to the matching stop_memory. */ switch ((re_opcode_t) *p1) { /* Could be either a loop or a series of alternatives. */ case on_failure_jump: p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); /* If the next operation is not a jump backwards in the pattern. */ if (mcnt >= 0) { /* Go through the on_failure_jumps of the alternatives, seeing if any of the alternatives cannot match nothing. The last alternative starts with only a jump, whereas the rest start with on_failure_jump and end with a jump, e.g., here is the pattern for `a|b|c': /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6 /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3 /exactn/1/c So, we have to first go through the first (n-1) alternatives and then deal with the last one separately. */ /* Deal with the first (n-1) alternatives, which start with an on_failure_jump (see above) that jumps to right past a jump_past_alt. */ while ((re_opcode_t) p1[mcnt-3] == jump_past_alt) { /* `mcnt' holds how many bytes long the alternative is, including the ending `jump_past_alt' and its number. */ if (!alt_match_null_string_p (p1, p1 + mcnt - 3, reg_info)) return false; /* Move to right after this alternative, including the jump_past_alt. */ p1 += mcnt; /* Break if it's the beginning of an n-th alternative that doesn't begin with an on_failure_jump. */ if ((re_opcode_t) *p1 != on_failure_jump) break; /* Still have to check that it's not an n-th alternative that starts with an on_failure_jump. */ p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); if ((re_opcode_t) p1[mcnt-3] != jump_past_alt) { /* Get to the beginning of the n-th alternative. */ p1 -= 3; break; } } /* Deal with the last alternative: go back and get number of the `jump_past_alt' just before it. `mcnt' contains the length of the alternative. */ EXTRACT_NUMBER (mcnt, p1 - 2); if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info)) return false; p1 += mcnt; /* Get past the n-th alternative. */ } /* if mcnt > 0 */ break; case stop_memory: assert (p1[1] == **p); *p = p1 + 2; return true; default: if (!common_op_match_null_string_p (&p1, end, reg_info)) return false; } } /* while p1 < end */ return false; } /* group_match_null_string_p */ /* Similar to group_match_null_string_p, but doesn't deal with alternatives: It expects P to be the first byte of a single alternative and END one byte past the last. The alternative can contain groups. */ static boolean alt_match_null_string_p (p, end, reg_info) unsigned char *p, *end; register_info_type *reg_info; { int mcnt; unsigned char *p1 = p; while (p1 < end) { /* Skip over opcodes that can match nothing, and break when we get to one that can't. */ switch ((re_opcode_t) *p1) { /* It's a loop. */ case on_failure_jump: p1++; EXTRACT_NUMBER_AND_INCR (mcnt, p1); p1 += mcnt; break; default: if (!common_op_match_null_string_p (&p1, end, reg_info)) return false; } } /* while p1 < end */ return true; } /* alt_match_null_string_p */ /* Deals with the ops common to group_match_null_string_p and alt_match_null_string_p. Sets P to one after the op and its arguments, if any. */ static boolean common_op_match_null_string_p (p, end, reg_info) unsigned char **p, *end; register_info_type *reg_info; { int mcnt; boolean ret; int reg_no; unsigned char *p1 = *p; switch ((re_opcode_t) *p1++) { case no_op: case begline: case endline: case begbuf: case endbuf: case wordbeg: case wordend: case wordbound: case notwordbound: #ifdef emacs case before_dot: case at_dot: case after_dot: #endif break; case start_memory: reg_no = *p1; assert (reg_no > 0 && reg_no <= MAX_REGNUM); ret = group_match_null_string_p (&p1, end, reg_info); /* Have to set this here in case we're checking a group which contains a group and a back reference to it. */ if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE) REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret; if (!ret) return false; break; /* If this is an optimized succeed_n for zero times, make the jump. */ case jump: EXTRACT_NUMBER_AND_INCR (mcnt, p1); if (mcnt >= 0) p1 += mcnt; else return false; break; case succeed_n: /* Get to the number of times to succeed. */ p1 += 2; EXTRACT_NUMBER_AND_INCR (mcnt, p1); if (mcnt == 0) { p1 -= 4; EXTRACT_NUMBER_AND_INCR (mcnt, p1); p1 += mcnt; } else return false; break; case duplicate: if (!REG_MATCH_NULL_STRING_P (reg_info[*p1])) return false; break; case set_number_at: p1 += 4; default: /* All other opcodes mean we cannot match the empty string. */ return false; } *p = p1; return true; } /* common_op_match_null_string_p */ /* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN bytes; nonzero otherwise. */ static int bcmp_translate (s1, s2, len, translate) unsigned char *s1, *s2; register int len; char *translate; { register unsigned char *p1 = s1, *p2 = s2; while (len) { if (translate[*p1++] != translate[*p2++]) return 1; len--; } return 0; } /* Entry points for GNU code. */ /* re_compile_pattern is the GNU regular expression compiler: it compiles PATTERN (of length SIZE) and puts the result in BUFP. Returns 0 if the pattern was valid, otherwise an error string. Assumes the `allocated' (and perhaps `buffer') and `translate' fields are set in BUFP on entry. We call regex_compile to do the actual compilation. */ const char * re_compile_pattern (pattern, length, bufp) const char *pattern; int length; struct re_pattern_buffer *bufp; { reg_errcode_t ret; /* GNU code is written to assume at least RE_NREGS registers will be set (and at least one extra will be -1). */ bufp->regs_allocated = REGS_UNALLOCATED; /* And GNU code determines whether or not to get register information by passing null for the REGS argument to re_match, etc., not by setting no_sub. */ bufp->no_sub = 0; /* Match anchors at newline. */ bufp->newline_anchor = 1; ret = regex_compile (pattern, length, re_syntax_options, bufp); return re_error_msg[(int) ret]; } /* Entry points compatible with 4.2 BSD regex library. We don't define them if this is an Emacs or POSIX compilation. */ #if !defined (emacs) && !defined (_POSIX_SOURCE) && 0 /* BSD has one and only one pattern buffer. */ static struct re_pattern_buffer re_comp_buf; char * re_comp (s) const char *s; { reg_errcode_t ret; if (!s || *s == '\0') { if (!re_comp_buf.buffer) return "No previous regular expression"; return 0; } if (!re_comp_buf.buffer) { re_comp_buf.buffer = (unsigned char *) malloc (200); if (re_comp_buf.buffer == NULL) return "Memory exhausted"; re_comp_buf.allocated = 200; re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); if (re_comp_buf.fastmap == NULL) return "Memory exhausted"; } /* Since `re_exec' always passes NULL for the `regs' argument, we don't need to initialize the pattern buffer fields which affect it. */ /* Match anchors at newlines. */ re_comp_buf.newline_anchor = 1; ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf); /* Yes, we're discarding `const' here. */ return (char *) re_error_msg[(int) ret]; } int re_exec (s) const char *s; { const int len = strlen (s); return 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); } #endif /* not emacs and not _POSIX_SOURCE */ /* POSIX.2 functions. Don't define these for Emacs. */ #ifndef emacs /* regcomp takes a regular expression as a string and compiles it. PREG is a regex_t *. We do not expect any fields to be initialized, since POSIX says we shouldn't. Thus, we set `buffer' to the compiled pattern; `used' to the length of the compiled pattern; `syntax' to RE_SYNTAX_POSIX_EXTENDED if the REG_EXTENDED bit in CFLAGS is set; otherwise, to RE_SYNTAX_POSIX_BASIC; `newline_anchor' to REG_NEWLINE being set in CFLAGS; `fastmap' and `fastmap_accurate' to zero; `re_nsub' to the number of subexpressions in PATTERN. PATTERN is the address of the pattern string. CFLAGS is a series of bits which affect compilation. If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we use POSIX basic syntax. If REG_NEWLINE is set, then . and [^...] don't match newline. Also, regexec will try a match beginning after every newline. If REG_ICASE is set, then we considers upper- and lowercase versions of letters to be equivalent when matching. If REG_NOSUB is set, then when PREG is passed to regexec, that routine will report only success or failure, and nothing about the registers. It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for the return codes and their meanings.) */ int regcomp (preg, pattern, cflags) regex_t *preg; const char *pattern; int cflags; { reg_errcode_t ret; unsigned syntax = (cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; /* regex_compile will allocate the space for the compiled pattern. */ preg->buffer = 0; preg->allocated = 0; preg->used = 0; /* Don't bother to use a fastmap when searching. This simplifies the REG_NEWLINE case: if we used a fastmap, we'd have to put all the characters after newlines into the fastmap. This way, we just try every character. */ preg->fastmap = 0; if (cflags & REG_ICASE) { unsigned i; preg->translate = (char *) malloc (CHAR_SET_SIZE); if (preg->translate == NULL) return (int) REG_ESPACE; /* Map uppercase characters to corresponding lowercase ones. */ for (i = 0; i < CHAR_SET_SIZE; i++) preg->translate[i] = ISUPPER (i) ? tolower (i) : i; } else preg->translate = NULL; /* If REG_NEWLINE is set, newlines are treated differently. */ if (cflags & REG_NEWLINE) { /* REG_NEWLINE implies neither . nor [^...] match newline. */ syntax &= ~RE_DOT_NEWLINE; syntax |= RE_HAT_LISTS_NOT_NEWLINE; /* It also changes the matching behavior. */ preg->newline_anchor = 1; } else preg->newline_anchor = 0; preg->no_sub = !!(cflags & REG_NOSUB); /* POSIX says a null character in the pattern terminates it, so we can use strlen here in compiling the pattern. */ ret = regex_compile (pattern, strlen (pattern), syntax, preg); /* POSIX doesn't distinguish between an unmatched open-group and an unmatched close-group: both are REG_EPAREN. */ if (ret == REG_ERPAREN) ret = REG_EPAREN; return (int) ret; } /* regexec searches for a given pattern, specified by PREG, in the string STRING. If NMATCH is zero or REG_NOSUB was set in the cflags argument to `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at least NMATCH elements, and we set them to the offsets of the corresponding matched substrings. EFLAGS specifies `execution flags' which affect matching: if REG_NOTBOL is set, then ^ does not match at the beginning of the string; if REG_NOTEOL is set, then $ does not match at the end. We return 0 if we find a match and REG_NOMATCH if not. */ int regexec (preg, string, nmatch, pmatch, eflags) const regex_t *preg; const char *string; size_t nmatch; regmatch_t pmatch[]; int eflags; { int ret; struct re_registers regs; regex_t private_preg; int len = strlen (string); boolean want_reg_info = !preg->no_sub && nmatch > 0; private_preg = *preg; private_preg.not_bol = !!(eflags & REG_NOTBOL); private_preg.not_eol = !!(eflags & REG_NOTEOL); /* The user has told us exactly how many registers to return information about, via `nmatch'. We have to pass that on to the matching routines. */ private_preg.regs_allocated = REGS_FIXED; if (want_reg_info) { regs.num_regs = nmatch; regs.start = TALLOC (nmatch, regoff_t); regs.end = TALLOC (nmatch, regoff_t); if (regs.start == NULL || regs.end == NULL) return (int) REG_NOMATCH; } /* Perform the searching operation. */ ret = re_search (&private_preg, string, len, /* start: */ 0, /* range: */ len, want_reg_info ? ®s : (struct re_registers *) 0); /* Copy the register information to the POSIX structure. */ if (want_reg_info) { if (ret >= 0) { unsigned r; for (r = 0; r < nmatch; r++) { pmatch[r].rm_so = regs.start[r]; pmatch[r].rm_eo = regs.end[r]; } } /* If we needed the temporary register info, free the space now. */ free (regs.start); free (regs.end); } /* We want zero return to mean success, unlike `re_search'. */ return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH; } /* Returns a message corresponding to an error code, ERRCODE, returned from either regcomp or regexec. We don't use PREG here. */ size_t regerror (errcode, preg, errbuf, errbuf_size) int errcode; const regex_t *preg; char *errbuf; size_t errbuf_size; { const char *msg; size_t msg_size; if (errcode < 0 || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0]))) /* Only error codes returned by the rest of the code should be passed to this routine. If we are given anything else, or if other regex code generates an invalid error code, then the program has a bug. Dump core so we can fix it. */ abort (); msg = re_error_msg[errcode]; /* POSIX doesn't require that we do anything in this case, but why not be nice. */ if (! msg) msg = "Success"; msg_size = strlen (msg) + 1; /* Includes the null. */ if (errbuf_size != 0) { if (msg_size > errbuf_size) { strncpy (errbuf, msg, errbuf_size - 1); errbuf[errbuf_size - 1] = 0; } else strcpy (errbuf, msg); } return msg_size; } /* Free dynamically allocated space used by PREG. */ void regfree (preg) regex_t *preg; { if (preg->buffer != NULL) free (preg->buffer); preg->buffer = NULL; preg->allocated = 0; preg->used = 0; if (preg->fastmap != NULL) free (preg->fastmap); preg->fastmap = NULL; preg->fastmap_accurate = 0; if (preg->translate != NULL) free (preg->translate); preg->translate = NULL; } #endif /* not emacs */ /* Local variables: make-backup-files: t version-control: t trim-versions-without-asking: nil End: */ ./libc-linux/compat/aliases.c100644 1676 334 1176 5517625555 14210 0ustar hjlisl#include /* Although we keep those functions in the jump table. But we * have removed the entry point to outside. So we need the * alias to bypass the jump table. */ symbol_alias (__old_re_search__LOCAL__,__old_re_search); symbol_alias (__old_re_search_2__LOCAL__,__old_re_search_2); symbol_alias (__old_re_match__LOCAL__,__old_re_match); symbol_alias (__old_re_match_2__LOCAL__,__old_re_match_2); symbol_alias (__old_re_compile_fastmap__LOCAL__,__old_re_compile_fastmap); symbol_alias (__old_re_compile_pattern__LOCAL__,__old_re_compile_pattern); symbol_alias (__old_re_set_registers__LOCAL__,__old_re_set_registers); ./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/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/shadow/ 40755 1676 334 0 5515546465 12323 5ustar hjlisl./libc-linux/shadow/README100644 1676 334 1235 5475455333 13277 0ustar hjlislCan you add this stuff to our libc for 4.4.5? It wont break anything and it will add compatibility with those people who use shadow passwords. I don't use shadow passwords myself but they have created a lot of problems in the Linux community which I want to resolve. So I took just the key pieces out of the shadow suite and added them to libc. This way, getpwnam works whether or not you have shadow passwords installed. libc.diffs diffs against libc-linux shadow.c goes into libc/pwd/shadow.c gshadow.c goes into libc/grp/shadow.c shadow.h new shadow.h goes into usr/include/shadow.h pwd.h new pwd.h goes into usr/include/pwd.h Rick Sladkey ./libc-linux/shadow/libc.diffs100644 1676 334 3463 5475460070 14344 0ustar hjlisldiff -rc libc-linux-4.4.4/grp/Makefile libc-linux/grp/Makefile *** libc-linux-4.4.4/grp/Makefile Fri Aug 27 19:27:18 1993 --- libc-linux/grp/Makefile Sun Nov 21 18:42:52 1993 *************** *** 21,27 **** DIRS:= SRCS= fgetgrent.c getgrent.c getgrgid.c getgrnam.c grpopen.c \ ! grpread.c initgroups.c SMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) --- 21,27 ---- DIRS:= SRCS= fgetgrent.c getgrent.c getgrgid.c getgrnam.c grpopen.c \ ! grpread.c initgroups.c gshadow.c SMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) diff -rc libc-linux-4.4.4/pwd/Makefile libc-linux/pwd/Makefile *** libc-linux-4.4.4/pwd/Makefile Mon Aug 23 22:20:48 1993 --- libc-linux/pwd/Makefile Sun Nov 21 18:41:56 1993 *************** *** 20,26 **** DIRS:= SRCS = fgetpwent.c getpw.c getpwent.c getpwnam.c getpwuid.c \ ! putpwent.c pwdopen.c pwdread.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) --- 20,26 ---- DIRS:= SRCS = fgetpwent.c getpw.c getpwent.c getpwnam.c getpwuid.c \ ! putpwent.c pwdopen.c pwdread.c shadow.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) diff -rc libc-linux-4.4.4/pwd/pwdread.c libc-linux/pwd/pwdread.c *** libc-linux-4.4.4/pwd/pwdread.c Sun Jul 25 16:18:38 1993 --- libc-linux/pwd/pwdread.c Sun Nov 21 18:57:30 1993 *************** *** 26,31 **** --- 26,36 ---- #include #include #include + + #ifndef NO_SHADOW + #include "shadow.h" + #endif + #ifdef YP #include #include *************** *** 278,283 **** --- 283,297 ---- return NULL; *end = '\0'; info->p.pw_passwd = start; + + #ifndef NO_SHADOW + { + struct spwd *spw = getspnam (info->p.pw_name); + + if (spw) + info->p.pw_passwd = spw->sp_pwdp; + } + #endif info->p.pw_uid = (uid_t) strtol (end + 1, &end, 10); if (*end != ':') ./libc-linux/shadow/Makefile100644 1676 334 343 5515544465 14036 0ustar hjlisl# # This is Makefile for shadow functions. # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules DIRS:= SRCS = shadow-comp.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIAESE= include $(TOPDIR)/Maketargets ./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/libbsd/ 40755 1676 334 0 5527714202 12262 5ustar hjlisl./libc-linux/libbsd/Makefile100644 1676 334 1611 5527714112 14016 0ustar hjlisl# # libbsd A collection of library modules similar or equal to their # BSD UNIX equivalents, to make the job of porting BSD pro- # grams to LINUX easier. # # Author: Rick Sladkey, # override STATIC=true override SHARED=false override DEBUG=false override PROFILE=false #override CHECKER=false ifeq ($(CHECKER),true) override STATIC=false endif # That is fake for SUBDIR. JUMP_LIB=libbsd TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules override STATIC_LIB=$(STATIC_DIR)/libbsd.a override CHECKER_LIB=$(CHECKER_DIR)/libbsd.a INC_CFLAGS= -I$(CROSS_INCDIR)/bsd -I$(CROSS_INCDIR) \ -include $(CROSS_INCDIR)/bsd/bsd.h DIRS:= SRCS= daemon.c logwtmp.c logout.c pty.c login_tty.c \ sgtty.c cfsetspeed.c revoke.c setpassent.c \ snprintf.c checkrhosts.c # strsep.c roundup.c getusersh.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) include $(TOPDIR)/Maketargets ./libc-linux/libbsd/README100644 1676 334 11436 5331024724 13260 0ustar hjlisl LINUX NET DISTRIBUTION Version 0.03 Fred N. van Kempen Ross Biro Rick Sladkey The NET distribution for LINUX is a complete set of executables, setup files, documentation and all the sources needed to rebuild the package. It is intended as the `official' NET package for the LINUX operating system, mostly to get rid of the current situation of total chaos in NETland... The first distribution has been done by Ross Biro, who wrote the TCP/IP stuff in the LINUX kernel to start with. As usual, the Berkeley BSD UNIX software was taken as a base for this distri- bution. Several `foreign' programs are included as well. To make porting easy, a library has been built which contains the modules from BSD UNIX that were missing in the LINUX library. They are declared in the header files that go with it. These files must be copied to the /usr/net/include/bsd directory and a symbolic link must be created from /usr/include/bsd. This is a compliation of some net sources, mostly from bsd-net2. I have made an effort to get the programs to compile with few or no changes except for a new Makefile. This resulted in a bsd include directory and a bsd library. Take a look at them to see what types of things are required to get BSD sources to compile correctly without changes. Some of the tricks are pretty ugly. Please don't laugh... Everything should compile straight with the libc-4.2 libraries. Just type "make" in this directory. You may have to do some surgery on libbsd/libbsd.a to get things to compile with libc-4.1. Notes ===== bsd: The directory "bsd" contains include files that, for the most part, just overload include files of the same name from /usr/include. It provides some BSD things like "union wait" and others. libbsd: The libbsd.a archive is a small library of some functions that are not in our libc as well as some emulation support functions referenced in the bsd header files. Notably, it includes a half-decent transparent sgtty emulation package. inetd: Works. Only pathname changes. ftp: Works. No changes. ftpd: I find that ls with ftpd doesn't work very often. It reports "Transport endpoint already connected" 9 times out of 10. I think this is a bug in the kernel which will be fixed in a subsequent release. There was a memory allocation bug in the original source, look for "#ifdef linux". Also, the shadow password stuff is not compiled in as I haven't had a chance to mess with that. telnet: Works but see the man page for info about the .telnetrc file and other new options. This is a really nice telnet with rlogin emulation and lots of other stuff not present in older telnets. The original Linux port of telnet/telnetd was done by Pete Chown. telnetd: Several people have reported that the 0.1 telnetd sometimes disconnected before getting to the login prompt. The 0.2 version omits the vhangup stuff which might have been causing the problem. Also fixed is the problem with /etc/wtmp not being updated correctly on logout. It was trying to use /var/adm/wtmp. finger: Works. One minor change for POSIX timezone handling. fingerd: Works, no changes. ping: Works, no changes. Must be suid to root. named: Works. A few changes for pathnames and net device configuration stuff. nslookup: Works, but it's fussier than older nslookups about named being setup correctly. Note the -I option is needed for flex -- that was a tough one to find. No changes. named-xfer: Not tested. rcp: Works. Must be suid to root. rsh: Works. Must be suid to root. rshd: Works. rlogin: Works OK but needs more testing. This one depends pretty heavily on the sgtty emulation in libbsd which is not complete yet. There is an odd timing bug with select and termio settings. Look for "sleep(1)" to see what I mean. Must be suid to root. rlogind: Works with the URGENT stuff commented out. There was a nasty bug with shared libraries because environ was redefined. talk: Works. This is the new byte-order independent talk, not the old talk that, e.g., native SunOS uses. The old one wouldn't work with them anyway. Not the fault of Linux. Includes a one line patch for a bug in our curses and another for a bug in the original source dealing with select. ntalkd: Works. No changes. tftp: Works. No changes. tftpd: Works. No changes. Sample Entries for inetd.conf ============================= telnet stream tcp nowait root /usr/etc/inet/telnetd telnetd ntalk dgram udp wait root /usr/etc/inet/ntalkd ntalkd ftp stream tcp nowait root /usr/etc/inet/ftpd ftpd -l finger stream tcp nowait root /usr/etc/inet/fingerd finger shell stream tcp nowait root /usr/etc/inet/rshd rshd login stream tcp nowait root /usr/etc/inet/rlogind rlogind tftp dgram udp wait root /usr/etc/inet/tftpd tftpd Rick Sladkey jrs@world.std.com ./libc-linux/libbsd/README.HLU100644 1676 334 1103 5346446406 13670 0ustar hjlislHJ, This is the source of the current "libbsd.a" as I have it next to the libc 4.3.2. You can safely ignore the blahblah in the other README- throw it away after you added this stuff to the rest of libc... I think the best way to add this to the standard set of C libraries is to keep it in the form of a single non-sharable library (/usr/lib/libbsd.a) that only gets linked if the user asks for it by typing "-lbsd". I don't know if this is pos- sible, but I don't think it should be added to the "shared" image, because it might cause other problems in that case... Fred. ./libc-linux/libbsd/cfsetspeed.c100644 1676 334 1117 5346447216 14657 0ustar hjlisl/* cfsetspeed.c - emulate BSD cfsetspeed with cfset[io]speed - rick sladkey */ #include struct { int flag, val; } xref[] = { B0, 0, B50, 50, B75, 75, B110, 110, B134, 134, B150, 150, B200, 200, B300, 300, B600, 600, B1200, 1200, B1800, 1800, B2400, 2400, B4800, 4800, B9600, 9600, B19200, 19200, B38400, 38400, 0, -1, }; int cfsetspeed(struct termios *p, int speed) { int i; for (i = 0; xref[i].val != -1; i++) { if (xref[i].val == speed) { speed = xref[i].flag; cfsetispeed(p, speed); cfsetospeed(p, speed); return 0; } } return -1; } ./libc-linux/libbsd/checkrhosts.c100644 1676 334 102 5346447224 15022 0ustar hjlisl /* This is not functional. Oh well. */ int _check_rhosts_file; ./libc-linux/libbsd/daemon.c100644 1676 334 4653 5346447235 14006 0ustar hjlisl/*- * Copyright (c) 1990 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[] = "@(#)daemon.c 5.3 (Berkeley) 12/28/90"; #endif /* LIBC_SCCS and not lint */ #include #include #include daemon(nochdir, noclose) int nochdir, noclose; { int cpid; if ((cpid = fork()) == -1) return (-1); if (cpid) exit(0); (void) setsid(); if (!nochdir) (void) chdir("/"); if (!noclose) { int devnull = open(_PATH_DEVNULL, O_RDWR, 0); if (devnull != -1) { (void) dup2(devnull, STDIN_FILENO); (void) dup2(devnull, STDOUT_FILENO); (void) dup2(devnull, STDERR_FILENO); if (devnull > 2) (void) close(devnull); } } } ./libc-linux/libbsd/login_tty.c100644 1676 334 4314 5350210335 14525 0ustar hjlisl/*- * Copyright (c) 1990 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[] = "@(#)login_tty.c 1.2 (Berkeley) 6/21/90"; #endif /* LIBC_SCCS and not lint */ #include #include #include login_tty(fd) int fd; { (void) setsid(); if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1) return (-1); (void) dup2(fd, 0); (void) dup2(fd, 1); (void) dup2(fd, 2); if (fd > 2) (void) close(fd); return (0); } ./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/libbsd/pty.c100644 1676 334 7252 5346447274 13360 0ustar hjlisl/*- * Copyright (c) 1990 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[] = "@(#)pty.c 5.6 (Berkeley) 5/10/91"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include #include #include #include #include #include #include openpty(amaster, aslave, name, termp, winp) int *amaster, *aslave; char *name; struct termios *termp; struct winsize *winp; { static char line[] = "/dev/ptyXX"; register const char *cp1, *cp2; register int master, slave, ttygid; struct group *gr; if ((gr = getgrnam("tty")) != NULL) ttygid = gr->gr_gid; else ttygid = -1; for (cp1 = "pqrs"; *cp1; cp1++) { line[8] = *cp1; for (cp2 = "0123456789abcdef"; *cp2; cp2++) { line[9] = *cp2; if ((master = open(line, O_RDWR, 0)) == -1) { if (errno == ENOENT) return (-1); /* out of ptys */ } else { line[5] = 't'; (void) chown(line, getuid(), ttygid); (void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP); (void) revoke(line); if ((slave = open(line, O_RDWR, 0)) != -1) { *amaster = master; *aslave = slave; if (name) strcpy(name, line); if (termp) (void) tcsetattr(slave, TCSAFLUSH, termp); if (winp) (void) ioctl(slave, TIOCSWINSZ, (char *)winp); return (0); } (void) close(master); line[5] = 'p'; } } } errno = ENOENT; /* out of ptys */ return (-1); } forkpty(amaster, name, termp, winp) int *amaster; char *name; struct termios *termp; struct winsize *winp; { int master, slave, pid; if (openpty(&master, &slave, name, termp, winp) == -1) return (-1); switch (pid = fork()) { case -1: return (-1); case 0: /* * child */ (void) close(master); login_tty(slave); return (0); } /* * parent */ *amaster = master; (void) close(slave); return (pid); } ./libc-linux/libbsd/revoke.c100644 1676 334 152 5346447305 14002 0ustar hjlisl/* revoke.c - can't quite emulate BSD revoke? - rick sladkey */ int revoke(char *line) { return 0; } ./libc-linux/libbsd/setpassent.c100644 1676 334 133 5346447320 14674 0ustar hjlisl/* setpassent.c - vacuous setpassent for BSD - rick sladkey */ void setpassent(int i) { } ./libc-linux/libbsd/sgtty.c100644 1676 334 13276 5350210670 13720 0ustar hjlisl/* sgtty.c - emulate BSD sgtty stuff with termios - ross biro, rick sladkey */ #define _SGTTY_SOURCE #include #include #include #include #include #include struct mask { unsigned short mask; unsigned short res; }; struct sf { struct mask iflag; struct mask oflag; struct mask cflag; struct mask lflag; }; static struct sf trans[] = { /* order is important here. */ /* iflag oflag cflag lflag */ /* this needs to be fixed. */ {{0,0}, {OPOST,0}, {0,0}, {ISIG,0}}, /* O_RAW */ {{0,0}, {0,0}, {0,0}, {XCASE,XCASE}}, /* O_LCASE */ {{ICRNL,ICRNL}, {ONLCR, ONLCR}, {0,0}, {0,0}}, /* O_CRMOD */ {{0,0}, {0,0}, {0,0}, {ECHO,ECHO}}, /* O_ECHO */ {{0,0}, {0,0}, {PARENB|PARODD,PARENB|PARODD}, {0,0}},/* O_ODDP */ {{0,0}, {0,0}, {PARENB|PARODD,PARENB}, {0,0}}, /* O_EVENP */ {{0,0}, {0,0}, {0,0}, {ICANON,0}}, /* O_CBREAK */ }; #define _BSD_VDISABLE 255 static int bchar (unsigned char c) { return c == _POSIX_VDISABLE ? _BSD_VDISABLE : c; } static int pchar (unsigned char c) { return c == _BSD_VDISABLE ? _POSIX_VDISABLE : c; } static int tiocgetp (int fd, struct sgttyb *sg) { struct termios t; int err; int i; err = ioctl (fd, TCGETS, &t); if (err < 0) return (err); sg->sg_ispeed = cfgetispeed (&t); sg->sg_ospeed = cfgetospeed (&t); sg->sg_erase = bchar (t.c_cc[VERASE]); sg->sg_kill = bchar (t.c_cc[VKILL]); sg->sg_flags = 0; for (i = 0; i < sizeof (trans) / sizeof (struct sf); i++) { if ((t.c_iflag & trans[i].iflag.mask) == trans[i].iflag.res && (t.c_oflag & trans[i].oflag.mask) == trans[i].oflag.res && (t.c_cflag & trans[i].cflag.mask) == trans[i].cflag.res && (t.c_lflag & trans[i].lflag.mask) == trans[i].lflag.res) { sg->sg_flags |= 1 << i; } } return (0); } static int tiocset (int fd, struct sgttyb *sg, int method) { struct termios t; int err; int i; err = ioctl (fd, TCGETS, &t); if (err < 0) return (err); cfsetispeed (&t, sg->sg_ispeed); cfsetospeed (&t, sg->sg_ospeed); t.c_cc[VERASE] = pchar (sg->sg_erase); t.c_cc[VKILL] = pchar (sg->sg_kill); for (i = sizeof (trans) / sizeof (struct sf) - 1; i >= 0; i--) { t.c_iflag &= ~trans[i].iflag.mask; t.c_oflag &= ~trans[i].oflag.mask; t.c_cflag &= ~trans[i].cflag.mask; t.c_lflag &= ~trans[i].lflag.mask; if (sg->sg_flags & (1 << i)) { t.c_iflag |= trans[i].iflag.res; t.c_oflag |= trans[i].oflag.res; t.c_cflag |= trans[i].cflag.res; t.c_lflag |= trans[i].lflag.res; } else { t.c_iflag |= (~trans[i].iflag.res) & trans[i].iflag.mask; t.c_oflag |= (~trans[i].oflag.res) & trans[i].oflag.mask; t.c_cflag |= (~trans[i].cflag.res) & trans[i].cflag.mask; t.c_lflag |= (~trans[i].lflag.res) & trans[i].lflag.mask; } } return (ioctl (fd, method, &t)); } static int tiocsetp (int fd, struct sgttyb *sg) { return tiocset (fd, sg, TCSETSF); } static int tiocsetn (int fd, struct sgttyb *sg) { return tiocset (fd, sg, TCSETS); } static int tiocgetc (int fd, struct tchars *tc) { struct termios t; int err; err = ioctl (fd, TCGETS, &t); if (err < 0) return (err); tc->t_intrc = bchar (t.c_cc[VINTR]); tc->t_quitc = bchar (t.c_cc[VQUIT]); tc->t_eofc = bchar (t.c_cc[VEOF]); tc->t_startc = bchar (t.c_cc[VSTART]); tc->t_stopc = bchar (t.c_cc[VSTOP]); tc->t_brkc = bchar (t.c_cc[VEOL]); return (0); } static int tiocsetc (int fd, struct tchars *tc) { struct termios t; int err; err = ioctl (fd, TCGETS, &t); if (err < 0) return (err); t.c_cc[VINTR] = pchar (tc->t_intrc); t.c_cc[VQUIT] = pchar (tc->t_quitc); t.c_cc[VEOF] = pchar (tc->t_eofc); t.c_cc[VEOL] = pchar (tc->t_brkc); t.c_cc[VSTART] = pchar (tc->t_startc); t.c_cc[VSTOP] = pchar (tc->t_stopc); return (ioctl (fd, TCSETS, &t)); } static int tiocgltc (int fd, struct ltchars *tc) { struct termios t; int err; err = ioctl (fd, TCGETS, &t); if (err < 0) return (err); tc->t_werasc = bchar (t.c_cc[VERASE]); tc->t_suspc = bchar (t.c_cc[VSUSP]); tc->t_dsuspc = bchar (t.c_cc[VSUSP]); tc->t_rprntc = bchar (t.c_cc[VREPRINT]); tc->t_flushc = bchar (t.c_cc[VDISCARD]); tc->t_lnextc = bchar (t.c_cc[VLNEXT]); return (0); } static int tiocsltc (int fd, struct ltchars *tc) { struct termios t; int err; err = ioctl (fd, TCGETS, &t); if (err < 0) return (err); t.c_cc[VERASE] = pchar (tc->t_werasc); t.c_cc[VSUSP] = pchar (tc->t_suspc); t.c_cc[VSUSP] = pchar (tc->t_dsuspc); t.c_cc[VREPRINT] = pchar (tc->t_rprntc); t.c_cc[VDISCARD] = pchar (tc->t_flushc); t.c_cc[VLNEXT] = pchar (tc->t_lnextc); return (ioctl (fd, TCSETS, &t)); } static int tioclget (int fd, int *lflagsp) { struct termios t; int lflags = 0; *lflagsp = lflags; return 0; } static int tioclset (int fd, int *lflagsp) { return 0; } static int tiocflush (int fd, int *arg) { return 0; } int bsd_ioctl (int fd, int option, void *arg) { switch (option) { case TIOCGETP: return tiocgetp(fd, (struct sgttyb *) arg); case TIOCSETP: return tiocsetp(fd, (struct sgttyb *) arg); case TIOCGETC: return tiocgetc(fd, (struct tchars *) arg); case TIOCSETC: return tiocsetc(fd, (struct tchars *) arg); case TIOCGLTC: return tiocgltc(fd, (struct ltchars *) arg); case TIOCSLTC: return tiocsltc(fd, (struct ltchars *) arg); case TIOCLGET: return tioclget(fd, (int *) arg); case TIOCLSET: return tioclset(fd, (int *) arg); case TIOCFLUSH: return tiocflush(fd, (int *) arg); case TIOCSETN: return tiocsetn(fd, (struct sgttyb *) arg); default: return ioctl(fd, option, arg); } } ./libc-linux/libbsd/snprintf.c100644 1676 334 435 5346447341 14356 0ustar hjlisl/* snprintf.c - emulate BSD snprintf with sprintf - rick sladkey */ #include #include int snprintf(char *s, int len, char *format, ...) { va_list args; int result; va_start(args, format); result = vsprintf(s, format, args); va_end(args); return result; } ./libc-linux/sbin/ 40755 1676 334 0 5515047461 11761 5ustar hjlisl./libc-linux/sbin/sln.c100644 1676 334 3231 5372550411 13010 0ustar hjlisl/* `sln' program to create links between files. Copyright (C) 1986, 1989, 1990, 1991, 1993 Free Software Foundation, Inc. This program 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 program 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Written by Mike Parker and David MacKenzie. */ #include #include #include #include #if !defined(S_ISDIR) && defined(S_IFDIR) #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif int main (argc, argv) int argc; char **argv; { struct stat stats; if (argc != 3) return 1; /* Destination must not be a directory. */ #if 0 if (stat (argv [2], &stats) == 0 && S_ISDIR (stats.st_mode)) { return 1; } #endif if (lstat (argv [2], &stats) == 0) { if (S_ISDIR (stats.st_mode)) { return 1; } else if (unlink (argv [2]) && errno != ENOENT) { return 1; } } else if (errno != ENOENT) { return 1; } #ifdef S_ISLNK if (symlink (argv [1], argv [2]) == 0) #else if (link (argv [1], argv [2]) == 0) #endif { return 0; } return 1; } ./libc-linux/sbin/lib/ 40755 1676 334 0 5521041736 12523 5ustar hjlisl./libc-linux/sbin/lib/__stat.S100644 1676 334 1555 5372550411 14222 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__ (stat, 2) ret ./libc-linux/sbin/lib/__lstat.S100644 1676 334 1556 5372550411 14377 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__ (lstat, 2) ret ./libc-linux/sbin/lib/__link.S100644 1676 334 1555 5372550411 14204 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__ (link, 2) ret ./libc-linux/sbin/lib/i386/ 40755 1676 334 0 5515045446 13221 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/i386/crt/ 40755 1676 334 0 5516661061 14007 5ustar hjlisl./libc-linux/sbin/lib/i386/crt/Makefile100644 1676 334 367 5515545474 15542 0ustar hjlisl# # Makefile for crt0.o of Linux # # LD=true MV=true TOPDIR=../../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules all lib: crt0.o realclean clean: $(RM) -f core *.o *.a tmp_make foo depend: @echo No dependency in $(SUBDIR). ./libc-linux/sbin/lib/i386/crt/crt0.S100644 1676 334 247 5372550413 15061 0ustar hjlisl .text __entry: movl 8(%esp),%eax movl %eax,___environ call _main /* * We use int $0x80 for __exit(). */ movl %eax,%ebx done: movl $1,%eax int $0x80 jmp done ./libc-linux/sbin/lib/__symlink.S100644 1676 334 1560 5372550412 14732 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__ (symlink, 2) ret ./libc-linux/sbin/lib/__unlink.S100644 1676 334 1557 5372550412 14552 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__ (unlink, 1) ret ./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/__main.c100644 1676 334 23 5372550412 14141 0ustar hjlislvoid __main () { } ./libc-linux/sbin/lib/__environ.S100644 1676 334 56 5372550413 14664 0ustar hjlisl.globl ___environ .data ___environ: .long 0 ./libc-linux/sbin/lib/errno.S100644 1676 334 46 5372550413 14032 0ustar hjlisl.globl _errno .data _errno: .long 0 ./libc-linux/sbin/lib/m68k/ 40755 1676 334 0 5521073074 13310 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/sbin/lib/m68k/crt/ 40755 1676 334 0 5521073105 14073 5ustar hjlisl./libc-linux/sbin/lib/m68k/crt/Makefile100644 1676 334 367 5521072114 15615 0ustar hjlisl# # Makefile for crt0.o of Linux # # LD=true MV=true TOPDIR=../../../.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules all lib: crt0.o realclean clean: $(RM) -f core *.o *.a tmp_make foo depend: @echo No dependency in $(SUBDIR). ./libc-linux/sbin/lib/m68k/crt/crt0.S100644 1676 334 240 5521072114 15137 0ustar hjlisl .text __entry: movel sp@(8),d0 movel d0,___environ jbsr _main /* * We use trap #0 for __exit(). */ movel d0,d1 done: moveq #1,d0 trap #0 bras done ./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/glibc100644 1676 334 4463 5533302753 12133 0ustar hjlislThe Linux C library 4.5.21 The GNU C library 1.07.4 ---------------------------------------------------------------------- dirent/dirent.h posix/fnmatch.h posix/getopt.h posix/glob.h sysdeps/ieee754/ieee754.h posix/gnu/wait.h posix/sys/wait.h new bsd new dirent/alphasort.c dirent/alphasort.c dirent/scandir.c dirent/scandir.c grp/initgroups.c grp/initgroups.c grp/grpread.c grp/grpread.c inet inet libio/floatconv.c stdlib/strtod.c libio/stdio/sysd-stdio.c sysdeps/posix/sysd-stdio.c login new malloc malloc mntent new misc/ldexp.c sysdeps/ieee754/ldexp.c misc/syslog.c misc/syslog.c posix/clock.c sysdeps/posix/clock.c posix/execl.c posix/execl.c posix/execle.c posix/execle.c posix/execlp.c posix/execlp.c posix/fnmatch.c posix/fnmatch.c posix/glob.c posix/glob.c posix/getcwd.c sysdeps/posix/getcwd.c posix/mktemp.c sysdeps/posix/mktemp.c posix/sleep.c sysdeps/posix/sleep.c pwd/putpwent.c pwd/putpwent.c pwd/pwdread.c pwd/pwdread.c rpc new stdio different string/bcmp.c string/bcmp.c string/bcopy.c sysdeps/string/bcopy.c string/bzero.c sysdeps/i386/bzero.c string/strerror.c string/strerror.c string/memchr.c sysdeps/i386/memchr.c string/memcmp.c sysdeps/i386/? string/memmove.c sysdeps/generic/memmove.c string/strcasecmp.c sysdeps/generic/strcasecmp.c string/strcat.c sysdeps/generic/strcat.c string/strchr.c sysdeps/generic/strchr.c string/strcmp.c sysdeps/generic/strcmp.c string/strcspn.c sysdeps/generic/strcspn.c string/strlen.c sysdeps/generic/strlen.c string/strncmp.c sysdeps/generic/strncmp.c string/strncasecmp.c sysdeps/generic/strncasecmp.c string/strpbrk.c sysdeps/generic/strpbrk.c string/strrchr.c sysdeps/generic/strrchr.c string/strsep.c sysdeps/generic/strsep.c string/strspn.c sysdeps/generic/strspn.c string/strstr.c sysdeps/generic/strstr.c sysdeps/i386/div.c stdlib/div.c stdlib/ldiv.c stdlib/ldiv.c sysdeps/linux/__flock.c new sysdeps/linux/__fpathcon.c sysdeps/posix/__fpathcon.c sysdeps/linux/__pathcon.c sysdeps/posix/__pathcon.c sysdeps/linux/i386/ulimit.c sysdeps/unix/bsd/ulimit.c sysdeps/linux/i386/math/frexp.c sysdeps/generic/frexp.c time different ./libc-linux/TODO100644 1676 334 1060 5533277532 11614 0ustar hjlisl2. fpu in setjmp and bsd setjump.. need kernel support. 3. time stuff from ? It may affect the compatibility of the shared library. 4. regex (new one?) 5. termcap/ncurses It may affect the compatibility of the shared library. 6. dbm It may affect the compatibility of the shared library. 7. strftime It may affect the compatibility of the shared library. 8. GPL to be changed to LGPL by the FSF in sysdeps/linux/mkfifo.c sysdeps/linux/morecore.c sysdeps/linux/nlist.c sysdeps/linux/__getpgsz.c sysdeps/linux/__getpgsz.c 9. NYS/shadow. ./libc-linux/malloc-930716/ 40755 1676 334 0 5550056164 13043 5ustar hjlisl./libc-linux/malloc-930716/cfree.c100644 1676 334 1731 5505465443 14376 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 #undef cfree #include function_alias(cfree, free, void, (ptr), DEFUN(cfree, (ptr), PTR ptr)) ./libc-linux/malloc-930716/README100644 1676 334 3772 5505465443 14035 0ustar hjlislThis is a fast malloc implementation that I wrote several years ago. I later used it as the basis of GNU malloc. My version differs from the GNU version in that it does not support debugging hooks, and does not record statistics. Therefore it is slightly faster. In order to safely link programs using this malloc with a C library that provides a different malloc, you need to make sure that malloc(), free(), and realloc() are defined in a single object file. Otherwise when linking you might get a combination of this malloc() with the library's free(). The Makefile builds such an object file, alloc.o. If you are using this malloc as the allocator for a C library of your own, and are not linking with another C library, then you don't need alloc.o. If you are building a C library, you should also write a replacement for the file "morecore.c" that doesn't pollute the name space. The header file "malloc.h" in this directory is NOT intended to be a public header file; it is for internal use by malloc and its friends. Don't install malloc.h in a public include directory! When porting this allocator to a new machine or operating system, you should inspect the definition of BLOCKSIZE in malloc.h to make sure it is greater than or equal to your target machine's virtual memory page size; otherwise valloc() won't work properly. (If you don't care about valloc() then BLOCKSIZE doesn't matter.) You will also need to provide a machine-dependent _default_morecore() function; see morecore.c for a sample version that works on Unix. Your morecore function should return a pointer to a newly allocated region of the given size, aligned on the most pessimistic alignment boundary for the machine. Subsequent calls to morecore should return contiguous memory, and calls to morecore with a negative argument should return memory to the system. If no memory is available morecore should return NULL. Bug reports to Mike Haertel, mike@cs.uoregon.edu. This version is dated March 26, 1993; include this date with your bug report. ./libc-linux/malloc-930716/calloc.c100644 1676 334 1534 5505465443 14550 0ustar hjlisl/* calloc.c - C standard library routine. Copyright (c) 1989, 1993 Michael J. Haertel You may redistribute this library under the terms of the GNU Library General Public License (version 2 or any later version) as published by the Free Software Foundation. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ #include #include /* Allocate space for the given number of elements of the given size, initializing the whole region to binary zeroes. */ void * calloc(size_t nelem, size_t size) { void *result; result = malloc(size * nelem); if (result) memset(result, 0, nelem * size); return result; } ./libc-linux/malloc-930716/free.c100644 1676 334 10571 5505465443 14255 0ustar hjlisl/* free.c - C standard library routine. Copyright (c) 1989, 1993 Michael J. Haertel You may redistribute this library under the terms of the GNU Library General Public License (version 2 or any later version) as published by the Free Software Foundation. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ #include #include #include #include "malloc.h" /* Return memory to the heap. */ void free(void *ptr) { int block, blocks, i, type; struct list *prev, *next; if (!ptr) return; block = BLOCK(ptr); switch (type = _heapinfo[block].busy.type) { case 0: /* Find the free cluster previous to this one in the free list. Start searching at the last block referenced; this may benefit programs with locality of allocation. */ i = _heapindex; if (i > block) while (i > block) i = _heapinfo[i].free.prev; else { do i = _heapinfo[i].free.next; while (i > 0 && i < block); i = _heapinfo[i].free.prev; } /* Determine how to link this block into the free list. */ if (block == i + _heapinfo[i].free.size) { /* Coalesce this block with its predecessor. */ _heapinfo[i].free.size += _heapinfo[block].busy.info.size; block = i; } else { /* Really link this block back into the free list. */ _heapinfo[block].free.size = _heapinfo[block].busy.info.size; _heapinfo[block].free.next = _heapinfo[i].free.next; _heapinfo[block].free.prev = i; _heapinfo[i].free.next = block; _heapinfo[_heapinfo[block].free.next].free.prev = block; } /* Now that the block is linked in, see if we can coalesce it with its successor (by deleting its successor from the list and adding in its size). */ if (block + _heapinfo[block].free.size == _heapinfo[block].free.next) { _heapinfo[block].free.size += _heapinfo[_heapinfo[block].free.next].free.size; _heapinfo[block].free.next = _heapinfo[_heapinfo[block].free.next].free.next; _heapinfo[_heapinfo[block].free.next].free.prev = block; } /* Now see if we can return stuff to the system. */ blocks = _heapinfo[block].free.size; if (blocks >= FINAL_FREE_BLOCKS && block + blocks == _heaplimit && (*_morecore)(0) == ADDRESS(block + blocks)) { _heaplimit -= blocks; (*_morecore)(-blocks * BLOCKSIZE); _heapinfo[_heapinfo[block].free.prev].free.next = _heapinfo[block].free.next; _heapinfo[_heapinfo[block].free.next].free.prev = _heapinfo[block].free.prev; block = _heapinfo[block].free.prev; } /* Set the next search to begin at this block. */ _heapindex = block; break; default: /* Get the address of the first free fragment in this block. */ prev = (struct list *) ((char *) ADDRESS(block) + (_heapinfo[block].busy.info.frag.first << type)); if (_heapinfo[block].busy.info.frag.nfree == (BLOCKSIZE >> type) - 1 && _fragblocks[type] > 1) { /* If all fragments of this block are free, remove them from the fragment list and free the whole block. */ --_fragblocks[type]; for (next = prev, i = 1; i < BLOCKSIZE >> type; ++i) next = next->next; prev->prev->next = next; if (next) next->prev = prev->prev; _heapinfo[block].busy.type = 0; _heapinfo[block].busy.info.size = 1; free(ADDRESS(block)); } else if (_heapinfo[block].busy.info.frag.nfree) { /* If some fragments of this block are free, link this fragment into the fragment list after the first free fragment of this block. */ next = ptr; next->next = prev->next; next->prev = prev; prev->next = next; if (next->next) next->next->prev = next; ++_heapinfo[block].busy.info.frag.nfree; } else { /* No fragments of this block are free, so link this fragment into the fragment list and announce that it is the first free fragment of this block. */ prev = (struct list *) ptr; _heapinfo[block].busy.info.frag.nfree = 1; _heapinfo[block].busy.info.frag.first = (unsigned int) ((char *) ptr - (char *) NULL) % BLOCKSIZE >> type; prev->next = _fraghead[type].next; prev->prev = &_fraghead[type]; prev->prev->next = prev; if (prev->next) prev->next->prev = prev; } break; } } ./libc-linux/malloc-930716/malloc.c100644 1676 334 16242 5505465443 14604 0ustar hjlisl/* malloc.c - C standard library routine. Copyright (c) 1989, 1993 Michael J. Haertel You may redistribute this library under the terms of the GNU Library General Public License (version 2 or any later version) as published by the Free Software Foundation. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ #include #include #include #include #include "malloc.h" /* How to really get more memory. */ void *(*_morecore)(long) = _default_morecore; /* Pointer to the base of the first block. */ char *_heapbase; /* Block information table. */ union info *_heapinfo; /* Number of info entries. */ static int heapsize; /* Search index in the info table. */ int _heapindex; /* Limit of valid info table indices. */ int _heaplimit; /* Count of large blocks allocated for each fragment size. */ int _fragblocks[BLOCKLOG]; /* Free lists for each fragment size. */ struct list _fraghead[BLOCKLOG]; /* Are we experienced? */ static int initialized; /* Aligned allocation. */ static void * align(size_t size) { void *result; unsigned int adj; result = (*_morecore)(size); adj = (unsigned int) ((char *) result - (char *) NULL) % BLOCKSIZE; if (adj != 0) { (*_morecore)(adj = BLOCKSIZE - adj); result = (char *) result + adj; } return result; } /* Set everything up and remember that we have. */ static int initialize() { heapsize = HEAP / BLOCKSIZE; _heapinfo = align(heapsize * sizeof (union info)); if (!_heapinfo) return 0; memset(_heapinfo, 0, heapsize * sizeof (union info)); _heapinfo[0].free.size = 0; _heapinfo[0].free.next = _heapinfo[0].free.prev = 0; _heapindex = 0; _heapbase = (char *) _heapinfo; initialized = 1; return 1; } /* Get neatly aligned memory, initializing or growing the heap info table as necessary. */ static void * morecore(size_t size) { void *result; union info *newinfo, *oldinfo; int newsize; result = align(size); if (!result) return NULL; /* Check if we need to grow the info table. */ if (BLOCK((char *) result + size) > heapsize) { newsize = heapsize; while (BLOCK((char *) result + size) > newsize) newsize *= 2; newinfo = align(newsize * sizeof (union info)); if (!newinfo) { (*_morecore)(-size); return NULL; } memset(newinfo, 0, newsize * sizeof (union info)); memcpy(newinfo, _heapinfo, heapsize * sizeof (union info)); oldinfo = _heapinfo; newinfo[BLOCK(oldinfo)].busy.type = 0; newinfo[BLOCK(oldinfo)].busy.info.size = BLOCKIFY(heapsize * sizeof (union info)); _heapinfo = newinfo; free(oldinfo); heapsize = newsize; } _heaplimit = BLOCK((char *) result + size); return result; } /* Allocate memory from the heap. */ void * malloc(size_t size) { void *result; int log, block, blocks, i, lastblocks, start; struct list *next; if (!initialized && !initialize()) return NULL; if (size == 0) return NULL; if (size < sizeof (struct list)) size = sizeof (struct list); /* Determine the allocation policy based on the request size. */ if (size <= BLOCKSIZE / 2) { /* Small allocation to receive a fragment of a block. Determine the logarithm to base two of the fragment size. */ --size; for (log = 1; (size >>= 1) != 0; ++log) ; /* Look in the fragment lists for a free fragment of the desired size. */ if ((next = _fraghead[log].next) != 0) { /* There are free fragments of this size. Pop a fragment out of the fragment list and return it. Update the block's nfree and first counters. */ result = next; next->prev->next = next->next; if (next->next) next->next->prev = next->prev; block = BLOCK(result); if (--_heapinfo[block].busy.info.frag.nfree) _heapinfo[block].busy.info.frag.first = (unsigned int) ((char *) next->next - (char *) NULL) % BLOCKSIZE >> log; } else { /* No free fragments of the desired size, so get a new block and break it into fragments, returning the first. */ result = malloc(BLOCKSIZE); if (!result) return NULL; ++_fragblocks[log]; /* Link all fragments but the first into the free list. */ for (i = 1; i < BLOCKSIZE >> log; ++i) { next = (struct list *) ((char *) result + (i << log)); next->next = _fraghead[log].next; next->prev = &_fraghead[log]; next->prev->next = next; if (next->next) next->next->prev = next; } /* Initialize the nfree and first counters for this block. */ block = BLOCK(result); _heapinfo[block].busy.type = log; _heapinfo[block].busy.info.frag.nfree = i - 1; _heapinfo[block].busy.info.frag.first = i - 1; } } else { /* Large allocation to receive one or more blocks. Search the free list in a circle starting at the last place visited. If we loop completely around without finding a large enough space we will have to get more memory from the system. */ blocks = BLOCKIFY(size); start = block = _heapindex; while (_heapinfo[block].free.size < blocks) { block = _heapinfo[block].free.next; if (block == start) { /* Need to get more from the system. Check to see if the new core will be contiguous with the final free block; if so we don't need to get as much. */ block = _heapinfo[0].free.prev; lastblocks = _heapinfo[block].free.size; if (_heaplimit && block + lastblocks == _heaplimit && (*_morecore)(0) == ADDRESS(block + lastblocks) && morecore((blocks - lastblocks) * BLOCKSIZE)) { /* Note that morecore() can change the location of the final block if it moves the info table and the old one gets coalesced into the final block. */ block = _heapinfo[0].free.prev; _heapinfo[block].free.size += blocks - lastblocks; continue; } result = morecore(blocks * BLOCKSIZE); if (!result) return NULL; block = BLOCK(result); _heapinfo[block].busy.type = 0; _heapinfo[block].busy.info.size = blocks; return result; } } /* At this point we have found a suitable free list entry. Figure out how to remove what we need from the list. */ result = ADDRESS(block); if (_heapinfo[block].free.size > blocks) { /* The block we found has a bit left over, so relink the tail end back into the free list. */ _heapinfo[block + blocks].free.size = _heapinfo[block].free.size - blocks; _heapinfo[block + blocks].free.next = _heapinfo[block].free.next; _heapinfo[block + blocks].free.prev = _heapinfo[block].free.prev; _heapinfo[_heapinfo[block].free.prev].free.next = _heapinfo[_heapinfo[block].free.next].free.prev = _heapindex = block + blocks; } else { /* The block exactly matches our requirements, so just remove it from the list. */ _heapinfo[_heapinfo[block].free.next].free.prev = _heapinfo[block].free.prev; _heapinfo[_heapinfo[block].free.prev].free.next = _heapindex = _heapinfo[block].free.next; } _heapinfo[block].busy.type = 0; _heapinfo[block].busy.info.size = blocks; } return result; } ./libc-linux/malloc-930716/malloc.h100644 1676 334 5774 5505465443 14601 0ustar hjlisl/* malloc.h - declarations for the allocator. Copyright (c) 1989, 1993 Michael J. Haertel You may redistribute this library under the terms of the GNU Library General Public License (version 2 or any later version) as published by the Free Software Foundation. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ /* Underlying allocation function; successive calls should return contiguous pieces of memory. */ extern void *(*_morecore)(long); /* Default value of previous. */ extern void *_default_morecore(long); /* The allocator divides the heap into blocks of fixed size; large requests receive one or more whole blocks, and small requests receive a fragment of a block. Fragment sizes are powers of two, and all fragments of a block are the same size. When all the fragments in a block have been freed, the block itself is freed. WARNING: BLOCKSIZE must be set greater than or equal to the machine's page size for valloc() to work correctly. The default definition here is 4096 bytes. */ #define INT_BIT (CHAR_BIT * sizeof (int)) #define BLOCKLOG (INT_BIT > 16 ? 12 : 9) #define BLOCKSIZE (1 << BLOCKLOG) #define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) /* Determine the amount of memory spanned by the initial heap table (not an absolute limit). */ #define HEAP (INT_BIT > 16 ? 4194304 : 65536) /* Number of contiguous free blocks allowed to build up at the end of memory before they will be returned to the system. */ #define FINAL_FREE_BLOCKS 8 /* Data structure giving per-block information. */ union info { struct { int type; /* Zero for a large block, or positive giving the logarithm to the base two of the fragment size. */ union { struct { int nfree; /* Free fragments in a fragmented block. */ int first; /* First free fragment of the block. */ } frag; int size; /* Size (in blocks) of a large cluster. */ } info; } busy; struct { int size; /* Size (in blocks) of a free cluster. */ int next; /* Index of next free cluster. */ int prev; /* Index of previous free cluster. */ } free; }; /* Pointer to first block of the heap. */ extern char *_heapbase; /* Table indexed by block number giving per-block information. */ extern union info *_heapinfo; /* Address to block number and vice versa. */ #define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1) #define ADDRESS(B) ((void *) (((B) - 1) * BLOCKSIZE + _heapbase)) /* Current search index for the heap table. */ extern int _heapindex; /* Limit of valid info table indices. */ extern int _heaplimit; /* Doubly linked lists of free fragments. */ struct list { struct list *next; struct list *prev; }; /* Count of blocks for each fragment size. */ extern int _fragblocks[]; /* Free list headers for each fragment size. */ extern struct list _fraghead[]; ./libc-linux/malloc-930716/morecore.c100644 1676 334 1566 5505465443 15133 0ustar hjlisl/* morecore.c - C library support routine for UNIX. Copyright (c) 1989, 1993 Michael J. Haertel You may redistribute this library under the terms of the GNU Library General Public License (version 2 or any later version) as published by the Free Software Foundation. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ #include #include #include "malloc.h" extern void *sbrk(int); /* Note that morecore has to take a signed argument so that negative values can return memory to the system. */ void * _default_morecore(long size) { void *result; result = sbrk(size); if (result == (void *) -1) return NULL; return result; } ./libc-linux/malloc-930716/realloc.c100644 1676 334 6603 5505465443 14736 0ustar hjlisl/* realloc.c - C standard library routine. Copyright (c) 1989, 1993 Michael J. Haertel You may redistribute this library under the terms of the GNU Library General Public License (version 2 or any later version) as published by the Free Software Foundation. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ #include #include #include #include #include "malloc.h" #define MIN(A, B) ((A) < (B) ? (A) : (B)) /* Resize the given region to the new size, returning a pointer to the (possibly moved) region. This is optimized for speed; some benchmarks seem to indicate that greater compactness is achieved by unconditionally allocating and copying to a new region. */ void * realloc(void *ptr, size_t size) { void *result, *previous; int block, blocks, type; int oldlimit; if (!ptr) return malloc(size); if (!size) { free(ptr); return malloc(0); } block = BLOCK(ptr); switch (type = _heapinfo[block].busy.type) { case 0: /* Maybe reallocate a large block to a small fragment. */ if (size <= BLOCKSIZE / 2) { if ((result = malloc(size)) != NULL) { memcpy(result, ptr, size); free(ptr); } return result; } /* The new size is a large allocation as well; see if we can hold it in place. */ blocks = BLOCKIFY(size); if (blocks < _heapinfo[block].busy.info.size) { /* The new size is smaller; return excess memory to the free list. */ _heapinfo[block + blocks].busy.type = 0; _heapinfo[block + blocks].busy.info.size = _heapinfo[block].busy.info.size - blocks; _heapinfo[block].busy.info.size = blocks; free(ADDRESS(block + blocks)); return ptr; } else if (blocks == _heapinfo[block].busy.info.size) /* No size change necessary. */ return ptr; else { /* Won't fit, so allocate a new region that will. Free the old region first in case there is sufficient adjacent free space to grow without moving. */ blocks = _heapinfo[block].busy.info.size; /* Prevent free from actually returning memory to the system. */ oldlimit = _heaplimit; _heaplimit = 0; free(ptr); _heaplimit = oldlimit; result = malloc(size); if (!result) { /* Now we're really in trouble. We have to unfree the thing we just freed. Unfortunately it might have been coalesced with its neighbors. */ if (_heapindex == block) malloc(blocks * BLOCKSIZE); else { previous = malloc((block - _heapindex) * BLOCKSIZE); malloc(blocks * BLOCKSIZE); free(previous); } return NULL; } if (ptr != result) memmove(result, ptr, blocks * BLOCKSIZE); return result; } break; default: /* Old size is a fragment; type is logarithm to base two of the fragment size. */ if ((size > 1 << (type - 1)) && (size <= 1 << type)) /* New size is the same kind of fragment. */ return ptr; else { /* New size is different; allocate a new space, and copy the lesser of the new size and the old. */ result = malloc(size); if (!result) return NULL; memcpy(result, ptr, MIN(size, 1 << type)); free(ptr); return result; } break; } } ./libc-linux/malloc-930716/valloc.c100644 1676 334 1703 5505465443 14571 0ustar hjlisl/* valloc.c - Berkeley C Library Compatibility routine. Copyright (c) 1989, 1993 Michael J. Haertel You may redistribute this library under the terms of the GNU Library General Public License (version 2 or any later version) as published by the Free Software Foundation. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ #include #include #include #include "malloc.h" #define MAX(A,B) ((A) > (B) ? (A) : (B)) /* * WARNING: The definition of BLOCKSIZE (in "malloc.h") * must be greater than or equal to the page size of * your machine. We don't do getpagesize() because I * want to keep weird Unix dependencies out of the code. */ void * valloc(size_t size) { return malloc(MAX(BLOCKSIZE, size)); } ./libc-linux/malloc-930716/Makefile100644 1676 334 1274 5515544133 14603 0ustar hjlisl# # Makefile for malloc library functions # override DEBUG=false TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules LIBMCHECK=$(TOPDIR)/debug/libmcheck.a INC_CFLAGS= -I. -I. -I. VSCFLAGS=-D_default_morecore=__default_morecore \ -D__MALLOC_0_RETURNS_NULL -D_morecore=__morecore BASE_CFLAGS := $(BASE_CFLAGS) $(VSCFLAGS) DIRS:= SRC1S = malloc.c free.c realloc.c calloc.c \ valloc.c SRC2S = cfree.c SRCS= $(SRC1S) $(SRC2S) ASMS= $(SRCS:.c=.s) OBJS= $(SRC1S:.c=.o) ALIASES= $(SRC2S:.c=.o) ifeq ($(DEBUG),true) lib:: $(LIBMCHECK) $(LIBMCHECK): mcheck-init.o $(RM) -f $(LIBMCHECK) $(AR) uvc $(LIBMCHECK) $? $(REALRANLIB) $(LIBMCHECK) endif include $(TOPDIR)/Maketargets ./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/nls/ 40755 1676 334 0 5550056237 11622 5ustar hjlisl./libc-linux/nls/Copyright100644 1676 334 2640 5461232662 13613 0ustar hjlisl/*********************************************************** Copyright 1990-1992, 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 Alphalpha'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. 148 Scituate St. Arlington, MA 02174 USA nazgul@alfalfa.com ******************************************************************/ ./libc-linux/nls/Makefile100644 1676 334 1466 5527713102 13361 0ustar hjlisl# # Makefile for message catalog'ing functions # TOPDIR=.. include $(TOPDIR)/Makeconfig include $(TOPDIR)/Makerules INC_CFLAGS=-I. ifeq ($(CHECKER),true) BASE_CFLAGS:= $(BASE_CFLAGS) -DI_STDARG else BASE_CFLAGS:= $(BASE_CFLAGS) -DHAVE_MMAP -DI_STDARG endif DIRS:= SRCS= msgcat.c msgcat-libc.c #mcprt.c mcprtlib.c ASMS= $(SRCS:.c=.s) OBJS= $(SRCS:.c=.o) ALIASES= include $(TOPDIR)/Maketargets #.c.o: # $(CC) $(CFLAGS) -c $< #clean: # rm -f $(OBJ) *~ *.bak gencat libmsg.a shar: msgcat.sh gencat.o: gencat.c gencat.h genlib.o: genlib.c gencat.h msgcat.h libmsg.a: $(MSGLIBOBJ) $(AR) crv $@ $(MSGLIBOBJ) msgcat.o: msgcat.h nl_types.h mcprt.o: mcprt.h mcprtlib.h mcprtlib.o: mcprtlib.h nl_types.h msgcat.sh: $(FILES) shar -C $(FILES) > $@ gencat: $(GENCATOBJ:.o=.c) $(CC) $(CFLAGS) -o $@ $(GENCATOBJ:.o=.c) ./libc-linux/nls/README100644 1676 334 23016 5461232663 12621 0ustar hjlislFirst a note on the copyright. This is the same one used by the X Consortium (fortunately no one has started copyrighting copyrights), so if your lawyers don't mind that one, they shouldn't mind this one. Simply put, you can do what you want with this, although if you are so inclined we'd appreciate it if you sent us back any enhancements, bug fixes, or other related material, so we can make it available to everyone else. But if you don't want to, you don't have to. So be it. So. What's here? It's an implementation of the Message Catalog System, as described in the X/Open Portability Guide (XSI Supplementary Definitions, X/Open Company, Ltd, Prentice Hall, Englewood Cliffs, New Jersey 07632, ISBN: 0-13-685850-3). Included is a version of gencat, to generate message catalogs, as well as the routines catgets, catopen, and catclose. There is also the beginings of an X/Open compliant set of print routines, but we'll talk about those later. I haven't done a man page yet (sorry, but I've got a product to get out the door, the pretty stuff has to come later). However you can use the definitions in the X/Open docs and it should all work. I have, however, added a series of pretty significant enhancements, particularly to gencat. As follows: Use: gencat [-new] [-or] [-lang C|C++|ANSIC] catfile msgfile [-h ]... This version of gencat accepts a number of flags. -new Erase the msg catalog and start a new one. The default behavior is to update the catalog with the specified msgfile(s). This will instead cause the old one to be deleted and a whole new one started. -h Output identifiers to the specified header files. This creates a header file with all of the appropriate #define's in it. Without this it would be up to you to ensure that you keep your code in sync with the catalog file. The header file is created from all of the previous msgfiles on the command line, so the order of the command line is important. This means that if you just put it at the end of the command line, all the defines will go in one file gencat foo.m bar.m zap.m -h all.h If you prefer to keep your dependencies down you can specify one after each message file, and each .h file will receive only the identifiers from the previous message file gencat foo.m -h foo.h bar.m -h bar.h zap.m -h zap.h As an added bonus, if you run the following sequence: gencat foo.m -h foo.h gencat foo.m -h foo.h the file foo.h will NOT be modified the second time. gencat checks to see if the contents have changed before modifying things. This means that you won't get spurious rebuilds of your source everytime you change a message. You can thus use a Makefile rule such as: MSGSRC=foo.m bar.m GENFLAGS=-or -lang C GENCAT=gencat NLSLIB=nlslib/OM/C $(NLSLIB): $(MSGSRC) @for i in $?; do cmd="$(GENCAT) $(GENFLAGS) $@ $$i -h `basename $$i .m`.H"; echo $$cmd; $$cmd; done foo.o: foo.h The for-loop isn't too pretty, but it works. For each .m file that has changed we run gencat on it. foo.o depends on the result of that gencat (foo.h) but foo.h won't actually be modified unless we changed the order (or added new members) to foo.m. (I hope this is clear, I'm in a bit of a rush.) -lang This governs the form of the include file. Currently supported is C, C++ and ANSIC. The latter two are identical in output. This argument is position dependent, you can switch the language back and forth inbetween include files if you care to. -or This is a hack, but a real useful one. MessageIds are ints, and it's not likely that you are going to go too high there if you generate them sequentially. catgets takes a msgId and a setId, since you can have multiple sets in a catalog. What -or does is shift the setId up to the high end of a long, and put the msgId in the low half. Assuming you don't go over half a long (usually 2 bytes nowadays) in either your set or msg ids, this will work great. Along with this are generated several macros for extracting ids and putting them back together. You can then easily define a macro for catgets which uses this single number instead of the two. Note that the form of the generated constants is somewhat different here. Take the file aboutMsgs.m $ aboutMsgs.m $ OmegaMail User Agent About Box Messages $ $set 4 #OmAbout $ About Box message and copyrights $ #Message # Welcome to OmegaMail(tm) $ #Copyright # Copyright (c) 1990 by Alphalpha Software, Inc. $ #CreatedBy # Created by: $ #About # About... # A # # $ #FaceBitmaps # /usr/lib/alphalpha/bitmaps/%s Here is the the output from: gencat foo aboutMsgs.m -h foo.h #define OmAboutSet 0x4 #define OmAboutMessage 0x1 #define OmAboutCopyright 0x2 #define OmAboutCreatedBy 0x3 #define OmAboutAbout 0x4 #define OmAboutFaceBitmaps 0x8 and now from: gencat -or foo aboutMsgs.m -h foo.h /* Use these Macros to compose and decompose setId's and msgId's */ #ifndef MCMakeId # define MCMakeId(s,m) (unsigned long)(((unsigned short)s<<(sizeof(short)*8))\ |(unsigned short)m) # define MCSetId(id) (unsigned int) (id >> (sizeof(short) * 8)) # define MCMsgId(id) (unsigned int) ((id << (sizeof(short) * 8))\ >> (sizeof(short) * 8)) #endif #define OmAboutSet 0x4 #define OmAboutMessage 0x40001 #define OmAboutCopyright 0x40002 #define OmAboutCreatedBy 0x40003 #define OmAboutAbout 0x40004 #define OmAboutFaceBitmaps 0x40008 Okay, by now, if you've read the X/Open docs, you'll see I've made a bunch of other extensions to the format of the msg catalog as well. Note that you don't have to use any of these and, with one exception, they are all compatible with the standard format. $set 4 #OmAbout In the standard the third argument is a comment. Here if the comment begins with a # then it is used to generate the setId constant (with the word "Set" appended). This constant is also prepended onto all of the msgId constants for this set. Anything after the first token is treated as a comment. $ #Message As with set, I've modified the comment to indicate an identifier. There are cleaner ways to do this, but I was trying to retain a modicom of compatibility. The identifier after # will be retained and used as the identifier for the next message (unless overridden before we get there). If a message has no previous identifier then no identifier is generated in the include file (I use this quite a bit myself, the first identifier is a Menu item, the next three are accelerator, accelerator-text and mnemonic - I don't need identifiers for them, I just add 1, 2 and 3). # Welcome to OmegaMail(tm) Finally the one incompatible extension. If a line begins with # a msgId number is automatically generated for it by adding one to the previous msgId. This wouldn't have been useful in the standard, since it didn't generate include files, but it's wonderful for this version. It makes it easy to reorder the message file to put things where they belong and not have to worry about renumber anything (although of course you'll have to recompile). That's about all for that. Now, what about the print routines? These are embarassing. They are a first pass. They support only %[dxo] and %[s], although they support *all* of the modifiers on those arguments (I had no idea there were so many!). They also, most importantly, support the position arguments that allow you to reference arguments out of order. There's a terrible hack macro to handle varargs which I wrote because I wasn't sure if it was okay to pass the address of the stack to a subroutine. I've since seen supposedly portable code that in fact does this, so I guess it's okay. If that's the case the code could become a lot simpler. I welcome anyone who would like to fix it up. I just don't know when I'll get the chance; it works, it's just ugly. One last comment. You probably want to know how reliable it is. I've tested the print routines pretty well. I've used the msgcat routines intensely, but I haven't exercised all of the options in the message catalog file (like all of the \ characters) although I have implemented them all. I'm pretty confident that all the basic stuff works, beyond that it's possible that there are bugs. As for portability, I've run it under BSD4.3 (Apollo) and SYSV-hybrid (SCO). (And I never want to see the words "System V with BSD extensions" again in my life.) I don't believe that there are any heavy dependencies on Unix, although using another system would probably require #ifdef's. I apologize for the state of the documentation, the lack of comments, the lack of testing, and all of the other things. This project is subsidiary to my primary goal (Graphical Email for Unix) and I'm afraid I haven't been able to spend the time on it that I would have liked. However I'll happily answer any questions that you may have, and will be glad to serve as a distribution point for future revisions. So if you make any changes or add more X/Open functions, send me a copy and I'll redistribute them. Best of luck! Kee Hinckley September 12, 1990 Bugs: There is currently one known bug. Updating an existing message catalog sometimes seems to not generate complete header files. If in doubt, delete the catalog and regenerate the whole thing. Kee - 02-12-92 Note, I've just applied a patch from that may fix this problem. 03-12-92 ./libc-linux/nls/gencat.c100644 1676 334 16162 5462546737 13365 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 01/18/91 3 hamilton #if not reparsed 01/12/91 2 schulert conditionally use prototypes 12/23/90 2 hamilton Fix fd == NULL to fd < 0 11/03/90 1 hamilton Alphalpha->Alfalfa & OmegaMail->Poste 08/13/90 1 schulert move from ua to omu */ #include #include #ifdef SYSV #include #include #else #include #endif #include #include #include "gencat.h" #ifndef L_SET #define L_SET SEEK_SET #endif #ifndef L_INCR #define L_INCR SEEK_CUR #endif /* * The spec says the syntax is "gencat catfile msgfile...". * We extend it to: * gencat [-new] [-or] [-lang C|C++|ANSIC] catfile msgfile * [-h ]... * Flags are order dependant, we'll take whatever lang was most recently chosen * and use it to generate the next header file. The header files are generated * at the point in the command line they are listed. Thus the sequence: * gencat -lang C foo.cat foo.mcs -h foo.h -lang C++ bar.mcs -h bar.H * will put constants from foo.mcs into foo.h and constants from bar.mcs into * bar.h. Constants are not saved in the catalog file, so nothing will come * from that, even if things have been defined before. The constants in foo.h * will be in C syntax, in bar.H in C++ syntax. */ static void writeIfChanged( #if defined(__STDC__) || defined(__cplusplus) char *fname, int lang, int orConsts #endif ); void usage() { fprintf(stderr, "Use: gencat [-new] [-or] [-lang C|C++|ANSIC] catfile msgfile [-h ]...\n"); } void main( #if defined(__STDC__) || defined(__cplusplus) int argc, char *argv[]) #else argc, argv) int argc; char *argv[]; #endif { int ofd, ifd, i; FILE *fptr; char *catfile = NULL; char *input = NULL; int lang = MCLangC; int new = False; int orConsts = False; for (i = 1; i < argc; ++i) { if (argv[i][0] == '-') { if (strcmp(argv[i], "-lang") == 0) { ++i; if (strcmp(argv[i], "C") == 0) lang = MCLangC; else if (strcmp(argv[i], "C++") == 0) lang = MCLangCPlusPlus; else if (strcmp(argv[i], "ANSIC") == 0) lang = MCLangANSIC; else { fprintf(stderr, "gencat: Unrecognized language: %s\n", argv[i]); exit(1); } } else if (strncmp(argv[i], "-h", 2) == 0) { if (!input) { fprintf(stderr, "gencat: Can't write to a header before reading something.\n"); exit(1); } ++i; writeIfChanged(argv[i], lang, orConsts); } else if (strncmp(argv[i], "-new", 4) == 0) { if (catfile) { fprintf(stderr, "gencat: You must specify -new before the catalog file name\n"); exit(1); } new = True; } else if (strncmp(argv[i], "-or", 3) == 0) { orConsts = ~orConsts; } else { usage(); exit(1); } } else { if (!catfile) { catfile = argv[i]; if (new) { if ((ofd = open(catfile, O_WRONLY|O_TRUNC|O_CREAT, 0666)) < 0) { fprintf(stderr, "gencat: Unable to create a new %s.\n", catfile); exit(1); } } else if ((ofd = open(catfile, O_RDONLY)) < 0) { if ((ofd = open(catfile, O_WRONLY|O_CREAT, 0666)) < 0) { fprintf(stderr, "gencat: Unable to create %s.\n", catfile); exit(1); } } else { MCReadCat(ofd); close(ofd); if ((ofd = open(catfile, O_WRONLY|O_TRUNC)) < 0) { fprintf(stderr, "gencat: Unable to truncate %s.\n", catfile); exit(1); } } } else { input = argv[i]; if ((ifd = open(input, O_RDONLY)) < 0) { fprintf(stderr, "gencat: Unable to read %s\n", input); exit(1); } MCParse(ifd); close(ifd); } } } if (catfile) { MCWriteCat(ofd); exit(0); } else { usage(); exit(1); } } static void writeIfChanged( #if defined(__STDC__) || defined(__cplusplus) char *fname, int lang, int orConsts) #else fname, lang, orConsts) char *fname; int lang; int orConsts; #endif { char tmpname[32]; char buf[BUFSIZ], tbuf[BUFSIZ], *cptr, *tptr; int fd, tfd; int diff = False; int c, len, tlen; struct stat sbuf; /* If it doesn't exist, just create it */ if (stat(fname, &sbuf)) { if ((fd = open(fname, O_WRONLY|O_CREAT, 0666)) < 0) { fprintf(stderr, "gencat: Unable to create header file %s.\n", fname); exit(1); } MCWriteConst(fd, lang, orConsts); close(fd); return; } /* If it does exist, create a temp file for now */ sprintf(tmpname, "/tmp/gencat.%d", (int) getpid()); if ((tfd = open(tmpname, O_RDWR|O_CREAT, 0666)) < 0) { fprintf(stderr, "gencat: Unable to open temporary file: %s\n", tmpname); exit(1); } unlink(tmpname); /* Write to the temp file and rewind */ MCWriteConst(tfd, lang, orConsts); /* Open the real header file */ if ((fd = open(fname, O_RDONLY)) < 0) { fprintf(stderr, "gencat: Unable to read header file: %s\n", fname); exit(1); } /* Backup to the start of the temp file */ if (lseek(tfd, 0L, L_SET) < 0) { fprintf(stderr, "gencat: Unable to seek in tempfile: %s\n", tmpname); exit(1); } /* Now compare them */ while ((tlen = read(tfd, tbuf, BUFSIZ)) > 0) { if ((len = read(fd, buf, BUFSIZ)) != tlen) { diff = True; goto done; } for (cptr = buf, tptr = tbuf; cptr < buf+len; ++cptr, ++tptr) { if (*tptr != *cptr) { diff = True; goto done; } } } done: if (diff) { if (lseek(tfd, 0L, L_SET) < 0) { fprintf(stderr, "gencat: Unable to seek in tempfile: %s\n", tmpname); exit(1); } close(fd); if ((fd = open(fname, O_WRONLY|O_TRUNC)) < 0) { fprintf(stderr, "gencat: Unable to truncate header file: %s\n", fname); exit(1); } while ((len = read(tfd, buf, BUFSIZ)) > 0) { if (write(fd, buf, len) != len) { fprintf(stderr, "gencat: Error writing to header file: %s\n", fname); } } } close(fd); close(tfd); } ./libc-linux/nls/genlib.c100644 1676 334 46103 5461531127 13344 0ustar hjlisl/* -*-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 12/03/82 nazgul Patch from . This may fix the problem with updating sets. 10/18/92 3 schulert actually put in the changes described in last edit. 10/18/92 7 nazgul Changes from gbooman@feds1.Prime.COM (Gordon Booman) 1) Support backslash quoted quotes in message file text. 2) Correctly indicate error location in messages that have tabs. 3) Fixed a misspelling. 04/15/91 6 nazgul Check for byte order first 02/25/91 5 nazgul Added flag for MS byteorder 01/14/91 4 nazgul Off by one on number specified entries */ #include #ifdef SYSV #include #include #ifndef __linux__ #include static int bcopy(src, dst, length) char *src, *dst; int length; { memcpy(dst, src, length); } static int bzero(b, length) char *b; int length; { memset(b, '\0', length); } #endif #endif #include #include #include "msgcat.h" #include "gencat.h" #ifndef L_SET #define L_SET SEEK_SET #endif #ifndef L_INCR #define L_INCR SEEK_CUR #endif static char *curline = NULL; static long lineno = 0; static void warning(cptr, msg) char *cptr; char *msg; { fprintf(stderr, "gencat: %s on line %d\n", msg, lineno); fprintf(stderr, "%s\n", curline); if (cptr) { char *tptr; for (tptr = curline; tptr < cptr; ++tptr) putc(*tptr == '\t' ? '\t' : ' ', stderr); fprintf(stderr, "^\n"); } } static void error(cptr, msg) char *cptr; char *msg; { warning(cptr, msg); exit(1); } static void corrupt() { error(NULL, "corrupt message catalog"); } static void nomem() { error(NULL, "out of memory"); } static char *getline(fd) int fd; { static long len = 0, curlen = BUFSIZ; static char buf[BUFSIZ], *bptr = buf, *bend = buf; char *cptr, *cend; long buflen; if (!curline) { curline = (char *) malloc(curlen); if (!curline) nomem(); } ++lineno; cptr = curline; cend = curline + curlen; while (True) { for (; bptr < bend && cptr < cend; ++cptr, ++bptr) { if (*bptr == '\n') { *cptr = '\0'; ++bptr; return(curline); } else *cptr = *bptr; } if (bptr == bend) { buflen = read(fd, buf, BUFSIZ); if (buflen <= 0) { if (cptr > curline) { *cptr = '\0'; return(curline); } return(NULL); } bend = buf + buflen; bptr = buf; } if (cptr == cend) { cptr = curline = (char *) realloc(curline, curlen *= 2); cend = curline + curlen; } } } static char *token(cptr) char *cptr; { static char tok[MAXTOKEN+1]; char *tptr = tok; while (*cptr && isspace(*cptr)) ++cptr; while (*cptr && !isspace(*cptr)) *tptr++ = *cptr++; *tptr = '\0'; return(tok); } static char *wskip(cptr) char *cptr; { if (!*cptr || !isspace(*cptr)) { warning(cptr, "expected a space"); return(cptr); } while (*cptr && isspace(*cptr)) ++cptr; return(cptr); } static char *cskip(cptr) char *cptr; { if (!*cptr || isspace(*cptr)) { warning(cptr, "wasn't expecting a space"); return(cptr); } while (*cptr && !isspace(*cptr)) ++cptr; return(cptr); } static char *getmsg(fd, cptr, quote) int fd; char *cptr; char quote; { static char *msg = NULL; static long msglen = 0; long clen, i; char *tptr; int needq; if (quote && *cptr == quote) { needq = True; ++cptr; } else needq = False; clen = strlen(cptr) + 1; if (clen > msglen) { if (msglen) msg = (char *) realloc(msg, clen); else msg = (char *) malloc(clen); msglen = clen; } tptr = msg; while (*cptr) { if (quote && *cptr == quote) { char *tmp; tmp = cptr+1; if (*tmp && (!isspace(*tmp) || *wskip(tmp))) { warning(cptr, "quote character before end of line, ignoring"); *tptr++ = *cptr++; } else { *cptr = '\0'; } } else if (*cptr == '\\') { ++cptr; switch (*cptr) { case '\0': cptr = getline(fd); if (!cptr) error(NULL, "premature end of file"); msglen += strlen(cptr); i = tptr - msg; msg = (char *) realloc(msg, msglen); tptr = msg + i; break; case 'n': *tptr++ = '\n'; ++cptr; break; case 't': *tptr++ = '\t'; ++cptr; break; case 'v': *tptr++ = '\v'; ++cptr; break; case 'b': *tptr++ = '\b'; ++cptr; break; case 'r': *tptr++ = '\r'; ++cptr; break; case 'f': *tptr++ = '\f'; ++cptr; break; case '\\': *tptr++ = '\\'; ++cptr; break; default: if (isdigit(*cptr)) { *tptr = 0; for (i = 0; i < 3; ++i) { if (!isdigit(*cptr)) break; if (*cptr > '7') warning(cptr, "octal number greater than 7?!"); *tptr *= 8; *tptr += (*cptr - '0'); ++cptr; } } else if (*cptr == quote) { *tptr++ = *cptr++; } else { warning(cptr, "unrecognized escape sequence"); } } } else { *tptr++ = *cptr++; } } *tptr = '\0'; return(msg); } static char *dupstr(ostr) char *ostr; { char *nstr; nstr = (char *) malloc(strlen(ostr) + 1); if (!nstr) error(NULL, "unable to allocate storage"); strcpy(nstr, ostr); return(nstr); } /* * The Global Stuff */ typedef struct _msgT { long msgId; char *str; char *hconst; long offset; struct _msgT *prev, *next; } msgT; typedef struct _setT { long setId; char *hconst; msgT *first, *last; struct _setT *prev, *next; } setT; typedef struct { setT *first, *last; } catT; static setT *curSet; static catT *cat; /* * Find the current byte order. There are of course some others, but this will do * for now. Note that all we care about is "long". */ long MCGetByteOrder() { long l = 0x00010203; char *cptr = (char *) &l; if (cptr[0] == 0 && cptr[1] == 1 && cptr[2] == 2 && cptr[3] == 3) return MC68KByteOrder; else return MCn86ByteOrder; } void MCParse( #if PROTO int fd) #else fd) int fd; #endif { char *cptr, *str; int setid, msgid = 0; char hconst[MAXTOKEN+1]; char quote = 0; int i; if (!cat) { cat = (catT *) malloc(sizeof(catT)); if (!cat) nomem(); bzero(cat, sizeof(catT)); } hconst[0] = '\0'; while (cptr = getline(fd)) { if (*cptr == '$') { ++cptr; if (strncmp(cptr, "set", 3) == 0) { cptr += 3; cptr = wskip(cptr); setid = atoi(cptr); cptr = cskip(cptr); if (*cptr) cptr = wskip(cptr); if (*cptr == '#') { ++cptr; MCAddSet(setid, token(cptr)); } else MCAddSet(setid, NULL); msgid = 0; } else if (strncmp(cptr, "delset", 6) == 0) { cptr += 6; cptr = wskip(cptr); setid = atoi(cptr); MCDelSet(setid); } else if (strncmp(cptr, "quote", 5) == 0) { cptr += 5; if (!*cptr) quote = 0; else { cptr = wskip(cptr); if (!*cptr) quote = 0; else quote = *cptr; } } else if (isspace(*cptr)) { cptr = wskip(cptr); if (*cptr == '#') { ++cptr; strcpy(hconst, token(cptr)); } } else { if (*cptr) { cptr = wskip(cptr); if (*cptr) warning(cptr, "unrecognized line"); } } } else { if (isdigit(*cptr) || *cptr == '#') { if (*cptr == '#') { ++msgid; ++cptr; if (!*cptr) { MCAddMsg(msgid, "", hconst); hconst[0] = '\0'; continue; } if (!isspace(*cptr)) warning(cptr, "expected a space"); ++cptr; if (!*cptr) { MCAddMsg(msgid, "", hconst); hconst[0] = '\0'; continue; } } else { msgid = atoi(cptr); cptr = cskip(cptr); cptr = wskip(cptr); /* if (*cptr) ++cptr; */ } if (!*cptr) MCDelMsg(msgid); else { str = getmsg(fd, cptr, quote); MCAddMsg(msgid, str, hconst); hconst[0] = '\0'; } } } } } void MCReadCat( #if PROTO int fd) #else fd) int fd; #endif { MCHeaderT mcHead; MCMsgT mcMsg; MCSetT mcSet; msgT *msg; setT *set; int i; char *data; cat = (catT *) malloc(sizeof(catT)); if (!cat) nomem(); bzero(cat, sizeof(catT)); if (read(fd, &mcHead, sizeof(mcHead)) != sizeof(mcHead)) corrupt(); if (strncmp(mcHead.magic, MCMagic, MCMagicLen) != 0) corrupt(); if ((mcHead.flags & MCGetByteOrder()) == 0) error(NULL, "wrong byte order"); if (mcHead.majorVer != MCMajorVer) error(NULL, "unrecognized catalog version"); if (lseek(fd, mcHead.firstSet, L_SET) == -1) corrupt(); while (True) { if (read(fd, &mcSet, sizeof(mcSet)) != sizeof(mcSet)) corrupt(); if (mcSet.invalid) continue; set = (setT *) malloc(sizeof(setT)); if (!set) nomem(); bzero(set, sizeof(*set)); if (cat->first) { cat->last->next = set; set->prev = cat->last; cat->last = set; } else cat->first = cat->last = set; set->setId = mcSet.setId; /* Get the data */ if (mcSet.dataLen) { data = (char *) malloc(mcSet.dataLen); if (!data) nomem(); if (lseek(fd, mcSet.data.off, L_SET) == -1) corrupt(); if (read(fd, data, mcSet.dataLen) != mcSet.dataLen) corrupt(); if (lseek(fd, mcSet.u.firstMsg, L_SET) == -1) corrupt(); for (i = 0; i < mcSet.numMsgs; ++i) { if (read(fd, &mcMsg, sizeof(mcMsg)) != sizeof(mcMsg)) corrupt(); if (mcMsg.invalid) { --i; continue; } msg = (msgT *) malloc(sizeof(msgT)); if (!msg) nomem(); bzero(msg, sizeof(*msg)); if (set->first) { set->last->next = msg; msg->prev = set->last; set->last = msg; } else set->first = set->last = msg; msg->msgId = mcMsg.msgId; msg->str = dupstr((char *) (data + mcMsg.msg.off)); } free(data); } if (!mcSet.nextSet) break; if (lseek(fd, mcSet.nextSet, L_SET) == -1) corrupt(); } } static void printS(fd, str) int fd; char *str; { write(fd, str, strlen(str)); } static void printL(fd, l) int fd; long l; { char buf[32]; sprintf(buf, "%ld", l); write(fd, buf, strlen(buf)); } static void printLX(fd, l) int fd; long l; { char buf[32]; sprintf(buf, "%lx", l); write(fd, buf, strlen(buf)); } static void genconst(fd, type, setConst, msgConst, val) int fd; int type; char *setConst; char *msgConst; long val; { switch (type) { case MCLangC: if (!msgConst) { printS(fd, "\n#define "); printS(fd, setConst); printS(fd, "Set"); } else { printS(fd, "#define "); printS(fd, setConst); printS(fd, msgConst); } printS(fd, "\t0x"); printLX(fd, val); printS(fd, "\n"); break; case MCLangCPlusPlus: case MCLangANSIC: if (!msgConst) { printS(fd, "\nconst long "); printS(fd, setConst); printS(fd, "Set"); } else { printS(fd, "const long "); printS(fd, setConst); printS(fd, msgConst); } printS(fd, "\t= "); printL(fd, val); printS(fd, ";\n"); break; default: error(NULL, "not a recognized (programming) language type"); } } void MCWriteConst( #if PROTO int fd, int type, int orConsts) #else fd, type, orConsts) int fd; int type; int orConsts; #endif { msgT *msg; setT *set; long id; if (orConsts && (type == MCLangC || type == MCLangCPlusPlus || type == MCLangANSIC)) { printS(fd, "/* Use these Macros to compose and decompose setId's and msgId's */\n"); printS(fd, "#ifndef MCMakeId\n"); printS(fd, "# define MCuint unsigned int\n"); printS(fd, "# define MCushort unsigned short\n"); printS(fd, "# define MCulong unsigned long\n"); printS(fd, "# define MCMakeId(s,m)\t(MCulong)(((MCushort)s<<(sizeof(short)*8))\\\n"); printS(fd, " \t |(MCushort)m)\n"); printS(fd, "# define MCSetId(id)\t(MCuint) ((MCuint)id >> (MCuint)(sizeof(short) * 8))\n"); printS(fd, "# define MCMsgId(id)\t(MCuint) (((MCuint)id << (MCuint)(sizeof(short) * 8))\\\n"); printS(fd, " \t >> (MCuint)(sizeof(short) * 8))\n"); printS(fd, "#endif\n"); } for (set = cat->first; set; set = set->next) { if (set->hconst) genconst(fd, type, set->hconst, NULL, set->setId); for (msg = set->first; msg; msg = msg->next) { if (msg->hconst) { if (orConsts) id = MCMakeId(set->setId, msg->msgId); else id = msg->msgId; genconst(fd, type, set->hconst, msg->hconst, id); free(msg->hconst); msg->hconst = NULL; } } if (set->hconst) { free(set->hconst); set->hconst = NULL; } } } void MCWriteCat( #if PROTO int fd) #else fd) int fd; #endif { MCHeaderT mcHead; int cnt; setT *set; msgT *msg; MCSetT mcSet; MCMsgT mcMsg; off_t pos; bcopy(MCMagic, mcHead.magic, MCMagicLen); mcHead.majorVer = MCMajorVer; mcHead.minorVer = MCMinorVer; mcHead.flags = MCGetByteOrder(); mcHead.firstSet = 0; /* We'll be back to set this in a minute */ for (cnt = 0, set = cat->first; set; set = set->next) ++cnt; mcHead.numSets = cnt; lseek(fd, 0L, L_SET); write(fd, &mcHead, sizeof(mcHead)); mcHead.firstSet = lseek(fd, 0, L_INCR); lseek(fd, 0L, L_SET); write(fd, &mcHead, sizeof(mcHead)); for (set = cat->first; set; set = set->next) { bzero(&mcSet, sizeof(mcSet)); mcSet.setId = set->setId; mcSet.invalid = False; /* The rest we'll have to come back and change in a moment */ pos = lseek(fd, 0, L_INCR); write(fd, &mcSet, sizeof(mcSet)); /* Now write all the string data */ mcSet.data.off = lseek(fd, 0, L_INCR); cnt = 0; for (msg = set->first; msg; msg = msg->next) { msg->offset = lseek(fd, 0, L_INCR) - mcSet.data.off; mcSet.dataLen += write(fd, msg->str, strlen(msg->str) + 1); ++cnt; } mcSet.u.firstMsg = lseek(fd, 0, L_INCR); mcSet.numMsgs = cnt; /* Now write the message headers */ for (msg = set->first; msg; msg = msg->next) { mcMsg.msgId = msg->msgId; mcMsg.msg.off = msg->offset; mcMsg.invalid = False; write(fd, &mcMsg, sizeof(mcMsg)); } /* Go back and fix things up */ if (set == cat->last) { mcSet.nextSet = 0; lseek(fd, pos, L_SET); write(fd, &mcSet, sizeof(mcSet)); } else { mcSet.nextSet = lseek(fd, 0, L_INCR); lseek(fd, pos, L_SET); write(fd, &mcSet, sizeof(mcSet)); lseek(fd, mcSet.nextSet, L_SET); } } } void MCAddSet( #if PROTO int setId, char *hconst) #else setId, hconst) int setId; char *hconst; #endif { setT *set; if (setId <= 0) { error(NULL, "setId's must be greater than zero"); return; } if (hconst && !*hconst) hconst = NULL; for (set = cat->first; set; set = set->next) { if (set->setId == setId) { if (set->hconst && hconst) free(set->hconst); set->hconst = NULL; break; } else if (set->setId > setId) { setT *newSet; newSet = (setT *) malloc(sizeof(setT)); if (!newSet) nomem(); bzero(newSet, sizeof(setT)); newSet->prev = set->prev; newSet->next = set; if (set->prev) set->prev->next = newSet; else cat->first = newSet; set->prev = newSet; set = newSet; break; } } if (!set) { set = (setT *) malloc(sizeof(setT)); if (!set) nomem(); bzero(set, sizeof(setT)); if (cat->first) { set->prev = cat->last; set->next = NULL; cat->last->next = set; cat->last = set; } else { set->prev = set->next = NULL; cat->first = cat->last = set; } } set->setId = setId; if (hconst) set->hconst = dupstr(hconst); curSet = set; } void MCAddMsg( #if PROTO int msgId, char *str, char *hconst) #else msgId, str, hconst) int msgId; char *str; char *hconst; #endif { msgT *msg; if (!curSet) error(NULL, "can't specify a message when no set exists"); if (msgId <= 0) { error(NULL, "msgId's must be greater than zero"); return; } if (hconst && !*hconst) hconst = NULL; for (msg = curSet->first; msg; msg = msg->next) { if (msg->msgId == msgId) { if (msg->hconst && hconst) free(msg->hconst); if (msg->str) free(msg->str); msg->hconst = msg->str = NULL; break; } else if (msg->msgId > msgId) { msgT *newMsg; newMsg = (msgT *) malloc(sizeof(msgT)); if (!newMsg) nomem(); bzero(newMsg, sizeof(msgT)); newMsg->prev = msg->prev; newMsg->next = msg; if (msg->prev) msg->prev->next = newMsg; else curSet->first = newMsg; msg->prev = newMsg; msg = newMsg; break; } } if (!msg) { msg = (msgT *) malloc(sizeof(msgT)); if (!msg) nomem(); bzero(msg, sizeof(msgT)); if (curSet->first) { msg->prev = curSet->last; msg->next = NULL; curSet->last->next = msg; curSet->last = msg; } else { msg->prev = msg->next = NULL; curSet->first = curSet->last = msg; } } msg->msgId = msgId; if (hconst) msg->hconst = dupstr(hconst); msg->str = dupstr(str); } void MCDelSet( #if PROTO int setId) #else setId) int setId; #endif { setT *set; msgT *msg; for (set = cat->first; set; set = set->next) { if (set->setId == setId) { for (msg = set->first; msg; msg = msg->next) { if (msg->hconst) free(msg->hconst); if (msg->str) free(msg->str); free(msg); } if (set->hconst) free(set->hconst); if (set->prev) set->prev->next = set->next; else cat->first = set->next; if (set->next) set->next->prev = set->prev; else cat->last = set->prev; free(set); return; } else if (set->setId > setId) break; } warning(NULL, "specified set doesn't exist"); } void MCDelMsg( #if PROTO int msgId) #else msgId) int msgId; #endif { msgT *msg; if (!curSet) error(NULL, "you can't delete a message before defining the set"); for (msg = curSet->first; msg; msg = msg->next) { if (msg->msgId == msgId) { if (msg->hconst) free(msg->hconst); if (msg->str) free(msg->str); if (msg->prev) msg->prev->next = msg->next; else curSet->first = msg->next; if (msg->next) msg->next->prev = msg->prev; else curSet->last = msg->prev; free(msg); return; } else if (msg->msgId > msgId) break; } warning(NULL, "specified msg doesn't exist"); } ./libc-linux/nls/mcprt.c100644 1676 334 6303 5462220506 13204 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 01/18/91 3 hamilton #if not rescanned 01/12/91 1 schulert conditionally use prototypes rework to use either varargs or stdargs 11/03/90 2 hamilton Alphalpha->Alfalfa & OmegaMail->Poste 08/10/90 1 nazgul printf, sprintf and fprintf */ #include #include "mcprt.h" #include "mcprtlib.h" int MCprintf( #if defined(__STDC__) || defined(__cplusplus) char *fmt, ...) #else fmt, va_alist) char *fmt; va_dcl #endif { MCRockT *rock; int len, i; if ((rock = MCPrintInit(fmt)) == NULL) return -1; MCPrintGet(fmt, rock); if ((len = MCPrintParse(rock)) < 0) return -1; for (i = 0; i < rock->replyCnt; ++i) fwrite(rock->replyList[i].data, 1, rock->replyList[i].dataLen, stdout); MCPrintFree(rock); return len; } int MCfprintf( #if defined(__STDC__) || defined(__cplusplus) FILE *fptr, char *fmt, ...) #else fptr, fmt, va_alist) FILE *fptr; char *fmt; va_dcl #endif { MCRockT *rock; int len, i; if ((rock = MCPrintInit(fmt)) == NULL) return -1; MCPrintGet(fmt, rock); if ((len = MCPrintParse(rock)) < 0) return -1; for (i = 0; i < rock->replyCnt; ++i) fwrite(rock->replyList[i].data, 1, rock->replyList[i].dataLen, fptr); MCPrintFree(rock); return len; } int MCsprintf( #if defined(__STDC__) || defined(__cplusplus) char *cptr, char *fmt, ...) #else cptr, fmt, va_alist) char *cptr; char *fmt; va_dcl #endif { MCRockT *rock; int len, i; if ((rock = MCPrintInit(fmt)) == NULL) return -1; MCPrintGet(fmt, rock); if ((len = MCPrintParse(rock)) < 0) return -1; for (i = 0; i < rock->replyCnt; ++i) { bcopy(rock->replyList[i].data, cptr, rock->replyList[i].dataLen); cptr += rock->replyList[i].dataLen; } *cptr = '\0'; MCPrintFree(rock); return len; } ./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/mcprt.h100644 1676 334 3777 5461232664 13234 0ustar hjlisl#ifndef mcprt_h #define mcprt_h /*********************************************************** 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 01/18/91 3 hamilton #if not rescanned 01/12/91 2 schulert conditionally use prototypes 12/13/90 1 schulert add ifdef __cplusplus 11/03/90 2 hamilton Alphalpha->Alfalfa & OmegaMail->Poste 08/10/90 1 nazgul Initial version */ #include #ifdef USENLS # ifdef I_STDARG extern int MCprintf(char *fmt, ...); extern int MCfprintf(FILE *fptr, char *fmt, ...); extern int MCsprintf(char *cptr, char *fmt, ...); # else extern int MCprintf(); extern int MCfprintf(); extern int MCsprintf(); # endif #endif #endif ./libc-linux/nls/mcprtlib.h100644 1676 334 12305 5461232664 13726 0ustar hjlisl#ifndef mcprtlib_h #define mcprtlib_h /*********************************************************** 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 03/20/91 2 schulert Ultrix cc has trouble with void*, so change them to int* 01/18/91 3 hamilton #if not rescanned 01/12/91 1 schulert conditionally use prototypes rework to use either varargs or stdarg 11/03/90 2 hamilton Alphalpha->Alfalfa & OmegaMail->Poste 08/10/90 1 nazgul Initial version */ /* taken from Xm/lib/VaSimple.h currently no one defines MISSING_STDARG_H */ #ifdef I_STDARG # include # define Va_start(a,b) va_start(a,b) #else # include # define Va_start(a,b) va_start(a) #endif #define MCFree 0x0010 /* Reminder to MCPrintFree */ #define MCCatalog 0x0100 /* Probably came from catalog */ #define MCFmtArg (0x0001|MCCatalog) /* Came from format string */ #define MCUserArg (0x0012|MCFree) /* Came from program (e.g. %s) */ #define MCDataArg (0x0013|MCFree) /* Came from data (e.g. %d) */ #define MCMsgArg (0x0004|MCCatalog) /* Came from message catalog */ #define MCShortType 1 #define MCLongType 2 #define MCIntType 3 #define MCLongFloatType 4 #define MCFloatType 5 #define MCStringType 6 #define MCVoidPType 7 #define MCShortPType 8 #define MCLongPType 9 #define MCIntPType 10 typedef struct { int type; union { short shortV; unsigned short ushortV; long longV; unsigned long ulongV; int intV; unsigned int uintV; #ifdef LongFloat long float lfloatV; #endif float floatV; char *charPV; int *voidPV; short *shortPV; long *longPV; int *intPV; } u; } MCTypesT; #define MCSpaceFlag 0x01 #define MCPlusFlag 0x02 #define MCMinusFlag 0x04 #define MCAltFlag 0x08 #define MCZeroFlag 0x10 typedef struct { int pos; int type; char c; int flag; int hasWidth; int widthPos; int width; int hasPrec; int precPos; int prec; char *data; int dataLen; } MCArgumentT; typedef struct { int argType; char *data; long dataLen; } MCReplyT; typedef struct { MCArgumentT *argList; int argCnt; MCTypesT *typeList; int typeCnt; MCReplyT *replyList; int replyCnt; } MCRockT; #define MCPrintGet(start,rock) \ { \ va_list vl; \ int i; \ int typeCnt = rock->typeCnt; \ MCTypesT *typeList = rock->typeList; \ \ Va_start(vl, start); \ for (i = 0; i < typeCnt; ++i) { \ switch (typeList[i].type) { \ case MCShortType: \ typeList[i].u.shortV = va_arg(vl, short); \ break; \ case MCLongType: \ typeList[i].u.longV = va_arg(vl, long); \ break; \ case MCIntType: \ typeList[i].u.intV = va_arg(vl, int); \ break; \ case MCLongFloatType: \ /*#ifdef LongFloat \ typeList[i].u.lfloatV = va_arg(vl, long float); \ break; \ #endif*/ \ case MCFloatType: \ typeList[i].u.floatV = va_arg(vl, float); \ break; \ case MCStringType: \ typeList[i].u.charPV = va_arg(vl, char *); \ break; \ case MCVoidPType: \ typeList[i].u.voidPV = va_arg(vl, int *); \ break; \ case MCShortPType: \ typeList[i].u.shortPV = va_arg(vl, short *); \ break; \ case MCLongPType: \ typeList[i].u.longPV = va_arg(vl, long *); \ break; \ case MCIntPType: \ typeList[i].u.intPV = va_arg(vl, int *); \ break; \ } \ } \ va_end(vl); \ } extern MCRockT *MCPrintInit(); extern int MCPrintParse(); extern void MCPrintFree(); #endif ./libc-linux/nls/msgcat.h100644 1676 334 13276 5472241240 13370 0ustar hjlisl/* -*-c++-*- */ #ifndef __msgcath /*********************************************************** 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 ******************************************************************/ #include /* * On disk data structures */ /* Edit History 02/25/91 2 nazgul Byte order flags, upped the version number 11/03/90 1 hamilton Alphalpha->Alfalfa & OmegaMail->Poste 08/13/90 1 schulert move from ua to omu */ /* For or'd constants */ #define MCMakeId(s,m) (unsigned long) ( ((unsigned short)s << (sizeof(short)*8)) \ | (unsigned short)m ) #define MCSetId(id) (unsigned int) ( id >> (sizeof(short) * 8) ) #define MCMsgId(id) (unsigned int) ( (id << (sizeof(short) * 8)) \ >> (sizeof(short) * 8) ) #undef S #undef UI #undef UL #define MCMagicLen 8 #define MCMagic "*nazgul*" #define MCLastMsg 0 #define MCLastSet 0 #define MCMajorVer 1 #define MCMinorVer 0 /* * Critical note here. Sets and Messages *MUST* be stored in ascending * order. There are stored that way (by specification) in the original * data file, however in the process of merging in new stuff you might * mix that up. Don't! The catget stuff does a binary search and will * totally lose it if these aren't in order (not contiguous mind you, just * in order. If this turns out to be a major problem this could be enhanced * by adding a 'sorted' flag to the db, and sorting msgs and sets at load * time if things aren't sorted, but I'd like not to have to do that. */ /* * I have tried here to define data structures which can be used * while the catalog is on disk, and at runtime. * This is rather dangerous of course, but I think it can be done without * overly increasing the memory usage, and it makes loading and storing * somewhat simpler and less prone to accidents. I have also tried to * define on disk data structures which can be updated in place, so that * with a very large catalog (e.g. all system errors) you don't have to * load everything in memory in order to add or update one set. With * this in mind there are "invalid" flags which allow items to be * invalidated and thus not loaded at runtime. Note however that although * I pay attention to these when I load the DB, I do not currently use * them in gencat (it just reads everything into memory), so there is * no guarantee that this will all work. */ /* These should be publicly available */ #define MCLoadBySet 0 /* Load entire sets as they are used */ #define MCLoadAll 1 /* Load entire DB on catopen */ extern char *MCAppPath; /* Additional search path for strings (appended) */ /* * MCOffsetT - Union to handle both disk and runtime pointers */ typedef union { off_t off; char *str; void *ptr; struct _MCMsgT *msg; struct _MCSetT *set; } MCOffsetT; /* * MCMsgT - Message structure (disk and runtime) */ typedef struct _MCMsgT { long msgId; /* Id of this message */ MCOffsetT msg; /* Relative offset on disk or pointer in memory */ long invalid; /* Valid on disk, loaded in memory */ } MCMsgT; /* * MCSetT - Set structure (disk and runtime) */ typedef struct _MCSetT { long setId; /* Id of this set */ off_t nextSet; /* Offset of next set on disk */ union { off_t firstMsg; /* Offset to first Msg (while on disk) */ MCMsgT *msgs; /* Pointer to array of msgs (in mem, loaded) */ } u; MCOffsetT data; /* Offset to data, or pointer to data */ long dataLen; /* Length of data area on disk */ long numMsgs; /* Number of messages */ long invalid; /* Valid on disk, loaded in memory */ } MCSetT; /* * MCCatT - Runtime catalog pointer */ typedef struct { long loadType; /* How to load the messages (see MSLoadType) */ #ifdef HAVE_MMAP union { #endif int fd; /* File descriptor of catalog (if load-on-demand) */ #ifdef HAVE_MMAP caddr_t addr; /* Mmaped() address */ } u; off_t size; /* File size */ #endif long numSets; /* Number of sets */ MCSetT *sets; /* Pointer to the sets */ off_t firstSet; /* Offset of first set on disk */ } MCCatT; /* * MCHeaderT - Disk file header */ typedef struct { char magic[MCMagicLen]; /* Magic cookie "*nazgul*" */ long majorVer; /* ++ on incompatible changes */ long minorVer; /* ++ on compatible changes */ long flags; /* Informational flags */ long numSets; /* Number of valid Sets */ off_t firstSet; /* Offset of first set on disk */ } MCHeaderT; /* Some flags */ #define MC68KByteOrder 0x01 #define MCn86ByteOrder 0x02 #endif ./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/gencat.h100644 1676 334 6623 5461232665 13342 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 02/25/91 2 nazgul Added MCGetByteOrder 01/18/91 2 hamilton #if not reparsed 01/12/91 2 schulert conditionally use prototypes 11/03/90 1 hamilton Alphalpha->Alfalfa & OmegaMail->Poste 08/13/90 1 schulert move from ua to omu */ #ifndef gencat_h #define gencat_h /* * $set n comment * My extension: If the comment begins with # treat the next string * as a constant identifier. * $delset n comment * n goes from 1 to NL_SETMAX * Deletes a set from the MC * $ comment * My extension: If comment begins with # treat the next string as * a constant identifier for the next message. * m message-text * m goes from 1 to NL_MSGMAX * If message-text is empty, and a space or tab is present, put * empty string in catalog. * If message-text is empty, delete the message. * Length of text is 0 to NL_TEXTMAX * My extension: If '#' is used instead of a number, the number * is generated automatically. A # followed by anything is an empty message. * $quote c * Optional quote character which can suround message-text to * show where spaces are. * * Escape Characters * \n (newline), \t (horiz tab), \v (vert tab), \b (backspace), * \r (carriage return), \f (formfeed), \\ (backslash), \ddd (bitpattern * in octal). * Also, \ at end of line is a continuation. * */ #define MCLangC 0 #define MCLangCPlusPlus 1 #define MCLangANSIC 2 #define MAXTOKEN 1024 #if !defined(ANSI_C) && (defined(__STDC__) || defined(_AIX)) # define ANSI_C 1 #endif #if ANSI_C || defined(__cplusplus) # define P_(x) x #else # define P_(x) /**/ #endif extern void MCAddSet P_((int setId, char *c)); extern void MCDelSet P_((int setId)); extern void MCAddMsg P_((int msgId, char *msg, char *c)); extern void MCDelMsg P_((int msgId)); extern void MCParse P_((int fd)); extern void MCReadCat P_((int fd)); extern void MCWriteConst P_((int fd, int type, int orConsts)); extern void MCWriteCat P_((int fd)); extern long MCGetByteOrder P_((void)); #ifndef True # define True ~0 # define False 0 #endif #endif ./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/nls/nls_libc.h100644 1676 334 15733 5473470630 13707 0ustar hjlisl #define ErrorListSet 0x1 #define ErrorList0 0x1 #define ErrorList1 0x2 #define ErrorList2 0x3 #define ErrorList3 0x4 #define ErrorList4 0x5 #define ErrorList5 0x6 #define ErrorList6 0x7 #define ErrorList7 0x8 #define ErrorList8 0x9 #define ErrorList9 0xa #define ErrorList10 0xb #define ErrorList11 0xc #define ErrorList12 0xd #define ErrorList13 0xe #define ErrorList14 0xf #define ErrorList15 0x10 #define ErrorList16 0x11 #define ErrorList17 0x12 #define ErrorList18 0x13 #define ErrorList19 0x14 #define ErrorList20 0x15 #define ErrorList21 0x16 #define ErrorList22 0x17 #define ErrorList23 0x18 #define ErrorList24 0x19 #define ErrorList25 0x1a #define ErrorList26 0x1b #define ErrorList27 0x1c #define ErrorList28 0x1d #define ErrorList29 0x1e #define ErrorList30 0x1f #define ErrorList31 0x20 #define ErrorList32 0x21 #define ErrorList33 0x22 #define ErrorList34 0x23 #define ErrorList35 0x24 #define ErrorList36 0x25 #define ErrorList37 0x26 #define ErrorList38 0x27 #define ErrorList39 0x28 #define ErrorList40 0x29 #define ErrorList41 0x2a #define ErrorList42 0x2b #define ErrorList43 0x2c #define ErrorList44 0x2d #define ErrorList45 0x2e #define ErrorList46 0x2f #define ErrorList47 0x30 #define ErrorList48 0x31 #define ErrorList49 0x32 #define ErrorList50 0x33 #define ErrorList51 0x34 #define ErrorList52 0x35 #define ErrorList53 0x36 #define ErrorList54 0x37 #define ErrorList55 0x38 #define ErrorList56 0x39 #define ErrorList57 0x3a #define ErrorList58 0x3b #define ErrorList59 0x3c #define ErrorList60 0x3d #define ErrorList61 0x3e #define ErrorList62 0x3f #define ErrorList63 0x40 #define ErrorList64 0x41 #define ErrorList65 0x42 #define ErrorList66 0x43 #define ErrorList67 0x44 #define ErrorList68 0x45 #define ErrorList69 0x46 #define ErrorList70 0x47 #define ErrorList71 0x48 #define ErrorList72 0x49 #define ErrorList73 0x4a #define ErrorList74 0x4b #define ErrorList75 0x4c #define ErrorList76 0x4d #define ErrorList77 0x4e #define ErrorList78 0x4f #define ErrorList79 0x50 #define ErrorList80 0x51 #define ErrorList81 0x52 #define ErrorList82 0x53 #define ErrorList83 0x54 #define ErrorList84 0x55 #define ErrorList85 0x56 #define ErrorList86 0x57 #define ErrorList87 0x58 #define ErrorList88 0x59 #define ErrorList89 0x5a #define ErrorList90 0x5b #define ErrorList91 0x5c #define ErrorList92 0x5d #define ErrorList93 0x5e #define ErrorList94 0x5f #define ErrorList95 0x60 #define ErrorList96 0x61 #define ErrorList97 0x62 #define ErrorList98 0x63 #define ErrorList99 0x64 #define ErrorList100 0x65 #define ErrorList101 0x66 #define ErrorList102 0x67 #define ErrorList103 0x68 #define ErrorList104 0x69 #define ErrorList105 0x6a #define ErrorList106 0x6b #define ErrorList107 0x6c #define ErrorList108 0x6d #define ErrorList109 0x6e #define ErrorList110 0x6f #define ErrorList111 0x70 #define ErrorList112 0x71 #define ErrorList113 0x72 #define ErrorList114 0x73 #define ErrorList115 0x74 #define ErrorList116 0x75 #define ErrorList117 0x76 #define ErrorList118 0x77 #define ErrorList119 0x78 #define ErrorList120 0x79 #define ErrorList121 0x7a #define UnknownErrorSet 0x2 #define UnknownError1 0x1 #define UnknownError2 0x2 #define SignalListSet 0x3 #define SignalList0 0x1 #define SignalList1 0x2 #define SignalList2 0x3 #define SignalList3 0x4 #define SignalList4 0x5 #define SignalList5 0x6 #define SignalList6 0x7 #define SignalList7 0x8 #define SignalList8 0x9 #define SignalList9 0xa #define SignalList10 0xb #define SignalList11 0xc #define SignalList12 0xd #define SignalList13 0xe #define SignalList14 0xf #define SignalList15 0x10 #define SignalList16 0x11 #define SignalList17 0x12 #define SignalList18 0x13 #define SignalList19 0x14 #define SignalList20 0x15 #define SignalList21 0x16 #define SignalList22 0x17 #define SignalList23 0x18 #define SignalList24 0x19 #define SignalList25 0x1a #define SignalList26 0x1b #define SignalList27 0x1c #define SignalList28 0x1d #define SignalList29 0x1e #define SignalList30 0x1f #define SignalList31 0x20 #define UnknownSignalSet 0x4 #define UnknownSignal0 0x1 #define UnknownSignal1 0x2 #define HerrorListSet 0x5 #define HerrorList1 0x1 #define HerrorList2 0x2 #define HerrorList3 0x3 #define HerrorList4 0x4 #define HerrorList5 0x5 #define GetoptSet 0x6 #define GetoptAmbiguous 0x1 #define GetoptNoArgumentsAllowed1 0x2 #define GetoptNoArgumentsAllowed2 0x3 #define GetoptRequiresArgument1 0x4 #define GetoptRequiresArgument2 0x5 #define GetoptUnrecognized1 0x6 #define GetoptUnrecognized2 0x7 #define GetoptIllegal 0x8 #define AuthListSet 0x7 #define AuthList1 0x1 #define AuthList2 0x2 #define AuthList3 0x3 #define AuthList4 0x4 #define AuthList5 0x5 #define AuthList6 0x6 #define AuthList7 0x7 #define AuthList8 0x8 #define RpcErrListSet 0x8 #define RpcErrList1 0x1 #define RpcErrList2 0x2 #define RpcErrList3 0x3 #define RpcErrList4 0x4 #define RpcErrList5 0x5 #define RpcErrList6 0x6 #define RpcErrList7 0x7 #define RpcErrList8 0x8 #define RpcErrList9 0x9 #define RpcErrList10 0xa #define RpcErrList11 0xb #define RpcErrList12 0xc #define RpcErrList13 0xd #define RpcErrList14 0xe #define RpcErrList15 0xf #define RpcErrList16 0x10 #define RpcErrList17 0x11 #define RpcErrList18 0x12 #define RpcErrListUnknown 0x13 #define ClntMiscSet 0x9 #define ClntMiscErrno 0x1 #define ClntMiscLowHigh 0x2 #define ClntMiscWhy 0x3 #define ClntMiscUnknownAuth 0x4 #define RpcMiscSet 0xa #define RpcMiscOutOfMemory 0x1 #define RpcMiscCannotRegister 0x2 #define RpcMiscFatalMarshall 0x3 #define RpcMiscFatalHeader 0x4 #define RpcMiscHostname 0x5 #define RpcMiscSocket 0x6 #define RpcMiscIface 0x7 #define RpcMiscIoctl 0x8 #define RpcMiscGetmaps 0x9 #define RpcMiscBConfig 0xa #define RpcMiscBFlags 0xb #define RpcMiscCantCreateBSocket 0xc #define RpcMiscCantSetBOption 0xd #define RpcMiscCantSendBPacket 0xe #define RpcMiscBSelectProblem 0xf #define RpcMiscCantReceiveBReply 0x10 #define RpcMiscBDesProblem 0x11 #define RpcMiscBadAuthLen 0x12 #define RpcMiscSelectFailed 0x13 #define RpcMiscCantReassignProc 0x14 #define RpcMiscCantCreateServer 0x15 #define RpcMiscCantRegisterProg 0x16 #define RpcMiscTroubleReplying 0x17 #define RpcMiscNeverRegisteredProg 0x18 #define RpcMiscTcpSocketCreateProblem 0x19 #define RpcMiscCantGetNameListen 0x1a #define RpcMiscUdpSocketCreateProblem 0x1b #define RpcMiscUdpCantGetName 0x1c #define RpcMiscCacheAlreadyEnabled 0x1d #define RpcMiscCantAllocateCache 0x1e #define RpcMiscCantAllocateCacheData 0x1f #define RpcMiscCantAllocateCacheFifo 0x20 #define RpcMiscVictimNotFound 0x21 #define RpcMiscVictimAllocFailed 0x22 #define RpcMiscCantAllocateRpcBuffer 0x23 #define NetMiscSet 0xb #define NetMiscAllPortsInUse 0x1 #define NetMiscConnectTo 0x2 #define NetMiscTrying 0x3 #define NetMiscSettingUpStderr 0x4 #define NetMiscAccept 0x5 #define NetMiscGetsockname 0x6 #define NetMiscProtocolFailure 0x7 #define NetMiscRcmdSocket 0x8 #define NetMiscRexecSocket 0x9 #define NetMiscNetrcWrongPasswordMode 0xa #define NetMiscUnknownNetrcOption 0xb #define NetMiscResolvIncorrectFormat 0xc #define NetMiscResolvInvalid 0xd #define NetMiscResolvValid 0xe #define NetMiscUnrecognized 0xf #define NetMiscPossibleSpoof 0x10 ./libc-linux/nls/linux/ 40755 1676 334 0 5527717050 12762 5ustar hjlisl./libc-linux/nls/linux/English/ 40755 1676 334 0 5504466647 14363 5ustar hjlisl./libc-linux/nls/linux/English/errlist-u.m100644 1676 334 265 5473470623 16541 0ustar hjlisl$set 2 #UnknownError $ #1 Original Message:(Unknown error 000000000000000000000) # Unknown error 000000000000000000000 $ #2 Original Message:(Unknown error %d) # Unknown error %d ./libc-linux/nls/linux/English/errlist.m100644 1676 334 21670 5473470624 16343 0ustar hjlisl$set 1 #ErrorList $ #0 Original Message:(Unknown error) # Unknown error $ #1 Original Message:(Operation not permitted) # Operation not permitted $ #2 Original Message:(No such file or directory) # No such file or directory $ #3 Original Message:(No such process) # No such process $ #4 Original Message:(Interrupted system call) # Interrupted system call $ #5 Original Message:(I/O error) # I/O error $ #6 Original Message:(No such device or address) # No such device or address $ #7 Original Message:(Arg list too long) # Arg list too long $ #8 Original Message:(Exec format error) # Exec format error $ #9 Original Message:(Bad file number) # Bad file number $ #10 Original Message:(No child processes) # No child processes $ #11 Original Message:(Try again) # Try again $ #12 Original Message:(Out of memory) # Out of memory $ #13 Original Message:(Permission denied) # Permission denied $ #14 Original Message:(Bad address) # Bad address $ #15 Original Message:(Block device required) # Block device required $ #16 Original Message:(Device or resource busy) # Device or resource busy $ #17 Original Message:(File exists) # File exists $ #18 Original Message:(Cross-device link) # Cross-device link $ #19 Original Message:(No such device) # No such device $ #20 Original Message:(Not a directory) # Not a directory $ #21 Original Message:(Is a directory) # Is a directory $ #22 Original Message:(Invalid argument) # Invalid argument $ #23 Original Message:(File table overflow) # File table overflow $ #24 Original Message:(Too many open files) # Too many open files $ #25 Original Message:(Not a typewriter) # Not a typewriter $ #26 Original Message:(Text file busy) # Text file busy $ #27 Original Message:(File too large) # File too large $ #28 Original Message:(No space left on device) # No space left on device $ #29 Original Message:(Illegal seek) # Illegal seek $ #30 Original Message:(Read-only file system) # Read-only file system $ #31 Original Message:(Too many links) # Too many links $ #32 Original Message:(Broken pipe) # Broken pipe $ #33 Original Message:(Math argument out of domain of func) # Math argument out of domain of func $ #34 Original Message:(Math result not representable) # Math result not representable $ #35 Original Message:(Resource deadlock would occur) # Resource deadlock would occur $ #36 Original Message:(File name too long) # File name too long $ #37 Original Message:(No record locks available) # No record locks available $ #38 Original Message:(Function not implemented) # Function not implemented $ #39 Original Message:(Directory not empty) # Directory not empty $ #40 Original Message:(Too many symbolic links encountered) # Too many symbolic links encountered $ #41 Original Message:(Operation would block) # Operation would block $ #42 Original Message:(No message of desired type) # No message of desired type $ #43 Original Message:(Identifier removed) # Identifier removed $ #44 Original Message:(Channel number out of range) # Channel number out of range $ #45 Original Message:(Level 2 not synchronized) # Level 2 not synchronized $ #46 Original Message:(Level 3 halted) # Level 3 halted $ #47 Original Message:(Level 3 reset) # Level 3 reset $ #48 Original Message:(Link number out of range) # Link number out of range $ #49 Original Message:(Protocol driver not attached) # Protocol driver not attached $ #50 Original Message:(No CSI structure available) # No CSI structure available $ #51 Original Message:(Level 2 halted) # Level 2 halted $ #52 Original Message:(Invalid exchange) # Invalid exchange $ #53 Original Message:(Invalid request descriptor) # Invalid request descriptor $ #54 Original Message:(Exchange full) # Exchange full $ #55 Original Message:(No anode) # No anode $ #56 Original Message:(Invalid request code) # Invalid request code $ #57 Original Message:(Invalid slot) # Invalid slot $ #58 Original Message:(File locking deadlock error) # File locking deadlock error $ #59 Original Message:(Bad font file format) # Bad font file format $ #60 Original Message:(Device not a stream) # Device not a stream $ #61 Original Message:(No data available) # No data available $ #62 Original Message:(Timer expired) # Timer expired $ #63 Original Message:(Out of streams resources) # Out of streams resources $ #64 Original Message:(Machine is not on the network) # Machine is not on the network $ #65 Original Message:(Package not installed) # Package not installed $ #66 Original Message:(Object is remote) # Object is remote $ #67 Original Message:(Link has been severed) # Link has been severed $ #68 Original Message:(Advertise error) # Advertise error $ #69 Original Message:(Srmount error) # Srmount error $ #70 Original Message:(Communication error on send) # Communication error on send $ #71 Original Message:(Protocol error) # Protocol error $ #72 Original Message:(Multihop attempted) # Multihop attempted $ #73 Original Message:(RFS specific error) # RFS specific error $ #74 Original Message:(Not a data message) # Not a data message $ #75 Original Message:(Value too large for defined data type) # Value too large for defined data type $ #76 Original Message:(Name not unique on network) # Name not unique on network $ #77 Original Message:(File descriptor in bad state) # File descriptor in bad state $ #78 Original Message:(Remote address changed) # Remote address changed $ #79 Original Message:(Can not access a needed shared library) # Can not access a needed shared library $ #80 Original Message:(Accessing a corrupted shared library) # Accessing a corrupted shared library $ #81 Original Message:(.lib section in a.out corrupted) # .lib section in a.out corrupted $ #82 Original Message:(Attempting to link in too many shared libraries) # Attempting to link in too many shared libraries $ #83 Original Message:(Cannot exec a shared library directly) # Cannot exec a shared library directly $ #84 Original Message:(Illegal byte sequence) # Illegal byte sequence $ #85 Original Message:(Interrupted system call should be restarted) # Interrupted system call should be restarted $ #86 Original Message:(Streams pipe error) # Streams pipe error $ #87 Original Message:(Too many users) # Too many users $ #88 Original Message:(Socket operation on non-socket) # Socket operation on non-socket $ #89 Original Message:(Destination address required) # Destination address required $ #90 Original Message:(Message too long) # Message too long $ #91 Original Message:(Protocol wrong type for socket) # Protocol wrong type for socket $ #92 Original Message:(Protocol not available) # Protocol not available $ #93 Original Message:(Protocol not supported) # Protocol not supported $ #94 Original Message:(Socket type not supported) # Socket type not supported $ #95 Original Message:(Operation not supported on transport endpoint) # Operation not supported on transport endpoint $ #96 Original Message:(Protocol family not supported) # Protocol family not supported $ #97 Original Message:(Address family not supported by protocol) # Address family not supported by protocol $ #98 Original Message:(Address already in use) # Address already in use $ #99 Original Message:(Cannot assign requested address) # Cannot assign requested address $ #100 Original Message:(Network is down) # Network is down $ #101 Original Message:(Network is unreachable) # Network is unreachable $ #102 Original Message:(Network dropped connection because of reset) # Network dropped connection because of reset $ #103 Original Message:(Software caused connection abort) # Software caused connection abort $ #104 Original Message:(Connection reset by peer) # Connection reset by peer $ #105 Original Message:(No buffer space available) # No buffer space available $ #106 Original Message:(Transport endpoint is already connected) # Transport endpoint is already connected $ #107 Original Message:(Transport endpoint is not connected) # Transport endpoint is not connected $ #108 Original Message:(Cannot send after transport endpoint shutdown) # Cannot send after transport endpoint shutdown $ #109 Original Message:(Too many references: cannot splice) # Too many references: cannot splice $ #110 Original Message:(Connection timed out) # Connection timed out $ #111 Original Message:(Connection refused) # Connection refused $ #112 Original Message:(Host is down) # Host is down $ #113 Original Message:(No route to host) # No route to host $ #114 Original Message:(Operation already in progress) # Operation already in progress $ #115 Original Message:(Operation now in progress) # Operation now in progress $ #116 Original Message:(Stale NFS file handle) # Stale NFS file handle $ #117 Original Message:(Structure needs cleaning) # Structure needs cleaning $ #118 Original Message:(Not a XENIX named type file) # Not a XENIX named type file $ #119 Original Message:(No XENIX semaphores available) # No XENIX semaphores available $ #120 Original Message:(Is a named type file) # Is a named type file $ #121 Original Message:(Remote I/O error) # Remote I/O error ./libc-linux/nls/linux/English/getopt.m100644 1676 334 1637 5473470624 16142 0ustar hjlisl$set 6 #Getopt $ #Ambiguous Original Message:(%s: option `%s' is ambiguous\n) # %s: option `%s' is ambiguous\n $ #NoArgumentsAllowed1 Original Message:(%s: option `--%s' doesn't allow an argument\n) # %s: option `--%s' doesn't allow an argument\n $ #NoArgumentsAllowed2 Original Message:(%s: option `%c%s' doesn't allow an argument\n) # %s: option `%c%s' doesn't allow an argument\n $ #RequiresArgument1 Original Message:(%s: option `%s' requires an argument\n) # %s: option `%s' requires an argument\n $ #RequiresArgument2 Original Message:(%s: option requires an argument -- %c\n) # %s: option requires an argument -- %c\n $ #Unrecognized1 Original Message:(%s: unrecognized option `--%s'\n) # %s: unrecognized option `--%s'\n $ #Unrecognized2 Original Message:(%s: unrecognized option `%c%s'\n) # %s: unrecognized option `%c%s'\n $ #Illegal Original Message:(%s: illegal option -- %c\n) # %s: illegal option -- %c\n ./libc-linux/nls/linux/English/h-errlist.m100644 1676 334 541 5473470625 16523 0ustar hjlisl$set 5 #HerrorList $ #1 Original Message:(Error 0) # Error 0 $ #2 Original Message:(Unknown host) # Unknown host $ #3 Original Message:(Host name lookup failure) # Host name lookup failure $ #4 Original Message:(Unknown server error) # Unknown server error $ #5 Original Message:(No address associated with name) # No address associated with name ./libc-linux/nls/linux/English/siglist-u.m100644 1676 334 264 5473470627 16536 0ustar hjlisl$set 4 #UnknownSignal $ #0 Original Message:(Unknown signal 000000000000000000) # Unknown signal 000000000000000000 $ #1 Original Message:(Unknown signal %d) # Unknown signal %d ./libc-linux/nls/linux/English/siglist.m100644 1676 334 3556 5473470627 16323 0ustar hjlisl$set 3 #SignalList $ #0 Original Message:(Unknown signal) # Unknown signal $ #1 Original Message:(Hangup) # Hangup $ #2 Original Message:(Interrupt) # Interrupt $ #3 Original Message:(Quit) # Quit $ #4 Original Message:(Illegal instruction) # Illegal instruction $ #5 Original Message:(Trace/breakpoint trap) # Trace/breakpoint trap $ #6 Original Message:(IOT trap/Abort) # IOT trap/Abort $ #7 Original Message:(Unused signal) # Unused signal $ #8 Original Message:(Floating point exception) # Floating point exception $ #9 Original Message:(Killed) # Killed $ #10 Original Message:(User defined signal 1) # User defined signal 1 $ #11 Original Message:(Segmentation fault) # Segmentation fault $ #12 Original Message:(User defined signal 2) # User defined signal 2 $ #13 Original Message:(Broken pipe) # Broken pipe $ #14 Original Message:(Alarm clock) # Alarm clock $ #15 Original Message:(Terminated) # Terminated $ #16 Original Message:(Stack fault) # Stack fault $ #17 Original Message:(Child exited) # Child exited $ #18 Original Message:(Continued) # Continued $ #19 Original Message:(Stopped (signal)) # Stopped (signal) $ #20 Original Message:(Stopped) # Stopped $ #21 Original Message:(Stopped (tty input)) # Stopped (tty input) $ #22 Original Message:(Stopped (tty output)) # Stopped (tty output) $ #23 Original Message:(Possible I/O) # Possible I/O $ #24 Original Message:(CPU time limit exceeded) # CPU time limit exceeded $ #25 Original Message:(File size limit exceeded) # File size limit exceeded $ #26 Original Message:(Virtual time alarm) # Virtual time alarm $ #27 Original Message:(Profile signal) # Profile signal $ #28 Original Message:(Window size changed) # Window size changed $ #29 Original Message:(File lock lost) # File lock lost $ #30 Original Message:(Unused signal) # Unused signal $ #31 Original Message:(Unused signal) # Unused signal ./libc-linux/nls/linux/English/auth.m100644 1676 334 1165 5473470622 15573 0ustar hjlisl$set 7 #AuthList $ #1 Original Message:(Authentication OK) # Authentication OK $ #2 Original Message:(Invalid client credential) # Invalid client credential $ #3 Original Message:(Server rejected credential) # Server rejected credential $ #4 Original Message:(Invalid client verifier) # Invalid client verifier $ #5 Original Message:(Server rejected verifier) # Server rejected verifier $ #6 Original Message:(Client credential too weak) # Client credential too weak $ #7 Original Message:(Invalid server verifier) # Invalid server verifier $ #8 Original Message:(Failed (unspecified error)) # Failed (unspecified error) ./libc-linux/nls/linux/English/clnt-misc.m100644 1676 334 530 5473470623 16477 0ustar hjlisl$set 9 #ClntMisc $ #Errno Original Message:(; errno = %s) # ; errno = %s $ #LowHigh Original Message:(; low version = %lu, high version = %lu) # ; low version = %lu, high version = %lu) $ #Why Original Message:(; why = ) # ; why = $ #UnknownAuth Original Message:((unknown authentication error - %d)) # (unknown authentication error - %d) ./libc-linux/nls/linux/English/net-misc.m100644 1676 334 3303 5473470625 16350 0ustar hjlisl$set 11 #NetMisc $ #AllPortsInUse Original Message:(All ports in use) # All ports in use $ #ConnectTo Original Message:(connect to address) # connect to address $ #Trying Original Message:(Trying %s...\n) # Trying %s...\n $ #SettingUpStderr Original Message:(write: setting up stderr) # write: setting up stderr $ #Accept Original Message:(accept) # accept $ #Getsockname Original Message:(getsockname) # getsockname $ #ProtocolFailure Original Message:(socket: protocol failure in circuit setup.) # socket: protocol failure in circuit setup. $ #RcmdSocket Original Message:(rcmd: socket) # rcmd: socket $ #RexecSocket Original Message:(rexec: socket) # rexec: socket $ #NetrcWrongPasswordMode Original Message:(Error - .netrc file not correct mode.\nRemove password or correct mode.) # Error - .netrc file not correct mode.\nRemove password or correct mode. $ #UnknownNetrcOption Original Message:(Unknown .netrc option) # Unknown .netrc option $ #ResolvIncorrectFormat Original Message:(resolv+: %s: \"%s\" command incorrectly formatted.\n) # X-resolv+: %s: "%s" command incorrectly formatted.\n $ #ResolvInvalid Original Message:(resolv+: \"%s\" is an invalid keyword\n) # X-resolv+: "%s" is an invalid keyword\n $ #ResolvValid Original Message:(resolv+: valid keywords are: %s, %s and %s\n) # X-resolv+: valid keywords are: %s, %s and %s\n $ #Unrecognized Original Message:(resolv+: search order not specified or unrecognized keyword, host resolution will fail.\n) # X-resolv+: search order not specified or unrecognized keyword, host resolution will fail.\n $ #PossibleSpoof Original Message:(gethostbyaddr: %s != %u.%u.%u.%u, possible spoof attempt) # gethostbyaddr: %s != %u.%u.%u.%u, possible spoof attempt ./libc-linux/nls/linux/English/rpc-errlist.m100644 1676 334 2735 5473470626 17110 0ustar hjlisl$set 8 #RpcErrList $ #1 Original Message:(RPC: Success) # RPC: Success $ #2 Original Message:(RPC: Can't encode arguments) # RPC: Can't encode arguments $ #3 Original Message:(RPC: Can't decode result) # RPC: Can't decode result $ #4 Original Message:(RPC: Unable to send) # RPC: Unable to send $ #5 Original Message:(RPC: Unable to receive) # RPC: Unable to receive $ #6 Original Message:(RPC: Timed out) # RPC: Timed out $ #7 Original Message:(RPC: Incompatible versions of RPC) # RPC: Incompatible versions of RPC $ #8 Original Message:(RPC: Authentication error) # RPC: Authentication error $ #9 Original Message:(RPC: Program unavailable) # RPC: Program unavailable $ #10 Original Message:(RPC: Program/version mismatch) # RPC: Program/version mismatch $ #11 Original Message:(RPC: Procedure unavailable) # RPC: Procedure unavailable $ #12 Original Message:(RPC: Server can't decode arguments) # RPC: Server can't decode arguments $ #13 Original Message:(RPC: Remote system error) # RPC: Remote system error $ #14 Original Message:(RPC: Unknown host) # RPC: Unknown host $ #15 Original Message:(RPC: Port mapper failure) # RPC: Port mapper failure $ #16 Original Message:(RPC: Program not registered) # RPC: Program not registered $ #17 Original Message:(RPC: Failed (unspecified error)) # RPC: Failed (unspecified error) $ #18 Original Message:(RPC: Unknown protocol) # RPC: Unknown protocol $ #Unknown Original Message:(RPC: (unknown error code)) # RPC: (unknown error code) ./libc-linux/nls/linux/English/rpc-misc.m100644 1676 334 7345 5473470626 16361 0ustar hjlisl$set 10 #RpcMisc $ #OutOfMemory Original Message:(out of memory) # out of memory $ #CannotRegister Original Message:(Cannot register service) # Cannot register service $ #FatalMarshall Original Message:(auth_none.c - Fatal marshalling problem) # auth_none.c - Fatal marshalling problem $ #FatalHeader Original Message:(clnt_raw.c - Fatal header serialization error.) # clnt_raw.c - Fatal header serialization error. $ #Hostname Original Message:(get_myaddress: gethostbyname) # get_myaddress: gethostbyname $ #Socket Original Message:(get_myaddress: socket) # get_myaddress: socket $ #Iface Original Message:(get_myaddress: ioctl (get interface configuration)) # get_myaddress: ioctl (get interface configuration) $ #Ioctl Original Message:(get_myaddress: ioctl) # get_myaddress: ioctl $ #Getmaps Original Message:(pmap_getmaps rpc problem) # pmap_getmaps rpc problem $ #BConfig Original Message:(broadcast: ioctl (get interface configuration)) # broadcast: ioctl (get interface configuration) $ #BFlags Original Message:(broadcast: ioctl (get interface flags)) # broadcast: ioctl (get interface flags) $ #CantCreateBSocket Original Message:(Cannot create socket for broadcast rpc) # Cannot create socket for broadcast rpc $ #CantSetBOption Original Message:(Cannot set socket option SO_BROADCAST) # Cannot set socket option SO_BROADCAST $ #CantSendBPacket Original Message:(Cannot send broadcast packet) # Cannot send broadcast packet $ #BSelectProblem Original Message:(Broadcast select problem) # Broadcast select problem $ #CantReceiveBReply Original Message:(Cannot receive reply to broadcast) # Cannot receive reply to broadcast $ #BDesProblem Original Message:(Broadcast deserialization problem) # Broadcast deserialization problem $ #BadAuthLen Original Message:(bad auth_len gid %d str %d auth %d\n) # bad auth_len gid %d str %d auth %d\n $ #SelectFailed Original Message:(svc_run: - select failed) # svc_run: - select failed $ #CantReassignProc Original Message:(can't reassign procedure number %d\n) # can't reassign procedure number %d\n $ #CantCreateServer Original Message:(couldn't create an rpc server) # couldn't create an rpc server $ #CantRegisterProg Original Message:(couldn't register prog %d vers %d\n) # couldn't register prog %d vers %d\n $ #TroubleReplying Original Message:(trouble replying to prog %d\n) # trouble replying to prog %d\n $ #NeverRegisteredProg Original Message:(never registered prog %d\n) # never registered prog %d\n $ #TcpSocketCreateProblem Original Message:(svc_tcp.c - tcp socket creation problem) # svc_tcp.c - tcp socket creation problem $ #CantGetNameListen Original Message:(svctcp_.c - cannot getsockname or listen) # svctcp_.c - cannot getsockname or listen $ #UdpSocketCreateProblem Original Message:(svcudp_create: socket creation problem) # svcudp_create: socket creation problem $ #UdpCantGetName Original Message:(svcudp_create - cannot getsockname) # svcudp_create - cannot getsockname $ #CacheAlreadyEnabled Original Message:(enablecache: cache already enabled) # enablecache: cache already enabled $ #CantAllocateCache Original Message:(enablecache: could not allocate cache) # enablecache: could not allocate cache $ #CantAllocateCacheData Original Message:(enablecache: could not allocate cache data) # enablecache: could not allocate cache data $ #CantAllocateCacheFifo Original Message:(enablecache: could not allocate cache fifo) # enablecache: could not allocate cache fifo $ #VictimNotFound Original Message:(cache_set: victim not found) # cache_set: victim not found $ #VictimAllocFailed Original Message:(cache_set: victim alloc failed) # cache_set: victim alloc failed $ #CantAllocateRpcBuffer Original Message:(cache_set: could not allocate new rpc_buffer) # cache_set: could not allocate new rpc_buffer ./libc-linux/nls/linux/German/ 40755 1676 334 0 5504466647 14203 5ustar hjlisl./libc-linux/nls/linux/German/errors-german100644 1676 334 52121 5462526702 17017 0ustar hjlisl/* Hilfsprogramm zum Erstellen der Fehlermeldungs-Tabelle ERRORS.C für CLISP unter UNIX. Bruno Haible 24.3.1993 Problem: viele verschiedene UNIX-Versionen, jede wieder mit anderen Fehlermeldungen. Abhilfe: Die Fehlernamen sind einigermaßen portabel. Die englische Fehlermeldung übernehmen wir, die Übersetzungen machen wir selbst. */ #if defined(__TURBOC__) || defined(__GO32__) #define STDC_HEADERS 1 #else #if defined(unix) || defined(__unix) || defined(vms) #include "unixconf.h" #if defined(sun) && (defined(sun386) || defined(sparc)) && defined(HAVE_VADVISE) #define UNIX_SUNOS4 /* SUN OS Version 4 */ #endif #if defined(SIGNALBLOCK_BSD) #define UNIX_BSD #endif #endif #endif #ifdef STDC_HEADERS #include /* definiert MALLOC(3V) */ #endif #include /* definiert PRINTF(3) */ /* Tabelle der System-Fehlermeldungen, siehe PERROR(3) */ #include #ifdef vms #include #else extern int sys_nerr; /* Anzahl der Betriebssystem-Fehlermeldungen */ extern char* sys_errlist[]; /* Betriebssystem-Fehlermeldungen */ #endif typedef struct { char* name; /* Name des Errors */ char* english; /* Fehlermeldung auf ENGLISH */ char* deutsch; /* Fehlermeldung auf DEUTSCH */ } error; int main () { int anzahl = sys_nerr; /* Gesamtzahl von Fehlermeldungen */ error* tabelle = (error*)malloc(anzahl*sizeof(error)); /* Tabelle von anzahl Meldungen */ int i; /* Tabelle vor-initialisieren: */ for (i=0; i=36 nicht. */ tabelle[i].english = ""; #endif tabelle[i].deutsch = ""; } /* Übersetzungen der Meldungen eintragen: */ for (i=0; i Check/$$i ;\ done ../gencat -new libc.cat $(ENG-SRCS:%=Check/%) xtract: xtract.c xtract.c: xtract.l $(LEX) $< mv lex.yy.c $@ install: libc.cat install -m a+xr -d $(INSTDIR) install -m a+r libc.cat $(INSTDIR) ./libc-linux/nls/linux/README.editing100644 1676 334 5132 5474772642 15373 0ustar hjlislMessage cataloging in the C library has some difficulties but may be overcome by forcing ordering in the message files. In general the message files (.m) are position independent as long as the keywords are unique when the sources are compiled. However static structures or arrays of error messages, (sys_errlist[] and sys_siglist[] are just a few that pop to mind), pose difficulties as the message are not available until execution and then only numerically (errnum or signum). Therefore these message files should NOT be re-ordered. If you do not have translation for the corresponding messages in the .m files the please leave them alone. Any of the message catalogs may be left out. See the `German' directory and the `Makefile' for "make german". I was only given the standard `errlist'. The message catalog retrival routines will return the default english message if the corresponding translated message cannot be found. Lets look at the format of the message file and what you need to edit. Example: English/h-error.m $set 5 #HerrorList $ #1 Original Message:(Unknown host) # Unknown host $ #2 Original Message:(Host name lookup failure) # Host name lookup failure , , , , , , , , , First: Anything with a $ at the begining of the line should not be touched. Ok. Now the first line: (DO NOT EDIT) The `set' word must exist in all message files. The second field number MUST be unique per application. The third field (minus the #) is prepended to all messages id's and +----> the word "Set" is appended to this to identify the set as a #define | instead. Obviously it can be accessed via the number in the second | field if you prefer. | | The second line: (DO NOT EDIT) | Don't touch the $. | The second field is the unique id for this message and is concatenated | with the third field of the `set' line above. So the #define in this | case becomes `HerrorList1'. You may access this message in your program | with the following. | | +------------------------+ | | +-----------------------------------------+ | | | catgets(catalog_fd, HerrorListSet, HerrorList1, "my message") The third and subsequent fields are ignored and is put there for your reference only. It is not included in the compiled catalog. The third line: (EDIT ME) Edit this line to your own language. DO NOT REMOVE THE hash (#) at the begining of the line. Subseuqent lines as just the same as the latter two above. Any problems ?? Contact me. Mitch (m.dsouza@mrc-apu.cam.ac.uk) ./libc-linux/nls/linux/NOTES100644 1676 334 2076 5474777121 13705 0ustar hjlislEnglish speakers need do nothing !! Do NOT install the catalog "libc.cat" unless you want change the text to be more explanatory/informative. If you just wanna see the libc cataloging in action just do a "make check" in this directory and then a make install will install the catalog. From now on all libc internal messages will be prepended with a X- (for example "X-Permission denied") If you are translating messages please read the README.editing and README.translate files. I wrote a small awk (well GNU's gawk actually) script to extract strings from source files to make them message files. Try: ./extract ../../sysdeps/linux/_errlist.c Not very clever, but it works. Gawk-2.15.3 broke this awk script so you must use the flex binary `xtract' instead. Just type "make xtract" and use this instead of `extract' in the example above. As of 24th Oct 1993 I only have German errlist messages. If you find a bug or feel a libc message might have been forgotten to be catalog'ed (very possible) then please don't hesitate to contact me. Thanx Mitch. ./libc-linux/nls/linux/TODO100644 1676 334 107 5462564137 13531 0ustar hjlislNeed to complete the catalog'ing in: libc-linux/inet libc-linux/rpc ./libc-linux/nls/linux/extract100755 1676 334 1236 5474773130 14463 0ustar hjlisl#!/bin/sh # Take a list of one line messages and output format for # message file. Use only for static structures because # position depencency is required. Otherwise make message # id's more informative for use (i.e. hand edit) # I used this for _errlist.c, _siglist.c. - Mitch # Its not as clever as I'd like it to be :-( # NOTE: Gawk-2.15.3 broke the RLENGTH return from match(). # So please use the lex version of this called `xtract'. Just type # % make xtract # in this directory. gawk '(/\".*\"/) && ($1 !~ /#/) { \ match($0,/\".*\"/); str = substr($0,RSTART+1,RLENGTH-2); \ if (str) printf("$ #%d Original Message:(%s)\n# %s\n",x++,str,str)}' "$*" ./libc-linux/nls/linux/xtract.l100644 1676 334 406 5474773736 14537 0ustar hjlisl%{ #include #include int x=0; char str[1024]; %} %% ^# \".*\" { if (yyleng >2) { strcpy(str,yytext+1); str[yyleng-2]='\0'; printf("$ #%d Original Message:(%s)\n",x++,str); printf("# %s\n\n",str); } } .|\n %% main() {yylex();} ./libc-linux/nls/linux/French/ 40755 1676 334 0 5532204345 14161 5ustar hjlisl./libc-linux/nls/linux/French/LISEZMOI100644 1676 334 23767 5527716662 15511 0ustar hjlislSalut! Un peu de français dans un monde de brutes! Ce répertoire contient des fichiers NLS pour des messages en français. Voyez ../README* pour plus d'information. Les messages contiennent des accents. Pour voir la table des codes ascii, vous pouvez éxécuter ce programme: (stupide, mais il marche!) main() { int i; for (i=32; i < 256; i++) printf("0x%x '%c'\n", i, i); } Pour tapez les lettres accentuées avec votre clavier (c'est ce que je fais en ce moment: éèàçôù), utilisez le fichier fr.map suivant: keycode 0 = keycode 1 = Escape Escape alt keycode 1 = Meta_Escape keycode 2 = ampersand one alt keycode 2 = Meta_one keycode 3 = 0xe9 two asciitilde control keycode 3 = nul alt keycode 3 = Meta_two keycode 4 = quotedbl three numbersign control keycode 4 = Escape alt keycode 4 = Meta_three keycode 5 = apostrophe four braceleft control keycode 5 = Control_backslash alt keycode 5 = Meta_four keycode 6 = parenleft five bracketleft control keycode 6 = Control_bracketright alt keycode 6 = Meta_five keycode 7 = minus six bar control keycode 7 = Control_asciicircum alt keycode 7 = Meta_six keycode 8 = 0xe8 seven grave control keycode 8 = Control_underscore alt keycode 8 = Meta_seven keycode 9 = underscore eight backslash control keycode 9 = Delete alt keycode 9 = Meta_eight keycode 10 = 0xe7 nine asciicircum alt keycode 10 = Meta_nine keycode 11 = 0xe0 zero at alt keycode 11 = Meta_zero keycode 12 = parenright bracketright bracketright control keycode 12 = Control_underscore alt keycode 12 = Meta_minus keycode 13 = equal plus braceright alt keycode 13 = Meta_equal keycode 14 = Delete Delete alt keycode 14 = Meta_Delete keycode 15 = Tab Tab alt keycode 15 = Meta_Tab keycode 16 = a keycode 17 = z keycode 18 = e keycode 19 = r keycode 20 = t keycode 21 = y keycode 22 = u keycode 23 = i keycode 24 = o keycode 25 = p keycode 26 = asciicircum less control keycode 26 = Escape alt keycode 26 = Meta_bracketleft keycode 27 = dollar 0xa3 0xf4 control keycode 27 = Control_bracketright alt keycode 27 = Meta_bracketright keycode 28 = Return alt keycode 28 = 0x080d keycode 29 = Control keycode 30 = q keycode 31 = s keycode 32 = d keycode 33 = f keycode 34 = g keycode 35 = h keycode 36 = j keycode 37 = k keycode 38 = l keycode 39 = m M alt keycode 39 = Meta_semicolon keycode 40 = 0xf9 percent control keycode 40 = Control_g alt keycode 40 = Meta_apostrophe keycode 41 = asterisk 0xb5 control keycode 41 = nul alt keycode 41 = Meta_grave keycode 42 = Shift keycode 43 = asterisk numbersign control keycode 43 = Control_backslash alt keycode 43 = Meta_backslash keycode 44 = w keycode 45 = x keycode 46 = c keycode 47 = v keycode 48 = b keycode 49 = n keycode 50 = comma question keycode 51 = semicolon period alt keycode 51 = Meta_comma keycode 52 = colon slash alt keycode 52 = Meta_period keycode 53 = exclam 0xa7 control keycode 53 = Delete alt keycode 53 = Meta_slash keycode 54 = Shift keycode 55 = KP_Multiply keycode 56 = Alt keycode 57 = space space control keycode 57 = nul alt keycode 57 = Meta_space keycode 58 = Caps_Lock keycode 59 = F1 F11 Console_13 control keycode 59 = F1 alt keycode 59 = Console_1 keycode 60 = F2 F12 Console_14 control keycode 60 = F2 alt keycode 60 = Console_2 keycode 61 = F3 F13 Console_15 control keycode 61 = F3 alt keycode 61 = Console_3 keycode 62 = F4 F14 Console_16 control keycode 62 = F4 alt keycode 62 = Console_4 keycode 63 = F5 F15 Console_17 control keycode 63 = F5 alt keycode 63 = Console_5 keycode 64 = F6 F16 Console_18 control keycode 64 = F6 alt keycode 64 = Console_6 keycode 65 = F7 F17 Console_19 control keycode 65 = F7 alt keycode 65 = Console_7 keycode 66 = F8 F18 Console_20 control keycode 66 = F8 alt keycode 66 = Console_8 keycode 67 = F9 F19 Console_21 control keycode 67 = F9 alt keycode 67 = Console_9 keycode 68 = F10 F20 Console_22 control keycode 68 = F10 alt keycode 68 = Console_10 keycode 69 = Num_Lock keycode 70 = Scroll_Lock Show_Memory Show_Registers control keycode 70 = Show_State alt keycode 70 = Scroll_Lock keycode 71 = KP_7 alt keycode 71 = Ascii_7 keycode 72 = KP_8 alt keycode 72 = Ascii_8 keycode 73 = KP_9 alt keycode 73 = Ascii_9 keycode 74 = KP_Subtract keycode 75 = KP_4 alt keycode 75 = Ascii_4 keycode 76 = KP_5 alt keycode 76 = Ascii_5 keycode 77 = KP_6 alt keycode 77 = Ascii_6 keycode 78 = KP_Add keycode 79 = KP_1 alt keycode 79 = Ascii_1 keycode 80 = KP_2 alt keycode 80 = Ascii_2 keycode 81 = KP_3 alt keycode 81 = Ascii_3 keycode 82 = KP_0 alt keycode 82 = Ascii_0 keycode 83 = KP_Period altgr control keycode 83 = Boot control alt keycode 83 = Boot keycode 84 = Last_Console keycode 85 = keycode 86 = less greater bar alt keycode 86 = Meta_less keycode 87 = F11 F11 Console_23 control keycode 87 = F11 alt keycode 87 = Console_11 keycode 88 = F12 F12 Console_24 control keycode 88 = F12 alt keycode 88 = Console_12 keycode 89 = keycode 90 = keycode 91 = keycode 92 = keycode 93 = keycode 94 = keycode 95 = keycode 96 = KP_Enter keycode 97 = Control keycode 98 = KP_Divide keycode 99 = Control_backslash control keycode 99 = Control_backslash alt keycode 99 = Control_backslash keycode 100 = AltGr keycode 101 = Break keycode 102 = Find keycode 103 = Up keycode 104 = Prior shift keycode 104 = Scroll_Backward keycode 105 = Left keycode 106 = Right keycode 107 = Select keycode 108 = Down keycode 109 = Next shift keycode 109 = Scroll_Forward keycode 110 = Insert keycode 111 = Remove altgr control keycode 111 = Boot control alt keycode 111 = Boot keycode 112 = keycode 113 = keycode 114 = keycode 115 = keycode 116 = keycode 117 = keycode 118 = keycode 119 = keycode 120 = keycode 121 = keycode 122 = keycode 123 = keycode 124 = keycode 125 = keycode 126 = keycode 127 = string F1 = "\033[[A" string F2 = "\033[[B" string F3 = "\033[[C" string F4 = "\033[[D" string F5 = "\033[[E" string F6 = "\033[17~" string F7 = "\033[18~" string F8 = "\033[19~" string F9 = "\033[20~" string F10 = "\033[21~" string F11 = "\033[23~" string F12 = "\033[24~" string F13 = "\033[25~" string F14 = "\033[26~" string F15 = "\033[28~" string F16 = "\033[29~" string F17 = "\033[31~" string F18 = "\033[32~" string F19 = "\033[33~" string F20 = "\033[34~" string Find = "\033[1~" string Insert = "\033[2~" string Remove = "\033[3~" string Select = "\033[4~" string Prior = "\033[5~" string Next = "\033[6~" string F21 = "" string F22 = "" string F23 = "" string F24 = "" string F25 = "" string F26 = "" ##################### FIN de fr.map ################################## Et chargez le avec loadkeys fr.map. (à inclure dans un /etc/rc.xxx) Les touches accentuées marchent. Pour obtenir ô, tapez Alt-Gr $. Attention, les majuscules ne sont pas disponibles (Pas génants pour les accents, mais pour le ç ...) Pour la traduction, j'ai fait comme j'ai pu. Si vous trouvez des fautes, corrigez-les; si des messages sont mal traduits (par exemple, les messages concernant les sockets, NFS, ou les réseaux, inconnus par moi), corrigez-les. Et surtout, faites des version en français ou utilisez NLS. Au fait, si vous utiliez 'joe' (un bon éditeur de textes, tapez ^TH pour voir les accents. Lors de la traduction, j'ai gardé quelques anglicismes: * les noms des appels systèmes, des procédures ... * mais quelques traductions: pipe : tuyau Bonne chance. -Tristan. (Chez marc@david.saclay.cea.fr) ./libc-linux/nls/linux/French/auth.m100644 1676 334 1274 5527716662 15417 0ustar hjlisl$set 7 #AuthList $ #1 Original Message:(Authentication OK) # Authentication réussie $ #2 Original Message:(Invalid client credential) # L'identité du client est inconnue $ #3 Original Message:(Server rejected credential) # Le serveur a rejeté l'identité $ #4 Original Message:(Invalid client verifier) # Le vérificateur du client est invalide $ #5 Original Message:(Server rejected verifier) # Le serveur a rejeté le vérificateur $ #6 Original Message:(Client credential too weak) # L'identité du client est trop faible $ #7 Original Message:(Invalid server verifier) # Le vérificateur du serveur est invalide $ #8 Original Message:(Failed (unspecified error)) # Echec (erreur non spécifiée) ./libc-linux/nls/linux/French/errlist.m100644 1676 334 23265 5532204324 16145 0ustar hjlisl$set 1 #ErrorList $ #0 Original Message:(Unknown error) # Erreur inconnue $ #1 Original Message:(Operation not permitted) # Opération non autorisée $ #2 Original Message:(No such file or directory) # Fichier ou répertoire inéxistant $ #3 Original Message:(No such process) # Processus inexistant $ #4 Original Message:(Interrupted system call) # Appel système interrompu $ #5 Original Message:(I/O error) # Erreur E/S $ #6 Original Message:(No such device or address) # Périphérique ou adresse inexistant $ #7 Original Message:(Arg list too long) # Liste d'arguments trop longue $ #8 Original Message:(Exec format error) # Erreur sur le format exécutable $ #9 Original Message:(Bad file number) # Mauvais numéro de fichier $ #10 Original Message:(No child processes) # Pas de processus fils $ #11 Original Message:(Try again) # Essayez encore $ #12 Original Message:(Out of memory) # Plus de mémoire $ #13 Original Message:(Permission denied) # Permission refusée $ #14 Original Message:(Bad address) # Mauvaise adresse $ #15 Original Message:(Block device required) # Périphérique bloc requis $ #16 Original Message:(Device or resource busy) # Périphérique ou ressource occupé $ #17 Original Message:(File exists) # Le fichier existe $ #18 Original Message:(Cross-device link) # Lien entre plusieurs périphériques $ #19 Original Message:(No such device) # Périphérique inexistant $ #20 Original Message:(Not a directory) # N'est pas un répertoire $ #21 Original Message:(Is a directory) # Est un répertoire $ #22 Original Message:(Invalid argument) # Argument invalide $ #23 Original Message:(File table overflow) # Dépassement de la table des fichiers $ #24 Original Message:(Too many open files) # Trop de fichiers ouverts $ #25 Original Message:(Not a typewriter) # N'est pas un terminal $ #26 Original Message:(Text file busy) # Fichier code occupé $ #27 Original Message:(File too large) # Fichier trop grand $ #28 Original Message:(No space left on device) # Plus d'espace libre sur le périphérique $ #29 Original Message:(Illegal seek) # seek illégal $ #30 Original Message:(Read-only file system) # Système de fichier en lecture seulement $ #31 Original Message:(Too many links) # Trop de liens $ #32 Original Message:(Broken pipe) # Rupture du tuyau $ #33 Original Message:(Math argument out of domain of func) # Argument mathématique en dehors du domaine de définition de la fonction $ #34 Original Message:(Math result not representable) # Résultat mathématique non représentable $ #35 Original Message:(Resource deadlock would occur) # Blocage mutuel de la ressource $ #36 Original Message:(File name too long) # Nom du fichier trop long $ #37 Original Message:(No record locks available) # Pas de verrou disponible $ #38 Original Message:(Function not implemented) # Fonction non implémenté $ #39 Original Message:(Directory not empty) # Répertoire non vide $ #40 Original Message:(Too many symbolic links encountered) # Trop de liens symboliques rencontrés $ #41 Original Message:(Operation would block) # L'opération devrait bloquer $ #42 Original Message:(No message of desired type) # Pas de messages du type désiré $ #43 Original Message:(Identifier removed) # Identificateur supprimé $ #44 Original Message:(Channel number out of range) # Numéro du canal en dehors des limites $ #45 Original Message:(Level 2 not synchronized) # Niveau 2 non synchronisé $ #46 Original Message:(Level 3 halted) # Niveau 3 arrêté $ #47 Original Message:(Level 3 reset) # Niveau 3 remis à zéro $ #48 Original Message:(Link number out of range) # Numéro du lien en dehors des limites $ #49 Original Message:(Protocol driver not attached) # Contrôleur de protocole non attaché $ #50 Original Message:(No CSI structure available) # Pas de structure CSI disponible $ #51 Original Message:(Level 2 halted) # Niveau 2 arrêté $ #52 Original Message:(Invalid exchange) # Echange invalide $ #53 Original Message:(Invalid request descriptor) # Demande de descripteur invalide $ #54 Original Message:(Exchange full) # Echange plein $ #55 Original Message:(No anode) # Pas d'anode $ #56 Original Message:(Invalid request code) # Code de demande invalide $ #57 Original Message:(Invalid slot) # Emplacement invalide $ #58 Original Message:(File locking deadlock error) # Erreur sur un interblocage de vérou $ #59 Original Message:(Bad font file format) # Mauvais format de fichier fonte $ #60 Original Message:(Device not a stream) # Le périphérique n'est pas un stream $ #61 Original Message:(No data available) # Pas de données disponibles $ #62 Original Message:(Timer expired) # Durée expirée $ #63 Original Message:(Out of streams resources) # Plus de ressources stream $ #64 Original Message:(Machine is not on the network) # La machine n'est pas sur le réseau $ #65 Original Message:(Package not installed) # Package non installé $ #66 Original Message:(Object is remote) # Objet à distance $ #67 Original Message:(Link has been severed) # Le lien a été coupé $ #68 Original Message:(Advertise error) # Erreur d'annonce $ #69 Original Message:(Srmount error) # Erreur srmount $ #70 Original Message:(Communication error on send) # Erreur de communication lors d'un envoi $ #71 Original Message:(Protocol error) # Erreur de protocole $ #72 Original Message:(Multihop attempted) # Tentative de sauts multiples $ #73 Original Message:(RFS specific error) # Erreur spécifique à RFS $ #74 Original Message:(Not a data message) # N'est pas un message de donnée $ #75 Original Message:(Value too large for defined data type) # Valeur trop grande pour le type de données définies $ #76 Original Message:(Name not unique on network) # Nom non unique sur le réseau $ #77 Original Message:(File descriptor in bad state) # Descripteur de fichier dans un mauvais état $ #78 Original Message:(Remote address changed) # Adresse à distance changée $ #79 Original Message:(Can not access a needed shared library) # Ne peut accéder à une librairie partagée nécessaire $ #80 Original Message:(Accessing a corrupted shared library) # Accès à une librairie altérée $ #81 Original Message:(.lib section in a.out corrupted) # La section .lib dans un a.out est altérée $ #82 Original Message:(Attempting to link in too many shared libraries) # Tentative de lier trop de librairies partagées $ #83 Original Message:(Cannot exec a shared library directly) # Impossibilté d'exécuter directement une librairie partagée $ #84 Original Message:(Illegal byte sequence) # Séquence d'octet illégale $ #85 Original Message:(Interrupted system call should be restarted) # L'appel système interrompu ne peut être repris $ #86 Original Message:(Streams pipe error) # Erreur d'un tuyau de stream $ #87 Original Message:(Too many users) # Trop d'utilisateurs $ #88 Original Message:(Socket operation on non-socket) # Opération de type socket sur un fichier non-socket $ #89 Original Message:(Destination address required) # Adresse de destination obligatoire $ #90 Original Message:(Message too long) # Message trop long $ #91 Original Message:(Protocol wrong type for socket) # Mauvais type de protocole pour un socket $ #92 Original Message:(Protocol not available) # Protocole non disponible $ #93 Original Message:(Protocol not supported) # Protocole non supporté $ #94 Original Message:(Socket type not supported) # Type de socket non supporté $ #95 Original Message:(Operation not supported on transport endpoint) # Opération non supportée sur l'extrémité du transport $ #96 Original Message:(Protocol family not supported) # Famille de protocoles non supportée $ #97 Original Message:(Address family not supported by protocol) # Famille d'adresses non supportée par le protocole $ #98 Original Message:(Address already in use) # Adresse déjà utilisée $ #99 Original Message:(Cannot assign requested address) # Ne peut pas assigner l'adresse demandée $ #100 Original Message:(Network is down) # Le réseau est éteint $ #101 Original Message:(Network is unreachable) # Le réseau ne peut être atteint $ #102 Original Message:(Network dropped connection because of reset) # Le réseau a rompu la connection à cause d'une remise à zéro $ #103 Original Message:(Software caused connection abort) # Echec de connection à cause du logiciel $ #104 Original Message:(Connection reset by peer) # Connection remise à zéro par le correspondant $ #105 Original Message:(No buffer space available) # Pas d'espace disponible dans le buffer $ #106 Original Message:(Transport endpoint is already connected) # L'extrémité du transport est déjà connectée $ #107 Original Message:(Transport endpoint is not connected) # L'extrémité du transport n'est pas connectée $ #108 Original Message:(Cannot send after transport endpoint shutdown) # Impossibilité d'envoyer après un arrêt de l'extrémité du transport $ #109 Original Message:(Too many references: cannot splice) # Trop de références: cannot splice $ #110 Original Message:(Connection timed out) # Durée écoulée pour la connection $ #111 Original Message:(Connection refused) # Connection refusée $ #112 Original Message:(Host is down) # L'hôte est éteint $ #113 Original Message:(No route to host) # Aucune route pour cet hôte $ #114 Original Message:(Operation already in progress) # Operation déjà en cours $ #115 Original Message:(Operation now in progress) # Operation maintenant en cours $ #116 Original Message:(Stale NFS file handle) # Handle de fichier NFS perdu $ #117 Original Message:(Structure needs cleaning) # Structure a besoin de nettoyage $ #118 Original Message:(Not a XENIX named type file) # N'est pas un fichier XENIX de type nommé $ #119 Original Message:(No XENIX semaphores available) # Aucun sémaphore XENIX disponible $ #120 Original Message:(Is a named type file) # Est un fichier de type nommé $ #121 Original Message:(Remote I/O error) # Erreur sur E/S eloignée ./libc-linux/nls/linux/French/clnt-misc.m100644 1676 334 546 5527716662 16330 0ustar hjlisl$set 9 #ClntMisc $ #Errno Original Message:(; errno = %s) # ; errno = %s $ #LowHigh Original Message:(; low version = %lu, high version = %lu) # ; version basse = %lu, version haute = %lu) $ #Why Original Message:(; why = ) # ; pourquoi = $ #UnknownAuth Original Message:((unknown authentication error - %d)) # (erreur d'authentification inconnue - %d) ./libc-linux/nls/linux/French/errlist-u.m100644 1676 334 271 5527716663 16361 0ustar hjlisl$set 2 #UnknownError $ #1 Original Message:(Unknown error 000000000000000000000) # Erreur inconnue 000000000000000000000 $ #2 Original Message:(Unknown error %d) # Erreur inconnue %d ./libc-linux/nls/linux/French/getopt.m100644 1676 334 1647 5527716663 15765 0ustar hjlisl$set 6 #Getopt $ #Ambiguous Original Message:(%s: option `%s' is ambiguous\n) # %s: l'option `%s' est ambigue\n $ #NoArgumentsAllowed1 Original Message:(%s: option `--%s' doesn't allow an argument\n) # %s: l'option `--%s' n'accepte pas d'arguments\n $ #NoArgumentsAllowed2 Original Message:(%s: option `%c%s' doesn't allow an argument\n) # %s: l'option `%c%s' n'accepte pas d'arguments\n $ #RequiresArgument1 Original Message:(%s: option `%s' requires an argument\n) # %s: l'option `%s' demande un argument\n $ #RequiresArgument2 Original Message:(%s: option requires an argument -- %c\n) # %s: l'option demande un argument -- %c\n $ #Unrecognized1 Original Message:(%s: unrecognized option `--%s'\n) # %s: option non reconnue `--%s'\n $ #Unrecognized2 Original Message:(%s: unrecognized option `%c%s'\n) # %s: option non reconnue `%c%s'\n $ #Illegal Original Message:(%s: illegal option -- %c\n) # %s: option illégale -- %c\n ./libc-linux/nls/linux/French/h-errlist.m100644 1676 334 614 5527716663 16345 0ustar hjlisl$set 5 #HerrorList $ #1 Original Message:(Error 0) # Erreur 0 $ #2 Original Message:(Unknown host) # Hôte inconnu $ #3 Original Message:(Host name lookup failure) # Echec lors de la recherche du nom de l'hôte $ #4 Original Message:(Unknown server error) # Erreur inconnue du serveur $ #5 Original Message:(No address associated with name) # Aucune adresse ne peut être associée avec le nom ./libc-linux/nls/linux/French/net-misc.m100644 1676 334 3466 5527716663 16203 0ustar hjlisl$set 11 #NetMisc $ #AllPortsInUse Original Message:(All ports in use) # Tous les ports sont utilisés $ #ConnectTo Original Message:(connect to address) # connecté à l'adresse $ #Trying Original Message:(Trying %s...\n) # Essaye %s...\n $ #SettingUpStderr Original Message:(write: setting up stderr) # écriture: installation de stderr $ #Accept Original Message:(accept) # accepté $ #Getsockname Original Message:(getsockname) # getsockname $ #ProtocolFailure Original Message:(socket: protocol failure in circuit setup.) # socket: échec du protocole lors de l'installation du circuit $ #RcmdSocket Original Message:(rcmd: socket) # rcmd: socket $ #RexecSocket Original Message:(rexec: socket) # rexec: socket $ #NetrcWrongPasswordMode Original Message:(Error - .netrc file not correct mode.\nRemove password or correct mode.) # Error - Fichier .netrc dans un mode incorrect.\nSupprimez le mot de passe ou corrigez le mode. $ #UnknownNetrcOption Original Message:(Unknown .netrc option) # Option dans .netrc inconnue $ #ResolvIncorrectFormat Original Message:(resolv+: %s: \"%s\" command incorrectly formatted.\n) # X-resolv+: %s: commande "%s" incorrectement formatée.\n $ #ResolvInvalid Original Message:(resolv+: \"%s\" is an invalid keyword\n) # X-resolv+: "%s" est un mot clé invalide\n $ #ResolvValid Original Message:(resolv+: valid keywords are: %s, %s and %s\n) # X-resolv+: Les mots clés valides sont : %s, %s et %s\n $ #Unrecognized Original Message:(resolv+: search order not specified or unrecognized keyword, host resolution will fail.\n) # X-resolv+: L'odre de recherche n'est pas spécifié ou mot clé non reconnu, la résolution de l'hôte va échouer.\n $ #PossibleSpoof Original Message:(gethostbyaddr: %s != %u.%u.%u.%u, possible spoof attempt) # gethostbyaddr: %s != %u.%u.%u.%u, tentative possible de plaisanterie ./libc-linux/nls/linux/French/rpc-errlist.m100644 1676 334 3105 5527716664 16721 0ustar hjlisl$set 8 #RpcErrList $ #1 Original Message:(RPC: Success) # RPC: Succès $ #2 Original Message:(RPC: Can't encode arguments) # RPC: Ne peut pas coder les arguments $ #3 Original Message:(RPC: Can't decode result) # RPC: Ne peur pas décoder le résultat $ #4 Original Message:(RPC: Unable to send) # RPC: Incapacité d'envoyer $ #5 Original Message:(RPC: Unable to receive) # RPC: Incapacité de recevoir $ #6 Original Message:(RPC: Timed out) # RPC: Durée expirée $ #7 Original Message:(RPC: Incompatible versions of RPC) # RPC: Versions de RPC incompatibles $ #8 Original Message:(RPC: Authentication error) # RPC: Erreur d'autentification $ #9 Original Message:(RPC: Program unavailable) # RPC: Programme non disponible $ #10 Original Message:(RPC: Program/version mismatch) # RPC: Le programme ou la version est incompatible $ #11 Original Message:(RPC: Procedure unavailable) # RPC: Procédure non disponible $ #12 Original Message:(RPC: Server can't decode arguments) # RPC: Le serveur ne peut décoder les arguments $ #13 Original Message:(RPC: Remote system error) # RPC: Erreur du système distant $ #14 Original Message:(RPC: Unknown host) # RPC: Hôte inconnu $ #15 Original Message:(RPC: Port mapper failure) # RPC: Echec de la redirection du port $ #16 Original Message:(RPC: Program not registered) # RPC: Programme non enregistré $ #17 Original Message:(RPC: Failed (unspecified error)) # RPC: Echec (erreur non spécifiée) $ #18 Original Message:(RPC: Unknown protocol) # RPC: Protocole inconnu $ #Unknown Original Message:(RPC: (unknown error code)) # RPC: (code d'erreur inconnu) ./libc-linux/nls/linux/French/rpc-misc.m100644 1676 334 7672 5527716664 16205 0ustar hjlisl$set 10 #RpcMisc $ #OutOfMemory Original Message:(out of memory) # Plus de mémoire $ #CannotRegister Original Message:(Cannot register service) # Ne peut pas enregistrer le service $ #FatalMarshall Original Message:(auth_none.c - Fatal marshalling problem) # auth_none.c - Problème fatal de maintien de l'ordre $ #FatalHeader Original Message:(clnt_raw.c - Fatal header serialization error.) # clnt_raw.c - Erreur fatale de sérialisation de l'entête. $ #Hostname Original Message:(get_myaddress: gethostbyname) # get_myaddress: gethostbyname $ #Socket Original Message:(get_myaddress: socket) # get_myaddress: socket $ #Iface Original Message:(get_myaddress: ioctl (get interface configuration)) # get_myaddress: ioctl (demande de la configuration de l'interface) $ #Ioctl Original Message:(get_myaddress: ioctl) # get_myaddress: ioctl $ #Getmaps Original Message:(pmap_getmaps rpc problem) # pmap_getmaps: problème rpc $ #BConfig Original Message:(broadcast: ioctl (get interface configuration)) # broadcast: ioctl (demande de la configuration de l'interface) $ #BFlags Original Message:(broadcast: ioctl (get interface flags)) # broadcast: ioctl (demande des drapeaux de l'interface) $ #CantCreateBSocket Original Message:(Cannot create socket for broadcast rpc) # Ne peut créer un socket pour une diffusion rpc $ #CantSetBOption Original Message:(Cannot set socket option SO_BROADCAST) # Ne peut mettre l'option socket SO_BROADCAST $ #CantSendBPacket Original Message:(Cannot send broadcast packet) # Ne peut envoyer un paquet de diffusion $ #BSelectProblem Original Message:(Broadcast select problem) # Problème de selection de diffusion $ #CantReceiveBReply Original Message:(Cannot receive reply to broadcast) # Ne peut recevoir la réponse à une diffusion $ #BDesProblem Original Message:(Broadcast deserialization problem) # Problème de sérialisation d'un diffusion $ #BadAuthLen Original Message:(bad auth_len gid %d str %d auth %d\n) # mauvais auth_len gid %d str %d auth %d\n $ #SelectFailed Original Message:(svc_run: - select failed) # svc_run: - échec de select $ #CantReassignProc Original Message:(can't reassign procedure number %d\n) # Ne peut réassigner la précedure numéro %d\n $ #CantCreateServer Original Message:(couldn't create an rpc server) # ne peut créer un serveur rpc $ #CantRegisterProg Original Message:(couldn't register prog %d vers %d\n) # ne peut enregistrer prog %d vers %d\n $ #TroubleReplying Original Message:(trouble replying to prog %d\n) # trouble en répondant au prog %d\n $ #NeverRegisteredProg Original Message:(never registered prog %d\n) # prog %d jamais enregistré\n $ #TcpSocketCreateProblem Original Message:(svc_tcp.c - tcp socket creation problem) # svc_tcp.c - problème de création de socket tcp $ #CantGetNameListen Original Message:(svctcp_.c - cannot getsockname or listen) # svctcp_.c - problème avec listen ou getsockname $ #UdpSocketCreateProblem Original Message:(svcudp_create: socket creation problem) # svcudp_create: problème de création de socket $ #UdpCantGetName Original Message:(svcudp_create - cannot getsockname) # svcudp_create - problème avec getsockname $ #CacheAlreadyEnabled Original Message:(enablecache: cache already enabled) # enablecache: cache déjà permis $ #CantAllocateCache Original Message:(enablecache: could not allocate cache) # enablecache: ne peut allouer un cache $ #CantAllocateCacheData Original Message:(enablecache: could not allocate cache data) # enablecache: ne peut allouer un cache de données $ #CantAllocateCacheFifo Original Message:(enablecache: could not allocate cache fifo) # enablecache: ne peut allouer un cache de fifo $ #VictimNotFound Original Message:(cache_set: victim not found) # cache_set: victime non trouvée $ #VictimAllocFailed Original Message:(cache_set: victim alloc failed) # cache_set: échec de l'allocation de la victime $ #CantAllocateRpcBuffer Original Message:(cache_set: could not allocate new rpc_buffer) # cache_set: ne peut pas allouer un nouveau rpc_buffer ./libc-linux/nls/linux/French/siglist-u.m100644 1676 334 264 5527716664 16356 0ustar hjlisl$set 4 #UnknownSignal $ #0 Original Message:(Unknown signal 000000000000000000) # Signal inconnu 000000000000000000 $ #1 Original Message:(Unknown signal %d) # Signal inconnu %d ./libc-linux/nls/linux/French/siglist.m100644 1676 334 3751 5527716664 16140 0ustar hjlisl$set 3 #SignalList $ #0 Original Message:(Unknown signal) # Signal inconnu $ #1 Original Message:(Hangup) # Raccrochage $ #2 Original Message:(Interrupt) # Interruption $ #3 Original Message:(Quit) # Sortie $ #4 Original Message:(Illegal instruction) # Instruction illégale $ #5 Original Message:(Trace/breakpoint trap) # Trace/Point d'arrêt $ #6 Original Message:(IOT trap/Abort) # Piège IOT ou abandon $ #7 Original Message:(Unused signal) # Signal non utilisé $ #8 Original Message:(Floating point exception) # Exception numérique $ #9 Original Message:(Killed) # Tué $ #10 Original Message:(User defined signal 1) # Signal utilisateur 1 $ #11 Original Message:(Segmentation fault) # Faute de segmentation $ #12 Original Message:(User defined signal 2) # Signal utilisateur 2 $ #13 Original Message:(Broken pipe) # Tuyau rompu $ #14 Original Message:(Alarm clock) # Alarme $ #15 Original Message:(Terminated) # Terminé $ #16 Original Message:(Stack fault) # Faute de la pile $ #17 Original Message:(Child exited) # Un enfant a terminé $ #18 Original Message:(Continued) # Continue $ #19 Original Message:(Stopped (signal)) # Stoppé (signal) $ #20 Original Message:(Stopped) # Stoppé $ #21 Original Message:(Stopped (tty input)) # Stoppé (entrée sur terminal) $ #22 Original Message:(Stopped (tty output)) # Stoppé (sortie sur le terminal) $ #23 Original Message:(Possible I/O) # E/S possible $ #24 Original Message:(CPU time limit exceeded) # La limite du temps processeur a été dépassée $ #25 Original Message:(File size limit exceeded) # La limite de taille des fichiers a été dépassée $ #26 Original Message:(Virtual time alarm) # Alarme du temps virtuel $ #27 Original Message:(Profile signal) # Signal de profil $ #28 Original Message:(Window size changed) # La taille de la fenêtre a changé $ #29 Original Message:(File lock lost) # Le fichier a perdu des vérous $ #30 Original Message:(Unused signal) # Signal non utilisé $ #31 Original Message:(Unused signal) # Signal non utilisé ./libc-linux/ChangeLog.1100644 1676 334 256545 5515050635 13112 0ustar hjlislWed Dec 22 07:02:31 1993 H.J. Lu (hlu@nighthawk) * version 4.5.8 is released. * pwd/shadow.c: speed up if /etc/shadow doesn't exist. * : * : new files for 0.99 pl14e above. * : fix typo in comment for strcat (). * : don't define __CONSTVALUE2 if __STDC__ is not define. * ./libio/stdio/ChangeLog: new entries. * ./libio/ChangeLog: new entries. * ./libio: copy files from libg++ 2.5.3 and apply my fixes. Sat Dec 11 09:11:55 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.8. * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: add __IO_default_underflow. * : don't include . don't pollute the name space with . use __gnuc_va_list in vsyslog (). * misc/syslog.c: include . * ./libio/stdio/ChangeLog: new entries. * ./libio/ChangeLog: new entries. Fri Dec 10 08:57:10 1993 H.J. Lu (hlu@nighthawk) * version 4.5.7 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.7. * sysdeps/linux/i386/Makefile: make "lib" depend on "libieee" for the static library. * locale/setlocale.c: add more features and try to be ANSI C. * nls/msgcat-libc.c: * nls/msgcat.c: support LOCALE. * : define LC_MESSAGES and add it to LC_ALL. * : * ./jump/libm/jump.funcs: change logp1 to log1p. * ./sysdeps/linux/i386/math/log1p.c: renamed from logp1.c with name change. * ./sysdeps/linux/i386/math/logp1.c: removed. * ./sysdeps/linux/i386/math/Makefile: change logp1.c to log1p.c. * ./libio/ChangeLog: new entries. * posix/readv.c: return 0 if 0 byte read in. * posix/writev.c return 0 if 0 byte to write. * : clear __CONSTVALUE2 if "const" is defined. clear __NORETURN2 if "noreturn" is defined. Mon Dec 6 14:39:29 1993 H.J. Lu (hlu@nighthawk) * version 4.5.6 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.6. * jump/libc.lite/jump.funcs: enable all the functions in libtermcap.a. * inet/inet_net.c (inet_network): treat the network address as a.b.c.d (with each treated as 8-bits) a.b.c (with each treated as 8-bits) a.b (with each treated as 8 bits) a (with a treated as 8 bits) * ./libio/ChangeLog: new entries. * libio: copy files from libg++ 2.5.2 and apply my fixes. * mntent/setmntent.c: change fopen to _IO_fopen. Fri Dec 3 09:46:56 1993 H.J. Lu (hlu@nighthawk) * version 4.5.5 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.5. * gcc/Makefile: add _op_new, _op_delete and _new_handler to LIB2FUNCS. * inet/inet_net.c: return the network number. * jump/libc.lite/jump.vars: * jump/libc/jump.vars: restore ___new_handler. * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: restore ___builtin_delete, ___builtin_new, ___set_new_handler and _set_new_handler. add __IO_file_close_it. change "___eprintf" to the type 'T'. * ./libio/ChangeLog: * ./libio/stdio/ChangeLog: new entries. * libio: copy files from libg++ 2.5.2 beta and apply my fixes. * : don't define const if __USE_BSD is define since __attribute__ uses const. * : change memcpy (src, dest, len) to memcpy(dest, src, len). * nls/msgcat.c: catopen() requires either a valid return catalog descriptor or -1. Mon Nov 29 09:45:31 1993 H.J. Lu (hlu@nighthawk) * version 4.5.4 is released. * gnu/types.h (__promoted_{dev,gid,uid,mode,nlink}_t): * fcntl.h, grp.h, pwd.h, rpc/auth.h, sys/stat.h, unistd.h: * sys/types.h (promoted_{dev,gid,uid,mode,nlink}_t): undo changes on Nov 27. * 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.4. * sysdeps/linux/i386/math/Makefile: fix typos. Sat Nov 27 20:39:58 1993 Chip Salzenberg (chip@fin.uucp) * gnu/types.h (__promoted_{dev,gid,uid,mode,nlink}_t): Define. * fcntl.h, grp.h, pwd.h, rpc/auth.h, sys/stat.h, unistd.h: Use. * sys/types.h (promoted_{dev,gid,uid,mode,nlink}_t): Define. Sat Nov 27 20:34:37 1993 Chip Salzenberg (chip@fin.uucp) * features.h (__extention__): Remove definition. * sys/cdefs.h (__extension__): Define. (__NORETURN{,2}, __CONSTVALUE{,2}): Define correctly for all versions of GCC and other compilers. * math.h, setjmp.h, stdlib.h, time.h, unistd.h: Use them. Fri Nov 26 18:55:26 1993 H.J. Lu (hlu@nighthawk) * version 4.5.3 is released. * Makefile: for the shared math library, don't looking for libgcc.sa, use libgcc3.a instead. * jump/libm/jump.params: * jump/libm/jump.params.build: bump up to version 4.5.3. * 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.3. * jump/libc.lite/jump.vars: * jump/libc/jump.vars: * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: add _endspent, _fgetspent, _getspent, _getspnam, _putspent, _setspent, _sgetspent, _endsgent, _fgetsgent, _getsgent, _getsgnam, _putsgent, _setsgent and _sgetsgent. * : * : changes for shadow. * grp/Makefile (SRCS): add gshadow.c. * pwd/Makefile (SRCS): add shadow.c. * pwd/pwdread.c (__pwdread): if NO_SHADOW is not defined, call getspnam () to get the shadow password on the local machine. * string/strsignal.c: * nls/Makefile: * nls/msgcat.c: * nls/msgcat.h: * nls/nl_types.h: * nls/linux/Makefile: * nls/linux/xtract.l: * nls/linux/extract: * nls/linux/NOTES: * nls/linux/README.editing: * libio/ioperror.c: changes for NLS. * : new for NLS. * locale/ISO88591_ct.c: * locale/C-ctype_ct.c: '\b' is not a white space. * gcc/longlong.h: removed. * gcc/libgcc1.c: removed. * gcc/Makefile (LIB2FUNCS): remove _muldi3, _udivdi3, _umoddi3 and _udivmoddi4. * ./libio/ChangeLog: * ./libio/stdio/ChangeLog: new entries. Wed Nov 24 15:58:22 1993 H.J. Lu (hlu@nighthawk) * version 4.5.2 is released. * ./Makefile: fix typo. * ./libio/ChangeLog: * ./libio/stdio/ChangeLog: new entries. * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: remove __IO_file_close_it. * 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.2. Tue Nov 23 01:09:06 1993 H.J. Lu (hlu@nighthawk) * version 4.5.1 is released. * ./libio/ChangeLog: * ./libio/stdio/ChangeLog: new entries. * 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.1. * jump/libc.lite/jump.vars: * jump/libc/jump.vars: * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: change "___eprintf" to the type 't'. Sun Nov 21 22:55:43 1993 H.J. Lu (hlu@nighthawk) * version 4.5 is released. * <_G_config.h>: * : * : new header files from the new libio-based stdio. * 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. * jump/libc.lite/jump.vars: * jump/libc/jump.vars: * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: new for the libio-based stdio. * jump/libc.lite/jump.vars.iostream: * jump/libc/jump.vars.iostream: * jump/libc.lite/jump.funcs.iostream: * jump/libc/jump.funcs.iostream: copied from the iosteram-based stdio. * Makefile: remove libgcc.a and libgcc.sa. * gcc/Makefile: use libgcc3.a. * stdlib/Makefile: for _IO_stdtod.c. * stdlib/strtod.c: alias for _IO_stdtod (). * misc/Makefile: for stdiocompat.c and dtoa.c. * misc/dtoa.c: alias for _IO_dtoa (). * misc/stdiocompat.c: new file for backward compatibilities with stdin, stdout and stderr. * ./Maketargets: change targets to "clean::" and "realclean::". add TARGET=$@. * iostream: removed. * libio: new. * Makeconfig: add NEWSTDIOFLAGS. Sat Nov 20 14:56:24 1993 H.J. Lu (hjl@jalod) * version 4.4.4c is released. * ./nls/Makefile: * ./nls/linux/English/auth.m: * ./nls/linux/English/clnt-misc.m: * ./nls/linux/English/errlist-u.m: * ./nls/linux/English/errlist.m: * ./nls/linux/English/getopt.m: * ./nls/linux/English/h-errlist.m: * ./nls/linux/English/net-misc.m: * ./nls/linux/English/rpc-errlist.m: * ./nls/linux/English/rpc-misc.m: * ./nls/linux/English/siglist-u.m: * ./nls/linux/English/siglist.m: * ./nls/linux/Makefile: * ./nls/nl_types.h: * ./nls/nls_libc.h: * ./inet/gethstnmad.c: * ./inet/herror.c: * ./inet/rcmd.c: * ./inet/rexec.c: * ./inet/ruserpass.c: * ./rpc/auth_unix.c: * ./rpc/clnt_perror.c: * ./rpc/clnt_raw.c: * ./rpc/clnt_tcp.c: * ./rpc/clnt_udp.c: * ./rpc/get_myaddr.c: * ./rpc/pmap_clnt.c: * ./rpc/pmap_getmaps.c: * ./rpc/pmap_rmt.c: * ./rpc/svc_au_ux.c: * ./rpc/svc_run.c: * ./rpc/svc_simple.c: * ./rpc/svc_tcp.c: * ./rpc/svc_udp.c: * ./rpc/xdr.c: * ./rpc/xdr_array.c: * ./rpc/xdr_rec.c: * ./rpc/xdr_ref.c: changes for NLS. * <: don't use __times. it is used in . * : new file for realpath () from jrs@world.std.com. * (sigprocmask): add __const to the 2nd arg. * ./inet/rcmd.c (ruserok): call seteuid(saveuid) before error return. Sun Nov 14 12:30:35 1993 H.J. Lu (hjl@jalod) * version 4.4.4b is released. * stdlib/labs.c: * stdlib/ldiv.c: remove __CONSTVALUE. * : * : change __CONSTVALUE in gcc 2.5 style. * : change __NORETURN and __CONSTVALUE in gcc 2.5 style. * : change __NORETURN in gcc 2.5 style. * : from glibc 1.06.7 for __NORETURN with fixes. * : from glibc 1.06.7 for __CONSTVALUE with fixes. * ./sstream: removed. * ./Makeconfig: * ./Makefile: * ./crt/Makefile: add CHECKER for SBPM Marc GINGOLD . * ./crt/chkrcrt0.S: new for CHECKER. * ./math/Makefile: add CHECKER. * ./sysdeps/linux/i386/math/cos.S: * ./sysdeps/linux/i386/math/sin.S: change comments for gas 2.x. * ./sysdeps/linux/i386/sysdep.h: change to $(SYS_##syscall_name) for gas 2.x. * : add realpath (). * bsd/realpath.c: new file for realpath () from jrs@world.std.com. * bsd/Makefile: add realpath.c. * nls/Makefile: * nls/msgcat.c: * nls/msgcat.h: add support for mmap (). from Mitchum DSouza . * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: add _realpath, _catopen, _catgets, _catclose, _MCGetSet and _MCGetMsg. Sat Nov 6 18:15:52 1993 H.J. Lu (hlu@nighthawk) * version 4.4.4a is released. * ./inet/ruserpass.c: call gethostbyname () while parsing ~/.netrc for aliases. from bin@att2.cs.mankato.msus.edu. * ./inet/gethstnmad.c: new patches from Mitchum DSouza . * ./Makeconfig: * ./Makefile: * ./bsd/psignal.c: * ./inet/herror.c: * ./iostream/stdio/perror.c: * ./posix/getopt.c: * ./string/strerror.c: * ./string/strsignal.c: add NLS support. * ./nls: NLS internationalization, catopen(), etc.. from Mitch DSouza . Please read instructions in ./nls for details. * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: add _mprotect, ___adjtime, ___adjtimex, and ___ntp_gettime, * Gcc 2.5.2 is mandatory due to the new C++ name mangling. * jump/libc.lite/jump.vars: * jump/libc/jump.vars: change `__vt$streambuf' to `__vt$9streambuf', change `__vt$filebuf' to `__vt$7filebuf', change `__vt$backupbuf' to `__vt$9backupbuf', change `__vt$ios' to `__vt$3ios', change `__vt$12strstreambuf' to `__vt$12strstreambuf'. * : change the type to int in sig[set|get]mask (). * ./time/difftime.c: remove __CONSTVALUE. * ./stdlib/abort.c: * ./stdlib/exit.c: * ./sysdeps/i386/__longjmp.c: * ./sysdeps/linux/i386/libc_exit.c: * ./setjmp/siglongjmp.c: remove __NORETURN. * ./misc/ldexp.c: remove __const. * ./jump/libm/jump.funcs: add _logp1 and _expm1. * ./sysdeps/linux/i386/math/logp1.c: * ./sysdeps/linux/i386/math/expm1.S: new files. * ./sysdeps/linux/i386/math/Makefile: add logp1.c and expm1.S. * : add logp1 () and expm1 (). * ./Makeconfig: use gcc 2.5.2. * ./iostream/stdstrbufs.C: change vt_filebuf to _vt$7filebuf for gcc 2.5.x. * ./compat/i386/__old_sigsj.c: * ./compat/i386/__old_sigjmp.c: * ./sysdeps/i386/sigsetjmp.c: * ./setjmp/__sj_save.c: use __sigprocmask () instead of __sigsgtmask (). * ./posix/sleep.c: use __sigprocmask () instead of __sigsetmask (). * ./sysdeps/linux/i386/__sigstmsk.c: * ./sysdeps/linux/i386/__siggtmsk.c: deleted. * ./sysdeps/linux/i386/Makefile: delete __sigstmsk.c and __siggtmsk.c. * ./sysdeps/linux/__sigstmsk.c: * ./sysdeps/linux/__siggtmsk.c: new files. * : add mprotect (). * ./sysdeps/linux/__sigproc.S: * ./sysdeps/linux/mprotect.S: new files. * ./sysdeps/linux/__sigstmsk.S: * ./sysdeps/linux/__siggtmsk.S: * ./sysdeps/linux/__sigproc.c: deleted. * ./sysdeps/linux/Makefile: delete __sigstmsk.S, __siggtmsk.S, and __sigproc.c. add __sigstmsk.c, __siggtmsk.c, __sigproc.S and mprotect.S. * : new system calls, mprotect and sigprocmask. * ./gmon/profil.c: change the profile signal handler according to kernel 0.99 pl 13. a different patch from jrs@world.std.com (Rick Sladkey). * ./string/strsignal.c: check signum >= NSIG. don't check sprintf () return. * ./string/strerror.c: unknown_error[len] = '\0'; * ./grp/grpread.c (__ypparsegrp): check if "end" is NULL. * : change va_list to _G_va_list in vsyslog (). include and . * : change FNDLEAY to FNDELAY. * : define __CONSTFUNCTION. * : * : declare extern const foo bar (...); as typedef foo foo_t (...); extern const foo_t bar; * : * : * : declare a function void foo (...) with no return as typedef void foo_t (...); extern volatile foo_t foo; * : declare __adjtimex () and __ntp_gettime (). need 0.99 pl 14. * : add adjtime () and __adjtime (). need 0.99 pl 14. * : change _TIMES_H to _SYS_TIMES_H. * ./sysdeps/linux/i386/__ntpgttm.c: new. need 0.99 pl 14. * ./sysdeps/linux/i386/__adjtimex.S: new. need 0.99 pl 14. * ./sysdeps/linux/i386/__adjtime.c: new. need 0.99 pl 14. * ./sysdeps/linux/i386/Makefile: add __adjtime.c, __ntpgttm.c and __adjtimex.S. add -I../../.. * ./time/adjtime.c: from glibc 1.04. need 0.99 pl 14. * ./time/Makefile: add adjtime.c. * ./gmon/profil.c: change the profile signal handler according to kernel 0.99 pl 13. from Jochen_Kiemes@s2.maus.de (Jochen Kiemes). Sat Oct 16 17:46:45 1993 H.J. Lu (hlu@nighthawk) * version 4.4.4 is released. * ./jump/libc/jump.params: * ./jump/libc/jump.params.build: * ./jump/libc.lite/jump.params: * ./jump/libc.lite/jump.params.build: * ./jump/libm/jump.params: * ./jump/libm/jump.params.build: change version to 4.4.4. * : add SYS_modify_ldt and SYS_adjtimex. * : new file. include . * : new file. include . * : add sv_flags. * ./inet/rcmd.c: change the effective uid when checking the users .rhosts. * ./Makefile: Use ./libc.a for __load.o, __setfpucw.o and __fpu_cpntrol.o while making the shared library. Thu Oct 14 15:53:23 1993 H.J. Lu (hlu@nighthawk) * version 4.4.2e is released. * ./jump/libc/jump.params: * ./jump/libc/jump.params.build: * ./jump/libc.lite/jump.params: * ./jump/libc.lite/jump.params.build: * ./jump/libm/jump.params: * ./jump/libm/jump.params.build: change version to 4.4.3. * ./Makeconfig: add LDSO_ADDR and LDSO_ENTRY. very BAD. what if they are changed in ld.so? * ./misc/ldexp.c: add __const. * ./sysdeps/linux/i386/Makefile: add _DLDSO_ADDR=$(LDSO_ENTRY) to CFLAGS. * ./sysdeps/linux/i386/config.h: * ./sysdeps/linux/i386/fixups.h: from ld.so 1.3. Wed Oct 13 13:25:03 1993 H.J. Lu (hlu@nighthawk) * version 4.4.2d is released. * : deleted. * : change __const to const. * : new file. * ./inet/gethstnmad.c: * ./inet/inetprivate.h: patched for resolve+ (?) 2.1.1. * ./sysdeps/linux/i386/__load.c: from ld.so 1.2a. * ./Makefile (realclean): new target. * ./Maketargets (depend): add $(CFLAGS). * : parenthesize the arguments. * : include if __STDC__ is not defined. use __DOTS. * ./crt/crt0.S: * ./crt/gcrt0.S: add "addl $4,%esp" after call __setfpucw (). * iostream/floatconv.C (strtod): modify checking "+" and "-". * ./crt/crt0.S: * ./crt/gcrt0.S: add "pushl %eax" before call __setfpucw (). Thu Sep 9 14:36:01 1993 H.J. Lu (hlu@nighthawk) * version 4.4.2c is released. * : new header file for 387 control word. * ./io/Makefile: fix a typo. * ./Makefile: changes for 387 control word. * ./sysdeps/linux/i386/Makefile: add __setfpucw.c and __fpu_control.c. * ./sysdeps/linux/i386/ieee.c: * ./sysdeps/linux/i386/__setfpucw.c: * ./sysdeps/linux/i386/__fpu_control.c: new files for 387 control word. * ./crt/crt0.S: * ./crt/gcrt0.S: call __setfpucw () to setup 387 control word. * ./sysdeps/linux/Makefile: fix typo. * ./locale/ISO88591-ctype.c: comment out _ctype_info. Mon Sep 6 15:25:10 1993 H.J. Lu (hlu@nighthawk) * version 4.4.2b is released. * ./iostream/stdio/Makefile: * ./iostream/Makefile: * ./Makefile: * ./signal/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: * ./gdbm/Makefile: * ./sysdeps/i386/Makefile: * ./sysdeps/linux/i386/Makefile: * ./sysdeps/linux/Makefile: * ./sysdeps/Makefile: * ./math/Makefile: * ./compat/Makefile: * ./compat/i386/Makefile: * ./shadow/Makefile: * ./libbsd/Makefile: * ./sbin/lib/Makefile: * ./sbin/crt/Makefile: * ./sbin/Makefile: * ./sstream/Makefile: * ./malloc-930716/Makefile: include "Maketargets". * iostream/floatconv.C (strtod): check "+" and "-". * ./Maketargets: new file. * ./Makeconfig: fix for YP. * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: add sethost ()/gethostid (). * ./misc/Makefile: add hostid.c. * ./misc/hostid.c: new from Mitchum DSouza * : change BYTE_ORDER to __BYTE_ORDER and XXX_ENDIAN to __XXX_ENDIAN. * ./string/memcopy.h: change #ifdef __XXX_ENDIAN to #if __BYTE_ORDER == __XXX_ENDIAN * ./inet/gethstnmad.c: check NULL pointers. Sat Aug 21 12:30:04 1993 H.J. Lu (hlu@nighthawk) * ./jump/libc.lite/jump.funcs: commented out YP functions. * : * : * : * : new files. need new network code. * : renamed from * : linked to ip_tcp.h. * : linked to ip_udp.h. Tue Aug 17 16:07:42 1993 H.J. Lu (hlu@nighthawk) * iostream/floatconv.C (dtoa): check "rve" instead of "*rve". * : "strerr()" -- this should be "strerror()" * : include for LONG_MAX. Sun Aug 15 12:28:32 1993 H.J. Lu (hlu@nighthawk) * version 4.4.2a is released. Sat Aug 14 13:40:44 1993 H.J. Lu (hlu@nighthawk) * : use __const instead of const. * : cleanup. * : cleanup. use __const instead of const. * : use __const instead of CONST. * : remove redundant __P (). * : add __CONSTVALUE in front of math functions. * : use __const instead of CONST. * : change __P(()) to __P((void)). * : add __P () for K&R code. remove the definition of __CONSTVALUE. * : add the definition of __CONSTVALUE. * : add __CONSTVALUE in front of difftime (). Tue Aug 10 14:07:26 1993 H.J. Lu (hlu@nighthawk) * Makefile: don't add LIBYP if it is libc. * Makeconfig: add SHARED for YP. * inet/Makefile: add -DNIS if YP is defined. Mon Aug 9 22:03:15 1993 H.J. Lu (hlu@nighthawk) * FYI, I have no idea if I implement the ISO-8859-1 char set support right. * locale/Makefile: add the ISO 8859 1 char set support. define -DUSE_ISO_8859_1. * locale/setlocale.c: add the ISO-8859-1 char set support if -DUSE_ISO_8859_1 is defined. * locale/ISO88591-ctype.c: * locale/ISO88591_ct.c: * locale/ISO88591_mb.c: new files for the ISO-8859-1 char set support. Sun Aug 8 14:52:29 1993 H.J. Lu (hlu@nighthawk) * : define HZ as HZ iff __STDC__ is defined. * : comment out define `ffs' to `__builtin_ffs' since gcc is broken. * rpc/Makefile: add -fno-builtin since gcc is broken. * gcc/libgcc2.c: add an inline static version of ffs () to _ffsdi2.o. Sat Aug 7 18:30:55 1993 H.J. Lu (hlu@nighthawk) * gdbm/system.h: comment out #define fsync(f) sync();sync() for Linux. Sat Aug 7 15:13:55 1993 H.J. Lu (hlu@nighthawk) * version 4.4.2 is released. * ./TODO: new file. * ./verify.out.libc.so: for 4.4.2. * ./jump/libm/jump.params: * ./jump/libm/jump.params.build: change version to 4.4.2. Fri Aug 6 01:02:21 1993 H.J. Lu (hlu@nighthawk) * jump/libc.lite/jump.funcs: * jump/libc/jump.funcs: change `_exception__3iosi' to `_exceptions__3iosi'. remove `_init_const__12strstreambuf'. change ` ___ls__7ostreamPv' to ` ___ls__7ostreamPCv'. * jump/libc.lite/jump.vars: * jump/libc/jump.vars: change `_not_open_filebuf' to `__DUMMY__". * ./compat/i386/__old_sigjmp.c: renamed from __old_sigsj.c. change it for new . * ./compat/i386/Makefile: change to __old_sigjmp.o from __old_sigsj.o. * ./sysdeps/linux/i386/__wait.c: * ./sysdeps/linux/i386/__wait3.c: * ./sysdeps/linux/i386/__waitpid.c: ajust for new . * ./misc/usleep.c: include . * ./posix/sleep.c: Save errno on entry and restore it before returning. * : from glibc 1.06.4. * iostream/Makefile: * iostream/stdio/Makefile: add target `obj'. * <_G_config.h>: compatible with libg++ 2.4. * : * : * : use the new . * : * : * : include the new . Thu Aug 5 18:02:43 1993 H.J. Lu (hlu@nighthawk) * ./malloc-930716: renamed from malloc-930326 * ./Makefile: malloc-930326 to malloc-930716. * ./malloc-930716/free.c: * ./malloc-930716/malloc.c: * ./malloc-930716/malloc.h: patches from mike@sisters.cs.uoregon.edu. * ./malloc-930716/README: update. * ./malloc/free.c: * ./malloc/malloc.c: * ./malloc/malloc.h: patches adapted from mike@sisters.cs.uoregon.edu. Wed Jul 28 21:21:37 1993 H.J. Lu (hlu@nighthawk) * ./Makefile: * ./Makeconfig: add YP support. from swen@uni-paderborn.de. * ./jump/libc/jump.funcs: ./jump/libc.lite/jump.funcs: add YP functions. * ./jump/libc/jump.ignore: ./jump/libc.lite/jump.ignore: add YP stuff. * ./jump/libc/jump.params: * ./jump/libc/jump.params.build: * ./jump/libc.lite/jump.params: * ./jump/libc.lite/jump.params.build: change version to 4.4.2. * ./pwd/getpwent.c: * ./pwd/getpwnam.c: * ./pwd/getpwuid.c: add YP support. from swen@uni-paderborn.de. * ./pwd/pwdread.c: add YP support. from swen@uni-paderborn.de. use __getline (). * ./grp/getgrent.c: * ./grp/getgrgid.c: * ./grp/getgrnam.c: add YP support. from swen@uni-paderborn.de. * ./grp/grpread.c: add YP support. from swen@uni-paderborn.de. use __getline (). * ./rpc/getrpcent.c: add YP support. from swen@uni-paderborn.de. * ./yp/Makefile: * ./yp/xdryp.c: * ./yp/xdryppasswd.c: * ./yp/yplib.c: new files for YP. from swen@uni-paderborn.de. Sun Jul 25 15:05:35 1993 H.J. Lu (hlu@nighthawk) * ./misc/obstack.c: from glibc 1.06.4. GPL to LGGL. * : from glibc 1.06.4. GPL to LGGL with minor changes. * ./posix/getopt.c: * ./posix/getopt1.c: from glibc 1.06.4. GPL to LGGL. * : from glibc 1.06.4. LGPL. * ./Makeconfig: define _LIBC. Fri Jul 23 22:55:03 1993 H.J. Lu (hlu@nighthawk) * ./jump/libc.lite/jump.funcs: * ./jump/libc/jump.funcs: change __sj_save to sigjmp. * : define _longjmp as longjmp if __FAVOR_BSD is not defined. * setjmp/sigjmp_save.c: Renamed to sigjmp.c. * setjmp/Makefile : Change reference. * (sigjmp_buf): Rename `__savemask' to `__mask_was_saved' and `__sigmask' to `__saved_mask'. * setjmp/sigjmp.c (__sigjmp_save): Change use. * setjmp/siglongjmp.c (siglongjmp): Likewise. * ./libc-linux/misc/__getline.c: new file. * ./libc-linux/misc/Makefile: add __getline.o. * ./libc-linux/grp/grpread.c: use __getline (). * ./libc-linux/pwd/pwdread.c: use __getline (). * ./libc-linux/iostream/PlotFile.C: * ./libc-linux/iostream/PlotFile.h: GPL to LGPL from Per. * : new file. * : from glibc 1.06.4. * : from glibc 1.06.4. * : from glibc 1.06.4 with patches for Linux. Mon Jul 12 19:55:03 1993 H.J. Lu (hlu@nighthawk) * : define FNDEALY as O_NDELAY if it is defined. * grp/initgroups.c: from glibc 1.06.4. [! NGROUPS_MAX || NGROUPS_MAX == 0]: Just return 0 and do nothing. close the file descriptor for /etc/group. * posix/ttyname.c: from glibc 1.06.4. Replace fixed-sized NAME array with static char *NAME and static size_t NAMELEN. Don't check S_ISCHR. Don't hack NAME before the loop. If need more than NAMELEN chars to hold the name, increase NAMELEN to more than big enough and malloc NAME. Save errno in local var SAVE before doing anything; restore it when returning non-error. change dirent structre fields for linux. * misc/ioctl.c: from glibc 1.06.4. Replace function_alias with: [HAVE_GNU_LD]: Use symbol_alias. [! HAVE_GNU_LD]: Write out the function; it must fetch its third arg with va_arg and then call __ioctl. Thu Jul 8 19:02:40 1993 H.J. Lu (hlu@nighthawk) * ./libc-linux/inet/inet_net.c: don't mask out hostid for subnet. * ./libc-linux/regex/regex.c: (re_comp ():) return if *s == '\0'. * ./libc-linux/string/strsignal.c: fix typos in comments. * ./libc-linux/string/strerror.c: check errnum >= sys_nerr instead of just errnum > sys_nerr. * ./libc-linux/posix/execvp.c: root should be able to run anything executable by anyone. * ./libc-linux/iosteram: use iostream in libg++ 2.4. * ./libc-linux/iostream/filebuf.C: filebuf::xspunts () calls streambuf::xspunts () instread of streambuf::spunts (). fix filebuf::open () to allow setting up a filebuf on an open file descriptor for fdopen (). * ./libc-linux/iostream/ioprivate.h: add some defaults for __linux__. * ./libc-linux/iostream/procbuf.h: add _exit_status and exit_status () in procbuf class. * ./libc-linux/iostream/procbuf.C: comment out signal stuff; turn on close-on-exec in parent; use waitpid (); check errno == EINTR; save the exit status of the child. * ./libc-linux/iostream/iomanip.h: in template class iapp, change iapp(ostream& (*f)(istream&,TP)) : _f(f) {} to iapp(istream& (*f)(istream&,TP)) : _f(f) {} * ./libc-linux/iostream/stdstrbufs.C: don't include if defined(_STDIO_USES_IOSTREAM) or defined(USE_FILEBUF). if defined(_STDIO_USES_IOSTREAM) or defined(USE_FILEBUF), don't define stdiobuf-bases objects. * ./libc-linux/iostream/_sbuf.C: aliases for old _cin_sbuf, _cout_sbuf and _cerr_sbuf. * ./libc-linux/iostream/Makefile: remove __flow.o * ./libc-linux/jump/libc/jump.funcs: ./libc-linux/jump/libc.lite/jump.funcs: change the filename of ___underflow and ___overflow from __flow to streambuf. change the filename of sysd-stdio to tempname. * ./libc-linux/iostream/stdio/sysd-stdio.c: removed. * ./libc-linux/iostream/stdio/tempname.c: get ./sysdeps/posix/tempname.c from glibc 1.06.4 and rewrite it based on ./libc-linux/iostream/stdio/sysd-stdio.c. * ./libc-linux/iostream/stdio/Makefile: change sysd-stdio.o to tempname.o. Thu Jul 1 17:17:28 1993 H.J. Lu (hlu@nighthawk) * version 4.4.1 is released. Mon Jun 28 08:51:00 1993 H.J. Lu (hlu@nighthawk) * version 4.4.0f is released. * update to tools 2.7.5. * ./libc-linux/jump/libm/jump.params: ./libc-linux/jump/libm/jump.params.build: Change back to GOT=0x00000100. You have to use tools newer than 2.7.4. * ./libc-linux/jump/libc/jump.vars: ./libc-linux/jump/libc.lite/jump.vars: change _BC, _PC and _UP to 'C' from 'D'. Sat Jun 26 19:02:04 1993 H.J. Lu (hlu@nighthawk) * version 4.4.0e is released. * : move #define __USE_BSD_SIGNAL before #include_next . * ./libc-linux/Makefile: build everything other than libc.so.x.y with -lgcc -lc -lgcc. * ./libc-linux/jump/libm/jump.params: ./libc-linux/jump/libm/jump.params.build: Change to GOT=0x00001000. Old binaries using GOT in libm may break. I don't think many use it. Sat Jun 19 13:30:26 1993 H.J. Lu (hlu@nighthawk) * version 4.4.0d is released. Thu Jun 17 19:32:11 1993 H.J. Lu (hlu@nighthawk) * ./libc-linux/sysdeps/linux/i386/Makefile: fix typos. * ./libc-linux/jump/libc/jump.funcs: ./libc-linux/jump/libc.lite/jump.funcs: add `_' to the names of new functions. Wed Jun 16 09:33:48 1993 H.J. Lu (hlu@nighthawk) * update to tools 2.7.4. * ./libc-linux/jump/libc/jump.ignore: ./libc-linux/jump/libc.lite/jump.ignore: delete __GLOBAL_$I$fprintf and __GLOBAL_$I$sync_with_stdio__3iosi. Fri Jun 11 17:27:48 1993 H.J. Lu (hlu@nighthawk) * ./libc-linux/misc/Makefile: add ftok.o. * ./libc-linux/misc/ftok.c: new file for ftok (). * ./libc-linux/sysdeps/linux/i386/Makefile: add msgctl.o, msgget.o, msgrcv.o msgsnd.o semctl.o semget.o semop.o, shmat.o, shmctl.o, shmdt.o amd shmget.o. * ./libc-linux/sysdeps/linux/i386/msgctl.c: * ./libc-linux/sysdeps/linux/i386/msgget.c: * ./libc-linux/sysdeps/linux/i386/msgrcv.c: * ./libc-linux/sysdeps/linux/i386/msgsnd.c: * ./libc-linux/sysdeps/linux/i386/semctl.c: * ./libc-linux/sysdeps/linux/i386/semget.c: * ./libc-linux/sysdeps/linux/i386/semop.c: * ./libc-linux/sysdeps/linux/i386/shmat.c: * ./libc-linux/sysdeps/linux/i386/shmctl.c: * ./libc-linux/sysdeps/linux/i386/shmdt.c: * ./libc-linux/sysdeps/linux/i386/shmget.c: new files for SYSV IPC. * ./libc-linux/jump/libc/jump.funcs: ./libc-linux/jump/libc.lite/jump.funcs: new entries: ftok, msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop, shmat, shmctl, shmdt and shmget. Fri Jun 3 10:20:19 1993 H.J. Lu (hlu@nighthawk) * version 4.4.0c is released. source code patch only. * ./libc-linux/Makerules: add .S -> .s. * ./libc-linux/sysdeps/linux/fsync.S: new file. need the latest 0.99 pl 10 or above to use. * ./libc-linux/sysdeps/linux/fsync.c: removed. Thu Jun 3 20:26:29 1993 H.J. Lu (hlu@nighthawk) * version 4.4.0b is released. * update to tools 2.7.3. Sun May 30 23:40:19 1993 H.J. Lu (hlu@nighthawk) * update to tools 2.7.2. * ./libc-linux/Makeconfig: set i486 as default. * ./libc-linux/Makefile: add libgcc.a to the math shared library for __main (). * ./libc-linux/gcc/Makefile: add __main.o, _exit.o and _ctors.o to the shared libgcc.a. * ./libc-linux/jump/libc/jump.ignore: ./libc-linux/jump/libc.lite/jump.ignore: add ___main, ___do_global_ctors, ___do_global_dtors and __exit_dummy_decl. Fri May 28 15:04:02 1993 H.J. Lu (hlu@nighthawk) * : fix it for 0.99 pl 10. * : include the gcc's limits.h only if it is not included already. * : only declare `alloca' if __STDC__ is defined or __GNUC__ < 2. `alloca' is the built-in function for gcc 2.x. * : add signaling NaNs, double and float. Sun May 23 16:45:45 1993 H.J. Lu (hlu@nighthawk) * ./libc-linux/Makefile: add gcc to the static dirs. Sat May 22 13:50:46 1993 H.J. Lu (hlu@nighthawk) * version 4.4.0a is released. * ./libc-linux/iostream/filebuf.C: (filebuf::sync ()): don't do sys_seek () if not in putback mode. WARNING: it may break something, especially the unlimited put back operations. I am still waiting for reply from Per. * : add signal and quiet NaN as well as float version. * ./libc-linux/sysdeps/linux/i386/math/ __infnan.c: return signal NaN. * ./libc-linux/sysdeps/linux/i386/math: (acos.c, acosh.c, asin.c, atanh.c, log.c, log10.c, pow.c, sqrt.c): change the return values for domain errors to IEEE conforming values. from flebbe@pluto.tat.physik.uni-tuebingen.de (Olaf Flebbe). Fri May 21 14:27:12 1993 H.J. Lu (hlu@nighthawk) * ./libc-linux/string/strncscmp.c: ./libc-linux/string/strcasecmp.c: change GPL to GLGPL. Thu May 20 23:25:25 1993 H.J. Lu (hlu@nighthawk) * version 4.4 is released. * ./libc-linux/sstream/Makefile: ./libc-linux/rpc/Makefile: ./libc-linux/inet/Makefile: add -I../include. * ./libc-linux/compat/i386/Makefile: ./libc-linux/sysdeps/i386/Makefile: ./libc-linux/sysdeps/linux/Makefile: add -I../../include. * : include . * ./libc-linux/rpc: (get_myaddr.c, pmap_getmaps.c, pmap_getport.c and pmap_rmt.c): include . it has no effect to RPC in the current Linux C library. * ./libc-linux/include: new directory for the kernel header files which are needed to compile the Linux C library but not present in the current public kernel source. (1) linux/in.h: new header file from the kernel 0.99 pl 10. (2) linux/if.h: dummy. we don't really need stuff inside that file. (3) linux/untsname.h: new header file from the kernel 0.99 pl 10. Wed May 19 22:51:06 1993 H.J. Lu (hlu@nighthawk) * ./libc-linux/Makefile: make libgcc.a while building the static library. * ./libc-linux/Makeconfig: change gcc version to 2.4.0. * : remove #if 0 and define _LIBC_LIMITS_H_ * ./libc-linux/crt/[g]crt0.S: ./libc-linux/sysdeps/linux/i386/__load.c: add copyright. Mon May 17 10:49:42 1993 H.J. Lu (hlu@nighthawk) * : (__MAX_ERRNO, __CHECK_RETURN_ADDR, __check_errno): defined. In case of returning a memory address, negative values may not mean error. * ./libc-linux/sysdeps/linux/i386/mmap.c: define __CHECK_RETURN_ADDR before include . Sun May 16 12:48:00 1993 H.J. Lu (hlu@nighthawk) * version 4.3.3g is released. Sat May 15 23:23:45 1993 H.J. Lu (hlu@nighthawk) * ./libc-linux/compat/Makefile: add i386 in clean target. * copy libgcc2.c to ./libc-linux/gcc from ss-930515. Mon May 10 23:52:25 1993 H.J. Lu (hlu@nighthawk) * version 4.3.3f is released. * ./libc-linux/misc/syslog.c: use NUL as a message delimiter. * : change _SYSEXIST_H to _SYSEXITS_H. * : remove __GNU_LIBRARY__ and __bits. Sun May 9 14:33:04 1993 H.J. Lu (hlu@nighthawk) * ./libc-linux/sysdeps/linux/i386/math/pow.c: return 0.0 for pow (x, 1.0). Sat May 8 10:22:11 1993 H.J. Lu (hlu@nighthawk) * and : include . * : add /* The `sig' bit is set if the interrupt on it * is enabled via siginterrupt (). */ extern sigset_t _sigintr; * : only declare `memcpy' and `memcmp' if __STDC__ is defined or __GNUC__ < 2. `memcpy' and `memcmp' are built-in functions for gcc 2.x. * ./libc-linux/libbsd/roundup.c: deleted. ditto Makefile. Fri May 7 14:25:20 1993 H.J. Lu (hlu@nighthawk) * ./libc-linux/sbin: new directory for special static linked binaries. * ./libc-linux/Makefile: target `clean' includes `sbin'. * : from gnu regex 0.12. * ./libc-linux/regex/regex.c: from gnu regex 0.12 + fixes. * add _sigintr in ./libc-linux/bsd/sigint.c to keep track which signal is set to allow interrupt. * remove inline function __bsd_signal () from . * ./libc-linux/sysdeps/linux/__bsd_sig.c: new file for __bsd_signal (). do not restart the signal handler if _sigintr is set by siginterrupt (). * ./libc-linux/sysdeps/linux/Makefile: add __bsd_sig.o. * add ___bsd_signal to jump/libc/jump.funcs and jump/libc.lite/jump.funcs. * add __sigintr to jump/libc/jump.vars and jump/libc.lite/jump.vars. Thu May 6 10:50:32 1993 H.J. Lu (hlu@nighthawk) * version 4.3.3e is released. * fix ./libc-linux/termcap/termcap.c. thanks to Orest Zborowski. * fix ./jump/libc/jump.funcs and ./jump/libc.lite/jump.funcs for new __gethostname () and old __gethostname (). * add __old__ghn.c to ./libc-linux/compat/i386 for old __gethostname (). Wed May 4 13:30:49 1993 H.J. Lu (hlu@nighthawk) * version 4.3.3d1 is released. * define roundup(x,y) in and . * ./libc-linux/sysdeps/linux/__gethstnm.c: use __uname () instead of uname (). * add prefix "__" to all variables in inline functions in . Tue May 4 14:32:59 1993 H.J. Lu (hlu@nighthawk) * version 4.3.3d is released. Mon May 3 14:21:06 1993 H.J. Lu (hlu@nighthawk) * bump up the version number to 4.4: ./libc-linux/jump/lib[cm][.lite]/jump.params[.build]. * install and from gnu make 3.64. * copy fnmatch.c and glob.c from gnu make 3.64 to ./libc-linux/posix. * add ___glob_closedir_hook, ___glob_opendir_hook and ___glob_readdir_hook to jump/libc/jump.funcs and jump/libc.lite/jump.funcs. * install from Michael Haardt. (Eric Allman ) Sun May 2 13:52:12 1993 H.J. Lu (hlu@nighthawk) * apply patch from Branko Lankester for ./libc-linux/profil.c to handle RA_RESTART in the new kernel (0.99.8 and newer). * modify ./libc-linux/sysdeps/linux/signal.c: mask out SA_RESTART. * modify (__bsd_signal): set sa_flags = SA_RESTART if SA_RESTART is defined. Thu Apr 29 15:59:34 1993 H.J. Lu (hlu@nighthawk) * ./libc-linux/Makefile and ./libc-linux/gcc: use libgcc.a from gcc 2.4 snapshot, ss-930426. * cleanup ./libc-linux/Makefile. * ./libc-linux/crt/[g]crt0.S: change 387 control word to 0x1372 from 0x1272. Use 80 bits for FP in 387. * ./libc-linux/Makefile: install libmcheck.a if DEBUG == true. * apply the patch from Rick Sladkey to fix the NGRPS bug in ./libc-linux/rpc/auth_unix.c when NGROUPS > NGRPS. Wed Apr 28 23:42:11 1993 H.J. Lu (hlu@nighthawk) * , and : change __inline__ to __inline. * in ./libc-linux/sysdeps/linux, change uname.S to __uname.S. add aliases for uname (). modify Makefile for that. * modify : add __uname () and a new filed domainname to struct utsname. * fix ./jump/libc/jump.funcs and ./jump/libc.lite/jump.funcs for new __uname () and old __uname (). * add __old___uname.c to ./libc-linux/compat/i386 for old __uname (). * add SYS_sigreturn, SYS_clone and SYS_setdomainname to . * libc-linux/sysdeps/linux: add setdnnm.c and getdnnm.c. modify Makefile for that. * add setdomainname () and getdomainname () to . * need setdomainname () support in kernel. Sat Apr 24 23:53:03 1993 H.J. Lu (hlu@nighthawk) * ./libc-linux/inet: inet_net.c: copy inet_addr.c, mask out hostid. Sat Apr 24 23:23:13 1993 H.J. Lu (hlu@nighthawk) * version 4.3.3c is released. * appy patch for from Rick Sladkey. fix union __wait. Thanks Rick. * modify ./libc-linux/sysdeps/linux/i386/__load.c: we append DEFAULT_LD_LIBRARY_PATH to LD_LIBRARY_PATH if LD_LIBRARY_PATH is ever used. Thanks Ted. Fri Apr 23 13:01:30 1993 H.J. Lu (hlu@nighthawk) * modify ./libc-linux/posix/cfmakeraw.c according to the suggestions from Bruce Evans. Thanks Bruce. Please report the problems to H.J. Lu (hlu@eecs.wsu.edu). * bump up the version number to 4.3.4: ./libc-linux/jump/lib[cm][.lite]/jump.params[.build]. * apply patch for ./libc-linux/rpc/clnt_udp.c from Rick Sladkey. fix a shadowed variable. * turn off GETOPT_COMPAT again in ./libc-linux/posix/Makefile for ./libc-linux/posix/getopt.c. Thu Apr 22 23:51:30 1993 H.J. Lu (hlu@nighthawk) * remove the leading '/' in the name of the shared libc image: ./libc-linux/jump/libc[.lite]/jump.params[.build]. * add obstack.c from the FSF to ./libc-linux/misc. modify ./libc-linux/Makefile for obstack.o. * add from the FSF with minor modifications. * add "_obstack" to jump/libc/jump.vars and jump/libc.lite/jump.vars. * add __obstack_allocated_p, __obstack_begin, __obstack_begin_1, __obstack_free, __obstack_newchunk and _obstack_free to jump/libc/jump.funcs and jump/libc.lite/jump.funcs. Wed Apr 21 23:11:40 1993 H.J. Lu (hlu@nighthawk) * turn on GETOPT_COMPAT again in ./libc-linux/posix/Makefile for ./libc-linux/posix/getopt.c which was turned off by Roland. should be phased out later. * modify ./libc-linux/sysdeps/linux/i386/__load.c: we use the environment LD_LIBRARY_PATH if the binary is not setuid nor setgid, otherwise use DEFAULT_LD_LIBRARY_PATH. * fix MINDOUBLE and MINFLOAT in . we use the denormals now. * add union i387_float to . Tue Apr 20 13:09:32 1993 H.J. Lu (hlu@nighthawk) * version 4.3.3b is released. * add and define UL_GETFSIZE and UL_SETFSIZE. modify ./libc-linux/sysdeps/linux/i386/ulimit.c: 1. takes UL_GETFSIZE and UL_SETFSIZE. 2. change ulimit () to long ulimit (int cmd, ...); * modify ./libc-linux/sysdeps/linux/i386/__load.c: we search the environment LD_LIBRARY_PATH for each shared image. we use DEFAULT_LD_LIBRARY_PATH if 1. USR_LD_LIBRARY_PATH == NULL or 2. set_ugid != 0 && the shared image name begins with '/'. Rational: We only care some functions in the C library. Xterm is often setuid root so that it can chown its tty properly. We still want to allow the user to select Xaw3d (for 3d scroll bars and such). So we check LD_LIBRARY_PATH on shared image by shared images cases. * use GNU termcap 1.2 with support for TIOCGWINSZ. * fix a memory leak in ./libc-linux/iostream/floatconv.C. Sat Apr 17 13:09:32 1993 H.J. Lu (hlu@nighthawk) * define _IEEE 1 in for i386. * remove the leading '/' in the name of the shared math image: ./libc-linux/jump/libm/jump.params[.build]. * add ./libc-linux/sstream: a BSD scoket stream. Not fully supported under Linux due to the incomplete networking support. The demos ran fine under Ultrix 4.2. * in ./libc-linux/iostream: modify stdstrbufs.C and __flow.C for other systems other than Linux. * change , and such that #ifndef NULL #ifdef __cplusplus #define NULL 0 #else #define NULL ((void *)0) #endif #endif Tue Apr 15 15:13:29 1993 H.J. Lu (hlu@nighthawk) * define fd_mask as unsigned long in . * define howmany(x,y) in and . fix MAXPATHLEN and NOFILE in . * copy ./libc-linux/iostream/iomanip.h from sstream, Mayan Moudgill. /usr/g++-include/iomanip.h: ditto. * in ./libc-linux/iostream/stdio: fix typos in getw.C, putw.C, fread.C and fwrite.C. Tue Apr 14 16:13:29 1993 H.J. Lu (hlu@nighthawk) * remove strsep.o from ./libc-linux/libbsd/Makefile. Tue Apr 14 06:13:29 1993 H.J. Lu (hlu@nighthawk) * version 4.3.3a1 is released. * fix typos in ./libc-linux/termcap/tparam.c. * fix typos in ./libc-linux/jump/libc/jump.vars and ./libc-linux/jump/libc.lite/jump.vars. * fix a typo in ./libc-linux/sysdeps/linux/_errlist.c. * replace ./libc-linux/string/strsep.c from jrs@world.std.com (Rick Sladkey). * fix ./libc-linux/jump/Makefile for pdksh. Tue Apr 13 22:13:29 1993 H.J. Lu (hlu@nighthawk) * version 4.3.3a is released. * fix procbuf/stdio in ./libc-linux/iostream. 1. ./libc-linux/iostream/procbuf.h: add _exit_status and exit_status (). 2. ./libc-linux/iostream/procbuf.C: comment out signal stuff; turn on close-on-exec in parent; use waitpid (); check errno == EINTR; save the exit status of the child. 3. ./libc-linux/iostream/stdio/popen.C: borrow code from fclose () and return the exit status of the child. * copy ./libc-linux/iostream/procbuf.h to /usr/g++-include. * check if return of fcntl () == -1 in ./libc-linux/iostream/filebuf.C. Mon Apr 12 11:45:08 1993 H.J. Lu (hlu@nighthawk) * update ./libc-linux/posix/getopt.c from Roland for "optopt". add "optopt" to jump/libc/jump.vars and jump/libc.lite/jump.vars. * update setjmp from glibc 1.05 with bug fixes for i386: 1. rename ./libc-linux/sysdeps/i386/sigsetjmp.c to ./libc-linux/compat/i386/__old_sigsj.c and change the function name to __old_sigsetjmp (). 2. in jump/libc/jump.funcs and jump/libc.lite/jump.funcs: change _sigsetjmp to __old_sigsetjmp and add __sigjmp_save (). 3. . files affected: 1. ./libc-linux/setjmp: Makefile, __sj_save.c, _setjmp.c, siglongjmp.c, _longjmp.c, longjmp.c 2. sysdeps/i386: Makefile, __setjmp.c * remove ./libc-linux/jumptable1 and ./libc-linux/jumptable1 from ./libc-linux/Makefile. files affected: 1. ./libc-linux/ctype: Makefile, ctype-info.c. 2. ./libc-linux/curses: Makefile, curses.c, unctrl.c. 3. ./libc-linux/gdbm: global.c. 4. ./libc-linux/inet: herror.c, res_init.c, rexec.c. 5. ./libc-linux/iostream: Makefile, stdstrbufs.C. 6. ./libc-linux/iostream/stdio: emulate.C. 7. ./libc-linux/misc: Makefile, __environ.S, errno.S. 8. ./libc-linux/misc: Makefile, __environ.S, errno.S. 9. ./libc-linux/posix: getopt.c. 10. ./libc-linux/regex: regex.c. 11. ./libc-linux/rpc: Makefile, rpc_comdata.c. 12. ./libc-linux/sysdeps/linux: Makefile, _errlist.c, _siglist.c. 13. ./libc-linux/sysdeps/linux/i386: __brk.c. 14. ./libc-linux/sysdeps/linux/i386/math: lgamma.c. 15. ./libc-linux/termcap: termcap.c. 16. ./libc-linux/time: bsdtime.c. modify jump/libc/jump.vars, jump/libc.lite/jump.vars and jump/libm/jump.vars for those changes. * increase size of "svc_fdset" in jump/libc/jump.vars and jump/libc.lite/jump.vars to 0x40 bytes. move it to a new location. Fri Apr 9 16:40:43 1993 H.J. Lu (hlu@nighthawk) * add "extern int optopt;" to . * in ./libc-linux/sysdeps/linux, change statfs.S to __statfs.S and fstatfs.S to __fstatfs.S. add aliases for statfs () and fstatfs.(). modify Makefile for that. * modify . fix ./jump/libc/jump.funcs and ./jump/libc.lite/jump.funcs * use __statfs ()/__fstatfs () for _PC_NAME_MAX in ./libc-linux/sysdeps/linux/__fpathconf.c and ./libc-linux/sysdeps/linux/__pathconf.c. * apply fix from junio@twinsun.com (Junio Hamano) to ./libc-linux/termcap/tparam.c. ------------ In comp.os.linux, Heiko Bobzin writes: I tried to write a termcap-entry for my ADM3a-based terminal ! The problem I have concerns cursor-positioning: The ESC-sequence should be: ESC = y x where x = (char)row + \040 and y = (char)col + \040 I thought it must be 'cm=\E=%+ %+ ,' but that fails: !!! The eighth bit is ALWAYS set in the 'x' and 'y' characters !!! All other characters are sent as expected. It indeed is caused by the termcap routine (tparam1 called from tgoto) used in GNU emacs and GNU termcap (hence linux libc). The intention of the original code seems to avoid putting '\0' in the encoded string, but it is a little too eager to do so and screws up other cases. -junio ----------- * use /bin/shell to get pwd in ./libc-linux/Makeconfig. * in ./libc-linux/inet/ruserpass.c, use pwd to get username when getlogin () fails. fix a memory leak. Sun Apr 4 12:37:41 1993 H.J. Lu (hlu@nighthawk) * version 4.3.3 is released. Fri Apr 2 10:13:57 1993 H.J. Lu (hlu@nighthawk) * fix and : include only if __STDC__ is defined. Thu Apr 1 13:53:19 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2i is released. Tue Mar 30 15:23:22 1993 H.J. Lu (hlu@nighthawk) * modify ./libc-linux/termcap/termcap.c for broken TIOCGWINSZ. make sure ws.ws_row and ws.ws_col are not zero. Mon Mar 29 15:40:05 1993 H.J. Lu (hlu@nighthawk) * in ./libc-linux/Makefile, fix a typo. Sun Mar 28 11:59:01 1993 H.J. Lu (hlu@nighthawk) * from Bruce Evans with a few changes: ./libc-linux/posix/getcwd.c: 'dirstream' was not being closed when the buffer was too small (try size 3 in /tmp). While fixing this I noticed several other bugs with resources not being freed, and fixed a couple. See the XXX comment for more details. ./libc-linux/posix/execl.c: ./libc-linux/posix/execle.c: ./libc-linux/posix/execlp.c: Cases where argv [0] == NULL and argc > 8192 were botched. Sat Mar 27 13:54:22 1993 H.J. Lu (hlu@nighthawk) * add -m486 to LDFLAGS if I486 = true in ./libc-linux/Makefile. You need the latest binutils.tar.z for that. Sat Mar 27 11:54:22 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2h1 is released. Fri Mar 26 23:15:08 1993 H.J. Lu (hlu@nighthawk) * fix __gethostname () type and include in ./libc-linux/sysdeps/linux/__gethstnm.c. * clean up libc-linux/malloc/Makefile. * get libc-linux/malloc-930326 from Mike Haertel, mike@cs.uoregon.edu. remove libc-linux/malloc-930325. * modify jump/libc/jump.vars and jump/libc.lite/jump.vars to undefine __aligned_blocks, ___morecore and __mb_shift * modify jump/libc/jump.ignore and jump/libc.lite/jump.ignore to add __aligned_blocks, ___morecore and __mb_shift * change libc-linux/malloc-930325/valloc.c from Mike Haertel, mike@cs.uoregon.edu. * restore libc-linux/malloc-930325/malloc.h from Mike Haertel, mike@cs.uoregon.edu. * remove libc-linux/malloc-930325/memalign.c from libc-linux/malloc, which is a SunOS invention and is not in ANSI C, POSIX 1003.1, or 4.3BSD. You now have to use libg.a to use it. * modify libc-linux/malloc-930325/Makefile. * modify jump/libc/jump.funcs and jump/libc.lite/jump.funcs to undefine memalign. * add libc-linux/malloc-930325/README.Linux. Fri Mar 26 16:15:08 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2h is released. * remove the internal malloc stuff from . * in libc-linux/malloc, add -I. -I. -I. in Makefile and make libmcheck.a only if DEBUG is defined; apply fix from Mike Haertel, mike@cs.uoregon.edu for malloc.c, malloc.h and realloc.c. * new directory libc-linux/malloc-930325, a fast malloc implementation from Mike Haertel, mike@cs.uoregon.edu, which is the basis of GNU malloc. This version differs from the GNU version in that it does not support debugging hooks, and does not record statistics. Therefore it is slightly faster. we use it in libc.a and libc_p.a. the GNU malloc is kept in libg.a. We need speed. * modify ./libc-linux/Makefile: use ./libc-linux/malloc only if DEBUG is defined (for libg.a) and for the other libraries use ./libc-linux/malloc-930325. * modify jump/libc/jump.funcs and jump/libc.lite/jump.funcs to undefine mcheck, mtrace, mstats and _free_internal. You now have to use libg.a to use them. Thu Mar 25 23:14:31 1993 H.J. Lu (hlu@nighthawk) * add __vt$xxxxxxxx from fstream.o in iostream to jump/libc/jump.vars and jump/libc.lite/jump.vars, and pad the size of them to 0x50 bytes. delete them from jump/libc/jump.ignore and jump/libc.lite/jump.ignore. * add __old_libc.c and __old_libm.c to ./libc-linux/compat for backward compatility. Also change ./libc-linux/Makefile. Tue Mar 23 23:13:35 1993 H.J. Lu (hlu@nighthawk) * modify ./libc-linux/misc/ldexp.c from glibc 1.05. * include in for CLK_TCK. * siginterrupt () (sigint.c) is added: libc-linux/bsd/sigint.c and libc-linux/bsd/Makefile. add siginterrupt () to the ends of ./libc-linux/jump/libc/jump.funcs and ./libc-linux/jump/libc.lite/jump.funcs. Mon Mar 22 16:58:07 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2g1 is released. * fix a stupid typo in ./libc-linux/Makefile which will prevent __load.o being included in libc.sa. Sun Mar 21 17:41:26 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2g is released. Sat Mar 20 12:09:48 1993 H.J. Lu (hlu@nighthawk) * change ./libc-linux/Makefile: get __load.o from the static libc.a. * include instead of in ./libc-linux/sysdeps/linux/nlist.c. * fix ./libc-linux/inet/inet_addr.c. * undo sa_flags = SA_RESTART for bsd singnal in . * undo sa_flags = SA_RESTART in ./libc-linux/posix/system.c ./libc-linux/gmon/profil.c Fri Mar 19 17:41:26 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2f is released. Wed Mar 17 15:07:42 1993 H.J. Lu (hlu@nighthawk) * fix typos in ./libc-linux/termcap/termcap.c. * in ./libc-linux/sysdeps/linux/i386/mmap.c, mmap () just returns _mmap (). * add fsync () to the ends of ./libc-linux/jump/libc/jump.funcs and ./libc-linux/jump/libc.lite/jump.funcs. add it to and remove it from libc-linux/libbsd. * add _validuser () to the ends of ./libc-linux/jump/libc/jump.funcs and ./libc-linux/jump/libc.lite/jump.funcs. remove it from ./libc-linux/jump/libc/jump.ignore. and ./libc-linux/jump/libc.lite/jump.ignore. * in , rename SYS_syslog to sys_klog. add SYS_sysinfo, SYS_ipc and SYS_fsync. they are not implemented in the stock kernel yet. * in ./libc-linux/sysdeps/linux add a fake fsync () [fync ()] in fsync.c and Makefile. change to system call later. Tue Mar 16 16:09:23 1993 H.J. Lu (hlu@nighthawk) * set sa_flags = SA_RESTART for bsd singnal in . need 0.99 pl8 for that. * set sa_flags = SA_RESTART in ./libc-linux/posix/system.c ./libc-linux/gmon/profil.c Mon Mar 15 23:27:24 1993 H.J. Lu (hlu@nighthawk) * fix warning in . * fix regcomp () in ./libc-linux/regex/regex.c: add preg->allocated = 0; preg->used = 0; * apply fix for ./libc-linux/iostream/floatconv.C from Per Bothner. define IEEE_8087 if i386 is defined and a small bug fix. * restore ./libc-linux/iostream/ioprivate.h. Fri Mar 12 23:19:47 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2e is released. * apply the fix for XDR representation of floats and doubles on i386 from jrs@world.std.com (Rick Sladkey), ./libc-linux/rpc/xdr_float.c. * apply termcap patches from obz@Kodak.COM (Orest Zborowski) to termcap/termcap.c. o Fixed incorrect behavior when TERMCAP was set but didn't match TERM. This was a matter of fixing a missing else clause. o Added the ability to read the number of lines/columns from the current tty and set them in the capability string returned. This is the behavior that Sun has, and allows curses applications to take advantage of the entire screen. * modify ./libc-linux/Makecofig for libbsd.a. Thu Mar 11 23:19:47 1993 H.J. Lu (hlu@nighthawk) * add "regex" to DIRS in jumptable1/Makefile if LITE is defined. * change WTMP_FILE to "/usr/adm/wtmp" in . * modify for BSD codes and move old one to . * in ./libc-linux/sysdeps/linux/i386, modify __wait.c, __wait3.c and __waitpid.c for new . * add a new diretory /usr/include/bsd with lots of new header files for BSD codes. is not included. * add lots of new files to /usr/include/rpcsvc. yppasswd.x is left out since it is not compatible with the current . * copy , , , and from "Fred N. van Kempen" . * modify files in ./libc-linux/rpc: get_myaddr.c, pmap_getmaps.c, pmap_getport.c and pmap_rmt.c to comment out for the time being. * add ./libc-linux/libbsd from "Fred N. van Kempen" . * modify ./libc-linux/Makefile for ./libc-linux/libbsd. only build it for static library. Wed Mar 10 23:56:54 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2d is released. * fix ./libc-linux/sysdeps/linux/i386/Makefile and ./libc-linux/Makefile. * fix typos in ./libc-linux/iostream/filebuf.C. don't write any code at 3:30 am in the morning :-(. I am too aggressive in fdopen (). relax a little, only check O_APPEND ("a"). * should we close the file descriptor on a stream obtained with fdopen ()? iostream/stdio/fdopen.C. the current scheme is YES. * copy ./jump/libc/jump.ignore to ./jump/libc.lite. * fix two typos in ./jump/libc.lite/jump.vars. Wed Mar 10 13:56:54 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2c is released. Tue Mar 9 23:56:54 1993 H.J. Lu (hlu@nighthawk) * fix libc-linux/iostream/filebuf.C: filebuf::xspunts () calls streambuf::xspunts () instread of streambuf::spunts (). filebuf::overflow() check if read buffer is full when changing from get mode to put mode. * change libc-linux/Makeconfig. only make libalias.a for the shared library. * remove minix fs macro from . getmntent () in libc-linux/mntent/mntent.c return NULL if no filesystem type is provided. * remove . * fix libc-linux/sysdeps/linux/i386/readir.c. POSIX says that readdir() does not change errno when there are no more entries. * remove "__" from networking routines in . change libc-linux/jump/libc/jump.funcs and libc-linux/jump/libc.lite/jump.funcs. Mon Mar 8 21:56:54 1993 H.J. Lu (hlu@nighthawk) * fix libc-linux/sysdeps/linux/i386/sysdep.h for new cpp in gcc, add ##. * remove error checking in string/strerr.c. trust sprintf () :-). Sun Mar 7 21:56:54 1993 H.J. Lu (hlu@nighthawk) * According to POSIX, directory streams should be closed when exec. "Anna Pluzhnikov" (Paul Pluzhnikov?) fixes ./libc-linux/dirent/opendir.c. * add FILE * check for some stdio functons. files in ./libc-linux/iostream/stdio changed: fgetc.C, fputc.C, fputs.C and macros.C. Sun Mar 7 11:56:54 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2b is released. * modify and for strict ANSI C, -pedantic. * fix filebuf::open () in iostream/filebuf.C to allow setting up a filebuf on an open file descriptor for fdopen (). * call filebuf::open (NULL, mode) in iostream/stdio/fdopen.C. * fix ./libc-linux/mntent/mntent.c from "Fred N. van Kempen" for comment lines in /etc/fstab. Sat Mar 6 22:20:08 1993 H.J. Lu (hlu@nighthawk) * add some functions to libm.a. add new directory: ./libc-linux/math. add new files in ./libc-lunux/sysdeps/linux/i386/math: __copysign.c, __infnan.c, __isinf.c, __isnan.c, __rint.c. add them to the shared math library, jump/libm/jump.funcs. modify ./libc-linux/Makefile for those additions. add those new declarations to . add two new header files and . change ./libc-lunux/sysdeps/linux/i386/math/drem.S to __drem.S and add an alias to drem (). NOTE: most of the new header files and functions are from glibc 1.05. * not to use the general syscall macros for _exit (). move libc_exit.c to ./libc-linux/sysdeps/linux/i386. * add -Wstrict-prototypes -Wmissing-prototypes to ./libc-linux/Makeconfig. Fri Mar 5 23:32:27 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2a is released. * change all "linux" to "__linux__" in some header files. * add the YP header files. no library code yet. need more kernel support. * not to use the general syscall macros for __sigsetmask() and __siggetmask(). move __siggtmsk.c and __sigstmsk.c to ./libc-linux/sysdeps/linux/i386. * add IEEE_8087 to iostream/ioprivate.h for correct strtod () in libc-linux/iostream/floatconv.C. That fixes a very serious FP bug. * fix string/strerr.c, not to null terminate the string. * fix char * strstr (const char *s1, const char *s2); in string/strstr.c. If s2 points to a string with zero length, the function returns s1. Thu Mar 4 14:52:04 1993 H.J. Lu (hlu@nighthawk) * version 4.3.2 is released. rename version 4.3.1f to 4.3.2. Wed Mar 3 16:12:12 1993 H.J. Lu (hlu@nighthawk) * version 4.3.1f is released. * change Makefiles for stupid SVR3. Tue Mar 2 13:42:24 1993 H.J. Lu (hlu@nighthawk) * change volatile to __volatile__ in . * fix dirent/alphasort.c, dirent/scandir.c and : the correct alphasort () is: extern int alphasort ( const struct dirent * const *, const struct dirent * const * ); thanks to alfie@dcs.warwick.ac.uk (Nick Holloway). * change __PATH_ETC to __PATH_ETC_INET. change and . change __PATH_ETC_INET from "/usr/etc/inet" to "/etc/inet". change inet/gethstnmad.c. * modify libc-linux/sysdeps/linux/i386/__load.c to search /usr/lib/, /lib/, then "". change jump/*/jump.params*. * change change __PATH_ETC_INET from "/etc/inet" to "/etc" :-). Mon Mar 1 13:57:54 1993 H.J. Lu (hlu@nighthawk) * put regex back in lite.so.x.y. fix ./libc-linux/Makefile and libc-linux/jump/libc.lite/jump.*. Sun Feb 28 13:47:53 1993 H.J. Lu (hlu@nighthawk) * version 4.3.1e is released. * fix ./libc-linux/Makefile and ./libc-linux/gcc/Makefile for libgcc.sa. * make libgcc.a for i486. * fix libc.sa. Sat Feb 27 16:47:53 1993 H.J. Lu (hlu@nighthawk) * version 4.3.1d is released. Fri Feb 26 18:47:53 1993 H.J. Lu (hlu@nighthawk) * fix dirent/scandir.c from alfie@dcs.warwick.ac.uk (Nick Holloway). The 'select' parameter is allowed to be null, meaning choose all, as is the 'cmp' parameter. * add BC, PC and UP to libcurses.sa (jump/libc/jump.vars). Wed Feb 24 11:08:40 1993 H.J. Lu (hlu@nighthawk) * add .EXPORT_ALL_VARIABLES: to libc-linux/Makeconfig. * fix posix/mktemp.c: check if a templated file exists and always start from the very first letter. * change bsd/mkstemp.c: use algorithm in posix/mktemp.c directly. * add i486 support to ./crt/[g]crt0.S. * add more tests to sysdeps/linux/i386/math/test-math.c. * `remove' symbols in regex.o from jump/libc.lite/jump.funcs and jump/libc.lite/jump.vars. save the old ones in jump/libc.lite/saved. Tue Feb 23 23:23:56 1993 H.J. Lu (hlu@nighthawk) * version 4.3.1c is released. * cleanup Makefiles. * apply fix to sysdeps/linux/i386/math/cosh.S and add i486 support to libm.a. Tue Feb 23 15:23:56 1993 H.J. Lu (hlu@nighthawk) * version 4.3.1b is released. * remove ./jump/src. use tools-x.y.tar.z * add __vt$xxxxxxxx from iostream to jump/libc/jump.vars and jump/libc.lite/jump.vars, and pad the size of them by 0x40 bytes. Sun Feb 21 20:32:05 1993 H.J. Lu (hlu@nighthawk) * cleanup Makefiles. * fix sysdeps/linux/i386/math/cosh.S and add i486 support to libm.a. * reduce the jump table size and GOT size. Sat Feb 20 23:32:05 1993 H.J. Lu (hlu@nighthawk) * version 4.3.1a is released. * in change all "linux" to "__linux__" * cleanup libm.a and add support for make MATH=true [SHARED=true] * in grp/initgroups.c, close the file descriptor for /etc/group. * make "signgam" always external in * copy from gnu libc 1.05. change to : /cvt/cvt.c, ./misc/ldexp.c, ./misc/modf.c and ./sysdeps/linux/i386/math/frexp.c. * futher cleanup Makefiles. add support for make LITE=true * inc 4.3.1, h_errlist and h_nerr are put back in libc.sa. BC, UP and PC are moved from libcurses.sa to libtermcap.sa. __new_handler is put back in libgcc.sa. those may cause some troubles for binaries linked with 4.3, i.e., Xfree86 1.2. that also means 4.3 is not 100% compatible with 4.2 and 4.1. * add ".long 5" as the end of jumptable1/inet/herrlist.S for h_nerr. the real one is moved to new location. but will someone really want to change that number? * in jump/libc[.lite]/jump.ignore, those symbols in libgmon.a and libm.a are removed. h_errlist and h_nerr are also removed since they are in jump.vars now. Fri Feb 19 00:28:58 1993 H.J. Lu (hlu@yardbird) * version 4.3.1 is released. * add __tcgetattr () to . * include in ./login/getpass.c. * undefine _POSIX_SOURCE for linux in ./iostream/procbuf.C. that is done automatically under linux. * cleanup Makefiles to use GNU make and make it easier for the shared library. try to build the dll in ./libc-linux * move tools 1.9 to ./jump/src. * include in termcap/termcap.c. * replace __fcntl.c, __ioctl.c and __open.c with assembly codes. move them from libc-linux/sysdeps/linux/i386 to libc-linux/sysdeps/linux. * add PIC to * add PIC to ____sig.S, __brk.c, __sbrk.c, __select.c, __sigact.c, getprio.c, ptrace.c, readdir.c, sigsuspend.c, sysdep.h in libc-linux/sysdeps/linux/i386. PIC is not supported in libc-linux/sysdeps/linux/i386/syscall.c yet. * add ./gcc for libgcc.a from gcc 2.3.3. * add ./compat for libcompat.a. Tue Feb 16 14:42:32 1993 H.J. Lu (hlu@yardbird) * Fix libc-linux/sydeps/linux/i386/__load.c for emacs from Eric Youngdale. Mon Feb 15 09:11:20 1993 H.J. Lu (hlu@yardbird) * the Linux C library 4.3 is released. * take "const" out of "struct timeval" of select () in and libc-linux/sysdeps/lnux/i386/__select (). no need to recompile the library. Sun Feb 14 13:11:20 1993 H.J. Lu (hlu@yardbird) * in posix/sleep.c, restore the signal mask before return. some small changes to make it more reliable. Fri Feb 12 15:41:43 1993 H.J. Lu (hlu@yardbird) * make posix/sleep.c more reliable with signal blocking. * add one more check to sysdeps/linux/i386/sigsuspend.c * modify crt/gcrt0.S for dll. * take out of . fix your code if you have to. * for non-kernel header files change "linux" to "__linux__" and "i386" to "__i386__". Thu Feb 11 23:31:55 1993 H.J. Lu (hlu@yardbird) * fix iostream/streambuf.C, ungetc (c, fp) with c != char was just read. * from jrs@world.std.com (Rick Sladkey), in ./rpc, fix clnt_tcp.c, clnt_udp.c, getrpcent.c, pmap_rmt.c, svc_au_ux.c and svc_tcp.c. select () modifies its last argument, timeout. also fix posix/sleep.c when it is interrupted by a signal. * from Eric, for dynamic linking, crt/crt0.S and sysdeps/linux/i386/__load.c. Wed Feb 10 15:34:59 1993 H.J. Lu (hlu@yardbird) * include in , instead of . Thu Feb 4 11:05:57 1993 H.J. Lu (hlu@yardbird) * complete . Wed Feb 3 23:40:44 1993 H.J. Lu (hlu@yardbird) * fix sysdeps/linux/__flock.c to use F_SHLCK and F_EXLCK. * copy fnmath.[ch] from gnu tar 1.11.1. Wed Feb 3 15:44:44 1993 H.J. Lu (hlu@yardbird) * fix sigaddset (), sigdelset () and sigismember() in . Sun Jan 24 15:30:19 1993 H.J. Lu (hlu@yardbird) * fix a typo in iostream/filebuf.C. filebuf::open (filename, "a+") should set `read_write' with read_write &= _S_IS_APPENDING; * apply patches from Per for pipe error. * apply patches from Ted for posix/getcwd.c, fixing stat (x, y) -> lstat (x, y). * fixe misc/syslog.c. open things with O_NOCTTY. Mon Jan 18 12:35:37 1993 H.J. Lu (hlu@yardbird) * add _CURSES_H to . Fri Jan 8 16:22:04 1993 H.J. Lu (hlu@yardbird) * fix __sigismember() in to check of sig # is less than _NSIG. Sat Jan 2 14:00:35 1993 H.J. Lu (hlu@yardbird) * include in . * include in . * change for C++. Fri Jan 1 14:00:35 1993 H.J. Lu (hlu@yardbird) * fixe typos in . * include in and if SHADOW_PWD is defined. * make fd == 0 ok in ./bsd/mkstemp.c. * change __sigsetjmp to sigsetjmp in . * set LINES and COLS in ./jumptable1/curses/curses.c to be 0. Tue Dec 29 21:22:53 1992 H.J. Lu (hlu@yardbird) * add shadow.h. * fix checking file existence in bsd/mkstemp.c and iostream/stdio/sysd-stdio.c. * change `__bits' in `fd_set' to `fds_bits'. rpc/svc.c. * change "%E" and "%G" to be the same as "%e" and "%g". * the Linux C library 4.2 is released. Sun Dec 27 23:38:08 1992 H.J. Lu (hlu@yardbird) * use new inet/gethstnmad.c. * put libnet and librpc back into libc to avoid confusion. Sat Dec 19 13:50:23 1992 H.J. Lu (hlu@yardbird) * upgrade iostream to libgcc 2.3. add 0's before the decimal point in iostream/outfloat.C. * comment out fsync () in * add ulimit (). No support for setting break values. * use sigaction () in sleep.c. Thu Dec 3 16:17:52 1992 H.J. Lu (hlu@yardbird) * separate libnet.a and librpc.a from libc.a. * modify ./jumptable1/inet to make sure the new shared libraries are compatible with old ones. * all kinds of misc changes for backward compatibilities. It is very ugly. * massive changes to shared libraries for backward compatibilities. I don't like what I did. * move ./rpc/bindresvport.c to ./inet. Sun Nov 29 14:56:32 1992 H.J. Lu (hlu@yardbird) * fix typo in . Fri Nov 27 23:56:32 1992 H.J. Lu (hlu@yardbird) * typo in memset.c, add the 4th copy. * fix sysd-stdio.c and change TMP_MAX in to 238328. * add __stdio_gen_tempname to jump table. * fix getcwd.c. Thu Nov 26 15:56:32 1992 H.J. Lu (hlu@yardbird) * use __MALLOC_0_RETURNS_NULL in and . * add const to struct timeval of select () in and __select.c. Mon Nov 23 10:56:32 1992 H.J. Lu (hlu@yardbird) * change signal () back to unreliable, usg style. put __USE_BSD_SIGNAL back in . Sat Nov 21 10:56:32 1992 H.J. Lu (hlu@yardbird) * add fchmod () to . * fix , not include . * change for . use MALLOC_0_RETURNS_NULL in and . change extern in malloc () to static when MALLOC_0_RETURNS_NULL is not defined. * add __old_getdtablesize () to shared image. Fri Nov 20 10:56:32 1992 H.J. Lu (hlu@yardbird) * comment oout IP_OPTIONS in . Linux doesn't have it for the moment. * don't use ld -x -r on crt0.o/gcrt0.o. * change signal () to reliable, bsd style. add __USE_USG_SIGNAL to . * apply jrs@world.std.com (Rick Sladkey)'s patches for sources and header files of rpc. * change BAD_SIG to BADSIG in signal.h. * change the definitions of malloc and calloc in stdlib.h. Thu Nov 19 10:56:32 1992 H.J. Lu (hlu@yardbird) * put __old_select () back in shared image with a minor fix. Tue Nov 17 10:56:32 1992 H.J. Lu (hlu@yardbird) * delete __old_select (). * add . Sat Nov 14 10:56:32 1992 H.J. Lu (hlu@yardbird) * use alpha libg++.a 2.3 * use GNU regex 0.11. * add __muldi3 () __udivdi3 (), _udivmoddi4 and __umoddi3 () to jump table. They are used by iostream. Thu Nov 12 12:40:46 1992 H.J. Lu (hlu@yardbird) * change fd_set and FD_XXX for 0.98 pl 4. * add NFDBITS. * add __old_select () to to shared image. * fix sigaction (sig, NULL, old). Thu Nov 5 12:25:06 1992 H.J. Lu (hlu@yardbird) * add syslog.c, paths.h. It uses UDP on domain socket. It has not been supported in kernel yet. Mon Nov 2 13:58:01 1992 H.J. Lu (hlu@yardbird) * move new glob () and globfree () to new location in jump table. redirect old glob () and globfree () to __libc_changed (). * fix typo in socket functions. * add utimes, idle, insque, remque, localeconv, memfrob, memmem, nlist, getusershell, endusershell, setegid, seteuid, strfry, strsep and syscall. * change system call back to push/pop. * move syscall (), __open (), __ioctl () and __fcntl () to sysdeps/linux/i386 since they use . With push/pop, we may move them back to sysdeps/linux. Tue Oct 27 01:21:25 1992 H.J. Lu (hlu@yoda) * define TZDIR to "/usr/lib/zoneinfo" in ./time. Fri Oct 23 16:24:47 1992 H.J. Lu (hlu@yardbird) * fix signal.c. use sigaction (). * fix perror.c. * check if a file exists in iostream/stdio/sysd-stdio.c. Thu Oct 22 11:36:01 1992 H.J. Lu (hlu@yardbird) * add mkstemp (). * fix a memory leak in grpread.c. Sun Oct 18 11:08:14 1992 H.J. Lu (hlu@yardbird) * change psignal (unsigned int, ..) to psignal (int, ...). * get localeconv () from glibc 1.05. * fix const in signal.h and errno.h. Tue Oct 13 01:07:32 1992 H.J. Lu (hlu@nighthawk) * add flock (). * add utimes (), seteuid () and setegid (). * add insque () and remque (). * fix getsocketopt (), get new socketcall.h from the kernel source. Wed Oct 7 18:16:09 1992 H.J. Lu (hlu@nighthawk) * add sun rpc 4.0. * change a few header files for gcc 2.3, stdio.h. * change to and use __P instead of _ARGS. Tue Oct 6 01:01:55 1992 H.J. Lu (hlu@nighthawk) * use scandir, alphasort and ftw from glibc 1.05. * use from glibc 1.05 to replace . * system call idle was added. * the floating point output bugs, `%-xxx' stuff, were fixed. * there was a new structure for compiler: different versions of library, i.e., static, jump table and classic shared library, would be in the same directory. static verion would be libfoo.a. jump table version would be libfoo.sa and classic version would be libfoo.ca. `ld' would search for the jump table library by default. you can overwrite it by adding -static or -nojump to `ld' or 'gcc'. jump table and classic verions are not compatible with each other. and the static library is used as the last resort. * strcmp, strncmp and memcpy were fixed for unsigned char. * sun rpc 4.0 was in. * the GNU C library 1.05 was used. * use `xchg' in system calls. Fri Sep 11 13:29:05 1992 H.J. Lu (hlu@poly2) * rearrange the file structures of gcc. separate compiler from libraries and header files. Here is the new structure: 1. static libraries are in /usr/lib. 2. jump table version of shared library stubs are in /usr/lib/shlib/jump. 3. classic version of shared library stubs are in /usr/lib/shlib/nojump 4. default for gcc is jump table. the other options are -nojump and -static. -g and -pg will use the corresponding static libraries. * shared images are in a separate package. * from this release on, the gcc will follow the FSF naming. the libraries will be named after jump table version number. the current versions are gcc 2.2.2d, the Linux C library 4.1 and the Linux math library 4.0. the Linux math library won't change with the minor version number. so for all the version y.xxx's, there is only one release of math library, version `y.0'. * file list for gcc 2.2.2d, libc 4.1 and libm 4.0: 1. 222d7.TZ gcc 2.2.2d linked with jump table 4.1. it has gcc, cc1, cc1plus and cpp. it also has version dependent header files. unpack it under /. 2. lib41.tar static libraries and shared library stubs. it has lib-4.1.TZ and lib-4.1.sh. run lib-4.1.sh will install lib-4.1.TZ. do lib-4.1.sh you have to have a real sh to run it. This script is used to install the math library, soft or hard. 3. inc-4.1.TZ header files for lib 4.1. unpack it under /. You have to make two symbolic links. one from include/linux of kernel source to /usr/include/linux, another from include/asm of kernel source to /usr/include/asm. There is a file, /usr/include/linux/const.h. You have to move it to include/linux of kernel source before you make symbolic link. unpack it under /. 4. jump41.tar shared images for jump table 4.1. it has jump-4.1.TZ and jump-4.1.sh. do jump-4.1.sh to install jump-4.1.TZ. this script is used to install the shared math image, soft or hard. 5. libdp-4.1.TZ libc_p.a and libg.a. unpack it under /. 6. jump-src-4.1.TZ scripts for build jump table 4.1. almost no documentations. contributions are welcome. 7. lib-src-4.1.TZ source code for the Linux C library 4.1. * the install procedures are minimal. it didn't do much file permission fixing. fix them when you find they are wrong. * this release contains no new binaries for gcc, cc1, cc1plus or cpp. only things changed are in libraries. Mon Sep 7 13:44:09 1992 H.J. Lu (hlu@poly2) * change to jump table 4.1 * add prefix __ to header files. * use strftime from shellutils 1.7 to replace the one from glibc.a 1.03. Sat Sep 5 16:57:21 1992 H.J. Lu (hlu@poly2) * swapoff, wait4 (real one, need 0.97 pl3 or above) are added. * vm86 () and are added. Fri Sep 4 17:31:44 1992 H.J. Lu (hlu@meriadoc) * change jump table to 4.0. Add __brk_addr to global data. fix streambuf static member, _list_all. Wed Sep 2 13:01:59 1992 H.J. Lu (hlu@poly2) * __overflow () and __underflow () are moved into a separate file to facilitate the implementation of jump table. * getdtablesize () returns OPEN_MAX. Mon Aug 31 16:14:38 1992 H.J. Lu (hlu@poly2) * new getpass () from poeigl-1.6.tar.Z. * add C++ wrapper in setjmp.h. * GNU regex 0.9 is used. * file lock in gdbm is changed for real thing in 0.97 pl 2. * ntol? () and hton? () netinet/in.h are fixed. Thu Aug 27 00:12:10 1992 H.J. Lu (hlu@yoda) * regex (version 0.9) from shellutiles-1.7 is used. * bsd style signal () is added in . define _USE_BSD_SIGNAL to use it. * sigblock and sigpause () are added. * ftw () is added. It is untested. It uses seekdir and telldir (). I am afraid it may not work with VFS. Wed Aug 26 00:17:33 1992 H.J. Lu (hlu@fili) * scandir () and alphasort () are added. * killpg () is added to . Sun Aug 23 14:49:23 1992 H.J. Lu (hlu@poly2) * some files are changed for the new shared image scheme. * you have to have 0.97 pl 2 or above to use it. * define WTMP_FILENAME and UTMP_FILENAME as WTMP_FILE and UTMP_FILE in . Sat Aug 22 10:57:11 1992 H.J. Lu (hlu@luke) * fix re_comp (""). * setfileno () is added to stdio. don't use it unless you have to. * use POSIX signals in curses, ./posix/system.c and ./iostream/procbuf.C ----------------Start to Use ChangeLog------------------ Thu Aug 12 1992 * gcc-2.2.2d You need to have the header files from virgin Linux kernel 0.97 patch 1 or above on line to use this release. The source codes for gcc itself is unchanged from 2.2.2, but it was recompiled for new kernel. And lots of bugs are fixed. I am trying to make the Linux C library to be POSIX.1 compliant. I cleared up the header files and some library functions. 1. and are fixed. (in 2.2.2dmisc.tar.Z) 2. is fixed, remove __tzname_max (). (in 0.97pl1inc.tar.Z) 3. posix/sysconf.c. (the shared image is compiled with old one. I don't think it will matter too much. this will be fixed in the next release.) 4. time/Makefile (remove tzname.o) There are some problems with pathconf()/fpathconf(). We need a new sys call to get info about the filesystem. Someone mentioned vfsstat (). It may be a good idea. To be compliance with POSIX.1, we need 1. LINK_MAX 2. MAX_CANON 3. NAME_MAX 4. PATH_MAX 5. PIPE_BUF 6. _POSIX_CHOWN_RESTRICTED 7. _POSIX_NO_TRUNC 8. _POSIX_VDISABLE Some of them may change for different filesystems. Some don't. Some may do in the future. The installation procedure is changed. Please read README first. The new correct setjmp/longjmp are not compatible with gcc 2.2.2. If your code uses them, please recompile it with gcc 2.2.2d. And DO NOT USE setjmp/longjmp WITH THE SHARED X386 v1.1, WAIT FOR v2.0. The following bugs in libraries are fixed. 1. div/ldiv. 2. setjmp/longjmp. 3. crt0.o/gcrt0.o. 387 control word is changed to 0x1272. No overflow exception. 4. floating point format errors are fixed. 5. minor bug in mntent.c. 6. popen.o is fixed in libg.a. 7. fopen ("foo", "a") will seek to the end of file. 8. printf ("%10.2f\n", 10.0); 9. libg++.a 2.2 is used. 10. libinet.a is folded into libc.a. All the data bases are in /usr/etc/inet. But you need kernel support for that. Please contact "bir7@leland.stanford.edu" first. 11. a typo in libc-linux/socket/bytedorer.c is fixed. 12. size of args + envs for exec () is fixed. 13. new mount for 0.97. 14. a bug in temporary filename creation is fixed. Now it checks if a process has permission to create a file in specified directory. 15. in libhard.a, pow (0.0, 0.0) = 1.0 now. 16. cc1/cc1plus is fixed for double foo=DBL_MAX; The following functions are added to libraries. 1. setpiority/getpiority. 2. iopl. 3. sigsetjmp/siglongjmp. 4. cfree. The following changes are made to the header files. You won't notice the changes unless you are testing TCP/IP. If you are, please first contact "bir7@leland.stanford.edu". You need more than that. 1. is fixed. 2. is fixed. 3. all the header files are now compatible with gcc -traditional. 4. strncasecmp is added to . 5. is added. 6. lots of bugs are fixed. 7. and are changed. 8. and are changed for TCP/IP. 9. and are in for TCP/IP. 10. lots of header files in kernel and /usr/include are fixed. two dummies, and are added for gdb 4.6. The following changes are made to libraries. 1. byte order functions for networking are written in C. Please read libc-linux/socket/byteorder.c and David's jump table version 2 release 2.1 is in. Jun 27 1992 * gcc-2.2.2 Please get the new binutils.tar.Z, which fixed some bugs in as and gprof with some patches from Rick Sladkey at jrs@world.std.com I added some jumptable stubs to gcc. But I don't have the time to implement it. In the future, you can use jump table with -jump in CFLAGS. Libg++.a is 2.2 beta. This gcc will produce binaries only run safely under 0.96a patch level 4 or above. The following bugs in libc.a are fixed. 1. hard and soft math libs are fixed. some of functions are totally rewritten. 2. acosh, asinh and atanh are added to libsoft.a and math.h. 3. open a file for read and write, then do fseek followed by fwrite works now. 4. now random () and srandom () are renamed to __random () and __srandom (), respectively. 5. the header files taken from glibc.a are fixed. 6. the sys call mount now takes 4 args. 7. getpagesize and getdtablesize work now. 8. netdb.h, resolv.h, sys/uio.h, netinet.h, arpa/inet.h and arpa/nameser.h are changed. 9. Some function declarations are added to sys/socket.h in 0.96bp2inc.tar.Z. The following functions are added to libc.a. 1. profil. 2. libg.a is there. 3. getdtablesize. 4. lots of stuffs added to errno.h and string/errlist.c. 5. some changes in string/siglist.c. 6. dtoa. 7. there is a new strtod, please check it out. 8. drem. 9. the inet library functions are in libinet.a. They are untested. Once they are tested ok, they will be moved to libc.a. All the inet library functions are there, except for res_xxxx, rcmd, rexec and ruserpass, which require more kernel support, like F_SETOWN, FASYNC, and a few network system calls. There should also be a set of files in /etc for inet functions. I hope Ross will provide them. In this release, there is a libc_p.a compiled with "-pg" for profiling. You should use "-g" for debugging and "-pg/-p" for profiling in CFLAGS when you compile the source code. Jun 16 1992 * gcc-2.2 based on FSF release gcc-2.2.1 new binutils.tar.Z, which fixed some bugs in as. Libg++.a is 2.1 A new structure of gcc is introduced here. All the static libs are in /usr/lib/gcc-lib/i386-linux/2.xxx and all the shared libs are in /usr/lib/gcc-lib/i386-linux/2.xxx/shared. By default, gcc will search /usr/lib/gcc-lib/i386-linux/2.xxx/shared first, then the static libs. You can turn off the shared libs with "-static". The following bugs in libc.a are fixed. 1. dirent.[ch] are fixed such that static memory no longer is used in readdir (). 2. sys/dir.h sys/dirent.h are modified such that there will be a warning when both of them are included. They are also compatible now. 3. __cpluscplus in fnmath.h 4. gets () will only give a warning during linking. 5. wait3 (). 6. is fixed. fputc, fgets and gets are no longer macros. 7. is added in 0.96ap2inc.tar.Z. 8. The return value of clock ticks of the old sysconf () was wrong. It returned 60 instead of 100. 9. The domain errors in the math libraries are improved. 10. bsearch and qsort are fixed for zero element. The following functions are added to libc.a. 1. accept 2. bind 3. bstring 4. connect 5. ftime 6. fchmod 7. fchown 8. ftruncate 9. getpagesize 10. getpeername 11. getsockname 12. getwd 13. ioperm 14. itimer. 15. listen 16. mmap 17. mntent. 18. ntohs/htons 19. ntohl/htonl 20. psignal 21. ptrace 22. setenv/unsetenv 23. socket 24. socketpair 25. statfs () and fstatfs (). 26. truncate 27. usleep 28. vfork 29. wait3() and wait4 (). Gdbm 1.5 is here for X11R5. popen now is based on iostream. I also changed the structure of header files. May 30 1992 * gcc-2.12c based on ss-920528 from FSF From this release, gcc will use the shared lib. That means you have to keep the shared images used by all the compilers you have. Now libg++.a 2.0.91 is here. The following bugs in gcc are fixed. 1. "\xxx" works now. 2. No more warning about "__FUNCTION__" stuffs. The following bugs in libc.a are fixed. 1. hypot added to math.h 2. popen is fixed by Per, Check it out. 3. __cpluseplus in setjmp.h 4. copy sys/dirent.h to sys/dir.h, but change dirent to direct. 5. proto type of gdbm_open in gdbm.h 6. Per tried to fix fseek/fread/fwrite. Check it out. Here is the list of the known bugs. 1. -O won't work with getdate.c from shellutils 1.6. I am trying to fix the following bugs in libg++.a. 1. Maybe Complex.o, which uses hypot. May 27 1992 * gcc-2.12b The following bugs in libc.a are fixed. 1. types used in sigsetmask and siggetmask are now sigset_t. 2. a minor change in sigproc.c. 3. signal.h is changed. I am trying to fix the follwing bugs in libg++.a. 1. Regex.o and String.o Please do this to fix the bug in libg++.a. /bin/rm -rf /usr/g++-include/regex.h May 26 1992 * gcc-2.12 based on FSF prerelease of gcc-2.2. The follwing bugs in libc.a are fixed. 1. index. 2. sigxxxx return values should be right now. 3. execxxx are taken from glibc.a 1.03. Please check it out. 4. malloc in stdlib.h and malloc.h, when they are included together, they may cause trouble. Can I include malloc.h in stdlib.h and fix malloc in malloc.h? The following functions are added. 1. tell (bsd) 2. sigsetmask 3. siggetmask popen now is based on iostream. I also changed the structure of header files. Libg++.a 2.0.90 is here, which is MUCH better than the one in gcc 2.11c. Please try this. Stdio should be less buggy. Check it out. To use this release, please get new binutils.tar.Z which has a new gas. May 19 1992 * gcc-2.11c ldd is supported. The source code of the libraries is in libc-2.11c.tar.Z. There are two files: gcc-2.1.tar.Z, for compiler, including some tips for cross-compiling. shlib-2.11c.tar.Z, for building the shared libs. May 17 1992 * gcc-2.11b 1. sleep (0) is fixed. 2. All binaries are recompiled with new gas. 3. X11R5 is not the part of gcc 2.1 anymore. Please get the new binutils.tar.Z. The old one may have bugs. ./libc-linux/configure100755 1676 334 17274 5530163571 13063 0ustar hjlisl#! /bin/sh # # Changes by H.J.Lu # Original version Mitchum Dsouza # # Simple libc configuration script tested with `bash' and `ksh' and # Sun `sh' # The following two are the ANSI sequences for start and end embolden case $TERM in vt*|ansi*|con*|xterm*) S= E= ;; *) S= E= ;; esac # Define some defaults TARGET_OS=linux HOST_ROOTDIR=/usr HOST_BINDIR=${HOST_ROOTDIR}/bin TARGET_ROOTDIR=/ STATIC_SHARED=true SPEED=fast BAD_GCCVERSION="Invalid gcc version" if [ -f ./config.in ]; then . ./config.in fi response() { echo -n "$1 [$2] ? " 1> /dev/tty read answer if [ x${answer} = x ]; then echo $2 else echo ${answer} fi } getresponse () { OLD_TARGET_MACHINE=${TARGET_MACHINE} if [ ${TARGET_ARCH} = i386 ]; then TMP=4; else TMP=m; fi TARGET_ARCH=`response "Build 386, 486 or m68k library code (486 default) 4/3/m" "${TMP}"` case i${TARGET_ARCH} in i4) TARGET_MACHINE=i486-linux TARGET_ARCH_486=true; TARGET_ARCH=i386; ;; i3) TARGET_MACHINE=i386-linux TARGET_ARCH_486=false; TARGET_ARCH=i386; ;; im) TARGET_MACHINE=m68k-linux TARGET_ARCH_486=false; TARGET_ARCH=m68k; ;; *) echo Unknown arch: \"${TARGET_ARCH}\". exit 1 ;; esac TARGET_MACHINE=`response "The target platform" "${TARGET_MACHINE}"` TARGET_OS=`response "The target OS" "${TARGET_OS}"` TMP=s STATIC_SHARED=`response "Build targets (static/shared default) s/a" "${TMP}"` case i${STATIC_SHARED} in is) STATIC_SHARED=true ;; *) STATIC_SHARED= ;; esac get_host_rootdir $TARGET_MACHINE HOST_ROOTDIR=`response "Root path to $TARGET_MACHINE related files" "${HOST_ROOTDIR}"` HOST_BINDIR=`response "Bin path to gcc" "${HOST_BINDIR}"` GCCVERSION=`response "The gcc version" "${GCCVERSION}"` TMP=f SPEED=`response "Fast build/save space (fast default) f/s" "${TMP}"` case i${SPEED}x in ifx) SPEED=fast ;; *) SPEED= ;; esac MAKE=`response "GNU \\\`make' executable" "${MAKE}"` TARGET_ROOTDIR=`response "Root path to installation dirs" "${TARGET_ROOTDIR}"` } showdefaults () { echo echo *******Current defaults******** echo if [ ${TARGET_ARCH_486} = "true" ]; then echo "Build ${S}${TARGET_MACHINE}${E} library for ${S}i486${E} running ${S}${TARGET_OS}${E}" else echo "Build ${S}${TARGET_MACHINE}${E} library for ${S}${TARGET_ARCH}${E} running ${S}${TARGET_OS}${E}" fi if [ x${STATIC_SHARED} = x"true" ]; then echo "Build targets are ${S}static and shared libraries only${E}." else echo "Build targets are ${S}static, shared, debug and profile libraries${E}." fi echo "Root path to ${S}${TARGET_MACHINE}${E} related files is ${S}${HOST_ROOTDIR}${E}" echo "Bin path to gcc is ${S}${HOST_BINDIR}${E}" echo "The version of gcc to be used is ${S}${GCCVERSION}${E}" if [ x${SPEED} = x"fast" ]; then echo "Build option is ${S}fast build${E}." else echo "Build option is ${S}save space${E}." fi echo "GNU \`make' executable is ${S}${MAKE}${E}" echo "Root path to installation dirs is ${S}${TARGET_ROOTDIR}${E}" echo } get_gnu_make () { make_list="make gmake gnumake" gf=0 v= for m in $make_list do $m -v 2> /dev/null | grep GNU > /dev/null 2>&1 if [ $? = 0 ]; then gf=1 TMP=`$m -v 2> /dev/null | head -1 | grep GNU | cut -f4 -d' '` v="$TMP $v" case $TMP in 3.7*|3.8*|3.9*|4*|5*|6*|7*|8*|9*) MAKE=$m return ;; esac fi done if [ $gf = 1 ]; then echo GNU make version, $v are found. Need GNU make 3.70 or above. else echo No GNU make is found. Need GNU make 3.70 or above. fi exit 1 } get_target_rootdir () { if [ -d /home/linux ]; then TARGET_ROOTDIR=/home/linux fi } get_host_rootdir () { target=$1 LIBGCC=`gcc --print` if [ ${LIBGCC} != libgcc.a ]; then position=2 TMP=`echo $LIBGCC | cut -f$position -d'/'` HOST_ROOTDIR= HOST_ROOTDIR=$HOST_ROOTDIR/$TMP until [ $TMP = "lib" ] do position=`expr $position + 1` TMP=`echo $LIBGCC | cut -f$position -d'/'` HOST_ROOTDIR=$HOST_ROOTDIR/$TMP done HOST_ROOTDIR=`(cd $HOST_ROOTDIR/..; pwd)` HOST_BINDIR=${HOST_ROOTDIR}/bin fi } get_default_gcc_version () { LIBGCC=`gcc -b $1 --print` if [ ${LIBGCC} != libgcc.a ]; then position=2 TMP=`echo $LIBGCC | cut -f$position -d'/'` until [ $TMP = "gcc-lib" ] do position=`expr $position + 1` TMP=`echo $LIBGCC | cut -f$position -d'/'` done position=`expr $position + 2` GCCVERSION=`echo $LIBGCC | cut -f$position -d'/'` else GCCVERSION="${BAD_GCCVERSION}" fi } get_default_gcc_target () { LIBGCC=`gcc --print` if [ ${LIBGCC} != libgcc.a ]; then position=2 TMP=`echo $LIBGCC | cut -f$position -d'/'` until [ $TMP = "gcc-lib" ] do position=`expr $position + 1` TMP=`echo $LIBGCC | cut -f$position -d'/'` done position=`expr $position + 1` DEFAULT_GCC_TARGET=`echo $LIBGCC | cut -f$position -d'/'` fi } get_target_info () { LIBGCC=`gcc --print` if [ ${LIBGCC} != libgcc.a ]; then position=2 TMP=`echo $LIBGCC | cut -f$position -d'/'` GCC_LIB_DIR= GCC_LIB_DIR=$GCC_LIB_DIR/$TMP until [ $TMP = "gcc-lib" ] do position=`expr $position + 1` TMP=`echo $LIBGCC | cut -f$position -d'/'` GCC_LIB_DIR=$GCC_LIB_DIR/$TMP done TARGET_MACHINE=`(cd $GCC_LIB_DIR; echo *linux*)` if [ xx"${TARGET_MACHINE}"xx != xxxx ]; then if [ `echo $TARGET_MACHINE | wc -w` != 1 ]; then echo More than one Linux targets found: echo " $TARGET_MACHINE" echo $TARGET_MACHINE | grep $DEFAULT_GCC_TARGET > /dev/null if [ $? = 0 ]; then TARGET_MACHINE=$DEFAULT_GCC_TARGET else TARGET_MACHINE=`echo $TARGET_MACHINE | cut -f1 -d ' '` fi echo \"$TARGET_MACHINE\" is chosen. fi TARGET_OS=linux case $TARGET_MACHINE in *486*) TARGET_ARCH_486=true TARGET_ARCH=i386 ;; *386*) TARGET_ARCH_486=false TARGET_ARCH=i386 ;; *68*) TARGET_ARCH_486=false TARGET_ARCH=m68k ;; *) echo Oops: Unknown target machine "$TARGET_MACHINE". ;; esac fi fi } get_host_info () { # First check out who you are. HOST_OS=`uname -s` case $HOST_OS in [Ll][Ii][Nn][Uu][Xx]) HOST_OS=linux HOST_ROOTDIR=/usr HOST_BINDIR=${HOST_ROOTDIR}/bin TARGET_ROOTDIR=/ get_default_gcc_target TARGET_ARCH=`uname -m` case $TARGET_ARCH in *386*) TARGET_ARCH_486=false TARGET_ARCH=i386 ;; *486*) TARGET_ARCH_486=true TARGET_ARCH=i386 ;; *68*) TARGET_ARCH_486=false TARGET_ARCH=m68k ;; esac ;; *) get_host_rootdir $TARGET_MACHINE get_target_rootdir ;; esac } get_default_gcc_target get_target_info get_host_info get_gnu_make get_default_gcc_version $TARGET_MACHINE #GCCVERSION=`gcc --version` get_host_rootdir $TARGET_MACHINE showdefaults if [ "${GCCVERSION}" = "${BAD_GCCVERSION}" ]; then echo Please provide a valid gcc version: ${S}${BAD_GCCVERSION}${E}! echo ans=n else ans=`response "Values correct (y/n)" "y"` fi while [ x${ans} != x -a x${ans} != xy ] do getresponse showdefaults if [ "${GCCVERSION}" = "${BAD_GCCVERSION}" ]; then echo Please provide a valid gcc version: ${S}${BAD_GCCVERSION}${E}! echo ans=n else ans=`response "Values correct (y/n)" "y"` fi done { echo STATIC_SHARED="${STATIC_SHARED}" echo MAKE="${MAKE}" echo SPEED="${SPEED}" echo HOST_ROOTDIR="${HOST_ROOTDIR}" echo HOST_BINDIR="${HOST_BINDIR}" echo TARGET_ROOTDIR="${TARGET_ROOTDIR}" echo TARGET_MACHINE="${TARGET_MACHINE}" echo TARGET_OS="${TARGET_OS}" echo TARGET_ARCH="${TARGET_ARCH}" echo TARGET_ARCH_486="${TARGET_ARCH_486}" echo GCCVERSION="${GCCVERSION}" } > config.in ./libc-linux/config.in100644 1676 334 372 5536177220 12702 0ustar hjlislSTATIC_SHARED= MAKE=gmake SPEED=fast HOST_ROOTDIR=/usr/GNU/H-sparc-sun-sunos4.1 HOST_BINDIR=/usr/GNU/H-sparc-sun-sunos4.1/bin TARGET_ROOTDIR=/home/linux TARGET_MACHINE=i486-linux TARGET_OS=linux TARGET_ARCH=i386 TARGET_ARCH_486=true GCCVERSION=2.5.8 ./libc-linux/checker/ 40755 1676 334 0 5527714200 12425 5ustar hjlisl./libc-linux/checker/Makefile100644 1676 334 1275 5527713100 14165 0ustar hjlisl# TOPDIR=.. CHECKER_LIB_DIR=/usr/local/lib/checker/ include $(TOPDIR)/Makeconfig libc.a: alwaysredo $(RM) -f libc.a; \ $(MKDIR) tmpcopy; \ cd tmpcopy; \ $(AR) -x ../../libalias.a; \ $(AR) ucv ../libc.a *.o; \ cd ..; $(RM) -rf tmpcopy; cd libc; \ $(AR) ucv ../libc.a *.o; libm.a: alwaysredo $(RM) -f libm.a; \ $(MKDIR) tmpcopy; \ cd tmpcopy; \ $(AR) -x ../../libmalias.a; \ $(AR) ucv ../libm.a *.o; \ cd ..; $(RM) -rf tmpcopy; cd libm; \ $(AR) ucv ../libm.a *.o; prepare.inst: libm.a libc.a cp libgcc/libgcc3.a libgcc.a $(REALRANLIB) *.a install: prepare.inst for i in *.a; do \ cp $$i $(CHECKER_LIB_DIR)/`basename $$i .a`.chkr.a ; \ done alwaysredo: .PHONY: alwaysredo