summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile18
-rw-r--r--lib/csu/alpha/Makefile6
-rw-r--r--lib/csu/alpha/crt1.c9
-rw-r--r--lib/csu/i386-elf/Makefile6
-rw-r--r--lib/csu/i386-elf/crt1.c12
-rw-r--r--lib/csu/i386/Makefile23
-rw-r--r--lib/csu/i386/crt0.c10
-rw-r--r--lib/libF77/MAIN.c1
-rw-r--r--lib/libalias/alias.c17
-rw-r--r--lib/libalias/alias_db.c6
-rw-r--r--lib/libalias/alias_local.h4
-rw-r--r--lib/libalias/alias_nbt.c215
-rw-r--r--lib/libalias/libalias.36
-rw-r--r--lib/libc/alpha/SYS.h4
-rw-r--r--lib/libc/alpha/gen/Makefile.inc8
-rw-r--r--lib/libc/alpha/gen/fpgetmask.c11
-rw-r--r--lib/libc/alpha/gen/fpgetround.c7
-rw-r--r--lib/libc/alpha/gen/fpgetsticky.c10
-rw-r--r--lib/libc/alpha/gen/fpsetmask.c12
-rw-r--r--lib/libc/alpha/gen/fpsetround.c17
-rw-r--r--lib/libc/alpha/gen/fpsetsticky.c16
-rw-r--r--lib/libc/alpha/gen/setjmp.S2
-rw-r--r--lib/libc/alpha/sys/cerror.S6
-rw-r--r--lib/libc/gen/fstab.c29
-rw-r--r--lib/libc/gen/getloadavg.31
-rw-r--r--lib/libc/gen/getobjformat.316
-rw-r--r--lib/libc/gen/getpwent.34
-rw-r--r--lib/libc/gen/getpwent.c4
-rw-r--r--lib/libc/gen/getvfsbyname.c4
-rw-r--r--lib/libc/gen/getvfsent.c11
-rw-r--r--lib/libc/gen/nlist.c136
-rw-r--r--lib/libc/gen/popen.39
-rw-r--r--lib/libc/gen/psignal.34
-rw-r--r--lib/libc/gen/psignal.c6
-rw-r--r--lib/libc/gen/setmode.311
-rw-r--r--lib/libc/gen/sysctl.35
-rw-r--r--lib/libc/gen/sysctl.c12
-rw-r--r--lib/libc/gen/tzset.34
-rw-r--r--lib/libc/i386/sys/sigsuspend.S8
-rw-r--r--lib/libc/locale/ansi.c12
-rw-r--r--lib/libc/quad/moddi3.c2
-rw-r--r--lib/libc/stdio/fclose.312
-rw-r--r--lib/libc/stdio/mktemp.c2
-rw-r--r--lib/libc/stdio/perror.c2
-rw-r--r--lib/libc/stdlib/merge.c7
-rw-r--r--lib/libc/stdlib/qsort.34
-rw-r--r--lib/libc/stdtime/asctime.c7
-rw-r--r--lib/libc/stdtime/ctime.3119
-rw-r--r--lib/libc/stdtime/localtime.c10
-rw-r--r--lib/libc/string/Makefile.inc3
-rw-r--r--lib/libc/string/strerror.313
-rw-r--r--lib/libc/string/strtok.3113
-rw-r--r--lib/libc/string/strtok.c191
-rw-r--r--lib/libc/sys/Makefile.inc6
-rw-r--r--lib/libc/sys/accept.28
-rw-r--r--lib/libc/sys/aio_read.2189
-rw-r--r--lib/libc/sys/fcntl.27
-rw-r--r--lib/libc/sys/getdirentries.22
-rw-r--r--lib/libc/sys/rename.254
-rw-r--r--lib/libc/sys/revoke.211
-rw-r--r--lib/libc/sys/sendfile.2151
-rw-r--r--lib/libc/sys/sigaltstack.25
-rw-r--r--lib/libc/sys/stat.238
-rw-r--r--lib/libc/sys/vfork.24
-rw-r--r--lib/libc_r/Makefile4
-rw-r--r--lib/libc_r/uthread/pthread_private.h4
-rw-r--r--lib/libc_r/uthread/uthread_cond.c55
-rw-r--r--lib/libc_r/uthread/uthread_info.c29
-rw-r--r--lib/libc_r/uthread/uthread_kern.c18
-rw-r--r--lib/libc_r/uthread/uthread_kill.c20
-rw-r--r--lib/libc_r/uthread/uthread_mattr_kind_np.c14
-rw-r--r--lib/libc_r/uthread/uthread_mutex.c85
-rw-r--r--lib/libcam/camlib.c9
-rw-r--r--lib/libcompat/Makefile17
-rw-r--r--lib/libdevstat/Makefile10
-rw-r--r--lib/libdevstat/devstat.38
-rw-r--r--lib/libdisk/Makefile22
-rw-r--r--lib/libdisk/create_chunk.c22
-rw-r--r--lib/libdisk/disk.c4
-rw-r--r--lib/libdisk/libdisk.39
-rw-r--r--lib/libdisk/libdisk.h3
-rw-r--r--lib/libdisk/write_disk.c17
-rw-r--r--lib/libedit/Makefile2
-rw-r--r--lib/libedit/term.c2
-rw-r--r--lib/libf2c/Makefile2
-rw-r--r--lib/libfetch/Makefile55
-rw-r--r--lib/libfetch/README17
-rw-r--r--lib/libfetch/common.c284
-rw-r--r--lib/libfetch/common.h59
-rw-r--r--lib/libfetch/fetch.3220
-rw-r--r--lib/libfetch/fetch.c231
-rw-r--r--lib/libfetch/fetch.h71
-rw-r--r--lib/libfetch/fetch_err.et50
-rw-r--r--lib/libfetch/file.c87
-rw-r--r--lib/libfetch/ftp.c280
-rw-r--r--lib/libfetch/ftp.errors80
-rw-r--r--lib/libfetch/http.c87
-rw-r--r--lib/libfetch/http.errors76
-rw-r--r--lib/libio/Makefile11
-rw-r--r--lib/libio/alpha_sethae.c50
-rw-r--r--lib/libio/bwx.c237
-rw-r--r--lib/libio/io.c151
-rw-r--r--lib/libio/io.h48
-rw-r--r--lib/libio/swiz.c246
-rw-r--r--lib/libkvm/kvm_proc.c29
-rw-r--r--lib/libkvm/kvm_read.31
-rw-r--r--lib/libmd/Makefile5
-rw-r--r--lib/libmytinfo/Makefile6
-rw-r--r--lib/libncurses/curs_addstr.34
-rw-r--r--lib/libpam/Makefile31
-rw-r--r--lib/libpam/Makefile.inc28
-rw-r--r--lib/libpam/libpam/Makefile112
-rw-r--r--lib/libpam/libpam/pam_get_pass.c93
-rw-r--r--lib/libpam/libpam/pam_mod_misc.h48
-rw-r--r--lib/libpam/libpam/pam_prompt.c62
-rw-r--r--lib/libpam/libpam/pam_std_option.c62
-rw-r--r--lib/libpam/modules/Makefile36
-rw-r--r--lib/libpam/modules/pam_cleartext_pass_ok/Makefile39
-rw-r--r--lib/libpam/modules/pam_cleartext_pass_ok/pam_cleartext_pass_ok.c67
-rw-r--r--lib/libpam/modules/pam_kerberosIV/Makefile41
-rw-r--r--lib/libpam/modules/pam_kerberosIV/klogin.c204
-rw-r--r--lib/libpam/modules/pam_kerberosIV/pam_kerberosIV.c108
-rw-r--r--lib/libpam/modules/pam_radius/Makefile40
-rw-r--r--lib/libpam/modules/pam_radius/pam_radius.c300
-rw-r--r--lib/libpam/modules/pam_skey/Makefile40
-rw-r--r--lib/libpam/modules/pam_skey/pam_skey.c108
-rw-r--r--lib/libpam/modules/pam_tacplus/Makefile40
-rw-r--r--lib/libpam/modules/pam_tacplus/pam_tacplus.c258
-rw-r--r--lib/libpam/modules/pam_unix/Makefile40
-rw-r--r--lib/libpam/modules/pam_unix/pam_unix.c90
-rw-r--r--lib/libpcap/Makefile4
-rw-r--r--lib/libradius/Makefile41
-rw-r--r--lib/libradius/libradius.3317
-rw-r--r--lib/libradius/radius.conf.5123
-rw-r--r--lib/libradius/radlib.c737
-rw-r--r--lib/libradius/radlib.h125
-rw-r--r--lib/libradius/radlib_private.h82
-rw-r--r--lib/libskey/Makefile2
-rw-r--r--lib/libskey/put.c2
-rw-r--r--lib/libskey/skey.h2
-rw-r--r--lib/libskey/skey_crypt.c4
-rw-r--r--lib/libskey/skeyaccess.c32
-rw-r--r--lib/libskey/skeylogin.c4
-rw-r--r--lib/libskey/skeysubr.c4
-rw-r--r--lib/libstand/Makefile18
-rw-r--r--lib/libstand/assert.c37
-rw-r--r--lib/libstand/dev_net.c13
-rw-r--r--lib/libstand/gets.c5
-rw-r--r--lib/libstand/libstand.320
-rw-r--r--lib/libstand/printf.c14
-rw-r--r--lib/libstand/qdivrem.c303
-rw-r--r--lib/libstand/quad.h116
-rw-r--r--lib/libstand/stand.h15
-rw-r--r--lib/libstand/zalloc_defs.h4
-rw-r--r--lib/libstand/zalloc_malloc.c11
-rw-r--r--lib/libtacplus/Makefile41
-rw-r--r--lib/libtacplus/libtacplus.3347
-rw-r--r--lib/libtacplus/taclib.c1053
-rw-r--r--lib/libtacplus/taclib.h105
-rw-r--r--lib/libtacplus/taclib_private.h152
-rw-r--r--lib/libtacplus/tacplus.conf.5114
-rw-r--r--lib/libtelnet/getent.c2
-rw-r--r--lib/libutil/libutil.h4
-rw-r--r--lib/libutil/property.321
-rw-r--r--lib/libutil/property.c15
-rw-r--r--lib/libutil/setproctitle.c15
-rw-r--r--lib/libz/ChangeLog69
-rw-r--r--lib/libz/FAQ72
-rw-r--r--lib/libz/README77
-rw-r--r--lib/libz/adler32.c2
-rw-r--r--lib/libz/compress.c2
-rw-r--r--lib/libz/crc32.c2
-rw-r--r--lib/libz/deflate.c10
-rw-r--r--lib/libz/deflate.h8
-rw-r--r--lib/libz/example.c30
-rw-r--r--lib/libz/gzio.c39
-rw-r--r--lib/libz/infblock.c15
-rw-r--r--lib/libz/infcodes.c13
-rw-r--r--lib/libz/inffast.c12
-rw-r--r--lib/libz/inffixed.h151
-rw-r--r--lib/libz/inftrees.c31
-rw-r--r--lib/libz/inftrees.h14
-rw-r--r--lib/libz/maketree.c85
-rw-r--r--lib/libz/minigzip.c5
-rw-r--r--lib/libz/trees.c54
-rw-r--r--lib/libz/uncompr.c2
-rw-r--r--lib/libz/zconf.h73
-rw-r--r--lib/libz/zlib.36
-rw-r--r--lib/libz/zlib.h153
-rw-r--r--lib/libz/zutil.c10
-rw-r--r--lib/libz/zutil.h23
-rw-r--r--lib/msun/Makefile4
192 files changed, 1307 insertions, 9809 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 26a65e1605c96..2e34bc40a0c27 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,5 +1,5 @@
# @(#)Makefile 8.1 (Berkeley) 6/4/93
-# $Id: Makefile,v 1.86 1998/11/29 02:47:52 bde Exp $
+# $Id: Makefile,v 1.81 1998/10/01 14:49:57 jkh Exp $
# To satisfy shared library or ELF linkage when only the libraries being
# built are visible:
@@ -8,23 +8,19 @@
# libcom_err must be built before libss.
# libcrypt must be built before libskey.
# libm must be built before libf2c, libg++ and libstdc++.
-# libmd must be built before libatm, libopie, libradius, libskey,
-# and libtacplus.
+# libmd must be built before libatm, libopie and libskey.
# libmytinfo must be built before libdialog and libncurses.
# libncurses must be built before libdialog.
-# libradius must be built before libpam.
-# libskey must be built before libpam.
-# libtacplus must be built before libpam.
# libtermcap must be built before libcurses, libedit and libreadline.
#
# Otherwise, the SUBDIR list should be in alphabetical order.
SUBDIR= ${_csu} libcom_err ${_libcrypt} ${_libm} libmd libmytinfo \
- libncurses libradius libskey libtacplus libtermcap \
+ libncurses libtermcap \
${_compat} libalias libatm libbind libc ${_libc_r} libcalendar libcam \
libcompat libcurses libdevstat libdisk libedit libf2c libfetch \
- libftpio libgnumalloc ${_libio} libipx libkvm libopie libpam \
- libpcap libresolv librpcsvc libss libstand \
+ libftpio libgnumalloc libipx libkvm libopie \
+ libpcap libresolv librpcsvc libskey libss libstand \
${_libtelnet} libutil ${_libvgl} libxpg4 liby libz
.if exists(${.CURDIR}/csu/${MACHINE_ARCH}-${OBJFORMAT})
@@ -56,10 +52,6 @@ _libm= libm
_libm= msun
.endif
-.if ${MACHINE_ARCH} == "alpha"
-_libio= libio
-.endif
-
.if defined(RELEASEDIR) || !exists(${.CURDIR}/../kerberosIV) || \
defined(NOCRYPT) || !defined(MAKE_KERBEROS4)
_libtelnet= libtelnet
diff --git a/lib/csu/alpha/Makefile b/lib/csu/alpha/Makefile
index 473dc99e201ab..219f923702c14 100644
--- a/lib/csu/alpha/Makefile
+++ b/lib/csu/alpha/Makefile
@@ -1,10 +1,10 @@
#
-# $Id: Makefile,v 1.6 1998/08/20 21:37:22 jb Exp $
+# $Id: Makefile,v 1.5 1998/05/04 02:06:09 jb Exp $
#
SRCS= crt1.c crtbegin.c crtend.c
OBJS= crt1.o crtbegin.o crtend.o
-SOBJS= crtbegin.So crtend.So
+SOBJS= crtbegin.so crtend.so
CFLAGS+= -Wall -Wno-unused -I${.CURDIR}/../../../libexec/rtld-elf
NOMAN= true
NOPIC= true
@@ -16,7 +16,7 @@ all: ${OBJS} ${SOBJS}
realinstall:
.for file in ${OBJS} ${SOBJS}
${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
- ${file} ${DESTDIR}${LIBDIR}/${file:S/.So$/S.o/}
+ ${file} ${DESTDIR}${LIBDIR}/${file:S/.so$/S.o/}
.endfor
.include <bsd.lib.mk>
diff --git a/lib/csu/alpha/crt1.c b/lib/csu/alpha/crt1.c
index ac87526ca9af8..2f7fd95a91b80 100644
--- a/lib/csu/alpha/crt1.c
+++ b/lib/csu/alpha/crt1.c
@@ -30,7 +30,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: crt1.c,v 1.3 1999/01/07 20:18:18 steve Exp $
+ * $Id: crt1.c,v 1.1.1.2 1998/03/11 20:36:09 jb Exp $
*/
#ifndef __GNUC__
@@ -80,13 +80,8 @@ _start(char **ap,
argv = ap + 1;
env = ap + 2 + argc;
environ = env;
- if(argc > 0 && argv[0] != NULL) {
- char *s;
+ if(argc > 0)
__progname = argv[0];
- for (s = __progname; *s != '\0'; s++)
- if (*s == '/')
- __progname = s + 1;
- }
if (&_DYNAMIC != NULL) {
if ((obj == NULL) || (obj->magic != RTLD_MAGIC))
diff --git a/lib/csu/i386-elf/Makefile b/lib/csu/i386-elf/Makefile
index ae195e85dfc3e..6432efe1d939a 100644
--- a/lib/csu/i386-elf/Makefile
+++ b/lib/csu/i386-elf/Makefile
@@ -1,11 +1,11 @@
#
-# $Id: Makefile,v 1.2 1998/09/07 23:31:59 jdp Exp $
+# $Id: Makefile,v 1.1.1.1 1998/03/07 20:27:10 jdp Exp $
#
SRCS= crt1.c crtbegin.c crtend.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= gcrt1.o
-SOBJS= crtbegin.So crtend.So
+SOBJS= crtbegin.so crtend.so
CFLAGS+= -elf
CFLAGS+= -Wall -Wno-unused
LDFLAGS+= -elf
@@ -22,7 +22,7 @@ gcrt1.o: crt1.c
realinstall:
.for file in ${OBJS} ${SOBJS}
${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
- ${file} ${DESTDIR}${LIBDIR}/${file:S/.So$/S.o/}
+ ${file} ${DESTDIR}${LIBDIR}/${file:S/.so$/S.o/}
.endfor
.include <bsd.lib.mk>
diff --git a/lib/csu/i386-elf/crt1.c b/lib/csu/i386-elf/crt1.c
index d1dd43d0c361b..a30399725f800 100644
--- a/lib/csu/i386-elf/crt1.c
+++ b/lib/csu/i386-elf/crt1.c
@@ -22,14 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: crt1.c,v 1.2 1998/09/07 23:31:59 jdp Exp $
+ * $Id: crt1.c,v 1.1.1.1 1998/03/07 20:27:10 jdp Exp $
*/
#ifndef __GNUC__
#error "GCC is needed to compile this file"
#endif
-#include <stddef.h>
#include <stdlib.h>
typedef void (*fptr)(void);
@@ -73,15 +72,10 @@ _start(char *arguments, ...)
argc = * (int *) (argv - 1);
env = argv + argc + 1;
environ = env;
- if(argc > 0 && argv[0] != NULL) {
- char *s;
+ if(argc > 0)
__progname = argv[0];
- for (s = __progname; *s != '\0'; s++)
- if (*s == '/')
- __progname = s + 1;
- }
- if(&_DYNAMIC != NULL)
+ if(&_DYNAMIC != 0)
atexit(rtld_cleanup);
#ifdef GCRT
diff --git a/lib/csu/i386/Makefile b/lib/csu/i386/Makefile
index d58be684afce7..9cd822c207bc4 100644
--- a/lib/csu/i386/Makefile
+++ b/lib/csu/i386/Makefile
@@ -1,22 +1,19 @@
# from: @(#)Makefile 5.6 (Berkeley) 5/22/91
-# $Id: Makefile,v 1.38 1998/05/31 11:32:37 bde Exp $
+# $Id: Makefile,v 1.37 1998/05/26 20:12:52 sos Exp $
CFLAGS+= -DLIBC_SCCS -fno-omit-frame-pointer
OBJS= crt0.o c++rt0.o gcrt0.o scrt0.o sgcrt0.o
-CLEANFILES= a.out crt0.o.tmp c++rt0.o.tmp gcrt0.o.tmp scrt0.o.tmp \
- sgcrt0.o.tmp
+CLEANFILES+= a.out
all: ${OBJS}
crt0.o: crt0.c
${CC} ${CFLAGS} -c -DCRT0 -DDYNAMIC ${.CURDIR}/crt0.c -o ${.TARGET}
- ${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
- @mv ${.TARGET}.tmp ${.TARGET}
+ ${LD} -O ${.TARGET} -x -r ${.TARGET}
c++rt0.o: c++rt0.c
${CC} ${CFLAGS} -fpic -c ${.CURDIR}/c++rt0.c
- @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
- @mv ${.TARGET}.tmp ${.TARGET}
+ @${LD} -O ${.TARGET} -x -r ${.TARGET}
#
# gcrt0.o doesn't really depend on crt0.o, but this is the easiest way
@@ -24,20 +21,17 @@ c++rt0.o: c++rt0.c
#
gcrt0.o: crt0.o
${CC} ${CFLAGS} -c -DMCRT0 -DDYNAMIC ${.CURDIR}/crt0.c -o ${.TARGET}
- @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
- @mv ${.TARGET}.tmp ${.TARGET}
+ ${LD} -O ${.TARGET} -x -r ${.TARGET}
# dependencies fudged as for gcrt0.o
scrt0.o: crt0.o
${CC} ${CFLAGS} -c -DCRT0 ${.CURDIR}/crt0.c -o ${.TARGET}
- @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
- @mv ${.TARGET}.tmp ${.TARGET}
+ ${LD} -O ${.TARGET} -x -r ${.TARGET}
# dependencies fudged as for gcrt0.o
sgcrt0.o: scrt0.o
${CC} ${CFLAGS} -c -DMCRT0 ${.CURDIR}/crt0.c -o ${.TARGET}
- @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
- @mv ${.TARGET}.tmp ${.TARGET}
+ ${LD} -O ${.TARGET} -x -r ${.TARGET}
realinstall:
${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m 444 ${OBJS} \
@@ -50,9 +44,6 @@ depend: .depend
mkdep ${CFLAGS} -DCRT0 -DDYNAMIC ${.CURDIR}/crt0.c
mkdep -a ${CFLAGS} ${.CURDIR}/c++rt0.c
-cleandepend:
- rm -f .depend
-
lint tags:
.include <bsd.prog.mk>
diff --git a/lib/csu/i386/crt0.c b/lib/csu/i386/crt0.c
index 4989c5c55a44c..8286e74057acb 100644
--- a/lib/csu/i386/crt0.c
+++ b/lib/csu/i386/crt0.c
@@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: crt0.c,v 1.34 1998/02/11 04:57:12 jdp Exp $
+ * $Id: crt0.c,v 1.33 1998/02/09 06:05:09 jdp Exp $
*/
#include <sys/param.h>
@@ -115,14 +115,14 @@ void monstartup(void *low, void *high);
#define _exit(v) \
__syscall(SYS_exit, (int)(v))
#define _open(name, f, m) \
- __syscall(SYS_open, (const char *)(name), (int)(f), (int)(m))
+ __syscall(SYS_open, (char *)(name), (int)(f), (int)(m))
#define _read(fd, s, n) \
__syscall(SYS_read, (int)(fd), (void *)(s), (size_t)(n))
#define _write(fd, s, n) \
- __syscall(SYS_write, (int)(fd), (const void *)(s), (size_t)(n))
+ __syscall(SYS_write, (int)(fd), (void *)(s), (size_t)(n))
#define _mmap(addr, len, prot, flags, fd, off) \
- (void *) __syscall(SYS_mmap, (void *)(addr), (size_t)(len), \
- (int)(prot), (int)(flags), (int)(fd), 0, (off_t)(off))
+ (caddr_t) __syscall(SYS_mmap, (caddr_t)(addr), (size_t)(len), \
+ (int)(prot), (int)(flags), (int)(fd), (long)0L, (off_t)(off))
#define _PUTNMSG(str, len) _write(2, (str), (len))
#define _PUTMSG(str) _PUTNMSG((str), sizeof (str) - 1)
diff --git a/lib/libF77/MAIN.c b/lib/libF77/MAIN.c
deleted file mode 100644
index 99b7114b958ac..0000000000000
--- a/lib/libF77/MAIN.c
+++ /dev/null
@@ -1 +0,0 @@
-MAIN__(){}
diff --git a/lib/libalias/alias.c b/lib/libalias/alias.c
index 50e597f4364a2..48a852a250f4c 100644
--- a/lib/libalias/alias.c
+++ b/lib/libalias/alias.c
@@ -73,9 +73,6 @@
- Eliminated PacketAliasIn2() and
PacketAliasOut2() as poorly conceived.
- Version 2.3 Dec 1998 (dillon)
- - Major bounds checking additions, see FreeBSD/CVS
-
See HISTORY file for additional revisions.
*/
@@ -606,7 +603,6 @@ UdpAliasIn(struct ip *pip)
u_short alias_port;
int accumulate;
u_short *sptr;
- int r = 0;
alias_address = GetAliasAddress(link);
original_address = GetOriginalAddress(link);
@@ -617,11 +613,11 @@ UdpAliasIn(struct ip *pip)
if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
|| ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER )
{
- r = AliasHandleUdpNbt(pip, link, &original_address, ud->uh_dport);
+ AliasHandleUdpNbt(pip, link, &original_address, ud->uh_dport);
} else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
|| ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER )
{
- r = AliasHandleUdpNbtNS(pip, link,
+ AliasHandleUdpNbtNS(pip, link,
&alias_address,
&alias_port,
&original_address,
@@ -652,14 +648,7 @@ UdpAliasIn(struct ip *pip)
(u_short *) &pip->ip_dst,
2);
pip->ip_dst = original_address;
-
- /*
- * If we cannot figure out the packet, ignore it.
- */
- if (r < 0)
- return(PKT_ALIAS_IGNORED);
- else
- return(PKT_ALIAS_OK);
+ return(PKT_ALIAS_OK);
}
return(PKT_ALIAS_IGNORED);
}
diff --git a/lib/libalias/alias_db.c b/lib/libalias/alias_db.c
index dc9d020bd8580..7bbb19122bed6 100644
--- a/lib/libalias/alias_db.c
+++ b/lib/libalias/alias_db.c
@@ -437,7 +437,7 @@ ShowAliasStats(void)
{
/* Used for debugging */
- if (monitorFile)
+ if (packetAliasMode & PKT_ALIAS_LOG)
{
fprintf(monitorFile, "icmp=%d, udp=%d, tcp=%d, frag_id=%d frag_ptr=%d",
icmpLinkCount,
@@ -1837,10 +1837,8 @@ InitPacketAliasLog(void)
static void
UninitPacketAliasLog(void)
{
- if (monitorFile) {
+ if( monitorFile )
fclose(monitorFile);
- monitorFile = NULL;
- }
packetAliasMode &= ~PKT_ALIAS_LOG;
}
diff --git a/lib/libalias/alias_local.h b/lib/libalias/alias_local.h
index 38462810733a7..0e94a64b28147 100644
--- a/lib/libalias/alias_local.h
+++ b/lib/libalias/alias_local.h
@@ -90,8 +90,8 @@ void HouseKeeping(void);
/*lint -save -library Suppress flexelint warnings */
void AliasHandleFtpOut(struct ip *, struct alias_link *, int);
void AliasHandleIrcOut(struct ip *pip, struct alias_link *link, int maxsize );
-int AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short);
-int AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *);
+void AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short);
+void AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *);
void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *);
void AliasHandleCUSeeMeIn(struct ip *, struct in_addr);
diff --git a/lib/libalias/alias_nbt.c b/lib/libalias/alias_nbt.c
index cd07431f5cbf4..f3581a72d5ff4 100644
--- a/lib/libalias/alias_nbt.c
+++ b/lib/libalias/alias_nbt.c
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: alias_nbt.c,v 1.1 1998/05/24 03:03:10 amurai Exp $
+ * $Id:$
*
* TODO:
* oClean up.
@@ -132,21 +132,15 @@ void PrintRcode( u_char rcode ) {
/* Handling Name field */
-u_char *AliasHandleName ( u_char *p, char *pmax ) {
+u_char *AliasHandleName ( u_char *p ) {
u_char *s;
u_char c;
int compress;
/* Following length field */
-
- if (p == NULL || (char *)p >= pmax)
- return(NULL);
-
if (*p & 0xc0 ) {
p = p + 2;
- if ((char *)p > pmax)
- return(NULL);
return ((u_char *)p);
}
while ( ( *p & 0x3f) != 0x00 ) {
@@ -158,10 +152,6 @@ u_char *AliasHandleName ( u_char *p, char *pmax ) {
/* Get next length field */
p = (u_char *)(p + (*p & 0x3f) + 1);
- if ((char *)p > pmax) {
- p = NULL;
- break;
- }
#ifdef DEBUG
printf(":");
#endif
@@ -189,10 +179,7 @@ u_char *AliasHandleName ( u_char *p, char *pmax ) {
}
/* Set up to out of Name field */
- if (p == NULL || (char *)p >= pmax)
- p = NULL;
- else
- p++;
+ p++;
return ((u_char *)p);
}
@@ -207,24 +194,19 @@ u_char *AliasHandleName ( u_char *p, char *pmax ) {
#define DGM_POSITIVE_RES 0x15
#define DGM_NEGATIVE_RES 0x16
-int AliasHandleUdpNbt(
+void AliasHandleUdpNbt(
struct ip *pip, /* IP packet to examine/patch */
struct alias_link *link,
struct in_addr *alias_address,
- u_short alias_port
-) {
+ u_short alias_port )
+{
struct udphdr * uh;
NbtDataHeader *ndh;
- u_char *p = NULL;
- char *pmax;
+ u_char *p;
/* Calculate data length of UDP packet */
uh = (struct udphdr *) ((char *) pip + (pip->ip_hl << 2));
- pmax = (char *)uh + ntohs( uh->uh_ulen );
-
ndh = (NbtDataHeader *)((char *)uh + (sizeof (struct udphdr)));
- if ((char *)(ndh + 1) > pmax)
- return(-1);
#ifdef DEBUG
printf("\nType=%02x,", ndh->type );
#endif
@@ -233,8 +215,8 @@ int AliasHandleUdpNbt(
case DGM_DIRECT_GROUP:
case DGM_BROADCAST:
p = (u_char *)ndh + 14;
- p = AliasHandleName ( p, pmax ); /* Source Name */
- p = AliasHandleName ( p, pmax ); /* Destination Name */
+ p = AliasHandleName ( p ); /* Source Name */
+ p = AliasHandleName ( p ); /* Destination Name */
break;
case DGM_ERROR:
p = (u_char *)ndh + 11;
@@ -243,11 +225,9 @@ int AliasHandleUdpNbt(
case DGM_POSITIVE_RES:
case DGM_NEGATIVE_RES:
p = (u_char *)ndh + 10;
- p = AliasHandleName ( p, pmax ); /* Destination Name */
+ p = AliasHandleName ( p ); /* Destination Name */
break;
}
- if (p == NULL || (char *)p > pmax)
- p = NULL;
#ifdef DEBUG
printf("%s:%d-->", inet_ntoa(ndh->source_ip), ntohs(ndh->source_port) );
#endif
@@ -271,7 +251,6 @@ int AliasHandleUdpNbt(
printf("%s:%d\n", inet_ntoa(ndh->source_ip), ntohs(ndh->source_port) );
fflush(stdout);
#endif
- return((p == NULL) ? -1 : 0);
}
/* Question Section */
#define QS_TYPE_NB 0x0020
@@ -282,22 +261,14 @@ typedef struct {
u_short class; /* The class of Request */
} NBTNsQuestion;
-u_char *
-AliasHandleQuestion(
- u_short count,
+u_char *AliasHandleQuestion(u_short count,
NBTNsQuestion *q,
- char *pmax,
NBTArguments *nbtarg)
{
while ( count != 0 ) {
/* Name Filed */
- q = (NBTNsQuestion *)AliasHandleName((u_char *)q, pmax);
-
- if (q == NULL || (char *)(q + 1) > pmax) {
- q = NULL;
- break;
- }
+ q = (NBTNsQuestion *)AliasHandleName((u_char *)q );
/* Type and Class filed */
switch ( ntohs(q->type) ) {
@@ -337,17 +308,12 @@ typedef struct {
struct in_addr addr;
} NBTNsRNB;
-u_char *
-AliasHandleResourceNB(
- NBTNsResource *q,
- char *pmax,
+u_char *AliasHandleResourceNB( NBTNsResource *q,
NBTArguments *nbtarg)
{
NBTNsRNB *nb;
u_short bcount;
- if (q == NULL || (char *)(q + 1) > pmax)
- return(NULL);
/* Check out a length */
bcount = ntohs(q->rdlen);
@@ -359,11 +325,7 @@ AliasHandleResourceNB(
printf("NB rec[%s", inet_ntoa(nbtarg->oldaddr));
printf("->%s, %dbytes] ",inet_ntoa(nbtarg->newaddr ), bcount);
#endif
- while ( nb != NULL && bcount != 0 ) {
- if ((char *)(nb + 1) > pmax) {
- nb = NULL;
- break;
- }
+ while ( bcount != 0 ) {
#ifdef DEBUG
printf("<%s>", inet_ntoa(nb->addr) );
#endif
@@ -394,9 +356,6 @@ AliasHandleResourceNB(
nb=(NBTNsRNB *)((u_char *)nb + SizeOfNsRNB);
bcount -= SizeOfNsRNB;
}
- if (nb == NULL || (char *)(nb + 1) > pmax) {
- nb = NULL;
- }
return ((u_char *)nb);
}
@@ -406,18 +365,12 @@ typedef struct {
struct in_addr addr;
} NBTNsResourceA;
-u_char *
-AliasHandleResourceA(
- NBTNsResource *q,
- char *pmax,
+u_char *AliasHandleResourceA( NBTNsResource *q,
NBTArguments *nbtarg)
{
NBTNsResourceA *a;
u_short bcount;
- if (q == NULL || (char *)(q + 1) > pmax)
- return(NULL);
-
/* Forward to Resource A position */
a = (NBTNsResourceA *)( (u_char *)q + sizeof(NBTNsResource) );
@@ -430,8 +383,6 @@ AliasHandleResourceA(
printf("->%s]",inet_ntoa(nbtarg->newaddr ));
#endif
while ( bcount != 0 ) {
- if (a == NULL || (char *)(a + 1) > pmax)
- return(NULL);
#ifdef DEBUG
printf("..%s", inet_ntoa(a->addr) );
#endif
@@ -454,8 +405,6 @@ AliasHandleResourceA(
a++; /*XXXX*/
bcount -= SizeOfResourceA;
}
- if (a == NULL || (char *)(a + 1) > pmax)
- a = NULL;
return ((u_char *)a);
}
@@ -463,18 +412,12 @@ typedef struct {
u_short opcode:4, flags:8, resv:4;
} NBTNsResourceNULL;
-u_char *
-AliasHandleResourceNULL(
- NBTNsResource *q,
- char *pmax,
+u_char *AliasHandleResourceNULL( NBTNsResource *q,
NBTArguments *nbtarg)
{
NBTNsResourceNULL *n;
u_short bcount;
- if (q == NULL || (char *)(q + 1) > pmax)
- return(NULL);
-
/* Forward to Resource NULL position */
n = (NBTNsResourceNULL *)( (u_char *)q + sizeof(NBTNsResource) );
@@ -483,31 +426,19 @@ AliasHandleResourceNULL(
/* Processing all in_addr array */
while ( bcount != 0 ) {
- if ((char *)(n + 1) > pmax) {
- n = NULL;
- break;
- }
n++;
bcount -= sizeof(NBTNsResourceNULL);
}
- if ((char *)(n + 1) > pmax)
- n = NULL;
return ((u_char *)n);
}
-u_char *
-AliasHandleResourceNS(
- NBTNsResource *q,
- char *pmax,
+u_char *AliasHandleResourceNS( NBTNsResource *q,
NBTArguments *nbtarg)
{
NBTNsResourceNULL *n;
u_short bcount;
- if (q == NULL || (char *)(q + 1) > pmax)
- return(NULL);
-
/* Forward to Resource NULL position */
n = (NBTNsResourceNULL *)( (u_char *)q + sizeof(NBTNsResource) );
@@ -515,11 +446,8 @@ AliasHandleResourceNS(
bcount = ntohs(q->rdlen);
/* Resource Record Name Filed */
- q = (NBTNsResource *)AliasHandleName( (u_char *)n, pmax ); /* XXX */
+ q = (NBTNsResource *)AliasHandleName( (u_char *)n ); /* XXX */
- if (q == NULL || (char *)((u_char *)n + bcount) > pmax)
- return(NULL);
- else
return ((u_char *)n + bcount);
}
@@ -527,44 +455,28 @@ typedef struct {
u_short numnames;
} NBTNsResourceNBSTAT;
-u_char *
-AliasHandleResourceNBSTAT(
- NBTNsResource *q,
- char *pmax,
+u_char *AliasHandleResourceNBSTAT( NBTNsResource *q,
NBTArguments *nbtarg)
{
NBTNsResourceNBSTAT *n;
u_short bcount;
- if (q == NULL || (char *)(q + 1) > pmax)
- return(NULL);
-
/* Forward to Resource NBSTAT position */
n = (NBTNsResourceNBSTAT *)( (u_char *)q + sizeof(NBTNsResource) );
/* Check out of length */
bcount = ntohs(q->rdlen);
- if (q == NULL || (char *)((u_char *)n + bcount) > pmax)
- return(NULL);
- else
return ((u_char *)n + bcount);
}
-u_char *
-AliasHandleResource(
- u_short count,
+u_char *AliasHandleResource(u_short count,
NBTNsResource *q,
- char *pmax,
- NBTArguments
- *nbtarg)
+ NBTArguments *nbtarg)
{
while ( count != 0 ) {
/* Resource Record Name Filed */
- q = (NBTNsResource *)AliasHandleName( (u_char *)q, pmax );
-
- if (q == NULL || (char *)(q + 1) > pmax)
- break;
+ q = (NBTNsResource *)AliasHandleName( (u_char *)q );
#ifdef DEBUG
printf("type=%02x, count=%d\n", ntohs(q->type), count );
#endif
@@ -572,45 +484,22 @@ AliasHandleResource(
/* Type and Class filed */
switch ( ntohs(q->type) ) {
case RR_TYPE_NB:
- q = (NBTNsResource *)AliasHandleResourceNB(
- q,
- pmax,
- nbtarg
- );
+ q = (NBTNsResource *)AliasHandleResourceNB( q, nbtarg );
break;
case RR_TYPE_A:
- q = (NBTNsResource *)AliasHandleResourceA(
- q,
- pmax,
- nbtarg
- );
+ q = (NBTNsResource *)AliasHandleResourceA( q, nbtarg );
break;
case RR_TYPE_NS:
- q = (NBTNsResource *)AliasHandleResourceNS(
- q,
- pmax,
- nbtarg
- );
+ q = (NBTNsResource *)AliasHandleResourceNS( q, nbtarg );
break;
case RR_TYPE_NULL:
- q = (NBTNsResource *)AliasHandleResourceNULL(
- q,
- pmax,
- nbtarg
- );
+ q = (NBTNsResource *)AliasHandleResourceNULL( q, nbtarg );
break;
case RR_TYPE_NBSTAT:
- q = (NBTNsResource *)AliasHandleResourceNBSTAT(
- q,
- pmax,
- nbtarg
- );
+ q = (NBTNsResource *)AliasHandleResourceNBSTAT( q, nbtarg );
break;
- default:
- printf(
- "\nUnknown Type of Resource %0x\n",
- ntohs(q->type)
- );
+ default: printf("\nUnknown Type of Resource %0x\n",
+ ntohs(q->type) );
break;
}
count--;
@@ -619,7 +508,7 @@ AliasHandleResource(
return ((u_char *)q);
}
-int AliasHandleUdpNbtNS(
+void AliasHandleUdpNbtNS(
struct ip *pip, /* IP packet to examine/patch */
struct alias_link *link,
struct in_addr *alias_address,
@@ -629,8 +518,8 @@ int AliasHandleUdpNbtNS(
{
struct udphdr * uh;
NbtNSHeader * nsh;
+ u_short dlen;
u_char * p;
- char *pmax;
NBTArguments nbtarg;
/* Set up Common Parameter */
@@ -642,16 +531,12 @@ int AliasHandleUdpNbtNS(
/* Calculate data length of UDP packet */
uh = (struct udphdr *) ((char *) pip + (pip->ip_hl << 2));
nbtarg.uh_sum = &(uh->uh_sum);
+ dlen = ntohs( uh->uh_ulen );
nsh = (NbtNSHeader *)((char *)uh + (sizeof(struct udphdr)));
p = (u_char *)(nsh + 1);
- pmax = (char *)uh + ntohs( uh->uh_ulen );
-
- if ((char *)(nsh + 1) > pmax)
- return(-1);
#ifdef DEBUG
- printf(" [%s] ID=%02x, op=%01x, flag=%02x, rcode=%01x, qd=%04x"
- ", an=%04x, ns=%04x, ar=%04x, [%d]-->",
+ printf(" [%s] ID=%02x, op=%01x, flag=%02x, rcode=%01x, qd=%04x, an=%04x, ns=%04x, ar=%04x, [%d]-->",
nsh->dir ? "Response": "Request",
nsh->nametrid,
nsh->opcode,
@@ -661,53 +546,31 @@ int AliasHandleUdpNbtNS(
ntohs(nsh->ancount),
ntohs(nsh->nscount),
ntohs(nsh->arcount),
- (u_char *)p -(u_char *)nsh
- );
+ (u_char *)p -(u_char *)nsh);
#endif
/* Question Entries */
if (ntohs(nsh->qdcount) !=0 ) {
- p = AliasHandleQuestion(
- ntohs(nsh->qdcount),
- (NBTNsQuestion *)p,
- pmax,
- &nbtarg
- );
+ p = AliasHandleQuestion(ntohs(nsh->qdcount), (NBTNsQuestion *)p, &nbtarg );
}
/* Answer Resource Records */
if (ntohs(nsh->ancount) !=0 ) {
- p = AliasHandleResource(
- ntohs(nsh->ancount),
- (NBTNsResource *)p,
- pmax,
- &nbtarg
- );
+ p = AliasHandleResource(ntohs(nsh->ancount), (NBTNsResource *)p, &nbtarg );
}
/* Authority Resource Recodrs */
if (ntohs(nsh->nscount) !=0 ) {
- p = AliasHandleResource(
- ntohs(nsh->nscount),
- (NBTNsResource *)p,
- pmax,
- &nbtarg
- );
+ p = AliasHandleResource(ntohs(nsh->nscount), (NBTNsResource *)p, &nbtarg );
}
/* Additional Resource Recodrs */
if (ntohs(nsh->arcount) !=0 ) {
- p = AliasHandleResource(
- ntohs(nsh->arcount),
- (NBTNsResource *)p,
- pmax,
- &nbtarg
- );
+ p = AliasHandleResource(ntohs(nsh->arcount), (NBTNsResource *)p, &nbtarg );
}
#ifdef DEBUG
PrintRcode(nsh->rcode);
#endif
- return ((p == NULL) ? -1 : 0);
+ return;
}
-
diff --git a/lib/libalias/libalias.3 b/lib/libalias/libalias.3
index f9b36e6c6d718..b3fcc91294513 100644
--- a/lib/libalias/libalias.3
+++ b/lib/libalias/libalias.3
@@ -26,8 +26,8 @@ of the text.
2.4 PacketAliasSetMode()
2.5 PacketAliasSetFWBase()
3. Packet Handling
- 3.1 PacketAliasIn()
- 3.2 PacketAliasOut()
+ 3.1 PacketAliasOut()
+ 3.2 PacketAliasIn()
4. Port and Address Redirection
4.1 PacketAliasRedirectPort()
4.2 PacketAliasRedirectAddr()
@@ -325,7 +325,7 @@ them with PacketAliasFragmentIn().
.Ss 3.2 PacketAliasOut()
.Ft int
-.Fn PacketAliasOut "char *buffer" "int maxpacketsize"
+.Fn PacketAliasIn "char *buffer" "int maxpacketsize"
An outgoing packet coming from the local network
to a remote machine is aliased by this function.
diff --git a/lib/libc/alpha/SYS.h b/lib/libc/alpha/SYS.h
index 01d114d2903a3..cfc0909d8d321 100644
--- a/lib/libc/alpha/SYS.h
+++ b/lib/libc/alpha/SYS.h
@@ -1,4 +1,4 @@
-/* $Id: SYS.h,v 1.4 1998/12/23 11:50:51 dfr Exp $ */
+/* $Id: SYS.h,v 1.2 1998/06/09 22:43:34 jb Exp $ */
/* From: NetBSD: SYS.h,v 1.5 1997/05/02 18:15:15 kleink Exp */
/*
@@ -41,7 +41,7 @@
LLABEL(name,0): \
LDGP(gp); \
beq a3, LLABEL(name,1); \
- jmp zero, .cerror; \
+ jmp zero, cerror; \
LLABEL(name,1):
diff --git a/lib/libc/alpha/gen/Makefile.inc b/lib/libc/alpha/gen/Makefile.inc
index cc7a87c10cffd..3ff99f0014397 100644
--- a/lib/libc/alpha/gen/Makefile.inc
+++ b/lib/libc/alpha/gen/Makefile.inc
@@ -1,8 +1,10 @@
-# $Id: Makefile.inc,v 1.4 1998/08/17 03:38:54 jb Exp $
+# $Id: Makefile.inc,v 1.3 1998/08/08 02:18:07 jb Exp $
SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.c ldexp.c modf.c setjmp.S
-SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
- fpsetround.c fpsetsticky.c
+SRCS+= flt_rounds.c
+
+#SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
+# fpsetround.c fpsetsticky.c
SRCS+= sigsetjmp.S
SRCS+= __divqu.S __divq.S __divlu.S __divl.S
diff --git a/lib/libc/alpha/gen/fpgetmask.c b/lib/libc/alpha/gen/fpgetmask.c
index 516ae981d55c7..c52a7ef071129 100644
--- a/lib/libc/alpha/gen/fpgetmask.c
+++ b/lib/libc/alpha/gen/fpgetmask.c
@@ -31,19 +31,12 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
#include <ieeefp.h>
-#include <machine/sysarch.h>
-
-struct params {
- u_int64_t mask;
-};
fp_except
fpgetmask()
{
- struct params p;
- sysarch(ALPHA_GET_FPMASK, (char *) &p);
- return((fp_except) p.mask);
+ /* XXX */
+ abort();
}
diff --git a/lib/libc/alpha/gen/fpgetround.c b/lib/libc/alpha/gen/fpgetround.c
index 46976c2e4c11e..39b9b4744a6be 100644
--- a/lib/libc/alpha/gen/fpgetround.c
+++ b/lib/libc/alpha/gen/fpgetround.c
@@ -33,7 +33,6 @@
#include <sys/types.h>
#include <ieeefp.h>
-#include <machine/fpu.h>
fp_rnd
fpgetround()
@@ -41,8 +40,10 @@ fpgetround()
double fpcrval;
u_int64_t old;
- GET_FPCR(fpcrval);
+ __asm__("trapb");
+ __asm__("mf_fpcr %0" : "=f" (fpcrval));
+ __asm__("trapb");
old = *(u_int64_t *)&fpcrval;
- return ((old & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT);
+ return ((old >> 58) & 0x3);
}
diff --git a/lib/libc/alpha/gen/fpgetsticky.c b/lib/libc/alpha/gen/fpgetsticky.c
index c0ff4d75c88ab..c36db3913d5ff 100644
--- a/lib/libc/alpha/gen/fpgetsticky.c
+++ b/lib/libc/alpha/gen/fpgetsticky.c
@@ -31,18 +31,12 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
#include <ieeefp.h>
-#include <machine/fpu.h>
fp_except
fpgetsticky()
{
- double fpcrval;
- u_int64_t old;
- GET_FPCR(fpcrval);
- old = *(u_int64_t *)&fpcrval;
- return (((old >> IEEE_STATUS_TO_FPCR_SHIFT) & IEEE_STATUS_MASK)
- >> IEEE_STATUS_TO_EXCSUM_SHIFT);
+ /* XXX */
+ abort();
}
diff --git a/lib/libc/alpha/gen/fpsetmask.c b/lib/libc/alpha/gen/fpsetmask.c
index 05201ce81d405..87fc5a2f4b4ce 100644
--- a/lib/libc/alpha/gen/fpsetmask.c
+++ b/lib/libc/alpha/gen/fpsetmask.c
@@ -31,21 +31,13 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
#include <ieeefp.h>
-#include <machine/sysarch.h>
-
-struct params {
- u_int64_t mask;
-};
fp_except
fpsetmask(mask)
fp_except mask;
{
- struct params p;
- p.mask = (u_int64_t) mask;
- sysarch(ALPHA_SET_FPMASK, (char *) &p);
- return ((fp_except) p.mask);
+ /* XXX */
+ abort();
}
diff --git a/lib/libc/alpha/gen/fpsetround.c b/lib/libc/alpha/gen/fpsetround.c
index 0d8f40af6d651..c28093cad87c1 100644
--- a/lib/libc/alpha/gen/fpsetround.c
+++ b/lib/libc/alpha/gen/fpsetround.c
@@ -33,7 +33,6 @@
#include <sys/types.h>
#include <ieeefp.h>
-#include <machine/fpu.h>
fp_rnd
fpsetround(rnd_dir)
@@ -42,14 +41,18 @@ fpsetround(rnd_dir)
double fpcrval;
u_int64_t old, new;
- GET_FPCR(fpcrval);
+ __asm__("trapb");
+ __asm__("mf_fpcr %0" : "=f" (fpcrval));
+ __asm__("trapb");
old = *(u_int64_t *)&fpcrval;
- new = old & (~FPCR_DYN_MASK);
- new |= ((long) rnd_dir << FPCR_DYN_SHIFT) & FPCR_DYN_MASK;
-
+ new = old & ~(long)0x0c00000000000000;
+ new = (long)rnd_dir << 58;
*(u_int64_t *)&fpcrval = new;
- SET_FPCR(fpcrval);
- return ((old & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT);
+ __asm__("trapb");
+ __asm__("mt_fpcr %0" : : "f" (fpcrval));
+ __asm__("trapb");
+
+ return ((old >> 58) & 0x3);
}
diff --git a/lib/libc/alpha/gen/fpsetsticky.c b/lib/libc/alpha/gen/fpsetsticky.c
index ae0d742f79f06..90a993ee642a0 100644
--- a/lib/libc/alpha/gen/fpsetsticky.c
+++ b/lib/libc/alpha/gen/fpsetsticky.c
@@ -31,25 +31,13 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
#include <ieeefp.h>
-#include <machine/fpu.h>
fp_except
fpsetsticky(sticky)
fp_except sticky;
{
- double fpcrval;
- u_int64_t old,new ;
- GET_FPCR(fpcrval);
- old = *(u_int64_t *)&fpcrval;
- new = old & ~ (IEEE_STATUS_MASK << IEEE_STATUS_TO_FPCR_SHIFT);
- new |= ((sticky << IEEE_STATUS_TO_EXCSUM_SHIFT) & IEEE_STATUS_MASK)
- << IEEE_STATUS_TO_FPCR_SHIFT;
- *(u_int64_t *)&fpcrval = new;
- SET_FPCR(fpcrval);
-
- return (((old >> IEEE_STATUS_TO_FPCR_SHIFT) & IEEE_STATUS_MASK)
- >> IEEE_STATUS_TO_EXCSUM_SHIFT);
+ /* XXX */
+ abort();
}
diff --git a/lib/libc/alpha/gen/setjmp.S b/lib/libc/alpha/gen/setjmp.S
index a6d10836ae954..86dbb38f1b903 100644
--- a/lib/libc/alpha/gen/setjmp.S
+++ b/lib/libc/alpha/gen/setjmp.S
@@ -68,7 +68,7 @@ LEAF(setjmp, 1)
lda sp, -24(sp) /* sizeof struct sigaltstack */
mov zero, a0
mov sp, a1
- PCALL(sigaltstack)
+ CALL(sigaltstack)
ldl t0, 16(sp) /* offset of ss_flags */
lda sp, 24(sp) /* sizeof struct sigaltstack */
ldq ra, ((26 + 4) * 8)(s0) /* restore return address */
diff --git a/lib/libc/alpha/sys/cerror.S b/lib/libc/alpha/sys/cerror.S
index 63771c0ffa080..cce30068de6ca 100644
--- a/lib/libc/alpha/sys/cerror.S
+++ b/lib/libc/alpha/sys/cerror.S
@@ -1,4 +1,4 @@
-/* $Id: cerror.S,v 1.3 1998/12/23 11:50:51 dfr Exp $ */
+/* $Id$ */
/* From: NetBSD: cerror.S,v 1.4 1996/11/08 00:52:46 cgd Exp */
/*
@@ -34,7 +34,7 @@
#define FRAME_RA_OFFSET 0
#define FRAME_V0_OFFSET 8
-NESTED(.cerror, 0, FRAME_SIZE, ra, IM_RA|IM_V0, 0)
+NESTED(cerror, 0, FRAME_SIZE, ra, IM_RA|IM_V0, 0)
br t0, L1
L1: LDGP(t0)
@@ -51,4 +51,4 @@ L1: LDGP(t0)
ldq ra, FRAME_RA_OFFSET(sp)
lda sp, FRAME_SIZE(sp)
RET
-END(.cerror)
+END(cerror)
diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c
index 65b02c1906658..a5260687149a3 100644
--- a/lib/libc/gen/fstab.c
+++ b/lib/libc/gen/fstab.c
@@ -35,13 +35,8 @@
static char sccsid[] = "@(#)fstab.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-
#include <errno.h>
#include <fstab.h>
-#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -52,30 +47,8 @@ static struct fstab _fs_fstab;
static int LineNo = 0;
static void error __P((int));
-static void fixfsfile __P((void));
static int fstabscan __P((void));
-static void
-fixfsfile()
-{
- static char buf[sizeof(_PATH_DEV) + MNAMELEN];
- struct stat sb;
- struct statfs sf;
-
- if (strcmp(_fs_fstab.fs_file, "/") != 0)
- return;
- if (statfs("/", &sf) != 0)
- return;
- if (sf.f_mntfromname[0] == '/')
- buf[0] = '\0';
- else
- strcpy(buf, _PATH_DEV);
- strcat(buf, sf.f_mntfromname);
- if (stat(buf, &sb) != 0 || !S_ISBLK(sb.st_mode))
- return;
- _fs_fstab.fs_spec = buf;
-}
-
static int
fstabscan()
{
@@ -96,7 +69,6 @@ fstabscan()
if (!strpbrk(p, " \t")) {
_fs_fstab.fs_spec = strsep(&p, ":\n");
_fs_fstab.fs_file = strsep(&p, ":\n");
- fixfsfile();
_fs_fstab.fs_type = strsep(&p, ":\n");
if (_fs_fstab.fs_type) {
if (!strcmp(_fs_fstab.fs_type, FSTAB_XX))
@@ -124,7 +96,6 @@ fstabscan()
while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0')
;
_fs_fstab.fs_file = cp;
- fixfsfile();
while ((cp = strsep(&p, " \t\n")) != NULL && *cp == '\0')
;
_fs_fstab.fs_vfstype = cp;
diff --git a/lib/libc/gen/getloadavg.3 b/lib/libc/gen/getloadavg.3
index 8d8facf4b8b4d..fa5b5715a5ff9 100644
--- a/lib/libc/gen/getloadavg.3
+++ b/lib/libc/gen/getloadavg.3
@@ -38,7 +38,6 @@
.Nm getloadavg
.Nd get system load averages
.Sh SYNOPSIS
-.Fd #include <stdlib.h>
.Ft int
.Fn getloadavg "double loadavg[]" "int nelem"
.Sh DESCRIPTION
diff --git a/lib/libc/gen/getobjformat.3 b/lib/libc/gen/getobjformat.3
index ad7ff438b234d..228bb5f448834 100644
--- a/lib/libc/gen/getobjformat.3
+++ b/lib/libc/gen/getobjformat.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: getobjformat.3,v 1.1 1998/09/09 01:21:24 jdp Exp $
+.\" $Id$
.\"
.Dd September 7, 1998
.Dt GETOBJFORMAT 3
@@ -103,22 +103,12 @@ and its null terminator,
returns -1. In that case, the contents of the buffer and argument
vector supplied by the caller are indeterminate.
.Sh ENVIRONMENT
-.Bl -tag -width OBJFORMAT
-.It Ev OBJFORMAT
-If the environment variable
.Ev OBJFORMAT
-is set, it overrides the default object file format.
-.Ev OBJFORMAT takes precedence over
-.Pa /etc/objformat .
.Sh FILES
-.Bl -tag -width /etc/objformat -compact
-.It Pa /etc/objformat
-If present, specifies the object file format to use. Syntax is
-.Ql OBJFORMAT=xxx .
+.Pa /etc/objformat
.Sh SEE ALSO
.Xr objformat 1
.Sh HISTORY
The
.Fn getobjformat
-function first appeared in
-.Fx 3.0 .
+function first appeared in FreeBSD 3.0.
diff --git a/lib/libc/gen/getpwent.3 b/lib/libc/gen/getpwent.3
index 94fc4063f30b4..8772a429e7e49 100644
--- a/lib/libc/gen/getpwent.3
+++ b/lib/libc/gen/getpwent.3
@@ -72,8 +72,8 @@ file
struct passwd {
char *pw_name; /* user name */
char *pw_passwd; /* encrypted password */
- uid_t pw_uid; /* user uid */
- gid_t pw_gid; /* user gid */
+ int pw_uid; /* user uid */
+ int pw_gid; /* user gid */
time_t pw_change; /* password change time */
char *pw_class; /* user access class */
char *pw_gecos; /* Honeywell login info */
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index 2ee0e32aabc7b..02ec190519fed 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -154,9 +154,7 @@ getpwnam(name)
bf[0] = _PW_KEYBYNAME;
len = strlen(name);
- if (len > UT_NAMESIZE)
- return(NULL);
- bcopy(name, bf + 1, len);
+ bcopy(name, bf + 1, MIN(len, UT_NAMESIZE));
key.data = (u_char *)bf;
key.size = len + 1;
rval = __hashpw(&key);
diff --git a/lib/libc/gen/getvfsbyname.c b/lib/libc/gen/getvfsbyname.c
index 7f8a9703710a1..57d1db4e7744c 100644
--- a/lib/libc/gen/getvfsbyname.c
+++ b/lib/libc/gen/getvfsbyname.c
@@ -36,13 +36,15 @@
static char sccsid[] = "@(#)kvm_getvfsbyname.c 8.1 (Berkeley) 4/3/95";
#endif
static const char rcsid[] =
- "$Id: getvfsbyname.c,v 1.3 1998/03/09 04:36:07 jb Exp $";
+ "$Id: getvfsbyname.c,v 1.2 1997/03/03 13:08:33 bde Exp $";
#endif /* not lint */
+#define _NEW_VFSCONF
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/sysctl.h>
#include <errno.h>
+#include <kvm.h>
/*
* Given a filesystem name, determine if it is resident in the kernel,
diff --git a/lib/libc/gen/getvfsent.c b/lib/libc/gen/getvfsent.c
index 8aa147db76aba..469ef975c1e94 100644
--- a/lib/libc/gen/getvfsent.c
+++ b/lib/libc/gen/getvfsent.c
@@ -193,7 +193,6 @@ vfspath(const char *name)
int
vfsisloadable(const char *name)
{
-#if 0
int fd;
fd = open("/dev/lkm", O_RDWR, 0);
@@ -203,24 +202,16 @@ vfsisloadable(const char *name)
close(fd);
return !!vfspath(name);
-#else
- return 1;
-#endif
}
int
vfsload(const char *name)
{
- const char *path;
+ const char *path = vfspath(name);
char name_mod[sizeof("_mod") + strlen(name)];
pid_t pid;
int status;
- status = kldload(name);
- if (status != -1)
- return 0;
-
- path = vfspath(name);
if(!path) {
errno = ENOENT;
return -1;
diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c
index 55f4f3978bb0f..ebd4234c9c2a6 100644
--- a/lib/libc/gen/nlist.c
+++ b/lib/libc/gen/nlist.c
@@ -29,8 +29,6 @@
* 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.
- *
- * $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -199,7 +197,18 @@ __aout_fdnlist(fd, list)
#endif
#ifdef _NLIST_DO_ELF
-static void elf_sym_to_nlist __P((struct nlist *, Elf_Sym *, Elf_Shdr *, int));
+
+#if ELF_TARG_CLASS == ELFCLASS32
+
+#define Elf(x) Elf32_##x
+#define ELF(x) ELF32_##x
+
+#else
+
+#define Elf(x) Elf64_##x
+#define ELF(x) ELF64_##x
+
+#endif
/*
* __elf_is_okay__ - Determine if ehdr really
@@ -210,13 +219,13 @@ static void elf_sym_to_nlist __P((struct nlist *, Elf_Sym *, Elf_Shdr *, int));
*/
int
__elf_is_okay__(ehdr)
- register Elf_Ehdr *ehdr;
+ register Elf(Ehdr) *ehdr;
{
register int retval = 0;
/*
* We need to check magic, class size, endianess,
* and version before we look at the rest of the
- * Elf_Ehdr structure. These few elements are
+ * Elf(Ehdr) structure. These few elements are
* represented in a machine independant fashion.
*/
if (IS_ELF(*ehdr) &&
@@ -238,19 +247,15 @@ __elf_fdnlist(fd, list)
register struct nlist *list;
{
register struct nlist *p;
+ register caddr_t strtab;
register Elf_Off symoff = 0, symstroff = 0;
register Elf_Word symsize = 0, symstrsize = 0;
- register Elf_Sword cc, i;
- int nent = -1;
- int errsave;
+ register Elf_Sword nent, cc, i;
Elf_Sym sbuf[1024];
Elf_Sym *s;
Elf_Ehdr ehdr;
- char *strtab = NULL;
Elf_Shdr *shdr = NULL;
- Elf_Shdr *sh;
Elf_Word shdr_size;
- void *base;
struct stat st;
/* Make sure obj is OK */
@@ -270,11 +275,10 @@ __elf_fdnlist(fd, list)
}
/* mmap section header table */
- base = mmap(NULL, (size_t)shdr_size, PROT_READ, 0, fd,
- (off_t)ehdr.e_shoff);
- if (base == MAP_FAILED)
+ shdr = (Elf_Shdr *)mmap(NULL, (size_t)shdr_size,
+ PROT_READ, 0, fd, (off_t) ehdr.e_shoff);
+ if (shdr == (Elf_Shdr *)-1)
return (-1);
- shdr = (Elf_Shdr *)base;
/*
* Find the symbol table entry and it's corresponding
@@ -292,10 +296,13 @@ __elf_fdnlist(fd, list)
}
}
+ /* Flush the section header table */
+ munmap((caddr_t)shdr, shdr_size);
+
/* Check for files too large to mmap. */
if (symstrsize > SIZE_T_MAX) {
errno = EFBIG;
- goto done;
+ return (-1);
}
/*
* Map string table into our address space. This gives us
@@ -303,11 +310,10 @@ __elf_fdnlist(fd, list)
* making the memory allocation permanent as with malloc/free
* (i.e., munmap will return it to the system).
*/
- base = mmap(NULL, (size_t)symstrsize, PROT_READ, 0, fd,
- (off_t)symstroff);
- if (base == MAP_FAILED)
- goto done;
- strtab = (char *)base;
+ strtab = mmap(NULL, (size_t)symstrsize, PROT_READ, 0, fd,
+ (off_t) symstroff);
+ if (strtab == (char *)-1)
+ return (-1);
/*
* clean out any left-over information for all valid entries.
@@ -329,6 +335,7 @@ __elf_fdnlist(fd, list)
}
/* Don't process any further if object is stripped. */
+ /* ELFism - dunno if stripped by looking at header */
if (symoff == 0)
goto done;
@@ -337,24 +344,43 @@ __elf_fdnlist(fd, list)
goto done;
}
- while (symsize > 0 && nent > 0) {
+ while (symsize > 0) {
cc = MIN(symsize, sizeof(sbuf));
if (read(fd, sbuf, cc) != cc)
break;
symsize -= cc;
- for (s = sbuf; cc > 0 && nent > 0; ++s, cc -= sizeof(*s)) {
- char *name;
- struct nlist *p;
+ for (s = sbuf; cc > 0; ++s, cc -= sizeof(*s)) {
+ register int soff = s->st_name;
- name = strtab + s->st_name;
- if (name[0] == '\0')
+ if (soff == 0)
continue;
for (p = list; !ISLAST(p); p++) {
if ((p->n_un.n_name[0] == '_' &&
- strcmp(name, p->n_un.n_name+1) == 0)
- || strcmp(name, p->n_un.n_name) == 0) {
- elf_sym_to_nlist(p, s, shdr,
- ehdr.e_shnum);
+ !strcmp(&strtab[soff], p->n_un.n_name+1))
+ || !strcmp(&strtab[soff], p->n_un.n_name)) {
+ p->n_value = s->st_value;
+
+ /* XXX - type conversion */
+ /* is pretty rude. */
+ switch(ELF(ST_TYPE)(s->st_info)) {
+ case STT_NOTYPE:
+ p->n_type = N_UNDF;
+ break;
+ case STT_OBJECT:
+ p->n_type = N_DATA;
+ break;
+ case STT_FUNC:
+ p->n_type = N_TEXT;
+ break;
+ case STT_FILE:
+ p->n_type = N_FN;
+ break;
+ }
+ if (ELF(ST_BIND)(s->st_info) ==
+ STB_LOCAL)
+ p->n_type = N_EXT;
+ p->n_desc = 0;
+ p->n_other = 0;
if (--nent <= 0)
break;
}
@@ -362,52 +388,8 @@ __elf_fdnlist(fd, list)
}
}
done:
- errsave = errno;
- if (strtab != NULL)
- munmap(strtab, symstrsize);
- if (shdr != NULL)
- munmap(shdr, shdr_size);
- errno = errsave;
- return (nent);
-}
+ munmap(strtab, symstrsize);
-/*
- * Convert an Elf_Sym into an nlist structure. This fills in only the
- * n_value and n_type members.
- */
-static void
-elf_sym_to_nlist(nl, s, shdr, shnum)
- struct nlist *nl;
- Elf_Sym *s;
- Elf_Shdr *shdr;
- int shnum;
-{
- nl->n_value = s->st_value;
-
- switch (s->st_shndx) {
- case SHN_UNDEF:
- case SHN_COMMON:
- nl->n_type = N_UNDF;
- break;
- case SHN_ABS:
- nl->n_type = ELF_ST_TYPE(s->st_info) == STT_FILE ?
- N_FN : N_ABS;
- break;
- default:
- if (s->st_shndx >= shnum)
- nl->n_type = N_UNDF;
- else {
- Elf_Shdr *sh = shdr + s->st_shndx;
-
- nl->n_type = sh->sh_type == SHT_PROGBITS ?
- (sh->sh_flags & SHF_WRITE ? N_DATA : N_TEXT) :
- (sh->sh_type == SHT_NOBITS ? N_BSS : N_UNDF);
- }
- break;
- }
-
- if (ELF_ST_BIND(s->st_info) == STB_GLOBAL ||
- ELF_ST_BIND(s->st_info) == STB_WEAK)
- nl->n_type |= N_EXT;
+ return (nent);
}
#endif /* _NLIST_DO_ELF */
diff --git a/lib/libc/gen/popen.3 b/lib/libc/gen/popen.3
index 600f5d085aad0..c4278e5f3e388 100644
--- a/lib/libc/gen/popen.3
+++ b/lib/libc/gen/popen.3
@@ -53,19 +53,16 @@ function
a process by creating a bidirectional pipe
forking,
and invoking the shell.
-Any streams opened by previous
-.Fn popen
-calls in the parent process are closed in the new child process.
Historically,
-.Fn popen
+.Nm popen
was implemented with a unidirectional pipe;
hence many implementations of
-.Fn popen
+.Nm popen
only allow the
.Fa type
argument to specify reading or writing, not both.
Since
-.Fn popen
+.Nm popen
is now implemented using a bidirectional pipe, the
.Fa type
argument may request a bidirectional data flow.
diff --git a/lib/libc/gen/psignal.3 b/lib/libc/gen/psignal.3
index aa78732d55aef..773759c1d89c9 100644
--- a/lib/libc/gen/psignal.3
+++ b/lib/libc/gen/psignal.3
@@ -57,9 +57,7 @@ If the argument
.Fa s
is
.Pf non- Dv NULL
-and does not point to the null character,
-.Fa s
-is written to the standard error file descriptor
+it is written to the standard error file descriptor
prior to the message string,
immediately followed by a colon and a space.
If the signal number is not recognized
diff --git a/lib/libc/gen/psignal.c b/lib/libc/gen/psignal.c
index 96eab9d45d14a..b7e7ab66761ab 100644
--- a/lib/libc/gen/psignal.c
+++ b/lib/libc/gen/psignal.c
@@ -49,13 +49,15 @@ psignal(sig, s)
const char *s;
{
register const char *c;
+ register int n;
if (sig < NSIG)
c = sys_siglist[sig];
else
c = "Unknown signal";
- if (s != NULL && *s != '\0') {
- (void)write(STDERR_FILENO, s, strlen(s));
+ n = strlen(s);
+ if (n) {
+ (void)write(STDERR_FILENO, s, n);
(void)write(STDERR_FILENO, ": ", 2);
}
(void)write(STDERR_FILENO, c, strlen(c));
diff --git a/lib/libc/gen/setmode.3 b/lib/libc/gen/setmode.3
index bc38fd3e11938..4c85b30e2a383 100644
--- a/lib/libc/gen/setmode.3
+++ b/lib/libc/gen/setmode.3
@@ -81,19 +81,10 @@ is to modify future file modes correctly.
.Pp
If the mode passed to
.Fn setmode
-is invalid or if memory cannot be allocated for the return value,
+is invalid,
.Fn setmode
returns
.Dv NULL .
-.Pp
-The value returned from
-.Fn setmode
-is obtained from
-.Fn malloc
-and should be returned to the system with
-.Fn free
-when the program is done with it, generally after a call to
-.Fn getmode .
.Sh ERRORS
The
.Fn setmode
diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3
index 02a185ca848ae..30e8e83eb8791 100644
--- a/lib/libc/gen/sysctl.3
+++ b/lib/libc/gen/sysctl.3
@@ -667,10 +667,9 @@ If the amount of free and cache memory falls below this value, the
pageout daemon will enter "memory conserving mode" to avoid deadlock.
.El
.Sh RETURN VALUES
+If the call to
.Fn sysctl
-and
-.Fn sysctlbyname
-return 0 when successful.
+is successful, the number of bytes copied out is returned.
Otherwise \-1 is returned and
.Va errno
is set appropriately.
diff --git a/lib/libc/gen/sysctl.c b/lib/libc/gen/sysctl.c
index 19709d5932e98..cb7448af32439 100644
--- a/lib/libc/gen/sysctl.c
+++ b/lib/libc/gen/sysctl.c
@@ -66,20 +66,16 @@ sysctl(name, namelen, oldp, oldlenp, newp, newlen)
switch (name[1]) {
case USER_CS_PATH:
- if (oldp && *oldlenp < sizeof(_PATH_STDPATH)) {
- errno = ENOMEM;
- return -1;
- }
+ if (oldp && *oldlenp < sizeof(_PATH_STDPATH))
+ return (ENOMEM);
*oldlenp = sizeof(_PATH_STDPATH);
if (oldp != NULL)
memmove(oldp, _PATH_STDPATH, sizeof(_PATH_STDPATH));
return (0);
}
- if (oldp && *oldlenp < sizeof(int)) {
- errno = ENOMEM;
- return (-1);
- }
+ if (oldp && *oldlenp < sizeof(int))
+ return (ENOMEM);
*oldlenp = sizeof(int);
if (oldp == NULL)
return (0);
diff --git a/lib/libc/gen/tzset.3 b/lib/libc/gen/tzset.3
index 5d83f335f525b..3c5b27650baec 100644
--- a/lib/libc/gen/tzset.3
+++ b/lib/libc/gen/tzset.3
@@ -137,7 +137,7 @@ is required; if
is missing, then summer time does not apply in this locale.
Upper and lowercase letters are explicitly allowed. Any characters
except a leading colon
-.Pq Ql \: ,
+.Pq Ql : ,
digits, comma
.Pq Ql \&, ,
minus
@@ -284,7 +284,7 @@ values in
.El
.Pp
For compatibility with System V Release 3.1, a semicolon
-.Pq Ql \;
+.Pq Ql ;
may be used to separate the
.Em rule
from the rest of the specification.
diff --git a/lib/libc/i386/sys/sigsuspend.S b/lib/libc/i386/sys/sigsuspend.S
index f85b2e1929f1b..660eabf854114 100644
--- a/lib/libc/i386/sys/sigsuspend.S
+++ b/lib/libc/i386/sys/sigsuspend.S
@@ -33,12 +33,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: sigsuspend.S,v 1.6 1997/02/22 14:59:40 peter Exp $
+ * $Id$
*/
#if defined(SYSLIBC_RCS) && !defined(lint)
.text
- .asciz "$Id: sigsuspend.S,v 1.6 1997/02/22 14:59:40 peter Exp $"
+ .asciz "$Id$"
#endif /* SYSLIBC_RCS and not lint */
#include "SYS.h"
@@ -50,9 +50,7 @@ err:
#ifdef _THREAD_SAFE
ENTRY(_thread_sys_sigsuspend)
#else
-ENTRY(_sigsuspend)
- .weak CNAME(sigsuspend) ;
- .set CNAME(sigsuspend), CNAME(_sigsuspend) ;
+ENTRY(sigsuspend)
#endif
movl 4(%esp),%eax # fetch mask arg
movl (%eax),%eax # indirect to mask arg
diff --git a/lib/libc/locale/ansi.c b/lib/libc/locale/ansi.c
index c0871fea6daca..a5a3362d8adf1 100644
--- a/lib/libc/locale/ansi.c
+++ b/lib/libc/locale/ansi.c
@@ -127,24 +127,22 @@ wcstombs(s, pwcs, n)
size_t n;
{
char *e;
- int cnt, nb;
+ int cnt = 0;
- if (!pwcs || !s || n > INT_MAX)
+ if (!pwcs || !s)
return (-1);
- nb = n;
- cnt = 0;
- while (nb > 0) {
+ while (n > 0) {
if (*pwcs == 0) {
*s = 0;
break;
}
- if (!sputrune(*pwcs++, s, nb, &e))
+ if (!sputrune(*pwcs++, s, n, &e))
return (-1); /* encoding error */
if (!e) /* too long */
return (cnt);
cnt += e - s;
- nb -= e - s;
+ n -= e - s;
s = e;
}
return (cnt);
diff --git a/lib/libc/quad/moddi3.c b/lib/libc/quad/moddi3.c
index fa76ea3838e3c..f31c6e84f2ba1 100644
--- a/lib/libc/quad/moddi3.c
+++ b/lib/libc/quad/moddi3.c
@@ -59,7 +59,7 @@ __moddi3(a, b)
else
ua = a, neg = 0;
if (b < 0)
- ub = -(u_quad_t)b;
+ ub = -(u_quad_t)b, neg ^= 1;
else
ub = b;
(void)__qdivrem(ua, ub, &ur);
diff --git a/lib/libc/stdio/fclose.3 b/lib/libc/stdio/fclose.3
index 81f260fc3498b..61822e5d76044 100644
--- a/lib/libc/stdio/fclose.3
+++ b/lib/libc/stdio/fclose.3
@@ -63,7 +63,7 @@ is returned and the global variable
.Va errno
is set to indicate the error.
In either case no further access to the stream is possible.
-.Sh ERRORS
+.Pp
The
.Fn fclose
function
@@ -75,12 +75,10 @@ or
.Xr fflush 3 .
.Sh NOTES
.Fn fclose
-does not handle NULL arguments; they will result in a segmentation
-violation.
-This is intentional - it makes it easier to make sure programs written
-under FreeBSD are bug free.
-This behaviour is an implementation detail, and programs should not
-rely upon it.
+does not handle NULL arguments; they will result in a segment
+violation. This is intentional - it makes it easier to make sure
+programs written under FreeBSD are bug free. This behaviour is an
+implementation detail, and programs should not rely upon it.
.Sh SEE ALSO
.Xr close 2 ,
.Xr fflush 3 ,
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c
index c2da533af8a0e..ca3fa5bdac3d5 100644
--- a/lib/libc/stdio/mktemp.c
+++ b/lib/libc/stdio/mktemp.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
- "$Id: mktemp.c,v 1.11 1998/10/20 12:36:36 peter Exp $";
+ "$Id: mktemp.c,v 1.9 1998/03/03 14:38:36 bde Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
diff --git a/lib/libc/stdio/perror.c b/lib/libc/stdio/perror.c
index bb618247e96fe..91a7dee8b2621 100644
--- a/lib/libc/stdio/perror.c
+++ b/lib/libc/stdio/perror.c
@@ -50,7 +50,7 @@ perror(s)
struct iovec iov[4];
v = iov;
- if (s != NULL && *s != '\0') {
+ if (s != NULL) {
v->iov_base = (char *)s;
v->iov_len = strlen(s);
v++;
diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c
index 083a9642502ee..a47e3007290e6 100644
--- a/lib/libc/stdlib/merge.c
+++ b/lib/libc/stdlib/merge.c
@@ -111,9 +111,6 @@ mergesort(base, nmemb, size, cmp)
return (-1);
}
- if (nmemb == 0)
- return (0);
-
/*
* XXX
* Stupid subtraction for the Cray.
@@ -150,7 +147,7 @@ mergesort(base, nmemb, size, cmp)
sense = 0;
}
if (!big) { /* here i = 0 */
- while ((b += size) < t && cmp(q, b) >sense)
+LINEAR: while ((b += size) < t && cmp(q, b) >sense)
if (++i == 6) {
big = 1;
goto EXPONENTIAL;
@@ -171,7 +168,7 @@ EXPONENTIAL: for (i = size; ; i <<= 1)
goto FASTCASE;
} else
b = p;
- while (t > b+size) {
+SLOWCASE: while (t > b+size) {
i = (((t - b) / size) >> 1) * size;
if ((*cmp)(q, p = b + i) <= sense)
t = p;
diff --git a/lib/libc/stdlib/qsort.3 b/lib/libc/stdlib/qsort.3
index aa2609c7efb0a..4f449c7529170 100644
--- a/lib/libc/stdlib/qsort.3
+++ b/lib/libc/stdlib/qsort.3
@@ -162,9 +162,7 @@ is set to indicate the error.
.Sh ERRORS
The
.Fn heapsort
-and
-.Fn mergesort
-functions succeed unless:
+function succeeds unless:
.Bl -tag -width Er
.It Bq Er EINVAL
The
diff --git a/lib/libc/stdtime/asctime.c b/lib/libc/stdtime/asctime.c
index 832f18592ff32..b9da143029eb7 100644
--- a/lib/libc/stdtime/asctime.c
+++ b/lib/libc/stdtime/asctime.c
@@ -14,6 +14,10 @@ static char elsieid[] = "@(#)asctime.c 7.7";
#include "private.h"
#include "tzfile.h"
+#ifndef _THREAD_SAFE
+static char *asctime_r __P((const struct tm *, char *));
+#endif
+
/*
** A la X3J11, with core dump avoidance.
*/
@@ -28,6 +32,9 @@ const struct tm * timeptr;
return(asctime_r(timeptr, result));
}
+#ifndef _THREAD_SAFE
+static
+#endif
char *
asctime_r(timeptr, result)
const struct tm * timeptr;
diff --git a/lib/libc/stdtime/ctime.3 b/lib/libc/stdtime/ctime.3
index 2b8ca3e45adc6..b14a92c47bf99 100644
--- a/lib/libc/stdtime/ctime.3
+++ b/lib/libc/stdtime/ctime.3
@@ -31,22 +31,17 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)ctime.3 8.1 (Berkeley) 6/4/93
-.\" $Id$
+.\" @(#)ctime.3 8.1 (Berkeley) 6/4/93
.\"
-.Dd January 2, 1999
+.Dd June 4, 1993
.Dt CTIME 3
.Os BSD 4.3
.Sh NAME
.Nm asctime ,
-.Nm asctime_r ,
.Nm ctime ,
-.Nm ctime_r ,
.Nm difftime ,
.Nm gmtime ,
-.Nm gmtime_r ,
.Nm localtime ,
-.Nm localtime_r ,
.Nm mktime ,
.Nm timegm
.Nd transform binary date and time values
@@ -67,14 +62,6 @@
.Fn mktime "struct tm *tm"
.Ft time_t
.Fn timegm "struct tm *tm"
-.Ft char *
-.Fn ctime_r "const time_t *clock" "char *buf"
-.Ft struct tm *
-.Fn localtime_r "const time_t *clock" "struct tm *result"
-.Ft struct tm *
-.Fn gmtime_r "const time_t *clock" "struct tm *result"
-.Ft char *
-.Fn asctime_r "const struct tm *tm" "char *buf"
.Sh DESCRIPTION
The functions
.Fn ctime ,
@@ -138,22 +125,6 @@ Thu Nov 24 18:22:48 1986\en\e0
.Pp
All the fields have constant width.
.Pp
-.Fn ctime_r
-provides the same functionality as
-.Fn ctime
-except the caller must provide the output buffer
-.Fa buf
-to store the result, which must be at least 26 characters long.
-.Fn localtime_r
-and
-.Fn gmtime_r
-provide the same functionality as
-.Fn localtime
-and
-.Fn gmtime
-respectively, except the caller must provide the output buffer
-.Fa result .
-.Pp
The
.Fn asctime
function
@@ -164,30 +135,14 @@ pointed at by
to the form
shown in the example above.
.Pp
-.Fn asctime_r
-provides the same functionality as
-.Fn asctime
-except the caller provide the output buffer
-.Fa buf
-to store the result, which must be at least 26 characters long.
-.Pp
-The functions
+The function
.Fn mktime
-and
-.Fn timegm
-converts the broken-down time in the structure
+converts the broken-down time, expressed as local time, in the structure
pointed to by tm into a time value with the same encoding as that of the
values returned by the
.Xr time 3
-function (that is, seconds from the Epoch,
-.Tn UTC ) .
-.Fn mktime
-interprets the input structure according to the current timezone setting
-(see
-.Xr tzset 3 ) .
-.Fn timegm
-interprets the input structure as representing Universal Coordinated Time
-.Pq Tn UTC .
+function, that is, seconds from the Epoch,
+.Tn UTC .
.Pp
The original values of the
.Fa tm_wday
@@ -206,13 +161,7 @@ A negative value for
causes the
.Fn mktime
function to attempt to divine whether summer time is in effect for the
-specified time.
-The
-.Fa tm_isdst
-and
-.Fa tm_gmtoff
-members are forced to zero by
-.Fn timegm . )
+specified time.)
.Pp
On successful completion, the values of the
.Fa tm_wday
@@ -231,6 +180,15 @@ are determined.
returns the specified calendar time; if the calendar time cannot be
represented, it returns \-1;
.Pp
+The function
+.Fn timegm
+is
+.Fn mktime
+analog, but assume that broke-down time expressed as UTC (not local) time.
+This function also set
+.Fa tm_isdst
+field to 0.
+.Pp
The
.Fn difftime
function
@@ -276,33 +234,6 @@ values indicating east of the Prime Meridian.
.Xr time 3 ,
.Xr tzset 3 ,
.Xr tzfile 5
-.Sh STANDARDS
-The
-.Fn asctime ,
-.Fn ctime ,
-.Fn difftime ,
-.Fn gmtime ,
-.Fn localtime ,
-and
-.Fn mktime
-functions conform to
-.St -isoC ,
-and conform to
-.St -p1003.1
-provided the selected local timezone does not contain a leap-second table
-(see
-.Xr zic 8 ) .
-.Pp
-The
-.Fn asctime_r ,
-.Fn ctime_r ,
-.Fn gmtime_r ,
-and
-.Fn localtime_r
-functions are expected to conform to
-.St -iso9945-1
-(again provided the selected local timezone does not contain a leap-second
-table).
.Sh HISTORY
This manual page is derived from
the time package contributed to Berkeley by
@@ -310,23 +241,13 @@ Arthur Olsen and which appeared in
.Bx 4.3 .
.Sh BUGS
Except for
-.Fn difftime ,
+.Fn difftime
+and
.Fn mktime ,
-and the
-.Fn \&_r
-variants of the other functions,
these functions leaves their result in an internal static object and return
a pointer to that object. Subsequent calls to these
function will modify the same object.
.Pp
-The C Standard provides no mechanism for a program to modify its current
-local timezone setting, and the
-.Tn POSIX Ns No \&-standard
-method is not reentrant. (However, thread-safe implementations are provided
-in the
-.Tn POSIX
-threaded environment.)
-.Pp
The
.Fa tm_zone
field of a returned tm structure points to a static array of characters,
@@ -341,3 +262,7 @@ Use of the external variable
is discouraged; the
.Fa tm_zone
entry in the tm structure is preferred.
+.Pp
+Avoid using out-of-range values with
+.Fn mktime
+when setting up lunch with promptness sticklers in Riyadh.
diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c
index 9e130bd560e22..ad227cf320291 100644
--- a/lib/libc/stdtime/localtime.c
+++ b/lib/libc/stdtime/localtime.c
@@ -1082,21 +1082,19 @@ struct tm * const tmp;
#endif /* defined TM_ZONE */
}
+#ifdef _THREAD_SAFE
struct tm *
localtime_r(timep, p_tm)
const time_t * const timep;
struct tm *p_tm;
{
-#ifdef _THREAD_SAFE
pthread_mutex_lock(&lcl_mutex);
-#endif
tzset();
localsub(timep, 0L, p_tm);
-#ifdef _THREAD_SAFE
pthread_mutex_unlock(&lcl_mutex);
-#endif
return(p_tm);
}
+#endif
struct tm *
localtime(timep)
@@ -1216,12 +1214,14 @@ const time_t * const timep;
#endif
}
+#ifdef _THREAD_SAFE
struct tm *
gmtime_r(const time_t * timep, struct tm * tm)
{
gmtsub(timep, 0L, tm);
return(tm);
}
+#endif
#ifdef STD_INSPIRED
@@ -1350,6 +1350,7 @@ const time_t * const timep;
return asctime(localtime(timep));
}
+#ifdef _THREAD_SAFE
char *
ctime_r(timep, buf)
const time_t * const timep;
@@ -1358,6 +1359,7 @@ char *buf;
struct tm tm;
return asctime_r(localtime_r(timep, &tm), buf);
}
+#endif
/*
** Adapted from code provided by Robert Elz, who writes:
diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc
index 42c8c39944c10..587da37b58550 100644
--- a/lib/libc/string/Makefile.inc
+++ b/lib/libc/string/Makefile.inc
@@ -1,5 +1,5 @@
# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-# $Id: Makefile.inc,v 1.14 1998/02/20 08:23:55 jb Exp $
+# $Id: Makefile.inc,v 1.13 1997/10/21 08:41:15 bde Exp $
.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/string ${.CURDIR}/../libc/string
@@ -27,5 +27,4 @@ MLINKS+=strcat.3 strncat.3
MLINKS+=strcmp.3 strncmp.3
MLINKS+=strcpy.3 strncpy.3
MLINKS+=strerror.3 perror.3 strerror.3 sys_errlist.3 strerror.3 sys_nerr.3
-MLINKS+=strtok.3 strtok_r.3
.endif
diff --git a/lib/libc/string/strerror.3 b/lib/libc/string/strerror.3
index ecb827841a866..67c22db97f80e 100644
--- a/lib/libc/string/strerror.3
+++ b/lib/libc/string/strerror.3
@@ -80,13 +80,16 @@ standard error file descriptor.
If the argument
.Fa string
is
-.Pf non- Dv NULL
-and does not point to the null character,
-this string is prepended to the message
+.Pf non- Dv NULL ,
+it is prepended to the message
string and separated from it by
a colon and space
-.Pq Ql \&:\ \& ;
-otherwise, only the error message string is printed.
+.Pq Ql \&:\ \& .
+If
+.Fa string
+is
+.Dv NULL ,
+only the error message string is printed.
.Pp
If
.Fa errnum
diff --git a/lib/libc/string/strtok.3 b/lib/libc/string/strtok.3
index 92d32ce0f59f5..56db2b03c7e33 100644
--- a/lib/libc/string/strtok.3
+++ b/lib/libc/string/strtok.3
@@ -1,8 +1,3 @@
-.\" Copyright (c) 1998 Softweyr LLC. All rights reserved.
-.\"
-.\" strtok_r, from Berkeley strtok
-.\" Oct 13, 1998 by Wes Peters <wes@softweyr.com>
-.\"
.\" Copyright (c) 1988, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -13,54 +8,43 @@
.\" 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
-.\" notices, this list of conditions and the following disclaimer.
-.\"
-.\" 2. Redistributions in binary form must reproduce the above
-.\" copyright notices, 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 Softweyr LLC, the
-.\" University of California, Berkeley, and its contributors.
-.\"
-.\" 4. Neither the name of Softweyr LLC, 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.
+.\" 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 SOFTWEYR LLC, 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 SOFTWEYR LLC, 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
+.\" 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.
.\"
.\" @(#)strtok.3 8.2 (Berkeley) 2/3/94
.\"
-.Dd November 27, 1998
+.Dd February 3, 1994
.Dt STRTOK 3
-.Os FreeBSD 3.0
+.Os BSD 3
.Sh NAME
-.Nm strtok, strtok_r
+.Nm strtok
.Nd string tokens
.Sh SYNOPSIS
.Fd #include <string.h>
.Ft char *
.Fn strtok "char *str" "const char *sep"
-.Ft char *
-.Fn strtok_r "char *str" "const char *sep" "char **last"
.Sh DESCRIPTION
.Bf -symbolic
This interface is obsoleted by strsep(3).
@@ -85,51 +69,13 @@ The separator string,
must be supplied each time, and may change between calls.
.Pp
The
-.Fn strtok_r
-function is a reentrant version of
-.Fn strtok .
-The context pointer
-.Fa last
-must be provided on each call.
-.Fn strtok_r
-may also be used to nest two parsing loops within one another, as
-long as separate context pointers are used.
-.Pp
-The
.Fn strtok
-and
-.Fn strtok_r
-functions
-return a pointer to the beginning of each subsequent token in the string,
+function
+returns a pointer to the beginning of each subsequent token in the string,
after replacing the token itself with a
.Dv NUL
character.
When no more tokens remain, a null pointer is returned.
-.Sh EXAMPLE
-The following uses
-.Fn strtok_r ()
-to parse two strings using separate contexts:
-.Bd -literal
-char test[80], blah[80];
-char *sep = "\\/:;=-";
-char *word, *phrase, *brkt, *brkb;
-
-strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function.");
-
-for (word = strtok_r(test, sep, &brkt);
- word;
- word = strtok_r(NULL, sep, &brkt))
-{
- strcpy(blah, "blah:blat:blab:blag");
-
- for (phrase = strtok_r(blah, sep, &brkb);
- phrase;
- phrase = strtok_r(NULL, sep, &brkb))
- {
- printf("So far we're at %s:%s\n", word, phrase);
- }
-}
-.Ed
.Sh SEE ALSO
.Xr index 3 ,
.Xr memchr 3 ,
@@ -148,6 +94,8 @@ function
conforms to
.St -ansiC .
.Sh BUGS
+There is no way to get tokens from multiple strings simultaneously.
+.Pp
The System V
.Fn strtok ,
if handed a string containing only delimiter characters,
@@ -160,8 +108,3 @@ value.
Since this implementation always alters the next starting point,
such a sequence of calls would always return
.Dv NULL .
-.Sh AUTHOR
-Wes Peters, Softweyr LLC:
-.Xr <wes@softweyr.com>
-.br
-Based on the FreeBSD 3.0 implementation.
diff --git a/lib/libc/string/strtok.c b/lib/libc/string/strtok.c
index 1140bfc73ebaf..9151cf257aabc 100644
--- a/lib/libc/string/strtok.c
+++ b/lib/libc/string/strtok.c
@@ -1,163 +1,90 @@
/*
- * Copyright (c) 1998 Softweyr LLC. All rights reserved.
- *
- * strtok_r, from Berkeley strtok
- * Oct 13, 1998 by Wes Peters <wes@softweyr.com>
- *
* Copyright (c) 1988, 1993
* 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
- * notices, this list of conditions and the following disclaimer.
- *
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notices, this list of conditions and the following disclaimer in the
+ * 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 Softweyr LLC, the
- * University of California, Berkeley, and its contributors.
- *
+ * 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 SOFTWEYR LLC, 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 SOFTWEYR LLC, 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.
+ * 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[] = "@(#)strtok.c 8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
#include <stddef.h>
#include <string.h>
char *
-strtok_r(char *s, const char *delim, char **last)
+strtok(s, delim)
+ register char *s;
+ register const char *delim;
{
- char *spanp;
- int c, sc;
- char *tok;
+ register char *spanp;
+ register int c, sc;
+ char *tok;
+ static char *last;
- if (s == NULL && (s = *last) == NULL)
- {
- return NULL;
- }
-
- /*
- * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
- */
-cont:
- c = *s++;
- for (spanp = (char *)delim; (sc = *spanp++) != 0; )
- {
- if (c == sc)
- {
- goto cont;
- }
- }
- if (c == 0) /* no non-delimiter characters */
- {
- *last = NULL;
- return NULL;
- }
- tok = s - 1;
+ if (s == NULL && (s = last) == NULL)
+ return (NULL);
- /*
- * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
- * Note that delim must have one NUL; we stop if we see that, too.
- */
- for (;;)
- {
+ /*
+ * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
+ */
+cont:
c = *s++;
- spanp = (char *)delim;
- do
- {
- if ((sc = *spanp++) == c)
- {
- if (c == 0)
- {
- s = NULL;
- }
- else
- {
- char *w = s - 1;
- *w = '\0';
- }
- *last = s;
- return tok;
- }
+ for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
+ if (c == sc)
+ goto cont;
}
- while (sc != 0);
- }
- /* NOTREACHED */
-}
-
-
-char *
-strtok(char *s, const char *delim)
-{
- static char *last;
-
- return strtok_r(s, delim, &last);
-}
-
-
-#if defined(DEBUG_STRTOK)
-
-/*
- * Test the tokenizer.
- */
-int
-main()
-{
- char test[80], blah[80];
- char *sep = "\\/:;=-";
- char *word, *phrase, *brkt, *brkb;
-
- printf("String tokenizer test:\n");
- strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function.");
-
- for (word = strtok(test, sep);
- word;
- word = strtok(NULL, sep))
- {
- printf("Next word is \"%s\".\n", word);
- }
-
- phrase = "foo";
-
- strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function.");
-
- for (word = strtok_r(test, sep, &brkt);
- word;
- word = strtok_r(NULL, sep, &brkt))
- {
- strcpy(blah, "blah:blat:blab:blag");
-
- for (phrase = strtok_r(blah, sep, &brkb);
- phrase;
- phrase = strtok_r(NULL, sep, &brkb))
- {
- printf("So far we're at %s:%s\n", word, phrase);
+ if (c == 0) { /* no non-delimiter characters */
+ last = NULL;
+ return (NULL);
}
- }
-
- return 0;
+ tok = s - 1;
+
+ /*
+ * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
+ * Note that delim must have one NUL; we stop if we see that, too.
+ */
+ for (;;) {
+ c = *s++;
+ spanp = (char *)delim;
+ do {
+ if ((sc = *spanp++) == c) {
+ if (c == 0)
+ s = NULL;
+ else
+ s[-1] = 0;
+ last = s;
+ return (tok);
+ }
+ } while (sc != 0);
+ }
+ /* NOTREACHED */
}
-
-#endif /* DEBUG_STRTOK */
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 517c4ba5f292c..6882621dd5a97 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -1,5 +1,5 @@
# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94
-# $Id: Makefile.inc,v 1.56 1998/11/05 14:43:29 dg Exp $
+# $Id: Makefile.inc,v 1.54 1998/07/28 03:33:25 jlemon Exp $
# sys sources
.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/sys ${.CURDIR}/../libc/sys
@@ -73,7 +73,7 @@ ${SPSEUDOR}:
> ${.TARGET}
.if ${LIB} == "c"
-MAN2+= _exit.2 accept.2 access.2 acct.2 adjtime.2 aio_read.2 \
+MAN2+= _exit.2 accept.2 access.2 acct.2 adjtime.2 \
bind.2 brk.2 chdir.2 chflags.2 \
chmod.2 chown.2 chroot.2 clock_gettime.2 close.2 \
connect.2 dup.2 execve.2 \
@@ -87,7 +87,7 @@ MAN2+= _exit.2 accept.2 access.2 acct.2 adjtime.2 aio_read.2 \
mount.2 mprotect.2 msync.2 munmap.2 nanosleep.2 \
nfssvc.2 open.2 pathconf.2 pipe.2 poll.2 profil.2 ptrace.2 quotactl.2 \
read.2 readlink.2 reboot.2 recv.2 rename.2 revoke.2 rfork.2 rmdir.2 \
- rtprio.2 select.2 semctl.2 semget.2 semop.2 send.2 sendfile.2 \
+ rtprio.2 select.2 semctl.2 semget.2 semop.2 send.2 \
setgroups.2 setpgid.2 setregid.2 setreuid.2 setsid.2 setuid.2 \
shmat.2 shmctl.2 shmget.2 shutdown.2 \
sigaction.2 sigaltstack.2 sigpending.2 sigprocmask.2 sigreturn.2 \
diff --git a/lib/libc/sys/accept.2 b/lib/libc/sys/accept.2
index 041ea5a774ae4..8a14cc6aa2e5f 100644
--- a/lib/libc/sys/accept.2
+++ b/lib/libc/sys/accept.2
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)accept.2 8.2 (Berkeley) 12/11/93
-.\" $Id: accept.2,v 1.5 1998/01/11 17:07:20 alex Exp $
+.\" $Id$
.\"
.Dd December 11, 1993
.Dt ACCEPT 2
@@ -171,9 +171,9 @@ The per-process descriptor table is full.
The system file table is full.
.It Bq Er ENOTSOCK
The descriptor references a file, not a socket.
-.It Bq Er EINVAL
-.Xr listen 2
-has not been called on the socket descriptor.
+.It Bq Er EOPNOTSUPP
+The referenced socket is not of type
+.Dv SOCK_STREAM .
.It Bq Er EFAULT
The
.Fa addr
diff --git a/lib/libc/sys/aio_read.2 b/lib/libc/sys/aio_read.2
deleted file mode 100644
index 16dab679519a7..0000000000000
--- a/lib/libc/sys/aio_read.2
+++ /dev/null
@@ -1,189 +0,0 @@
-.\" Copyright (c) 1998 Terry Lambert
-.\" 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-.\"
-.\" $Id$
-.\"
-.Dd November 17, 1998
-.Dt AIO_READ 2
-.Os
-.Sh NAME
-.Nm aio_read
-.Nd asynchronus read from a file (REALTIME)
-.Sh SYNOPSIS
-.Fd #include <aio.h>
-.Ft int
-.Fn aio_read "struct aiocb *iocb"
-.Sh DESCRIPTION
-The
-.Fn aio_read
-function allows the calling process to read
-.Ar iocb->aio_nbytes
-from the descriptor
-.Ar iocb->aio_fildes
-beginning at the offset
-.Ar iocb->aio_offset
-into the buffer pointed to by
-.Ar iocb->aio_buf .
-The call returns immediately after the read request has
-been enqueued to the descriptor; the read may or may not have
-completed at the time the call returns.
-.Pp
-If _POSIX_PRIORITIZED_IO is defined, and the descriptor supports it,
-then the enqueued operation is submitted at a priority equal to that
-of the calling process minus
-.Ar iocb->aio_reqprio .
-.Pp
-The
-.Ar iocb->aio_lio_opcode
-is ignored by the
-.Fn aio_read
-call.
-.Pp
-The
-.Ar iocb
-pointer may be subsequently used as an argument to
-.Fn aio_return
-and
-.Fn aio_error
-in order to determine return or error status for the enqueued operation
-while it is in progress.
-.Pp
-If the request could not be enqueued (generally due to invalid arguments),
-then the call returns without having enqueued the request.
-.Pp
-If the request is successfully enqueued, the value of
-.Ar iocb->aio_offset
-can be modified during the request as context, so this value must
-not be referenced after the request is enqueued.
-.Sh RESTRICTIONS
-The Asynchronous I/O Control Block structure pointed to by
-.Ar iocb
-and the buffer that the
-.Ar iocb->aio_buf
-member of that structure references must remain valid until the
-operation has completed. For this reason, use of auto (stack) variables
-for these objects is discouraged.
-.Pp
-Modifications of the Asynchronous I/O Control Block structure or the
-buffer contents after the request has been enqueued, but before the
-request has completed, are not allowed.
-.Pp
-If the file offset in
-.Ar iocb->aio_offset
-is past the offset maximum for
-.Ar iocb->aio_fildes ,
-no I/O will occur.
-.Sh RETURN VALUES
-.Rv -std aio_read
-.Sh STANDARDS
-The
-.Fn aio_read
-call conforms to the
-.St -p1003.2
-standard.
-.Sh DIAGNOSTICS
-None.
-.Sh ERRORS
-The
-.Fn aio_read
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The request was not queued because of system resource limitations.
-.It Bq Er ENOSYS
-The
-.Fn aio_read
-call is not supported.
-.El
-.Pp
-The following conditions may be synchronously detected when the
-.Fn aio_read
-call is made, or asynchronously, at any time thereafter. If they
-are detected at call time,
-.Fn aio_read
-returns -1 and sets
-.Ar errno
-appropriately; otherwise the
-.Fn aio_return
-function must be called, and will return -1, and
-Fn aio_error
-must be called to determine the actual calue that would have been
-returned in
-.Ar errno .
-.Pp
-.Bl -tag -width Er
-.It Bq Er EBADF
-.Ar iocb->aio_fildes
-is invalid.
-.It Bq Er EINVAL
-The offset
-.Ar iocb->aio_offset
-is not valid, the priority specified by
-.Ar iocb->aio_reqprio
-is not a valid priority, or the number of bytes specified by
-.Ar iocb->aio_nbytes
-is not valid.
-.It Bq Er EOVERFLOW
-The file is a regular file,
-.Ar iocb->aio_nbytes
-is greater than zero, the starting offset in
-.Ar iocb->aio_offset
-is before the end of the file, but is at or beyond the
-.Ar iocb->aio_fildes
-offset maximum.
-.El
-.Pp
-If the request is successfully enqueued, but subsequently cancelled
-or an error occurs, the value returned by the
-.Fn aio_return
-function is per the
-.Xr read 2
-call, and the value returned by the
-.Fn aio_error
-function is either one of the error returns from the
-.Xr read 2
-call, or one of:
-.Bl -tag -width Er
-.It Bq Er EBADF
-.Ar iocb->aio_fildes
-is invalid for reading.
-.It Bq Er ECANCELED
-The request was explicitly cancelled via a call to
-.Fn aio_cancel .
-.It Bq Er EINVAL
-The offset
-.Ar iocb->aio_offset
-would be invalid.
-.El
-.Sh HISTORY
-The
-.Nm
-Function first appeared in
-.Fx 3.0 .
-.Sh AUTHOR
-This
-manual page was written by
-.An Terry Lambert Aq terry@whistle.com .
-.Sh BUGS
-The value of iocb->aio_offset is ignored.
diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2
index 51f0ef5190070..fdf1941d3cb1c 100644
--- a/lib/libc/sys/fcntl.2
+++ b/lib/libc/sys/fcntl.2
@@ -483,13 +483,6 @@ or
.Dv F_SETLKW ,
and satisfying the lock or unlock request would result in the
number of locked regions in the system exceeding a system-imposed limit.
-.It Bq Er EPERM
-.Fa Cmd
-is
-.Dv F_SETOWN
-and
-the process ID or process group given as an argument is in a
-different session than the caller.
.It Bq Er ESRCH
.Fa Cmd
is
diff --git a/lib/libc/sys/getdirentries.2 b/lib/libc/sys/getdirentries.2
index 329b6502b3a76..abc680e7b9b33 100644
--- a/lib/libc/sys/getdirentries.2
+++ b/lib/libc/sys/getdirentries.2
@@ -69,7 +69,7 @@ structures each containing the following entries:
u_int32_t d_fileno;
u_int16_t d_reclen;
u_int8_t d_type;
-u_int8_t d_namlen;
+u_int8_t d_namelen;
char d_name[MAXNAMELEN + 1]; /* see below */
.Ed
.Pp
diff --git a/lib/libc/sys/rename.2 b/lib/libc/sys/rename.2
index 9c5102655c5a8..d9e1b8351f0a9 100644
--- a/lib/libc/sys/rename.2
+++ b/lib/libc/sys/rename.2
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)rename.2 8.1 (Berkeley) 6/4/93
-.\" $Id: rename.2,v 1.6 1997/02/22 15:04:16 peter Exp $
+.\" $Id$
.\"
.Dd June 4, 1993
.Dt RENAME 2
@@ -69,32 +69,32 @@ If the final component of
is a symbolic link,
the symbolic link is renamed,
not the file or directory to which it points.
-.\".Sh CAVEAT
-.\"The system can deadlock if a loop in the file system graph is present.
-.\"This loop takes the form of an entry in directory
-.\".Ql Pa a ,
-.\"say
-.\".Ql Pa a/foo ,
-.\"being a hard link to directory
-.\".Ql Pa b ,
-.\"and an entry in
-.\"directory
-.\".Ql Pa b ,
-.\"say
-.\".Ql Pa b/bar ,
-.\"being a hard link
-.\"to directory
-.\".Ql Pa a .
-.\"When such a loop exists and two separate processes attempt to
-.\"perform
-.\".Ql rename a/foo b/bar
-.\"and
-.\".Ql rename b/bar a/foo ,
-.\"respectively,
-.\"the system may deadlock attempting to lock
-.\"both directories for modification.
-.\"Hard links to directories should be
-.\"replaced by symbolic links by the system administrator.
+.Sh CAVEAT
+The system can deadlock if a loop in the file system graph is present.
+This loop takes the form of an entry in directory
+.Ql Pa a ,
+say
+.Ql Pa a/foo ,
+being a hard link to directory
+.Ql Pa b ,
+and an entry in
+directory
+.Ql Pa b ,
+say
+.Ql Pa b/bar ,
+being a hard link
+to directory
+.Ql Pa a .
+When such a loop exists and two separate processes attempt to
+perform
+.Ql rename a/foo b/bar
+and
+.Ql rename b/bar a/foo ,
+respectively,
+the system may deadlock attempting to lock
+both directories for modification.
+Hard links to directories should be
+replaced by symbolic links by the system administrator.
.Sh RETURN VALUES
A 0 value is returned if the operation succeeds, otherwise
.Fn rename
diff --git a/lib/libc/sys/revoke.2 b/lib/libc/sys/revoke.2
index 8787597f8206e..b64c9dc5fc884 100644
--- a/lib/libc/sys/revoke.2
+++ b/lib/libc/sys/revoke.2
@@ -65,8 +65,10 @@ is called as if all open references to the file had been closed.
Access to a file may be revoked only by its owner or the super user.
The
.Fn revoke
-function is normally used to prepare a terminal device for a new
-login session, preventing any access by a previous user of the terminal.
+function is currently supported only for block and character special
+device files.
+It is normally used to prepare a terminal device for a new login session,
+preventing any access by a previous user of the terminal.
.Sh RETURN VALUES
A 0 value indicated that the call succeeded. A \-1 return value
indicates an error occurred and
@@ -90,9 +92,8 @@ Too many symbolic links were encountered in translating the pathname.
.Fa Path
points outside the process's allocated address space.
.It Bq Er EINVAL
-The named file does not support the
-.Fn revoke
-operation.
+The named file is neither a character special or block
+special file.
.It Bq Er EPERM
The caller is neither the owner of the file nor the super user.
.El
diff --git a/lib/libc/sys/sendfile.2 b/lib/libc/sys/sendfile.2
deleted file mode 100644
index 58d61571a6616..0000000000000
--- a/lib/libc/sys/sendfile.2
+++ /dev/null
@@ -1,151 +0,0 @@
-.\" Copyright (c) 1998, David Greenman
-.\" 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 unmodified, 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-.\"
-.\" $Id: sendfile.2,v 1.1 1998/11/05 14:43:29 dg Exp $
-.\"
-.Dd November 5, 1998
-.Dt SENDFILE 2
-.Os
-.Sh NAME
-.Nm sendfile
-.Nd send a file to a socket
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/socket.h>
-.Fd #include <sys/uio.h>
-.Ft int
-.Fn sendfile "int fd" "int s" "off_t offset" "size_t nbytes" "struct sf_hdtr *hdtr" "off_t *sbytes" "int flags"
-.Sh DESCRIPTION
-.Fn Sendfile
-sends a regular file specified by descriptor
-.Fa fd
-out a stream socket specified by descriptor
-.Fa s .
-.Pp
-The
-.Fa offset
-argument specifies where to begin in the file. The
-.Fa nbytes
-argument specifies how many bytes of the file should be sent, with 0 having the special
-meaning of send until the end of file has been reached.
-.Pp
-An optional header and/or trailer can be sent before and after the file data by specifying
-a pointer to a struct sf_hdtr, which has the following structure:
-.Pp
-.Bd -literal -offset indent -compact
-struct sf_hdtr {
- struct iovec *headers; /* pointer to header iovecs */
- int hdr_cnt; /* number of header iovecs */
- struct iovec *trailers; /* pointer to trailer iovecs */
- int trl_cnt; /* number of trailer iovecs */
-};
-.Ed
-.Pp
-The
-.Fa headers
-and
-.Fa tailers
-pointers, if non-NULL, point to arrays of struct iovec structures. See the
-.Fn writev
-system call for information on the iovec structure. The number of iovecs in these
-arrays is specified by
-.Fa hdr_cnt
-and
-.Fa trl_cnt .
-.Pp
-If non-NULL, the system will write the total number of bytes sent on the socket to the
-variable pointed to by
-.Fa sbytes .
-.Pp
-The
-.Fa flags
-argument is currently undefined and should be specified as 0.
-.Pp
-When using a socket marked for non-blocking I/O,
-.Fn sendfile
-may send fewer bytes than requested. In this case, the number of bytes successfully
-written is returned in
-.Fa *sbytes
-(if specified),
-and the error
-.Er EAGAIN
-is returned.
-.Sh IMPLEMENTATION NOTES
-.Pp
-The FreeBSD implementation of
-.Fn sendfile
-is "zero-copy", meaning that it has been optimized so that copying of the file data is avoided.
-.Sh RETURN VALUES
-Upon successful completion,
-.Fn sendfile
-returns 0. Otherwise a -1 is returned and the global variable
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er EBADF
-.Fa fd
-is not a valid file descriptor.
-.It Bq Er EBADF
-.Fa s
-is not a valid socket descriptor.
-.It Bq Er ENOTSOCK
-.Fa s
-is not a socket.
-.It Bq Er EINVAL
-.Fa fd
-is not a regular file.
-.It Bq Er EINVAL
-.Fa s
-is not a SOCK_STREAM type socket.
-.It Bq Er EINVAL
-.Fa offset
-is negative or out of range.
-.It Bq Er ENOTCONN
-.Fa s
-points to an unconnected socket.
-.It Bq Er EPIPE
-The socket peer has closed the connection.
-.It Bq Er EIO
-An error occurred while reading from
-.Fa fd .
-.It Bq Er EFAULT
-An invalid address was specified for a parameter.
-.It Bq Er EAGAIN
-The socket is marked for non-blocking I/O and not all data was sent due to the socket buffer being filled.
-If specified, the number of bytes successfully sent will be returned in
-.Fa *sbytes .
-.El
-.Sh SEE ALSO
-.Xr open 2 ,
-.Xr socket 2 ,
-.Xr send 2 ,
-.Xr writev 2
-.Sh HISTORY
-.Fn sendfile
-first appeared in FreeBSD 3.0.1.
-.Sh AUTHORS
-.Fn sendfile
-and this manual page were written by David Greenman <dg@root.com>.
diff --git a/lib/libc/sys/sigaltstack.2 b/lib/libc/sys/sigaltstack.2
index 9d77c8525a20c..7ea6113a4d53a 100644
--- a/lib/libc/sys/sigaltstack.2
+++ b/lib/libc/sys/sigaltstack.2
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)sigaltstack.2 8.2 (Berkeley) 5/1/95
-.\" $Id: sigaltstack.2,v 1.8 1997/03/12 17:16:22 bde Exp $
+.\" $Id: sigaltstack.2,v 1.7 1997/03/12 16:23:36 mpp Exp $
.\"
.Dd May 1, 1995
.Dt SIGALTSTACK 2
@@ -39,11 +39,12 @@
.Nm sigaltstack
.Nd set and/or get signal stack context
.Sh SYNOPSIS
+.Fd #include <sys/types.h>
.Fd #include <signal.h>
.Bd -literal
struct sigaltstack {
char *ss_sp;
- size_t ss_size;
+ long ss_size;
int ss_flags;
};
.Ed
diff --git a/lib/libc/sys/stat.2 b/lib/libc/sys/stat.2
index 6e5ffeeab0cad..50d489a75e830 100644
--- a/lib/libc/sys/stat.2
+++ b/lib/libc/sys/stat.2
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)stat.2 8.4 (Berkeley) 5/1/95
-.\" $Id: stat.2,v 1.13 1998/01/02 19:22:49 alex Exp $
+.\" $Id: stat.2,v 1.12 1997/03/11 11:35:55 peter Exp $
.\"
.Dd May 1, 1995
.Dt STAT 2
@@ -94,30 +94,30 @@ as defined by
and into which information is placed concerning the file.
.Bd -literal
struct stat {
- dev_t st_dev; /* inode's device */
- ino_t st_ino; /* inode's number */
- mode_t st_mode; /* inode protection mode */
- nlink_t st_nlink; /* number of hard links */
- uid_t st_uid; /* user ID of the file's owner */
- gid_t st_gid; /* group ID of the file's group */
- dev_t st_rdev; /* device type */
+ dev_t st_dev; /* inode's device */
+ ino_t st_ino; /* inode's number */
+ mode_t st_mode; /* inode protection mode */
+ nlink_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_rdev; /* device type */
#ifndef _POSIX_SOURCE
struct timespec st_atimespec; /* time of last access */
struct timespec st_mtimespec; /* time of last data modification */
struct timespec st_ctimespec; /* time of last file status change */
#else
- time_t st_atime; /* time of last access */
- long st_atimensec; /* nsec of last access */
- time_t st_mtime; /* time of last data modification */
- long st_mtimensec; /* nsec of last data modification */
- time_t st_ctime; /* time of last file status change */
- long st_ctimensec; /* nsec of last file status change */
+ time_t st_atime; /* time of last access */
+ long st_atimensec; /* nsec of last access */
+ time_t st_mtime; /* time of last data modification */
+ long st_mtimensec; /* nsec of last data modification */
+ time_t st_ctime; /* time of last file status change */
+ long st_ctimensec; /* nsec of last file status change */
#endif
- off_t st_size; /* file size, in bytes */
- int64_t st_blocks; /* blocks allocated for file */
- u_int32_t st_blksize; /* optimal blocksize for I/O */
- u_int32_t st_flags; /* user defined flags for file */
- u_int32_t st_gen; /* file generation number */
+ off_t st_size; /* file size, in bytes */
+ quad_t st_blocks; /* blocks allocated for file */
+ u_long st_blksize; /* optimal blocksize for I/O */
+ u_long st_flags; /* user defined flags for file */
+ u_long st_gen; /* file generation number */
};
.Ed
.Pp
diff --git a/lib/libc/sys/vfork.2 b/lib/libc/sys/vfork.2
index 2c97af94ca409..5fff122a90bde 100644
--- a/lib/libc/sys/vfork.2
+++ b/lib/libc/sys/vfork.2
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)vfork.2 8.1 (Berkeley) 6/4/93
-.\" $Id: vfork.2,v 1.10 1998/01/02 19:22:49 alex Exp $
+.\" $Id: vfork.2,v 1.9 1997/11/18 03:59:30 jdp Exp $
.\"
.Dd June 4, 1993
.Dt VFORK 2
@@ -57,7 +57,7 @@ in that the child borrows the parent's memory and thread of
control until a call to
.Xr execve 2
or an exit (either by a call to
-.Xr _exit 2
+.Xr exit 3
or abnormally).
The parent process is suspended while the child is using its resources.
.Pp
diff --git a/lib/libc_r/Makefile b/lib/libc_r/Makefile
index 806cd10b5fa5a..84497f23658bc 100644
--- a/lib/libc_r/Makefile
+++ b/lib/libc_r/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.13 1998/06/14 11:25:44 peter Exp $
+# $Id: Makefile,v 1.12 1998/06/12 02:21:27 jb Exp $
#
# All library objects contain rcsid strings by default; they may be
# excluded as a space-saving measure. To produce a library that does
@@ -26,7 +26,7 @@ HIDDEN_SYSCALLS= accept.o bind.o close.o connect.o dup.o dup2.o \
execve.o fchflags.o fchmod.o fchown.o fcntl.o \
flock.o fpathconf.o fstat.o fstatfs.o fsync.o getdirentries.o \
getpeername.o getsockname.o getsockopt.o ioctl.o listen.o \
- nanosleep.o nfssvc.o open.o poll.o read.o readv.o recvfrom.o \
+ mknod.o nanosleep.o nfssvc.o open.o poll.o read.o readv.o recvfrom.o \
recvmsg.o sched_yield.o select.o sendmsg.o sendto.o \
setsockopt.o shutdown.o sigaction.o sigaltstack.o \
signanosleep.o socket.o socketpair.o wait4.o write.o writev.o
diff --git a/lib/libc_r/uthread/pthread_private.h b/lib/libc_r/uthread/pthread_private.h
index 2d7e723bbfa1e..04600cfbb3beb 100644
--- a/lib/libc_r/uthread/pthread_private.h
+++ b/lib/libc_r/uthread/pthread_private.h
@@ -447,7 +447,7 @@ struct pthread {
int signo;
/* Miscellaneous data. */
- int flags;
+ char flags;
#define PTHREAD_EXITING 0x0100
char pthread_priority;
void *ret;
@@ -654,8 +654,6 @@ void _thread_dump_info(void);
void _thread_init(void);
void _thread_kern_sched(struct sigcontext *);
void _thread_kern_sched_state(enum pthread_state,char *fname,int lineno);
-void _thread_kern_sched_state_unlock(enum pthread_state state,
- spinlock_t *lock, char *fname, int lineno);
void _thread_kern_set_timeout(struct timespec *);
void _thread_sig_handler(int, int, struct sigcontext *);
void _thread_start(void);
diff --git a/lib/libc_r/uthread/uthread_cond.c b/lib/libc_r/uthread/uthread_cond.c
index a085ea60fa899..fae12ebb68b52 100644
--- a/lib/libc_r/uthread/uthread_cond.c
+++ b/lib/libc_r/uthread/uthread_cond.c
@@ -144,9 +144,6 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
switch ((*cond)->c_type) {
/* Fast condition variable: */
case COND_TYPE_FAST:
- /* Wait forever: */
- _thread_run->wakeup_time.tv_sec = -1;
-
/*
* Queue the running thread for the condition
* variable:
@@ -154,36 +151,34 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
_thread_queue_enq(&(*cond)->c_queue, _thread_run);
/* Unlock the mutex: */
- if ((rval = pthread_mutex_unlock(mutex)) != 0) {
- /*
- * Cannot unlock the mutex, so remove the
- * running thread from the condition
- * variable queue:
- */
- _thread_queue_deq(&(*cond)->c_queue);
+ pthread_mutex_unlock(mutex);
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
- } else {
- /* Schedule the next thread: */
- _thread_kern_sched_state_unlock(PS_COND_WAIT,
- &(*cond)->lock, __FILE__, __LINE__);
+ /* Wait forever: */
+ _thread_run->wakeup_time.tv_sec = -1;
- /* Lock the mutex: */
- rval = pthread_mutex_lock(mutex);
- }
+ /* Unlock the condition variable structure: */
+ _SPINUNLOCK(&(*cond)->lock);
+
+ /* Schedule the next thread: */
+ _thread_kern_sched_state(PS_COND_WAIT,
+ __FILE__, __LINE__);
+
+ /* Lock the condition variable structure: */
+ _SPINLOCK(&(*cond)->lock);
+
+ /* Lock the mutex: */
+ rval = pthread_mutex_lock(mutex);
break;
/* Trap invalid condition variable types: */
default:
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
/* Return an invalid argument error: */
rval = EINVAL;
break;
}
+ /* Unlock the condition variable structure: */
+ _SPINUNLOCK(&(*cond)->lock);
}
/* Return the completion status: */
@@ -234,13 +229,16 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
* variable queue:
*/
_thread_queue_deq(&(*cond)->c_queue);
-
+ } else {
/* Unlock the condition variable structure: */
_SPINUNLOCK(&(*cond)->lock);
- } else {
+
/* Schedule the next thread: */
- _thread_kern_sched_state_unlock(PS_COND_WAIT,
- &(*cond)->lock, __FILE__, __LINE__);
+ _thread_kern_sched_state(PS_COND_WAIT,
+ __FILE__, __LINE__);
+
+ /* Lock the condition variable structure: */
+ _SPINLOCK(&(*cond)->lock);
/* Lock the mutex: */
if ((rval = pthread_mutex_lock(mutex)) != 0) {
@@ -255,14 +253,13 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
/* Trap invalid condition variable types: */
default:
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
/* Return an invalid argument error: */
rval = EINVAL;
break;
}
+ /* Unlock the condition variable structure: */
+ _SPINUNLOCK(&(*cond)->lock);
}
/* Return the completion status: */
diff --git a/lib/libc_r/uthread/uthread_info.c b/lib/libc_r/uthread/uthread_info.c
index f66dd2d6ddcf4..07877d167e337 100644
--- a/lib/libc_r/uthread/uthread_info.c
+++ b/lib/libc_r/uthread/uthread_info.c
@@ -36,7 +36,6 @@
#include <unistd.h>
#ifdef _THREAD_SAFE
#include <pthread.h>
-#include <errno.h>
#include "pthread_private.h"
struct s_thread_info {
@@ -74,31 +73,11 @@ _thread_dump_info(void)
int i;
int j;
pthread_t pthread;
- char tmpfile[128];
- for (i = 0; i < 100000; i++) {
- snprintf(tmpfile, sizeof(tmpfile), "/tmp/uthread.dump.%u.%i",
- getpid(), i);
- /* Open the dump file for append and create it if necessary: */
- if ((fd = _thread_sys_open(tmpfile, O_RDWR | O_CREAT | O_EXCL,
- 0666)) < 0) {
- /* Can't open the dump file. */
- if (errno == EEXIST)
- continue;
- /*
- * We only need to continue in case of
- * EEXIT error. Most other error
- * codes means that we will fail all
- * the times.
- */
- return;
- } else {
- break;
- }
- }
- if (i==100000) {
- /* all 100000 possibilities are in use :( */
- return;
+ /* Open the dump file for append and create it if necessary: */
+ if ((fd = _thread_sys_open("/tmp/uthread.dump",
+ O_RDWR | O_CREAT | O_APPEND, 0666)) < 0) {
+ /* Can't open the dump file. */
} else {
/* Output a header for active threads: */
strcpy(s, "\n\n=============\nACTIVE THREADS\n\n");
diff --git a/lib/libc_r/uthread/uthread_kern.c b/lib/libc_r/uthread/uthread_kern.c
index 3a6966bad5bf3..22746c7d211e1 100644
--- a/lib/libc_r/uthread/uthread_kern.c
+++ b/lib/libc_r/uthread/uthread_kern.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: uthread_kern.c,v 1.14 1998/10/09 19:01:30 dt Exp $
+ * $Id: uthread_kern.c,v 1.13 1998/09/30 06:36:56 jb Exp $
*
*/
#include <errno.h>
@@ -616,22 +616,6 @@ _thread_kern_sched_state(enum pthread_state state, char *fname, int lineno)
return;
}
-void
-_thread_kern_sched_state_unlock(enum pthread_state state,
- spinlock_t *lock, char *fname, int lineno)
-{
- /* Change the state of the current thread: */
- _thread_run->state = state;
- _thread_run->fname = fname;
- _thread_run->lineno = lineno;
-
- _SPINUNLOCK(lock);
-
- /* Schedule the next thread that is ready: */
- _thread_kern_sched(NULL);
- return;
-}
-
static void
_thread_kern_select(int wait_reqd)
{
diff --git a/lib/libc_r/uthread/uthread_kill.c b/lib/libc_r/uthread/uthread_kill.c
index 7572c05faff73..292ba5caf8f2c 100644
--- a/lib/libc_r/uthread/uthread_kill.c
+++ b/lib/libc_r/uthread/uthread_kill.c
@@ -83,26 +83,6 @@ pthread_kill(pthread_t pthread, int sig)
sigaddset(&pthread->sigpend,sig);
break;
- case PS_SELECT_WAIT:
- case PS_FDR_WAIT:
- case PS_FDW_WAIT:
- case PS_SLEEP_WAIT:
- if (!sigismember(&pthread->sigmask, sig) &&
- (_thread_sigact[sig - 1].sa_handler != SIG_IGN)) {
- /* Flag the operation as interrupted: */
- pthread->interrupted = 1;
-
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- } else {
- /* Increment the pending signal count: */
- sigaddset(&pthread->sigpend,sig);
- }
- break;
-
default:
/* Increment the pending signal count: */
sigaddset(&pthread->sigpend,sig);
diff --git a/lib/libc_r/uthread/uthread_mattr_kind_np.c b/lib/libc_r/uthread/uthread_mattr_kind_np.c
index c145a1f899277..3eeabff038a73 100644
--- a/lib/libc_r/uthread/uthread_mattr_kind_np.c
+++ b/lib/libc_r/uthread/uthread_mattr_kind_np.c
@@ -61,18 +61,4 @@ pthread_mutexattr_getkind_np(pthread_mutexattr_t attr)
}
return(ret);
}
-
-int
-pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
-{
- int ret;
- if (attr == NULL || *attr == NULL || type >= MUTEX_TYPE_MAX) {
- errno = EINVAL;
- ret = -1;
- } else {
- (*attr)->m_type = type;
- ret = 0;
- }
- return(ret);
-}
#endif
diff --git a/lib/libc_r/uthread/uthread_mutex.c b/lib/libc_r/uthread/uthread_mutex.c
index d3801f1750c0b..4f4aa8af041e6 100644
--- a/lib/libc_r/uthread/uthread_mutex.c
+++ b/lib/libc_r/uthread/uthread_mutex.c
@@ -53,7 +53,7 @@ pthread_mutex_init(pthread_mutex_t * mutex,
/* Check if default mutex attributes: */
if (mutex_attr == NULL || *mutex_attr == NULL)
/* Default to a fast mutex: */
- type = PTHREAD_MUTEX_DEFAULT;
+ type = MUTEX_TYPE_FAST;
else if ((*mutex_attr)->m_type >= MUTEX_TYPE_MAX)
/* Return an invalid argument error: */
@@ -74,14 +74,12 @@ pthread_mutex_init(pthread_mutex_t * mutex,
/* Process according to mutex type: */
switch (type) {
/* Fast mutex: */
- case PTHREAD_MUTEX_DEFAULT:
- case PTHREAD_MUTEX_NORMAL:
- case PTHREAD_MUTEX_ERRORCHECK:
+ case MUTEX_TYPE_FAST:
/* Nothing to do here. */
break;
/* Counting mutex: */
- case PTHREAD_MUTEX_RECURSIVE:
+ case MUTEX_TYPE_COUNTING_FAST:
/* Reset the mutex count: */
pmutex->m_data.m_count = 0;
break;
@@ -176,9 +174,7 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
/* Process according to mutex type: */
switch ((*mutex)->m_type) {
/* Fast mutex: */
- case PTHREAD_MUTEX_NORMAL:
- case PTHREAD_MUTEX_DEFAULT:
- case PTHREAD_MUTEX_ERRORCHECK:
+ case MUTEX_TYPE_FAST:
/* Check if this mutex is not locked: */
if ((*mutex)->m_owner == NULL) {
/* Lock the mutex for the running thread: */
@@ -190,7 +186,7 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
break;
/* Counting mutex: */
- case PTHREAD_MUTEX_RECURSIVE:
+ case MUTEX_TYPE_COUNTING_FAST:
/* Check if this mutex is locked: */
if ((*mutex)->m_owner != NULL) {
/*
@@ -243,26 +239,8 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
/* Process according to mutex type: */
switch ((*mutex)->m_type) {
- /* What SS2 define as a 'normal' mutex. This has to deadlock
- on attempts to get a lock you already own. */
- case PTHREAD_MUTEX_NORMAL:
- if ((*mutex)->m_owner == _thread_run) {
- /* Intetionally deadlock */
- for (;;)
- _thread_kern_sched_state(PS_MUTEX_WAIT, __FILE__, __LINE__);
- }
- goto COMMON_LOCK;
-
- /* Return error (not OK) on attempting to re-lock */
- case PTHREAD_MUTEX_ERRORCHECK:
- if ((*mutex)->m_owner == _thread_run) {
- ret = EDEADLK;
- break;
- }
-
/* Fast mutexes do not check for any error conditions: */
- case PTHREAD_MUTEX_DEFAULT:
- COMMON_LOCK:
+ case MUTEX_TYPE_FAST:
/*
* Enter a loop to wait for the mutex to be locked by the
* current thread:
@@ -279,10 +257,11 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
*/
_thread_queue_enq(&(*mutex)->m_queue, _thread_run);
- /* Wait for the mutex: */
- _thread_kern_sched_state_unlock(
- PS_MUTEX_WAIT, &(*mutex)->lock,
- __FILE__, __LINE__);
+ /* Unlock the mutex structure: */
+ _SPINUNLOCK(&(*mutex)->lock);
+
+ /* Block signals: */
+ _thread_kern_sched_state(PS_MUTEX_WAIT, __FILE__, __LINE__);
/* Lock the mutex again: */
_SPINLOCK(&(*mutex)->lock);
@@ -291,7 +270,7 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
break;
/* Counting mutex: */
- case PTHREAD_MUTEX_RECURSIVE:
+ case MUTEX_TYPE_COUNTING_FAST:
/*
* Enter a loop to wait for the mutex to be locked by the
* current thread:
@@ -311,10 +290,11 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
*/
_thread_queue_enq(&(*mutex)->m_queue, _thread_run);
- /* Wait for the mutex: */
- _thread_kern_sched_state_unlock(
- PS_MUTEX_WAIT, &(*mutex)->lock,
- __FILE__, __LINE__);
+ /* Unlock the mutex structure: */
+ _SPINUNLOCK(&(*mutex)->lock);
+
+ /* Block signals: */
+ _thread_kern_sched_state(PS_MUTEX_WAIT, __FILE__, __LINE__);
/* Lock the mutex again: */
_SPINLOCK(&(*mutex)->lock);
@@ -353,15 +333,12 @@ pthread_mutex_unlock(pthread_mutex_t * mutex)
/* Process according to mutex type: */
switch ((*mutex)->m_type) {
- /* Default & normal mutexes do not really need to check for
- any error conditions: */
- case PTHREAD_MUTEX_NORMAL:
- case PTHREAD_MUTEX_DEFAULT:
- case PTHREAD_MUTEX_ERRORCHECK:
+ /* Fast mutexes do not check for any error conditions: */
+ case MUTEX_TYPE_FAST:
/* Check if the running thread is not the owner of the mutex: */
if ((*mutex)->m_owner != _thread_run) {
/* Return an invalid argument error: */
- ret = (*mutex)->m_owner ? EPERM : EINVAL;
+ ret = EINVAL;
}
/*
* Get the next thread from the queue of threads waiting on
@@ -374,26 +351,24 @@ pthread_mutex_unlock(pthread_mutex_t * mutex)
break;
/* Counting mutex: */
- case PTHREAD_MUTEX_RECURSIVE:
+ case MUTEX_TYPE_COUNTING_FAST:
/* Check if the running thread is not the owner of the mutex: */
if ((*mutex)->m_owner != _thread_run) {
/* Return an invalid argument error: */
ret = EINVAL;
}
/* Check if there are still counts: */
- else if ((*mutex)->m_data.m_count > 1) {
+ else if ((*mutex)->m_data.m_count) {
/* Decrement the count: */
(*mutex)->m_data.m_count--;
- } else {
- (*mutex)->m_data.m_count = 0;
- /*
- * Get the next thread from the queue of threads waiting on
- * the mutex:
- */
- if (((*mutex)->m_owner = _thread_queue_deq(&(*mutex)->m_queue)) != NULL) {
- /* Allow the new owner of the mutex to run: */
- PTHREAD_NEW_STATE((*mutex)->m_owner,PS_RUNNING);
- }
+ }
+ /*
+ * Get the next thread from the queue of threads waiting on
+ * the mutex:
+ */
+ else if (((*mutex)->m_owner = _thread_queue_deq(&(*mutex)->m_queue)) != NULL) {
+ /* Allow the new owner of the mutex to run: */
+ PTHREAD_NEW_STATE((*mutex)->m_owner,PS_RUNNING);
}
break;
diff --git a/lib/libcam/camlib.c b/lib/libcam/camlib.c
index 394f63596cc10..d4ba57e3c6a64 100644
--- a/lib/libcam/camlib.c
+++ b/lib/libcam/camlib.c
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: camlib.c,v 1.3 1998/11/15 23:12:42 ken Exp $
+ * $Id: camlib.c,v 1.1 1998/09/15 06:16:46 gibbs Exp $
*/
#include <sys/types.h>
@@ -585,10 +585,9 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
device->given_unit_number = given_unit_number;
if ((fd = open(path, flags)) < 0) {
- snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
- "%s: couldn't open passthrough device %s\n"
- "%s: %s", func_name, path, func_name,
- strerror(errno));
+ sprintf(cam_errbuf, "%s: couldn't open passthrough device %s\n"
+ "%s: %s", func_name, newpath, func_name,
+ strerror(errno));
goto crod_bailout;
}
diff --git a/lib/libcompat/Makefile b/lib/libcompat/Makefile
index f57107ee6f0d5..c9ba0ec1563b7 100644
--- a/lib/libcompat/Makefile
+++ b/lib/libcompat/Makefile
@@ -14,6 +14,10 @@ NOPIC=
# XXX MISSING: tell.c vlimit.c vtimes.c
SRCS+= ascftime.c cftime.c ftime.c getpw.c gtty.c stty.c
+.if (${MACHINE_ARCH} == "vax")
+SRCS+= reset.s
+.endif
+
MAN3+= 4.1/ftime.3 4.1/getpw.3 4.1/stty.3 4.1/vlimit.3 4.1/vtimes.3
MAN3+= 4.1/cftime.3
@@ -23,7 +27,20 @@ MLINKS+=cftime.3 ascftime.3
# compat 4.3 sources
# XXX MISSING: ecvt.c gcvt.c sibuf.c sobuf.c strout.c
SRCS+= cfree.c lsearch.c regex.c rexec.c
+
+.if (${MACHINE_ARCH} == "hp300" || ${MACHINE_ARCH} == "luna68k")
+SRCS+= insque.s remque.s
+.elif (${MACHINE_ARCH} == "i386")
+SRCS+= insque.c remque.c
+.elif (${MACHINE_ARCH} == "mips")
+SRCS+= insque.c remque.c
+.elif (${MACHINE_ARCH} == "sparc")
SRCS+= insque.c remque.c
+.elif (${MACHINE_ARCH} == "tahoe")
+SRCS+= nargs.s insque.s remque.s
+.elif (${MACHINE_ARCH} == "vax")
+SRCS+= nargs.s insque.s remque.s
+.endif
# XXX MISSING: ecvt.0
MAN3+= 4.3/cfree.3 4.3/insque.3 4.3/lsearch.3 4.3/re_comp.3 4.3/rexec.3
diff --git a/lib/libdevstat/Makefile b/lib/libdevstat/Makefile
index 063354425d65e..ce3f9c2bdf683 100644
--- a/lib/libdevstat/Makefile
+++ b/lib/libdevstat/Makefile
@@ -4,16 +4,6 @@ SRCS= devstat.c
MAN3= devstat.3
-MLINKS+=devstat.3 getnumdevs.3
-MLINKS+=devstat.3 getgeneration.3
-MLINKS+=devstat.3 getversion.3
-MLINKS+=devstat.3 checkversion.3
-MLINKS+=devstat.3 getdevs.3
-MLINKS+=devstat.3 selectdevs.3
-MLINKS+=devstat.3 buildmatch.3
-MLINKS+=devstat.3 compute_stats.3
-MLINKS+=devstat.3 compute_etime.3
-
beforeinstall:
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/devstat.h \
${DESTDIR}/usr/include
diff --git a/lib/libdevstat/devstat.3 b/lib/libdevstat/devstat.3
index f189abfd3070d..6da22aa8c32a6 100644
--- a/lib/libdevstat/devstat.3
+++ b/lib/libdevstat/devstat.3
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: devstat.3,v 1.2 1998/09/20 00:11:09 ken Exp $
+.\" $Id: devstat.3,v 1.1 1998/09/15 06:23:21 gibbs Exp $
.\"
.Dd May 21, 1998
.Dt DEVSTAT 3
@@ -221,7 +221,7 @@ this may be done for him in a
library routine.
If no devices have been selected by name or by pattern, the performance
tracking code will select every device in the system, and sort them by
-performance. If devices have been selected by name or pattern, the
+perforcmance. If devices have been selected by name or pattern, the
performance tracking code will honor those selections and will only sort
among the selected devices.
.It order in the devstat list
@@ -258,7 +258,7 @@ In remove mode,
will remove devices specified by name or by matching pattern. It will not
select any additional devices.
.It DS_SELECT_ADDONLY
-In add only mode,
+In addonly mode,
.Fn selectdevs
will select any unselected devices specified by name or matching pattern.
In this respect it is identical to add mode. It will not, however, select
@@ -433,7 +433,7 @@ This is average blocks per second. If the device blocksize is
.Sq 0 ,
a default blocksize of 512 bytes will be used instead.
.It ms_per_transaction
-The average number of milliseconds per transaction.
+The average number of miliseconds per transaction.
.El
.Pp
.Fn compute_etime
diff --git a/lib/libdisk/Makefile b/lib/libdisk/Makefile
index 1a3809931453f..1b1200dedbad1 100644
--- a/lib/libdisk/Makefile
+++ b/lib/libdisk/Makefile
@@ -1,11 +1,11 @@
-# $Id: Makefile,v 1.24 1998/12/30 13:29:11 jkh Exp $
+# $Id: Makefile,v 1.20 1997/02/22 15:06:25 peter Exp $
LIB= disk
SRCS= blocks.c disklabel.c dkcksum.c chunk.c disk.c change.c \
- create_chunk.c rules.c write_disk.c
+ create_chunk.c rules.c write_disk.c data.c
CFLAGS+= -Wall
-CLEANFILES+= tmp.c tst01 tst01.o
+CLEANFILES+= tmp.c tst01 tst01.o data.c
VPATH= ${.CURDIR}/../../sbin/disklabel
NOPROFILE= yes
NOSHARED= yes
@@ -42,6 +42,22 @@ MLINKS+= libdisk.3 Open_Disk.3 \
.include <bsd.lib.mk>
+BOOTS=/usr/mdec
+
+.if ${MACHINE_ARCH} == "i386"
+data.c: ${.CURDIR}/libdisk.h ${BOOTS}/boot1 ${BOOTS}/boot2
+ file2c 'const unsigned char boot1[] = {' '};' \
+ < ${BOOTS}/boot1 > tmp.c
+ file2c 'const unsigned char boot2[] = {' '};' \
+ < ${BOOTS}/boot2 >> tmp.c
+ mv -f tmp.c data.c
+.elif ${MACHINE_ARCH} == "alpha"
+data.c: ${.CURDIR}/libdisk.h ${BOOTS}/boot1
+ file2c 'const unsigned char boot1[] = {' '};' \
+ < ${BOOTS}/boot1 > tmp.c
+ mv -f tmp.c data.c
+.endif
+
beforeinstall:
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/libdisk.h \
${DESTDIR}/usr/include/libdisk.h
diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c
index 9bb8dd51f9da1..86e18f87319a1 100644
--- a/lib/libdisk/create_chunk.c
+++ b/lib/libdisk/create_chunk.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: create_chunk.c,v 1.33 1999/01/08 00:32:19 jkh Exp $
+ * $Id: create_chunk.c,v 1.30 1998/03/20 23:43:03 jkh Exp $
*
*/
@@ -151,7 +151,6 @@ Fixup_Names(struct disk *d)
continue;
if (strcmp(c2->name,"X"))
continue;
-#ifndef __alpha__
c2->oname = malloc(12);
if(!c2->oname) err(1,"malloc failed");
for(j=1;j<=NDOSPART;j++) {
@@ -168,10 +167,6 @@ Fixup_Names(struct disk *d)
}
if (c2->oname)
free(c2->oname);
-#else
- free(c2->name);
- c2->name = strdup(c1->name);
-#endif
}
for(c2 = c1->part; c2 ; c2 = c2->next) {
if (c2->type == freebsd) {
@@ -259,19 +254,18 @@ MakeDev(struct chunk *c1, const char *path)
return 0;
if (!strncmp(p, "wd", 2))
- bmaj = 0, cmaj = 3, p += 2;
+ bmaj = 0, cmaj = 3;
else if (!strncmp(p, "sd", 2))
- bmaj = 4, cmaj = 13, p += 2;
+ bmaj = 4, cmaj = 13;
else if (!strncmp(p, "wfd", 3))
- bmaj = 1, cmaj = 87, p += 3;
- else if (!strncmp(p, "fla", 3))
- bmaj = 28, cmaj = 101, p += 3;
+ bmaj = 1, cmaj = 87;
else if (!strncmp(p, "da", 2)) /* CAM support */
- bmaj = 4, cmaj = 13, p += 2;
+ bmaj = 4, cmaj = 13;
else {
msgDebug("MakeDev: Unknown major/minor for devtype %s\n", p);
return 0;
}
+ p += 2;
if (!isdigit(*p)) {
msgDebug("MakeDev: Invalid disk unit passed: %s\n", p);
return 0;
@@ -288,7 +282,6 @@ MakeDev(struct chunk *c1, const char *path)
unit += (*p - '0');
p++;
}
-#ifndef __alpha__
if (*p != 's') {
msgDebug("MakeDev: `%s' is not a valid slice delimiter\n", p);
return 0;
@@ -306,9 +299,6 @@ MakeDev(struct chunk *c1, const char *path)
p++;
}
slice = slice + 1;
-#else
- slice = 0;
-#endif
if (!*p) {
part = 2;
if(c1->type == freebsd)
diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c
index 4d6deafc65fd3..f5c19994b4a8a 100644
--- a/lib/libdisk/disk.c
+++ b/lib/libdisk/disk.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: disk.c,v 1.38 1998/10/06 11:57:08 dfr Exp $
+ * $Id: disk.c,v 1.37 1998/09/30 21:40:51 jkh Exp $
*
*/
@@ -323,7 +323,7 @@ Collapse_Disk(struct disk *d)
}
#endif
-static char * device_list[] = {"wd", "sd", "da", "wfd", "fla", 0};
+static char * device_list[] = {"wd","sd","da","wfd",0};
char **
Disk_Names()
diff --git a/lib/libdisk/libdisk.3 b/lib/libdisk/libdisk.3
index 5657fd32e4305..6b56cf7de2498 100644
--- a/lib/libdisk/libdisk.3
+++ b/lib/libdisk/libdisk.3
@@ -25,7 +25,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id: libdisk.3,v 1.7 1998/06/06 05:50:52 jkoshy Exp $
+.\" $Id: libdisk.3,v 1.6 1998/03/19 07:34:03 charnier Exp $
.\" "
.Dd March 15, 1996
.Dt LIBDISK 3
@@ -63,6 +63,7 @@
.Sh SYNOPSIS
.Fd #include <sys/types.h>
.Fd #include <libdisk.h>
+.Dv extern const u_char *boot1, boot2;
.\" What is the correct way to cause a single line break ???
.Bd -literal
.Dv extern const char *chunk_n[];
@@ -262,7 +263,11 @@ is called.
.Fn Set_Boot_Blocks
sets the boot-blocks for use on this disk. Gets written when
.Fn Write_Disk
-is called.
+is called. The external variables
+.Dv boot1
+and
+.Dv boot2
+contain suitable data to be passed to this function.
.Pp
.Fn Write_Disk
writes all the MBRs, disklabels, bootblocks and boot managers.
diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h
index 91b1817b6ddd0..3ae62cab12f39 100644
--- a/lib/libdisk/libdisk.h
+++ b/lib/libdisk/libdisk.h
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
-* $Id: libdisk.h,v 1.29 1998/10/06 11:57:08 dfr Exp $
+* $Id: libdisk.h,v 1.28 1998/01/20 11:03:15 bde Exp $
*
*/
@@ -86,6 +86,7 @@ struct chunk {
};
extern const char *chunk_n[];
+extern const u_char boot1[], boot2[];
const char *
slice_type_name( int type, int subtype );
diff --git a/lib/libdisk/write_disk.c b/lib/libdisk/write_disk.c
index b27d17b2c79e2..6d3b2a7d1d1c5 100644
--- a/lib/libdisk/write_disk.c
+++ b/lib/libdisk/write_disk.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: write_disk.c,v 1.24 1998/10/27 21:14:03 msmith Exp $
+ * $Id: write_disk.c,v 1.22 1998/09/30 21:40:51 jkh Exp $
*
*/
@@ -64,10 +64,10 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1)
for(c2=c1->part;c2;c2=c2->next) {
if (c2->type == unused) continue;
if (!strcmp(c2->name,"X")) continue;
- j = c2->name[strlen(new->name) + 2] - 'a';
+ j = c2->name[5] - 'a';
if (j < 0 || j >= MAXPARTITIONS || j == RAW_PART) {
#ifdef DEBUG
- warn("Weird parititon letter %c",c2->name[strlen(new->name) + 2]);
+ warn("Weird parititon letter %c",c2->name[5]);
#endif
continue;
}
@@ -110,14 +110,6 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1)
#ifdef __alpha__
/*
- * Tell SRM where the bootstrap is.
- */
- lp = (u_long *)buf;
- lp[60] = 15;
- lp[61] = 1;
- lp[62] = 0;
-
- /*
* Generate the bootblock checksum for the SRM console.
*/
for (lp = (u_long *)buf, i = 0, sum = 0; i < 63; i++)
@@ -181,7 +173,6 @@ Write_Disk(struct disk *d1)
if (c1->type == unused) continue;
if (!strcmp(c1->name,"X")) continue;
j = c1->name[4] - '1';
- j = c1->name[strlen(d1->name) + 1] - '1';
if (j < 0 || j > 3)
continue;
s[j]++;
@@ -250,7 +241,6 @@ Write_Disk(struct disk *d1)
if (dp[i].dp_typ == 0xa5)
dp[i].dp_flag = 0x80;
-#ifndef __alpha__
mbr = read_block(fd,WHERE(0,d1));
if (d1->bootmgr)
memcpy(mbr,d1->bootmgr,DOSPARTOFF);
@@ -258,7 +248,6 @@ Write_Disk(struct disk *d1)
mbr[512-2] = 0x55;
mbr[512-1] = 0xaa;
write_block(fd,WHERE(0,d1),mbr);
-#endif
i = 1;
i = ioctl(fd,DIOCSYNCSLICEINFO,&i);
diff --git a/lib/libedit/Makefile b/lib/libedit/Makefile
index 12d5cb4f1e954..db3057ff2c7cb 100644
--- a/lib/libedit/Makefile
+++ b/lib/libedit/Makefile
@@ -58,7 +58,7 @@ help.h: ${ASRC} makelist
editline.c:
sh ${.CURDIR}/makelist -e ${OSRCS} > ${.TARGET}
-beforedepend editline.o editline.po editline.So: \
+beforedepend editline.o editline.po editline.so: \
vi.h emacs.h common.h fcns.h fcns.c help.h help.c
test: test.o libedit.a ${DPADD} ${LIBTERMCAP}
diff --git a/lib/libedit/term.c b/lib/libedit/term.c
index 90ebf9522c937..442583b094625 100644
--- a/lib/libedit/term.c
+++ b/lib/libedit/term.c
@@ -240,7 +240,7 @@ term_init(el)
el->el_term.t_str = (char **) el_malloc(T_str * sizeof(char*));
(void) memset(el->el_term.t_str, 0, T_str * sizeof(char*));
el->el_term.t_val = (int *) el_malloc(T_val * sizeof(int));
- (void) memset(el->el_term.t_val, 0, T_val * sizeof(int));
+ (void) memset(el->el_term.t_val, 0, T_val * sizeof(char*));
term_outfile = el->el_outfile;
(void) term_set(el, NULL);
term_init_arrow(el);
diff --git a/lib/libf2c/Makefile b/lib/libf2c/Makefile
index fd17e2ae91c35..6183d58808689 100644
--- a/lib/libf2c/Makefile
+++ b/lib/libf2c/Makefile
@@ -5,7 +5,7 @@ CFLAGS+= -DIEEE_drem -DNON_ANSI_RW_MODES -DNON_UNIX_STDIO -DPedantic -I${.CURDIR
MISC = Version.c main.c s_rnge.c abort_.c getarg_.c iargc_.c getenv_.c\
signal_.c s_stop.c s_paus.c system_.c cabs.c\
- derf_.c derfc_.c erf_.c erfc_.c sig_die.c F77_aloc.c exit.c MAIN.c
+ derf_.c derfc_.c erf_.c erfc_.c sig_die.c F77_aloc.c exit.c
POW = pow_ci.c pow_dd.c pow_di.c pow_hh.c pow_ii.c pow_ri.c pow_zi.c pow_zz.c
CX = c_abs.c c_cos.c c_div.c c_exp.c c_log.c c_sin.c c_sqrt.c
DCX = z_cos.c z_div.c z_exp.c z_log.c z_sin.c z_sqrt.c
diff --git a/lib/libfetch/Makefile b/lib/libfetch/Makefile
index 0be36ffbfd157..2afd8bbb623d7 100644
--- a/lib/libfetch/Makefile
+++ b/lib/libfetch/Makefile
@@ -1,50 +1,53 @@
-# $Id: Makefile,v 1.10 1998/12/16 10:24:52 des Exp $
+# $Id$
LIB= fetch
-CFLAGS+= -I. -Wall -pedantic
-.if !defined(DEBUG)
-CFLAGS+= -DNDEBUG
-.endif
-SRCS= fetch.c common.c ftp.c http.c file.c fetch_err.c \
- fetch_err.h ftperr.h httperr.h
+CFLAGS+= -I. -Wall -pedantic -DNDEBUG
+SRCS= fetch.c ftp.c http.c file.c
+DPSRCS= ftperr.c httperr.c
MAN3= fetch.3
-CLEANFILES= fetch_err.c fetch_err.h ftperr.h httperr.h
+CLEANFILES= ${DPSRCS}
SHLIB_MAJOR= 1
SHLIB_MINOR= 0
+beforedepend: ${DPSRCS}
+
beforeinstall:
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/fetch.h \
${DESTDIR}/usr/include
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 fetch_err.h \
- ${DESTDIR}/usr/include
-ftperr.h: ftp.errors
- @echo "static struct fetcherr _ftp_errlist[] = {" > ${.TARGET}
+ftperr.c: ftp.errors
+ @echo "struct ftperr {" \ > ${.TARGET}
+ @echo " const int num;" \ >> ${.TARGET}
+ @echo " const char *string;" \ >> ${.TARGET}
+ @echo "};" \ >> ${.TARGET}
+ @echo "static struct ftperr _ftp_errlist[] = {" \ >> ${.TARGET}
@cat ${.ALLSRC} \
| grep -v ^# \
| sort \
- | while read NUM CAT STRING; do \
- echo " { $${NUM}, FETCH_$${CAT}, \"$${STRING}\" },"; \
+ | while read NUM STRING; do \
+ echo " { $${NUM}, \"$${STRING}\" },"; \
done >> ${.TARGET}
- @echo " { -1, FETCH_UNKNOWN, \"Unknown FTP error\" }" >> ${.TARGET}
+ @echo " { -1, \"Unknown FTP error\" }" >> ${.TARGET}
@echo "};" >> ${.TARGET}
-httperr.h: http.errors
- @echo "static struct fetcherr _http_errlist[] = {" > ${.TARGET}
+httperr.c: http.errors
+ @echo "struct httperr {" \ > ${.TARGET}
+ @echo " const int num;" \ >> ${.TARGET}
+ @echo " const char *string;" \ >> ${.TARGET}
+ @echo "};" \ >> ${.TARGET}
+ @echo "static struct httperr _http_errlist[] = {" \ >> ${.TARGET}
@cat ${.ALLSRC} \
| grep -v ^# \
| sort \
- | while read NUM CAT STRING; do \
- echo " { $${NUM}, FETCH_$${CAT}, \"$${STRING}\" },"; \
+ | while read NUM STRING; do \
+ echo " { $${NUM}, \"$${STRING}\" },"; \
done >> ${.TARGET}
- @echo " { -1, FETCH_UNKNOWN, \"Unknown HTTP error\" }" >> ${.TARGET}
+ @echo " { -1, \"Unknown HTTP error\" }" >> ${.TARGET}
@echo "};" >> ${.TARGET}
-hdrs: fetch_err.h
-
-.ORDER: fetch_err.c fetch_err.h
-fetch_err.c fetch_err.h: fetch_err.et
- compile_et ${.ALLSRC}
-
.include <bsd.lib.mk>
+
+.if !exists(${DEPENDFILE})
+${OBJS} ${POBJS} ${SOBJS}: ${DPSRCS}
+.endif
diff --git a/lib/libfetch/README b/lib/libfetch/README
index 7b8537618ccac..ce50f569c294e 100644
--- a/lib/libfetch/README
+++ b/lib/libfetch/README
@@ -3,8 +3,19 @@ library and provide a new, unified backend for all fetch(1),
pkg_add(1) and sysinstall(8).
Note that this is very much work in progress. It compiles (with a few
-warnings), but there is much left to be implemented. Comments, patches
-etc. of all kinds are welcome, but please don't commit anything
-without talking to me first.
+warnings), but there is much left to be implemented. Amongst other
+items:
+
+ * The man page needs work. Really. I mean it. Now.
+
+ * HTTP authentication doesn't work. I'm not sure if I bungled http.c
+ or fubared base64.c (which was ripped from MIT fetch(1)).
+
+ * The library needs a decent interface for reporting errors. I've
+ started on something (sending back an error code in the url_t that
+ was sent in) but we're Not There (tm) yet.
+
+Comments, patches etc. of all kinds are welcome, but please don't
+commit anything without talking to me first.
-- Dag-Erling C. Smørgrav (des@FreeBSD.org)
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
deleted file mode 100644
index e3dab8dfc28a8..0000000000000
--- a/lib/libfetch/common.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*-
- * Copyright (c) 1998 Dag-Erling Coïdan Smørgrav
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $Id: common.c,v 1.4 1998/12/18 14:32:48 des Exp $
- */
-
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <com_err.h>
-#include <errno.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "fetch.h"
-#include "common.h"
-
-
-/*** Local data **************************************************************/
-
-/*
- * Error messages for resolver errors
- */
-static struct fetcherr _netdb_errlist[] = {
- { HOST_NOT_FOUND, FETCH_RESOLV, "Host not found" },
- { TRY_AGAIN, FETCH_TEMP, "Transient resolver failure" },
- { NO_RECOVERY, FETCH_RESOLV, "Non-recoverable resolver failure" },
- { NO_DATA, FETCH_RESOLV, "No address record" },
- { -1, FETCH_UNKNOWN, "Unknown resolver error" }
-};
-
-static int com_err_initialized;
-
-/*** Error-reporting functions ***********************************************/
-
-/*
- * Initialize the common error library
- */
-static void
-_fetch_init_com_err(void)
-{
- initialize_ftch_error_table();
- com_err_initialized = 1;
-}
-
-/*
- * Map error code to string
- */
-static int
-_fetch_finderr(struct fetcherr *p, int e)
-{
- int i;
- for (i = 0; p[i].num != -1; i++)
- if (p[i].num == e)
- break;
- return i;
-}
-
-/*
- * Set error code
- */
-void
-_fetch_seterr(struct fetcherr *p, int e)
-{
- int n;
-
- if (!com_err_initialized)
- _fetch_init_com_err();
-
- n = _fetch_finderr(p, e);
- fetchLastErrCode = p[n].cat;
- com_err("libfetch", fetchLastErrCode, "(%03d %s)", e, p[n].string);
-}
-
-/*
- * Set error code according to errno
- */
-void
-_fetch_syserr(void)
-{
- int e;
- e = errno;
-
- if (!com_err_initialized)
- _fetch_init_com_err();
-
- switch (errno) {
- case 0:
- fetchLastErrCode = FETCH_OK;
- break;
- case EPERM:
- case EACCES:
- case EROFS:
- case EAUTH:
- case ENEEDAUTH:
- fetchLastErrCode = FETCH_AUTH;
- break;
- case ENOENT:
- case EISDIR: /* XXX */
- fetchLastErrCode = FETCH_UNAVAIL;
- break;
- case ENOMEM:
- fetchLastErrCode = FETCH_MEMORY;
- break;
- case EBUSY:
- case EAGAIN:
- fetchLastErrCode = FETCH_TEMP;
- break;
- case EEXIST:
- fetchLastErrCode = FETCH_EXISTS;
- break;
- case ENOSPC:
- fetchLastErrCode = FETCH_FULL;
- break;
- case EADDRINUSE:
- case EADDRNOTAVAIL:
- case ENETDOWN:
- case ENETUNREACH:
- case ENETRESET:
- case EHOSTUNREACH:
- fetchLastErrCode = FETCH_NETWORK;
- break;
- case ECONNABORTED:
- case ECONNRESET:
- fetchLastErrCode = FETCH_ABORT;
- break;
- case ETIMEDOUT:
- fetchLastErrCode = FETCH_TIMEOUT;
- break;
- case ECONNREFUSED:
- case EHOSTDOWN:
- fetchLastErrCode = FETCH_DOWN;
- break;
- default:
- fetchLastErrCode = FETCH_UNKNOWN;
- }
- com_err("libfetch", fetchLastErrCode, "(%03d %s)", e, strerror(e));
-}
-
-
-/*
- * Emit status message
- */
-int
-_fetch_info(char *fmt, ...)
-{
- va_list ap;
- char *s;
-
- if (!com_err_initialized)
- _fetch_init_com_err();
-
- va_start(ap, fmt);
- vasprintf(&s, fmt, ap);
- va_end(ap);
-
- if (s == NULL) {
- com_err("libfetch", FETCH_MEMORY, "");
- return -1;
- } else {
- com_err("libfetch", FETCH_VERBOSE, "%s", s);
- free(s);
- return 0;
- }
-}
-
-
-/*** Network-related utility functions ***************************************/
-
-/*
- * Establish a TCP connection to the specified port on the specified host.
- */
-int
-_fetch_connect(char *host, int port, int verbose)
-{
- struct sockaddr_in sin;
- struct hostent *he;
- int sd;
-
-#ifndef NDEBUG
- fprintf(stderr, "\033[1m---> %s:%d\033[m\n", host, port);
-#endif
-
- if (verbose)
- _fetch_info("looking up %s", host);
-
- /* look up host name */
- if ((he = gethostbyname(host)) == NULL) {
- _netdb_seterr(h_errno);
- return -1;
- }
-
- if (verbose)
- _fetch_info("connecting to %s:%d", host, port);
-
- /* set up socket address structure */
- bzero(&sin, sizeof(sin));
- bcopy(he->h_addr, (char *)&sin.sin_addr, he->h_length);
- sin.sin_family = he->h_addrtype;
- sin.sin_port = htons(port);
-
- /* try to connect */
- if ((sd = socket(sin.sin_family, SOCK_STREAM, IPPROTO_TCP)) == -1) {
- _fetch_syserr();
- return -1;
- }
- if (connect(sd, (struct sockaddr *)&sin, sizeof sin) == -1) {
- _fetch_syserr();
- close(sd);
- return -1;
- }
-
- return sd;
-}
-
-
-/*** Directory-related utility functions *************************************/
-
-int
-_fetch_add_entry(struct url_ent **p, int *size, int *len,
- char *name, struct url_stat *stat)
-{
- struct url_ent *tmp;
-
- if (*p == NULL) {
-#define INITIAL_SIZE 8
- if ((*p = malloc(INITIAL_SIZE * sizeof **p)) == NULL) {
- errno = ENOMEM;
- _fetch_syserr();
- return -1;
- }
- *size = INITIAL_SIZE;
- *len = 0;
-#undef INITIAL_SIZE
- }
-
- if (*len >= *size - 1) {
- tmp = realloc(*p, *size * 2 * sizeof **p);
- if (tmp == NULL) {
- errno = ENOMEM;
- _fetch_syserr();
- return -1;
- }
- *size *= 2;
- *p = tmp;
- }
-
- tmp = *p + *len;
- snprintf(tmp->name, MAXPATHLEN, "%s", name);
- bcopy(stat, &tmp->stat, sizeof *stat);
-
- (*len)++;
- (++tmp)->name[0] = 0;
-
- return 0;
-}
diff --git a/lib/libfetch/common.h b/lib/libfetch/common.h
deleted file mode 100644
index 0a1154885b787..0000000000000
--- a/lib/libfetch/common.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * Copyright (c) 1998 Dag-Erling Coïdan Smørgrav
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $Id: common.h,v 1.4 1998/12/18 14:32:48 des Exp $
- */
-
-#ifndef _COMMON_H_INCLUDED
-#define _COMMON_H_INCLUDED
-
-/* Structure used for error message lists */
-#define ERRCAT_
-struct fetcherr {
- const int num, cat;
- const char *string;
-};
-
-void _fetch_seterr(struct fetcherr *, int);
-void _fetch_syserr(void);
-int _fetch_info(char *fmt, ...);
-int _fetch_connect(char *, int, int);
-int _fetch_add_entry(struct url_ent **p, int *size, int *len,
- char *name, struct url_stat *stat);
-
-#define _ftp_seterr(n) _fetch_seterr(_ftp_errlist, n)
-#define _http_seterr(n) _fetch_seterr(_http_errlist, n)
-#define _netdb_seterr(n) _fetch_seterr(_netdb_errlist, n)
-#define _url_seterr(n) _fetch_seterr(_url_errlist, n)
-
-#ifndef NDEBUG
-#define DEBUG(x) do x; while (0)
-#else
-#define DEBUG(x) do { } while (0)
-#endif
-
-#endif
diff --git a/lib/libfetch/fetch.3 b/lib/libfetch/fetch.3
index 16dec553ecfc1..c23d0677b8271 100644
--- a/lib/libfetch/fetch.3
+++ b/lib/libfetch/fetch.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: fetch.3,v 1.6 1998/12/16 15:29:03 des Exp $
+.\" $Id: fetch.3,v 1.1.1.1 1998/07/09 16:52:43 des Exp $
.\"
.Dd July 1, 1998
.Dt FETCH 3
@@ -30,74 +30,44 @@
.Sh NAME
.Nm fetchGetURL ,
.Nm fetchPutURL ,
-.Nm fetchStatURL ,
-.Nm fetchListURL ,
.Nm fetchParseURL ,
+.Nm fetchFreeURL ,
.Nm fetchGet ,
.Nm fetchPut ,
-.Nm fetchStat ,
-.Nm fetchList ,
.Nm fetchGetFile ,
.Nm fetchPutFile ,
-.Nm fetchStatFile ,
-.Nm fetchListFile ,
.Nm fetchGetHTTP ,
.Nm fetchPutHTTP ,
-.Nm fetchStatHTTP ,
-.Nm fetchListHTTP ,
.Nm fetchGetFTP ,
.Nm fetchPutFTP
-.Nm fetchStatFTP
-.Nm fetchListFTP ,
.Nd file transfer library
.Sh SYNOPSIS
-.Fd #include <sys/param.h>
-.Fd #include <stdio.h>
.Fd #include <fetch.h>
.Ft FILE *
.Fn fetchGetURL "char *URL" "char *flags"
.Ft FILE *
.Fn fetchPutURL "char *URL" "char *flags"
-.Ft int
-.Fn fetchStatURL "char *URL" "struct url_stat *us" "char *flags"
-.Ft struct url_ent *
-.Fn fetchListURL "char *URL" "char *flags"
-.Ft struct url *
+.Ft url_t *
.Fn fetchParseURL "char *URL" "char *flags"
+.Ft void
+.Fn fetchFreeURL "url_t *u"
.Ft FILE *
-.Fn fetchGet "struct url *URL" "char *flags"
+.Fn fetchGet "url_t *URL" "char *flags"
.Ft FILE *
-.Fn fetchPut "struct url *URL" "char *flags"
-.Ft int
-.Fn fetchStat "struct url *URL" "struct url_stat *us" "char *flags"
-.Ft struct url_ent *
-.Fn fetchList "struct url *" "char *flags"
+.Fn fetchPut "url_t *URL" "char *flags"
.Ft FILE *
-.Fn fetchGetFile "struct url *u" "char *flags"
+.Fn fetchGetFile "url_t *u" "char *flags"
.Ft FILE *
-.Fn fetchPutFile "struct url *u" "char *flags"
-.Ft int
-.Fn fetchStatFile "struct url *URL" "struct url_stat *us" "char *flags"
-.Ft struct url_ent *
-.Fn fetchListFile "struct url *" "char *flags"
+.Fn fetchPutFile "url_t *u" "char *flags"
.Ft FILE *
-.Fn fetchGetHTTP "struct url *u" "char *flags"
+.Fn fetchGetHTTP "url_t *u" "char *flags"
.Ft FILE *
-.Fn fetchPutHTTP "struct url *u" "char *flags"
-.Ft int
-.Fn fetchStatHTTP "struct url *URL" "struct url_stat *us" "char *flags"
-.Ft struct url_ent *
-.Fn fetchListHTTP "struct url *" "char *flags"
+.Fn fetchPutHTTP "url_t *u" "char *flags"
.Ft FILE *
-.Fn fetchGetFTP "struct url *u" "char *flags"
+.Fn fetchGetFTP "url_t *u" "char *flags"
.Ft FILE *
-.Fn fetchPutFTP "struct url *u" "char *flags"
-.Ft int
-.Fn fetchStatFTP "struct url *URL" "struct url_stat *us" "char *flags"
-.Ft struct url_ent *
-.Fn fetchListFTP "struct url *" "char *flags"
+.Fn fetchPutFTP "url_t *u" "char *flags"
.Sh DESCRIPTION
-.Pp
These functions implement a high-level library for retrieving and
uploading files using Uniform Resource Locators (URLs).
.Pp
@@ -114,42 +84,6 @@ argument is a string of characters which specify transfer options. The
meaning of the individual flags is scheme-dependent, and is detailed
in the appropriate section below.
.Pp
-.Fn fetchStatURL
-attempts to obtain the requested document's metadata and fill in the
-structure pointed to by it's second argument. The
-.Fa url_stat
-structure is defined as follows in
-.Aq Pa fetch.h :
-.Bd -literal
-struct url_stat {
- off_t size;
- time_t atime;
- time_t mtime;
-};
-.Ed
-.Pp
-.Fn fetchListURL
-attempts to list the contents of the directory pointed to by the URL
-provided. If successful, it returns a malloced array of
-.Fa url_ent
-structures. The
-.Fa url_ent
-structure is defined as follows in
-.Aq Pa fetch.h :
-.Bd -literal
-struct url_ent {
- char name[MAXPATHLEN];
- struct url_stat stat;
-};
-.Ed
-.Pp
-The list is terminated by an entry with an empty name.
-.Pp
-The pointer returned by
-.Fn fetchListURL
-should be freed using
-.Fn free .
-.Pp
.Fn fetchParseURL
takes a URL in the form of a null-terminated string and splits it into
its components function according to the Common Internet Scheme Syntax
@@ -166,21 +100,19 @@ and <document> components.
The pointer returned by
.Fn fetchParseURL
should be freed using
-.Fn free .
+.Fn fetchFreeURL .
.Pp
-.Fn fetchGet ,
-.Fn fetchPut
+.Fn fetchGet
and
-.Fn fetchStat
+.Fn fetchPut
are similar to
-.Fn fetchGetURL ,
-.Fn fetchPutURL
+.Fn fetchGetURL
and
-.Fn fetchStatURL ,
+.Fn fetchPutURL ,
except that they expect a pre-parsed URL in the form of a pointer to
-a
-.Fa struct url
-rather than a string.
+an
+.Fa url_t
+structure rather than a string.
.Pp
All of the
.Fn fetchGetXXX
@@ -244,66 +176,18 @@ is currently unimplemented.
.Sh RETURN VALUES
.Fn fetchParseURL
returns a pointer to a
-.Fa struct url
-containing the individual components of the URL. If it is
+.Fa url_t
+structure containing the individual components of the URL. If it is
unable to allocate memory, or the URL is syntactically incorrect,
.Fn fetchParseURL
returns a NULL pointer.
.Pp
-The
-.Fn fetchStat
-functions return 0 on success and -1 on failure.
+.Fn fetchFreeURL
+does not return any value.
.Pp
All other functions return a stream pointer which may be used to
-access the requested document, or NULL if an error occurred.
-.Pp
-.Nm Libfetch
-uses the Common Error Library
-.Nm ( libcom_err )
-to report errors. The error code passed to
-.Fn com_err
-is one of:
-.Bl -tag -width Er
-.It Bq Er FETCH_ABORT
-Operation aborted
-.It Bq Er FETCH_AUTH
-Authentication failed
-.It Bq Er FETCH_DOWN
-Service unavailable
-.It Bq Er FETCH_EXISTS
-File exists
-.It Bq Er FETCH_FULL
-File system full
-.It Bq Er FETCH_INFO
-Informational response
-.It Bq Er FETCH_MEMORY
-Insufficient memory
-.It Bq Er FETCH_MOVED
-File has moved
-.It Bq Er FETCH_NETWORK
-Network error
-.It Bq Er FETCH_OK
-No error
-.It Bq Er FETCH_PROTO
-Protocol error
-.It Bq Er FETCH_RESOLV
-Resolver error
-.It Bq Er FETCH_SERVER
-Server error
-.It Bq Er FETCH_TEMP
-Temporary error
-.It Bq Er FETCH_TIMEOUT
-Operation timed out
-.It Bq Er FETCH_UNAVAIL
-File is not available
-.It Bq Er FETCH_UNKNOWN
-Unknown error
-.It Bq Er FETCH_URL
-Invalid URL
-.El
-.Pp
-The accompanying error message includes a protocol-specific error code
-and message, e.g. "File is not available (404 Not Found)"
+access the requested document. Upon failure of any kind, they return a
+NULL pointer.
.Sh ENVIRONMENT
The FTP and HTTP related functions use the
.Ev HTTP_PROXY
@@ -312,7 +196,6 @@ and
environment variables, respectively, as the address of a proxy server
to use for transferring files.
.Sh SEE ALSO
-.Xr com_err 3 ,
.Xr fetch 1 ,
.Xr ftpio 3
.Rs
@@ -333,14 +216,13 @@ to use for transferring files.
.%B File Transfer Protocol
.%O RFC959
.Re
+.Sh DIAGNOSTICS
+Add later.
.Sh NOTES
-The
-.Nm fetch
-library uses the Common Error library, and applications which link
-with
-.Nm libfetch
-must therefore also link with
-.Nm libcom_err .
+Some parts of the library are not yet implemented. The most notable
+examples of this are
+.Fn fetchPutHTTP
+and proxy support for the FTP access method.
.Sh HISTORY
The
.Nm fetch
@@ -352,27 +234,18 @@ The
library was mostly written by
.An Dag-Erling Coïdan Smørgrav Aq des@FreeBSD.org
with numerous suggestions from
-.An Jordan K. Hubbard Aq jkh@FreeBSD.org ,
-.An Eugene Skepner Aq eu@qub.com
+.An Jordan K. Hubbard Aq jkh@FreeBSD.org
and other FreeBSD developers.
-It replaces the older
+It incorporates the older
.Nm ftpio
-library written by
-.An Poul-Henning Kamp Aq pkh@FreeBSD.org
-and
+library, which was originally written by
+.Nm Poul-Henning Kamp Aq pkh@FreeBSD.org
+and later turned inside out by
.An Jordan K. Hubbard Aq jkh@FreeBSD.org .
.Pp
This manual page was written by
.An Dag-Erling Coïdan Smørgrav Aq des@FreeBSD.org
.Sh BUGS
-Some parts of the library are not yet implemented. The most notable
-examples of this are
-.Fn fetchPutHTTP ,
-.Fn fetchStatHTTP ,
-.Fn fetchListHTTP ,
-.Fn fetchListFTP ,
-and FTP proxy support.
-.Pp
There's no way to select a proxy at run-time other than setting the
.Ev HTTP_PROXY
or
@@ -386,21 +259,6 @@ code; as far as I can determine,
.Nm libfetch
handles HTTP/1.1 basic authentication correctly as outlined in
RFC2068, but I haven't been able to find an HTTP server that honors
-the Authentication: header field. Also,
-.Nm libfetch
-does not attempt to interpret and respond to authentication requests
-from the HTTP server.
-.Pp
-No attempt is made to encode spaces etc. within URLs. Spaces in the
-document part of an URLshould be replaced with "%20" in HTTP URLs and
-"\\ " in FTP URLs.
-.Pp
-Error numbers are unique only within a certain context; the error
-codes used for FTP and HTTP overlap, as do those used for resolver and
-system errors. For instance, error code 202 means "Command not
-implemented, superfluous at this site" in an FTP context and
-"Accepted" in an HTTP context.
-.Pp
-The man page is poorly written and produces badly formatted text.
+the Authentication: header field.
.Pp
Tons of other stuff.
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index d8d2443787ced..54421a25b1ef7 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -25,48 +25,34 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: fetch.c,v 1.7 1998/12/16 10:24:54 des Exp $
+ * $Id: fetch.c,v 1.3 1998/07/11 21:29:07 des Exp $
*/
#include <sys/param.h>
-#include <sys/errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <ctype.h>
+#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "fetch.h"
-#include "common.h"
+#ifndef NDEBUG
+#define DEBUG(x) do x; while (0)
+#else
+#define DEBUG(x) do { } while (0)
+#endif
int fetchLastErrCode;
+const char *fetchLastErrText;
-
-/*** Local data **************************************************************/
-
-/*
- * Error messages for parser errors
- */
-#define URL_MALFORMED 1
-#define URL_BAD_SCHEME 2
-#define URL_BAD_PORT 3
-static struct fetcherr _url_errlist[] = {
- { URL_MALFORMED, FETCH_URL, "Malformed URL" },
- { URL_BAD_SCHEME, FETCH_URL, "Invalid URL scheme" },
- { URL_BAD_PORT, FETCH_URL, "Invalid server port" },
- { -1, FETCH_UNKNOWN, "Unknown parser error" }
-};
-
-
-/*** Public API **************************************************************/
-
-/*
- * Select the appropriate protocol for the URL scheme, and return a
- * read-only stream connected to the document referenced by the URL.
- */
FILE *
-fetchGet(struct url *URL, char *flags)
+fetchGet(url_t *URL, char *flags)
{
if (strcasecmp(URL->scheme, "file") == 0)
return fetchGetFile(URL, flags);
@@ -74,18 +60,12 @@ fetchGet(struct url *URL, char *flags)
return fetchGetHTTP(URL, flags);
else if (strcasecmp(URL->scheme, "ftp") == 0)
return fetchGetFTP(URL, flags);
- else {
- _url_seterr(URL_BAD_SCHEME);
- return NULL;
- }
+ else return NULL;
+
}
-/*
- * Select the appropriate protocol for the URL scheme, and return a
- * write-only stream connected to the document referenced by the URL.
- */
FILE *
-fetchPut(struct url *URL, char *flags)
+fetchPut(url_t *URL, char *flags)
{
if (strcasecmp(URL->scheme, "file") == 0)
return fetchPutFile(URL, flags);
@@ -93,57 +73,14 @@ fetchPut(struct url *URL, char *flags)
return fetchPutHTTP(URL, flags);
else if (strcasecmp(URL->scheme, "ftp") == 0)
return fetchPutFTP(URL, flags);
- else {
- _url_seterr(URL_BAD_SCHEME);
- return NULL;
- }
-}
-
-/*
- * Select the appropriate protocol for the URL scheme, and return the
- * size of the document referenced by the URL if it exists.
- */
-int
-fetchStat(struct url *URL, struct url_stat *us, char *flags)
-{
- if (strcasecmp(URL->scheme, "file") == 0)
- return fetchStatFile(URL, us, flags);
- else if (strcasecmp(URL->scheme, "http") == 0)
- return fetchStatHTTP(URL, us, flags);
- else if (strcasecmp(URL->scheme, "ftp") == 0)
- return fetchStatFTP(URL, us, flags);
- else {
- _url_seterr(URL_BAD_SCHEME);
- return -1;
- }
-}
-
-/*
- * Select the appropriate protocol for the URL scheme, and return a
- * list of files in the directory pointed to by the URL.
- */
-struct url_ent *
-fetchList(struct url *URL, char *flags)
-{
- if (strcasecmp(URL->scheme, "file") == 0)
- return fetchListFile(URL, flags);
- else if (strcasecmp(URL->scheme, "http") == 0)
- return fetchListHTTP(URL, flags);
- else if (strcasecmp(URL->scheme, "ftp") == 0)
- return fetchListFTP(URL, flags);
- else {
- _url_seterr(URL_BAD_SCHEME);
- return NULL;
- }
+ else return NULL;
}
-/*
- * Attempt to parse the given URL; if successful, call fetchGet().
- */
+/* get URL */
FILE *
fetchGetURL(char *URL, char *flags)
{
- struct url *u;
+ url_t *u;
FILE *f;
if ((u = fetchParseURL(URL)) == NULL)
@@ -151,18 +88,16 @@ fetchGetURL(char *URL, char *flags)
f = fetchGet(u, flags);
- free(u);
+ fetchFreeURL(u);
return f;
}
-/*
- * Attempt to parse the given URL; if successful, call fetchPut().
- */
+/* put URL */
FILE *
fetchPutURL(char *URL, char *flags)
{
- struct url *u;
+ url_t *u;
FILE *f;
if ((u = fetchParseURL(URL)) == NULL)
@@ -170,73 +105,32 @@ fetchPutURL(char *URL, char *flags)
f = fetchPut(u, flags);
- free(u);
+ fetchFreeURL(u);
return f;
}
/*
- * Attempt to parse the given URL; if successful, call fetchStat().
- */
-int
-fetchStatURL(char *URL, struct url_stat *us, char *flags)
-{
- struct url *u;
- int s;
-
- if ((u = fetchParseURL(URL)) == NULL)
- return -1;
-
- s = fetchStat(u, us, flags);
-
- free(u);
- return s;
-}
-
-/*
- * Attempt to parse the given URL; if successful, call fetchList().
- */
-struct url_ent *
-fetchListURL(char *URL, char *flags)
-{
- struct url *u;
- struct url_ent *ue;
-
- if ((u = fetchParseURL(URL)) == NULL)
- return NULL;
-
- ue = fetchList(u, flags);
-
- free(u);
- return ue;
-}
-
-/*
* Split an URL into components. URL syntax is:
* method:[//[user[:pwd]@]host[:port]]/[document]
* This almost, but not quite, RFC1738 URL syntax.
*/
-struct url *
+url_t *
fetchParseURL(char *URL)
{
char *p, *q;
- struct url *u;
+ url_t *u;
int i;
- /* allocate struct url */
- if ((u = calloc(1, sizeof(struct url))) == NULL) {
- errno = ENOMEM;
- _fetch_syserr();
+ /* allocate url_t */
+ if ((u = calloc(1, sizeof(url_t))) == NULL)
return NULL;
- }
/* scheme name */
for (i = 0; *URL && (*URL != ':'); URL++)
if (i < URL_SCHEMELEN)
u->scheme[i++] = *URL;
- if (!URL[0] || (URL[1] != '/')) {
- _url_seterr(URL_BAD_SCHEME);
+ if (!URL[0] || (URL[1] != '/'))
goto ouch;
- }
else URL++;
if (URL[1] != '/') {
p = URL;
@@ -245,7 +139,7 @@ fetchParseURL(char *URL)
else URL += 2;
p = strpbrk(URL, "/@");
- if (p && *p == '@') {
+ if (*p == '@') {
/* username */
for (q = URL, i = 0; (*q != ':') && (*q != '@'); q++)
if (i < URL_USERLEN)
@@ -270,31 +164,18 @@ fetchParseURL(char *URL)
for (q = ++p; *q && (*q != '/'); q++)
if (isdigit(*q))
u->port = u->port * 10 + (*q - '0');
- else {
- /* invalid port */
- _url_seterr(URL_BAD_PORT);
- goto ouch;
- }
+ else return 0; /* invalid port */
while (*p && (*p != '/'))
p++;
}
nohost:
/* document */
- if (*p) {
- struct url *t;
- t = realloc(u, sizeof(*u)+strlen(p)-1);
- if (t == NULL) {
- errno = ENOMEM;
- _fetch_syserr();
- goto ouch;
- }
- u = t;
- strcpy(u->doc, p);
- } else {
- u->doc[0] = '/';
- u->doc[1] = 0;
- }
+ if (*p)
+ u->doc = strdup(p);
+ u->doc = strdup(*p ? p : "/");
+ if (!u->doc)
+ goto ouch;
DEBUG(fprintf(stderr,
"scheme: [\033[1m%s\033[m]\n"
@@ -312,3 +193,45 @@ ouch:
free(u);
return NULL;
}
+
+void
+fetchFreeURL(url_t *u)
+{
+ if (u) {
+ if (u->doc)
+ free(u->doc);
+ free(u);
+ }
+}
+
+int
+fetchConnect(char *host, int port)
+{
+ struct sockaddr_in sin;
+ struct hostent *he;
+ int sd;
+
+#ifndef NDEBUG
+ fprintf(stderr, "\033[1m---> %s:%d\033[m\n", host, port);
+#endif
+
+ /* look up host name */
+ if ((he = gethostbyname(host)) == NULL)
+ return -1;
+
+ /* set up socket address structure */
+ bzero(&sin, sizeof(sin));
+ bcopy(he->h_addr, (char *)&sin.sin_addr, he->h_length);
+ sin.sin_family = he->h_addrtype;
+ sin.sin_port = htons(port);
+
+ /* try to connect */
+ if ((sd = socket(sin.sin_family, SOCK_STREAM, IPPROTO_TCP)) == -1)
+ return -1;
+ if (connect(sd, (struct sockaddr *)&sin, sizeof sin) == -1) {
+ close(sd);
+ return -1;
+ }
+
+ return sd;
+}
diff --git a/lib/libfetch/fetch.h b/lib/libfetch/fetch.h
index 2e33245503cc7..377edad2acc8b 100644
--- a/lib/libfetch/fetch.h
+++ b/lib/libfetch/fetch.h
@@ -25,13 +25,14 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: fetch.h,v 1.7 1998/12/16 10:24:55 des Exp $
+ * $Id: fetch.h,v 1.3 1998/07/11 21:29:08 des Exp $
*/
#ifndef _FETCH_H_INCLUDED
#define _FETCH_H_INCLUDED
-#include <fetch_err.h>
+#include <sys/param.h>
+#include <stdio.h>
#define _LIBFETCH_VER "libfetch/1.0"
@@ -39,57 +40,41 @@
#define URL_USERLEN 256
#define URL_PWDLEN 256
-struct url {
- char scheme[URL_SCHEMELEN+1];
- char user[URL_USERLEN+1];
- char pwd[URL_PWDLEN+1];
- char host[MAXHOSTNAMELEN+1];
- int port;
- char doc[2];
+struct url_s {
+ char scheme[URL_SCHEMELEN+1];
+ char user[URL_USERLEN+1];
+ char pwd[URL_PWDLEN+1];
+ char host[MAXHOSTNAMELEN+1];
+ char *doc;
+ int port;
};
-struct url_stat {
- off_t size;
- time_t atime;
- time_t mtime;
-};
-
-struct url_ent {
- char name[MAXPATHLEN];
- struct url_stat stat;
-};
+typedef struct url_s url_t;
/* FILE-specific functions */
-FILE *fetchGetFile(struct url *, char *);
-FILE *fetchPutFile(struct url *, char *);
-int fetchStatFile(struct url *, struct url_stat *, char *);
-struct url_ent *fetchListFile(struct url *, char *);
+FILE *fetchGetFile(url_t *, char *);
+FILE *fetchPutFile(url_t *, char *);
/* HTTP-specific functions */
-char *fetchContentType(FILE *);
-FILE *fetchGetHTTP(struct url *, char *);
-FILE *fetchPutHTTP(struct url *, char *);
-int fetchStatHTTP(struct url *, struct url_stat *, char *);
-struct url_ent *fetchListHTTP(struct url *, char *);
+char *fetchContentType(FILE *);
+FILE *fetchGetHTTP(url_t *, char *);
+FILE *fetchPutHTTP(url_t *, char *);
/* FTP-specific functions */
-FILE *fetchGetFTP(struct url *, char *);
-FILE *fetchPutFTP(struct url *, char *);
-int fetchStatFTP(struct url *, struct url_stat *, char *);
-struct url_ent *fetchListFTP(struct url *, char *);
+FILE *fetchGetFTP(url_t *, char *);
+FILE *fetchPutFTP(url_t *, char *);
/* Generic functions */
-struct url *fetchParseURL(char *);
-FILE *fetchGetURL(char *, char *);
-FILE *fetchPutURL(char *, char *);
-int fetchStatURL(char *, struct url_stat *, char *);
-struct url_ent *fetchListURL(char *, char *);
-FILE *fetchGet(struct url *, char *);
-FILE *fetchPut(struct url *, char *);
-int fetchStat(struct url *, struct url_stat *, char *);
-struct url_ent *fetchList(struct url *, char *);
+int fetchConnect(char *, int);
+url_t *fetchParseURL(char *);
+void fetchFreeURL(url_t *);
+FILE *fetchGetURL(char *, char *);
+FILE *fetchPutURL(char *, char *);
+FILE *fetchGet(url_t *, char *);
+FILE *fetchPut(url_t *, char *);
-/* Last error code */
-extern int fetchLastErrCode;
+/* Error code and string */
+extern int fetchLastErrCode;
+extern const char *fetchLastErrText;
#endif
diff --git a/lib/libfetch/fetch_err.et b/lib/libfetch/fetch_err.et
deleted file mode 100644
index 2e247a6006aa5..0000000000000
--- a/lib/libfetch/fetch_err.et
+++ /dev/null
@@ -1,50 +0,0 @@
-#-
-# Copyright (c) 1998 Dag-Erling Coïdan Smørgrav
-# 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
-# in this position and unchanged.
-# 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.
-#
-# $Id: fetch_err.et,v 1.1 1998/11/06 22:14:08 des Exp $
-#
-et ftch
- ec FETCH_ABORT, "Operation aborted"
- ec FETCH_AUTH, "Authentication failed"
- ec FETCH_DOWN, "Service unavailable"
- ec FETCH_EXISTS, "File exists"
- ec FETCH_FULL, "File system full"
- ec FETCH_INFO, "Informational response"
- ec FETCH_MEMORY, "Insufficient memory"
- ec FETCH_MOVED, "File has moved"
- ec FETCH_NETWORK, "Network error"
- ec FETCH_OK, "No error"
- ec FETCH_PROTO, "Protocol error"
- ec FETCH_RESOLV, "Resolver error"
- ec FETCH_SERVER, "Server error"
- ec FETCH_TEMP, "Temporary error"
- ec FETCH_TIMEOUT, "Operation timed out"
- ec FETCH_UNAVAIL, "File is not available"
- ec FETCH_UNKNOWN, "Unknown error"
- ec FETCH_URL, "Invalid URL"
- ec FETCH_VERBOSE, ""
-end
diff --git a/lib/libfetch/file.c b/lib/libfetch/file.c
index 15cb043f52b14..0c685ef34f815 100644
--- a/lib/libfetch/file.c
+++ b/lib/libfetch/file.c
@@ -25,98 +25,25 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: file.c,v 1.3 1998/12/16 10:24:55 des Exp $
+ * $Id$
*/
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include "fetch.h"
-#include "common.h"
FILE *
-fetchGetFile(struct url *u, char *flags)
+fetchGetFile(url_t *u, char *flags)
{
- FILE *f;
-
- f = fopen(u->doc, "r");
-
- if (f == NULL)
- _fetch_syserr();
- return f;
+ flags = flags; /* unused */
+ return fopen(u->doc, "r");
}
FILE *
-fetchPutFile(struct url *u, char *flags)
+fetchPutFile(url_t *u, char *flags)
{
- FILE *f;
-
if (strchr(flags, 'a'))
- f = fopen(u->doc, "a");
- else
- f = fopen(u->doc, "w");
-
- if (f == NULL)
- _fetch_syserr();
- return f;
-}
-
-static int
-_fetch_stat_file(char *fn, struct url_stat *us)
-{
- struct stat sb;
-
- if (stat(fn, &sb) == -1) {
- _fetch_syserr();
- return -1;
- }
- us->size = sb.st_size;
- us->atime = sb.st_atime;
- us->mtime = sb.st_mtime;
- return 0;
-}
-
-int
-fetchStatFile(struct url *u, struct url_stat *us, char *flags)
-{
- return _fetch_stat_file(u->doc, us);
-}
-
-struct url_ent *
-fetchListFile(struct url *u, char *flags)
-{
- DIR *dir;
- struct dirent *de;
- struct url_stat us;
- struct url_ent *ue;
- int size, len;
- char fn[MAXPATHLEN], *p;
- int l;
-
- if ((dir = opendir(u->doc)) == NULL) {
- _fetch_syserr();
- return NULL;
- }
-
- ue = NULL;
- strncpy(fn, u->doc, sizeof fn - 2);
- fn[sizeof fn - 2] = 0;
- strcat(fn, "/");
- p = strchr(fn, 0);
- l = sizeof fn - strlen(fn) - 1;
-
- while ((de = readdir(dir)) != NULL) {
- strncpy(p, de->d_name, l - 1);
- p[l - 1] = 0;
- if (_fetch_stat_file(fn, &us) == -1)
- /* should I return a partial result, or abort? */
- break;
- _fetch_add_entry(&ue, &size, &len, de->d_name, &us);
- }
-
- return ue;
+ return fopen(u->doc, "a");
+ else return fopen(u->doc, "w");
}
diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c
index 10e27b45ae939..d66b7c3f74940 100644
--- a/lib/libfetch/ftp.c
+++ b/lib/libfetch/ftp.c
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: ftp.c,v 1.11 1998/12/18 14:32:48 des Exp $
+ * $Id: ftp.c,v 1.4 1998/07/12 22:34:39 des Exp $
*/
/*
@@ -55,30 +55,30 @@
*
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <sys/errno.h>
#include <ctype.h>
+#include <errno.h>
+#include <netdb.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <time.h>
#include <unistd.h>
#include "fetch.h"
-#include "common.h"
-#include "ftperr.h"
+#include "ftperr.c"
+#define FTP_DEFAULT_TO_ANONYMOUS
#define FTP_ANONYMOUS_USER "ftp"
#define FTP_ANONYMOUS_PASSWORD "ftp"
#define FTP_DEFAULT_PORT 21
#define FTP_OPEN_DATA_CONNECTION 150
#define FTP_OK 200
-#define FTP_FILE_STATUS 213
-#define FTP_SERVICE_READY 220
#define FTP_PASSIVE_MODE 227
#define FTP_LOGGED_IN 230
#define FTP_FILE_ACTION_OK 250
@@ -87,44 +87,84 @@
#define ENDL "\r\n"
-static struct url cached_host;
+static url_t cached_host;
static FILE *cached_socket;
-static char _ftp_last_reply[1024];
+static char *_ftp_last_reply;
+
+/*
+ * Map error code to string
+ */
+static const char *
+_ftp_errstring(int e)
+{
+ struct ftperr *p = _ftp_errlist;
+
+ while ((p->num != -1) && (p->num != e))
+ p++;
+
+ return p->string;
+}
+
+/*
+ * Set error code
+ */
+static void
+_ftp_seterr(int e)
+{
+ fetchLastErrCode = e;
+ fetchLastErrText = _ftp_errstring(e);
+}
+
+/*
+ * Set error code according to errno
+ */
+static void
+_ftp_syserr(void)
+{
+ fetchLastErrCode = errno;
+ fetchLastErrText = strerror(errno);
+}
/*
* Get server response, check that first digit is a '2'
*/
static int
-_ftp_chkerr(FILE *s)
+_ftp_chkerr(FILE *s, int *e)
{
char *line;
size_t len;
+ if (e)
+ *e = 0;
+
do {
if (((line = fgetln(s, &len)) == NULL) || (len < 4)) {
- _fetch_syserr();
+ _ftp_syserr();
return -1;
}
- } while (len >= 4 && line[3] == '-');
+ } while (line[3] == '-');
- while (len && isspace(line[len-1]))
- len--;
- snprintf(_ftp_last_reply, sizeof(_ftp_last_reply),
- "%*.*s", (int)len, (int)len, line);
+ _ftp_last_reply = line;
#ifndef NDEBUG
fprintf(stderr, "\033[1m<<< ");
- fprintf(stderr, "%*.*s\n", (int)len, (int)len, line);
+ fprintf(stderr, "%*.*s", (int)len, (int)len, line);
fprintf(stderr, "\033[m");
#endif
- if (len < 4 || !isdigit(line[1]) || !isdigit(line[1])
+ if (!isdigit(line[1]) || !isdigit(line[1])
|| !isdigit(line[2]) || (line[3] != ' ')) {
+ _ftp_seterr(-1);
return -1;
}
- return (line[0] - '0') * 100 + (line[1] - '0') * 10 + (line[2] - '0');
+ _ftp_seterr((line[0] - '0') * 100 + (line[1] - '0') * 10 + (line[2] - '0'));
+
+ if (e)
+ *e = fetchLastErrCode;
+
+ return (line[0] == '2') - 1;
}
/*
@@ -134,6 +174,7 @@ static int
_ftp_cmd(FILE *f, char *fmt, ...)
{
va_list ap;
+ int e;
va_start(ap, fmt);
vfprintf(f, fmt, ap);
@@ -144,7 +185,8 @@ _ftp_cmd(FILE *f, char *fmt, ...)
#endif
va_end(ap);
- return _ftp_chkerr(f);
+ _ftp_chkerr(f, &e);
+ return e;
}
/*
@@ -154,31 +196,28 @@ static FILE *
_ftp_transfer(FILE *cf, char *oper, char *file, char *mode, int pasv)
{
struct sockaddr_in sin;
- int e, sd = -1, l;
+ int sd = -1, l;
char *s;
FILE *df;
/* change directory */
if (((s = strrchr(file, '/')) != NULL) && (s != file)) {
*s = 0;
- if ((e = _ftp_cmd(cf, "CWD %s" ENDL, file)) != FTP_FILE_ACTION_OK) {
+ if (_ftp_cmd(cf, "CWD %s" ENDL, file) != FTP_FILE_ACTION_OK) {
*s = '/';
- _ftp_seterr(e);
return NULL;
}
*s++ = '/';
} else {
- if ((e = _ftp_cmd(cf, "CWD /" ENDL)) != FTP_FILE_ACTION_OK) {
- _ftp_seterr(e);
+ if (_ftp_cmd(cf, "CWD /" ENDL) != FTP_FILE_ACTION_OK)
return NULL;
- }
}
/* s now points to file name */
/* open data socket */
if ((sd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
- _fetch_syserr();
+ _ftp_syserr();
return NULL;
}
@@ -188,7 +227,7 @@ _ftp_transfer(FILE *cf, char *oper, char *file, char *mode, int pasv)
int i;
/* send PASV command */
- if ((e = _ftp_cmd(cf, "PASV" ENDL)) != FTP_PASSIVE_MODE)
+ if (_ftp_cmd(cf, "PASV" ENDL) != FTP_PASSIVE_MODE)
goto ouch;
/* find address and port number. The reply to the PASV command
@@ -213,8 +252,7 @@ _ftp_transfer(FILE *cf, char *oper, char *file, char *mode, int pasv)
goto sysouch;
/* make the server initiate the transfer */
- e = _ftp_cmd(cf, "%s %s" ENDL, oper, s);
- if (e != FTP_OPEN_DATA_CONNECTION)
+ if (_ftp_cmd(cf, "%s %s" ENDL, oper, s) != FTP_OPEN_DATA_CONNECTION)
goto ouch;
} else {
@@ -237,16 +275,13 @@ _ftp_transfer(FILE *cf, char *oper, char *file, char *mode, int pasv)
goto sysouch;
a = ntohl(sin.sin_addr.s_addr);
p = ntohs(sin.sin_port);
- e = _ftp_cmd(cf, "PORT %d,%d,%d,%d,%d,%d" ENDL,
- (a >> 24) & 0xff, (a >> 16) & 0xff,
- (a >> 8) & 0xff, a & 0xff,
- (p >> 8) & 0xff, p & 0xff);
- if (e != FTP_OK)
+ if (_ftp_cmd(cf, "PORT %d,%d,%d,%d,%d,%d" ENDL,
+ (a >> 24) & 0xff, (a >> 16) & 0xff, (a >> 8) & 0xff, a & 0xff,
+ (p >> 8) & 0xff, p & 0xff) != FTP_OK)
goto ouch;
/* make the server initiate the transfer */
- e = _ftp_cmd(cf, "%s %s" ENDL, oper, s);
- if (e != FTP_OPEN_DATA_CONNECTION)
+ if (_ftp_cmd(cf, "%s %s" ENDL, oper, s) != FTP_OPEN_DATA_CONNECTION)
goto ouch;
/* accept the incoming connection and go to town */
@@ -261,12 +296,8 @@ _ftp_transfer(FILE *cf, char *oper, char *file, char *mode, int pasv)
return df;
sysouch:
- _fetch_syserr();
- close(sd);
- return NULL;
-
+ _ftp_syserr();
ouch:
- _ftp_seterr(e);
close(sd);
return NULL;
}
@@ -275,7 +306,7 @@ ouch:
* Log on to FTP server
*/
static FILE *
-_ftp_connect(char *host, int port, char *user, char *pwd, int verbose)
+_ftp_connect(char *host, int port, char *user, char *pwd)
{
int sd, e, pp = FTP_DEFAULT_PORT;
char *p, *q;
@@ -289,29 +320,28 @@ _ftp_connect(char *host, int port, char *user, char *pwd, int verbose)
}
if (q)
*q = 0;
- sd = _fetch_connect(p, pp, verbose);
+ sd = fetchConnect(p, pp);
if (q)
*q = ':';
} else {
/* no proxy, go straight to target */
- sd = _fetch_connect(host, port, verbose);
+ sd = fetchConnect(host, port);
}
/* check connection */
if (sd == -1) {
- _fetch_syserr();
+ _ftp_syserr();
return NULL;
}
/* streams make life easier */
if ((f = fdopen(sd, "r+")) == NULL) {
- _fetch_syserr();
- close(sd);
- return NULL;
+ _ftp_syserr();
+ goto ouch;
}
/* expect welcome message */
- if ((e = _ftp_chkerr(f)) != FTP_SERVICE_READY)
+ if (_ftp_chkerr(f, NULL) == -1)
goto fouch;
/* send user name and password */
@@ -329,7 +359,7 @@ _ftp_connect(char *host, int port, char *user, char *pwd, int verbose)
/* did the server request an account? */
if (e == FTP_NEED_ACCOUNT)
- goto fouch;
+ /* help! */ ;
/* we should be done by now */
if (e != FTP_LOGGED_IN)
@@ -337,17 +367,19 @@ _ftp_connect(char *host, int port, char *user, char *pwd, int verbose)
/* might as well select mode and type at once */
#ifdef FTP_FORCE_STREAM_MODE
- if ((e = _ftp_cmd(f, "MODE S" ENDL)) != FTP_OK) /* default is S */
- goto fouch;
+ if (_ftp_cmd(f, "MODE S" ENDL) != FTP_OK) /* default is S */
+ goto ouch;
#endif
- if ((e = _ftp_cmd(f, "TYPE I" ENDL)) != FTP_OK) /* default is A */
- goto fouch;
+ if (_ftp_cmd(f, "TYPE I" ENDL) != FTP_OK) /* default is A */
+ goto ouch;
/* done */
return f;
+ouch:
+ close(sd);
+ return NULL;
fouch:
- _ftp_seterr(e);
fclose(f);
return NULL;
}
@@ -358,7 +390,7 @@ fouch:
static void
_ftp_disconnect(FILE *f)
{
- (void)_ftp_cmd(f, "QUIT" ENDL);
+ _ftp_cmd(f, "QUIT" ENDL);
fclose(f);
}
@@ -366,7 +398,7 @@ _ftp_disconnect(FILE *f)
* Check if we're already connected
*/
static int
-_ftp_isconnected(struct url *url)
+_ftp_isconnected(url_t *url)
{
return (cached_socket
&& (strcmp(url->host, cached_host.host) == 0)
@@ -376,145 +408,53 @@ _ftp_isconnected(struct url *url)
}
/*
- * Check the cache, reconnect if no luck
+ * FTP session
*/
static FILE *
-_ftp_cached_connect(struct url *url, char *flags)
+fetchXxxFTP(url_t *url, char *oper, char *mode, char *flags)
{
- FILE *cf;
+ FILE *cf = NULL;
+ int e;
- cf = NULL;
-
/* set default port */
if (!url->port)
url->port = FTP_DEFAULT_PORT;
- /* try to use previously cached connection */
- if (_ftp_isconnected(url))
- if (_ftp_cmd(cached_socket, "NOOP" ENDL) != -1)
+ /* try to use previously cached connection; there should be a 226 waiting */
+ if (_ftp_isconnected(url)) {
+ _ftp_chkerr(cached_socket, &e);
+ if (e > 0)
cf = cached_socket;
+ }
/* connect to server */
if (!cf) {
- cf = _ftp_connect(url->host, url->port, url->user, url->pwd,
- (strchr(flags, 'v') != NULL));
+ cf = _ftp_connect(url->host, url->port, url->user, url->pwd);
if (!cf)
return NULL;
if (cached_socket)
_ftp_disconnect(cached_socket);
cached_socket = cf;
- memcpy(&cached_host, url, sizeof(struct url));
+ memcpy(&cached_host, url, sizeof(url_t));
}
- return cf;
-}
-
-/*
- * Get file
- */
-FILE *
-fetchGetFTP(struct url *url, char *flags)
-{
- FILE *cf;
-
- /* connect to server */
- if ((cf = _ftp_cached_connect(url, flags)) == NULL)
- return NULL;
-
/* initiate the transfer */
- return _ftp_transfer(cf, "RETR", url->doc, "r",
- (flags && strchr(flags, 'p')));
+ return _ftp_transfer(cf, oper, url->doc, mode, (flags && strchr(flags, 'p')));
}
/*
- * Put file
+ * Itsy bitsy teeny weenie
*/
FILE *
-fetchPutFTP(struct url *url, char *flags)
-{
- FILE *cf;
-
- /* connect to server */
- if ((cf = _ftp_cached_connect(url, flags)) == NULL)
- return NULL;
-
- /* initiate the transfer */
- return _ftp_transfer(cf, (flags && strchr(flags, 'a')) ? "APPE" : "STOR",
- url->doc, "w", (flags && strchr(flags, 'p')));
-}
-
-/*
- * Get file stats
- */
-int
-fetchStatFTP(struct url *url, struct url_stat *us, char *flags)
+fetchGetFTP(url_t *url, char *flags)
{
- FILE *cf;
- char *ln, *s;
- struct tm tm;
- time_t t;
- int e;
-
- /* connect to server */
- if ((cf = _ftp_cached_connect(url, flags)) == NULL)
- return -1;
-
- /* change directory */
- if (((s = strrchr(url->doc, '/')) != NULL) && (s != url->doc)) {
- *s = 0;
- if ((e = _ftp_cmd(cf, "CWD %s" ENDL, url->doc)) != FTP_FILE_ACTION_OK) {
- *s = '/';
- goto ouch;
- }
- *s++ = '/';
- } else {
- if ((e = _ftp_cmd(cf, "CWD /" ENDL)) != FTP_FILE_ACTION_OK)
- goto ouch;
- }
-
- /* s now points to file name */
-
- if (_ftp_cmd(cf, "SIZE %s" ENDL, s) != FTP_FILE_STATUS)
- goto ouch;
- for (ln = _ftp_last_reply + 4; *ln && isspace(*ln); ln++)
- /* nothing */ ;
- for (us->size = 0; *ln && isdigit(*ln); ln++)
- us->size = us->size * 10 + *ln - '0';
- if (*ln && !isspace(*ln)) {
- _ftp_seterr(999); /* XXX should signal a FETCH_PROTO error */
- return -1;
- }
-
- if ((e = _ftp_cmd(cf, "MDTM %s" ENDL, s)) != FTP_FILE_STATUS)
- goto ouch;
- for (ln = _ftp_last_reply + 4; *ln && isspace(*ln); ln++)
- /* nothing */ ;
- t = time(NULL);
- us->mtime = localtime(&t)->tm_gmtoff;
- sscanf(ln, "%04d%02d%02d%02d%02d%02d",
- &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
- &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
- /* XXX should check the return value from sscanf */
- tm.tm_mon--;
- tm.tm_year -= 1900;
- tm.tm_isdst = -1;
- tm.tm_gmtoff = 0;
- us->mtime += mktime(&tm);
- us->atime = us->mtime;
- return 0;
-
-ouch:
- _ftp_seterr(e);
- return -1;
+ return fetchXxxFTP(url, "RETR", "r", flags);
}
-/*
- * List a directory
- */
-extern void warnx(char *, ...);
-struct url_ent *
-fetchListFTP(struct url *url, char *flags)
+FILE *
+fetchPutFTP(url_t *url, char *flags)
{
- warnx("fetchListFTP(): not implemented");
- return NULL;
+ if (flags && strchr(flags, 'a'))
+ return fetchXxxFTP(url, "APPE", "w", flags);
+ else return fetchXxxFTP(url, "STOR", "w", flags);
}
diff --git a/lib/libfetch/ftp.errors b/lib/libfetch/ftp.errors
index d7816d28dedac..53a87f04d7b24 100644
--- a/lib/libfetch/ftp.errors
+++ b/lib/libfetch/ftp.errors
@@ -1,44 +1,44 @@
-# $Id: ftp.errors,v 1.1.1.1 1998/07/09 16:52:43 des Exp $
+# $Id: ftp.errors,v 1.3 1997/02/22 15:06:47 peter Exp $
#
# This list is taken from RFC 959.
# It probably needs a going over.
#
-110 OK Restart marker reply
-120 TEMP Service ready in a few minutes
-125 OK Data connection already open; transfer starting
-150 OK File status okay; about to open data connection
-200 OK Command okay
-202 PROTO Command not implemented, superfluous at this site
-211 INFO System status, or system help reply
-212 INFO Directory status
-213 INFO File status
-214 INFO Help message
-215 INFO Set system type
-220 OK Service ready for new user
-221 OK Service closing control connection
-225 OK Data connection open; no transfer in progress
-226 OK Requested file action successful
-227 OK Entering Passive Mode
-230 OK User logged in, proceed
-250 OK Requested file action okay, completed
-257 OK File/directory created
-331 AUTH User name okay, need password
-332 AUTH Need account for login
-350 OK Requested file action pending further information
-421 DOWN Service not available, closing control connection
-425 NETWORK Can't open data connection
-426 ABORT Connection closed; transfer aborted
-450 UNAVAIL File unavailable (e.g., file busy)
-451 SERVER Requested action aborted: local error in processing
-452 FULL Insufficient storage space in system
-500 PROTO Syntax error, command unrecognized
-501 PROTO Syntax error in parameters or arguments
-502 PROTO Command not implemented
-503 PROTO Bad sequence of commands
-504 PROTO Command not implemented for that parameter
-530 AUTH Not logged in
-532 AUTH Need account for storing files
-550 UNAVAIL File unavailable (e.g., file not found, no access)
-551 PROTO Requested action aborted. Page type unknown
-552 FULL Exceeded storage allocation
-553 EXISTS File name not allowed
+110 Restart marker reply
+120 Service ready in a few minutes
+125 Data connection already open; transfer starting
+150 File status okay; about to open data connection
+200 Command okay
+202 Command not implemented, superfluous at this site
+211 System status, or system help reply
+212 Directory status
+213 File status
+214 Help message
+215 Set system type
+220 Service ready for new user
+221 Service closing control connection
+225 Data connection open; no transfer in progress
+226 Requested file action successful
+227 Entering Passive Mode
+230 User logged in, proceed
+250 Requested file action okay, completed
+257 File/directory created
+331 User name okay, need password
+332 Need account for login
+350 Requested file action pending further information
+421 Service not available, closing control connection
+425 Can't open data connection
+426 Connection closed; transfer aborted
+450 File unavailable (e.g., file busy)
+451 Requested action aborted: local error in processing
+452 Insufficient storage space in system
+500 Syntax error, command unrecognized
+501 Syntax error in parameters or arguments
+502 Command not implemented
+503 Bad sequence of commands
+504 Command not implemented for that parameter
+530 Not logged in
+532 Need account for storing files
+550 File unavailable (e.g., file not found, no access)
+551 Requested action aborted. Page type unknown
+552 Exceeded storage allocation
+553 File name not allowed
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index 0d5804a885c40..9ce86a9c8f0f1 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: http.c,v 1.10 1998/12/18 14:32:48 des Exp $
+ * $Id: http.c,v 1.4 1998/07/12 22:34:40 des Exp $
*/
/*
@@ -61,9 +61,15 @@
* SUCH DAMAGE. */
#include <sys/param.h>
+#include <sys/errno.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+
+#include <netinet/in.h>
#include <err.h>
#include <ctype.h>
+#include <netdb.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -71,8 +77,13 @@
#include <unistd.h>
#include "fetch.h"
-#include "common.h"
-#include "httperr.h"
+#include "httperr.c"
+
+#ifndef NDEBUG
+#define DEBUG(x) do x; while (0)
+#else
+#define DEBUG(x) do { } while (0)
+#endif
extern char *__progname;
@@ -92,6 +103,20 @@ struct cookie
};
/*
+ * Look up error code
+ */
+static const char *
+_http_errstring(int e)
+{
+ struct httperr *p = _http_errlist;
+
+ while ((p->num != -1) && (p->num != e))
+ p++;
+
+ return p->string;
+}
+
+/*
* Send a formatted line; optionally echo to terminal
*/
static int
@@ -288,19 +313,17 @@ _http_auth(char *usr, char *pwd)
}
/*
- * Retrieve a file by HTTP
+ * retrieve a file by HTTP
*/
FILE *
-fetchGetHTTP(struct url *URL, char *flags)
+fetchGetHTTP(url_t *URL, char *flags)
{
- int sd = -1, e, i, enc = ENC_NONE, verbose;
+ int sd = -1, err, i, enc = ENC_NONE;
struct cookie *c;
- char *ln, *p, *px, *q;
+ char *ln, *p, *q;
FILE *f, *cf;
size_t len;
- verbose = (strchr(flags, 'v') != NULL);
-
/* allocate cookie */
if ((c = calloc(1, sizeof(struct cookie))) == NULL)
return NULL;
@@ -310,11 +333,13 @@ fetchGetHTTP(struct url *URL, char *flags)
URL->port = 80; /* default HTTP port */
/* attempt to connect to proxy server */
- if ((px = getenv("HTTP_PROXY")) != NULL) {
- char host[MAXHOSTNAMELEN];
+ if (getenv("HTTP_PROXY")) {
+ char *px, host[MAXHOSTNAMELEN];
int port = 3128; /* XXX I think 3128 is default... check? */
+ size_t len;
/* measure length */
+ px = getenv("HTTP_PROXY");
len = strcspn(px, ":");
/* get port (atoi is a little too tolerant perhaps?) */
@@ -328,12 +353,12 @@ fetchGetHTTP(struct url *URL, char *flags)
host[len] = 0;
/* connect */
- sd = _fetch_connect(host, port, verbose);
+ sd = fetchConnect(host, port);
}
/* if no proxy is configured or could be contacted, try direct */
if (sd == -1) {
- if ((sd = _fetch_connect(URL->host, URL->port, verbose)) == -1)
+ if ((sd = fetchConnect(URL->host, URL->port)) == -1)
goto ouch;
}
@@ -343,9 +368,6 @@ fetchGetHTTP(struct url *URL, char *flags)
c->real_f = f;
/* send request (proxies require absolute form, so use that) */
- if (verbose)
- _fetch_info("requesting http://%s:%d%s",
- URL->host, URL->port, URL->doc);
_http_cmd(f, "GET http://%s:%d%s HTTP/1.1" ENDL,
URL->host, URL->port, URL->doc);
@@ -375,12 +397,13 @@ fetchGetHTTP(struct url *URL, char *flags)
p++;
if (!isdigit(*p))
goto fouch;
- e = atoi(p);
- DEBUG(fprintf(stderr, "code: [\033[1m%d\033[m]\n", e));
+ err = atoi(p);
+ DEBUG(fprintf(stderr, "code: [\033[1m%d\033[m]\n", err));
/* add code to handle redirects later */
- if (e != 200) {
- _http_seterr(e);
+ if (err != 200) {
+ fetchLastErrCode = err;
+ fetchLastErrText = _http_errstring(err);
goto fouch;
}
@@ -434,38 +457,16 @@ ouch:
if (sd >= 0)
close(sd);
free(c);
- _http_seterr(999); /* XXX do this properly RSN */
return NULL;
fouch:
fclose(f);
free(c);
- _http_seterr(999); /* XXX do this properly RSN */
return NULL;
}
FILE *
-fetchPutHTTP(struct url *URL, char *flags)
+fetchPutHTTP(url_t *URL, char *flags)
{
warnx("fetchPutHTTP(): not implemented");
return NULL;
}
-
-/*
- * Get an HTTP document's metadata
- */
-int
-fetchStatHTTP(struct url *url, struct url_stat *us, char *flags)
-{
- warnx("fetchStatHTTP(): not implemented");
- return -1;
-}
-
-/*
- * List a directory
- */
-struct url_ent *
-fetchListHTTP(struct url *url, char *flags)
-{
- warnx("fetchListHTTP(): not implemented");
- return NULL;
-}
diff --git a/lib/libfetch/http.errors b/lib/libfetch/http.errors
index 26907d538adc8..c0e35391d18e6 100644
--- a/lib/libfetch/http.errors
+++ b/lib/libfetch/http.errors
@@ -1,41 +1,41 @@
-# $Id: http.errors,v 1.1.1.1 1998/07/09 16:52:44 des Exp $
+# $Id$
#
# This list is taken from RFC 2068.
#
-100 OK Continue
-101 OK Switching Protocols
-200 OK OK
-201 OK Created
-202 OK Accepted
-203 INFO Non-Authoritative Information
-204 OK No Content
-205 OK Reset Content
-206 OK Partial Content
-300 MOVED Multiple Choices
-301 MOVED Moved Permanently
-302 MOVED Moved Temporarily
-303 MOVED See Other
-304 OK Not Modified
-305 INFO Use Proxy
-400 PROTO Bad Request
-401 AUTH Unauthorized
-402 AUTH Payment Required
-403 AUTH Forbidden
-404 UNAVAIL Not Found
-405 PROTO Method Not Allowed
-406 PROTO Not Acceptable
-407 AUTH Proxy Authentication Required
-408 TIMEOUT Request Time-out
-409 EXISTS Conflict
-410 UNAVAIL Gone
-411 PROTO Length Required
-412 SERVER Precondition Failed
-413 PROTO Request Entity Too Large
-414 PROTO Request-URI Too Large
-415 PROTO Unsupported Media Type
-500 SERVER Internal Server Error
-501 PROTO Not Implemented
-502 SERVER Bad Gateway
-503 TEMP Service Unavailable
-504 TIMEOUT Gateway Time-out
-505 PROTO HTTP Version not supported
+100 Continue
+101 Switching Protocols
+200 OK
+201 Created
+202 Accepted
+203 Non-Authoritative Information
+204 No Content
+205 Reset Content
+206 Partial Content
+300 Multiple Choices
+301 Moved Permanently
+302 Moved Temporarily
+303 See Other
+304 Not Modified
+305 Use Proxy
+400 Bad Request
+401 Unauthorized
+402 Payment Required
+403 Forbidden
+404 Not Found
+405 Method Not Allowed
+406 Not Acceptable
+407 Proxy Authentication Required
+408 Request Time-out
+409 Conflict
+410 Gone
+411 Length Required
+412 Precondition Failed
+413 Request Entity Too Large
+414 Request-URI Too Large
+415 Unsupported Media Type
+500 Internal Server Error
+501 Not Implemented
+502 Bad Gateway
+503 Service Unavailable
+504 Gateway Time-out
+505 HTTP Version not supported
diff --git a/lib/libio/Makefile b/lib/libio/Makefile
deleted file mode 100644
index b9aeebdcaa79d..0000000000000
--- a/lib/libio/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id$
-
-LIB= io
-SHLIB_MAJOR= 1
-SRCS= io.c swiz.c bwx.c alpha_sethae.c
-
-CFLAGS+= -Wall -Wa,-mev56
-
-NOMAN=1
-
-.include <bsd.lib.mk>
diff --git a/lib/libio/alpha_sethae.c b/lib/libio/alpha_sethae.c
deleted file mode 100644
index 365b0514965af..0000000000000
--- a/lib/libio/alpha_sethae.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * Copyright (c) 1998 Doug Rabson
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $Id$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
-static const char rcsid[] = "$Id$";
-#endif /* LIBC_RCS and not lint */
-
-#include <sys/types.h>
-#include <machine/sysarch.h>
-
-extern int sysarch(int, char *);
-
-struct parms {
- u_int64_t hae;
-};
-
-int
-alpha_sethae(u_int64_t hae)
-{
- struct parms p;
-
- p.hae = hae;
-
- return (sysarch(ALPHA_SETHAE, (char *)&p));
-}
diff --git a/lib/libio/bwx.c b/lib/libio/bwx.c
deleted file mode 100644
index 5a9e778a17347..0000000000000
--- a/lib/libio/bwx.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*-
- * Copyright (c) 1998 Doug Rabson
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $Id$
- */
-
-#include <sys/param.h>
-#include <sys/mman.h>
-#include <sys/fcntl.h>
-#include <sys/sysctl.h>
-#include <err.h>
-#include <machine/bwx.h>
-#include <machine/sysarch.h>
-#include <stdlib.h>
-#include "io.h"
-
-#define mb() __asm__ __volatile__("mb" : : : "memory")
-#define wmb() __asm__ __volatile__("wmb" : : : "memory")
-
-static int mem_fd; /* file descriptor to /dev/mem */
-static void *bwx_int1_ports; /* mapped int1 io ports */
-static void *bwx_int2_ports; /* mapped int2 io ports */
-static void *bwx_int4_ports; /* mapped int4 io ports */
-static u_int64_t bwx_io_base; /* physical address of ports */
-static u_int64_t bwx_mem_base; /* physical address of bwx mem */
-
-static void
-bwx_init()
-{
- size_t len = sizeof(u_int64_t);
- int error;
-
- mem_fd = open("/dev/mem", O_RDWR);
- if (mem_fd < 0)
- err(1, "/dev/mem");
- bwx_int1_ports = mmap(0, 1L<<32, PROT_READ, MAP_ANON, -1, 0);
- bwx_int2_ports = mmap(0, 1L<<32, PROT_READ, MAP_ANON, -1, 0);
- bwx_int4_ports = mmap(0, 1L<<32, PROT_READ, MAP_ANON, -1, 0);
-
- if ((error = sysctlbyname("hw.chipset.ports", &bwx_io_base, &len,
- 0, 0)) < 0)
- err(1, "hw.chipset.ports");
- if ((error = sysctlbyname("hw.chipset.memory", &bwx_mem_base, &len,
- 0, 0)) < 0)
- err(1, "hw.chipset.memory");
-}
-
-static int
-bwx_ioperm(u_int32_t from, u_int32_t num, int on)
-{
- if (!bwx_int1_ports)
- bwx_init();
-
- if (!on)
- return -1; /* XXX can't unmap yet */
-
- munmap(bwx_int1_ports + from, num);
- munmap(bwx_int2_ports + from, num);
- munmap(bwx_int4_ports + from, num);
- mmap(bwx_int1_ports + from, num, PROT_READ|PROT_WRITE, MAP_SHARED,
- mem_fd, bwx_io_base + BWX_EV56_INT1 + from);
- mmap(bwx_int2_ports + from, num, PROT_READ|PROT_WRITE, MAP_SHARED,
- mem_fd, bwx_io_base + BWX_EV56_INT2 + from);
- mmap(bwx_int4_ports + from, num, PROT_READ|PROT_WRITE, MAP_SHARED,
- mem_fd, bwx_io_base + BWX_EV56_INT4 + from);
- return 0;
-}
-
-static u_int8_t
-bwx_inb(u_int32_t port)
-{
- mb();
- return ldbu((vm_offset_t)bwx_int1_ports + port);
-}
-
-static u_int16_t
-bwx_inw(u_int32_t port)
-{
- mb();
- return ldwu((vm_offset_t)bwx_int2_ports + port);
-}
-
-static u_int32_t
-bwx_inl(u_int32_t port)
-{
- mb();
- return ldl((vm_offset_t)bwx_int4_ports + port);
-}
-
-static void
-bwx_outb(u_int32_t port, u_int8_t val)
-{
- stb((vm_offset_t)bwx_int1_ports + port, val);
- wmb();
-}
-
-static void
-bwx_outw(u_int32_t port, u_int16_t val)
-{
- stw((vm_offset_t)bwx_int2_ports + port, val);
- wmb();
-}
-
-static void
-bwx_outl(u_int32_t port, u_int32_t val)
-{
- stl((vm_offset_t)bwx_int4_ports + port, val);
- wmb();
-}
-
-struct bwx_mem_handle {
- void *virt1; /* int1 address in user address-space */
- void *virt2; /* int2 address in user address-space */
- void *virt4; /* int4 address in user address-space */
-};
-
-static void *
-bwx_map_memory(u_int32_t address, u_int32_t size)
-{
- struct bwx_mem_handle *h;
- h = malloc(sizeof(struct bwx_mem_handle));
- if (!h) return 0;
- h->virt1 = mmap(0, size << 5, PROT_READ|PROT_WRITE, MAP_SHARED,
- mem_fd, bwx_mem_base + BWX_EV56_INT1 + address);
- if ((long) h->virt1 == -1) {
- free(h);
- return 0;
- }
- h->virt2 = mmap(0, size << 5, PROT_READ|PROT_WRITE, MAP_SHARED,
- mem_fd, bwx_mem_base + BWX_EV56_INT2 + address);
- if ((long) h->virt2 == -1) {
- munmap(h->virt1, size);
- free(h);
- return 0;
- }
- h->virt4 = mmap(0, size << 5, PROT_READ|PROT_WRITE, MAP_SHARED,
- mem_fd, bwx_mem_base + BWX_EV56_INT4 + address);
- if ((long) h->virt4 == -1) {
- munmap(h->virt1, size);
- munmap(h->virt2, size);
- free(h);
- return 0;
- }
- return h;
-}
-
-static void
-bwx_unmap_memory(void *handle, u_int32_t size)
-{
- struct bwx_mem_handle *h = handle;
- munmap(h->virt1, size);
- munmap(h->virt2, size);
- munmap(h->virt4, size);
- free(h);
-}
-
-static u_int8_t
-bwx_readb(void *handle, u_int32_t offset)
-{
- struct bwx_mem_handle *h = handle;
- return ldbu((vm_offset_t)h->virt1 + offset);
-}
-
-static u_int16_t
-bwx_readw(void *handle, u_int32_t offset)
-{
- struct bwx_mem_handle *h = handle;
- return ldwu((vm_offset_t)h->virt2 + offset);
-}
-
-static u_int32_t
-bwx_readl(void *handle, u_int32_t offset)
-{
- struct bwx_mem_handle *h = handle;
- return ldl((vm_offset_t)h->virt4 + offset);
-}
-
-static void
-bwx_writeb(void *handle, u_int32_t offset, u_int8_t val)
-{
- struct bwx_mem_handle *h = handle;
- stb((vm_offset_t)h->virt1 + offset, val);
-}
-
-static void
-bwx_writew(void *handle, u_int32_t offset, u_int16_t val)
-{
- struct bwx_mem_handle *h = handle;
- stw((vm_offset_t)h->virt2 + offset, val);
-}
-
-static void
-bwx_writel(void *handle, u_int32_t offset, u_int32_t val)
-{
- struct bwx_mem_handle *h = handle;
- stl((vm_offset_t)h->virt4 + offset, val);
-}
-
-struct io_ops bwx_io_ops = {
- bwx_ioperm,
- bwx_inb,
- bwx_inw,
- bwx_inl,
- bwx_outb,
- bwx_outw,
- bwx_outl,
- bwx_map_memory,
- bwx_unmap_memory,
- bwx_readb,
- bwx_readw,
- bwx_readl,
- bwx_writeb,
- bwx_writew,
- bwx_writel,
-};
diff --git a/lib/libio/io.c b/lib/libio/io.c
deleted file mode 100644
index f847755a57939..0000000000000
--- a/lib/libio/io.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*-
- * Copyright (c) 1998 Doug Rabson
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $Id$
- */
-
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#include <err.h>
-#include "io.h"
-
-static struct io_ops *ops;
-
-int
-ioperm(unsigned long from, unsigned long num, int on)
-{
- int error;
- int bwx;
- size_t len = sizeof(bwx);
-
- if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0)
- return error;
- if (bwx)
- ops = &bwx_io_ops;
- else
- ops = &swiz_io_ops;
-
- return ops->ioperm(from, num, on);
-}
-
-u_int8_t
-inb(u_int32_t port)
-{
- return ops->inb(port);
-}
-
-u_int16_t
-inw(u_int32_t port)
-{
- return ops->inw(port);
-}
-
-u_int32_t
-inl(u_int32_t port)
-{
- return ops->inl(port);
-}
-
-void
-outb(u_int32_t port, u_int8_t val)
-{
- ops->outb(port, val);
-}
-
-void
-outw(u_int32_t port, u_int16_t val)
-{
- ops->outw(port, val);
-}
-
-void
-outl(u_int32_t port, u_int32_t val)
-{
- ops->outl(port, val);
-}
-
-void *
-map_memory(u_int32_t address, u_int32_t size)
-{
- return ops->map_memory(address, size);
-}
-
-void
-unmap_memory(void *handle, u_int32_t size)
-{
- ops->unmap_memory(handle, size);
-}
-
-u_int8_t
-readb(void *handle, u_int32_t offset)
-{
- return ops->readb(handle, offset);
-}
-
-u_int16_t
-readw(void *handle, u_int32_t offset)
-{
- return ops->readw(handle, offset);
-}
-
-u_int32_t
-readl(void *handle, u_int32_t offset)
-{
- return ops->readl(handle, offset);
-}
-
-void
-writeb(void *handle, u_int32_t offset, u_int8_t val)
-{
- return ops->writeb(handle, offset, val);
-}
-
-void
-writew(void *handle, u_int32_t offset, u_int16_t val)
-{
- return ops->writew(handle, offset, val);
-}
-
-void
-writel(void *handle, u_int32_t offset, u_int32_t val)
-{
- return ops->writel(handle, offset, val);
-}
-
-u_int64_t
-dense_base(void)
-{
- static u_int64_t base = 0;
-
- if (base == 0) {
- size_t len = sizeof(base);
- int error;
- if ((error = sysctlbyname("hw.chipset.dense", &base, &len,
- 0, 0)) < 0)
- err(1, "hw.chipset.dense");
- }
-
- return base;
-}
diff --git a/lib/libio/io.h b/lib/libio/io.h
deleted file mode 100644
index a166355612ea6..0000000000000
--- a/lib/libio/io.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright (c) 1998 Doug Rabson
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $Id$
- */
-
-struct io_ops {
- int (*ioperm)(u_int32_t, u_int32_t, int);
- u_int8_t (*inb)(u_int32_t);
- u_int16_t (*inw)(u_int32_t);
- u_int32_t (*inl)(u_int32_t);
- void (*outb)(u_int32_t, u_int8_t);
- void (*outw)(u_int32_t, u_int16_t);
- void (*outl)(u_int32_t, u_int32_t);
- void * (*map_memory)(u_int32_t, u_int32_t);
- void (*unmap_memory)(void *, u_int32_t);
- u_int8_t (*readb)(void *, u_int32_t);
- u_int16_t (*readw)(void *, u_int32_t);
- u_int32_t (*readl)(void *, u_int32_t);
- void (*writeb)(void *, u_int32_t, u_int8_t);
- void (*writew)(void *, u_int32_t, u_int16_t);
- void (*writel)(void *, u_int32_t, u_int32_t);
-};
-
-extern struct io_ops swiz_io_ops;
-extern struct io_ops bwx_io_ops;
diff --git a/lib/libio/swiz.c b/lib/libio/swiz.c
deleted file mode 100644
index d8bb7b5c287ec..0000000000000
--- a/lib/libio/swiz.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*-
- * Copyright (c) 1998 Doug Rabson
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $Id$
- */
-
-#include <sys/param.h>
-#include <sys/mman.h>
-#include <sys/fcntl.h>
-#include <sys/sysctl.h>
-#include <err.h>
-#include <machine/swiz.h>
-#include <machine/sysarch.h>
-#include <stdlib.h>
-#include "io.h"
-
-#define mb() __asm__ __volatile__("mb" : : : "memory")
-#define wmb() __asm__ __volatile__("wmb" : : : "memory")
-
-static int mem_fd; /* file descriptor to /dev/mem */
-static void *swiz_ports; /* mapped io ports */
-static u_int64_t swiz_io_base; /* physical address of ports */
-static u_int64_t swiz_mem_base; /* physical address of sparse mem */
-static u_int64_t swiz_dense_base; /* physical address of dense mem */
-static u_int64_t swiz_hae_mask; /* mask address bits for hae */
-static u_int32_t swiz_hae; /* cache of current hae */
-
-static void
-swiz_init()
-{
-
- size_t len = sizeof(u_int64_t);
- int error;
-
- mem_fd = open("/dev/mem", O_RDWR);
- if (mem_fd < 0)
- err(1, "/dev/mem");
- swiz_ports = mmap(0, 1L<<32, PROT_READ, MAP_ANON, -1, 0);
-
- if ((error = sysctlbyname("hw.chipset.ports", &swiz_io_base, &len,
- 0, 0)) < 0)
- err(1, "hw.chipset.ports");
- if ((error = sysctlbyname("hw.chipset.memory", &swiz_mem_base, &len,
- 0, 0)) < 0)
- err(1, "hw.chipset.memory");
- if ((error = sysctlbyname("hw.chipset.dense", &swiz_dense_base, &len,
- 0, 0)) < 0)
- err(1, "hw.chipset.memory");
- if ((error = sysctlbyname("hw.chipset.hae_mask", &swiz_hae_mask, &len,
- 0, 0)) < 0)
- err(1, "hw.chipset.memory");
-
-}
-
-static int
-swiz_ioperm(u_int32_t from, u_int32_t num, int on)
-{
- u_int64_t start, end;
- void *addr;
-
- if (!swiz_ports)
- swiz_init();
-
- if (!on)
- return -1; /* XXX can't unmap yet */
-
- start = from << 5;
- end = (from + num) << 5;
- addr = swiz_ports + start;
- munmap(addr, end - start);
- mmap(addr, end - start, PROT_READ|PROT_WRITE, MAP_SHARED,
- mem_fd, swiz_io_base + start);
- return 0;
-}
-
-static u_int8_t
-swiz_inb(u_int32_t port)
-{
- mb();
- return SPARSE_READ_BYTE(swiz_ports, port);
-}
-
-static u_int16_t
-swiz_inw(u_int32_t port)
-{
- mb();
- return SPARSE_READ_WORD(swiz_ports, port);
-}
-
-static u_int32_t
-swiz_inl(u_int32_t port)
-{
- mb();
- return SPARSE_READ_LONG(swiz_ports, port);
-}
-
-static void
-swiz_outb(u_int32_t port, u_int8_t val)
-{
- SPARSE_WRITE_BYTE(swiz_ports, port, val);
- wmb();
-}
-
-static void
-swiz_outw(u_int32_t port, u_int16_t val)
-{
- SPARSE_WRITE_WORD(swiz_ports, port, val);
- wmb();
-}
-
-static void
-swiz_outl(u_int32_t port, u_int32_t val)
-{
- SPARSE_WRITE_LONG(swiz_ports, port, val);
- wmb();
-}
-
-struct swiz_mem_handle {
- u_int32_t phys; /* address in PCI address-space */
- void *virt; /* address in user address-space */
- u_int32_t size; /* size of mapped region */
-};
-
-static void *
-swiz_map_memory(u_int32_t address, u_int32_t size)
-{
- struct swiz_mem_handle *h;
- h = malloc(sizeof(struct swiz_mem_handle));
- if (!h) return 0;
- h->phys = address;
- h->virt = mmap(0, size << 5, PROT_READ|PROT_WRITE, MAP_SHARED,
- mem_fd,
- swiz_mem_base + ((address & ~swiz_hae_mask) << 5));
- if ((long) h->virt == -1) {
- free(h);
- return 0;
- }
- h->size = size << 5;
- return h;
-}
-
-static void
-swiz_unmap_memory(void *handle, u_int32_t size)
-{
- struct swiz_mem_handle *h = handle;
- munmap(h->virt, h->size);
- free(h);
-}
-
-static void
-swiz_sethae(vm_offset_t phys)
-{
- u_int32_t hae = phys & swiz_hae_mask;
- if (hae != swiz_hae) {
- alpha_sethae(hae);
- swiz_hae = hae;
- }
-}
-
-static u_int8_t
-swiz_readb(void *handle, u_int32_t offset)
-{
- struct swiz_mem_handle *h = handle;
- swiz_sethae(h->phys + offset);
- return SPARSE_READ_BYTE(h->virt, offset);
-}
-
-static u_int16_t
-swiz_readw(void *handle, u_int32_t offset)
-{
- struct swiz_mem_handle *h = handle;
- swiz_sethae(h->phys + offset);
- return SPARSE_READ_WORD(h->virt, offset);
-}
-
-static u_int32_t
-swiz_readl(void *handle, u_int32_t offset)
-{
- struct swiz_mem_handle *h = handle;
- swiz_sethae(h->phys + offset);
- return SPARSE_READ_LONG(h->virt, offset);
-}
-
-static void
-swiz_writeb(void *handle, u_int32_t offset, u_int8_t val)
-{
- struct swiz_mem_handle *h = handle;
- swiz_sethae(h->phys + offset);
- SPARSE_WRITE_BYTE(h->virt, offset, val);
-}
-
-static void
-swiz_writew(void *handle, u_int32_t offset, u_int16_t val)
-{
- struct swiz_mem_handle *h = handle;
- swiz_sethae(h->phys + offset);
- SPARSE_WRITE_WORD(h->virt, offset, val);
-}
-
-static void
-swiz_writel(void *handle, u_int32_t offset, u_int32_t val)
-{
- struct swiz_mem_handle *h = handle;
- swiz_sethae(h->phys + offset);
- SPARSE_WRITE_LONG(h->virt, offset, val);
-}
-
-struct io_ops swiz_io_ops = {
- swiz_ioperm,
- swiz_inb,
- swiz_inw,
- swiz_inl,
- swiz_outb,
- swiz_outw,
- swiz_outl,
- swiz_map_memory,
- swiz_unmap_memory,
- swiz_readb,
- swiz_readw,
- swiz_readl,
- swiz_writeb,
- swiz_writew,
- swiz_writel,
-};
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c
index 9543feee4de6c..c91786113a216 100644
--- a/lib/libkvm/kvm_proc.c
+++ b/lib/libkvm/kvm_proc.c
@@ -302,14 +302,15 @@ kvm_getprocs(kd, op, arg, cnt)
_kvm_syserr(kd, kd->program, "kvm_getprocs");
return (0);
}
+ kd->procbase = 0;
do {
size += size / 10;
kd->procbase = (struct kinfo_proc *)
- _kvm_realloc(kd, kd->procbase, size);
+ _kvm_realloc(kd, kd->procbase, size);
if (kd->procbase == 0)
return (0);
st = sysctl(mib, op == KERN_PROC_ALL ? 3 : 4,
- kd->procbase, &size, NULL, 0);
+ kd->procbase, &size, NULL, 0);
} while (st == -1 && errno == ENOMEM);
if (st == -1) {
_kvm_syserr(kd, kd->program, "kvm_getprocs");
@@ -600,18 +601,21 @@ proc_verify(kd, kernp, p)
const struct proc *p;
{
struct kinfo_proc kp;
- int mib[4];
+ int mib[4], st;
size_t len;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = p->p_pid;
- len = sizeof(kp);
- if (sysctl(mib, 4, &kp, &len, NULL, 0) == -1)
- return (0);
+
+ len = sizeof kp;
+
+ st = sysctl(mib, 4, &kp, &len, NULL, 0);
+ if (st < 0)
+ return(0);
return (p->p_pid == kp.kp_proc.p_pid &&
- (kp.kp_proc.p_stat != SZOMB || p->p_stat == SZOMB));
+ (kp.kp_proc.p_stat != SZOMB || p->p_stat == SZOMB));
}
static char **
@@ -625,14 +629,15 @@ kvm_doargv(kd, kp, nchr, info)
register char **ap;
u_long addr;
int cnt;
- static struct ps_strings arginfo;
- static u_long ps_strings;
+ static struct ps_strings arginfo, *ps_strings;
size_t len;
+ int i;
if (ps_strings == NULL) {
- len = sizeof(ps_strings);
- if (sysctlbyname("kern.ps_strings", &ps_strings, &len, NULL,
- 0) == -1)
+ len = sizeof ps_strings;
+ i = sysctlbyname("kern.ps_strings",
+ &ps_strings, &len, 0, 0);
+ if (i < 0 || ps_strings == NULL)
ps_strings = PS_STRINGS;
}
diff --git a/lib/libkvm/kvm_read.3 b/lib/libkvm/kvm_read.3
index b5609599f6abe..1e8e3ad4288ff 100644
--- a/lib/libkvm/kvm_read.3
+++ b/lib/libkvm/kvm_read.3
@@ -43,6 +43,7 @@
.Nm kvm_write
.Nd read or write kernel virtual memory
.Sh SYNOPSIS
+.Fd #include <sys/types.h>
.Fd #include <kvm.h>
.Ft ssize_t
.Fn kvm_read "kvm_t *kd" "u_long addr" "void *buf" "size_t nbytes"
diff --git a/lib/libmd/Makefile b/lib/libmd/Makefile
index d2cb2d5e84405..842f801b8ea0e 100644
--- a/lib/libmd/Makefile
+++ b/lib/libmd/Makefile
@@ -1,6 +1,9 @@
-# $Id: Makefile,v 1.27 1998/09/11 05:41:29 imp Exp $
+# $Id: Makefile,v 1.26 1998/08/30 01:50:04 jb Exp $
LIB= md
+.if ${OBJFORMAT} != elf
+NOPIC= true
+.endif
SRCS= md2c.c md4c.c md5c.c md2hl.c md4hl.c md5hl.c
MAN3+= md2.3 md4.3 md5.3
MLINKS+=md2.3 MD2Init.3 md2.3 MD2Update.3 md2.3 MD2Final.3
diff --git a/lib/libmytinfo/Makefile b/lib/libmytinfo/Makefile
index 700a8827cde96..8b7c637bb0843 100644
--- a/lib/libmytinfo/Makefile
+++ b/lib/libmytinfo/Makefile
@@ -1,14 +1,14 @@
# Makefile for libmytinfo
# Use 'make update_term_h' manually after changing internal
# mytinfo structures
-# $Id: Makefile,v 1.15 1998/09/02 15:22:11 bde Exp $
+# $Id: Makefile,v 1.14 1998/08/15 07:15:51 jb Exp $
LIB= mytinfo
SRCS= addstr.c binorder.c buildpath.c caplist.c capsort.c compar.c\
fillterm.c findcap.c findterm.c getother.c gettbin.c\
gettcap.c gettinfo.c tcapconv.c tcapvars.c termcap.c\
terminfo.c tgoto.c tiget.c tmatch.c tparm.c tputs.c tty.c version.c
-CLEANFILES=binorder.c caplist.c capsort.c mkbinorder mkcaplist \
+CLEANFILES+= binorder.c caplist.c capsort.c mkbinorder mkcaplist \
mkcapsort mktermhead mkversion readcaps.o version.c
CFLAGS+=-Wall -I${.CURDIR}
@@ -30,7 +30,7 @@ capsort.c: mkcapsort
./mkcapsort > capsort.c
.for f in caplist capsort compar findcap
-CLEANFILES+=cross-$f.o
+CLANFILES+= cross-$f.o
cross-$f.o: $f.c
${CC} ${CFLAGS} -c -o ${.TARGET} ${.ALLSRC}
.endfor
diff --git a/lib/libncurses/curs_addstr.3 b/lib/libncurses/curs_addstr.3
index 74ac9c754bcad..c55c2f57ede94 100644
--- a/lib/libncurses/curs_addstr.3
+++ b/lib/libncurses/curs_addstr.3
@@ -14,9 +14,9 @@
.br
\fBint waddnstr(WINDOW *win, char *str, int n);\fR
.br
-\fBint mvaddstr(int y, int x, char *str);\fR
+\fBint mvaddstr(y, int x, char *str);\fR
.br
-\fBint mvaddnstr(int y, int x, char *str, int n);\fR
+\fBint mvaddnstr(y, int x, char *str, int n);\fR
.br
\fBint mvwaddstr(WINDOW *win, int y, int x, char *str);\fR
.br
diff --git a/lib/libpam/Makefile b/lib/libpam/Makefile
deleted file mode 100644
index 8e99888bd7bf4..0000000000000
--- a/lib/libpam/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-# The modules must be built first, because they are built into the
-# static version of libpam.
-SUBDIR+= modules libpam
-
-.include <bsd.subdir.mk>
diff --git a/lib/libpam/Makefile.inc b/lib/libpam/Makefile.inc
deleted file mode 100644
index 2558a61faa10b..0000000000000
--- a/lib/libpam/Makefile.inc
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-SHLIB_MAJOR= 1
-SHLIB_MINOR= 0
diff --git a/lib/libpam/libpam/Makefile b/lib/libpam/libpam/Makefile
deleted file mode 100644
index 9b6cd7e2ec442..0000000000000
--- a/lib/libpam/libpam/Makefile
+++ /dev/null
@@ -1,112 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-PAMDIR= ${.CURDIR}/../../../contrib/libpam
-MODOBJDIR= ../modules
-
-.PATH: ${PAMDIR}/libpam ${PAMDIR}/libpam_misc ${PAMDIR}/doc/man
-
-LIB= pam
-CFLAGS+= -I${PAMDIR}/libpam/include -I.
-CFLAGS+= -DDEFAULT_MODULE_PATH=\"${SHLIBDIR}/\"
-NOPROFILE= true
-CLEANFILES+= security
-
-# Files from ${PAMDIR}/libpam:
-SRCS= pam_account.c pam_auth.c pam_data.c pam_delay.c \
- pam_dispatch.c pam_end.c pam_env.c pam_handlers.c \
- pam_item.c pam_log.c pam_misc.c pam_password.c \
- pam_second.c pam_session.c pam_start.c pam_static.c \
- pam_strerror.c
-HDRS1= _pam_compat.h _pam_macros.h _pam_types.h \
- pam_appl.h pam_malloc.h pam_modules.h
-MAN3+= pam_authenticate.3 pam_chauthtok.3 pam_fail_delay.3 \
- pam_open_session.3 pam_setcred.3 pam_start.3 \
- pam_strerror.3
-MLINKS+= pam_open_session.3 pam_close_session.3 \
- pam_start.3 pam_end.3
-MAN8+= pam.8
-MLINKS+= pam.8 pam.conf.5 pam.8 pam.d.5
-
-# Files from ${PAMDIR}/libpam_misc:
-SRCS+= help_env.c misc_conv.c xstrdup.c
-HDRS2= pam_misc.h
-
-# Files from ${.CURDIR}:
-SRCS+= pam_get_pass.c pam_prompt.c pam_std_option.c
-HDRS3= pam_mod_misc.h
-
-# Static PAM modules:
-STATIC_MODULES+= ${MODOBJDIR}/pam_cleartext_pass_ok/libpam_cleartext_pass_ok.a
-.if defined(MAKE_KERBEROS4)
-STATIC_MODULES+= ${MODOBJDIR}/pam_kerberosIV/libpam_kerberosIV.a
-.endif
-STATIC_MODULES+= ${MODOBJDIR}/pam_radius/libpam_radius.a
-STATIC_MODULES+= ${MODOBJDIR}/pam_skey/libpam_skey.a
-STATIC_MODULES+= ${MODOBJDIR}/pam_tacplus/libpam_tacplus.a
-STATIC_MODULES+= ${MODOBJDIR}/pam_unix/libpam_unix.a
-
-STATICOBJS+= pam_static_modules.o
-
-.if ${OBJFORMAT} == elf
-CLEANFILES+= setdef0.o _pam_static_modules.o setdef1.o \
- setdef0.c setdef1.c setdefs.h
-
-pam_static_modules.o: setdef0.o _pam_static_modules.o setdef1.o
- ${LD} -o ${.TARGET} -r ${.ALLSRC}
-
-setdef0.o: setdef0.c setdefs.h
-setdef1.o: setdef1.c setdefs.h
-
-setdef0.c setdef1.c setdefs.h: _pam_static_modules.o
- gensetdefs ${.ALLSRC}
-
-_pam_static_modules.o: ${STATIC_MODULES}
- ${LD} -o ${.TARGET} -r --whole-archive ${.ALLSRC}
-.else
-pam_static_modules.o: ${STATIC_MODULES}
- ${LD} -o ${.TARGET} -r -Bforcearchive ${.ALLSRC}
-.endif
-
-all: security
-
-beforedepend: security
-
-beforeinstall:
- cd ${PAMDIR}/libpam/include/security; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${HDRS1} ${DESTDIR}/usr/include/security
- cd ${PAMDIR}/libpam_misc; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${HDRS2} ${DESTDIR}/usr/include/security
- cd ${.CURDIR}; \
- ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${HDRS3} ${DESTDIR}/usr/include/security
-
-security:
- ln -sf ${PAMDIR}/libpam_misc security
-
-.include <bsd.lib.mk>
diff --git a/lib/libpam/libpam/pam_get_pass.c b/lib/libpam/libpam/pam_get_pass.c
deleted file mode 100644
index 78ef75abdb8f0..0000000000000
--- a/lib/libpam/libpam/pam_get_pass.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <security/pam_modules.h>
-#include "pam_mod_misc.h"
-
-static int pam_conv_pass(pam_handle_t *, const char *, int);
-
-static int
-pam_conv_pass(pam_handle_t *pamh, const char *prompt, int options)
-{
- int retval;
- const void *item;
- const struct pam_conv *conv;
- struct pam_message msg;
- const struct pam_message *msgs[1];
- struct pam_response *resp;
-
- if ((retval = pam_get_item(pamh, PAM_CONV, &item)) !=
- PAM_SUCCESS)
- return retval;
- conv = (const struct pam_conv *)item;
- msg.msg_style = options & PAM_OPT_ECHO_PASS ?
- PAM_PROMPT_ECHO_ON : PAM_PROMPT_ECHO_OFF;
- msg.msg = prompt;
- msgs[0] = &msg;
- if ((retval = conv->conv(1, msgs, &resp, conv->appdata_ptr)) !=
- PAM_SUCCESS)
- return retval;
- if ((retval = pam_set_item(pamh, PAM_AUTHTOK, resp[0].resp)) !=
- PAM_SUCCESS)
- return retval;
- memset(resp[0].resp, 0, strlen(resp[0].resp));
- free(resp[0].resp);
- free(resp);
- return PAM_SUCCESS;
-}
-
-int
-pam_get_pass(pam_handle_t *pamh, const char **passp, const char *prompt,
- int options)
-{
- int retval;
- const void *item = NULL;
-
- /*
- * Grab the already-entered password if we might want to use it.
- */
- if (options & (PAM_OPT_TRY_FIRST_PASS | PAM_OPT_USE_FIRST_PASS)) {
- if ((retval = pam_get_item(pamh, PAM_AUTHTOK, &item)) !=
- PAM_SUCCESS)
- return retval;
- }
-
- if (item == NULL) {
- /* The user hasn't entered a password yet. */
- if (options & PAM_OPT_USE_FIRST_PASS)
- return PAM_AUTH_ERR;
- /* Use the conversation function to get a password. */
- if ((retval = pam_conv_pass(pamh, prompt, options)) !=
- PAM_SUCCESS ||
- (retval = pam_get_item(pamh, PAM_AUTHTOK, &item)) !=
- PAM_SUCCESS)
- return retval;
- }
- *passp = (const char *)item;
- return PAM_SUCCESS;
-}
diff --git a/lib/libpam/libpam/pam_mod_misc.h b/lib/libpam/libpam/pam_mod_misc.h
deleted file mode 100644
index 06f474d293a22..0000000000000
--- a/lib/libpam/libpam/pam_mod_misc.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef PAM_MOD_MISC_H
-#define PAM_MOD_MISC_H
-
-#include <sys/cdefs.h>
-
-/* Options */
-#define PAM_OPT_DEBUG 0x01
-#define PAM_OPT_NO_WARN 0x02
-#define PAM_OPT_USE_FIRST_PASS 0x04
-#define PAM_OPT_TRY_FIRST_PASS 0x08
-#define PAM_OPT_USE_MAPPED_PASS 0x10
-#define PAM_OPT_ECHO_PASS 0x20
-
-__BEGIN_DECLS
-int pam_get_pass(pam_handle_t *, const char **, const char *, int);
-int pam_prompt(pam_handle_t *, int, const char *, char **);
-int pam_std_option(int *, const char *);
-__END_DECLS
-
-#endif
diff --git a/lib/libpam/libpam/pam_prompt.c b/lib/libpam/libpam/pam_prompt.c
deleted file mode 100644
index 220616ee2aaa4..0000000000000
--- a/lib/libpam/libpam/pam_prompt.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <security/pam_modules.h>
-#include "pam_mod_misc.h"
-
-/*
- * Do a simple conversation which can consist of a message and/or a user
- * response.
- */
-int
-pam_prompt(pam_handle_t *pamh, int style, const char *prompt, char **user_msg)
-{
- int retval;
- const void *item;
- const struct pam_conv *conv;
- struct pam_message msg;
- const struct pam_message *msgs[1];
- struct pam_response *resp;
-
- if ((retval = pam_get_item(pamh, PAM_CONV, &item)) !=
- PAM_SUCCESS)
- return retval;
- conv = (const struct pam_conv *)item;
- msg.msg_style = style;
- msg.msg = prompt != NULL ? prompt : "";
- msgs[0] = &msg;
- if ((retval = conv->conv(1, msgs, &resp, conv->appdata_ptr)) !=
- PAM_SUCCESS)
- return retval;
- if (user_msg != NULL)
- *user_msg = resp[0].resp;
- else if (resp[0].resp != NULL)
- free(resp[0].resp);
- free(resp);
- return PAM_SUCCESS;
-}
diff --git a/lib/libpam/libpam/pam_std_option.c b/lib/libpam/libpam/pam_std_option.c
deleted file mode 100644
index 0c00908b37f27..0000000000000
--- a/lib/libpam/libpam/pam_std_option.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <security/pam_modules.h>
-#include <string.h>
-#include "pam_mod_misc.h"
-
-/*
- * If the given name is a standard option, set the corresponding flag in
- * the options word and return 0. Else return -1.
- */
-int
-pam_std_option(int *options, const char *name)
-{
- struct opttab {
- const char *name;
- int value;
- };
- static struct opttab std_options[] = {
- { "debug", PAM_OPT_DEBUG },
- { "no_warn", PAM_OPT_NO_WARN },
- { "use_first_pass", PAM_OPT_USE_FIRST_PASS },
- { "try_first_pass", PAM_OPT_TRY_FIRST_PASS },
- { "use_mapped_pass", PAM_OPT_USE_MAPPED_PASS },
- { "echo_pass", PAM_OPT_ECHO_PASS },
- { NULL, 0 }
- };
- struct opttab *p;
-
- for (p = std_options; p->name != NULL; p++) {
- if (strcmp(name, p->name) == 0) {
- *options |= p->value;
- return 0;
- }
- }
- return -1;
-}
diff --git a/lib/libpam/modules/Makefile b/lib/libpam/modules/Makefile
deleted file mode 100644
index 5a3e3c120c3a0..0000000000000
--- a/lib/libpam/modules/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-SUBDIR+= pam_cleartext_pass_ok
-.if defined(MAKE_KERBEROS4)
-SUBDIR+= pam_kerberosIV
-.endif
-SUBDIR+= pam_radius
-SUBDIR+= pam_skey
-SUBDIR+= pam_tacplus
-SUBDIR+= pam_unix
-
-.include <bsd.subdir.mk>
diff --git a/lib/libpam/modules/pam_cleartext_pass_ok/Makefile b/lib/libpam/modules/pam_cleartext_pass_ok/Makefile
deleted file mode 100644
index 2336ea3e46156..0000000000000
--- a/lib/libpam/modules/pam_cleartext_pass_ok/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-PAMDIR= ${.CURDIR}/../../../../contrib/libpam
-
-LIB= pam_cleartext_pass_ok
-SHLIB_NAME= pam_cleartext_pass_ok.so
-SRCS= pam_cleartext_pass_ok.c
-CFLAGS+= -I${PAMDIR}/libpam/include
-CFLAGS+= -Wall
-DPADD+= ${LIBSKEY}
-LDADD+= -lskey -lgcc_pic
-INTERNALLIB= yes
-INTERNALSTATICLIB=yes
-
-.include <bsd.lib.mk>
diff --git a/lib/libpam/modules/pam_cleartext_pass_ok/pam_cleartext_pass_ok.c b/lib/libpam/modules/pam_cleartext_pass_ok/pam_cleartext_pass_ok.c
deleted file mode 100644
index 437225c304508..0000000000000
--- a/lib/libpam/modules/pam_cleartext_pass_ok/pam_cleartext_pass_ok.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <stdio.h>
-#include <skey.h>
-
-#define PAM_SM_AUTH
-#include <security/pam_modules.h>
-
-PAM_EXTERN int
-pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc,
- const char **argv)
-{
- int retval;
- const void *item;
- const char *user;
- const char *tty;
- const char *rhost;
-
- if ((retval = pam_get_user(pamh, &user, NULL)) != PAM_SUCCESS)
- return retval;
- if ((retval = pam_get_item(pamh, PAM_TTY, &item)) != PAM_SUCCESS)
- return retval;
- tty = (const char *)item;
- if ((retval = pam_get_item(pamh, PAM_RHOST, &item)) != PAM_SUCCESS)
- return retval;
- rhost = (const char *)item;
- /*
- * The cast in the next statement is necessary only because the
- * declaration of skeyaccess is wrong.
- */
- return skeyaccess((char *)user, tty, rhost, NULL) ?
- PAM_SUCCESS : PAM_AUTH_ERR;
-}
-
-PAM_EXTERN int
-pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv)
-{
- return PAM_SUCCESS;
-}
-
-PAM_MODULE_ENTRY("pam_cleartext_pass_ok");
diff --git a/lib/libpam/modules/pam_kerberosIV/Makefile b/lib/libpam/modules/pam_kerberosIV/Makefile
deleted file mode 100644
index 8ab1e6e349b47..0000000000000
--- a/lib/libpam/modules/pam_kerberosIV/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-PAMDIR= ${.CURDIR}/../../../../contrib/libpam
-
-LIB= pam_kerberosIV
-SHLIB_NAME= pam_kerberosIV.so
-SRCS= pam_kerberosIV.c klogin.c
-CFLAGS+= -Wall
-CFLAGS+= -I${PAMDIR}/libpam/include
-CFLAGS+= -I${.CURDIR}/../../libpam
-CFLAGS+= -DKERBEROS
-DPADD+= ${LIBKRB} ${LIBDES} ${LIBGCC_PIC}
-LDADD+= -lkrb -ldes -lgcc_pic
-INTERNALLIB= yes
-INTERNALSTATICLIB=yes
-
-.include <bsd.lib.mk>
diff --git a/lib/libpam/modules/pam_kerberosIV/klogin.c b/lib/libpam/modules/pam_kerberosIV/klogin.c
deleted file mode 100644
index d2c2d0691683d..0000000000000
--- a/lib/libpam/modules/pam_kerberosIV/klogin.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993, 1994
- * 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.
- */
-
-#ifndef lint
-static const char sccsid[] = "@(#)klogin.c 8.3 (Berkeley) 4/2/94";
-#endif /* not lint */
-
-#ifdef KERBEROS
-#include <sys/param.h>
-#include <sys/syslog.h>
-#include <des.h>
-#include <krb.h>
-
-#include <err.h>
-#include <netdb.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define INITIAL_TICKET "krbtgt"
-#define VERIFY_SERVICE "rcmd"
-
-extern int _pam_notickets;
-extern char *_pam_krbtkfile_env;
-extern int _pam_noticketsdontcomplain;
-
-/*
- * Attempt to log the user in using Kerberos authentication
- *
- * return 0 on success (will be logged in)
- * 1 if Kerberos failed (try local password in login)
- */
-int
-_pam_klogin(pw, instance, localhost, password)
- struct passwd *pw;
- char *instance, *localhost, *password;
-{
- int kerror;
- char realm[REALM_SZ], savehost[MAXHOSTNAMELEN];
- char tkt_location[MAXPATHLEN];
- char *krb_get_phost();
-
-#ifdef KLOGIN_PARANOID
- AUTH_DAT authdata;
- KTEXT_ST ticket;
- struct hostent *hp;
- unsigned long faddr;
-
- _pam_noticketsdontcomplain = 0; /* enable warning message */
-#endif
-
- /*
- * Root logins don't use Kerberos.
- * If we have a realm, try getting a ticket-granting ticket
- * and using it to authenticate. Otherwise, return
- * failure so that we can try the normal passwd file
- * for a password. If that's ok, log the user in
- * without issuing any tickets.
- */
- if (strcmp(pw->pw_name, "root") == 0 ||
- krb_get_lrealm(realm, 0) != KSUCCESS)
- return (1);
-
- _pam_noticketsdontcomplain = 0; /* enable warning message */
-
- /*
- * get TGT for local realm
- * tickets are stored in a file named TKT_ROOT plus uid
- * except for user.root tickets.
- */
-
- if (strcmp(instance, "root") != 0)
- (void)sprintf(tkt_location, "%s%d", TKT_ROOT, pw->pw_uid);
- else {
- (void)sprintf(tkt_location, "%s_root_%d", TKT_ROOT, pw->pw_uid);
- _pam_krbtkfile_env = tkt_location;
- }
- (void)krb_set_tkt_string(tkt_location);
-
- /*
- * Set real as well as effective ID to 0 for the moment,
- * to make the kerberos library do the right thing.
- */
- if (setuid(0) < 0) {
- warnx("setuid");
- return (1);
- }
- kerror = krb_get_pw_in_tkt(pw->pw_name, instance,
- realm, INITIAL_TICKET, realm, DEFAULT_TKT_LIFE, password);
-
- /*
- * If we got a TGT, get a local "rcmd" ticket and check it so as to
- * ensure that we are not talking to a bogus Kerberos server.
- *
- * There are 2 cases where we still allow a login:
- * 1: the VERIFY_SERVICE doesn't exist in the KDC
- * 2: local host has no srvtab, as (hopefully) indicated by a
- * return value of RD_AP_UNDEC from krb_rd_req().
- */
- if (kerror != INTK_OK) {
- if (kerror != INTK_BADPW && kerror != KDC_PR_UNKNOWN) {
- syslog(LOG_ERR, "Kerberos intkt error: %s",
- krb_err_txt[kerror]);
- dest_tkt();
- }
- return (1);
- }
-
- if (chown(TKT_FILE, pw->pw_uid, pw->pw_gid) < 0)
- syslog(LOG_ERR, "chown tkfile (%s): %m", TKT_FILE);
-
- (void)strncpy(savehost, krb_get_phost(localhost), sizeof(savehost));
- savehost[sizeof(savehost)-1] = NULL;
-
-#ifdef KLOGIN_PARANOID
- /*
- * if the "VERIFY_SERVICE" doesn't exist in the KDC for this host,
- * still allow login with tickets, but log the error condition.
- */
-
- kerror = krb_mk_req(&ticket, VERIFY_SERVICE, savehost, realm, 33);
- if (kerror == KDC_PR_UNKNOWN) {
- syslog(LOG_NOTICE,
- "warning: TGT not verified (%s); %s.%s not registered, or srvtab is wrong?",
- krb_err_txt[kerror], VERIFY_SERVICE, savehost);
- _pam_notickets = 0;
- return (0);
- }
-
- if (kerror != KSUCCESS) {
- warnx("unable to use TGT: (%s)", krb_err_txt[kerror]);
- syslog(LOG_NOTICE, "unable to use TGT: (%s)",
- krb_err_txt[kerror]);
- dest_tkt();
- return (1);
- }
-
- if (!(hp = gethostbyname(localhost))) {
- syslog(LOG_ERR, "couldn't get local host address");
- dest_tkt();
- return (1);
- }
-
- memmove((void *)&faddr, (void *)hp->h_addr, sizeof(faddr));
-
- kerror = krb_rd_req(&ticket, VERIFY_SERVICE, savehost, faddr,
- &authdata, "");
-
- if (kerror == KSUCCESS) {
- _pam_notickets = 0;
- return (0);
- }
-
- /* undecipherable: probably didn't have a srvtab on the local host */
- if (kerror == RD_AP_UNDEC) {
- syslog(LOG_NOTICE, "krb_rd_req: (%s)\n", krb_err_txt[kerror]);
- dest_tkt();
- return (1);
- }
- /* failed for some other reason */
- warnx("unable to verify %s ticket: (%s)", VERIFY_SERVICE,
- krb_err_txt[kerror]);
- syslog(LOG_NOTICE, "couldn't verify %s ticket: %s", VERIFY_SERVICE,
- krb_err_txt[kerror]);
- dest_tkt();
- return (1);
-#else
- _pam_notickets = 0;
- return (0);
-#endif
-}
-#endif
diff --git a/lib/libpam/modules/pam_kerberosIV/pam_kerberosIV.c b/lib/libpam/modules/pam_kerberosIV/pam_kerberosIV.c
deleted file mode 100644
index a4e3226749e65..0000000000000
--- a/lib/libpam/modules/pam_kerberosIV/pam_kerberosIV.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <pwd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define PAM_SM_AUTH
-#include <security/pam_modules.h>
-
-#include "pam_mod_misc.h"
-
-#define PASSWORD_PROMPT "Password:"
-
-extern int _pam_klogin(struct passwd *, char *, char *, char *);
-
-/* Globals used by _pam_klogin.c */
-int _pam_notickets = 1;
-int _pam_noticketsdontcomplain = 1;
-char *_pam_krbtkfile_env;
-
-PAM_EXTERN int
-pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc,
- const char **argv)
-{
- int retval;
- const char *user;
- char *principal;
- char *instance;
- const char *password;
- char localhost[MAXHOSTNAMELEN + 1];
- struct passwd *pwd;
- int options;
- int i;
-
- options = 0;
- for (i = 0; i < argc; i++)
- pam_std_option(&options, argv[i]);
- if ((retval = pam_get_user(pamh, &user, NULL)) != PAM_SUCCESS)
- return retval;
- if ((retval = pam_get_pass(pamh, &password, PASSWORD_PROMPT,
- options)) != PAM_SUCCESS)
- return retval;
- if (gethostname(localhost, sizeof localhost - 1) == -1)
- return PAM_SYSTEM_ERR;
- if ((principal = strdup(user)) == NULL)
- return PAM_BUF_ERR;
- if ((instance = strchr(principal, '.')) != NULL)
- *instance++ = '\0';
- else
- instance = "";
- if ((pwd = getpwnam(user)) != NULL &&
- _pam_klogin(pwd, instance, localhost, (char *)password) == 0) {
- if (!(flags & PAM_SILENT) && _pam_notickets &&
- !_pam_noticketsdontcomplain)
- pam_prompt(pamh, PAM_ERROR_MSG,
- "Warning: no Kerberos tickets issued", NULL);
- /*
- * XXX - I think the ticket file really isn't supposed to
- * be even created until pam_sm_setcred() is called.
- */
- if (_pam_krbtkfile_env != NULL)
- setenv("KRBTKFILE", _pam_krbtkfile_env, 1);
- retval = PAM_SUCCESS;
- } else
- retval = PAM_AUTH_ERR;
- /*
- * The PAM infrastructure will obliterate the cleartext
- * password before returning to the application.
- */
- free(principal);
- return retval;
-}
-
-PAM_EXTERN int
-pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv)
-{
- return PAM_SUCCESS;
-}
-
-PAM_MODULE_ENTRY("pam_kerberosIV");
diff --git a/lib/libpam/modules/pam_radius/Makefile b/lib/libpam/modules/pam_radius/Makefile
deleted file mode 100644
index 23f62ec9531e4..0000000000000
--- a/lib/libpam/modules/pam_radius/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-PAMDIR= ${.CURDIR}/../../../../contrib/libpam
-
-LIB= pam_radius
-SHLIB_NAME= pam_radius.so
-SRCS= pam_radius.c
-CFLAGS+= -Wall
-CFLAGS+= -I${PAMDIR}/libpam/include
-CFLAGS+= -I${.CURDIR}/../../libpam
-DPADD+= ${LIBRADIUS} ${LIBGCC_PIC}
-LDADD+= -lradius -lgcc_pic
-INTERNALLIB= yes
-INTERNALSTATICLIB=yes
-
-.include <bsd.lib.mk>
diff --git a/lib/libpam/modules/pam_radius/pam_radius.c b/lib/libpam/modules/pam_radius/pam_radius.c
deleted file mode 100644
index c04d8f2883154..0000000000000
--- a/lib/libpam/modules/pam_radius/pam_radius.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <pwd.h>
-#include <radlib.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <unistd.h>
-
-#define PAM_SM_AUTH
-#include <security/pam_modules.h>
-
-#include "pam_mod_misc.h"
-
-#define MAX_CHALLENGE_MSGS 10
-#define PASSWORD_PROMPT "RADIUS password:"
-
-/* Option names, including the "=" sign. */
-#define OPT_CONF "conf="
-#define OPT_TMPL "template_user="
-
-static int build_access_request(struct rad_handle *, const char *,
- const char *, const void *, size_t);
-static int do_accept(pam_handle_t *, struct rad_handle *);
-static int do_challenge(pam_handle_t *, struct rad_handle *,
- const char *);
-
-/*
- * Construct an access request, but don't send it. Returns 0 on success,
- * -1 on failure.
- */
-static int
-build_access_request(struct rad_handle *radh, const char *user,
- const char *pass, const void *state, size_t state_len)
-{
- char host[MAXHOSTNAMELEN];
-
- if (rad_create_request(radh, RAD_ACCESS_REQUEST) == -1) {
- syslog(LOG_CRIT, "rad_create_request: %s", rad_strerror(radh));
- return -1;
- }
- if ((user != NULL &&
- rad_put_string(radh, RAD_USER_NAME, user) == -1) ||
- (pass != NULL &&
- rad_put_string(radh, RAD_USER_PASSWORD, pass) == -1) ||
- (gethostname(host, sizeof host) != -1 &&
- rad_put_string(radh, RAD_NAS_IDENTIFIER, host) == -1)) {
- syslog(LOG_CRIT, "rad_put_string: %s", rad_strerror(radh));
- return -1;
- }
- if (state != NULL && rad_put_attr(radh, RAD_STATE, state,
- state_len) == -1) {
- syslog(LOG_CRIT, "rad_put_attr: %s", rad_strerror(radh));
- return -1;
- }
- if (rad_put_int(radh, RAD_SERVICE_TYPE, RAD_AUTHENTICATE_ONLY) == -1) {
- syslog(LOG_CRIT, "rad_put_int: %s", rad_strerror(radh));
- return -1;
- }
- return 0;
-}
-
-static int
-do_accept(pam_handle_t *pamh, struct rad_handle *radh)
-{
- int attrtype;
- const void *attrval;
- size_t attrlen;
- char *s;
-
- while ((attrtype = rad_get_attr(radh, &attrval, &attrlen)) > 0) {
- if (attrtype == RAD_USER_NAME) {
- s = rad_cvt_string(attrval, attrlen);
- if (s == NULL) {
- syslog(LOG_CRIT,
- "rad_cvt_string: out of memory");
- return -1;
- }
- pam_set_item(pamh, PAM_USER, s);
- free(s);
- }
- }
- if (attrtype == -1) {
- syslog(LOG_CRIT, "rad_get_attr: %s", rad_strerror(radh));
- return -1;
- }
- return 0;
-}
-
-static int
-do_challenge(pam_handle_t *pamh, struct rad_handle *radh, const char *user)
-{
- int retval;
- int attrtype;
- const void *attrval;
- size_t attrlen;
- const void *state;
- size_t statelen;
- struct pam_message msgs[MAX_CHALLENGE_MSGS];
- const struct pam_message *msg_ptrs[MAX_CHALLENGE_MSGS];
- struct pam_response *resp;
- int num_msgs;
- const void *item;
- const struct pam_conv *conv;
-
- state = NULL;
- statelen = 0;
- num_msgs = 0;
- while ((attrtype = rad_get_attr(radh, &attrval, &attrlen)) > 0) {
- switch (attrtype) {
-
- case RAD_STATE:
- state = attrval;
- statelen = attrlen;
- break;
-
- case RAD_REPLY_MESSAGE:
- if (num_msgs >= MAX_CHALLENGE_MSGS) {
- syslog(LOG_CRIT,
- "Too many RADIUS challenge messages");
- return PAM_SERVICE_ERR;
- }
- msgs[num_msgs].msg = rad_cvt_string(attrval, attrlen);
- if (msgs[num_msgs].msg == NULL) {
- syslog(LOG_CRIT,
- "rad_cvt_string: out of memory");
- return PAM_SERVICE_ERR;
- }
- msgs[num_msgs].msg_style = PAM_TEXT_INFO;
- msg_ptrs[num_msgs] = &msgs[num_msgs];
- num_msgs++;
- break;
- }
- }
- if (attrtype == -1) {
- syslog(LOG_CRIT, "rad_get_attr: %s", rad_strerror(radh));
- return PAM_SERVICE_ERR;
- }
- if (num_msgs == 0) {
- msgs[num_msgs].msg = strdup("(null RADIUS challenge): ");
- if (msgs[num_msgs].msg == NULL) {
- syslog(LOG_CRIT, "Out of memory");
- return PAM_SERVICE_ERR;
- }
- msgs[num_msgs].msg_style = PAM_TEXT_INFO;
- msg_ptrs[num_msgs] = &msgs[num_msgs];
- num_msgs++;
- }
- msgs[num_msgs-1].msg_style = PAM_PROMPT_ECHO_ON;
- if ((retval = pam_get_item(pamh, PAM_CONV, &item)) != PAM_SUCCESS) {
- syslog(LOG_CRIT, "do_challenge: cannot get PAM_CONV");
- return retval;
- }
- conv = (const struct pam_conv *)item;
- if ((retval = conv->conv(num_msgs, msg_ptrs, &resp,
- conv->appdata_ptr)) != PAM_SUCCESS)
- return retval;
- if (build_access_request(radh, user, resp[num_msgs-1].resp, state,
- statelen) == -1)
- return PAM_SERVICE_ERR;
- memset(resp[num_msgs-1].resp, 0, strlen(resp[num_msgs-1].resp));
- free(resp[num_msgs-1].resp);
- free(resp);
- while (num_msgs > 0)
- free((void *)msgs[--num_msgs].msg);
- return PAM_SUCCESS;
-}
-
-PAM_EXTERN int
-pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc,
- const char **argv)
-{
- struct rad_handle *radh;
- const char *user;
- const char *pass;
- const char *conf_file = NULL;
- const char *template_user = NULL;
- int options = 0;
- int retval;
- int i;
- int e;
-
- for (i = 0; i < argc; i++) {
- size_t len;
-
- pam_std_option(&options, argv[i]);
- if (strncmp(argv[i], OPT_CONF, (len = strlen(OPT_CONF))) == 0)
- conf_file = argv[i] + len;
- else if (strncmp(argv[i], OPT_TMPL,
- (len = strlen(OPT_TMPL))) == 0)
- template_user = argv[i] + len;
- }
- if ((retval = pam_get_user(pamh, &user, NULL)) != PAM_SUCCESS)
- return retval;
- if ((retval = pam_get_pass(pamh, &pass, PASSWORD_PROMPT,
- options)) != PAM_SUCCESS)
- return retval;
-
- if ((radh = rad_open()) == NULL) {
- syslog(LOG_CRIT, "rad_open failed");
- return PAM_SERVICE_ERR;
- }
- if (rad_config(radh, conf_file) == -1) {
- syslog(LOG_ALERT, "rad_config: %s", rad_strerror(radh));
- rad_close(radh);
- return PAM_SERVICE_ERR;
- }
- if (build_access_request(radh, user, pass, NULL, 0) == -1) {
- rad_close(radh);
- return PAM_SERVICE_ERR;
- }
- for ( ; ; ) {
- switch (rad_send_request(radh)) {
-
- case RAD_ACCESS_ACCEPT:
- e = do_accept(pamh, radh);
- rad_close(radh);
- if (e == -1)
- return PAM_SERVICE_ERR;
- if (template_user != NULL) {
- const void *item;
- const char *user;
-
- /*
- * If the given user name doesn't exist in
- * the local password database, change it
- * to the value given in the "template_user"
- * option.
- */
- retval = pam_get_item(pamh, PAM_USER, &item);
- if (retval != PAM_SUCCESS)
- return retval;
- user = (const char *)item;
- if (getpwnam(user) == NULL)
- pam_set_item(pamh, PAM_USER,
- template_user);
- }
- return PAM_SUCCESS;
-
- case RAD_ACCESS_REJECT:
- rad_close(radh);
- return PAM_AUTH_ERR;
-
- case RAD_ACCESS_CHALLENGE:
- if ((retval = do_challenge(pamh, radh, user)) !=
- PAM_SUCCESS) {
- rad_close(radh);
- return retval;
- }
- break;
-
- case -1:
- syslog(LOG_CRIT, "rad_send_request: %s",
- rad_strerror(radh));
- rad_close(radh);
- return PAM_AUTHINFO_UNAVAIL;
-
- default:
- syslog(LOG_CRIT,
- "rad_send_request: unexpected return value");
- rad_close(radh);
- return PAM_SERVICE_ERR;
- }
- }
-}
-
-PAM_EXTERN int
-pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv)
-{
- return PAM_SUCCESS;
-}
-
-PAM_MODULE_ENTRY("pam_radius");
diff --git a/lib/libpam/modules/pam_skey/Makefile b/lib/libpam/modules/pam_skey/Makefile
deleted file mode 100644
index bf6af9edd2b43..0000000000000
--- a/lib/libpam/modules/pam_skey/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-PAMDIR= ${.CURDIR}/../../../../contrib/libpam
-
-LIB= pam_skey
-SHLIB_NAME= pam_skey.so
-SRCS= pam_skey.c
-CFLAGS+= -Wall
-CFLAGS+= -I${PAMDIR}/libpam/include
-CFLAGS+= -I${.CURDIR}/../../libpam
-DPADD+= ${LIBSKEY} ${LIBGCC_PIC}
-LDADD+= -lskey -lgcc_pic
-INTERNALLIB= yes
-INTERNALSTATICLIB=yes
-
-.include <bsd.lib.mk>
diff --git a/lib/libpam/modules/pam_skey/pam_skey.c b/lib/libpam/modules/pam_skey/pam_skey.c
deleted file mode 100644
index 439591e24015c..0000000000000
--- a/lib/libpam/modules/pam_skey/pam_skey.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <syslog.h> /* XXX */
-
-#include <stdio.h>
-#include <string.h>
-#include <skey.h>
-
-#define PAM_SM_AUTH
-#include <security/pam_modules.h>
-
-#include "pam_mod_misc.h"
-
-PAM_EXTERN int
-pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc,
- const char **argv)
-{
- int retval;
- const char *user;
- const char *response;
- struct skey skey;
- char challenge[128];
- char prompt[128];
- char resp_buf[128];
- int options;
- int i;
- int e;
-
- options = 0;
- for (i = 0; i < argc; i++)
- pam_std_option(&options, argv[i]);
- /*
- * It doesn't make sense to use a password that has already been
- * typed in, since we haven't presented the challenge to the user
- * yet.
- */
- options &= ~(PAM_OPT_USE_FIRST_PASS | PAM_OPT_TRY_FIRST_PASS);
- if ((retval = pam_get_user(pamh, &user, NULL)) != PAM_SUCCESS)
- return retval;
- if (skeyinfo(&skey, user, challenge) != 0)
- return PAM_AUTH_ERR;
- snprintf(prompt, sizeof prompt, "%s\nPassword: ", challenge);
- if ((retval = pam_get_pass(pamh, &response, prompt, options)) !=
- PAM_SUCCESS)
- return retval;
- if (response[0] == '\0' && !(options & PAM_OPT_ECHO_PASS)) {
- options |= PAM_OPT_ECHO_PASS;
- snprintf(prompt, sizeof prompt,
- "%s\nPassword [echo on]: ", challenge);
- if ((retval = pam_get_pass(pamh, &response, prompt,
- options)) != PAM_SUCCESS)
- return retval;
- }
- /*
- * Skeyinfo closed the database file, so we have to call skeylookup
- * to open it again.
- */
- if ((e = skeylookup(&skey, user)) != 0) {
- if (e == -1) {
- syslog(LOG_ERR, "Error opening S/Key database");
- return PAM_SERVICE_ERR;
- } else
- return PAM_AUTH_ERR;
- }
- /* We have to copy the response, because skeyverify mucks with it. */
- snprintf(resp_buf, sizeof resp_buf, "%s", response);
- /*
- * Skeyverify is supposed to return -1 only if an error occurs.
- * But it returns -1 even if the response string isn't in the form
- * it expects. Thus we can't log an error and can only check for
- * success or lack thereof.
- */
- return skeyverify(&skey, resp_buf) == 0 ? PAM_SUCCESS : PAM_AUTH_ERR;
-}
-
-PAM_EXTERN int
-pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv)
-{
- return PAM_SUCCESS;
-}
-
-PAM_MODULE_ENTRY("pam_skey");
diff --git a/lib/libpam/modules/pam_tacplus/Makefile b/lib/libpam/modules/pam_tacplus/Makefile
deleted file mode 100644
index 6430ca8a66fe4..0000000000000
--- a/lib/libpam/modules/pam_tacplus/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-PAMDIR= ${.CURDIR}/../../../../contrib/libpam
-
-LIB= pam_tacplus
-SHLIB_NAME= pam_tacplus.so
-SRCS= pam_tacplus.c
-CFLAGS+= -Wall
-CFLAGS+= -I${PAMDIR}/libpam/include
-CFLAGS+= -I${.CURDIR}/../../libpam
-DPADD+= ${LIBTACPLUS} ${LIBGCC_PIC}
-LDADD+= -ltacplus -lgcc_pic
-INTERNALLIB= yes
-INTERNALSTATICLIB=yes
-
-.include <bsd.lib.mk>
diff --git a/lib/libpam/modules/pam_tacplus/pam_tacplus.c b/lib/libpam/modules/pam_tacplus/pam_tacplus.c
deleted file mode 100644
index 0820071529b4f..0000000000000
--- a/lib/libpam/modules/pam_tacplus/pam_tacplus.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-
-#include <pwd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <taclib.h>
-#include <unistd.h>
-
-#define PAM_SM_AUTH
-#include <security/pam_modules.h>
-
-#include "pam_mod_misc.h"
-
-/* Option names, including the "=" sign. */
-#define OPT_CONF "conf="
-#define OPT_TMPL "template_user="
-
-typedef int (*set_func)(struct tac_handle *, const char *);
-
-static int do_item(pam_handle_t *, struct tac_handle *, int,
- set_func, const char *);
-static char *get_msg(struct tac_handle *);
-static int set_msg(struct tac_handle *, const char *);
-
-static int
-do_item(pam_handle_t *pamh, struct tac_handle *tach, int item,
- set_func func, const char *funcname)
-{
- int retval;
- const void *value;
-
- if ((retval = pam_get_item(pamh, item, &value)) != PAM_SUCCESS)
- return retval;
- if (value != NULL && (*func)(tach, (const char *)value) == -1) {
- syslog(LOG_CRIT, "%s: %s", funcname, tac_strerror(tach));
- tac_close(tach);
- return PAM_SERVICE_ERR;
- }
- return PAM_SUCCESS;
-}
-
-static char *
-get_msg(struct tac_handle *tach)
-{
- char *msg;
-
- if ((msg = tac_get_msg(tach)) == NULL) {
- syslog(LOG_CRIT, "tac_get_msg: %s", tac_strerror(tach));
- tac_close(tach);
- return NULL;
- }
- return msg;
-}
-
-static int
-set_msg(struct tac_handle *tach, const char *msg)
-{
- if (tac_set_msg(tach, msg) == -1) {
- syslog(LOG_CRIT, "tac_set_msg: %s", tac_strerror(tach));
- tac_close(tach);
- return -1;
- }
- return 0;
-}
-
-PAM_EXTERN int
-pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc,
- const char **argv)
-{
- int retval;
- struct tac_handle *tach;
- const char *conf_file = NULL;
- const char *template_user = NULL;
- int options = 0;
- int i;
-
- for (i = 0; i < argc; i++) {
- size_t len;
-
- pam_std_option(&options, argv[i]);
- if (strncmp(argv[i], OPT_CONF, (len = strlen(OPT_CONF))) == 0)
- conf_file = argv[i] + len;
- else if (strncmp(argv[i], OPT_TMPL,
- (len = strlen(OPT_TMPL))) == 0)
- template_user = argv[i] + len;
- }
-
- if ((tach = tac_open()) == NULL) {
- syslog(LOG_CRIT, "tac_open failed");
- return PAM_SERVICE_ERR;
- }
- if (tac_config(tach, conf_file) == -1) {
- syslog(LOG_ALERT, "tac_config: %s", tac_strerror(tach));
- tac_close(tach);
- return PAM_SERVICE_ERR;
- }
- if (tac_create_authen(tach, TAC_AUTHEN_LOGIN, TAC_AUTHEN_TYPE_ASCII,
- TAC_AUTHEN_SVC_LOGIN) == -1) {
- syslog(LOG_CRIT, "tac_create_authen: %s", tac_strerror(tach));
- tac_close(tach);
- return PAM_SERVICE_ERR;
- }
- if ((retval = do_item(pamh, tach, PAM_USER,
- tac_set_user, "tac_set_user")) != PAM_SUCCESS)
- return retval;
- if ((retval = do_item(pamh, tach, PAM_TTY,
- tac_set_port, "tac_set_port")) != PAM_SUCCESS)
- return retval;
- if ((retval = do_item(pamh, tach, PAM_RHOST,
- tac_set_rem_addr, "tac_set_rem_addr")) != PAM_SUCCESS)
- return retval;
- for ( ; ; ) {
- char *srvr_msg;
- size_t msg_len;
- const char *user_msg;
- char *data_msg;
- int sflags;
- int status;
- int echo;
-
- if ((sflags = tac_send_authen(tach)) == -1) {
- syslog(LOG_CRIT, "tac_send_authen: %s",
- tac_strerror(tach));
- tac_close(tach);
- return PAM_AUTHINFO_UNAVAIL;
- }
- status = TAC_AUTHEN_STATUS(sflags);
- echo = TAC_AUTHEN_NOECHO(sflags) ? 0 : PAM_OPT_ECHO_PASS;
- switch (status) {
-
- case TAC_AUTHEN_STATUS_PASS:
- tac_close(tach);
- if (template_user != NULL) {
- const void *item;
- const char *user;
-
- /*
- * If the given user name doesn't exist in
- * the local password database, change it
- * to the value given in the "template_user"
- * option.
- */
- retval = pam_get_item(pamh, PAM_USER, &item);
- if (retval != PAM_SUCCESS)
- return retval;
- user = (const char *)item;
- if (getpwnam(user) == NULL)
- pam_set_item(pamh, PAM_USER,
- template_user);
- }
- return PAM_SUCCESS;
-
- case TAC_AUTHEN_STATUS_FAIL:
- tac_close(tach);
- return PAM_AUTH_ERR;
-
- case TAC_AUTHEN_STATUS_GETUSER:
- case TAC_AUTHEN_STATUS_GETPASS:
- if ((srvr_msg = get_msg(tach)) == NULL)
- return PAM_SERVICE_ERR;
- if (status == TAC_AUTHEN_STATUS_GETUSER)
- retval = pam_get_user(pamh, &user_msg,
- srvr_msg[0] != '\0' ? srvr_msg : NULL);
- else if (status == TAC_AUTHEN_STATUS_GETPASS)
- retval = pam_get_pass(pamh, &user_msg,
- srvr_msg[0] != '\0' ? srvr_msg :
- "Password:", options | echo);
- free(srvr_msg);
- if (retval != PAM_SUCCESS) {
- /* XXX - send a TACACS+ abort packet */
- tac_close(tach);
- return retval;
- }
- if (set_msg(tach, user_msg) == -1)
- return PAM_SERVICE_ERR;
- break;
-
- case TAC_AUTHEN_STATUS_GETDATA:
- if ((srvr_msg = get_msg(tach)) == NULL)
- return PAM_SERVICE_ERR;
- retval = pam_prompt(pamh,
- (options|echo) & PAM_OPT_ECHO_PASS ?
- PAM_PROMPT_ECHO_ON : PAM_PROMPT_ECHO_OFF,
- srvr_msg[0] != '\0' ? srvr_msg : "Data:",
- &data_msg);
- free(srvr_msg);
- if (retval != PAM_SUCCESS) {
- /* XXX - send a TACACS+ abort packet */
- tac_close(tach);
- return retval;
- }
- retval = set_msg(tach, data_msg);
- memset(data_msg, 0, strlen(data_msg));
- free(data_msg);
- if (retval == -1)
- return PAM_SERVICE_ERR;
- break;
-
- case TAC_AUTHEN_STATUS_ERROR:
- srvr_msg = (char *)tac_get_data(tach, &msg_len);
- if (srvr_msg != NULL && msg_len != 0) {
- syslog(LOG_CRIT, "tac_send_authen:"
- " server detected error: %s", srvr_msg);
- free(srvr_msg);
- } else
- syslog(LOG_CRIT,
- "tac_send_authen: server detected error");
- tac_close(tach);
- return PAM_AUTHINFO_UNAVAIL;
- break;
-
- case TAC_AUTHEN_STATUS_RESTART:
- case TAC_AUTHEN_STATUS_FOLLOW:
- default:
- syslog(LOG_CRIT,
- "tac_send_authen: unexpected status %#x", status);
- tac_close(tach);
- return PAM_AUTHINFO_UNAVAIL;
- }
- }
-}
-
-PAM_EXTERN int
-pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv)
-{
- return PAM_SUCCESS;
-}
-
-PAM_MODULE_ENTRY("pam_tacplus");
diff --git a/lib/libpam/modules/pam_unix/Makefile b/lib/libpam/modules/pam_unix/Makefile
deleted file mode 100644
index d3bb68921de7b..0000000000000
--- a/lib/libpam/modules/pam_unix/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-PAMDIR= ${.CURDIR}/../../../../contrib/libpam
-
-LIB= pam_unix
-SHLIB_NAME= pam_unix.so
-SRCS= pam_unix.c
-CFLAGS+= -Wall
-CFLAGS+= -I${PAMDIR}/libpam/include
-CFLAGS+= -I${.CURDIR}/../../libpam
-DPADD+= ${LIBGCC_PIC}
-LDADD+= -lgcc_pic
-INTERNALLIB= yes
-INTERNALSTATICLIB=yes
-
-.include <bsd.lib.mk>
diff --git a/lib/libpam/modules/pam_unix/pam_unix.c b/lib/libpam/modules/pam_unix/pam_unix.c
deleted file mode 100644
index f47ea555a2711..0000000000000
--- a/lib/libpam/modules/pam_unix/pam_unix.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <pwd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define PAM_SM_AUTH
-#include <security/pam_modules.h>
-
-#include "pam_mod_misc.h"
-
-#define PASSWORD_PROMPT "Password:"
-
-PAM_EXTERN int
-pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc,
- const char **argv)
-{
- int retval;
- const char *user;
- const char *password;
- struct passwd *pwd;
- char *encrypted;
- int options;
- int i;
-
- options = 0;
- for (i = 0; i < argc; i++)
- pam_std_option(&options, argv[i]);
- if ((retval = pam_get_user(pamh, &user, NULL)) != PAM_SUCCESS)
- return retval;
- if ((retval = pam_get_pass(pamh, &password, PASSWORD_PROMPT,
- options)) != PAM_SUCCESS)
- return retval;
- if ((pwd = getpwnam(user)) != NULL) {
- encrypted = crypt(password, pwd->pw_passwd);
- if (password[0] == '\0' && pwd->pw_passwd != '\0')
- encrypted = ":";
-
- retval = strcmp(encrypted, pwd->pw_passwd) == 0 ?
- PAM_SUCCESS : PAM_AUTH_ERR;
- } else {
- /*
- * User unknown. Encrypt anyway so that it takes the
- * same amount of time.
- */
- crypt(password, "xx");
- retval = PAM_AUTH_ERR;
- }
- /*
- * The PAM infrastructure will obliterate the cleartext
- * password before returning to the application.
- */
- return retval;
-}
-
-PAM_EXTERN int
-pam_sm_setcred(pam_handle_t *pamh, int flags, int argc, const char **argv)
-{
- return PAM_SUCCESS;
-}
-
-PAM_MODULE_ENTRY("pam_unix");
diff --git a/lib/libpcap/Makefile b/lib/libpcap/Makefile
index 36e565087816a..81f32068bf820 100644
--- a/lib/libpcap/Makefile
+++ b/lib/libpcap/Makefile
@@ -1,5 +1,5 @@
# Makefile for libpcap
-# $Id: Makefile,v 1.21 1998/09/15 19:34:01 fenner Exp $
+# $Id: Makefile,v 1.20 1998/08/18 10:29:37 ache Exp $
LIB= pcap
SRCS= grammar.y tokdefs.h pcap-bpf.c \
@@ -7,7 +7,7 @@ SRCS= grammar.y tokdefs.h pcap-bpf.c \
etherent.c savefile.c bpf_filter.c bpf_image.c \
scanner.l version.c
MAN3= pcap.3
-CLEANFILES=tokdefs.h version.c
+CLEANFILES+= tokdefs.h
DEFS= -DHAVE_SYS_IOCCOM_H=1 -DHAVE_SYS_SOCKIO_H=1 \
-DHAVE_ETHER_HOSTTON=1 -DHAVE_STRERROR=1 \
diff --git a/lib/libradius/Makefile b/lib/libradius/Makefile
deleted file mode 100644
index acc3fa3e3220a..0000000000000
--- a/lib/libradius/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-LIB= radius
-SRCS= radlib.c
-CFLAGS+= -Wall
-DPADD+= ${LIBMD}
-LDADD+= -lmd
-SHLIB_MAJOR= 1
-SHLIB_MINOR= 0
-MAN3+= libradius.3
-MAN5+= radius.conf.5
-
-beforeinstall:
- ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${.CURDIR}/radlib.h ${DESTDIR}/usr/include
-
-.include <bsd.lib.mk>
diff --git a/lib/libradius/libradius.3 b/lib/libradius/libradius.3
deleted file mode 100644
index 25ccdc09d8168..0000000000000
--- a/lib/libradius/libradius.3
+++ /dev/null
@@ -1,317 +0,0 @@
-.\" Copyright 1998 Juniper Networks, Inc.
-.\" 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 29, 1998
-.Dt LIBRADIUS 3
-.Os FreeBSD
-.Sh NAME
-.Nm libradius
-.Nd RADIUS client library
-.Sh SYNOPSIS
-.Fd #include <radlib.h>
-.Ft int
-.Fn rad_add_server "struct rad_handle *h" "const char *host" "int port" "const char *secret" "int timeout" "int max_tries"
-.Ft void
-.Fn rad_close "struct rad_handle *h"
-.Ft int
-.Fn rad_config "struct rad_handle *h" "const char *file"
-.Ft int
-.Fn rad_create_request "struct rad_handle *h" "int code"
-.Ft struct in_addr
-.Fn rad_cvt_addr "const void *data"
-.Ft u_int32_t
-.Fn rad_cvt_int "const void *data"
-.Ft char *
-.Fn rad_cvt_string "const void *data" "size_t len"
-.Ft int
-.Fn rad_get_attr "struct rad_handle *h" "const void **data" "size_t *len"
-.Ft struct rad_handle *
-.Fn rad_open "void"
-.Ft int
-.Fn rad_put_addr "struct rad_handle *h" "int type" "struct in_addr addr"
-.Ft int
-.Fn rad_put_attr "struct rad_handle *h" "int type" "const void *data" "size_t len"
-.Ft int
-.Fn rad_put_int "struct rad_handle *h" "int type" "u_int32_t value"
-.Ft int
-.Fn rad_put_string "struct rad_handle *h" "int type" "const char *str"
-.Ft int
-.Fn rad_send_request "struct rad_handle *h"
-.Ft const char *
-.Fn rad_strerror "struct rad_handle *h"
-.Sh DESCRIPTION
-The
-.Nm
-library implements the client side of the Remote Authentication
-Dial In User Service (RADIUS). RADIUS, defined in RFC 2138, allows
-clients to perform authentication by means of network requests to
-remote authentication servers.
-.Sh INITIALIZATION
-To use the library, an application must first call
-.Fn rad_open
-to obtain a
-.Va struct rad_handle * ,
-which provides the context for subsequent operations.
-Calls to
-.Fn rad_open
-always succeed unless insufficient virtual memory is available. If
-the necessary memory cannot be allocated,
-.Fn rad_open
-returns
-.Dv NULL .
-.Pp
-Before issuing any RADIUS requests, the library must be made aware
-of the servers it can contact. The easiest way to configure the
-library is to call
-.Fn rad_config .
-.Fn rad_config
-causes the library to read a configuration file whose format is
-described in
-.Xr radius.conf 5 .
-The pathname of the configuration file is passed as the
-.Va file
-argument to
-.Fn rad_config .
-This argument may also be given as
-.Dv NULL ,
-in which case the standard configuration file
-.Pa /etc/radius.conf
-is used.
-.Fn rad_config
-returns 0 on success, or -1 if an error occurs.
-.Pp
-The library can also be configured programmatically by calls to
-.Fn rad_add_server .
-The
-.Va host
-parameter specifies the server host, either as a fully qualified
-domain name or as a dotted-quad IP address in text form.
-The
-.Va port
-parameter specifies the UDP port to contact on the server. If
-.Va port
-is given as 0, the library looks up the
-.Ql radius/udp
-service in the network services database, and uses the port found
-there. If no entry is found, the library uses port 1812, the standard
-RADIUS port. The shared secret for the server host is passed to the
-.Va secret
-parameter.
-It may be any NUL-terminated string of bytes. The RADIUS protocol
-ignores all but the leading 128 bytes of the shared secret.
-The timeout for receiving replies from the server is passed to the
-.Va timeout
-parameter, in units of seconds. The maximum number of repeated
-requests to make before giving up is passed into the
-.Va max_tries
-parameter.
-.Fn rad_add_server
-returns 0 on success, or -1 if an error occurs.
-.Pp
-.Fn rad_add_server
-may be called multiple times, and it may be used together with
-.Fn rad_config .
-At most 10 servers may be specified.
-When multiple servers are given, they are tried in round-robin
-fashion until a valid response is received, or until each server's
-.Va max_tries
-limit has been reached.
-.Sh CREATING A RADIUS REQUEST
-A RADIUS request consists of a code specifying the kind of request,
-and zero or more attributes which provide additional information. To
-begin constructing a new request, call
-.Fn rad_create_request .
-In addition to the usual
-.Va struct rad_handle * ,
-this function takes a
-.Va code
-parameter which specifies the type of the request. Most often this
-will be
-.Dv RAD_ACCESS_REQUEST .
-.Fn rad_create_request
-returns 0 on success, or -1 on if an error occurs.
-.Pp
-After the request has been created with
-.Fn rad_create request ,
-attributes can be attached to it. This is done through calls to
-.Fn rad_put_addr ,
-.Fn rad_put_int ,
-and
-.Fn rad_put_string .
-Each accepts a
-.Va type
-parameter identifying the attribute, and a value which may be
-an Internet address, an integer, or a NUL-terminated string,
-respectively.
-.Pp
-The library also provides a function
-.Fn rad_put_attr
-which can be used to supply a raw, uninterpreted attribute. The
-.Va data
-argument points to an array of bytes, and the
-.Va len
-argument specifies its length.
-.Pp
-The
-.Fn rad_put_X
-functions return 0 on success, or -1 if an error occurs.
-.Sh SENDING THE REQUEST AND RECEIVING THE RESPONSE
-After the RADIUS request has been constructed, it is sent by means
-of
-.Fn rad_send_request .
-This function sends the request and waits for a valid reply,
-retrying the defined servers in round-robin fashion as necessary.
-If a valid response is received,
-.Fn rad_send_request
-returns the RADIUS code which specifies the type of the response.
-This will typically be
-.Dv RAD_ACCESS_ACCEPT ,
-.Dv RAD_ACCESS_REJECT ,
-or
-.Dv RAD_ACCESS_CHALLENGE .
-If no valid response is received,
-.Fn rad_send_request
-returns -1.
-.Pp
-Like RADIUS requests, each response may contain zero or more
-attributes. After a response has been received successfully by
-.Fn rad_send_request ,
-its attributes can be extracted one by one using
-.Fn rad_get_attr .
-Each time
-.Fn rad_get_attr
-is called, it gets the next attribute from the current response, and
-stores a pointer to the data and the length of the data via the
-reference parameters
-.Va data
-and
-.Va len ,
-respectively. Note that the data resides in the response itself,
-and must not be modified.
-A successful call to
-.Fn rad_get_attr
-returns the RADIUS attribute type.
-If no more attributes remain in the current response,
-.Fn rad_get_attr
-returns 0.
-If an error such as a malformed attribute is detected, -1 is
-returned.
-.Pp
-The common types of attributes can be decoded using
-.Fn rad_cvt_addr ,
-.Fn rad_cvt_int ,
-and
-.Fn rad_cvt_string .
-These functions accept a pointer to the attribute data, which should
-have been obtained using
-.Fn rad_get_attr .
-In the case of
-.Fn rad_cvt_string ,
-the length
-.Va len
-must also be given. These functions interpret the attribute as an
-Internet address, an integer, or a string, respectively, and return
-its value.
-.Fn rad_cvt_string
-returns its value as a NUL-terminated string in dynamically
-allocated memory. The application should free the string using
-.Xr free 3
-when it is no longer needed.
-.Pp
-If insufficient virtual memory is available,
-.Fn rad_cvt_string
-returns
-.Dv NULL .
-.Fn rad_cvt_addr
-and
-.Fn rad_cvt_int
-cannot fail.
-.Sh OBTAINING ERROR MESSAGES
-Those functions which accept a
-.Va struct rad_handle *
-argument record an error message if they fail. The error message
-can be retrieved by calling
-.Fn rad_strerror .
-The message text is overwritten on each new error for the given
-.Va struct rad_handle * .
-Thus the message must be copied if it is to be preserved through
-subsequent library calls using the same handle.
-.Sh CLEANUP
-To free the resources used by the RADIUS library, call
-.Fn rad_close .
-.Sh RETURN VALUES
-The following functions return a non-negative value on success. If
-they detect an error, they return -1 and record an error message
-which can be retrieved using
-.Fn rad_strerror .
-.Pp
-.Bl -item -offset indent -compact
-.It
-.Fn rad_add_server
-.It
-.Fn rad_config
-.It
-.Fn rad_create_request
-.It
-.Fn rad_get_attr
-.It
-.Fn rad_put_addr
-.It
-.Fn rad_put_attr
-.It
-.Fn rad_put_int
-.It
-.Fn rad_put_string
-.It
-.Fn rad_send_request
-.El
-.Pp
-The following functions return a
-.No non- Ns Dv NULL
-pointer on success. If they are unable to allocate sufficient
-virtual memory, they return
-.Dv NULL ,
-without recording an error message.
-.Pp
-.Bl -item -offset indent -compact
-.It
-.Fn rad_cvt_string
-.It
-.Fn rad_open
-.El
-.Sh FILES
-.Pa /etc/radius.conf
-.Sh SEE ALSO
-.Xr radius.conf 5
-.Rs
-.%A C. Rigney, et al
-.%T Remote Authentication Dial In User Service (RADIUS)
-.%O RFC 2138
-.Re
-.Sh AUTHORS
-This software was written by
-.An John Polstra ,
-and donated to the FreeBSD project by Juniper Networks, Inc.
diff --git a/lib/libradius/radius.conf.5 b/lib/libradius/radius.conf.5
deleted file mode 100644
index 2cd72c2952ba0..0000000000000
--- a/lib/libradius/radius.conf.5
+++ /dev/null
@@ -1,123 +0,0 @@
-.\" Copyright 1998 Juniper Networks, Inc.
-.\" 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 29, 1998
-.Dt RADIUS.CONF 5
-.Os FreeBSD
-.Sh NAME
-.Nm radius.conf
-.Nd RADIUS client configuration file
-.Sh SYNOPSIS
-.Pa /etc/radius.conf
-.Sh DESCRIPTION
-.Nm
-contains the information necessary to configure the RADIUS client
-library. It is parsed by
-.Xr rad_config 3 .
-The file contains one or more lines of text, each describing a
-single RADIUS server which will be used by the library. Leading
-white space is ignored, as are empty lines and lines containing
-only comments.
-.Pp
-A RADIUS server is described by two to four fields on a line. The
-fields are separated by white space. The
-.Ql #
-character at the beginning of a field begins a comment, which extends
-to the end of the line. A field may be enclosed in double quotes,
-in which case it may contain white space and/or begin with the
-.Ql #
-character. Within a quoted string, the double quote character can
-be represented by
-.Ql \e\&" ,
-and the backslash can be represented by
-.Ql \e\e .
-No other escape sequences are supported.
-.Pp
-The first field specifies
-the server host, either as a fully qualified domain name or as a
-dotted-quad IP address. The host may optionally be followed by a
-.Ql \&:
-and a numeric port number, without intervening white space. If the
-port specification is omitted, it defaults to the
-.Ql radius
-service in the
-.Pa /etc/services
-file, or to the standard RADIUS port 1812 if there is no such entry in
-.Pa /etc/services .
-.Pp
-The second field contains the shared secret, which should be known
-only to the client and server hosts. It is an arbitrary string of
-characters, though it must be enclosed in double quotes if it
-contains white space. The shared secret may be
-any length, but the RADIUS protocol uses only the first 128
-characters. N.B., some popular RADIUS servers have bugs which
-prevent them from working properly with secrets longer than 16
-characters.
-.Pp
-The third field contains a decimal integer specifying the timeout in
-seconds for receiving a valid reply from the server. If this field
-is omitted, it defaults to 3 seconds.
-.Pp
-The fourth field contains a decimal integer specifying the maximum
-number of attempts that will be made to authenticate with the server
-before giving up. If omitted, it defaults to 3 attempts. Note,
-this is the total number of attempts and not the number of retries.
-.Pp
-Up to 10 RADIUS servers may be specified. The servers are tried in
-round-robin fashion, until a valid response is received or the
-maximum number of tries has been reached for all servers.
-.Pp
-The standard location for this file is
-.Pa /etc/radius.conf .
-But an alternate pathname may be specified in the call to
-.Xr rad_config 3 .
-Since the file contains sensitive information in the form of the
-shared secrets, it should not be readable except by root.
-.Sh FILES
-.Pa /etc/radius.conf
-.Sh EXAMPLES
-.Bd -literal
-# A simple entry using all the defaults:
-radius1.domain.com OurLittleSecret
-
-# A server still using the obsolete RADIUS port, with increased
-# timeout and maximum tries:
-auth.domain.com:1645 "I can't see you, but I know you're there" 5 4
-
-# A server specified by its IP address:
-192.168.27.81 $X*#..38947ax-+=
-.Ed
-.Sh SEE ALSO
-.Xr libradius 3
-.Rs
-.%A C. Rigney, et al
-.%T Remote Authentication Dial In User Service (RADIUS)
-.%O RFC 2138
-.Re
-.Sh AUTHORS
-This documentation was written by
-.An John Polstra ,
-and donated to the FreeBSD project by Juniper Networks, Inc.
diff --git a/lib/libradius/radlib.c b/lib/libradius/radlib.c
deleted file mode 100644
index 2825c3dae7866..0000000000000
--- a/lib/libradius/radlib.c
+++ /dev/null
@@ -1,737 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <errno.h>
-#include <md5.h>
-#include <netdb.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "radlib_private.h"
-
-static void clear_password(struct rad_handle *);
-static void generr(struct rad_handle *, const char *, ...)
- __printflike(2, 3);
-static void insert_scrambled_password(struct rad_handle *, int);
-static int is_valid_response(struct rad_handle *, int,
- const struct sockaddr_in *);
-static int put_password_attr(struct rad_handle *, int,
- const void *, size_t);
-static int put_raw_attr(struct rad_handle *, int,
- const void *, size_t);
-static int split(char *, char *[], int, char *, size_t);
-
-static void
-clear_password(struct rad_handle *h)
-{
- if (h->pass_len != 0) {
- memset(h->pass, 0, h->pass_len);
- h->pass_len = 0;
- h->pass_pos = 0;
- }
-}
-
-static void
-generr(struct rad_handle *h, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vsnprintf(h->errmsg, ERRSIZE, format, ap);
- va_end(ap);
-}
-
-static void
-insert_scrambled_password(struct rad_handle *h, int srv)
-{
- MD5_CTX ctx;
- unsigned char md5[16];
- const struct rad_server *srvp;
- int padded_len;
- int pos;
-
- srvp = &h->servers[srv];
- padded_len = h->pass_len == 0 ? 16 : (h->pass_len+15) & ~0xf;
-
- memcpy(md5, &h->request[POS_AUTH], LEN_AUTH);
- for (pos = 0; pos < padded_len; pos += 16) {
- int i;
-
- /* Calculate the new scrambler */
- MD5Init(&ctx);
- MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
- MD5Update(&ctx, md5, 16);
- MD5Final(md5, &ctx);
-
- /*
- * Mix in the current chunk of the password, and copy
- * the result into the right place in the request. Also
- * modify the scrambler in place, since we will use this
- * in calculating the scrambler for next time.
- */
- for (i = 0; i < 16; i++)
- h->request[h->pass_pos + pos + i] =
- md5[i] ^= h->pass[pos + i];
- }
-}
-
-/*
- * Return true if the current response is valid for a request to the
- * specified server.
- */
-static int
-is_valid_response(struct rad_handle *h, int srv,
- const struct sockaddr_in *from)
-{
- MD5_CTX ctx;
- unsigned char md5[16];
- const struct rad_server *srvp;
- int len;
-
- srvp = &h->servers[srv];
-
- /* Check the source address */
- if (from->sin_family != srvp->addr.sin_family ||
- from->sin_addr.s_addr != srvp->addr.sin_addr.s_addr ||
- from->sin_port != srvp->addr.sin_port)
- return 0;
-
- /* Check the message length */
- if (h->resp_len < POS_ATTRS)
- return 0;
- len = h->response[POS_LENGTH] << 8 | h->response[POS_LENGTH+1];
- if (len > h->resp_len)
- return 0;
-
- /* Check the response authenticator */
- MD5Init(&ctx);
- MD5Update(&ctx, &h->response[POS_CODE], POS_AUTH - POS_CODE);
- MD5Update(&ctx, &h->request[POS_AUTH], LEN_AUTH);
- MD5Update(&ctx, &h->response[POS_ATTRS], len - POS_ATTRS);
- MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
- MD5Final(md5, &ctx);
- if (memcmp(&h->response[POS_AUTH], md5, sizeof md5) != 0)
- return 0;
-
- return 1;
-}
-
-static int
-put_password_attr(struct rad_handle *h, int type, const void *value, size_t len)
-{
- int padded_len;
- int pad_len;
-
- if (h->pass_pos != 0) {
- generr(h, "Multiple User-Password attributes specified");
- return -1;
- }
- if (len > PASSSIZE)
- len = PASSSIZE;
- padded_len = len == 0 ? 16 : (len+15) & ~0xf;
- pad_len = padded_len - len;
-
- /*
- * Put in a place-holder attribute containing all zeros, and
- * remember where it is so we can fill it in later.
- */
- clear_password(h);
- put_raw_attr(h, type, h->pass, padded_len);
- h->pass_pos = h->req_len - padded_len;
-
- /* Save the cleartext password, padded as necessary */
- memcpy(h->pass, value, len);
- h->pass_len = len;
- memset(h->pass + len, 0, pad_len);
- return 0;
-}
-
-static int
-put_raw_attr(struct rad_handle *h, int type, const void *value, size_t len)
-{
- if (len > 253) {
- generr(h, "Attribute too long");
- return -1;
- }
- if (h->req_len + 2 + len > MSGSIZE) {
- generr(h, "Maximum message length exceeded");
- return -1;
- }
- h->request[h->req_len++] = type;
- h->request[h->req_len++] = len + 2;
- memcpy(&h->request[h->req_len], value, len);
- h->req_len += len;
- return 0;
-}
-
-int
-rad_add_server(struct rad_handle *h, const char *host, int port,
- const char *secret, int timeout, int tries)
-{
- struct rad_server *srvp;
-
- if (h->num_servers >= MAXSERVERS) {
- generr(h, "Too many RADIUS servers specified");
- return -1;
- }
- srvp = &h->servers[h->num_servers];
-
- memset(&srvp->addr, 0, sizeof srvp->addr);
- srvp->addr.sin_len = sizeof srvp->addr;
- srvp->addr.sin_family = AF_INET;
- if (!inet_aton(host, &srvp->addr.sin_addr)) {
- struct hostent *hent;
-
- if ((hent = gethostbyname(host)) == NULL) {
- generr(h, "%s: host not found", host);
- return -1;
- }
- memcpy(&srvp->addr.sin_addr, hent->h_addr,
- sizeof srvp->addr.sin_addr);
- }
- if (port != 0)
- srvp->addr.sin_port = htons(port);
- else {
- struct servent *sent;
-
- srvp->addr.sin_port =
- (sent = getservbyname("radius", "udp")) != NULL ?
- sent->s_port : htons(RADIUS_PORT);
- }
- if ((srvp->secret = strdup(secret)) == NULL) {
- generr(h, "Out of memory");
- return -1;
- }
- srvp->timeout = timeout;
- srvp->max_tries = tries;
- srvp->num_tries = 0;
- h->num_servers++;
- return 0;
-}
-
-void
-rad_close(struct rad_handle *h)
-{
- int srv;
-
- if (h->fd != -1)
- close(h->fd);
- for (srv = 0; srv < h->num_servers; srv++) {
- memset(h->servers[srv].secret, 0,
- strlen(h->servers[srv].secret));
- free(h->servers[srv].secret);
- }
- clear_password(h);
- free(h);
-}
-
-int
-rad_config(struct rad_handle *h, const char *path)
-{
- FILE *fp;
- char buf[MAXCONFLINE];
- int linenum;
- int retval;
-
- if (path == NULL)
- path = PATH_RADIUS_CONF;
- if ((fp = fopen(path, "r")) == NULL) {
- generr(h, "Cannot open \"%s\": %s", path, strerror(errno));
- return -1;
- }
- retval = 0;
- linenum = 0;
- while (fgets(buf, sizeof buf, fp) != NULL) {
- int len;
- char *fields[4];
- int nfields;
- char msg[ERRSIZE];
- char *host;
- char *port_str;
- char *secret;
- char *timeout_str;
- char *maxtries_str;
- char *end;
- unsigned long timeout;
- unsigned long maxtries;
- int port;
-
- linenum++;
- len = strlen(buf);
- /* We know len > 0, else fgets would have returned NULL. */
- if (buf[len - 1] != '\n') {
- if (len == sizeof buf - 1)
- generr(h, "%s:%d: line too long", path,
- linenum);
- else
- generr(h, "%s:%d: missing newline", path,
- linenum);
- retval = -1;
- break;
- }
- buf[len - 1] = '\0';
-
- /* Extract the fields from the line. */
- nfields = split(buf, fields, 4, msg, sizeof msg);
- if (nfields == -1) {
- generr(h, "%s:%d: %s", path, linenum, msg);
- retval = -1;
- break;
- }
- if (nfields == 0)
- continue;
- if (nfields < 2) {
- generr(h, "%s:%d: missing shared secret", path,
- linenum);
- retval = -1;
- break;
- }
- host = fields[0];
- secret = fields[1];
- timeout_str = fields[2];
- maxtries_str = fields[3];
-
- /* Parse and validate the fields. */
- host = strtok(host, ":");
- port_str = strtok(NULL, ":");
- if (port_str != NULL) {
- port = strtoul(port_str, &end, 10);
- if (*end != '\0') {
- generr(h, "%s:%d: invalid port", path,
- linenum);
- retval = -1;
- break;
- }
- } else
- port = 0;
- if (timeout_str != NULL) {
- timeout = strtoul(timeout_str, &end, 10);
- if (*end != '\0') {
- generr(h, "%s:%d: invalid timeout", path,
- linenum);
- retval = -1;
- break;
- }
- } else
- timeout = TIMEOUT;
- if (maxtries_str != NULL) {
- maxtries = strtoul(maxtries_str, &end, 10);
- if (*end != '\0') {
- generr(h, "%s:%d: invalid maxtries", path,
- linenum);
- retval = -1;
- break;
- }
- } else
- maxtries = MAXTRIES;
-
- if (rad_add_server(h, host, port, secret, timeout, maxtries) ==
- -1) {
- char msg[ERRSIZE];
-
- strcpy(msg, h->errmsg);
- generr(h, "%s:%d: %s", path, linenum, msg);
- retval = -1;
- break;
- }
- }
- /* Clear out the buffer to wipe a possible copy of a shared secret */
- memset(buf, 0, sizeof buf);
- fclose(fp);
- return retval;
-}
-
-int
-rad_create_request(struct rad_handle *h, int code)
-{
- int i;
-
- h->request[POS_CODE] = code;
- h->request[POS_IDENT] = ++h->ident;
- /* Create a random authenticator */
- for (i = 0; i < LEN_AUTH; i += 2) {
- long r;
- r = random();
- h->request[POS_AUTH+i] = r;
- h->request[POS_AUTH+i+1] = r >> 8;
- }
- h->req_len = POS_ATTRS;
- clear_password(h);
- return 0;
-}
-
-struct in_addr
-rad_cvt_addr(const void *data)
-{
- struct in_addr value;
-
- memcpy(&value.s_addr, data, sizeof value.s_addr);
- return value;
-}
-
-u_int32_t
-rad_cvt_int(const void *data)
-{
- u_int32_t value;
-
- memcpy(&value, data, sizeof value);
- return ntohl(value);
-}
-
-char *
-rad_cvt_string(const void *data, size_t len)
-{
- char *s;
-
- s = malloc(len + 1);
- if (s != NULL) {
- memcpy(s, data, len);
- s[len] = '\0';
- }
- return s;
-}
-
-/*
- * Returns the attribute type. If none are left, returns 0. On failure,
- * returns -1.
- */
-int
-rad_get_attr(struct rad_handle *h, const void **value, size_t *len)
-{
- int type;
-
- if (h->resp_pos >= h->resp_len)
- return 0;
- if (h->resp_pos + 2 > h->resp_len) {
- generr(h, "Malformed attribute in response");
- return -1;
- }
- type = h->response[h->resp_pos++];
- *len = h->response[h->resp_pos++] - 2;
- if (h->resp_pos + *len > h->resp_len) {
- generr(h, "Malformed attribute in response");
- return -1;
- }
- *value = &h->response[h->resp_pos];
- h->resp_pos += *len;
- return type;
-}
-
-/*
- * Create and initialize a rad_handle structure, and return it to the
- * caller. Can fail only if the necessary memory cannot be allocated.
- * In that case, it returns NULL.
- */
-struct rad_handle *
-rad_open(void)
-{
- struct rad_handle *h;
-
- h = (struct rad_handle *)malloc(sizeof(struct rad_handle));
- if (h != NULL) {
- srandomdev();
- h->fd = -1;
- h->num_servers = 0;
- h->ident = random();
- h->errmsg[0] = '\0';
- memset(h->pass, 0, sizeof h->pass);
- h->pass_len = 0;
- h->pass_pos = 0;
- }
- return h;
-}
-
-int
-rad_put_addr(struct rad_handle *h, int type, struct in_addr addr)
-{
- return rad_put_attr(h, type, &addr.s_addr, sizeof addr.s_addr);
-}
-
-int
-rad_put_attr(struct rad_handle *h, int type, const void *value, size_t len)
-{
- return type == RAD_USER_PASSWORD ?
- put_password_attr(h, type, value, len) :
- put_raw_attr(h, type, value, len);
-}
-
-int
-rad_put_int(struct rad_handle *h, int type, u_int32_t value)
-{
- u_int32_t nvalue;
-
- nvalue = htonl(value);
- return rad_put_attr(h, type, &nvalue, sizeof nvalue);
-}
-
-int
-rad_put_string(struct rad_handle *h, int type, const char *str)
-{
- return rad_put_attr(h, type, str, strlen(str));
-}
-
-/*
- * Returns the response type code on success, or -1 on failure.
- */
-int
-rad_send_request(struct rad_handle *h)
-{
- int total_tries;
- int try;
- int srv;
- int n;
- int got_valid_response;
-
- /* Make sure we have a socket to use */
- if (h->fd == -1) {
- struct sockaddr_in sin;
-
- if ((h->fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
- generr(h, "Cannot create socket: %s", strerror(errno));
- return -1;
- }
- memset(&sin, 0, sizeof sin);
- sin.sin_len = sizeof sin;
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = INADDR_ANY;
- sin.sin_port = htons(0);
- if (bind(h->fd, (const struct sockaddr *)&sin,
- sizeof sin) == -1) {
- generr(h, "bind: %s", strerror(errno));
- close(h->fd);
- h->fd = -1;
- return -1;
- }
- }
-
- /* Make sure the user gave us a password */
- if (h->pass_pos == 0) {
- generr(h, "No User-Password attribute given");
- return -1;
- }
-
- /* Fill in the length field in the message */
- h->request[POS_LENGTH] = h->req_len >> 8;
- h->request[POS_LENGTH+1] = h->req_len;
-
- /*
- * Count the total number of tries we will make, and zero the
- * counter for each server.
- */
- total_tries = 0;
- for (srv = 0; srv < h->num_servers; srv++) {
- total_tries += h->servers[srv].max_tries;
- h->servers[srv].num_tries = 0;
- }
- if (total_tries == 0) {
- generr(h, "No RADIUS servers specified");
- return -1;
- }
-
- srv = 0;
- got_valid_response = 0;
- for (try = 0; try < total_tries; try++) {
- struct timeval timelimit;
- struct timeval tv;
-
- /*
- * Scan round-robin to the next server that has some
- * tries left. There is guaranteed to be one, or we
- * would have exited this loop by now.
- */
- while (h->servers[srv].num_tries >=
- h->servers[srv].max_tries)
- if (++srv >= h->num_servers)
- srv = 0;
-
- /* Insert the scrambled password into the request */
- insert_scrambled_password(h, srv);
-
- /* Send the request */
- n = sendto(h->fd, h->request, h->req_len, 0,
- (const struct sockaddr *)&h->servers[srv].addr,
- sizeof h->servers[srv].addr);
- if (n != h->req_len) {
- if (n == -1)
- generr(h, "sendto: %s", strerror(errno));
- else
- generr(h, "sendto: short write");
- return -1;
- }
- h->servers[srv].num_tries++;
-
- /* Wait for a valid response */
- gettimeofday(&timelimit, NULL);
- timelimit.tv_sec += h->servers[srv].timeout;
-
- tv.tv_sec = h->servers[srv].timeout;
- tv.tv_usec = 0;
- for ( ; ; ) {
- fd_set readfds;
-
- FD_ZERO(&readfds);
- FD_SET(h->fd, &readfds);
- n = select(h->fd + 1, &readfds, NULL, NULL, &tv);
- if (n == -1) {
- generr(h, "select: %s", strerror(errno));
- return -1;
- }
- if (n == 0) /* Timed out */
- break;
- if (FD_ISSET(h->fd, &readfds)) {
- struct sockaddr_in from;
- int fromlen;
-
- fromlen = sizeof from;
- h->resp_len = recvfrom(h->fd, h->response,
- MSGSIZE, MSG_WAITALL,
- (struct sockaddr *)&from, &fromlen);
- if (h->resp_len == -1) {
- generr(h, "recvfrom: %s",
- strerror(errno));
- return -1;
- }
- if (is_valid_response(h, srv, &from)) {
- got_valid_response = 1;
- break;
- }
- }
- /* Compute a new timeout */
- gettimeofday(&tv, NULL);
- timersub(&timelimit, &tv, &tv);
- if (tv.tv_sec < 0) /* Still poll once more */
- timerclear(&tv);
- }
- if (got_valid_response)
- break;
- /* Advance to the next server */
- if (++srv >= h->num_servers)
- srv = 0;
- }
- if (!got_valid_response) {
- generr(h, "No valid RADIUS responses received");
- return -1;
- }
- h->resp_len = h->response[POS_LENGTH] << 8 | h->response[POS_LENGTH+1];
- h->resp_pos = POS_ATTRS;
- return h->response[POS_CODE];
-}
-
-const char *
-rad_strerror(struct rad_handle *h)
-{
- return h->errmsg;
-}
-
-/*
- * Destructively split a string into fields separated by white space.
- * `#' at the beginning of a field begins a comment that extends to the
- * end of the string. Fields may be quoted with `"'. Inside quoted
- * strings, the backslash escapes `\"' and `\\' are honored.
- *
- * Pointers to up to the first maxfields fields are stored in the fields
- * array. Missing fields get NULL pointers.
- *
- * The return value is the actual number of fields parsed, and is always
- * <= maxfields.
- *
- * On a syntax error, places a message in the msg string, and returns -1.
- */
-static int
-split(char *str, char *fields[], int maxfields, char *msg, size_t msglen)
-{
- char *p;
- int i;
- static const char ws[] = " \t";
-
- for (i = 0; i < maxfields; i++)
- fields[i] = NULL;
- p = str;
- i = 0;
- while (*p != '\0') {
- p += strspn(p, ws);
- if (*p == '#' || *p == '\0')
- break;
- if (i >= maxfields) {
- snprintf(msg, msglen, "line has too many fields");
- return -1;
- }
- if (*p == '"') {
- char *dst;
-
- dst = ++p;
- fields[i] = dst;
- while (*p != '"') {
- if (*p == '\\') {
- p++;
- if (*p != '"' && *p != '\\' &&
- *p != '\0') {
- snprintf(msg, msglen,
- "invalid `\\' escape");
- return -1;
- }
- }
- if (*p == '\0') {
- snprintf(msg, msglen,
- "unterminated quoted string");
- return -1;
- }
- *dst++ = *p++;
- }
- *dst = '\0';
- p++;
- if (*fields[i] == '\0') {
- snprintf(msg, msglen,
- "empty quoted string not permitted");
- return -1;
- }
- if (*p != '\0' && strspn(p, ws) == 0) {
- snprintf(msg, msglen, "quoted string not"
- " followed by white space");
- return -1;
- }
- } else {
- fields[i] = p;
- p += strcspn(p, ws);
- if (*p != '\0')
- *p++ = '\0';
- }
- i++;
- }
- return i;
-}
diff --git a/lib/libradius/radlib.h b/lib/libradius/radlib.h
deleted file mode 100644
index 146bcd51b29a8..0000000000000
--- a/lib/libradius/radlib.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _RADLIB_H_
-#define _RADLIB_H_
-
-#include <sys/types.h>
-#include <netinet/in.h>
-
-/* Message types */
-#define RAD_ACCESS_REQUEST 1
-#define RAD_ACCESS_ACCEPT 2
-#define RAD_ACCESS_REJECT 3
-#define RAD_ACCESS_CHALLENGE 11
-
-/* Attribute types and values */
-#define RAD_USER_NAME 1 /* String */
-#define RAD_USER_PASSWORD 2 /* String */
-#define RAD_CHAP_PASSWORD 3 /* String */
-#define RAD_NAS_IP_ADDRESS 4 /* IP address */
-#define RAD_NAS_PORT 5 /* Integer */
-#define RAD_SERVICE_TYPE 6 /* Integer */
- #define RAD_LOGIN 1
- #define RAD_FRAMED 2
- #define RAD_CALLBACK_LOGIN 3
- #define RAD_CALLBACK_FRAMED 4
- #define RAD_OUTBOUND 5
- #define RAD_ADMINISTRATIVE 6
- #define RAD_NAS_PROMPT 7
- #define RAD_AUTHENTICATE_ONLY 8
- #define RAD_CALLBACK_NAS_PROMPT 9
-#define RAD_FRAMED_PROTOCOL 7 /* Integer */
- #define RAD_PPP 1
- #define RAD_SLIP 2
- #define RAD_ARAP 3 /* Appletalk */
- #define RAD_GANDALF 4
- #define RAD_XYLOGICS 5
-#define RAD_FRAMED_IP_ADDRESS 8 /* IP address */
-#define RAD_FRAMED_IP_NETMASK 9 /* IP address */
-#define RAD_FRAMED_ROUTING 10 /* Integer */
-#define RAD_FILTER_ID 11 /* String */
-#define RAD_FRAMED_MTU 12 /* Integer */
-#define RAD_FRAMED_COMPRESSION 13 /* Integer */
-#define RAD_LOGIN_IP_HOST 14 /* IP address */
-#define RAD_LOGIN_SERVICE 15 /* Integer */
-#define RAD_LOGIN_TCP_PORT 16 /* Integer */
- /* unassiged 17 */
-#define RAD_REPLY_MESSAGE 18 /* String */
-#define RAD_CALLBACK_NUMBER 19 /* String */
-#define RAD_CALLBACK_ID 20 /* String */
- /* unassiged 21 */
-#define RAD_FRAMED_ROUTE 22 /* String */
-#define RAD_FRAMED_IPX_NETWORK 23 /* IP address */
-#define RAD_STATE 24 /* String */
-#define RAD_CLASS 25 /* Integer */
-#define RAD_VENDOR_SPECIFIC 26 /* Integer */
-#define RAD_SESSION_TIMEOUT 27 /* Integer */
-#define RAD_IDLE_TIMEOUT 28 /* Integer */
-#define RAD_TERMINATION_ACTION 29 /* Integer */
-#define RAD_CALLED_STATION_ID 30 /* String */
-#define RAD_CALLING_STATION_ID 31 /* String */
-#define RAD_NAS_IDENTIFIER 32 /* Integer */
-#define RAD_PROXY_STATE 33 /* Integer */
-#define RAD_LOGIN_LAT_SERVICE 34 /* Integer */
-#define RAD_LOGIN_LAT_NODE 35 /* Integer */
-#define RAD_LOGIN_LAT_GROUP 36 /* Integer */
-#define RAD_FRAMED_APPLETALK_LINK 37 /* Integer */
-#define RAD_FRAMED_APPLETALK_NETWORK 38 /* Integer */
-#define RAD_FRAMED_APPLETALK_ZONE 39 /* Integer */
- /* reserved for accounting 40-59 */
-#define RAD_CHAP_CHALLENGE 60 /* String */
-#define RAD_NAS_PORT_TYPE 61 /* Integer */
-#define RAD_PORT_LIMIT 62 /* Integer */
-#define RAD_LOGIN_LAT_PORT 63 /* Integer */
-
-struct rad_handle;
-
-__BEGIN_DECLS
-int rad_add_server(struct rad_handle *,
- const char *, int, const char *, int, int);
-void rad_close(struct rad_handle *);
-int rad_config(struct rad_handle *, const char *);
-int rad_create_request(struct rad_handle *, int);
-struct in_addr rad_cvt_addr(const void *);
-u_int32_t rad_cvt_int(const void *);
-char *rad_cvt_string(const void *, size_t);
-int rad_get_attr(struct rad_handle *, const void **,
- size_t *);
-struct rad_handle *rad_open(void);
-int rad_put_addr(struct rad_handle *, int, struct in_addr);
-int rad_put_attr(struct rad_handle *, int,
- const void *, size_t);
-int rad_put_int(struct rad_handle *, int, u_int32_t);
-int rad_put_string(struct rad_handle *, int,
- const char *);
-int rad_send_request(struct rad_handle *);
-const char *rad_strerror(struct rad_handle *);
-__END_DECLS
-
-#endif /* _RADLIB_H_ */
diff --git a/lib/libradius/radlib_private.h b/lib/libradius/radlib_private.h
deleted file mode 100644
index d3301e3261921..0000000000000
--- a/lib/libradius/radlib_private.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef RADLIB_PRIVATE_H
-#define RADLIB_PRIVATE_H
-
-#include <sys/types.h>
-#include <netinet/in.h>
-
-#include "radlib.h"
-
-/* Defaults */
-#define MAXTRIES 3
-#define PATH_RADIUS_CONF "/etc/radius.conf"
-#define RADIUS_PORT 1812
-#define TIMEOUT 3 /* In seconds */
-
-/* Limits */
-#define ERRSIZE 128 /* Maximum error message length */
-#define MAXCONFLINE 1024 /* Maximum config file line length */
-#define MAXSERVERS 10 /* Maximum number of servers to try */
-#define MSGSIZE 4096 /* Maximum RADIUS message */
-#define PASSSIZE 128 /* Maximum significant password chars */
-
-/* Positions of fields in RADIUS messages */
-#define POS_CODE 0 /* Message code */
-#define POS_IDENT 1 /* Identifier */
-#define POS_LENGTH 2 /* Message length */
-#define POS_AUTH 4 /* Authenticator */
-#define LEN_AUTH 16 /* Length of authenticator */
-#define POS_ATTRS 20 /* Start of attributes */
-
-struct rad_server {
- struct sockaddr_in addr; /* Address of server */
- char *secret; /* Shared secret */
- int timeout; /* Timeout in seconds */
- int max_tries; /* Number of tries before giving up */
- int num_tries; /* Number of tries so far */
-};
-
-struct rad_handle {
- int fd; /* Socket file descriptor */
- struct rad_server servers[MAXSERVERS]; /* Servers to contact */
- int num_servers; /* Number of valid server entries */
- int ident; /* Current identifier value */
- char errmsg[ERRSIZE]; /* Most recent error message */
- unsigned char request[MSGSIZE]; /* Request to send */
- int req_len; /* Length of request */
- char pass[PASSSIZE]; /* Cleartext password */
- int pass_len; /* Length of cleartext password */
- int pass_pos; /* Position of scrambled password */
- unsigned char response[MSGSIZE]; /* Response received */
- int resp_len; /* Length of response */
- int resp_pos; /* Current position scanning attrs */
-};
-
-#endif
diff --git a/lib/libskey/Makefile b/lib/libskey/Makefile
index 4ad0fe344735d..25f99fe8bc19b 100644
--- a/lib/libskey/Makefile
+++ b/lib/libskey/Makefile
@@ -15,8 +15,10 @@ CFLAGS+=-W -Wall
CFLAGS+=-Werror
.endif
+.if ${OBJFORMAT} == elf
DPADD+= ${LIBCRYPT} ${LIBMD}
LDADD+= -lcrypt -lmd
+.endif
beforeinstall:
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/skey.h \
diff --git a/lib/libskey/put.c b/lib/libskey/put.c
index e57d9ca9ce4cf..fd262a4d3db73 100644
--- a/lib/libskey/put.c
+++ b/lib/libskey/put.c
@@ -2137,7 +2137,7 @@ char *e;
standard(word);
if( (v = wsrch(word,low,high)) < 0 )
return 0;
- insert(b,v,(int)p,11);
+ insert(b,v,p,11);
}
/* now check the parity of what we got */
diff --git a/lib/libskey/skey.h b/lib/libskey/skey.h
index e62d507e0c8e4..6dc564bd4e40d 100644
--- a/lib/libskey/skey.h
+++ b/lib/libskey/skey.h
@@ -55,6 +55,6 @@ int skeychallenge __P((struct skey *mp, const char *name, char *challenge));
int skeyinfo __P((struct skey *mp, const char* name, char *ss));
int skeyaccess __P((char *user, const char *port, const char *host, const char *addr));
char *skey_getpass __P((const char *prompt, struct passwd * pwd, int pwok));
-const char *skey_crypt __P((char *pp, char *salt, struct passwd *pwd, int pwok));
+char *skey_crypt __P((char *pp, char *salt, struct passwd *pwd, int pwok));
#endif /* _SKEY_H_ */
diff --git a/lib/libskey/skey_crypt.c b/lib/libskey/skey_crypt.c
index 4e3a141333a56..6ed6bdb154ae1 100644
--- a/lib/libskey/skey_crypt.c
+++ b/lib/libskey/skey_crypt.c
@@ -3,13 +3,12 @@
#include <string.h>
#include <stdio.h>
#include <pwd.h>
-#include <unistd.h>
#include "skey.h"
/* skey_crypt - return encrypted UNIX passwd if s/key or regular password ok */
-const char *skey_crypt(pp, salt, pwd, pwok)
+char *skey_crypt(pp, salt, pwd, pwok)
char *pp;
char *salt;
struct passwd *pwd;
@@ -17,6 +16,7 @@ int pwok;
{
struct skey skey;
char *p;
+ char *crypt();
/* Try s/key authentication even when the UNIX password is permitted. */
diff --git a/lib/libskey/skeyaccess.c b/lib/libskey/skeyaccess.c
index b5796abe0b0b8..5a6e2d3a29633 100644
--- a/lib/libskey/skeyaccess.c
+++ b/lib/libskey/skeyaccess.c
@@ -45,12 +45,12 @@
*/
static char *prev_token = 0; /* push-back buffer */
static char *line_pointer = NULL;
-static char *first_token __P((char *, int, FILE *));
+static char *first_token();
static int line_number;
-static void unget_token __P((char *));
-static char *get_token __P((void));
-static char *need_token __P((void));
-static char *need_internet_addr __P((void));
+static void unget_token();
+static char *get_token();
+static char *need_token();
+static char *need_internet_addr();
/*
* Various forms of token matching.
@@ -58,13 +58,12 @@ static char *need_internet_addr __P((void));
#define match_host_name(l) match_token((l)->host_name)
#define match_port(l) match_token((l)->port)
#define match_user(l) match_token((l)->user)
-struct login_info;
-static int match_internet_addr __P((struct login_info *));
-static int match_group __P((struct login_info *));
-static int match_token __P((char *));
-static int is_internet_addr __P((char *));
-static struct in_addr *convert_internet_addr __P((char *));
-static struct in_addr *lookup_internet_addr __P((char *));
+static int match_internet_addr();
+static int match_group();
+static int match_token();
+static int is_internet_addr();
+static struct in_addr *convert_internet_addr();
+static struct in_addr *lookup_internet_addr();
#define MAX_ADDR 32
#define PERMIT 1
@@ -84,8 +83,7 @@ struct login_info {
char *port; /* login port */
};
-static int _skeyaccess __P((FILE *, struct login_info *));
-int skeyaccess __P((char *, char *, char *, char *));
+static int _skeyaccess __P(( FILE *, struct login_info * ));
/* skeyaccess - find out if UNIX passwords are permitted */
@@ -410,7 +408,7 @@ char *host;
for (i = 0; i < MAX_ADDR && hp->h_addr_list[i]; i++)
memcpy((char *) &list[i],
- hp->h_addr_list[i], (size_t)hp->h_length);
+ hp->h_addr_list[i], hp->h_length);
list[i].s_addr = 0;
strncpy(buf, hp->h_name, MAXHOSTNAMELEN);
@@ -429,12 +427,12 @@ char *host;
if ((hp = gethostbyaddr((char *) &list[i], length, AF_INET)) == 0) {
syslog(LOG_ERR, "address %s not registered for host %s",
inet_ntoa(list[i]), buf);
- list[i].s_addr = (u_int32_t) -1;
+ list[i].s_addr = -1;
}
if (NEQ(buf, hp->h_name) && NEQ3(buf, "localhost.", 10)) {
syslog(LOG_ERR, "address %s registered for host %s and %s",
inet_ntoa(list[i]), hp->h_name, buf);
- list[i].s_addr = (u_int32_t) -1;
+ list[i].s_addr = -1;
}
}
return (list);
diff --git a/lib/libskey/skeylogin.c b/lib/libskey/skeylogin.c
index 75e62458bc3a8..96de96feacb51 100644
--- a/lib/libskey/skeylogin.c
+++ b/lib/libskey/skeylogin.c
@@ -22,11 +22,11 @@
#include "skey.h"
#include "pathnames.h"
-static char *skipspace __P((char *));
+static char *skipspace();
#define setpriority(x,y,z) /* nothing */
-static const char *month[12] = {
+static char *month[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
diff --git a/lib/libskey/skeysubr.c b/lib/libskey/skeysubr.c
index 81284443e7a7c..ba88d8c8370b4 100644
--- a/lib/libskey/skeysubr.c
+++ b/lib/libskey/skeysubr.c
@@ -73,8 +73,6 @@ char *buf;
static struct termios saved_ttymode;
-static void interrupt __P((int));
-
static void interrupt(sig)
int sig;
{
@@ -88,7 +86,7 @@ char *buf;
int n;
{
struct termios noecho_ttymode;
- void (*oldsig) __P((int));
+ void (*oldsig)();
/* Save normal line editing modes */
tcgetattr(0, &saved_ttymode);
diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile
index 5c207be2159af..84e031d89e031 100644
--- a/lib/libstand/Makefile
+++ b/lib/libstand/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.10 1998/11/04 07:39:53 msmith Exp $
+# $Id: Makefile,v 1.5 1998/10/04 08:10:29 msmith Exp $
#
# Originally from $NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $
#
@@ -13,16 +13,16 @@ NOPIC= YES
MAN3= libstand.3
# Mostly OK, some of the libc imports are a bit noisy
-CFLAGS+= -Wall -g
+CFLAGS+= -Wall #-g
.if ${MACHINE_ARCH} == "alpha"
CFLAGS+= -mno-fp-regs
.endif
# standalone components and stuff we have modified locally
-SRCS+= __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
- globals.c pager.c printf.c strdup.c strerror.c strtol.c random.c \
- sbrk.c twiddle.c zalloc.c zalloc_malloc.c
+SRCS+= __main.c bcd.c bswap.c environment.c getopt.c gets.c globals.c \
+ pager.c printf.c strdup.c strerror.c strtol.c random.c sbrk.c \
+ twiddle.c zalloc.c zalloc_malloc.c
# private (pruned) versions of libc string functions
SRCS+= strcasecmp.c
@@ -31,7 +31,7 @@ SRCS+= strcasecmp.c
.PATH: ${.CURDIR}/../libc/string
.if ${MACHINE_ARCH} == "i386"
SRCS+= bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c memcmp.c \
- memcpy.c memmove.c memset.c qdivrem.c rindex.c strcat.c strchr.c \
+ memcpy.c memmove.c memset.c rindex.c strcat.c strchr.c \
strcmp.c strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c \
strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
.endif
@@ -90,12 +90,6 @@ __reml.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4
.PATH: ${.CURDIR}/../libc/net
SRCS+= inet_ntoa.c inet_addr.c
-# _setjmp/_longjmp
-.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/gen
-SRCS+= _setjmp.S
-# really only required for i386
-CFLAGS+=-I${.CURDIR}/../libc/${MACHINE_ARCH}
-
# decompression functionality from libz
.PATH: ${.CURDIR}/../libz
CFLAGS+=-DHAVE_MEMCPY
diff --git a/lib/libstand/assert.c b/lib/libstand/assert.c
deleted file mode 100644
index 1ca15f86be951..0000000000000
--- a/lib/libstand/assert.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $Id$
- */
-
-#include <stand.h>
-#include <assert.h>
-
-void
-__assert(const char *file, int line, const char *expression)
-{
- printf("assertion \"%s\" failed: file \"%s\", line %d\n", expression, file, line);
- exit();
-}
diff --git a/lib/libstand/dev_net.c b/lib/libstand/dev_net.c
index cfa9fbff8a944..8d09e4f7c0840 100644
--- a/lib/libstand/dev_net.c
+++ b/lib/libstand/dev_net.c
@@ -73,8 +73,6 @@ static int netdev_opens;
static int net_getparams(int sock);
-static void net_print(int verbose);
-
struct devsw netdev = {
"net",
DEVT_NET,
@@ -83,20 +81,9 @@ struct devsw netdev = {
net_open,
net_close,
noioctl
- net_print,
};
/*
- * Print stuff about our net 'device'.
- */
-static void
-net_print(int verbose)
-{
- pager_output(" net: network interface");
- /* XXX much more verbose stuff here */
-}
-
-/*
* Called by devopen after it sets f->f_dev to our devsw entry.
* This opens the low-level device and sets f->f_devdata.
* This is declared with variable arguments...
diff --git a/lib/libstand/gets.c b/lib/libstand/gets.c
index dc26a998b325a..3fbe9b4047a30 100644
--- a/lib/libstand/gets.c
+++ b/lib/libstand/gets.c
@@ -95,11 +95,8 @@ fgetstr(char *buf, int size, int fd)
err = read(fd, &c, sizeof(c));
if (err < 0) /* read error */
return(-1);
- if (err == 0) { /* EOF */
- if (len == 0)
- return(-1); /* nothing to read */
+ if (err == 0) /* EOF */
break;
- }
if ((c == '\r') || /* line terminators */
(c == '\n'))
break;
diff --git a/lib/libstand/libstand.3 b/lib/libstand/libstand.3
index aa5365ed43d70..4d4b287b3583f 100644
--- a/lib/libstand/libstand.3
+++ b/lib/libstand/libstand.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: libstand.3,v 1.2 1998/11/01 09:31:08 msmith Exp $
+.\" $Id$
.\"
.Dd June 22, 1998
.Dt LIBSTAND 3
@@ -124,19 +124,6 @@ may be used to prevent a variable being unset.
.Pp
Returns error messages for the subset of errno values supported by
.Nm No .
-.It Fn "assert" "expression"
-.Pp
-Requires
-.Fd #include <assert.h>
-.It Fn "int setjmp" "jmp_buf env"
-.It Fn "void longjmp" "jmp_buf env" "int val"
-.Pp
-Defined as
-.Fn _setjmp
-and
-.Fn _lonjmp
-respectively as there is no signal state to manipulate. Requires
-.Fd #include <setjmp.h>
.El
.Sh CHARACTER I/O
.Bl -hang -width 10n
@@ -168,7 +155,6 @@ if successful, or -1 if a read error occurs.
.It Fn "int printf" "const char *fmt" "..."
.It Fn "void vprintf" "const char *fmt" "va_list ap"
.It Fn "int sprintf" "char *buf" "const char *fmt" "..."
-.It Fn "void vsprintf" "char *buf" "const char *fmt" "va_list ap"
.Pp
The *printf functions implement a subset of the standard
.Fn printf
@@ -462,10 +448,6 @@ and
.Nm libkern
from
.Fx 3.0 .
-.It
-.Nm zalloc
-from
-.An Matthew Dillon Aq dillon@backplane.com
.El
.Pp
The reorganisation and port to
diff --git a/lib/libstand/printf.c b/lib/libstand/printf.c
index 5135e10183a93..8c7b38477a7ea 100644
--- a/lib/libstand/printf.c
+++ b/lib/libstand/printf.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
- * $Id: printf.c,v 1.1.1.1 1998/08/20 08:19:55 msmith Exp $
+ * $Id: subr_prf.c,v 1.46 1998/05/28 09:30:20 phk Exp $
*/
/*
@@ -74,6 +74,9 @@ vprintf(const char *fmt, va_list ap)
kvprintf(fmt, putchar, NULL, 10, ap);
}
+/*
+ * Scaled down version of sprintf(3).
+ */
int
sprintf(char *buf, const char *cfmt, ...)
{
@@ -87,15 +90,6 @@ sprintf(char *buf, const char *cfmt, ...)
return retval;
}
-void
-vsprintf(char *buf, const char *cfmt, va_list ap)
-{
- int retval;
-
- retval = kvprintf(cfmt, NULL, (void *)buf, 10, ap);
- buf[retval] = '\0';
-}
-
/*
* Put a number (base <= 16) in a buffer in reverse order; return an
* optional length and a pointer to the NULL terminated (preceded?)
diff --git a/lib/libstand/qdivrem.c b/lib/libstand/qdivrem.c
deleted file mode 100644
index d42b9f507021b..0000000000000
--- a/lib/libstand/qdivrem.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * 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.
- *
- * $Id$
- * From: Id: qdivrem.c,v 1.7 1997/11/07 09:20:40 phk Exp
- */
-
-/*
- * Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed),
- * section 4.3.1, pp. 257--259.
- */
-
-#include "quad.h"
-
-#define B (1 << HALF_BITS) /* digit base */
-
-/* Combine two `digits' to make a single two-digit number. */
-#define COMBINE(a, b) (((u_long)(a) << HALF_BITS) | (b))
-
-/* select a type for digits in base B: use unsigned short if they fit */
-#if ULONG_MAX == 0xffffffff && USHRT_MAX >= 0xffff
-typedef unsigned short digit;
-#else
-typedef u_long digit;
-#endif
-
-/*
- * Shift p[0]..p[len] left `sh' bits, ignoring any bits that
- * `fall out' the left (there never will be any such anyway).
- * We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS.
- */
-static void
-shl(register digit *p, register int len, register int sh)
-{
- register int i;
-
- for (i = 0; i < len; i++)
- p[i] = LHALF(p[i] << sh) | (p[i + 1] >> (HALF_BITS - sh));
- p[i] = LHALF(p[i] << sh);
-}
-
-/*
- * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v.
- *
- * We do this in base 2-sup-HALF_BITS, so that all intermediate products
- * fit within u_long. As a consequence, the maximum length dividend and
- * divisor are 4 `digits' in this base (they are shorter if they have
- * leading zeros).
- */
-u_quad_t
-__qdivrem(uq, vq, arq)
- u_quad_t uq, vq, *arq;
-{
- union uu tmp;
- digit *u, *v, *q;
- register digit v1, v2;
- u_long qhat, rhat, t;
- int m, n, d, j, i;
- digit uspace[5], vspace[5], qspace[5];
-
- /*
- * Take care of special cases: divide by zero, and u < v.
- */
- if (vq == 0) {
- /* divide by zero. */
- static volatile const unsigned int zero = 0;
-
- tmp.ul[H] = tmp.ul[L] = 1 / zero;
- if (arq)
- *arq = uq;
- return (tmp.q);
- }
- if (uq < vq) {
- if (arq)
- *arq = uq;
- return (0);
- }
- u = &uspace[0];
- v = &vspace[0];
- q = &qspace[0];
-
- /*
- * Break dividend and divisor into digits in base B, then
- * count leading zeros to determine m and n. When done, we
- * will have:
- * u = (u[1]u[2]...u[m+n]) sub B
- * v = (v[1]v[2]...v[n]) sub B
- * v[1] != 0
- * 1 < n <= 4 (if n = 1, we use a different division algorithm)
- * m >= 0 (otherwise u < v, which we already checked)
- * m + n = 4
- * and thus
- * m = 4 - n <= 2
- */
- tmp.uq = uq;
- u[0] = 0;
- u[1] = HHALF(tmp.ul[H]);
- u[2] = LHALF(tmp.ul[H]);
- u[3] = HHALF(tmp.ul[L]);
- u[4] = LHALF(tmp.ul[L]);
- tmp.uq = vq;
- v[1] = HHALF(tmp.ul[H]);
- v[2] = LHALF(tmp.ul[H]);
- v[3] = HHALF(tmp.ul[L]);
- v[4] = LHALF(tmp.ul[L]);
- for (n = 4; v[1] == 0; v++) {
- if (--n == 1) {
- u_long rbj; /* r*B+u[j] (not root boy jim) */
- digit q1, q2, q3, q4;
-
- /*
- * Change of plan, per exercise 16.
- * r = 0;
- * for j = 1..4:
- * q[j] = floor((r*B + u[j]) / v),
- * r = (r*B + u[j]) % v;
- * We unroll this completely here.
- */
- t = v[2]; /* nonzero, by definition */
- q1 = u[1] / t;
- rbj = COMBINE(u[1] % t, u[2]);
- q2 = rbj / t;
- rbj = COMBINE(rbj % t, u[3]);
- q3 = rbj / t;
- rbj = COMBINE(rbj % t, u[4]);
- q4 = rbj / t;
- if (arq)
- *arq = rbj % t;
- tmp.ul[H] = COMBINE(q1, q2);
- tmp.ul[L] = COMBINE(q3, q4);
- return (tmp.q);
- }
- }
-
- /*
- * By adjusting q once we determine m, we can guarantee that
- * there is a complete four-digit quotient at &qspace[1] when
- * we finally stop.
- */
- for (m = 4 - n; u[1] == 0; u++)
- m--;
- for (i = 4 - m; --i >= 0;)
- q[i] = 0;
- q += 4 - m;
-
- /*
- * Here we run Program D, translated from MIX to C and acquiring
- * a few minor changes.
- *
- * D1: choose multiplier 1 << d to ensure v[1] >= B/2.
- */
- d = 0;
- for (t = v[1]; t < B / 2; t <<= 1)
- d++;
- if (d > 0) {
- shl(&u[0], m + n, d); /* u <<= d */
- shl(&v[1], n - 1, d); /* v <<= d */
- }
- /*
- * D2: j = 0.
- */
- j = 0;
- v1 = v[1]; /* for D3 -- note that v[1..n] are constant */
- v2 = v[2]; /* for D3 */
- do {
- register digit uj0, uj1, uj2;
-
- /*
- * D3: Calculate qhat (\^q, in TeX notation).
- * Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and
- * let rhat = (u[j]*B + u[j+1]) mod v[1].
- * While rhat < B and v[2]*qhat > rhat*B+u[j+2],
- * decrement qhat and increase rhat correspondingly.
- * Note that if rhat >= B, v[2]*qhat < rhat*B.
- */
- uj0 = u[j + 0]; /* for D3 only -- note that u[j+...] change */
- uj1 = u[j + 1]; /* for D3 only */
- uj2 = u[j + 2]; /* for D3 only */
- if (uj0 == v1) {
- qhat = B;
- rhat = uj1;
- goto qhat_too_big;
- } else {
- u_long nn = COMBINE(uj0, uj1);
- qhat = nn / v1;
- rhat = nn % v1;
- }
- while (v2 * qhat > COMBINE(rhat, uj2)) {
- qhat_too_big:
- qhat--;
- if ((rhat += v1) >= B)
- break;
- }
- /*
- * D4: Multiply and subtract.
- * The variable `t' holds any borrows across the loop.
- * We split this up so that we do not require v[0] = 0,
- * and to eliminate a final special case.
- */
- for (t = 0, i = n; i > 0; i--) {
- t = u[i + j] - v[i] * qhat - t;
- u[i + j] = LHALF(t);
- t = (B - HHALF(t)) & (B - 1);
- }
- t = u[j] - t;
- u[j] = LHALF(t);
- /*
- * D5: test remainder.
- * There is a borrow if and only if HHALF(t) is nonzero;
- * in that (rare) case, qhat was too large (by exactly 1).
- * Fix it by adding v[1..n] to u[j..j+n].
- */
- if (HHALF(t)) {
- qhat--;
- for (t = 0, i = n; i > 0; i--) { /* D6: add back. */
- t += u[i + j] + v[i];
- u[i + j] = LHALF(t);
- t = HHALF(t);
- }
- u[j] = LHALF(u[j] + t);
- }
- q[j] = qhat;
- } while (++j <= m); /* D7: loop on j. */
-
- /*
- * If caller wants the remainder, we have to calculate it as
- * u[m..m+n] >> d (this is at most n digits and thus fits in
- * u[m+1..m+n], but we may need more source digits).
- */
- if (arq) {
- if (d) {
- for (i = m + n; i > m; --i)
- u[i] = (u[i] >> d) |
- LHALF(u[i - 1] << (HALF_BITS - d));
- u[i] = 0;
- }
- tmp.ul[H] = COMBINE(uspace[1], uspace[2]);
- tmp.ul[L] = COMBINE(uspace[3], uspace[4]);
- *arq = tmp.q;
- }
-
- tmp.ul[H] = COMBINE(qspace[1], qspace[2]);
- tmp.ul[L] = COMBINE(qspace[3], qspace[4]);
- return (tmp.q);
-}
-
-/*
- * Divide two unsigned quads.
- */
-
-u_quad_t
-__udivdi3(a, b)
- u_quad_t a, b;
-{
-
- return (__qdivrem(a, b, (u_quad_t *)0));
-}
-
-/*
- * Return remainder after dividing two unsigned quads.
- */
-u_quad_t
-__umoddi3(a, b)
- u_quad_t a, b;
-{
- u_quad_t r;
-
- (void)__qdivrem(a, b, &r);
- return (r);
-}
diff --git a/lib/libstand/quad.h b/lib/libstand/quad.h
deleted file mode 100644
index bddca839a5049..0000000000000
--- a/lib/libstand/quad.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * 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.
- *
- * @(#)quad.h 8.1 (Berkeley) 6/4/93
- * $Id: quad.h,v 1.6 1997/02/22 09:39:58 peter Exp $
- */
-
-/*
- * Quad arithmetic.
- *
- * This library makes the following assumptions:
- *
- * - The type long long (aka quad_t) exists.
- *
- * - A quad variable is exactly twice as long as `long'.
- *
- * - The machine's arithmetic is two's complement.
- *
- * This library can provide 128-bit arithmetic on a machine with 128-bit
- * quads and 64-bit longs, for instance, or 96-bit arithmetic on machines
- * with 48-bit longs.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <limits.h>
-
-/*
- * Depending on the desired operation, we view a `long long' (aka quad_t) in
- * one or more of the following formats.
- */
-union uu {
- quad_t q; /* as a (signed) quad */
- quad_t uq; /* as an unsigned quad */
- long sl[2]; /* as two signed longs */
- u_long ul[2]; /* as two unsigned longs */
-};
-
-/*
- * Define high and low longwords.
- */
-#define H _QUAD_HIGHWORD
-#define L _QUAD_LOWWORD
-
-/*
- * Total number of bits in a quad_t and in the pieces that make it up.
- * These are used for shifting, and also below for halfword extraction
- * and assembly.
- */
-#define QUAD_BITS (sizeof(quad_t) * CHAR_BIT)
-#define LONG_BITS (sizeof(long) * CHAR_BIT)
-#define HALF_BITS (sizeof(long) * CHAR_BIT / 2)
-
-/*
- * Extract high and low shortwords from longword, and move low shortword of
- * longword to upper half of long, i.e., produce the upper longword of
- * ((quad_t)(x) << (number_of_bits_in_long/2)). (`x' must actually be u_long.)
- *
- * These are used in the multiply code, to split a longword into upper
- * and lower halves, and to reassemble a product as a quad_t, shifted left
- * (sizeof(long)*CHAR_BIT/2).
- */
-#define HHALF(x) ((x) >> HALF_BITS)
-#define LHALF(x) ((x) & ((1 << HALF_BITS) - 1))
-#define LHUP(x) ((x) << HALF_BITS)
-
-quad_t __divdi3 __P((quad_t a, quad_t b));
-quad_t __moddi3 __P((quad_t a, quad_t b));
-u_quad_t __qdivrem __P((u_quad_t u, u_quad_t v, u_quad_t *rem));
-u_quad_t __udivdi3 __P((u_quad_t a, u_quad_t b));
-u_quad_t __umoddi3 __P((u_quad_t a, u_quad_t b));
-
-/*
- * XXX
- * Compensate for gcc 1 vs gcc 2. Gcc 1 defines ?sh?di3's second argument
- * as u_quad_t, while gcc 2 correctly uses int. Unfortunately, we still use
- * both compilers.
- */
-#if __GNUC__ >= 2
-typedef unsigned int qshift_t;
-#else
-typedef u_quad_t qshift_t;
-#endif
diff --git a/lib/libstand/stand.h b/lib/libstand/stand.h
index 74abcd7660b38..4199fd672e465 100644
--- a/lib/libstand/stand.h
+++ b/lib/libstand/stand.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: stand.h,v 1.12 1998/11/04 07:39:53 msmith Exp $
+ * $Id: stand.h,v 1.6 1998/09/26 10:48:50 dfr Exp $
* From $NetBSD: stand.h,v 1.22 1997/06/26 19:17:40 drochner Exp $
*/
@@ -137,7 +137,6 @@ struct devsw {
int (*dv_open)(struct open_file *f, ...);
int (*dv_close)(struct open_file *f);
int (*dv_ioctl)(struct open_file *f, u_long cmd, void *data);
- void (*dv_print)(int verbose); /* print device information */
};
extern int errno;
@@ -162,7 +161,7 @@ extern struct open_file files[];
#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
#define islower(c) ((c) >= 'a' && (c) <= 'z')
-#define isspace(c) ((c) == ' ' || ((c) >= 0x9 && (c) <= 0xd))
+#define isspace(c) ((c) == ' ' || (c) == '\t')
#define isdigit(c) ((c) >= '0' && (c) <= '9')
#define isxdigit(c) (isdigit(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
#define isascii(c) ((c) >= 0 || (c <= 0x7f))
@@ -182,9 +181,6 @@ extern void *calloc(size_t n1, size_t n2);
extern void *realloc(void *ptr, size_t size);
extern void *reallocf(void *ptr, size_t size);
extern void mallocstats(void);
-#ifdef __alpha__
-extern void free_region(void *start, void *end);
-#endif
/* disklabel support (undocumented, may be junk) */
struct disklabel;
@@ -194,7 +190,6 @@ extern int dkcksum(struct disklabel *);
extern int printf(const char *fmt, ...);
extern void vprintf(const char *fmt, _BSD_VA_LIST_);
extern int sprintf(char *buf, const char *cfmt, ...);
-extern void vsprintf(char *buf, const char *cfmt, _BSD_VA_LIST_);
extern void twiddle(void);
@@ -220,7 +215,7 @@ extern u_long random(void);
extern long strtol(const char *, char **, int);
extern char * strerror(int err);
extern char *optarg; /* getopt(3) external variables */
-extern int optind, opterr, optopt, optreset;
+extern int optind, opterr, optopt;
extern int getopt(int, char * const [], const char *);
/* pager.c */
@@ -229,10 +224,6 @@ extern void pager_close(void);
extern int pager_output(const char *lines);
extern int pager_file(const char *fname);
-/* No signal state to preserve */
-#define setjmp _setjmp
-#define longjmp _longjmp
-
/* environment.c */
#define EV_DYNAMIC (1<<0) /* value was dynamically allocated, free if changed/unset */
#define EV_VOLATILE (1<<1) /* value is volatile, make a copy of it */
diff --git a/lib/libstand/zalloc_defs.h b/lib/libstand/zalloc_defs.h
index 051c53fffb12a..d3f46da410aa4 100644
--- a/lib/libstand/zalloc_defs.h
+++ b/lib/libstand/zalloc_defs.h
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: zalloc_defs.h,v 1.4 1998/10/16 19:23:37 msmith Exp $
+ * $Id: zalloc_defs.h,v 1.2 1998/09/26 10:48:50 dfr Exp $
*/
/*
@@ -63,7 +63,7 @@ typedef long saddr_t; /* signed int same size as pointer */
* block extension for sbrk()
*/
-#define BLKEXTEND (4 * 1024)
+#define BLKEXTEND (64 * 1024)
#define BLKEXTENDMASK (BLKEXTEND - 1)
/*
diff --git a/lib/libstand/zalloc_malloc.c b/lib/libstand/zalloc_malloc.c
index d70a8f7577c0f..6cb4953ef312f 100644
--- a/lib/libstand/zalloc_malloc.c
+++ b/lib/libstand/zalloc_malloc.c
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: zalloc_malloc.c,v 1.3 1998/10/01 17:35:08 msmith Exp $
+ * $Id: zalloc_malloc.c,v 1.2 1998/09/26 10:48:50 dfr Exp $
*/
/*
@@ -49,15 +49,6 @@ void mallocstats(void);
#undef free
#endif
-#ifdef __alpha__
-void
-free_region(void *start, void *end)
-{
- zextendPool(&MallocPool, start, (caddr_t)end - (caddr_t)start);
- zfree(&MallocPool, start, (caddr_t)end - (caddr_t)start);
-}
-#endif
-
void *
malloc(size_t bytes)
{
diff --git a/lib/libtacplus/Makefile b/lib/libtacplus/Makefile
deleted file mode 100644
index 798a8e08f306e..0000000000000
--- a/lib/libtacplus/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 1998 Juniper Networks, Inc.
-# 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-#
-# $FreeBSD$
-
-LIB= tacplus
-SRCS= taclib.c
-CFLAGS+= -Wall
-DPADD+= ${LIBMD}
-LDADD+= -lmd
-SHLIB_MAJOR= 1
-SHLIB_MINOR= 0
-MAN3+= libtacplus.3
-MAN5+= tacplus.conf.5
-
-beforeinstall:
- ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \
- ${.CURDIR}/taclib.h ${DESTDIR}/usr/include
-
-.include <bsd.lib.mk>
diff --git a/lib/libtacplus/libtacplus.3 b/lib/libtacplus/libtacplus.3
deleted file mode 100644
index bfbfa352a7d3a..0000000000000
--- a/lib/libtacplus/libtacplus.3
+++ /dev/null
@@ -1,347 +0,0 @@
-.\" Copyright 1998 Juniper Networks, Inc.
-.\" 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd September 2, 1998
-.Dt LIBTACPLUS 3
-.Os FreeBSD
-.Sh NAME
-.Nm libtacplus
-.Nd TACACS+ client library
-.Sh SYNOPSIS
-.Fd #include <taclib.h>
-.Ft int
-.Fn tac_add_server "struct tac_handle *h" "const char *host" "int port" "const char *secret" "int timeout" "int flags"
-.Ft void
-.Fn tac_close "struct tac_handle *h"
-.Ft int
-.Fn tac_config "struct tac_handle *h" "const char *path"
-.Ft int
-.Fn tac_create_authen "struct tac_handle *h" "int action" "int type" "int service"
-.Ft void *
-.Fn tac_get_data "struct tac_handle *h" "size_t *len"
-.Ft char *
-.Fn tac_get_msg "struct tac_handle *h"
-.Ft struct tac_handle *
-.Fn tac_open "void"
-.Ft int
-.Fn tac_send_authen "struct tac_handle *h"
-.Ft int
-.Fn tac_set_data "struct tac_handle *h" "const void *data" "size_t data_len"
-.Ft int
-.Fn tac_set_msg "struct tac_handle *h" "const char *msg"
-.Ft int
-.Fn tac_set_port "struct tac_handle *h" "const char *port"
-.Ft int
-.Fn tac_set_priv "struct tac_handle *h" "int priv"
-.Ft int
-.Fn tac_set_rem_addr "struct tac_handle *h" "const char *addr"
-.Ft int
-.Fn tac_set_user "struct tac_handle *h" "const char *user"
-.Ft const char *
-.Fn tac_strerror "struct tac_handle *h"
-.Sh DESCRIPTION
-The
-.Nm
-library implements the client side of the TACACS+ network access
-control protocol. TACACS+ allows clients to perform authentication,
-authorization, and accounting by means of network requests to remote
-servers. This library currently supports only the authentication
-portion of the protocol.
-.Sh INITIALIZATION
-To use the library, an application must first call
-.Fn tac_open
-to obtain a
-.Va struct tac_handle * ,
-which provides context for subsequent operations.
-Calls to
-.Fn tac_open
-always succeed unless insufficient virtual memory is available. If
-the necessary memory cannot be allocated,
-.Fn tac_open
-returns
-.Dv NULL .
-.Pp
-Before issuing any TACACS+ requests, the library must be made aware
-of the servers it can contact. The easiest way to configure the
-library is to call
-.Fn tac_config .
-.Fn tac_config
-causes the library to read a configuration file whose format is
-described in
-.Xr tacplus.conf 5 .
-The pathname of the configuration file is passed as the
-.Va file
-argument to
-.Fn tac_config .
-This argument may also be given as
-.Dv NULL ,
-in which case the standard configuration file
-.Pa /etc/tacplus.conf
-is used.
-.Fn tac_config
-returns 0 on success, or -1 if an error occurs.
-.Pp
-The library can also be configured programmatically by calls to
-.Fn tac_add_server .
-The
-.Va host
-parameter specifies the server host, either as a fully qualified
-domain name or as a dotted-quad IP address in text form.
-The
-.Va port
-parameter specifies the TCP port to contact on the server. If
-.Va port
-is given as 0, the library uses port 49, the standard TACACS+ port.
-The shared secret for the server host is passed to the
-.Va secret
-parameter. It may be any null-terminated string of bytes.
-The timeout for receiving replies from the server is passed to the
-.Va timeout
-parameter, in units of seconds.
-The
-.Va flags
-parameter is a bit mask of flags to specify various characteristics of
-the server. It may contain:
-.Pp
-.Bl -tag -width Fl
-.It Dv TAC_SRVR_SINGLE_CONNECT
-Causes the library to attempt to negotiate single connection mode
-when communicating with the server. In single connection mode, the
-original TCP connection is held open for multiple TACACS+ sessions.
-Older servers do not support this mode, and some of them become
-confused if the client attempts to negotiate it.
-.El
-.Pp
-.Fn tac_add_server
-returns 0 on success, or -1 if an error occurs.
-.Pp
-.Fn tac_add_server
-may be called multiple times, and it may be used together with
-.Fn tac_config .
-At most 10 servers may be specified.
-When multiple servers are given, they are tried in round-robin
-fashion until a working, accessible server is found. Once the
-library finds such a server, it continues to use it as long as it
-works.
-.Sh CREATING A TACACS+ AUTHENTICATION REQUEST
-To begin constructing a new authentication request, call
-.Fn tac_create_authen .
-The
-.Va action ,
-.Va type ,
-and
-.Va service
-arguments must be be set to appropriate values as defined in the
-TACACS+ protocol specification. The
-.Aq taclib.h
-header file contains symbolic constants for these values.
-.Pp
-After creating a request with
-.Fn tac_create_authen ,
-various optional parameters may be attached to it through calls to
-.Fn tac_set_data ,
-.Fn tac_set_port ,
-.Fn tac_set_priv ,
-.Fn tac_set_rem_addr ,
-and
-.Fn tac_set_user .
-The library creates its own copies of any strings provided to these
-functions, so that it is not necessary for the caller to preserve
-them. By default, each of these parameters is empty except for the
-privilege level, which defaults to
-.Ql USER
-privilege.
-.Sh SENDING THE AUTHENTICATION REQUEST AND RECEIVING THE RESPONSE
-After the TACACS+ request has been constructed, it is sent by means
-of
-.Fn tac_send_authen .
-This function connects to a server if not already connected, sends
-the request, and waits for a reply. On failure,
-.Fn tac_send_authen
-returns -1. Otherwise, it returns the TACACS+ status code and flags,
-packed into an integer value. The status can be extracted using the
-macro
-.Fn TAC_AUTHEN_STATUS .
-Possible status codes, defined in
-.Aq taclib.h ,
-include:
-.Pp
-.Bl -item -compact -offset indent
-.It
-.Dv TAC_AUTHEN_STATUS_PASS
-.It
-.Dv TAC_AUTHEN_STATUS_FAIL
-.It
-.Dv TAC_AUTHEN_STATUS_GETDATA
-.It
-.Dv TAC_AUTHEN_STATUS_GETUSER
-.It
-.Dv TAC_AUTHEN_STATUS_GETPASS
-.It
-.Dv TAC_AUTHEN_STATUS_RESTART
-.It
-.Dv TAC_AUTHEN_STATUS_ERROR
-.It
-.Dv TAC_AUTHEN_STATUS_FOLLOW
-.El
-.Pp
-The only flag is the no-echo flag, which can be tested using the
-macro
-.Fn TAC_AUTHEN_NOECHO .
-.Sh EXTRACTING INFORMATION FROM THE SERVER'S RESPONSE
-An authentication response packet from the server may contain a
-server message, a data string, or both. After a successful call to
-.Fn tac_send_authen ,
-this information may be retrieved from the response by calling
-.Fn tac_get_msg
-and
-.Fn tac_get_data .
-These functions return dynamically-allocated copies of the
-information from the packet. The caller is responsible for freeing
-the copies when it no longer needs them. The data returned from
-these functions is guaranteed to be terminated by a null byte.
-.Pp
-In the case of
-.Fn tac_get_data ,
-the
-.Va len
-argument points to a location into which the library will store the
-actual length of the received data, not including the null
-terminator. This argument may be given as
-.Dv NULL
-if the caller is not interested in the length.
-.Sh SENDING AUTHENTICATION CONTINUE PACKETS
-If
-.Fn tac_send_authen
-returns a value containing one of the status codes
-.Dv TAC_AUTHEN_STATUS_GETDATA ,
-.Dv TAC_AUTHEN_STATUS_GETUSER ,
-or
-.Dv TAC_AUTHEN_STATUS_GETPASS ,
-then the client must provide additional information to the server by
-means of a TACACS+ CONTINUE packet. To do so, the application must
-first set the packet's user message and/or data fields using
-.Fn tac_set_msg
-and
-.Fn tac_set_data .
-The client then sends the CONTINUE packet with
-.Fn tac_send_authen .
-N.B.,
-.Fn tac_create_authen
-should
-.Em not
-be called to construct a CONTINUE packet; it is used only for the
-initial authentication request.
-.Pp
-When it receives the CONTINUE packet, the server may again request
-more information by returning
-.Dv TAC_AUTHEN_STATUS_GETDATA ,
-.Dv TAC_AUTHEN_STATUS_GETUSER ,
-or
-.Dv TAC_AUTHEN_STATUS_GETPASS .
-The application should send further CONTINUEs until some other
-status is received from the server.
-.Sh OBTAINING ERROR MESSAGES
-Those functions which accept a
-.Va struct tac_handle *
-argument record an error message if they fail. The error message
-can be retrieved by calling
-.Fn tac_strerror .
-The message text is overwritten on each new error for the given
-.Va struct tac_handle * .
-Thus the message must be copied if it is to be preserved through
-subsequent library calls using the same handle.
-.Sh CLEANUP
-To free the resources used by the TACACS+ library, call
-.Fn tac_close .
-.Sh RETURN VALUES
-The following functions return a non-negative value on success. If
-they detect an error, they return -1 and record an error message
-which can be retrieved using
-.Fn tac_strerror .
-.Pp
-.Bl -item -offset indent -compact
-.It
-.Fn tac_add_server
-.It
-.Fn tac_config
-.It
-.Fn tac_create_authen
-.It
-.Fn tac_send_authen
-.It
-.Fn tac_set_data
-.It
-.Fn tac_set_msg
-.It
-.Fn tac_set_port
-.It
-.Fn tac_set_priv
-.It
-.Fn tac_set_rem_addr
-.It
-.Fn tac_set_user
-.El
-.Pp
-The following functions return a
-.No non- Ns Dv NULL
-pointer on success. If they are unable to allocate sufficient
-virtual memory, they return
-.Dv NULL
-and record an error message which can be retrieved using
-.Fn tac_strerror .
-.Pp
-.Bl -item -offset indent -compact
-.It
-.Fn tac_get_data
-.It
-.Fn tac_get_msg
-.El
-.Pp
-The following functions return a
-.No non- Ns Dv NULL
-pointer on success. If they are unable to allocate sufficient
-virtual memory, they return
-.Dv NULL ,
-without recording an error message.
-.Pp
-.Bl -item -offset indent -compact
-.It
-.Fn tac_open
-.El
-.Sh FILES
-.Pa /etc/tacplus.conf
-.Sh SEE ALSO
-.Xr tacplus.conf 5
-.Rs
-.%A D. Carrel and Lol Grant
-.%T The TACACS+ Protocol, Version 1.78
-.%O draft-grant-tacacs-02.txt (Internet Draft)
-.Re
-.Sh AUTHORS
-This software was written by
-.An John Polstra ,
-and donated to the FreeBSD project by Juniper Networks, Inc.
diff --git a/lib/libtacplus/taclib.c b/lib/libtacplus/taclib.c
deleted file mode 100644
index bd2e663b32c88..0000000000000
--- a/lib/libtacplus/taclib.c
+++ /dev/null
@@ -1,1053 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <md5.h>
-#include <netdb.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "taclib_private.h"
-
-static int add_str_8(struct tac_handle *, u_int8_t *,
- struct clnt_str *);
-static int add_str_16(struct tac_handle *, u_int16_t *,
- struct clnt_str *);
-static int authen_version(int, int);
-static void close_connection(struct tac_handle *);
-static int conn_server(struct tac_handle *);
-static void crypt_msg(struct tac_handle *, struct tac_msg *);
-static void *dup_str(struct tac_handle *, const struct srvr_str *,
- size_t *);
-static int establish_connection(struct tac_handle *);
-static void free_str(struct clnt_str *);
-static void generr(struct tac_handle *, const char *, ...)
- __printflike(2, 3);
-static void gen_session_id(struct tac_msg *);
-static int get_srvr_end(struct tac_handle *);
-static int get_srvr_str(struct tac_handle *, struct srvr_str *,
- size_t);
-static void init_clnt_str(struct clnt_str *);
-static void init_srvr_str(struct srvr_str *);
-static int read_timed(struct tac_handle *, void *, size_t,
- const struct timeval *);
-static int recv_msg(struct tac_handle *);
-static int save_str(struct tac_handle *, struct clnt_str *,
- const void *, size_t);
-static int send_msg(struct tac_handle *);
-static int split(char *, char *[], int, char *, size_t);
-static void *xmalloc(struct tac_handle *, size_t);
-static char *xstrdup(struct tac_handle *, const char *);
-
-/*
- * Append some optional data to the current request, and store its
- * length into the 8-bit field referenced by "fld". Returns 0 on
- * success, or -1 on failure.
- *
- * This function also frees the "cs" string data and initializes it
- * for the next time.
- */
-static int
-add_str_8(struct tac_handle *h, u_int8_t *fld, struct clnt_str *cs)
-{
- u_int16_t len;
-
- if (add_str_16(h, &len, cs) == -1)
- return -1;
- len = ntohs(len);
- if (len > 0xff) {
- generr(h, "Field too long");
- return -1;
- }
- *fld = len;
- return 0;
-}
-
-/*
- * Append some optional data to the current request, and store its
- * length into the 16-bit field (network byte order) referenced by
- * "fld". Returns 0 on success, or -1 on failure.
- *
- * This function also frees the "cs" string data and initializes it
- * for the next time.
- */
-static int
-add_str_16(struct tac_handle *h, u_int16_t *fld, struct clnt_str *cs)
-{
- size_t len;
-
- len = cs->len;
- if (cs->data == NULL)
- len = 0;
- if (len != 0) {
- int offset;
-
- if (len > 0xffff) {
- generr(h, "Field too long");
- return -1;
- }
- offset = ntohl(h->request.length);
- if (offset + len > BODYSIZE) {
- generr(h, "Message too long");
- return -1;
- }
- memcpy(h->request.u.body + offset, cs->data, len);
- h->request.length = htonl(offset + len);
- }
- *fld = htons(len);
- free_str(cs);
- return 0;
-}
-
-static int
-authen_version(int action, int type)
-{
- int minor;
-
- switch (action) {
-
- case TAC_AUTHEN_LOGIN:
- switch (type) {
-
- case TAC_AUTHEN_TYPE_PAP:
- case TAC_AUTHEN_TYPE_CHAP:
- case TAC_AUTHEN_TYPE_MSCHAP:
- case TAC_AUTHEN_TYPE_ARAP:
- minor = 1;
- break;
-
- default:
- minor = 0;
- break;
- }
- break;
-
- case TAC_AUTHEN_SENDAUTH:
- minor = 1;
- break;
-
- default:
- minor = 0;
- break;
- };
-
- return TAC_VER_MAJOR << 4 | minor;
-}
-
-static void
-close_connection(struct tac_handle *h)
-{
- if (h->fd != -1) {
- close(h->fd);
- h->fd = -1;
- }
-}
-
-static int
-conn_server(struct tac_handle *h)
-{
- const struct tac_server *srvp = &h->servers[h->cur_server];
- int flags;
-
- if ((h->fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
- generr(h, "Cannot create socket: %s", strerror(errno));
- return -1;
- }
- if ((flags = fcntl(h->fd, F_GETFL, 0)) == -1 ||
- fcntl(h->fd, F_SETFL, flags | O_NONBLOCK) == -1) {
- generr(h, "Cannot set non-blocking mode on socket: %s",
- strerror(errno));
- close(h->fd);
- h->fd = -1;
- return -1;
- }
- if (connect(h->fd, (struct sockaddr *)&srvp->addr,
- sizeof srvp->addr) == 0)
- return 0;
-
- if (errno == EINPROGRESS) {
- fd_set wfds;
- struct timeval tv;
- int nfds;
- struct sockaddr peer;
- int peerlen;
- int err;
- int errlen;
-
- /* Wait for the connection to complete. */
- FD_ZERO(&wfds);
- FD_SET(h->fd, &wfds);
- tv.tv_sec = srvp->timeout;
- tv.tv_usec = 0;
- nfds = select(h->fd + 1, NULL, &wfds, NULL, &tv);
- if (nfds == -1) {
- generr(h, "select: %s", strerror(errno));
- close(h->fd);
- h->fd = -1;
- return -1;
- }
- if (nfds == 0) {
- generr(h, "connect: timed out");
- close(h->fd);
- h->fd = -1;
- return -1;
- }
-
- /* See whether we are connected now. */
- peerlen = sizeof peer;
- if (getpeername(h->fd, &peer, &peerlen) == 0)
- return 0;
-
- if (errno != ENOTCONN) {
- generr(h, "getpeername: %s", strerror(errno));
- close(h->fd);
- h->fd = -1;
- return -1;
- }
-
- /* Find out why the connect failed. */
- errlen = sizeof err;
- getsockopt(h->fd, SOL_SOCKET, SO_ERROR, &err, &errlen);
- errno = err;
- }
- generr(h, "connect: %s", strerror(errno));
- close(h->fd);
- h->fd = -1;
- return -1;
-}
-
-/*
- * Encrypt or decrypt a message. The operations are symmetrical.
- */
-static void
-crypt_msg(struct tac_handle *h, struct tac_msg *msg)
-{
- const char *secret;
- MD5_CTX base_ctx;
- MD5_CTX ctx;
- unsigned char md5[16];
- int chunk;
- int msg_len;
-
- secret = h->servers[h->cur_server].secret;
- if (secret[0] == '\0')
- msg->flags |= TAC_UNENCRYPTED;
- if (msg->flags & TAC_UNENCRYPTED)
- return;
-
- msg_len = ntohl(msg->length);
-
- MD5Init(&base_ctx);
- MD5Update(&base_ctx, msg->session_id, sizeof msg->session_id);
- MD5Update(&base_ctx, secret, strlen(secret));
- MD5Update(&base_ctx, &msg->version, sizeof msg->version);
- MD5Update(&base_ctx, &msg->seq_no, sizeof msg->seq_no);
-
- ctx = base_ctx;
- for (chunk = 0; chunk < msg_len; chunk += sizeof md5) {
- int chunk_len;
- int i;
-
- MD5Final(md5, &ctx);
-
- if ((chunk_len = msg_len - chunk) > sizeof md5)
- chunk_len = sizeof md5;
- for (i = 0; i < chunk_len; i++)
- msg->u.body[chunk + i] ^= md5[i];
-
- ctx = base_ctx;
- MD5Update(&ctx, md5, sizeof md5);
- }
-}
-
-/*
- * Return a dynamically allocated copy of the given server string.
- * The copy is null-terminated. If "len" is non-NULL, the length of
- * the string (excluding the terminating null byte) is stored via it.
- * Returns NULL on failure. Empty strings are still allocated even
- * though they have no content.
- */
-static void *
-dup_str(struct tac_handle *h, const struct srvr_str *ss, size_t *len)
-{
- unsigned char *p;
-
- if ((p = (unsigned char *)xmalloc(h, ss->len + 1)) == NULL)
- return NULL;
- if (ss->data != NULL && ss->len != 0)
- memcpy(p, ss->data, ss->len);
- p[ss->len] = '\0';
- if (len != NULL)
- *len = ss->len;
- return p;
-}
-
-static int
-establish_connection(struct tac_handle *h)
-{
- int i;
-
- if (h->fd >= 0) /* Already connected. */
- return 0;
- if (h->num_servers == 0) {
- generr(h, "No TACACS+ servers specified");
- return -1;
- }
- /*
- * Try the servers round-robin. We begin with the one that
- * worked for us the last time. That way, once we find a good
- * server, we won't waste any more time trying the bad ones.
- */
- for (i = 0; i < h->num_servers; i++) {
- if (conn_server(h) == 0) {
- h->single_connect = (h->servers[h->cur_server].flags &
- TAC_SRVR_SINGLE_CONNECT) != 0;
- return 0;
- }
- if (++h->cur_server >= h->num_servers) /* Wrap around */
- h->cur_server = 0;
- }
- /* Just return whatever error was last reported by conn_server(). */
- return -1;
-}
-
-/*
- * Free a client string, obliterating its contents first for security.
- */
-static void
-free_str(struct clnt_str *cs)
-{
- if (cs->data != NULL) {
- memset(cs->data, 0, cs->len);
- free(cs->data);
- cs->data = NULL;
- cs->len = 0;
- }
-}
-
-static void
-generr(struct tac_handle *h, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- vsnprintf(h->errmsg, ERRSIZE, format, ap);
- va_end(ap);
-}
-
-static void
-gen_session_id(struct tac_msg *msg)
-{
- int r;
-
- r = random();
- msg->session_id[0] = r >> 8;
- msg->session_id[1] = r;
- r = random();
- msg->session_id[2] = r >> 8;
- msg->session_id[3] = r;
-}
-
-/*
- * Verify that we are exactly at the end of the response message.
- * Returns 0 on success, -1 on failure.
- */
-static int
-get_srvr_end(struct tac_handle *h)
-{
- if (h->srvr_pos != ntohl(h->response.length)) {
- generr(h, "Invalid length field in response from server");
- return -1;
- }
- return 0;
-}
-
-static int
-get_srvr_str(struct tac_handle *h, struct srvr_str *ss, size_t len)
-{
- if (h->srvr_pos + len > ntohl(h->response.length)) {
- generr(h, "Invalid length field in response from server");
- return -1;
- }
- ss->data = len != 0 ? h->response.u.body + h->srvr_pos : NULL;
- ss->len = len;
- h->srvr_pos += len;
- return 0;
-}
-
-static void
-init_clnt_str(struct clnt_str *cs)
-{
- cs->data = NULL;
- cs->len = 0;
-}
-
-static void
-init_srvr_str(struct srvr_str *ss)
-{
- ss->data = NULL;
- ss->len = 0;
-}
-
-static int
-read_timed(struct tac_handle *h, void *buf, size_t len,
- const struct timeval *deadline)
-{
- char *ptr;
-
- ptr = (char *)buf;
- while (len > 0) {
- int n;
-
- n = read(h->fd, ptr, len);
- if (n == -1) {
- struct timeval tv;
- int nfds;
-
- if (errno != EAGAIN) {
- generr(h, "Network read error: %s",
- strerror(errno));
- return -1;
- }
-
- /* Wait until we can read more data. */
- gettimeofday(&tv, NULL);
- timersub(deadline, &tv, &tv);
- if (tv.tv_sec >= 0) {
- fd_set rfds;
-
- FD_ZERO(&rfds);
- FD_SET(h->fd, &rfds);
- nfds =
- select(h->fd + 1, &rfds, NULL, NULL, &tv);
- if (nfds == -1) {
- generr(h, "select: %s",
- strerror(errno));
- return -1;
- }
- } else
- nfds = 0;
- if (nfds == 0) {
- generr(h, "Network read timed out");
- return -1;
- }
- } else if (n == 0) {
- generr(h, "unexpected EOF from server");
- return -1;
- } else {
- ptr += n;
- len -= n;
- }
- }
- return 0;
-}
-
-/*
- * Receive a response from the server and decrypt it. Returns 0 on
- * success, or -1 on failure.
- */
-static int
-recv_msg(struct tac_handle *h)
-{
- struct timeval deadline;
- struct tac_msg *msg;
- size_t len;
-
- msg = &h->response;
- gettimeofday(&deadline, NULL);
- deadline.tv_sec += h->servers[h->cur_server].timeout;
-
- /* Read the message header and make sure it is reasonable. */
- if (read_timed(h, msg, HDRSIZE, &deadline) == -1)
- return -1;
- if (memcmp(msg->session_id, h->request.session_id,
- sizeof msg->session_id) != 0) {
- generr(h, "Invalid session ID in received message");
- return -1;
- }
- if (msg->type != h->request.type) {
- generr(h, "Invalid type in received message");
- return -1;
- }
- len = ntohl(msg->length);
- if (len > BODYSIZE) {
- generr(h, "Received message too large");
- return -1;
- }
- if (msg->seq_no != ++h->last_seq_no) {
- generr(h, "Invalid sequence number in received message");
- return -1;
- }
-
- /* Read the message body. */
- if (read_timed(h, msg->u.body, len, &deadline) == -1)
- return -1;
-
- /* Decrypt it. */
- crypt_msg(h, msg);
-
- /*
- * Turn off single-connection mode if the server isn't amenable
- * to it.
- */
- if (!(msg->flags & TAC_SINGLE_CONNECT))
- h->single_connect = 0;
- return 0;
-}
-
-static int
-save_str(struct tac_handle *h, struct clnt_str *cs, const void *data,
- size_t len)
-{
- free_str(cs);
- if (data != NULL && len != 0) {
- if ((cs->data = xmalloc(h, len)) == NULL)
- return -1;
- cs->len = len;
- memcpy(cs->data, data, len);
- }
- return 0;
-}
-
-/*
- * Send the current request, after encrypting it. Returns 0 on success,
- * or -1 on failure.
- */
-static int
-send_msg(struct tac_handle *h)
-{
- struct timeval deadline;
- struct tac_msg *msg;
- char *ptr;
- int len;
-
- if (h->last_seq_no & 1) {
- generr(h, "Attempt to send message out of sequence");
- return -1;
- }
-
- msg = &h->request;
- msg->seq_no = ++h->last_seq_no;
- if (msg->seq_no == 1)
- gen_session_id(msg);
- crypt_msg(h, msg);
-
- if (establish_connection(h) == -1)
- return -1;
-
- if (h->single_connect)
- msg->flags |= TAC_SINGLE_CONNECT;
- else
- msg->flags &= ~TAC_SINGLE_CONNECT;
- gettimeofday(&deadline, NULL);
- deadline.tv_sec += h->servers[h->cur_server].timeout;
- len = HDRSIZE + ntohl(msg->length);
- ptr = (char *)msg;
- while (len > 0) {
- int n;
-
- n = write(h->fd, ptr, len);
- if (n == -1) {
- struct timeval tv;
- int nfds;
-
- if (errno != EAGAIN) {
- generr(h, "Network write error: %s",
- strerror(errno));
- return -1;
- }
-
- /* Wait until we can write more data. */
- gettimeofday(&tv, NULL);
- timersub(&deadline, &tv, &tv);
- if (tv.tv_sec >= 0) {
- fd_set wfds;
-
- FD_ZERO(&wfds);
- FD_SET(h->fd, &wfds);
- nfds =
- select(h->fd + 1, NULL, &wfds, NULL, &tv);
- if (nfds == -1) {
- generr(h, "select: %s",
- strerror(errno));
- return -1;
- }
- } else
- nfds = 0;
- if (nfds == 0) {
- generr(h, "Network write timed out");
- return -1;
- }
- } else {
- ptr += n;
- len -= n;
- }
- }
- return 0;
-}
-
-/*
- * Destructively split a string into fields separated by white space.
- * `#' at the beginning of a field begins a comment that extends to the
- * end of the string. Fields may be quoted with `"'. Inside quoted
- * strings, the backslash escapes `\"' and `\\' are honored.
- *
- * Pointers to up to the first maxfields fields are stored in the fields
- * array. Missing fields get NULL pointers.
- *
- * The return value is the actual number of fields parsed, and is always
- * <= maxfields.
- *
- * On a syntax error, places a message in the msg string, and returns -1.
- */
-static int
-split(char *str, char *fields[], int maxfields, char *msg, size_t msglen)
-{
- char *p;
- int i;
- static const char ws[] = " \t";
-
- for (i = 0; i < maxfields; i++)
- fields[i] = NULL;
- p = str;
- i = 0;
- while (*p != '\0') {
- p += strspn(p, ws);
- if (*p == '#' || *p == '\0')
- break;
- if (i >= maxfields) {
- snprintf(msg, msglen, "line has too many fields");
- return -1;
- }
- if (*p == '"') {
- char *dst;
-
- dst = ++p;
- fields[i] = dst;
- while (*p != '"') {
- if (*p == '\\') {
- p++;
- if (*p != '"' && *p != '\\' &&
- *p != '\0') {
- snprintf(msg, msglen,
- "invalid `\\' escape");
- return -1;
- }
- }
- if (*p == '\0') {
- snprintf(msg, msglen,
- "unterminated quoted string");
- return -1;
- }
- *dst++ = *p++;
- }
- *dst = '\0';
- p++;
- if (*p != '\0' && strspn(p, ws) == 0) {
- snprintf(msg, msglen, "quoted string not"
- " followed by white space");
- return -1;
- }
- } else {
- fields[i] = p;
- p += strcspn(p, ws);
- if (*p != '\0')
- *p++ = '\0';
- }
- i++;
- }
- return i;
-}
-
-int
-tac_add_server(struct tac_handle *h, const char *host, int port,
- const char *secret, int timeout, int flags)
-{
- struct tac_server *srvp;
-
- if (h->num_servers >= MAXSERVERS) {
- generr(h, "Too many RADIUS servers specified");
- return -1;
- }
- srvp = &h->servers[h->num_servers];
-
- memset(&srvp->addr, 0, sizeof srvp->addr);
- srvp->addr.sin_len = sizeof srvp->addr;
- srvp->addr.sin_family = AF_INET;
- if (!inet_aton(host, &srvp->addr.sin_addr)) {
- struct hostent *hent;
-
- if ((hent = gethostbyname(host)) == NULL) {
- generr(h, "%s: host not found", host);
- return -1;
- }
- memcpy(&srvp->addr.sin_addr, hent->h_addr,
- sizeof srvp->addr.sin_addr);
- }
- srvp->addr.sin_port = htons(port != 0 ? port : TACPLUS_PORT);
- if ((srvp->secret = xstrdup(h, secret)) == NULL)
- return -1;
- srvp->timeout = timeout;
- srvp->flags = flags;
- h->num_servers++;
- return 0;
-}
-
-void
-tac_close(struct tac_handle *h)
-{
- int srv;
-
- if (h->fd != -1)
- close(h->fd);
- for (srv = 0; srv < h->num_servers; srv++) {
- memset(h->servers[srv].secret, 0,
- strlen(h->servers[srv].secret));
- free(h->servers[srv].secret);
- }
- free_str(&h->user);
- free_str(&h->port);
- free_str(&h->rem_addr);
- free_str(&h->data);
- free_str(&h->user_msg);
- free(h);
-}
-
-int
-tac_config(struct tac_handle *h, const char *path)
-{
- FILE *fp;
- char buf[MAXCONFLINE];
- int linenum;
- int retval;
-
- if (path == NULL)
- path = PATH_TACPLUS_CONF;
- if ((fp = fopen(path, "r")) == NULL) {
- generr(h, "Cannot open \"%s\": %s", path, strerror(errno));
- return -1;
- }
- retval = 0;
- linenum = 0;
- while (fgets(buf, sizeof buf, fp) != NULL) {
- int len;
- char *fields[4];
- int nfields;
- char msg[ERRSIZE];
- char *host;
- char *port_str;
- char *secret;
- char *timeout_str;
- char *options_str;
- char *end;
- unsigned long timeout;
- int port;
- int options;
-
- linenum++;
- len = strlen(buf);
- /* We know len > 0, else fgets would have returned NULL. */
- if (buf[len - 1] != '\n') {
- if (len == sizeof buf - 1)
- generr(h, "%s:%d: line too long", path,
- linenum);
- else
- generr(h, "%s:%d: missing newline", path,
- linenum);
- retval = -1;
- break;
- }
- buf[len - 1] = '\0';
-
- /* Extract the fields from the line. */
- nfields = split(buf, fields, 4, msg, sizeof msg);
- if (nfields == -1) {
- generr(h, "%s:%d: %s", path, linenum, msg);
- retval = -1;
- break;
- }
- if (nfields == 0)
- continue;
- if (nfields < 2) {
- generr(h, "%s:%d: missing shared secret", path,
- linenum);
- retval = -1;
- break;
- }
- host = fields[0];
- secret = fields[1];
- timeout_str = fields[2];
- options_str = fields[3];
-
- /* Parse and validate the fields. */
- host = strtok(host, ":");
- port_str = strtok(NULL, ":");
- if (port_str != NULL) {
- port = strtoul(port_str, &end, 10);
- if (port_str[0] == '\0' || *end != '\0') {
- generr(h, "%s:%d: invalid port", path,
- linenum);
- retval = -1;
- break;
- }
- } else
- port = 0;
- if (timeout_str != NULL) {
- timeout = strtoul(timeout_str, &end, 10);
- if (timeout_str[0] == '\0' || *end != '\0') {
- generr(h, "%s:%d: invalid timeout", path,
- linenum);
- retval = -1;
- break;
- }
- } else
- timeout = TIMEOUT;
- options = 0;
- if (options_str != NULL) {
- if (strcmp(options_str, "single-connection") == 0)
- options |= TAC_SRVR_SINGLE_CONNECT;
- else {
- generr(h, "%s:%d: invalid option \"%s\"",
- path, linenum, options_str);
- retval = -1;
- break;
- }
- };
-
- if (tac_add_server(h, host, port, secret, timeout,
- options) == -1) {
- char msg[ERRSIZE];
-
- strcpy(msg, h->errmsg);
- generr(h, "%s:%d: %s", path, linenum, msg);
- retval = -1;
- break;
- }
- }
- /* Clear out the buffer to wipe a possible copy of a shared secret */
- memset(buf, 0, sizeof buf);
- fclose(fp);
- return retval;
-}
-
-int
-tac_create_authen(struct tac_handle *h, int action, int type, int service)
-{
- struct tac_msg *msg;
- struct tac_authen_start *as;
-
- h->last_seq_no = 0;
-
- msg = &h->request;
- msg->type = TAC_AUTHEN;
- msg->version = authen_version(action, type);
- msg->flags = 0;
-
- as = &msg->u.authen_start;
- as->action = action;
- as->priv_lvl = TAC_PRIV_LVL_USER;
- as->authen_type = type;
- as->service = service;
-
- free_str(&h->user);
- free_str(&h->port);
- free_str(&h->rem_addr);
- free_str(&h->data);
- free_str(&h->user_msg);
-
- /* XXX - more to do */
- return 0;
-}
-
-void *
-tac_get_data(struct tac_handle *h, size_t *len)
-{
- return dup_str(h, &h->srvr_data, len);
-}
-
-char *
-tac_get_msg(struct tac_handle *h)
-{
- return (char *)dup_str(h, &h->srvr_msg, NULL);
-}
-
-/*
- * Create and initialize a tac_handle structure, and return it to the
- * caller. Can fail only if the necessary memory cannot be allocated.
- * In that case, it returns NULL.
- */
-struct tac_handle *
-tac_open(void)
-{
- struct tac_handle *h;
-
- h = (struct tac_handle *)malloc(sizeof(struct tac_handle));
- if (h != NULL) {
- h->fd = -1;
- h->num_servers = 0;
- h->cur_server = 0;
- h->errmsg[0] = '\0';
- init_clnt_str(&h->user);
- init_clnt_str(&h->port);
- init_clnt_str(&h->rem_addr);
- init_clnt_str(&h->data);
- init_clnt_str(&h->user_msg);
- init_srvr_str(&h->srvr_msg);
- init_srvr_str(&h->srvr_data);
- srandomdev();
- }
- return h;
-}
-
-int
-tac_send_authen(struct tac_handle *h)
-{
- struct tac_authen_reply *ar;
-
- if (h->last_seq_no == 0) { /* Authentication START packet */
- struct tac_authen_start *as;
-
- as = &h->request.u.authen_start;
- h->request.length =
- htonl(offsetof(struct tac_authen_start, rest[0]));
- if (add_str_8(h, &as->user_len, &h->user) == -1 ||
- add_str_8(h, &as->port_len, &h->port) == -1 ||
- add_str_8(h, &as->rem_addr_len, &h->rem_addr) == -1 ||
- add_str_8(h, &as->data_len, &h->data) == -1)
- return -1;
- } else { /* Authentication CONTINUE packet */
- struct tac_authen_cont *ac;
-
- ac = &h->request.u.authen_cont;
- ac->flags = 0;
- h->request.length =
- htonl(offsetof(struct tac_authen_cont, rest[0]));
- if (add_str_16(h, &ac->user_msg_len, &h->user_msg) == -1 ||
- add_str_16(h, &ac->data_len, &h->data) == -1)
- return -1;
- }
-
- /* Send the message and retrieve the reply. */
- if (send_msg(h) == -1 || recv_msg(h) == -1)
- return -1;
-
- /* Scan the optional fields in the reply. */
- ar = &h->response.u.authen_reply;
- h->srvr_pos = offsetof(struct tac_authen_reply, rest[0]);
- if (get_srvr_str(h, &h->srvr_msg, ntohs(ar->msg_len)) == -1 ||
- get_srvr_str(h, &h->srvr_data, ntohs(ar->data_len)) == -1 ||
- get_srvr_end(h) == -1)
- return -1;
-
- if (!h->single_connect &&
- ar->status != TAC_AUTHEN_STATUS_GETDATA &&
- ar->status != TAC_AUTHEN_STATUS_GETUSER &&
- ar->status != TAC_AUTHEN_STATUS_GETPASS)
- close_connection(h);
-
- return ar->flags << 8 | ar->status;
-}
-
-int
-tac_set_rem_addr(struct tac_handle *h, const char *addr)
-{
- return save_str(h, &h->rem_addr, addr, addr != NULL ? strlen(addr) : 0);
-}
-
-int
-tac_set_data(struct tac_handle *h, const void *data, size_t data_len)
-{
- return save_str(h, &h->data, data, data_len);
-}
-
-int
-tac_set_msg(struct tac_handle *h, const char *msg)
-{
- return save_str(h, &h->user_msg, msg, msg != NULL ? strlen(msg) : 0);
-}
-
-int
-tac_set_port(struct tac_handle *h, const char *port)
-{
- return save_str(h, &h->port, port, port != NULL ? strlen(port) : 0);
-}
-
-int
-tac_set_priv(struct tac_handle *h, int priv)
-{
- if (!(TAC_PRIV_LVL_MIN <= priv && priv <= TAC_PRIV_LVL_MAX)) {
- generr(h, "Attempt to set invalid privilege level");
- return -1;
- }
- h->request.u.authen_start.priv_lvl = priv;
- return 0;
-}
-
-int
-tac_set_user(struct tac_handle *h, const char *user)
-{
- return save_str(h, &h->user, user, user != NULL ? strlen(user) : 0);
-}
-
-const char *
-tac_strerror(struct tac_handle *h)
-{
- return h->errmsg;
-}
-
-static void *
-xmalloc(struct tac_handle *h, size_t size)
-{
- void *r;
-
- if ((r = malloc(size)) == NULL)
- generr(h, "Out of memory");
- return r;
-}
-
-static char *
-xstrdup(struct tac_handle *h, const char *s)
-{
- char *r;
-
- if ((r = strdup(s)) == NULL)
- generr(h, "Out of memory");
- return r;
-}
diff --git a/lib/libtacplus/taclib.h b/lib/libtacplus/taclib.h
deleted file mode 100644
index 0da1b0889ab39..0000000000000
--- a/lib/libtacplus/taclib.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _TACLIB_H_
-#define _TACLIB_H_
-
-#include <sys/types.h>
-
-struct tac_handle;
-
-/* Flags for tac_add_server(). */
-#define TAC_SRVR_SINGLE_CONNECT 0x04 /* Keep connection open for multiple
- sessions. */
-
-/* Disassembly of tac_send_authen() return value. */
-#define TAC_AUTHEN_STATUS(s) ((s) & 0xff)
-#define TAC_AUTHEN_NOECHO(s) ((s) & (1<<8))
-
-/* Privilege levels */
-#define TAC_PRIV_LVL_MIN 0x00
-#define TAC_PRIV_LVL_USER 0x01
-#define TAC_PRIV_LVL_ROOT 0x0f
-#define TAC_PRIV_LVL_MAX 0x0f
-
-/* Authentication actions */
-#define TAC_AUTHEN_LOGIN 0x01
-#define TAC_AUTHEN_CHPASS 0x02
-#define TAC_AUTHEN_SENDPASS 0x03
-#define TAC_AUTHEN_SENDAUTH 0x04
-
-/* Authentication types */
-#define TAC_AUTHEN_TYPE_ASCII 0x01
-#define TAC_AUTHEN_TYPE_PAP 0x02
-#define TAC_AUTHEN_TYPE_CHAP 0x03
-#define TAC_AUTHEN_TYPE_ARAP 0x04
-#define TAC_AUTHEN_TYPE_MSCHAP 0x05
-
-/* Authentication services */
-#define TAC_AUTHEN_SVC_NONE 0x00
-#define TAC_AUTHEN_SVC_LOGIN 0x01
-#define TAC_AUTHEN_SVC_ENABLE 0x02
-#define TAC_AUTHEN_SVC_PPP 0x03
-#define TAC_AUTHEN_SVC_ARAP 0x04
-#define TAC_AUTHEN_SVC_PT 0x05
-#define TAC_AUTHEN_SVC_RCMD 0x06
-#define TAC_AUTHEN_SVC_X25 0x07
-#define TAC_AUTHEN_SVC_NASI 0x08
-#define TAC_AUTHEN_SVC_FWPROXY 0x09
-
-/* Authentication reply status codes */
-#define TAC_AUTHEN_STATUS_PASS 0x01
-#define TAC_AUTHEN_STATUS_FAIL 0x02
-#define TAC_AUTHEN_STATUS_GETDATA 0x03
-#define TAC_AUTHEN_STATUS_GETUSER 0x04
-#define TAC_AUTHEN_STATUS_GETPASS 0x05
-#define TAC_AUTHEN_STATUS_RESTART 0x06
-#define TAC_AUTHEN_STATUS_ERROR 0x07
-#define TAC_AUTHEN_STATUS_FOLLOW 0x21
-
-__BEGIN_DECLS
-int tac_add_server(struct tac_handle *,
- const char *, int, const char *, int, int);
-void tac_close(struct tac_handle *);
-int tac_config(struct tac_handle *, const char *);
-int tac_create_authen(struct tac_handle *, int, int, int);
-void *tac_get_data(struct tac_handle *, size_t *);
-char *tac_get_msg(struct tac_handle *);
-struct tac_handle *tac_open(void);
-int tac_send_authen(struct tac_handle *);
-int tac_set_data(struct tac_handle *,
- const void *, size_t);
-int tac_set_msg(struct tac_handle *, const char *);
-int tac_set_port(struct tac_handle *, const char *);
-int tac_set_priv(struct tac_handle *, int);
-int tac_set_rem_addr(struct tac_handle *, const char *);
-int tac_set_user(struct tac_handle *, const char *);
-const char *tac_strerror(struct tac_handle *);
-__END_DECLS
-
-#endif /* _TACLIB_H_ */
diff --git a/lib/libtacplus/taclib_private.h b/lib/libtacplus/taclib_private.h
deleted file mode 100644
index 830fc921fbf3a..0000000000000
--- a/lib/libtacplus/taclib_private.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef TACLIB_PRIVATE_H
-#define TACLIB_PRIVATE_H
-
-#include "taclib.h"
-
-/* Defaults */
-#define PATH_TACPLUS_CONF "/etc/tacplus.conf"
-#define TACPLUS_PORT 49
-#define TIMEOUT 3 /* In seconds */
-
-/* Limits */
-#define BODYSIZE 8150 /* Maximum message body size */
-#define ERRSIZE 128 /* Maximum error message length */
-#define MAXCONFLINE 1024 /* Maximum config file line length */
-#define MAXSERVERS 10 /* Maximum number of servers to try */
-
-/* Protocol constants. */
-#define HDRSIZE 12 /* Size of message header */
-
-/* Protocol version number */
-#define TAC_VER_MAJOR 0xc /* Major version number */
-
-/* Protocol packet types */
-#define TAC_AUTHEN 0x01 /* Authentication */
-#define TAC_AUTHOR 0x02 /* Authorization */
-#define TAC_ACCT 0x03 /* Accouting */
-
-/* Protocol header flags */
-#define TAC_UNENCRYPTED 0x01
-#define TAC_SINGLE_CONNECT 0x04
-
-struct tac_server {
- struct sockaddr_in addr; /* Address of server */
- char *secret; /* Shared secret */
- int timeout; /* Timeout in seconds */
- int flags;
-};
-
-/*
- * An optional string of bytes specified by the client for inclusion in
- * a request. The data is always a dynamically allocated copy that
- * belongs to the library. It is copied into the request packet just
- * before sending the request.
- */
-struct clnt_str {
- void *data;
- size_t len;
-};
-
-/*
- * An optional string of bytes from a server response. The data resides
- * in the response packet itself, and must not be freed.
- */
-struct srvr_str {
- const void *data;
- size_t len;
-};
-
-struct tac_authen_start {
- u_int8_t action;
- u_int8_t priv_lvl;
- u_int8_t authen_type;
- u_int8_t service;
- u_int8_t user_len;
- u_int8_t port_len;
- u_int8_t rem_addr_len;
- u_int8_t data_len;
- unsigned char rest[1];
-};
-
-struct tac_authen_reply {
- u_int8_t status;
- u_int8_t flags;
- u_int16_t msg_len;
- u_int16_t data_len;
- unsigned char rest[1];
-};
-
-struct tac_authen_cont {
- u_int16_t user_msg_len;
- u_int16_t data_len;
- u_int8_t flags;
- unsigned char rest[1];
-};
-
-struct tac_msg {
- u_int8_t version;
- u_int8_t type;
- u_int8_t seq_no;
- u_int8_t flags;
- u_int8_t session_id[4];
- u_int32_t length;
- union {
- struct tac_authen_start authen_start;
- struct tac_authen_reply authen_reply;
- struct tac_authen_cont authen_cont;
- unsigned char body[BODYSIZE];
- } u;
-};
-
-struct tac_handle {
- int fd; /* Socket file descriptor */
- struct tac_server servers[MAXSERVERS]; /* Servers to contact */
- int num_servers; /* Number of valid server entries */
- int cur_server; /* Server we are currently using */
- int single_connect; /* Use a single connection */
- int last_seq_no;
- char errmsg[ERRSIZE]; /* Most recent error message */
-
- struct clnt_str user;
- struct clnt_str port;
- struct clnt_str rem_addr;
- struct clnt_str data;
- struct clnt_str user_msg;
-
- struct tac_msg request;
- struct tac_msg response;
-
- int srvr_pos; /* Scan position in response body */
- struct srvr_str srvr_msg;
- struct srvr_str srvr_data;
-};
-
-#endif
diff --git a/lib/libtacplus/tacplus.conf.5 b/lib/libtacplus/tacplus.conf.5
deleted file mode 100644
index a61da844848b5..0000000000000
--- a/lib/libtacplus/tacplus.conf.5
+++ /dev/null
@@ -1,114 +0,0 @@
-.\" Copyright 1998 Juniper Networks, Inc.
-.\" 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 29, 1998
-.Dt TACPLUS.CONF 5
-.Os FreeBSD
-.Sh NAME
-.Nm tacplus.conf
-.Nd TACACS+ client configuration file
-.Sh SYNOPSIS
-.Pa /etc/tacplus.conf
-.Sh DESCRIPTION
-.Nm
-contains the information necessary to configure the TACACS+ client
-library. It is parsed by
-.Xr tac_config 3 .
-The file contains one or more lines of text, each describing a
-single TACACS+ server which is to be used by the library. Leading
-white space is ignored, as are empty lines and lines containing
-only comments.
-.Pp
-A TACACS+ server is described by two to four fields on a line. The
-fields are separated by white space. The
-.Ql #
-character at the beginning of a field begins a comment, which extends
-to the end of the line. A field may be enclosed in double quotes,
-in which case it may contain white space and/or begin with the
-.Ql #
-character. Within a quoted string, the double quote character can
-be represented by
-.Ql \e\&" ,
-and the backslash can be represented by
-.Ql \e\e .
-No other escape sequences are supported.
-.Pp
-The first field specifies
-the server host, either as a fully qualified domain name or as a
-dotted-quad IP address. The host may optionally be followed by a
-.Ql \&:
-and a numeric port number, without intervening white space. If the
-port specification is omitted, it defaults to 49, the standard TACACS+
-port.
-.Pp
-The second field contains the shared secret, which should be known
-only to the client and server hosts. It is an arbitrary string
-of characters, though it must be enclosed in double quotes if it
-contains white space or is empty. An empty secret disables the
-normal encryption mechanism, causing all data to cross the network in
-cleartext.
-.Pp
-The third field contains a decimal integer specifying the timeout
-in seconds for communicating with the server. The timeout applies
-separately to each connect, write, and read operation. If this field
-is omitted, it defaults to 3 seconds.
-.Pp
-The optional fourth field may contain the string
-.Ql single-connection .
-If this option is included, the library will attempt to negotiate
-with the server to keep the TCP connection open for multiple
-sessions. Some older TACACS+ servers become confused if this option
-is specified.
-.Pp
-Up to 10 TACACS+ servers may be specified. The servers are tried in
-order, until a valid response is received or the list is exhausted.
-.Pp
-The standard location for this file is
-.Pa /etc/tacplus.conf .
-An alternate pathname may be specified in the call to
-.Xr tac_config 3 .
-Since the file contains sensitive information in the form of the
-shared secrets, it should not be readable except by root.
-.Sh FILES
-.Pa /etc/tacplus.conf
-.Sh EXAMPLES
-.Bd -literal
-# A simple entry using all the defaults:
-tacserver.domain.com OurLittleSecret
-
-# A server using a non-standard port, with an increased timeout and
-# the "single-connection" option.
-auth.domain.com:4333 "Don't tell!!" 15 single-connection
-
-# A server specified by its IP address:
-192.168.27.81 $X*#..38947ax-+=
-.Ed
-.Sh SEE ALSO
-.Xr libtacplus 3
-.Sh AUTHORS
-This documentation was written by
-.An John Polstra ,
-and donated to the FreeBSD project by Juniper Networks, Inc.
diff --git a/lib/libtelnet/getent.c b/lib/libtelnet/getent.c
index 0956a2abd381a..e87bf667cec93 100644
--- a/lib/libtelnet/getent.c
+++ b/lib/libtelnet/getent.c
@@ -58,7 +58,7 @@ char *cp, *name;
#ifndef SOLARIS
/*ARGSUSED*/
char *
-Getstr(id, cpp)
+getstr(id, cpp)
char *id, **cpp;
{
# ifdef HAS_CGETENT
diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h
index dda01c17ad96d..2aa2ad030a618 100644
--- a/lib/libutil/libutil.h
+++ b/lib/libutil/libutil.h
@@ -18,7 +18,7 @@
* 5. Modifications may be freely made to this file providing the above
* conditions are met.
*
- * $Id: libutil.h,v 1.20 1998/10/09 07:32:38 jkh Exp $
+ * $Id: libutil.h,v 1.19 1998/10/09 07:28:14 jkh Exp $
*/
#ifndef _LIBUTIL_H_
@@ -39,7 +39,7 @@ struct winsize;
struct utmp;
__BEGIN_DECLS
-void setproctitle __P((const char *_fmt, ...)) __printf0like(1, 2);
+void setproctitle __P((const char *_fmt, ...));
void login __P((struct utmp *_ut));
int login_tty __P((int _fd));
int logout __P((char *_line));
diff --git a/lib/libutil/property.3 b/lib/libutil/property.3
index eebdde66cca07..bcd3556116e25 100644
--- a/lib/libutil/property.3
+++ b/lib/libutil/property.3
@@ -23,7 +23,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id: property.3,v 1.3 1998/10/14 11:04:36 jkh Exp $
+.\" $Id: property.3,v 1.2 1998/10/09 07:33:58 jkh Exp $
.\" "
.Dd October 7, 1998
.Os
@@ -65,7 +65,9 @@ pairs from the file descriptor passed in
.Fa fd
and returns the head of a new property list, assuming that the
file's contents have been parsed properly, or NULL in case
-of error.
+of error. The property list pointer should be passed to
+.Fn properties_free
+when no longer needed.
.Pp
.Fn property_find
Returns the associated value string for the property named
@@ -76,22 +78,7 @@ if found, otherwise NULL.
is used to free the structure returned by
.Fn properties_read
when it is no longer needed.
-.Pp
-.Sh FILE FORMAT
-Each property in the file is assumed to have the format of
-.Fa name = value
-where
-.Fa name
-is an alphanumeric string (and any punctuation not including the `=' character)
-and
-.Fa value
-is an arbitary string of text terminated by a newline character. If newlines
-are desired, the entire value should be enclosed in { } (curly-bracket)
-characters. Any line beginning with a # or ; character is assumed to
-be a comment and will be ignored.
.Sh SEE ALSO
.Xr auth_getval 3
.Sh BUGS
Simplistic.
-.Sh AUTHOR
-Jordan Hubbard
diff --git a/lib/libutil/property.c b/lib/libutil/property.c
index 23714a0c3dafa..211450c80464b 100644
--- a/lib/libutil/property.c
+++ b/lib/libutil/property.c
@@ -35,7 +35,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <err.h>
#include <sys/types.h>
#include <libutil.h>
@@ -63,7 +62,7 @@ properties_read(int fd)
char buf[BUFSIZ * 4];
int bp, n, v, max;
enum { LOOK, COMMENT, NAME, VALUE, MVALUE, COMMIT, FILL, STOP } state;
- int ch = 0, blevel = 0;
+ int ch = 0;
n = v = bp = max = 0;
head = ptr = NULL;
@@ -136,10 +135,8 @@ properties_read(int fd)
case VALUE:
if (v == 0 && isspace(ch))
continue;
- else if (ch == '{') {
+ else if (ch == '{')
state = MVALUE;
- ++blevel;
- }
else if (ch == '\n' || !ch) {
hold_v[v] = '\0';
v = n = 0;
@@ -159,20 +156,16 @@ properties_read(int fd)
case MVALUE:
/* multiline value */
if (v >= MAX_VALUE) {
- warn("properties_read: value exceeds max length");
state = COMMENT;
n = v = 0;
}
- else if (ch == '}' && !--blevel) {
+ else if (ch == '}') {
hold_v[v] = '\0';
v = n = 0;
state = COMMIT;
}
- else {
+ else
hold_v[v++] = ch;
- if (ch == '{')
- ++blevel;
- }
break;
case COMMIT:
diff --git a/lib/libutil/setproctitle.c b/lib/libutil/setproctitle.c
index 3bce42074da8f..217df06ac8c0e 100644
--- a/lib/libutil/setproctitle.c
+++ b/lib/libutil/setproctitle.c
@@ -14,7 +14,7 @@
* 3. Absolutely no warranty of function or purpose is made by the author
* Peter Wemm.
*
- * $Id: setproctitle.c,v 1.7 1998/04/28 07:02:33 dg Exp $
+ * $Id: setproctitle.c,v 1.6 1998/04/28 06:59:14 dg Exp $
*/
#include <sys/types.h>
@@ -72,8 +72,8 @@ setproctitle(fmt, va_alist)
static char buf[SPT_BUFSIZE];
static char *ps_argv[2];
va_list ap;
+ int mib[2];
size_t len;
- unsigned long ul_ps_strings;
#if defined(__STDC__)
va_start(ap, fmt);
@@ -104,11 +104,12 @@ setproctitle(fmt, va_alist)
va_end(ap);
if (ps_strings == NULL) {
- len = sizeof(ul_ps_strings);
- if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL,
- 0) == -1)
- ul_ps_strings = PS_STRINGS;
- ps_strings = (struct ps_strings *)ul_ps_strings;
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PS_STRINGS;
+ len = sizeof(ps_strings);
+ if (sysctl(mib, 2, &ps_strings, &len, NULL, 0) < 0 ||
+ ps_strings == NULL)
+ ps_strings = PS_STRINGS;
}
/* PS_STRINGS points to zeroed memory on a style #2 kernel */
diff --git a/lib/libz/ChangeLog b/lib/libz/ChangeLog
index 57386a26f485d..95d3c3b8b2e00 100644
--- a/lib/libz/ChangeLog
+++ b/lib/libz/ChangeLog
@@ -1,73 +1,6 @@
ChangeLog file for zlib
-Changes in 1.1.3 (9 July 1998)
-- fix "an inflate input buffer bug that shows up on rare but persistent
- occasions" (Mark)
-- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
-- fix gzseek(..., SEEK_SET) in write mode
-- fix crc check after a gzeek (Frank Faubert)
-- fix miniunzip when the last entry in a zip file is itself a zip file
- (J Lillge)
-- add contrib/asm586 and contrib/asm686 (Brian Raiter)
- See http://www.muppetlabs.com/~breadbox/software/assembly.html
-- add support for Delphi 3 in contrib/delphi (Bob Dellaca)
-- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
-- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
-- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
-- added a FAQ file
-
-- Support gzdopen on Mac with Metrowerks (Jason Linhart)
-- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart)
-- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young)
-- avoid some warnings with Borland C (Tom Tanner)
-- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant)
-- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant)
-- allow several arguments to configure (Tim Mooney, Frodo Looijaard)
-- use libdir and includedir in Makefile.in (Tim Mooney)
-- support shared libraries on OSF1 V4 (Tim Mooney)
-- remove so_locations in "make clean" (Tim Mooney)
-- fix maketree.c compilation error (Glenn, Mark)
-- Python interface to zlib now in Python 1.5 (Jeremy Hylton)
-- new Makefile.riscos (Rich Walker)
-- initialize static descriptors in trees.c for embedded targets (Nick Smith)
-- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith)
-- add the OS/2 files in Makefile.in too (Andrew Zabolotny)
-- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane)
-- fix maketree.c to allow clean compilation of inffixed.h (Mark)
-- fix parameter check in deflateCopy (Gunther Nikl)
-- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler)
-- Many portability patches by Christian Spieler:
- . zutil.c, zutil.h: added "const" for zmem*
- . Make_vms.com: fixed some typos
- . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists
- . msdos/Makefile.msc: remove "default rtl link library" info from obj files
- . msdos/Makefile.*: use model-dependent name for the built zlib library
- . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc:
- new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT)
-- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane)
-- replace __far with _far for better portability (Christian Spieler, Tom Lane)
-- fix test for errno.h in configure (Tim Newsham)
-
-Changes in 1.1.2 (19 March 98)
-- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant)
- See http://www.winimage.com/zLibDll/unzip.html
-- preinitialize the inflate tables for fixed codes, to make the code
- completely thread safe (Mark)
-- some simplifications and slight speed-up to the inflate code (Mark)
-- fix gzeof on non-compressed files (Allan Schrum)
-- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs)
-- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn)
-- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny)
-- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori)
-- do not wrap extern "C" around system includes (Tom Lane)
-- mention zlib binding for TCL in README (Andreas Kupries)
-- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert)
-- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson)
-- allow "configure --prefix $HOME" (Tim Mooney)
-- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson)
-- move Makefile.sas to amiga/Makefile.sas
-
Changes in 1.1.1 (27 Feb 98)
- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson)
- remove block truncation heuristic which had very marginal effect for zlib
@@ -205,7 +138,7 @@ Changes in 1.0.6 (19 Jan 1998)
- allow compilation with ANSI keywords only enabled for TurboC in large model
- avoid "versionString"[0] (Borland bug)
- add NEED_DUMMY_RETURN for Borland
-- use variable z_verbose for tracing in debug mode (L. Peter Deutsch).
+- use variable z_verbose for tracing in debug mode (Peter Deutsch).
- allow compilation with CC
- defined STDC for OS/2 (David Charlap)
- limit external names to 8 chars for MVS (Thomas Lund)
diff --git a/lib/libz/FAQ b/lib/libz/FAQ
deleted file mode 100644
index 0feb6d3e9bbbe..0000000000000
--- a/lib/libz/FAQ
+++ /dev/null
@@ -1,72 +0,0 @@
-
- Frequently Asked Questions about zlib
-
-
-If your question is not there, please check the zlib home page
-http://www.cdrom.com/pub/infozip/zlib/ which may have more recent information.
-
-
-1) I need a Windows DLL
-2) I need a Visual Basic interface to zlib
-3) compress() returns Z_BUF_ERROR
-4) deflate or inflate returns Z_BUF_ERROR
-5) Where is the zlib documentation (man pages, etc...)?
-6) Why don't you use GNU autoconf, libtool, etc...?
-7) There is a bug in zlib.
-8) I get "undefined reference to gzputc"
-
-
-
-1) I need a Windows DLL
-
- The zlib sources can be compiled without change to produce a DLL.
- If you want a precompiled DLL, see http://www.winimage.com/zLibDll
-
-
-2) I need a Visual Basic interface to zlib
-
- See http://www.tcfb.com/dowseware/cmp-z-it.zip
- http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm
- and contrib/visual-basic.txt
-
-3) compress() returns Z_BUF_ERROR
-
- Make sure that before the call of compress, the length of the
- compressed buffer is equal to the total size of the compressed buffer
- and not zero. For Visual Basic, check that this parameter is passed
- by reference ("as any"), not by value ("as long").
-
-
-4) deflate or inflate returns Z_BUF_ERROR
-
- Make sure that before the call avail_in and avail_out are not zero.
-
-
-5) Where is the zlib documentation (man pages, etc...)?
-
- It's in zlib.h for the moment. Volunteers to transform this
- to man pages, please contact jloup@gzip.org. Examples of zlib usage
- are in the files example.c and minigzip.c.
-
-
-6) Why don't you use GNU autoconf, libtool, etc...?
-
- Because we would like to keep zlib as a very small and simple package.
- zlib is rather portable and doesn't need much configuration.
-
-
-7) There is a bug in zlib.
-
- Most of the time, such problems are due to an incorrect usage
- of zlib. Please try to reproduce the problem with a small
- program and send us the corresponding source at zlib@quest.jpl.nasa.gov
- Do not send multi-megabyte data files without prior agreement.
-
-
-8) I get "undefined reference to gzputc"
-
- If "make test" produces something like
- example.o(.text+0x174):
- check that you don't have old files libz.* in /usr/lib, /usr/local/lib
- or /usr/X11R6/lib. Remove old versions then do "make install".
-
diff --git a/lib/libz/README b/lib/libz/README
index 8ff458799b957..acaea4fc8eae7 100644
--- a/lib/libz/README
+++ b/lib/libz/README
@@ -1,4 +1,4 @@
-zlib 1.1.3 is a general purpose data compression library. All the code
+zlib 1.1.1 is a general purpose data compression library. All the code
is thread safe. The data format used by the zlib library
is described by RFCs (Request for Comments) 1950 to 1952 in the files
ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
@@ -14,41 +14,26 @@ except example.c and minigzip.c.
To compile all files and run the test program, follow the instructions
given at the top of Makefile. In short "make test; make install"
-should work for most machines. For Unix: "configure; make test; make install"
-For MSDOS, use one of the special makefiles such as Makefile.msc.
-For VMS, use Make_vms.com or descrip.mms.
+should work for most machines. For MSDOS, use one of the special
+makefiles such as Makefile.msc; for VMS, use Make_vms.com or descrip.mms.
-Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov>, or to
-Gilles Vollant <info@winimage.com> for the Windows DLL version.
+Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov> or,
+if this fails, to the addresses given below in the Copyright section.
The zlib home page is http://www.cdrom.com/pub/infozip/zlib/
The official zlib ftp site is ftp://ftp.cdrom.com/pub/infozip/zlib/
-Before reporting a problem, please check those sites to verify that
-you have the latest version of zlib; otherwise get the latest version and
-check whether the problem still exists or not.
-
-Mark Nelson <markn@tiny.com> wrote an article about zlib for the Jan. 1997
-issue of Dr. Dobb's Journal; a copy of the article is available in
+Mark Nelson wrote an article about zlib for the Jan. 1997 issue of
+Dr. Dobb's Journal; a copy of the article is available in
http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm
-The changes made in version 1.1.3 are documented in the file ChangeLog.
-The main changes since 1.1.2 are:
-
-- fix "an inflate input buffer bug that shows up on rare but persistent
- occasions" (Mark)
-- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
-- fix gzseek(..., SEEK_SET) in write mode
-- fix crc check after a gzeek (Frank Faubert)
-- fix miniunzip when the last entry in a zip file is itself a zip file
- (J Lillge)
-- add contrib/asm586 and contrib/asm686 (Brian Raiter)
- See http://www.muppetlabs.com/~breadbox/software/assembly.html
-- add support for Delphi 3 in contrib/delphi (Bob Dellaca)
-- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
-- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
-- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
-- added a FAQ file
-
-plus many changes for portability.
+The changes made in version 1.1.1 are documented in the file ChangeLog.
+The main changes since 1.1.0 are:
+
+- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson)
+- remove block truncation heuristic which had very marginal effect for zlib
+ (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the
+ compression ratio on some files. This also allows inlining _tr_tally for
+ matches in deflate_slow.
+
Unsupported third party contributions are provided in directory "contrib".
@@ -61,16 +46,12 @@ is in the CPAN (Comprehensive Perl Archive Network) sites, such as:
ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib*
A Python interface to zlib written by A.M. Kuchling <amk@magnet.com>
-is available in Python 1.5 and later versions, see
-http://www.python.org/doc/lib/module-zlib.html
-
-A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com>
-is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html
+is available from the Python Software Association sites, such as:
+ftp://ftp.python.org/pub/python/contrib/Encoding/zlib*.tar.gz
-An experimental package to read and write files in .zip format,
-written on top of zlib by Gilles Vollant <info@winimage.com>, is
-available at http://www.winimage.com/zLibDll/unzip.html
-and also in the contrib/minizip directory of zlib.
+An experimental package to read files in .zip format, written on top of
+zlib by Gilles Vollant <info@winimage.com>, is available at
+http://www.winimage.com/zLibDll/unzip.html
Notes for some targets:
@@ -83,8 +64,8 @@ Notes for some targets:
From Visual Basic, you can call the DLL functions which do not take
a structure as argument: compress, uncompress and all gz* functions.
- See contrib/visual-basic.txt for more information, or get
- http://www.tcfb.com/dowseware/cmp-z-it.zip
+ See contrib/visual-basic.txt for more information.
+ I don't know how to handle structures in Visual Basic, sorry.
- For 64-bit Irix, deflate.c must be compiled without any optimization.
With -O, one libpng test fails. The test works in 32 bit mode (with
@@ -93,25 +74,23 @@ Notes for some targets:
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1
it works when compiled with cc.
-- on Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1
- is necessary to get gzprintf working correctly. This is done by configure.
-
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works
with other compilers. Use "make test" to check your compiler.
+- For shared memory multiprocessors, the decompression code assumes that
+ writes to pointers are atomic. Also the functions zalloc and zfree passed
+ to deflateInit must be multi-threaded in this case.
+
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
- For Turbo C the small model is supported only with reduced performance to
avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
-- For PalmOs, see http://www.cs.uit.no/~perm/PASTA/pilot/software.html
- Per Harald Myrvang <perm@stud.cs.uit.no>
-
Acknowledgments:
The deflate format used by zlib was defined by Phil Katz. The deflate
- and zlib specifications were written by L. Peter Deutsch. Thanks to all the
+ and zlib specifications were written by Peter Deutsch. Thanks to all the
people who reported problems and suggested various improvements in zlib;
they are too numerous to cite here.
diff --git a/lib/libz/adler32.c b/lib/libz/adler32.c
index 16cf9a703f7cd..b1f71ce05fe69 100644
--- a/lib/libz/adler32.c
+++ b/lib/libz/adler32.c
@@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* @(#) $Id$ */
+/* $FreeBSD$ */
#include "zlib.h"
diff --git a/lib/libz/compress.c b/lib/libz/compress.c
index 1cee470913d75..31c51e611659d 100644
--- a/lib/libz/compress.c
+++ b/lib/libz/compress.c
@@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* @(#) $Id$ */
+/* $FreeBSD$ */
#include "zlib.h"
diff --git a/lib/libz/crc32.c b/lib/libz/crc32.c
index a91101a81c6ae..2e98580b0b956 100644
--- a/lib/libz/crc32.c
+++ b/lib/libz/crc32.c
@@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* @(#) $Id$ */
+/* $FreeBSD$ */
#include "zlib.h"
diff --git a/lib/libz/deflate.c b/lib/libz/deflate.c
index cfa05059d3ff2..dc8c76c51372a 100644
--- a/lib/libz/deflate.c
+++ b/lib/libz/deflate.c
@@ -47,12 +47,12 @@
*
*/
-/* @(#) $Id: deflate.c,v 1.1.1.3 1999/01/10 09:46:53 peter Exp $ */
+/* $FreeBSD$ */
#include "deflate.h"
const char deflate_copyright[] =
- " deflate 1.1.3 Copyright 1995-1998 Jean-loup Gailly ";
+ " deflate 1.1.1 Copyright 1995-1998 Jean-loup Gailly ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -608,13 +608,11 @@ int ZEXPORT deflateCopy (dest, source)
deflate_state *ss;
ushf *overlay;
+ ss = source->state;
- if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
+ if (source == Z_NULL || dest == Z_NULL || ss == Z_NULL) {
return Z_STREAM_ERROR;
}
-
- ss = source->state;
-
*dest = *source;
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
diff --git a/lib/libz/deflate.h b/lib/libz/deflate.h
index 112a15e0f443e..5cf65ec89f1ec 100644
--- a/lib/libz/deflate.h
+++ b/lib/libz/deflate.h
@@ -8,7 +8,7 @@
subject to change. Applications should only use zlib.h.
*/
-/* @(#) $Id: deflate.h,v 1.1.1.3 1999/01/10 09:46:53 peter Exp $ */
+/* $FreeBSD$ */
#ifndef _DEFLATE_H
#define _DEFLATE_H
@@ -230,12 +230,12 @@ typedef struct internal_state {
ulg opt_len; /* bit length of current block with optimal trees */
ulg static_len; /* bit length of current block with static trees */
+ ulg compressed_len; /* total bit length of compressed file */
uInt matches; /* number of string matches in current block */
int last_eob_len; /* bit length of EOB code for last block */
#ifdef DEBUG
- ulg compressed_len; /* total bit length of compressed file mod 2^32 */
- ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
+ ulg bits_sent; /* bit length of the compressed data */
#endif
ush bi_buf;
@@ -268,7 +268,7 @@ typedef struct internal_state {
/* in trees.c */
void _tr_init OF((deflate_state *s));
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
-void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
+ulg _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof));
void _tr_align OF((deflate_state *s));
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
diff --git a/lib/libz/example.c b/lib/libz/example.c
index ed718cbe5f5b5..e313c552d5812 100644
--- a/lib/libz/example.c
+++ b/lib/libz/example.c
@@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* @(#) $Id: example.c,v 1.1.1.3 1999/01/10 09:46:54 peter Exp $ */
+/* $FreeBSD$ */
#include <stdio.h>
#include "zlib.h"
@@ -15,12 +15,6 @@
extern void exit OF((int));
#endif
-#if defined(VMS) || defined(RISCOS)
-# define TESTFILE "foo-gz"
-#else
-# define TESTFILE "foo.gz"
-#endif
-
#define CHECK_ERR(err, msg) { \
if (err != Z_OK) { \
fprintf(stderr, "%s error: %d\n", msg, err); \
@@ -77,7 +71,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
fprintf(stderr, "bad uncompress\n");
exit(1);
} else {
- printf("uncompress(): %s\n", (char *)uncompr);
+ printf("uncompress(): %s\n", uncompr);
}
}
@@ -85,8 +79,8 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
* Test read/write of .gz files
*/
void test_gzio(out, in, uncompr, uncomprLen)
- const char *out; /* compressed output file */
- const char *in; /* compressed input file */
+ const char *out; /* output file */
+ const char *in; /* input file */
Byte *uncompr;
int uncomprLen;
{
@@ -127,13 +121,13 @@ void test_gzio(out, in, uncompr, uncomprLen)
fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
exit(1);
} else {
- printf("gzread(): %s\n", (char *)uncompr);
+ printf("gzread(): %s\n", uncompr);
}
pos = gzseek(file, -8L, SEEK_CUR);
if (pos != 6 || gztell(file) != pos) {
fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
- (long)pos, (long)gztell(file));
+ pos, gztell(file));
exit(1);
}
@@ -152,7 +146,7 @@ void test_gzio(out, in, uncompr, uncomprLen)
fprintf(stderr, "bad gzgets after gzseek\n");
exit(1);
} else {
- printf("gzgets() after gzseek: %s\n", (char *)uncompr);
+ printf("gzgets() after gzseek: %s\n", uncompr);
}
gzclose(file);
@@ -233,7 +227,7 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
fprintf(stderr, "bad inflate\n");
exit(1);
} else {
- printf("inflate(): %s\n", (char *)uncompr);
+ printf("inflate(): %s\n", uncompr);
}
}
@@ -412,7 +406,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
- printf("after inflateSync(): hel%s\n", (char *)uncompr);
+ printf("after inflateSync(): hel%s\n", uncompr);
}
/* ===========================================================================
@@ -498,7 +492,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
fprintf(stderr, "bad inflate with dict\n");
exit(1);
} else {
- printf("inflate with dictionary: %s\n", (char *)uncompr);
+ printf("inflate with dictionary: %s\n", uncompr);
}
}
@@ -534,8 +528,8 @@ int main(argc, argv)
}
test_compress(compr, comprLen, uncompr, uncomprLen);
- test_gzio((argc > 1 ? argv[1] : TESTFILE),
- (argc > 2 ? argv[2] : TESTFILE),
+ test_gzio((argc > 1 ? argv[1] : "foo.gz"),
+ (argc > 2 ? argv[2] : "foo.gz"),
uncompr, (int)uncomprLen);
test_deflate(compr, comprLen);
diff --git a/lib/libz/gzio.c b/lib/libz/gzio.c
index b2090b8094803..e3782d582712b 100644
--- a/lib/libz/gzio.c
+++ b/lib/libz/gzio.c
@@ -5,7 +5,7 @@
* Compile this file with -DNO_DEFLATE to avoid the compression code.
*/
-/* @(#) $Id: gzio.c,v 1.1.1.3 1999/01/10 09:46:54 peter Exp $ */
+/* $FreeBSD$ */
#include <stdio.h>
@@ -13,16 +13,8 @@
struct internal_state {int dummy;}; /* for buggy compilers */
-#ifndef Z_BUFSIZE
-# ifdef MAXSEG_64K
-# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
-# else
-# define Z_BUFSIZE 16384
-# endif
-#endif
-#ifndef Z_PRINTF_BUFSIZE
-# define Z_PRINTF_BUFSIZE 4096
-#endif
+#define Z_BUFSIZE 16384
+#define Z_PRINTF_BUFSIZE 4096
#define ALLOC(size) malloc(size)
#define TRYFREE(p) {if (p) free(p);}
@@ -140,12 +132,8 @@ local gzFile gz_open (path, mode, fd)
s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
err = inflateInit2(&(s->stream), -MAX_WBITS);
- /* windowBits is passed < 0 to tell that there is no zlib header.
- * Note that in this case inflate *requires* an extra "dummy" byte
- * after the compressed stream in order to complete decompression and
- * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
- * present after the compressed stream.
- */
+ /* windowBits is passed < 0 to tell that there is no zlib header */
+
if (err != Z_OK || s->inbuf == Z_NULL) {
return destroy(s), (gzFile)Z_NULL;
}
@@ -391,7 +379,6 @@ int ZEXPORT gzread (file, buf, len)
len -= s->stream.avail_out;
s->stream.total_in += (uLong)len;
s->stream.total_out += (uLong)len;
- if (len == 0) s->z_eof = 1;
return (int)len;
}
if (s->stream.avail_in == 0 && !s->z_eof) {
@@ -414,14 +401,10 @@ int ZEXPORT gzread (file, buf, len)
s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
start = s->stream.next_out;
- if (getLong(s) != s->crc) {
+ if (getLong(s) != s->crc || getLong(s) != s->stream.total_out) {
s->z_err = Z_DATA_ERROR;
} else {
- (void)getLong(s);
- /* The uncompressed length returned by above getlong() may
- * be different from s->stream.total_out) in case of
- * concatenated .gz files. Check for such files:
- */
+ /* Check for concatenated .gz files: */
check_header(s);
if (s->z_err == Z_OK) {
uLong total_in = s->stream.total_in;
@@ -589,7 +572,7 @@ int ZEXPORT gzputs(file, s)
gzFile file;
const char *s;
{
- return gzwrite(file, (char*)s, (unsigned)strlen(s));
+ return gzwrite(file, (const voidp)s, (unsigned)strlen(s));
}
@@ -674,7 +657,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
return -1L;
#else
if (whence == SEEK_SET) {
- offset -= s->stream.total_in;
+ offset -= s->stream.total_out;
}
if (offset < 0) return -1L;
@@ -749,7 +732,6 @@ int ZEXPORT gzrewind (file)
s->z_eof = 0;
s->stream.avail_in = 0;
s->stream.next_in = s->inbuf;
- s->crc = crc32(0L, Z_NULL, 0);
if (s->startpos == 0) { /* not a compressed file */
rewind(s->file);
@@ -798,8 +780,7 @@ local void putLong (file, x)
}
/* ===========================================================================
- Reads a long in LSB order from the given gz_stream. Sets z_err in case
- of error.
+ Reads a long in LSB order from the given gz_stream. Sets
*/
local uLong getLong (s)
gz_stream *s;
diff --git a/lib/libz/infblock.c b/lib/libz/infblock.c
index f4920faa5ea06..17943ab7939b9 100644
--- a/lib/libz/infblock.c
+++ b/lib/libz/infblock.c
@@ -11,10 +11,6 @@
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
-/* simplify the use of the inflate_huft type with some defines */
-#define exop word.what.Exop
-#define bits word.what.Bits
-
/* Table for deflate from PKZIP's appnote.txt. */
local const uInt border[] = { /* Order of the bit length code lengths */
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
@@ -268,8 +264,8 @@ int r;
t = s->sub.trees.bb;
NEEDBITS(t)
h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
- t = h->bits;
- c = h->base;
+ t = h->word.what.Bits;
+ c = h->more.Base;
if (c < 16)
{
DUMPBITS(t)
@@ -345,6 +341,13 @@ int r;
s->mode = TYPE;
break;
}
+ if (k > 7) /* return unused byte, if any */
+ {
+ Assert(k < 16, "inflate_codes grabbed too many bytes")
+ k -= 8;
+ n++;
+ p--; /* can always return one */
+ }
s->mode = DRY;
case DRY:
FLUSH
diff --git a/lib/libz/infcodes.c b/lib/libz/infcodes.c
index d4e5ee9a55439..181aa53896397 100644
--- a/lib/libz/infcodes.c
+++ b/lib/libz/infcodes.c
@@ -11,6 +11,8 @@
#include "inffast.h"
/* simplify the use of the inflate_huft type with some defines */
+#define base more.Base
+#define next more.Next
#define exop word.what.Exop
#define bits word.what.Bits
@@ -143,7 +145,7 @@ int r;
if ((e & 64) == 0) /* next table */
{
c->sub.code.need = e;
- c->sub.code.tree = t + t->base;
+ c->sub.code.tree = t->next;
break;
}
if (e & 32) /* end of block */
@@ -181,7 +183,7 @@ int r;
if ((e & 64) == 0) /* next table */
{
c->sub.code.need = e;
- c->sub.code.tree = t + t->base;
+ c->sub.code.tree = t->next;
break;
}
c->mode = BADCODE; /* invalid code */
@@ -221,13 +223,6 @@ int r;
c->mode = START;
break;
case WASH: /* o: got eob, possibly more output */
- if (k > 7) /* return unused byte, if any */
- {
- Assert(k < 16, "inflate_codes grabbed too many bytes")
- k -= 8;
- n++;
- p--; /* can always return one */
- }
FLUSH
if (s->read != s->write)
LEAVE
diff --git a/lib/libz/inffast.c b/lib/libz/inffast.c
index 61a78ee933fcd..3c6ff06f6c250 100644
--- a/lib/libz/inffast.c
+++ b/lib/libz/inffast.c
@@ -13,12 +13,14 @@
struct inflate_codes_state {int dummy;}; /* for buggy compilers */
/* simplify the use of the inflate_huft type with some defines */
+#define base more.Base
+#define next more.Next
#define exop word.what.Exop
#define bits word.what.Bits
/* macros for bit input with no checking and for returning unused bytes */
#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
-#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
+#define UNGRAB {n+=(c=k>>3);p-=c;k&=7;}
/* Called with number of bytes left to write in window at least 258
(the maximum string length) and number of input bytes available
@@ -118,10 +120,7 @@ z_streamp z;
break;
}
else if ((e & 64) == 0)
- {
- t += t->base;
- e = (t += ((uInt)b & inflate_mask[e]))->exop;
- }
+ e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop;
else
{
z->msg = (char*)"invalid distance code";
@@ -134,8 +133,7 @@ z_streamp z;
}
if ((e & 64) == 0)
{
- t += t->base;
- if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0)
+ if ((e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop) == 0)
{
DUMPBITS(t->bits)
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
diff --git a/lib/libz/inffixed.h b/lib/libz/inffixed.h
deleted file mode 100644
index 77f7e76314521..0000000000000
--- a/lib/libz/inffixed.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/* inffixed.h -- table for decoding fixed codes
- * Generated automatically by the maketree.c program
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-local uInt fixed_bl = 9;
-local uInt fixed_bd = 5;
-local inflate_huft fixed_tl[] = {
- {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
- {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},
- {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},
- {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224},
- {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144},
- {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208},
- {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176},
- {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240},
- {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
- {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200},
- {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168},
- {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232},
- {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152},
- {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216},
- {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184},
- {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248},
- {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
- {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196},
- {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164},
- {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228},
- {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148},
- {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212},
- {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180},
- {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244},
- {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204},
- {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172},
- {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236},
- {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156},
- {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220},
- {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188},
- {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252},
- {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
- {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194},
- {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162},
- {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226},
- {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146},
- {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210},
- {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178},
- {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242},
- {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
- {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202},
- {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170},
- {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234},
- {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154},
- {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218},
- {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186},
- {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250},
- {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
- {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198},
- {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166},
- {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230},
- {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150},
- {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214},
- {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182},
- {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246},
- {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206},
- {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174},
- {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238},
- {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158},
- {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222},
- {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190},
- {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254},
- {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
- {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193},
- {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161},
- {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225},
- {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145},
- {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209},
- {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177},
- {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241},
- {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
- {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},
- {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169},
- {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233},
- {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153},
- {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217},
- {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185},
- {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249},
- {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
- {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197},
- {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},
- {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},
- {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},
- {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},
- {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},
- {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},
- {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},
- {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},
- {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},
- {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},
- {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},
- {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},
- {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},
- {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
- {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},
- {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},
- {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},
- {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},
- {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},
- {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},
- {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},
- {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
- {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},
- {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},
- {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},
- {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},
- {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},
- {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},
- {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},
- {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
- {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},
- {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},
- {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},
- {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},
- {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},
- {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},
- {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},
- {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},
- {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},
- {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},
- {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},
- {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},
- {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},
- {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}
- };
-local inflate_huft fixed_td[] = {
- {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
- {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
- {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
- {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},
- {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},
- {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},
- {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
- {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
- };
diff --git a/lib/libz/inftrees.c b/lib/libz/inftrees.c
index ef1e0b6b87329..9f85187f0af20 100644
--- a/lib/libz/inftrees.c
+++ b/lib/libz/inftrees.c
@@ -6,12 +6,8 @@
#include "zutil.h"
#include "inftrees.h"
-#if !defined(BUILDFIXED) && !defined(STDC)
-# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */
-#endif
-
const char inflate_copyright[] =
- " inflate 1.1.3 Copyright 1995-1998 Mark Adler ";
+ " inflate 1.1.1 Copyright 1995-1998 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -21,6 +17,8 @@ const char inflate_copyright[] =
struct internal_state {int dummy;}; /* for buggy compilers */
/* simplify the use of the inflate_huft type with some defines */
+#define base more.Base
+#define next more.Next
#define exop word.what.Exop
#define bits word.what.Bits
@@ -234,6 +232,11 @@ uIntf *v; /* working area: values in order of bit length */
return Z_MEM_ERROR; /* not enough memory */
u[h] = q = hp + *hn;
*hn += z;
+ if (t != Z_NULL) /* first table is returned result */
+ {
+ *t = q;
+ t = Z_NULL;
+ }
/* connect to last table, if there is one */
if (h)
@@ -241,12 +244,10 @@ uIntf *v; /* working area: values in order of bit length */
x[h] = i; /* save pattern for backing up */
r.bits = (Byte)l; /* bits to dump before this table */
r.exop = (Byte)j; /* bits in this table */
- j = i >> (w - l);
- r.base = (uInt)(q - u[h-1] - j); /* offset to this table */
+ r.next = q; /* pointer to this table */
+ j = i >> (w - l); /* (get around Turbo C bug) */
u[h-1][j] = r; /* connect to last table */
}
- else
- *t = q; /* first table is returned result */
}
/* set up table entry in r */
@@ -383,17 +384,13 @@ z_streamp z; /* for messages */
/* build fixed tables only once--keep them here */
-#ifdef BUILDFIXED
local int fixed_built = 0;
-#define FIXEDH 544 /* number of hufts used by fixed tables */
+#define FIXEDH 424 /* number of hufts used by fixed tables */
local inflate_huft fixed_mem[FIXEDH];
local uInt fixed_bl;
local uInt fixed_bd;
local inflate_huft *fixed_tl;
local inflate_huft *fixed_td;
-#else
-#include "inffixed.h"
-#endif
int inflate_trees_fixed(bl, bd, tl, td, z)
@@ -403,8 +400,7 @@ inflate_huft * FAR *tl; /* literal/length tree result */
inflate_huft * FAR *td; /* distance tree result */
z_streamp z; /* for memory allocation */
{
-#ifdef BUILDFIXED
- /* build fixed tables if not already */
+ /* build fixed tables if not already (multiple overlapped executions ok) */
if (!fixed_built)
{
int k; /* temporary variable */
@@ -430,7 +426,7 @@ z_streamp z; /* for memory allocation */
c[k] = 7;
for (; k < 288; k++)
c[k] = 8;
- fixed_bl = 9;
+ fixed_bl = 7;
huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl,
fixed_mem, &f, v);
@@ -446,7 +442,6 @@ z_streamp z; /* for memory allocation */
ZFREE(z, c);
fixed_built = 1;
}
-#endif
*bl = fixed_bl;
*bd = fixed_bd;
*tl = fixed_tl;
diff --git a/lib/libz/inftrees.h b/lib/libz/inftrees.h
index 85853e097b373..c2513d194927a 100644
--- a/lib/libz/inftrees.h
+++ b/lib/libz/inftrees.h
@@ -19,15 +19,17 @@ struct inflate_huft_s {
Byte Exop; /* number of extra bits or operation */
Byte Bits; /* number of bits in this code or subcode */
} what;
- uInt pad; /* pad structure to a power of 2 (4 bytes for */
- } word; /* 16-bit, 8 bytes for 32-bit int's) */
- uInt base; /* literal, length base, distance base,
- or table offset */
+ Bytef *pad; /* pad structure to a power of 2 (4 bytes for */
+ } word; /* 16-bit, 8 bytes for 32-bit machines) */
+ union {
+ uInt Base; /* literal, length base, or distance base */
+ inflate_huft *Next; /* pointer to next level of table */
+ } more;
};
/* Maximum size of dynamic tree. The maximum found in a long but non-
- exhaustive search was 1004 huft structures (850 for length/literals
- and 154 for distances, the latter actually the result of an
+ exhaustive search was 1041 huft structures (875 for length/literals
+ and 166 for distances, the latter actually the result of an
exhaustive search). The actual maximum is not known, but the
value below is more than safe. */
#define MANY 1440
diff --git a/lib/libz/maketree.c b/lib/libz/maketree.c
deleted file mode 100644
index 949d786418513..0000000000000
--- a/lib/libz/maketree.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* maketree.c -- make inffixed.h table for decoding fixed codes
- * Copyright (C) 1998 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* This program is included in the distribution for completeness.
- You do not need to compile or run this program since inffixed.h
- is already included in the distribution. To use this program
- you need to compile zlib with BUILDFIXED defined and then compile
- and link this program with the zlib library. Then the output of
- this program can be piped to inffixed.h. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "zutil.h"
-#include "inftrees.h"
-
-/* simplify the use of the inflate_huft type with some defines */
-#define exop word.what.Exop
-#define bits word.what.Bits
-
-/* generate initialization table for an inflate_huft structure array */
-void maketree(uInt b, inflate_huft *t)
-{
- int i, e;
-
- i = 0;
- while (1)
- {
- e = t[i].exop;
- if (e && (e & (16+64)) == 0) /* table pointer */
- {
- fprintf(stderr, "maketree: cannot initialize sub-tables!\n");
- exit(1);
- }
- if (i % 4 == 0)
- printf("\n ");
- printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base);
- if (++i == (1<<b))
- break;
- putchar(',');
- }
- puts("");
-}
-
-/* create the fixed tables in C initialization syntax */
-void main(void)
-{
- int r;
- uInt bl, bd;
- inflate_huft *tl, *td;
- z_stream z;
-
- z.zalloc = zcalloc;
- z.opaque = (voidpf)0;
- z.zfree = zcfree;
- r = inflate_trees_fixed(&bl, &bd, &tl, &td, &z);
- if (r)
- {
- fprintf(stderr, "inflate_trees_fixed error %d\n", r);
- return;
- }
- puts("/* inffixed.h -- table for decoding fixed codes");
- puts(" * Generated automatically by the maketree.c program");
- puts(" */");
- puts("");
- puts("/* WARNING: this file should *not* be used by applications. It is");
- puts(" part of the implementation of the compression library and is");
- puts(" subject to change. Applications should only use zlib.h.");
- puts(" */");
- puts("");
- printf("local uInt fixed_bl = %d;\n", bl);
- printf("local uInt fixed_bd = %d;\n", bd);
- printf("local inflate_huft fixed_tl[] = {");
- maketree(bl, tl);
- puts(" };");
- printf("local inflate_huft fixed_td[] = {");
- maketree(bd, td);
- puts(" };");
-}
diff --git a/lib/libz/minigzip.c b/lib/libz/minigzip.c
index 180b39d2ce241..487632e7f1d2f 100644
--- a/lib/libz/minigzip.c
+++ b/lib/libz/minigzip.c
@@ -13,7 +13,7 @@
* or in pipe mode.
*/
-/* @(#) $Id: minigzip.c,v 1.1.1.3 1999/01/10 09:46:57 peter Exp $ */
+/* $FreeBSD$ */
#include <stdio.h>
#include "zlib.h"
@@ -48,9 +48,6 @@
# define GZ_SUFFIX "-gz"
# define fileno(file) file->__file
#endif
-#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fileno */
-#endif
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
extern int unlink OF((const char *));
diff --git a/lib/libz/trees.c b/lib/libz/trees.c
index b02b5277f48a2..2497001742d3e 100644
--- a/lib/libz/trees.c
+++ b/lib/libz/trees.c
@@ -29,7 +29,7 @@
* Addison-Wesley, 1983. ISBN 0-201-06672-6.
*/
-/* @(#) $Id: trees.c,v 1.1.1.3 1999/01/10 09:46:57 peter Exp $ */
+/* $FreeBSD$ */
/* #define GEN_TREES_H */
@@ -250,13 +250,6 @@ local void tr_static_init()
if (static_init_done) return;
- /* For some embedded targets, global variables are not initialized: */
- static_l_desc.static_tree = static_ltree;
- static_l_desc.extra_bits = extra_lbits;
- static_d_desc.static_tree = static_dtree;
- static_d_desc.extra_bits = extra_dbits;
- static_bl_desc.extra_bits = extra_blbits;
-
/* Initialize the mapping length (0..255) -> length code (0..28) */
length = 0;
for (code = 0; code < LENGTH_CODES-1; code++) {
@@ -385,6 +378,8 @@ void _tr_init(s)
{
tr_static_init();
+ s->compressed_len = 0L;
+
s->l_desc.dyn_tree = s->dyn_ltree;
s->l_desc.stat_desc = &static_l_desc;
@@ -398,7 +393,6 @@ void _tr_init(s)
s->bi_valid = 0;
s->last_eob_len = 8; /* enough lookahead for inflate */
#ifdef DEBUG
- s->compressed_len = 0L;
s->bits_sent = 0L;
#endif
@@ -871,10 +865,9 @@ void _tr_stored_block(s, buf, stored_len, eof)
int eof; /* true if this is the last block for a file */
{
send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
-#ifdef DEBUG
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
s->compressed_len += (stored_len + 4) << 3;
-#endif
+
copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
}
@@ -894,9 +887,7 @@ void _tr_align(s)
{
send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
-#endif
bi_flush(s);
/* Of the 10 bits for the empty block, we have already sent
* (10 - bi_valid) bits. The lookahead for the last real code (before
@@ -906,9 +897,7 @@ void _tr_align(s)
if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
s->compressed_len += 10L;
-#endif
bi_flush(s);
}
s->last_eob_len = 7;
@@ -916,9 +905,10 @@ void _tr_align(s)
/* ===========================================================================
* Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file.
+ * trees or store, and output the encoded block to the zip file. This function
+ * returns the total compressed length for the file so far.
*/
-void _tr_flush_block(s, buf, stored_len, eof)
+ulg _tr_flush_block(s, buf, stored_len, eof)
deflate_state *s;
charf *buf; /* input block, or NULL if too old */
ulg stored_len; /* length of input block */
@@ -965,6 +955,25 @@ void _tr_flush_block(s, buf, stored_len, eof)
opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
}
+ /* If compression failed and this is the first and last block,
+ * and if the .zip file can be seeked (to rewrite the local header),
+ * the whole file is transformed into a stored file:
+ */
+#ifdef STORED_FILE_OK
+# ifdef FORCE_STORED_FILE
+ if (eof && s->compressed_len == 0L) { /* force stored file */
+# else
+ if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable()) {
+# endif
+ /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
+ if (buf == (charf*)0) error ("block vanished");
+
+ copy_block(buf, (unsigned)stored_len, 0); /* without header */
+ s->compressed_len = stored_len << 3;
+ s->method = STORED;
+ } else
+#endif /* STORED_FILE_OK */
+
#ifdef FORCE_STORED
if (buf != (char*)0) { /* force stored block */
#else
@@ -986,32 +995,25 @@ void _tr_flush_block(s, buf, stored_len, eof)
#endif
send_bits(s, (STATIC_TREES<<1)+eof, 3);
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
-#ifdef DEBUG
s->compressed_len += 3 + s->static_len;
-#endif
} else {
send_bits(s, (DYN_TREES<<1)+eof, 3);
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
max_blindex+1);
compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
-#ifdef DEBUG
s->compressed_len += 3 + s->opt_len;
-#endif
}
Assert (s->compressed_len == s->bits_sent, "bad compressed size");
- /* The above check is made mod 2^32, for files larger than 512 MB
- * and uLong implemented on 32 bits.
- */
init_block(s);
if (eof) {
bi_windup(s);
-#ifdef DEBUG
s->compressed_len += 7; /* align on byte boundary */
-#endif
}
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
s->compressed_len-7*eof));
+
+ return s->compressed_len >> 3;
}
/* ===========================================================================
diff --git a/lib/libz/uncompr.c b/lib/libz/uncompr.c
index d1033213781ee..b1bd9fc41b0f3 100644
--- a/lib/libz/uncompr.c
+++ b/lib/libz/uncompr.c
@@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* @(#) $Id$ */
+/* $FreeBSD$ */
#include "zlib.h"
diff --git a/lib/libz/zconf.h b/lib/libz/zconf.h
index f06124f81b7f5..5b71e4b0ad425 100644
--- a/lib/libz/zconf.h
+++ b/lib/libz/zconf.h
@@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* @(#) $Id: zconf.h,v 1.1.1.3 1999/01/10 09:46:58 peter Exp $ */
+/* $FreeBSD$ */
#ifndef _ZCONF_H
#define _ZCONF_H
@@ -91,8 +91,8 @@
# define NO_DUMMY_DECL
#endif
-/* Old Borland C incorrectly complains about missing returns: */
-#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
+/* Borland C incorrectly complains about missing returns: */
+#if defined(__BORLANDC__)
# define NEED_DUMMY_RETURN
#endif
@@ -148,7 +148,7 @@
/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
-# define FAR _far
+# define FAR __far
# else
# define FAR far
# endif
@@ -156,68 +156,42 @@
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
# ifndef __32BIT__
# define SMALL_MEDIUM
-# define FAR _far
+# define FAR __far
# endif
#endif
/* Compile with -DZLIB_DLL for Windows DLL support */
-#if defined(ZLIB_DLL)
-# if defined(_WINDOWS) || defined(WINDOWS)
-# ifdef FAR
-# undef FAR
-# endif
-# include <windows.h>
-# define ZEXPORT WINAPI
-# ifdef WIN32
-# define ZEXPORTVA WINAPIV
-# else
-# define ZEXPORTVA FAR _cdecl _export
-# endif
+#if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL)
+# ifdef FAR
+# undef FAR
# endif
-# if defined (__BORLANDC__)
-# if (__BORLANDC__ >= 0x0500) && defined (WIN32)
-# include <windows.h>
-# define ZEXPORT __declspec(dllexport) WINAPI
-# define ZEXPORTRVA __declspec(dllexport) WINAPIV
-# else
-# if defined (_Windows) && defined (__DLL__)
-# define ZEXPORT _export
-# define ZEXPORTVA _export
-# endif
-# endif
-# endif
-#endif
-
-#if defined (__BEOS__)
-# if defined (ZLIB_DLL)
-# define ZEXTERN extern __declspec(dllexport)
+# include <windows.h>
+# define ZEXPORT WINAPI
+# ifdef WIN32
+# define ZEXPORTVA WINAPIV
# else
-# define ZEXTERN extern __declspec(dllimport)
+# define ZEXPORTVA FAR _cdecl _export
# endif
-#endif
-
-#ifndef ZEXPORT
-# define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-# define ZEXPORTVA
-#endif
-#ifndef ZEXTERN
-# define ZEXTERN extern
+#else
+# if defined (__BORLANDC__) && defined (_Windows) && defined (__DLL__)
+# define ZEXPORT _export
+# define ZEXPORTVA _export
+# else
+# define ZEXPORT
+# define ZEXPORTVA
+# endif
#endif
#ifndef FAR
# define FAR
#endif
-#if !defined(MACOS) && !defined(TARGET_OS_MAC)
typedef unsigned char Byte; /* 8 bits */
-#endif
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
-#ifdef SMALL_MEDIUM
- /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
+#if defined(__BORLANDC__) && defined(SMALL_MEDIUM)
+ /* Borland C/C++ ignores FAR inside typedef */
# define Bytef Byte FAR
#else
typedef Byte FAR Bytef;
@@ -243,7 +217,6 @@ typedef uLong FAR uLongf;
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
-# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
# define z_off_t long
diff --git a/lib/libz/zlib.3 b/lib/libz/zlib.3
index 25c8495d25f1f..8519184d4fb86 100644
--- a/lib/libz/zlib.3
+++ b/lib/libz/zlib.3
@@ -1,4 +1,4 @@
-.TH ZLIB 3 "9 July 1998"
+.TH ZLIB 3 "27 February 1998"
.SH NAME
zlib \- compression/decompression library
.SH SYNOPSIS
@@ -81,7 +81,7 @@ These documents are also available in other formats from:
.IP
ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
.SH AUTHORS
-Version 1.1.3
+Version 1.1.1
Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org)
and Mark Adler (madler@alumni.caltech.edu).
.LP
@@ -96,7 +96,7 @@ The deflate format used by
was defined by Phil Katz.
The deflate and
.I zlib
-specifications were written by L. Peter Deutsch.
+specifications were written by Peter Deutsch.
Thanks to all the people who reported problems and suggested various
improvements in
.IR zlib ;
diff --git a/lib/libz/zlib.h b/lib/libz/zlib.h
index 49f56b43bc6c5..06f988c1f0585 100644
--- a/lib/libz/zlib.h
+++ b/lib/libz/zlib.h
@@ -1,5 +1,5 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.1.3, July 9th, 1998
+ version 1.1.1, Feb 27th, 1998
Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
@@ -31,13 +31,13 @@
#ifndef _ZLIB_H
#define _ZLIB_H
-#include "zconf.h"
-
#ifdef __cplusplus
extern "C" {
#endif
-#define ZLIB_VERSION "1.1.3"
+#include "zconf.h"
+
+#define ZLIB_VERSION "1.1.1"
/*
The 'zlib' compression library provides in-memory compression and
@@ -168,7 +168,7 @@ typedef z_stream FAR *z_streamp;
/* basic functions */
-ZEXTERN const char * ZEXPORT zlibVersion OF((void));
+extern const char * ZEXPORT zlibVersion OF((void));
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
If the first character differs, the library code actually used is
not compatible with the zlib.h header file used by the application.
@@ -176,7 +176,7 @@ ZEXTERN const char * ZEXPORT zlibVersion OF((void));
*/
/*
-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
+extern int ZEXPORT deflateInit OF((z_streamp strm, int level));
Initializes the internal stream state for compression. The fields
zalloc, zfree and opaque must be initialized before by the caller.
@@ -198,7 +198,7 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
*/
-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
+extern int ZEXPORT deflate OF((z_streamp strm, int flush));
/*
deflate compresses as much data as possible, and stops when the input
buffer becomes empty or the output buffer becomes full. It may introduce some
@@ -271,12 +271,11 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
processed or more output produced), Z_STREAM_END if all input has been
consumed and all output has been produced (only when flush is set to
Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
- (for example avail_in or avail_out was zero).
+ if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible.
*/
-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
+extern int ZEXPORT deflateEnd OF((z_streamp strm));
/*
All dynamically allocated data structures for this stream are freed.
This function discards any unprocessed input and does not flush any
@@ -291,7 +290,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
/*
-ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
+extern int ZEXPORT inflateInit OF((z_streamp strm));
Initializes the internal stream state for decompression. The fields
next_in, avail_in, zalloc, zfree and opaque must be initialized before by
@@ -311,7 +310,7 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
*/
-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
+extern int ZEXPORT inflate OF((z_streamp strm, int flush));
/*
inflate decompresses as much data as possible, and stops when the input
buffer becomes empty or the output buffer becomes full. It may some
@@ -380,7 +379,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
*/
-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
+extern int ZEXPORT inflateEnd OF((z_streamp strm));
/*
All dynamically allocated data structures for this stream are freed.
This function discards any unprocessed input and does not flush any
@@ -398,12 +397,12 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
*/
/*
-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
- int level,
- int method,
- int windowBits,
- int memLevel,
- int strategy));
+extern int ZEXPORT deflateInit2 OF((z_streamp strm,
+ int level,
+ int method,
+ int windowBits,
+ int memLevel,
+ int strategy));
This is another version of deflateInit with more compression options. The
fields next_in, zalloc, zfree and opaque must be initialized before by
@@ -441,14 +440,14 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
not perform any compression: this will be done by deflate().
*/
-ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
+extern int ZEXPORT deflateSetDictionary OF((z_streamp strm,
+ const Bytef *dictionary,
+ uInt dictLength));
/*
Initializes the compression dictionary from the given byte sequence
without producing any compressed output. This function must be called
- immediately after deflateInit, deflateInit2 or deflateReset, before any
- call of deflate. The compressor and decompressor must use exactly the same
+ immediately after deflateInit or deflateInit2, before any call of
+ deflate. The compressor and decompressor must use exactly the same
dictionary (see inflateSetDictionary).
The dictionary should consist of strings (byte sequences) that are likely
@@ -477,8 +476,8 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
perform any compression: this will be done by deflate().
*/
-ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
- z_streamp source));
+extern int ZEXPORT deflateCopy OF((z_streamp dest,
+ z_streamp source));
/*
Sets the destination stream as a complete copy of the source stream.
@@ -495,7 +494,7 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
destination.
*/
-ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
+extern int ZEXPORT deflateReset OF((z_streamp strm));
/*
This function is equivalent to deflateEnd followed by deflateInit,
but does not free and reallocate all the internal compression state.
@@ -506,9 +505,7 @@ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
stream state was inconsistent (such as zalloc or state being NULL).
*/
-ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
- int level,
- int strategy));
+extern int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy));
/*
Dynamically update the compression level and compression strategy. The
interpretation of level and strategy is as in deflateInit2. This can be
@@ -528,8 +525,8 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
*/
/*
-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
- int windowBits));
+extern int ZEXPORT inflateInit2 OF((z_streamp strm,
+ int windowBits));
This is another version of inflateInit with an extra parameter. The
fields next_in, avail_in, zalloc, zfree and opaque must be initialized
@@ -550,9 +547,9 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
modified, but next_out and avail_out are unchanged.)
*/
-ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
+extern int ZEXPORT inflateSetDictionary OF((z_streamp strm,
+ const Bytef *dictionary,
+ uInt dictLength));
/*
Initializes the decompression dictionary from the given uncompressed byte
sequence. This function must be called immediately after a call of inflate
@@ -569,7 +566,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
inflate().
*/
-ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
+extern int ZEXPORT inflateSync OF((z_streamp strm));
/*
Skips invalid compressed data until a full flush point (see above the
description of deflate with Z_FULL_FLUSH) can be found, or until all
@@ -584,7 +581,7 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
until success or end of the input data.
*/
-ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
+extern int ZEXPORT inflateReset OF((z_streamp strm));
/*
This function is equivalent to inflateEnd followed by inflateInit,
but does not free and reallocate all the internal decompression state.
@@ -605,8 +602,8 @@ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
utility functions can easily be modified if you need special options.
*/
-ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
+extern int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
/*
Compresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total
@@ -620,9 +617,9 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
buffer.
*/
-ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen,
- int level));
+extern int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen,
+ int level));
/*
Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
@@ -635,8 +632,8 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
Z_STREAM_ERROR if the level parameter is invalid.
*/
-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
+extern int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
/*
Decompresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total
@@ -656,7 +653,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
typedef voidp gzFile;
-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
+extern gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
/*
Opens a gzip (.gz) file for reading or writing. The mode parameter
is as in fopen ("rb" or "wb") but can also include a compression level
@@ -672,7 +669,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
can be checked to distinguish the two cases (if errno is zero, the
zlib error is Z_MEM_ERROR). */
-ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
+extern gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
/*
gzdopen() associates a gzFile with the file descriptor fd. File
descriptors are obtained from calls like open, dup, creat, pipe or
@@ -685,7 +682,7 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
the (de)compression state.
*/
-ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
+extern int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
/*
Dynamically update the compression level or strategy. See the description
of deflateInit2 for the meaning of these parameters.
@@ -693,7 +690,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
opened for writing.
*/
-ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
+extern int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
/*
Reads the given number of uncompressed bytes from the compressed file.
If the input file was not in gzip format, gzread copies the given number
@@ -701,29 +698,28 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
gzread returns the number of uncompressed bytes actually read (0 for
end of file, -1 for error). */
-ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
- const voidp buf, unsigned len));
+extern int ZEXPORT gzwrite OF((gzFile file, const voidp buf, unsigned len));
/*
Writes the given number of uncompressed bytes into the compressed file.
gzwrite returns the number of uncompressed bytes actually written
(0 in case of error).
*/
-ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
+extern int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
/*
Converts, formats, and writes the args to the compressed file under
control of the format string, as in fprintf. gzprintf returns the number of
uncompressed bytes actually written (0 in case of error).
*/
-ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
+extern int ZEXPORT gzputs OF((gzFile file, const char *s));
/*
Writes the given null-terminated string to the compressed file, excluding
the terminating null character.
gzputs returns the number of characters written, or -1 in case of error.
*/
-ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
+extern char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
/*
Reads bytes from the compressed file until len-1 characters are read, or
a newline character is read and transferred to buf, or an end-of-file
@@ -732,19 +728,19 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
gzgets returns buf, or Z_NULL in case of error.
*/
-ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
+extern int ZEXPORT gzputc OF((gzFile file, int c));
/*
Writes c, converted to an unsigned char, into the compressed file.
gzputc returns the value that was written, or -1 in case of error.
*/
-ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
+extern int ZEXPORT gzgetc OF((gzFile file));
/*
Reads one byte from the compressed file. gzgetc returns this byte
or -1 in case of end of file or error.
*/
-ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
+extern int ZEXPORT gzflush OF((gzFile file, int flush));
/*
Flushes all pending output into the compressed file. The parameter
flush is as in the deflate() function. The return value is the zlib
@@ -754,11 +750,10 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
degrade compression.
*/
-ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
- z_off_t offset, int whence));
+extern z_off_t ZEXPORT gzseek OF((gzFile file, z_off_t offset, int whence));
/*
- Sets the starting position for the next gzread or gzwrite on the
- given compressed file. The offset represents a number of bytes in the
+ Sets the starting position for the next gzread or gzwrite on the given
+ compressed file. The offset represents a number of bytes in the
uncompressed data stream. The whence parameter is defined as in lseek(2);
the value SEEK_END is not supported.
If the file is opened for reading, this function is emulated but can be
@@ -772,14 +767,14 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
would be before the current position.
*/
-ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
+extern int ZEXPORT gzrewind OF((gzFile file));
/*
Rewinds the given file. This function is supported only for reading.
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
*/
-ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
+extern z_off_t ZEXPORT gztell OF((gzFile file));
/*
Returns the starting position for the next gzread or gzwrite on the
given compressed file. This position represents a number of bytes in the
@@ -788,20 +783,20 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
*/
-ZEXTERN int ZEXPORT gzeof OF((gzFile file));
+extern int ZEXPORT gzeof OF((gzFile file));
/*
Returns 1 when EOF has previously been detected reading the given
input stream, otherwise zero.
*/
-ZEXTERN int ZEXPORT gzclose OF((gzFile file));
+extern int ZEXPORT gzclose OF((gzFile file));
/*
Flushes all pending output if necessary, closes the compressed file
and deallocates all the (de)compression state. The return value is the zlib
error number (see function gzerror below).
*/
-ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
+extern const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
/*
Returns the error message for the last error which occurred on the
given compressed file. errnum is set to zlib error number. If an
@@ -818,7 +813,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
compression library.
*/
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
+extern uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
/*
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
@@ -835,7 +830,7 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
if (adler != original_adler) error();
*/
-ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
+extern uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
/*
Update a running crc with the bytes buf[0..len-1] and return the updated
crc. If buf is NULL, this function returns the required initial value
@@ -857,16 +852,16 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
/* deflateInit and inflateInit are macros to allow checking the zlib version
* and the compiler's view of z_stream:
*/
-ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
+extern int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
+ const char *version, int stream_size));
+extern int ZEXPORT inflateInit_ OF((z_streamp strm,
+ const char *version, int stream_size));
+extern int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
+ int windowBits, int memLevel,
+ int strategy, const char *version,
+ int stream_size));
+extern int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
const char *version, int stream_size));
-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
- int windowBits, int memLevel,
- int strategy, const char *version,
- int stream_size));
-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
- const char *version, int stream_size));
#define deflateInit(strm, level) \
deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
#define inflateInit(strm) \
@@ -882,9 +877,9 @@ ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
struct internal_state {int dummy;}; /* hack for buggy compilers */
#endif
-ZEXTERN const char * ZEXPORT zError OF((int err));
-ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
-ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
+extern const char * ZEXPORT zError OF((int err));
+extern int ZEXPORT inflateSyncPoint OF((z_streamp z));
+extern const uLongf * ZEXPORT get_crc_table OF((void));
#ifdef __cplusplus
}
diff --git a/lib/libz/zutil.c b/lib/libz/zutil.c
index 60340c838cb98..0d12b55d28b2e 100644
--- a/lib/libz/zutil.c
+++ b/lib/libz/zutil.c
@@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-/* @(#) $Id: zutil.c,v 1.1.1.3 1999/01/10 09:46:59 peter Exp $ */
+/* $FreeBSD$ */
#include "zutil.h"
@@ -60,7 +60,7 @@ const char * ZEXPORT zError(err)
void zmemcpy(dest, source, len)
Bytef* dest;
- const Bytef* source;
+ Bytef* source;
uInt len;
{
if (len == 0) return;
@@ -70,8 +70,8 @@ void zmemcpy(dest, source, len)
}
int zmemcmp(s1, s2, len)
- const Bytef* s1;
- const Bytef* s2;
+ Bytef* s1;
+ Bytef* s2;
uInt len;
{
uInt j;
@@ -178,7 +178,7 @@ void zcfree (voidpf opaque, voidpf ptr)
# define MY_ZCALLOC
-#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
+#if (!defined(_MSC_VER) || (_MSC_VER < 600))
# define _halloc halloc
# define _hfree hfree
#endif
diff --git a/lib/libz/zutil.h b/lib/libz/zutil.h
index 429339ff9846a..3843e0de9f2fd 100644
--- a/lib/libz/zutil.h
+++ b/lib/libz/zutil.h
@@ -8,7 +8,7 @@
subject to change. Applications should only use zlib.h.
*/
-/* @(#) $Id: zutil.h,v 1.1.1.3 1999/01/10 09:46:59 peter Exp $ */
+/* $FreeBSD$ */
#ifndef _Z_UTIL_H
#define _Z_UTIL_H
@@ -75,7 +75,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
#ifdef MSDOS
# define OS_CODE 0x00
-# if defined(__TURBOC__) || defined(__BORLANDC__)
+# ifdef __TURBOC__
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block );
@@ -112,12 +112,13 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
#if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
+# ifndef fdopen
+# define fdopen(fd,mode) NULL /* No fdopen() */
+# endif
+#endif
+#if defined(__MWERKS__) && !defined(fdopen)
+# if __dest_os != __be_os && __dest_os != __win32_os
+# define fdopen(fd,mode) NULL
# endif
#endif
@@ -133,7 +134,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
# define fdopen(fd,mode) NULL /* No fdopen() */
#endif
-#if (defined(_MSC_VER) && (_MSC_VER > 600))
+#if (defined(_MSC_VER) && (_MSC_VER >= 600))
# define fdopen(fd,type) _fdopen(fd,type)
#endif
@@ -181,8 +182,8 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
# define zmemzero(dest, len) memset(dest, 0, len)
# endif
#else
- extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
- extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
+ extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len));
+ extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len));
extern void zmemzero OF((Bytef* dest, uInt len));
#endif
diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index 0507810348f84..a0ca7405fbd74 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -1,5 +1,5 @@
# @(#)Makefile 5.1beta 93/09/24
-# $Id: Makefile,v 1.21 1998/12/23 11:50:51 dfr Exp $
+# $Id: Makefile,v 1.19 1997/04/15 14:05:28 bde Exp $
#
# ====================================================
# Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -48,8 +48,6 @@ ARCH_SRCS = s_copysign.S s_copysignf.S
# XXX Comment from NetBSD/Alpha:
# XXX LINT SIGFPEs in e_exp.c's strtod(). FP underflow/denorm software
# handling is broken (doesn't exist!) on the Alpha port.
-# Stock gcc 2.7.2.1 doesn't understand these options.
-#CFLAGS += -mtrap-precision=i -mfp-trap-mode=su
.elif ${MACHINE_ARCH} == "i386"
ARCH= i387
ARCH_PREFIX= ${ARCH}_