diff options
author | nectar <nectar@FreeBSD.org> | 2002-02-19 15:46:56 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2002-02-19 15:46:56 +0000 |
commit | 69a91bec14ec3ad49d1c8a82c40a796755f9e4a3 (patch) | |
tree | 85ecf91fd00875cec4b93111d3a8ed9eec9cddfe /crypto/heimdal/lib/roken | |
parent | 8db4cdb3da4228a5d93635e43825e2e8a2f66db7 (diff) | |
download | FreeBSD-src-69a91bec14ec3ad49d1c8a82c40a796755f9e4a3.zip FreeBSD-src-69a91bec14ec3ad49d1c8a82c40a796755f9e4a3.tar.gz |
Import of Heimdal Kerberos from KTH repository circa 2002/02/17.
Diffstat (limited to 'crypto/heimdal/lib/roken')
42 files changed, 2345 insertions, 763 deletions
diff --git a/crypto/heimdal/lib/roken/ChangeLog b/crypto/heimdal/lib/roken/ChangeLog index cbc7393..833ddae 100644 --- a/crypto/heimdal/lib/roken/ChangeLog +++ b/crypto/heimdal/lib/roken/ChangeLog @@ -1,5 +1,212 @@ +2001-11-30 Assar Westerlund <assar@sics.se> + + * getifaddrs.c: support SIOCGLIFCONF and SIOCGLIFFLAGS which are + used on Solaris 8 to retrieve addresses larger than `struct + sockaddr'. From Magnus Ahltorp <ahltorp@nada.kth.se> (with some + modifications by me) + +2001-10-27 Assar Westerlund <assar@sics.se> + + * Makefile.am (libroken_la_LDFLAGS): set version to 15:0:6 + +2001-10-22 Assar Westerlund <assar@sics.se> + + * localtime_r.c: add + +2001-10-02 Johan Danielsson <joda@pdc.kth.se> + + * resolve.c (dns_srv_order): don't try to return a value + +2001-09-24 Johan Danielsson <joda@pdc.kth.se> + + * snprintf.c: va_{start,end} fixes; from Thomas Klausner + +2001-09-20 Assar Westerlund <assar@sics.se> + + * resolve.c (dns_srv_order): make sure of not reading after the + array + +2001-09-17 Assar Westerlund <assar@sics.se> + + * Makefile.am (libroken_la_LDFLAGS): bump to 14:4:5 + * snprintf.c: rename 'struct state' -> 'struct snprintf_test' to + avoid collision with resolv.h on aix + +2001-09-04 Assar Westerlund <assar@sics.se> + + * parse_bytes-test.c, parse_bytes.c, parse_bytes.h, parse_units.c, + parse_units.h: use int instead of size_t as return values to be + compatible with snprintf + + * strftime.c (strftime): check for return values from snprintf() < + 0 + +2001-09-03 Johan Danielsson <joda@pdc.kth.se> + + * socket.c: restrict is a keyword + +2001-09-03 Assar Westerlund <assar@sics.se> + + * write_pid.c: handle atexit or on_exit + + * Makefile.am (EXTRA_libroken_la_SOURCES): add vis.hin to help + solaris make + +2001-08-30 Johan Danielsson <joda@pdc.kth.se> + + * Makefile.am: use LDADD directly + +2001-08-28 Assar Westerlund <assar@sics.se> + + * Makefile.am (libroken_la_LDFLAGS): set to 14:3:5 + + * issuid.c (issuid): call issetugid if it exists + +2001-08-24 Assar Westerlund <assar@sics.se> + + * Makefile.am: make it play better with recent automake + +2001-08-21 Assar Westerlund <assar@sics.se> + + * glob.c: provide a fallback for ARG_MAX. from <tol@stacken.kth.se> + + * roken.h.in: remove all winsock.h + for now, it does more harm than good under cygwin and if it should be + used, the correct conditional needs to be found + from <tol@stacken.kth.se> + +2001-08-17 Johan Danielsson <joda@pdc.kth.se> + + * getaddrinfo.c: include a definition of in6addr_loopback if it + doesn't exist + +2001-08-10 Assar Westerlund <assar@sics.se> + + * Makefile.am (libroken_la_LDFLAGS): update to 14:2:5 + +2001-08-08 Assar Westerlund <assar@sics.se> + + * hstrerror.c: move h_errno to its own file (h_errno.c) + +2001-08-04 Assar Westerlund <assar@sics.se> + + * Makefile.am: add getarg.3 + +2001-08-01 Assar Westerlund <assar@sics.se> + + * mini_inetd.c (mini_inetd): explicitly use PF_UNSPEC. be more + resilient to bind/listen failing. + +2001-07-31 Assar Westerlund <assar@sics.se> + + * getifaddrs.c (getifaddrs2): remove unused variables + +2001-07-31 Assar Westerlund <assar@sics.se> + + * Makefile.am (libroken_la_LDFLAGS): update version to 14:1:5 + +2001-07-23 Assar Westerlund <assar@sics.se> + + * getarg.c (arg_match_long): fix parsing of arg_counter optional + argument + +2001-07-19 Assar Westerlund <assar@sics.se> + + * Makefile.am (libroken_la_LDFLAGS): bump version to 14:0:5 + +2001-07-17 Assar Westerlund <assar@sics.se> + + * snprintf-test.h: add a file with renaming of the snprintf + functions, to be used for running the tests + +2001-07-11 Assar Westerlund <assar@sics.se> + + * snprintf-test.c: add more %X tests, and long and conditional + long long tests + * snprintf.c: add support for printing long long (if available) + +2001-07-10 Assar Westerlund <assar@sics.se> + + * getaddrinfo.c (add_hostent): adapt to const hostent_find_fqdn + * hostent_find_fqdn.c (hostent_find_fqdn): const-ize + +2001-07-09 Assar Westerlund <assar@sics.se> + + * roken-common.h (hostent_find_fqdn): add + * hostent_find_fqdn.c: separate out hostent_find_fqdn + + * warnerr.c: move out getprogname, setprogname + +2001-07-03 Assar Westerlund <assar@sics.se> + + * warnerr.c (setprogname): add const cast + * vis.c (SVIS): add some (unsigned char) before calling isfoo* + * Makefile.am (libroken_la_LDFLAGS:) set version to 13:0:4 + + * Makefile.am: add snprintf_test + * snprintf.c: rewrite so that it does not stop as soon as there + are no more characters to print, we need to figure out how long + the string would have to be. this also fixes snprintf(NULL, 0 + +2001-06-21 Assar Westerlund <assar@sics.se> + + * simple_exec.c (pipe_execv): remove unused variable + +2001-06-20 Johan Danielsson <joda@pdc.kth.se> + + * getdtablesize.c: fix typo in obviously never used sysctl case + + * simple_exec.c: rename check_status to wait_for_process, and + export it; function pipe_execv similar to popen, but with more + control over input and output + + * roken-common.h: prototypes for wait_for_process and pipe_execv + +2001-06-17 Assar Westerlund <assar@sics.se> + + * roken-common.h: move emalloc et al to roken.h.in + * Makefile.am: make emalloc,ecalloc,erealloc,estrdup conditional + * emalloc.c, erealloc.c, estrup.c: use errx, since errno might not + be set reliably + * ecalloc.c: add for symmetry + +2001-06-09 Johan Danielsson <joda@pdc.kth.se> + + * resolve.c: dns_srv_order to order srv records + +2001-06-08 Johan Danielsson <joda@pdc.kth.se> + + * getarg.c: Grog tries to figure out if to use mdoc.old instead of + mdoc by looking at some macros that were only present in the old + version, and by looking at the number of .Oo's present. In + mdoc.old .Oo was a toggle, but in mdoc it's closed by .Oc, so if + the number of .Oo's is bigger than the number of .Oc's, it figures + it must be mdoc.old. This doesn't however account for called Oc's, + and thus grog thinks that valid pages are mdoc.old when they + infact are mdoc. So let's make sure that Oc's are not called by + other macros. + +2001-05-29 Assar Westerlund <assar@sics.se> + + * base64-test.c (main): initialize numerr + +2001-05-28 Johan Danielsson <joda@pdc.kth.se> + + * base64.c: clean up the decode mess somewhat + + * base64-test.c: base64 tests + +2001-05-18 Johan Danielsson <joda@pdc.kth.se> + + * roken.h.in: just use standard C types with bswap* + + * bswap.c: just use standard C types + 2001-05-17 Assar Westerlund <assar@sics.se> + * roken.h.in: include all the headers that AC_GROK_TYPES tries for + finding u_int17_t et al + * Makefile.am: bump version to 12:0:3 * roken.h.in: re-add set_progname and get_progname for backwards compatability diff --git a/crypto/heimdal/lib/roken/Makefile.am b/crypto/heimdal/lib/roken/Makefile.am index ce874b0..4c96b3c 100644 --- a/crypto/heimdal/lib/roken/Makefile.am +++ b/crypto/heimdal/lib/roken/Makefile.am @@ -1,53 +1,52 @@ -# $Id: Makefile.am,v 1.96 2001/05/16 23:57:10 assar Exp $ +# $Id: Makefile.am,v 1.117 2001/10/27 17:47:53 assar Exp $ -AUTOMAKE_OPTIONS = foreign no-dependencies +include $(top_srcdir)/Makefile.am.common -AM_CFLAGS += $(WFLAGS) - -## ACLOCAL = @ACLOCAL@ -I cf ACLOCAL_AMFLAGS = -I ../../cf CLEANFILES = roken.h make-roken.c $(XHEADERS) lib_LTLIBRARIES = libroken.la -libroken_la_LDFLAGS = -version-info 12:0:3 +libroken_la_LDFLAGS = -version-info 15:0:6 -noinst_PROGRAMS = make-roken +noinst_PROGRAMS = make-roken snprintf-test nodist_make_roken_SOURCES = make-roken.c -check_PROGRAMS = parse_bytes-test \ - strpftime-test \ - getaddrinfo-test +check_PROGRAMS = \ + base64-test \ + getaddrinfo-test \ + parse_bytes-test \ + snprintf-test \ + strpftime-test TESTS = $(check_PROGRAMS) LIB_crypt = @LIB_crypt@ -common_LDADD = libroken.la $(LIB_crypt) +LDADD = libroken.la $(LIB_crypt) +make_roken_LDADD = -strpftime_test_SOURCES = strpftime-test.c strftime.c strptime.c snprintf.c -##snprintf_test_SOURCES = snprintf-test.c snprintf.c -##snprintf_test_LDADD = $(common_LDADD) -lm -getaddrinfo_test_LDADD = $(common_LDADD) -parse_bytes_test_LDADD = $(common_LDADD) +strpftime_test_SOURCES = strpftime-test.c strftime.c strptime.c snprintf.c +snprintf_test_SOURCES = snprintf-test.c snprintf.c +snprintf_test_CFLAGS = -DTEST_SNPRINTF libroken_la_SOURCES = \ base64.c \ bswap.c \ concat.c \ - emalloc.c \ environment.c \ eread.c \ - erealloc.c \ esetenv.c \ - estrdup.c \ ewrite.c \ getaddrinfo_hostspec.c \ get_default_username.c \ get_window_size.c \ getarg.c \ getnameinfo_verified.c \ + getprogname.c \ + h_errno.c \ + hostent_find_fqdn.c \ issuid.c \ k_getpwnam.c \ k_getpwuid.c \ @@ -61,6 +60,7 @@ libroken_la_SOURCES = \ roken_gethostby.c \ rtbl.c \ rtbl.h \ + setprogname.c \ signal.c \ simple_exec.c \ snprintf.c \ @@ -80,6 +80,10 @@ EXTRA_libroken_la_SOURCES = \ chown.c \ copyhostent.c \ daemon.c \ + ecalloc.c \ + emalloc.c \ + erealloc.c \ + estrdup.c \ err.c \ err.hin \ errx.c \ @@ -90,7 +94,6 @@ EXTRA_libroken_la_SOURCES = \ freeaddrinfo.c \ freehostent.c \ gai_strerror.c \ - getaddrinfo.c \ getdtablesize.c \ getegid.c \ geteuid.c \ @@ -142,6 +145,7 @@ EXTRA_libroken_la_SOURCES = \ unsetenv.c \ verr.c \ verrx.c \ + vis.hin \ vsyslog.c \ vwarn.c \ vwarnx.c \ @@ -151,9 +155,9 @@ EXTRA_libroken_la_SOURCES = \ EXTRA_DIST = roken.awk roken.h.in -libroken_la_LIBADD = @LTLIBOBJS@ +libroken_la_LIBADD = @LTLIBOBJS@ $(DBLIB) -$(LTLIBOBJS) $(libroken_la_OBJECTS): $(include_HEADERS) roken.h +$(LTLIBOBJS) $(libroken_la_OBJECTS): $(include_HEADERS) roken.h $(XHEADERS) BUILT_SOURCES = make-roken.c roken.h @@ -204,8 +208,9 @@ include_HEADERS = \ nodist_include_HEADERS = roken.h +man_MANS = getarg.3 -SUFFIXES += .hin +SUFFIXES = .hin .hin.h: cp $< $@ diff --git a/crypto/heimdal/lib/roken/Makefile.in b/crypto/heimdal/lib/roken/Makefile.in index b72df46..0bdf597 100644 --- a/crypto/heimdal/lib/roken/Makefile.in +++ b/crypto/heimdal/lib/roken/Makefile.in @@ -1,6 +1,6 @@ -# Makefile.in generated automatically by automake 1.4b from Makefile.am +# Makefile.in generated automatically by automake 1.5 from Makefile.am. -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -11,6 +11,16 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. +@SET_MAKE@ + +# $Id: Makefile.am,v 1.117 2001/10/27 17:47:53 assar Exp $ + + +# $Id: Makefile.am.common,v 1.3 1999/04/01 14:58:43 joda Exp $ + + +# $Id: Makefile.am.common,v 1.31 2001/09/01 11:12:18 assar Exp $ + SHELL = @SHELL@ srcdir = @srcdir@ @@ -31,11 +41,9 @@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include - pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ - top_builddir = ../.. ACLOCAL = @ACLOCAL@ @@ -47,21 +55,17 @@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_FLAG = +INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ - NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : - -@SET_MAKE@ host_alias = @host_alias@ host_triplet = @host@ AIX_EXTRA_KAFS = @AIX_EXTRA_KAFS@ -AMDEP = @AMDEP@ AMTAR = @AMTAR@ AS = @AS@ AWK = @AWK@ @@ -69,11 +73,11 @@ CANONICAL_HOST = @CANONICAL_HOST@ CATMAN = @CATMAN@ CATMANEXT = @CATMANEXT@ CC = @CC@ +COMPILE_ET = @COMPILE_ET@ CPP = @CPP@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ DBLIB = @DBLIB@ DEPDIR = @DEPDIR@ +DIR_com_err = @DIR_com_err@ DIR_des = @DIR_des@ DIR_roken = @DIR_roken@ DLLTOOL = @DLLTOOL@ @@ -82,20 +86,27 @@ EXTRA_LIB45 = @EXTRA_LIB45@ GROFF = @GROFF@ INCLUDES_roken = @INCLUDES_roken@ INCLUDE_ = @INCLUDE_@ +INCLUDE_des = @INCLUDE_des@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LEX = @LEX@ LIBOBJS = @LIBOBJS@ LIBTOOL = @LIBTOOL@ LIB_ = @LIB_@ LIB_AUTH_SUBDIRS = @LIB_AUTH_SUBDIRS@ +LIB_NDBM = @LIB_NDBM@ +LIB_com_err = @LIB_com_err@ +LIB_com_err_a = @LIB_com_err_a@ +LIB_com_err_so = @LIB_com_err_so@ LIB_des = @LIB_des@ +LIB_des_a = @LIB_des_a@ LIB_des_appl = @LIB_des_appl@ +LIB_des_so = @LIB_des_so@ LIB_kdb = @LIB_kdb@ LIB_otp = @LIB_otp@ LIB_roken = @LIB_roken@ LIB_security = @LIB_security@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ NEED_WRITEAUTH_FALSE = @NEED_WRITEAUTH_FALSE@ NEED_WRITEAUTH_TRUE = @NEED_WRITEAUTH_TRUE@ NROFF = @NROFF@ @@ -103,66 +114,134 @@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ -STRIP = @STRIP@ VERSION = @VERSION@ VOID_RETSIGTYPE = @VOID_RETSIGTYPE@ WFLAGS = @WFLAGS@ WFLAGS_NOIMPLICITINT = @WFLAGS_NOIMPLICITINT@ WFLAGS_NOUNUSED = @WFLAGS_NOUNUSED@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ dpagaix_CFLAGS = @dpagaix_CFLAGS@ dpagaix_LDADD = @dpagaix_LDADD@ install_sh = @install_sh@ -# $Id: Makefile.am,v 1.96 2001/05/16 23:57:10 assar Exp $ +AUTOMAKE_OPTIONS = foreign no-dependencies 1.4b + +SUFFIXES = .hin + +INCLUDES = -I$(top_builddir)/include $(INCLUDES_roken) + +AM_CFLAGS = $(WFLAGS) + +CP = cp + +buildinclude = $(top_builddir)/include + +LIB_XauReadAuth = @LIB_XauReadAuth@ + +LIB_crypt = @LIB_crypt@ +LIB_dbm_firstkey = @LIB_dbm_firstkey@ +LIB_dbopen = @LIB_dbopen@ +LIB_dlopen = @LIB_dlopen@ +LIB_dn_expand = @LIB_dn_expand@ +LIB_el_init = @LIB_el_init@ +LIB_getattr = @LIB_getattr@ +LIB_gethostbyname = @LIB_gethostbyname@ +LIB_getpwent_r = @LIB_getpwent_r@ +LIB_getpwnam_r = @LIB_getpwnam_r@ +LIB_getsockopt = @LIB_getsockopt@ +LIB_logout = @LIB_logout@ +LIB_logwtmp = @LIB_logwtmp@ +LIB_odm_initialize = @LIB_odm_initialize@ +LIB_openpty = @LIB_openpty@ +LIB_pidfile = @LIB_pidfile@ +LIB_res_search = @LIB_res_search@ +LIB_setpcred = @LIB_setpcred@ +LIB_setsockopt = @LIB_setsockopt@ +LIB_socket = @LIB_socket@ +LIB_syslog = @LIB_syslog@ +LIB_tgetent = @LIB_tgetent@ + +LIBS = @LIBS@ + +HESIODLIB = @HESIODLIB@ +HESIODINCLUDE = @HESIODINCLUDE@ +INCLUDE_hesiod = @INCLUDE_hesiod@ +LIB_hesiod = @LIB_hesiod@ + +INCLUDE_krb4 = @INCLUDE_krb4@ +LIB_krb4 = @LIB_krb4@ + +INCLUDE_openldap = @INCLUDE_openldap@ +LIB_openldap = @LIB_openldap@ + +INCLUDE_readline = @INCLUDE_readline@ +LIB_readline = @LIB_readline@ + +LEXLIB = @LEXLIB@ + +NROFF_MAN = groff -mandoc -Tascii +@KRB4_TRUE@LIB_kafs = $(top_builddir)/lib/kafs/libkafs.la $(AIX_EXTRA_KAFS) -AUTOMAKE_OPTIONS = foreign no-dependencies +@KRB5_TRUE@LIB_krb5 = $(top_builddir)/lib/krb5/libkrb5.la \ +@KRB5_TRUE@ $(top_builddir)/lib/asn1/libasn1.la -AM_CFLAGS = $(WFLAGS) +@KRB5_TRUE@LIB_gssapi = $(top_builddir)/lib/gssapi/libgssapi.la + +@DCE_TRUE@LIB_kdfs = $(top_builddir)/lib/kdfs/libkdfs.la + +CHECK_LOCAL = $(PROGRAMS) ACLOCAL_AMFLAGS = -I ../../cf CLEANFILES = roken.h make-roken.c $(XHEADERS) lib_LTLIBRARIES = libroken.la -libroken_la_LDFLAGS = -version-info 12:0:3 +libroken_la_LDFLAGS = -version-info 15:0:6 -noinst_PROGRAMS = make-roken +noinst_PROGRAMS = make-roken snprintf-test nodist_make_roken_SOURCES = make-roken.c -check_PROGRAMS = parse_bytes-test \ - strpftime-test \ - getaddrinfo-test +check_PROGRAMS = \ + base64-test \ + getaddrinfo-test \ + parse_bytes-test \ + snprintf-test \ + strpftime-test TESTS = $(check_PROGRAMS) -LIB_crypt = @LIB_crypt@ - -common_LDADD = libroken.la $(LIB_crypt) +LDADD = libroken.la $(LIB_crypt) +make_roken_LDADD = strpftime_test_SOURCES = strpftime-test.c strftime.c strptime.c snprintf.c -getaddrinfo_test_LDADD = $(common_LDADD) -parse_bytes_test_LDADD = $(common_LDADD) +snprintf_test_SOURCES = snprintf-test.c snprintf.c +snprintf_test_CFLAGS = -DTEST_SNPRINTF libroken_la_SOURCES = \ base64.c \ bswap.c \ concat.c \ - emalloc.c \ environment.c \ eread.c \ - erealloc.c \ esetenv.c \ - estrdup.c \ ewrite.c \ getaddrinfo_hostspec.c \ get_default_username.c \ get_window_size.c \ getarg.c \ getnameinfo_verified.c \ + getprogname.c \ + h_errno.c \ + hostent_find_fqdn.c \ issuid.c \ k_getpwnam.c \ k_getpwuid.c \ @@ -176,6 +255,7 @@ libroken_la_SOURCES = \ roken_gethostby.c \ rtbl.c \ rtbl.h \ + setprogname.c \ signal.c \ simple_exec.c \ snprintf.c \ @@ -196,6 +276,10 @@ EXTRA_libroken_la_SOURCES = \ chown.c \ copyhostent.c \ daemon.c \ + ecalloc.c \ + emalloc.c \ + erealloc.c \ + estrdup.c \ err.c \ err.hin \ errx.c \ @@ -206,7 +290,6 @@ EXTRA_libroken_la_SOURCES = \ freeaddrinfo.c \ freehostent.c \ gai_strerror.c \ - getaddrinfo.c \ getdtablesize.c \ getegid.c \ geteuid.c \ @@ -258,6 +341,7 @@ EXTRA_libroken_la_SOURCES = \ unsetenv.c \ verr.c \ verrx.c \ + vis.hin \ vsyslog.c \ vwarn.c \ vwarnx.c \ @@ -268,19 +352,24 @@ EXTRA_libroken_la_SOURCES = \ EXTRA_DIST = roken.awk roken.h.in -libroken_la_LIBADD = @LTLIBOBJS@ +libroken_la_LIBADD = @LTLIBOBJS@ $(DBLIB) BUILT_SOURCES = make-roken.c roken.h + @have_err_h_TRUE@err_h = -@have_err_h_FALSE@err_h = @have_err_h_FALSE@err.h +@have_err_h_FALSE@err_h = err.h + @have_fnmatch_h_TRUE@fnmatch_h = -@have_fnmatch_h_FALSE@fnmatch_h = @have_fnmatch_h_FALSE@fnmatch.h +@have_fnmatch_h_FALSE@fnmatch_h = fnmatch.h + @have_glob_h_TRUE@glob_h = -@have_glob_h_FALSE@glob_h = @have_glob_h_FALSE@glob.h +@have_glob_h_FALSE@glob_h = glob.h + @have_ifaddrs_h_TRUE@ifaddrs_h = -@have_ifaddrs_h_FALSE@ifaddrs_h = @have_ifaddrs_h_FALSE@ifaddrs.h +@have_ifaddrs_h_FALSE@ifaddrs_h = ifaddrs.h + @have_vis_h_TRUE@vis_h = -@have_vis_h_FALSE@vis_h = @have_vis_h_FALSE@vis.h +@have_vis_h_FALSE@vis_h = vis.h XHEADERS = $(err_h) $(fnmatch_h) $(glob_h) $(ifaddrs_h) $(vis_h) @@ -299,186 +388,238 @@ include_HEADERS = \ nodist_include_HEADERS = roken.h -SUFFIXES = .hin +man_MANS = getarg.3 subdir = lib/roken mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = ../../include/config.h -CONFIG_CLEAN_FILES = -LTLIBRARIES = $(lib_LTLIBRARIES) - - -DEFS = @DEFS@ -I. -I$(srcdir) -I../../include -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -X_CFLAGS = @X_CFLAGS@ -X_LIBS = @X_LIBS@ -X_EXTRA_LIBS = @X_EXTRA_LIBS@ -X_PRE_LIBS = @X_PRE_LIBS@ -libroken_la_DEPENDENCIES = @LTLIBOBJS@ -am_libroken_la_OBJECTS = base64.lo bswap.lo concat.lo emalloc.lo \ -environment.lo eread.lo erealloc.lo esetenv.lo estrdup.lo ewrite.lo \ -getaddrinfo_hostspec.lo get_default_username.lo get_window_size.lo \ -getarg.lo getnameinfo_verified.lo issuid.lo k_getpwnam.lo k_getpwuid.lo \ -mini_inetd.lo net_read.lo net_write.lo parse_bytes.lo parse_time.lo \ -parse_units.lo resolve.lo roken_gethostby.lo rtbl.lo signal.lo \ -simple_exec.lo snprintf.lo socket.lo strcollect.lo timeval.lo \ -tm2time.lo unvis.lo verify.lo vis.lo warnerr.lo write_pid.lo -libroken_la_OBJECTS = $(am_libroken_la_OBJECTS) -check_PROGRAMS = parse_bytes-test$(EXEEXT) strpftime-test$(EXEEXT) \ -getaddrinfo-test$(EXEEXT) -noinst_PROGRAMS = make-roken$(EXEEXT) -PROGRAMS = $(noinst_PROGRAMS) - +CONFIG_HEADER = $(top_builddir)/include/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) + +libroken_la_DEPENDENCIES = @LTLIBOBJS@ +am_libroken_la_OBJECTS = base64.lo bswap.lo concat.lo environment.lo \ + eread.lo esetenv.lo ewrite.lo getaddrinfo_hostspec.lo \ + get_default_username.lo get_window_size.lo getarg.lo \ + getnameinfo_verified.lo getprogname.lo h_errno.lo \ + hostent_find_fqdn.lo issuid.lo k_getpwnam.lo k_getpwuid.lo \ + mini_inetd.lo net_read.lo net_write.lo parse_bytes.lo \ + parse_time.lo parse_units.lo resolve.lo roken_gethostby.lo \ + rtbl.lo setprogname.lo signal.lo simple_exec.lo snprintf.lo \ + socket.lo strcollect.lo timeval.lo tm2time.lo unvis.lo \ + verify.lo vis.lo warnerr.lo write_pid.lo +libroken_la_OBJECTS = $(am_libroken_la_OBJECTS) +check_PROGRAMS = base64-test$(EXEEXT) getaddrinfo-test$(EXEEXT) \ + parse_bytes-test$(EXEEXT) snprintf-test$(EXEEXT) \ + strpftime-test$(EXEEXT) +noinst_PROGRAMS = make-roken$(EXEEXT) snprintf-test$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) + +base64_test_SOURCES = base64-test.c +base64_test_OBJECTS = base64-test.$(OBJEXT) +base64_test_LDADD = $(LDADD) +base64_test_DEPENDENCIES = libroken.la +base64_test_LDFLAGS = getaddrinfo_test_SOURCES = getaddrinfo-test.c -getaddrinfo_test_OBJECTS = getaddrinfo-test.$(OBJEXT) -getaddrinfo_test_DEPENDENCIES = libroken.la -getaddrinfo_test_LDFLAGS = -nodist_make_roken_OBJECTS = make-roken.$(OBJEXT) -make_roken_OBJECTS = $(nodist_make_roken_OBJECTS) -make_roken_LDADD = $(LDADD) -make_roken_DEPENDENCIES = -make_roken_LDFLAGS = +getaddrinfo_test_OBJECTS = getaddrinfo-test.$(OBJEXT) +getaddrinfo_test_LDADD = $(LDADD) +getaddrinfo_test_DEPENDENCIES = libroken.la +getaddrinfo_test_LDFLAGS = +nodist_make_roken_OBJECTS = make-roken.$(OBJEXT) +make_roken_OBJECTS = $(nodist_make_roken_OBJECTS) +make_roken_DEPENDENCIES = +make_roken_LDFLAGS = parse_bytes_test_SOURCES = parse_bytes-test.c -parse_bytes_test_OBJECTS = parse_bytes-test.$(OBJEXT) -parse_bytes_test_DEPENDENCIES = libroken.la -parse_bytes_test_LDFLAGS = -am_strpftime_test_OBJECTS = strpftime-test.$(OBJEXT) strftime.$(OBJEXT) \ -strptime.$(OBJEXT) snprintf.$(OBJEXT) -strpftime_test_OBJECTS = $(am_strpftime_test_OBJECTS) +parse_bytes_test_OBJECTS = parse_bytes-test.$(OBJEXT) +parse_bytes_test_LDADD = $(LDADD) +parse_bytes_test_DEPENDENCIES = libroken.la +parse_bytes_test_LDFLAGS = +am_snprintf_test_OBJECTS = snprintf_test-snprintf-test.$(OBJEXT) \ + snprintf_test-snprintf.$(OBJEXT) +snprintf_test_OBJECTS = $(am_snprintf_test_OBJECTS) +snprintf_test_LDADD = $(LDADD) +snprintf_test_DEPENDENCIES = libroken.la +snprintf_test_LDFLAGS = +am_strpftime_test_OBJECTS = strpftime-test.$(OBJEXT) strftime.$(OBJEXT) \ + strptime.$(OBJEXT) snprintf.$(OBJEXT) +strpftime_test_OBJECTS = $(am_strpftime_test_OBJECTS) strpftime_test_LDADD = $(LDADD) -strpftime_test_DEPENDENCIES = -strpftime_test_LDFLAGS = -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CFLAGS = @CFLAGS@ +strpftime_test_DEPENDENCIES = libroken.la +strpftime_test_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +depcomp = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -DIST_SOURCES = $(libroken_la_SOURCES) $(EXTRA_libroken_la_SOURCES) \ -getaddrinfo-test.c parse_bytes-test.c $(strpftime_test_SOURCES) -HEADERS = $(include_HEADERS) $(nodist_include_HEADERS) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = $(libroken_la_SOURCES) $(EXTRA_libroken_la_SOURCES) \ + base64-test.c getaddrinfo-test.c parse_bytes-test.c \ + $(snprintf_test_SOURCES) $(strpftime_test_SOURCES) -depcomp = -DIST_COMMON = $(include_HEADERS) ChangeLog Makefile.am Makefile.in \ -acinclude.m4 getcap.c getnameinfo.c glob.c install-sh \ -make-print-version.c missing mkinstalldirs +NROFF = nroff +MANS = $(man_MANS) +HEADERS = $(include_HEADERS) $(nodist_include_HEADERS) +DIST_COMMON = $(include_HEADERS) ChangeLog Makefile.am Makefile.in \ + acinclude.m4 freeaddrinfo.c getaddrinfo.c getcap.c \ + getnameinfo.c glob.c install-sh missing mkinstalldirs +SOURCES = $(libroken_la_SOURCES) $(EXTRA_libroken_la_SOURCES) base64-test.c getaddrinfo-test.c $(nodist_make_roken_SOURCES) parse_bytes-test.c $(snprintf_test_SOURCES) $(strpftime_test_SOURCES) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am -GZIP_ENV = --best -SOURCES = $(libroken_la_SOURCES) $(EXTRA_libroken_la_SOURCES) getaddrinfo-test.c $(nodist_make_roken_SOURCES) parse_bytes-test.c $(strpftime_test_SOURCES) -OBJECTS = $(am_libroken_la_OBJECTS) getaddrinfo-test.$(OBJEXT) $(nodist_make_roken_OBJECTS) parse_bytes-test.$(OBJEXT) $(am_strpftime_test_OBJECTS) - -all: all-redirect .SUFFIXES: -.SUFFIXES: .hin .c .h .lo .o .obj -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/roken/Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - - -mostlyclean-libLTLIBRARIES: - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) +.SUFFIXES: .hin .1 .3 .5 .8 .c .cat1 .cat3 .cat5 .cat8 .et .h .lo .o .obj .x -distclean-libLTLIBRARIES: +mostlyclean-libtool: + -rm -f *.lo -maintainer-clean-libLTLIBRARIES: +clean-libtool: + -rm -rf .libs _libs +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/Makefile.am.common $(top_srcdir)/cf/Makefile.am.common $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign lib/roken/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(libdir) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ if test -f $$p; then \ - echo " $(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$p"; \ - $(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$p; \ + echo " $(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$p; \ else :; fi; \ done uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \ - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ done -mostlyclean-compile: - -rm -f *.o core *.core - -rm -f *.$(OBJEXT) - -clean-compile: - -distclean-compile: - -rm -f *.tab.c - -maintainer-clean-compile: - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -maintainer-clean-libtool: - -libroken.la: $(libroken_la_OBJECTS) $(libroken_la_DEPENDENCIES) +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) +libroken.la: $(libroken_la_OBJECTS) $(libroken_la_DEPENDENCIES) $(LINK) -rpath $(libdir) $(libroken_la_LDFLAGS) $(libroken_la_OBJECTS) $(libroken_la_LIBADD) $(LIBS) -mostlyclean-checkPROGRAMS: - clean-checkPROGRAMS: -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) -distclean-checkPROGRAMS: - -maintainer-clean-checkPROGRAMS: - -mostlyclean-noinstPROGRAMS: - clean-noinstPROGRAMS: -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) - -distclean-noinstPROGRAMS: - -maintainer-clean-noinstPROGRAMS: - -getaddrinfo-test$(EXEEXT): $(getaddrinfo_test_OBJECTS) $(getaddrinfo_test_DEPENDENCIES) +base64-test$(EXEEXT): $(base64_test_OBJECTS) $(base64_test_DEPENDENCIES) + @rm -f base64-test$(EXEEXT) + $(LINK) $(base64_test_LDFLAGS) $(base64_test_OBJECTS) $(base64_test_LDADD) $(LIBS) +getaddrinfo-test$(EXEEXT): $(getaddrinfo_test_OBJECTS) $(getaddrinfo_test_DEPENDENCIES) @rm -f getaddrinfo-test$(EXEEXT) $(LINK) $(getaddrinfo_test_LDFLAGS) $(getaddrinfo_test_OBJECTS) $(getaddrinfo_test_LDADD) $(LIBS) - -make-roken$(EXEEXT): $(make_roken_OBJECTS) $(make_roken_DEPENDENCIES) +make-roken$(EXEEXT): $(make_roken_OBJECTS) $(make_roken_DEPENDENCIES) @rm -f make-roken$(EXEEXT) $(LINK) $(make_roken_LDFLAGS) $(make_roken_OBJECTS) $(make_roken_LDADD) $(LIBS) - -parse_bytes-test$(EXEEXT): $(parse_bytes_test_OBJECTS) $(parse_bytes_test_DEPENDENCIES) +parse_bytes-test$(EXEEXT): $(parse_bytes_test_OBJECTS) $(parse_bytes_test_DEPENDENCIES) @rm -f parse_bytes-test$(EXEEXT) $(LINK) $(parse_bytes_test_LDFLAGS) $(parse_bytes_test_OBJECTS) $(parse_bytes_test_LDADD) $(LIBS) - -strpftime-test$(EXEEXT): $(strpftime_test_OBJECTS) $(strpftime_test_DEPENDENCIES) +snprintf_test-snprintf-test.$(OBJEXT): snprintf-test.c +snprintf_test-snprintf.$(OBJEXT): snprintf.c +snprintf-test$(EXEEXT): $(snprintf_test_OBJECTS) $(snprintf_test_DEPENDENCIES) + @rm -f snprintf-test$(EXEEXT) + $(LINK) $(snprintf_test_LDFLAGS) $(snprintf_test_OBJECTS) $(snprintf_test_LDADD) $(LIBS) +strpftime-test$(EXEEXT): $(strpftime_test_OBJECTS) $(strpftime_test_DEPENDENCIES) @rm -f strpftime-test$(EXEEXT) $(LINK) $(strpftime_test_LDFLAGS) $(strpftime_test_OBJECTS) $(strpftime_test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + .c.o: - $(COMPILE) -c $< + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + .c.obj: $(COMPILE) -c `cygpath -w $<` + .c.lo: - $(LTCOMPILE) -c -o $@ $< + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< + +snprintf_test-snprintf-test.o: snprintf-test.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(snprintf_test_CFLAGS) $(CFLAGS) -c -o snprintf_test-snprintf-test.o `test -f snprintf-test.c || echo '$(srcdir)/'`snprintf-test.c +snprintf_test-snprintf-test.obj: snprintf-test.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(snprintf_test_CFLAGS) $(CFLAGS) -c -o snprintf_test-snprintf-test.obj `cygpath -w snprintf-test.c` + +snprintf_test-snprintf-test.lo: snprintf-test.c + $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(snprintf_test_CFLAGS) $(CFLAGS) -c -o snprintf_test-snprintf-test.lo `test -f snprintf-test.c || echo '$(srcdir)/'`snprintf-test.c + +snprintf_test-snprintf.o: snprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(snprintf_test_CFLAGS) $(CFLAGS) -c -o snprintf_test-snprintf.o `test -f snprintf.c || echo '$(srcdir)/'`snprintf.c + +snprintf_test-snprintf.obj: snprintf.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(snprintf_test_CFLAGS) $(CFLAGS) -c -o snprintf_test-snprintf.obj `cygpath -w snprintf.c` + +snprintf_test-snprintf.lo: snprintf.c + $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(snprintf_test_CFLAGS) $(CFLAGS) -c -o snprintf_test-snprintf.lo `test -f snprintf.c || echo '$(srcdir)/'`snprintf.c +uninstall-info-am: + +man3dir = $(mandir)/man3 +install-man3: $(man3_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(man3dir) + @list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.3*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man3dir)/$$inst"; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(man3dir)/$$inst; \ + done +uninstall-man3: + @$(NORMAL_UNINSTALL) + @list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.3*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f $(DESTDIR)$(man3dir)/$$inst"; \ + rm -f $(DESTDIR)$(man3dir)/$$inst; \ + done install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(includedir) @list='$(include_HEADERS)'; for p in $$list; do \ - if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$f"; \ - $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$f; \ + echo " $(INSTALL_HEADER) $$d$$p $(DESTDIR)$(includedir)/$$f"; \ + $(INSTALL_HEADER) $$d$$p $(DESTDIR)$(includedir)/$$f; \ done uninstall-includeHEADERS: @@ -488,15 +629,14 @@ uninstall-includeHEADERS: echo " rm -f $(DESTDIR)$(includedir)/$$f"; \ rm -f $(DESTDIR)$(includedir)/$$f; \ done - install-nodist_includeHEADERS: $(nodist_include_HEADERS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(includedir) @list='$(nodist_include_HEADERS)'; for p in $$list; do \ - if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$f"; \ - $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$f; \ + echo " $(INSTALL_HEADER) $$d$$p $(DESTDIR)$(includedir)/$$f"; \ + $(INSTALL_HEADER) $$d$$p $(DESTDIR)$(includedir)/$$f; \ done uninstall-nodist_includeHEADERS: @@ -534,16 +674,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ GTAGS: here=`CDPATH=: && cd $(top_builddir) && pwd` \ && cd $(top_srcdir) \ - && gtags -i $$here - -mostlyclean-tags: - -clean-tags: + && gtags -i $(GTAGS_ARGS) $$here distclean-tags: - -rm -f TAGS ID + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH -maintainer-clean-tags: check-TESTS: $(TESTS) @failed=0; all=0; xfail=0; xpass=0; \ srcdir=$(srcdir); export srcdir; \ @@ -599,11 +734,18 @@ check-TESTS: $(TESTS) test "$$failed" -eq 0; \ fi -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @for file in $(DISTFILES); do \ - d=$(srcdir); \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ if test -d $$d/$$file; then \ cp -pR $$d/$$file $(distdir) \ || exit 1; \ @@ -613,104 +755,235 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done -info-am: -info: info-am -dvi-am: -dvi: dvi-am + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="${top_distdir}" distdir="$(distdir)" \ + dist-hook check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local check: check-am -installcheck-am: -installcheck: installcheck-am -all-recursive-am: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-recursive +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(MANS) $(HEADERS) all-local -install-exec-am: install-libLTLIBRARIES -install-exec: install-exec-am +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(man3dir) $(DESTDIR)$(includedir) $(DESTDIR)$(includedir) -install-data-am: install-includeHEADERS install-nodist_includeHEADERS +install: install-am +install-exec: install-exec-am install-data: install-data-am +uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -install: install-am -uninstall-am: uninstall-libLTLIBRARIES uninstall-includeHEADERS \ - uninstall-nodist_includeHEADERS -uninstall: uninstall-am -all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install -installdirs: - $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir) \ - $(DESTDIR)$(nodist_includedir) - +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* maintainer-clean-generic: - -rm -f Makefile.in + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \ - mostlyclean-libtool mostlyclean-checkPROGRAMS \ - mostlyclean-noinstPROGRAMS mostlyclean-tags \ - mostlyclean-generic +clean: clean-am -mostlyclean: mostlyclean-am +clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ + clean-libtool clean-noinstPROGRAMS mostlyclean-am -clean-am: clean-libLTLIBRARIES clean-compile clean-libtool \ - clean-checkPROGRAMS clean-noinstPROGRAMS clean-tags \ - clean-generic mostlyclean-am +distclean: distclean-am -clean: clean-am +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags -distclean-am: distclean-libLTLIBRARIES distclean-compile \ - distclean-libtool distclean-checkPROGRAMS \ - distclean-noinstPROGRAMS distclean-tags \ - distclean-generic clean-am - -rm -f libtool +dvi: dvi-am -distclean: distclean-am +dvi-am: -maintainer-clean-am: maintainer-clean-libLTLIBRARIES \ - maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-checkPROGRAMS \ - maintainer-clean-noinstPROGRAMS maintainer-clean-tags \ - maintainer-clean-generic distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." +info: info-am + +info-am: + +install-data-am: install-data-local install-includeHEADERS install-man \ + install-nodist_includeHEADERS + +install-exec-am: install-libLTLIBRARIES + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook + +install-info: install-info-am + +install-man: install-man3 + +installcheck-am: maintainer-clean: maintainer-clean-am -.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ -clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ -uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ -distclean-compile clean-compile maintainer-clean-compile \ -mostlyclean-libtool distclean-libtool clean-libtool \ -maintainer-clean-libtool mostlyclean-checkPROGRAMS \ -distclean-checkPROGRAMS clean-checkPROGRAMS \ -maintainer-clean-checkPROGRAMS mostlyclean-noinstPROGRAMS \ -distclean-noinstPROGRAMS clean-noinstPROGRAMS \ -maintainer-clean-noinstPROGRAMS uninstall-includeHEADERS \ -install-includeHEADERS uninstall-nodist_includeHEADERS \ -install-nodist_includeHEADERS tags mostlyclean-tags distclean-tags \ -clean-tags maintainer-clean-tags check-TESTS distdir info-am info \ -dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ -install-exec-am install-exec install-data-am install-data install-am \ -install uninstall-am uninstall all-redirect all-am all install-strip \ -installdirs mostlyclean-generic distclean-generic clean-generic \ -maintainer-clean-generic clean mostlyclean distclean maintainer-clean - - -$(LTLIBOBJS) $(libroken_la_OBJECTS): $(include_HEADERS) roken.h +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-includeHEADERS uninstall-info-am \ + uninstall-libLTLIBRARIES uninstall-man \ + uninstall-nodist_includeHEADERS + +uninstall-man: uninstall-man3 + +.PHONY: GTAGS all all-am all-local check check-TESTS check-am \ + check-local clean clean-checkPROGRAMS clean-generic \ + clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS \ + distclean distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-data-local \ + install-exec install-exec-am install-includeHEADERS \ + install-info install-info-am install-libLTLIBRARIES install-man \ + install-man3 install-nodist_includeHEADERS install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool tags uninstall \ + uninstall-am uninstall-includeHEADERS uninstall-info-am \ + uninstall-libLTLIBRARIES uninstall-man uninstall-man3 \ + uninstall-nodist_includeHEADERS + + +install-suid-programs: + @foo='$(bin_SUIDS)'; \ + for file in $$foo; do \ + x=$(DESTDIR)$(bindir)/$$file; \ + if chown 0:0 $$x && chmod u+s $$x; then :; else \ + echo "*"; \ + echo "* Failed to install $$x setuid root"; \ + echo "*"; \ + fi; done + +install-exec-hook: install-suid-programs + +install-build-headers:: $(include_HEADERS) $(build_HEADERZ) + @foo='$(include_HEADERS) $(build_HEADERZ)'; \ + for f in $$foo; do \ + f=`basename $$f`; \ + if test -f "$(srcdir)/$$f"; then file="$(srcdir)/$$f"; \ + else file="$$f"; fi; \ + if cmp -s $$file $(buildinclude)/$$f 2> /dev/null ; then \ + : ; else \ + echo " $(CP) $$file $(buildinclude)/$$f"; \ + $(CP) $$file $(buildinclude)/$$f; \ + fi ; \ + done + +all-local: install-build-headers +#NROFF_MAN = nroff -man +.1.cat1: + $(NROFF_MAN) $< > $@ +.3.cat3: + $(NROFF_MAN) $< > $@ +.5.cat5: + $(NROFF_MAN) $< > $@ +.8.cat8: + $(NROFF_MAN) $< > $@ + +dist-cat1-mans: + @foo='$(man1_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.1) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat1/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-cat3-mans: + @foo='$(man3_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.3) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat3/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-cat5-mans: + @foo='$(man5_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.5) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat5/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-cat8-mans: + @foo='$(man8_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.8) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat8/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-hook: dist-cat1-mans dist-cat3-mans dist-cat5-mans dist-cat8-mans + +install-cat-mans: + $(SHELL) $(top_srcdir)/cf/install-catman.sh "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_MANS) + +install-data-local: install-cat-mans + +.et.h: + $(COMPILE_ET) $< +.et.c: + $(COMPILE_ET) $< + +.x.c: + @cmp -s $< $@ 2> /dev/null || cp $< $@ + +check-local:: + @foo='$(CHECK_LOCAL)'; \ + if test "$$foo"; then \ + failed=0; all=0; \ + for i in $$foo; do \ + all=`expr $$all + 1`; \ + if ./$$i --version > /dev/null 2>&1; then \ + echo "PASS: $$i"; \ + else \ + echo "FAIL: $$i"; \ + failed=`expr $$failed + 1`; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="$$failed of $$all tests failed"; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +$(LTLIBOBJS) $(libroken_la_OBJECTS): $(include_HEADERS) roken.h $(XHEADERS) .hin.h: cp $< $@ @@ -721,7 +994,6 @@ roken.h: make-roken$(EXEEXT) make-roken.c: roken.h.in roken.awk $(AWK) -f $(srcdir)/roken.awk $(srcdir)/roken.h.in > make-roken.c - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/crypto/heimdal/lib/roken/base64-test.c b/crypto/heimdal/lib/roken/base64-test.c new file mode 100644 index 0000000..eace04b --- /dev/null +++ b/crypto/heimdal/lib/roken/base64-test.c @@ -0,0 +1,99 @@ +/* + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +RCSID("$Id: base64-test.c,v 1.2 2001/05/29 13:12:21 assar Exp $"); +#endif + +#include <roken.h> +#include <base64.h> + +int +main(int argc, char **argv) +{ + int numerr = 0; + int numtest = 1; + struct test { + void *data; + size_t len; + const char *result; + } *t, tests[] = { + { "", 0 , "" }, + { "1", 1, "MQ==" }, + { "22", 2, "MjI=" }, + { "333", 3, "MzMz" }, + { "4444", 4, "NDQ0NA==" }, + { "55555", 5, "NTU1NTU=" }, + { "abc:def", 7, "YWJjOmRlZg==" }, + { NULL } + }; + for(t = tests; t->data; t++) { + char *str; + int len; + len = base64_encode(t->data, t->len, &str); + if(strcmp(str, t->result) != 0) { + fprintf(stderr, "failed test %d: %s != %s\n", numtest, + str, t->result); + numerr++; + } + free(str); + str = strdup(t->result); + len = base64_decode(t->result, str); + if(len != t->len) { + fprintf(stderr, "failed test %d: len %d != %d\n", numtest, + len, t->len); + numerr++; + } else if(memcmp(str, t->data, t->len) != 0) { + fprintf(stderr, "failed test %d: data\n", numtest); + numerr++; + } + free(str); + numtest++; + } + + { + char str[32]; + if(base64_decode("M=M=", str) != -1) { + fprintf(stderr, "failed test %d: successful decode of `M=M='\n", + numtest++); + numerr++; + } + if(base64_decode("MQ===", str) != -1) { + fprintf(stderr, "failed test %d: successful decode of `MQ==='\n", + numtest++); + numerr++; + } + } + return numerr; +} diff --git a/crypto/heimdal/lib/roken/base64.c b/crypto/heimdal/lib/roken/base64.c index daed869..21e79c1 100644 --- a/crypto/heimdal/lib/roken/base64.c +++ b/crypto/heimdal/lib/roken/base64.c @@ -1,23 +1,23 @@ /* - * Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1995-2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * 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. Neither the name of the Institute 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 INSTITUTE 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 @@ -33,114 +33,104 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: base64.c,v 1.4 1999/12/02 16:58:45 joda Exp $"); +RCSID("$Id: base64.c,v 1.5 2001/05/28 17:33:41 joda Exp $"); #endif #include <stdlib.h> #include <string.h> #include "base64.h" -static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static char base64_chars[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static int pos(char c) +static int +pos(char c) { - char *p; - for(p = base64; *p; p++) - if(*p == c) - return p - base64; - return -1; + char *p; + for (p = base64_chars; *p; p++) + if (*p == c) + return p - base64_chars; + return -1; } -int base64_encode(const void *data, int size, char **str) +int +base64_encode(const void *data, int size, char **str) { - char *s, *p; - int i; - int c; - const unsigned char *q; + char *s, *p; + int i; + int c; + const unsigned char *q; - p = s = (char*)malloc(size*4/3+4); - if (p == NULL) - return -1; - q = (const unsigned char*)data; - i=0; - for(i = 0; i < size;){ - c=q[i++]; - c*=256; - if(i < size) - c+=q[i]; - i++; - c*=256; - if(i < size) - c+=q[i]; - i++; - p[0]=base64[(c&0x00fc0000) >> 18]; - p[1]=base64[(c&0x0003f000) >> 12]; - p[2]=base64[(c&0x00000fc0) >> 6]; - p[3]=base64[(c&0x0000003f) >> 0]; - if(i > size) - p[3]='='; - if(i > size+1) - p[2]='='; - p+=4; - } - *p=0; - *str = s; - return strlen(s); + p = s = (char *) malloc(size * 4 / 3 + 4); + if (p == NULL) + return -1; + q = (const unsigned char *) data; + i = 0; + for (i = 0; i < size;) { + c = q[i++]; + c *= 256; + if (i < size) + c += q[i]; + i++; + c *= 256; + if (i < size) + c += q[i]; + i++; + p[0] = base64_chars[(c & 0x00fc0000) >> 18]; + p[1] = base64_chars[(c & 0x0003f000) >> 12]; + p[2] = base64_chars[(c & 0x00000fc0) >> 6]; + p[3] = base64_chars[(c & 0x0000003f) >> 0]; + if (i > size) + p[3] = '='; + if (i > size + 1) + p[2] = '='; + p += 4; + } + *p = 0; + *str = s; + return strlen(s); } -int base64_decode(const char *str, void *data) +#define DECODE_ERROR 0xffffffff + +static unsigned int +token_decode(const char *token) { - const char *p; - unsigned char *q; - int c; - int x; - int done = 0; - q=(unsigned char*)data; - for(p=str; *p && !done; p+=4){ - x = pos(p[0]); - if(x >= 0) - c = x; - else{ - done = 3; - break; + int i; + unsigned int val = 0; + int marker = 0; + if (strlen(token) < 4) + return DECODE_ERROR; + for (i = 0; i < 4; i++) { + val *= 64; + if (token[i] == '=') + marker++; + else if (marker > 0) + return DECODE_ERROR; + else + val += pos(token[i]); } - c*=64; - - x = pos(p[1]); - if(x >= 0) - c += x; - else - return -1; - c*=64; - - if(p[2] == '=') - done++; - else{ - x = pos(p[2]); - if(x >= 0) - c += x; - else - return -1; - } - c*=64; - - if(p[3] == '=') - done++; - else{ - if(done) - return -1; - x = pos(p[3]); - if(x >= 0) - c += x; - else - return -1; + if (marker > 2) + return DECODE_ERROR; + return (marker << 24) | val; +} + +int +base64_decode(const char *str, void *data) +{ + const char *p; + unsigned char *q; + + q = data; + for (p = str; *p && (*p == '=' || strchr(base64_chars, *p)); p += 4) { + unsigned int val = token_decode(p); + unsigned int marker = (val >> 24) & 0xff; + if (val == DECODE_ERROR) + return -1; + *q++ = (val >> 16) & 0xff; + if (marker < 2) + *q++ = (val >> 8) & 0xff; + if (marker < 1) + *q++ = val & 0xff; } - if(done < 3) - *q++=(c&0x00ff0000)>>16; - - if(done < 2) - *q++=(c&0x0000ff00)>>8; - if(done < 1) - *q++=(c&0x000000ff)>>0; - } - return q - (unsigned char*)data; + return q - (unsigned char *) data; } diff --git a/crypto/heimdal/lib/roken/ecalloc.c b/crypto/heimdal/lib/roken/ecalloc.c new file mode 100644 index 0000000..142704f --- /dev/null +++ b/crypto/heimdal/lib/roken/ecalloc.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +RCSID("$Id: ecalloc.c,v 1.1 2001/06/17 12:09:37 assar Exp $"); +#endif + +#include <stdlib.h> +#include <err.h> + +#include <roken.h> + +/* + * Like calloc but never fails. + */ + +void * +ecalloc (size_t number, size_t size) +{ + void *tmp = calloc (number, size); + + if (tmp == NULL && number * size != 0) + errx (1, "calloc %lu failed", (unsigned long)number * size); + return tmp; +} diff --git a/crypto/heimdal/lib/roken/emalloc.c b/crypto/heimdal/lib/roken/emalloc.c index bbea1e0..e2734f3 100644 --- a/crypto/heimdal/lib/roken/emalloc.c +++ b/crypto/heimdal/lib/roken/emalloc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: emalloc.c,v 1.4 1999/12/02 16:58:45 joda Exp $"); +RCSID("$Id: emalloc.c,v 1.5 2001/06/17 12:07:48 assar Exp $"); #endif #include <stdlib.h> @@ -51,6 +51,6 @@ emalloc (size_t sz) void *tmp = malloc (sz); if (tmp == NULL && sz != 0) - err (1, "malloc %lu", (unsigned long)sz); + errx (1, "malloc %lu failed", (unsigned long)sz); return tmp; } diff --git a/crypto/heimdal/lib/roken/erealloc.c b/crypto/heimdal/lib/roken/erealloc.c index 8afa8f3..8eddd2b 100644 --- a/crypto/heimdal/lib/roken/erealloc.c +++ b/crypto/heimdal/lib/roken/erealloc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: erealloc.c,v 1.4 1999/12/02 16:58:45 joda Exp $"); +RCSID("$Id: erealloc.c,v 1.5 2001/06/17 12:08:05 assar Exp $"); #endif #include <stdlib.h> @@ -51,6 +51,6 @@ erealloc (void *ptr, size_t sz) void *tmp = realloc (ptr, sz); if (tmp == NULL && sz != 0) - err (1, "realloc %lu", (unsigned long)sz); + errx (1, "realloc %lu failed", (unsigned long)sz); return tmp; } diff --git a/crypto/heimdal/lib/roken/estrdup.c b/crypto/heimdal/lib/roken/estrdup.c index 8c0d9a7..75d2721 100644 --- a/crypto/heimdal/lib/roken/estrdup.c +++ b/crypto/heimdal/lib/roken/estrdup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: estrdup.c,v 1.2 1999/12/02 16:58:45 joda Exp $"); +RCSID("$Id: estrdup.c,v 1.3 2001/06/17 12:07:56 assar Exp $"); #endif #include <stdlib.h> @@ -51,6 +51,6 @@ estrdup (const char *str) char *tmp = strdup (str); if (tmp == NULL) - err (1, "strdup"); + errx (1, "strdup failed"); return tmp; } diff --git a/crypto/heimdal/lib/roken/getaddrinfo.c b/crypto/heimdal/lib/roken/getaddrinfo.c index 4b94d3d..83957bb 100644 --- a/crypto/heimdal/lib/roken/getaddrinfo.c +++ b/crypto/heimdal/lib/roken/getaddrinfo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: getaddrinfo.c,v 1.9 2000/07/24 02:34:20 assar Exp $"); +RCSID("$Id: getaddrinfo.c,v 1.12 2001/08/17 13:06:57 joda Exp $"); #endif #include "roken.h" @@ -172,6 +172,13 @@ const_v6 (struct addrinfo *a, void *data, int port) } #endif +/* this is mostly a hack for some versions of AIX that has a prototype + for in6addr_loopback but no actual symbol in libc */ +#if defined(HAVE_IPV6) && !defined(HAVE_IN6ADDR_LOOPBACK) && defined(IN6ADDR_LOOPBACK_INIT) +#define in6addr_loopback _roken_in6addr_loopback +struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; +#endif + static int get_null (const struct addrinfo *hints, int port, int protocol, int socktype, @@ -215,26 +222,6 @@ get_null (const struct addrinfo *hints, return 0; } -/* - * Try to find a fqdn (with `.') in he if possible, else return h_name - */ - -static char * -find_fqdn (const struct hostent *he) -{ - char *ret = he->h_name; - char **h; - - if (strchr (ret, '.') == NULL) - for (h = he->h_aliases; *h; ++h) { - if (strchr (*h, '.') != NULL) { - ret = *h; - break; - } - } - return ret; -} - static int add_hostent (int port, int protocol, int socktype, struct addrinfo ***current, @@ -247,22 +234,23 @@ add_hostent (int port, int protocol, int socktype, if (*flags & AI_CANONNAME) { struct hostent *he2 = NULL; + const char *tmp_canon; - canonname = find_fqdn (he); - if (strchr (canonname, '.') == NULL) { + tmp_canon = hostent_find_fqdn (he); + if (strchr (tmp_canon, '.') == NULL) { int error; he2 = getipnodebyaddr (he->h_addr_list[0], he->h_length, he->h_addrtype, &error); if (he2 != NULL) { - char *tmp = find_fqdn (he2); + const char *tmp = hostent_find_fqdn (he2); if (strchr (tmp, '.') != NULL) - canonname = tmp; + tmp_canon = tmp; } } - canonname = strdup (canonname); + canonname = strdup (tmp_canon); if (he2 != NULL) freehostent (he2); if (canonname == NULL) diff --git a/crypto/heimdal/lib/roken/getarg.c b/crypto/heimdal/lib/roken/getarg.c index dc2df50..90bc2cc 100644 --- a/crypto/heimdal/lib/roken/getarg.c +++ b/crypto/heimdal/lib/roken/getarg.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: getarg.c,v 1.40 2001/04/25 12:06:10 assar Exp $"); +RCSID("$Id: getarg.c,v 1.44 2001/09/10 13:22:43 assar Exp $"); #endif #include <stdio.h> @@ -139,7 +139,7 @@ mandoc_template(struct getargs *args, print_arg(buf, sizeof(buf), 1, 0, args + i); printf(".Oo Fl %c%s \\*(Ba Xo\n", args[i].short_name, buf); print_arg(buf, sizeof(buf), 1, 1, args + i); - printf(".Fl -%s%s Oc\n.Xc\n", args[i].long_name, buf); + printf(".Fl -%s%s\n.Xc\n.Oc\n", args[i].long_name, buf); } /* if(args[i].type == arg_strings) @@ -402,7 +402,11 @@ arg_match_long(struct getargs *args, size_t num_args, *flag = !negate; return 0; } else if (*optarg && strcmp(optarg + 1, "maybe") == 0) { +#ifdef HAVE_RANDOM + *flag = random() & 1; +#else *flag = rand() & 1; +#endif } else { *flag = negate; return 0; @@ -415,13 +419,8 @@ arg_match_long(struct getargs *args, size_t num_args, if (*optarg == '\0') val = 1; - else { - char *endstr; - - val = strtol (optarg, &endstr, 0); - if (endstr == optarg) - return ARG_ERR_BAD_ARG; - } + else if(sscanf(optarg + 1, "%d", &val) != 1) + return ARG_ERR_BAD_ARG; *(int *)current->value += val; return 0; } @@ -522,7 +521,13 @@ getarg(struct getargs *args, size_t num_args, int i; int ret = 0; +#if defined(HAVE_SRANDOMDEV) + srandomdev(); +#elif defined(HAVE_RANDOM) + srandom(time(NULL)); +#else srand (time(NULL)); +#endif (*optind)++; for(i = *optind; i < argc; i++) { if(argv[i][0] != '-') diff --git a/crypto/heimdal/lib/roken/getdtablesize.c b/crypto/heimdal/lib/roken/getdtablesize.c index 9f9c74b..183e8ff 100644 --- a/crypto/heimdal/lib/roken/getdtablesize.c +++ b/crypto/heimdal/lib/roken/getdtablesize.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan + * Copyright (c) 1995-2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: getdtablesize.c,v 1.10 1999/12/02 16:58:46 joda Exp $"); +RCSID("$Id: getdtablesize.c,v 1.11 2001/06/20 00:00:38 joda Exp $"); #endif #include "roken.h" @@ -82,7 +82,7 @@ int getdtablesize(void) mib[0] = CTL_KERN; mib[1] = KERN_MAXFILES; len = sizeof(files); - sysctl(&mib, 2, &files, sizeof(nfil), NULL, 0); + sysctl(&mib, 2, &files, sizeof(files), NULL, 0); #endif /* defined(HAVE_SYSCTL) */ #endif /* !definded(HAVE_GETRLIMIT) */ #endif /* !defined(HAVE_SYSCONF) */ diff --git a/crypto/heimdal/lib/roken/getifaddrs.c b/crypto/heimdal/lib/roken/getifaddrs.c index 04935ed..d8cf1eb 100644 --- a/crypto/heimdal/lib/roken/getifaddrs.c +++ b/crypto/heimdal/lib/roken/getifaddrs.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: getifaddrs.c,v 1.5 2001/04/17 08:27:47 joda Exp $"); +RCSID("$Id: getifaddrs.c,v 1.7 2001/11/30 03:27:30 assar Exp $"); #endif #include "roken.h" @@ -66,13 +66,11 @@ getifaddrs2(struct ifaddrs **ifap, size_t buf_size; char *buf; struct ifconf ifconf; - int num, j = 0; char *p; size_t sz; struct sockaddr sa_zero; struct ifreq *ifr; - - struct ifaddrs *start, **end = &start; + struct ifaddrs *start = NULL, **end = &start; buf = NULL; @@ -109,8 +107,6 @@ getifaddrs2(struct ifaddrs **ifap, buf_size *= 2; } - num = ifconf.ifc_len / ifreq_sz; - j = 0; for (p = ifconf.ifc_buf; p < ifconf.ifc_buf + ifconf.ifc_len; p += sz) { @@ -140,6 +136,10 @@ getifaddrs2(struct ifaddrs **ifap, } *end = malloc(sizeof(**end)); + if (*end == NULL) { + ret = ENOMEM; + goto error_out; + } (*end)->ifa_next = NULL; (*end)->ifa_name = strdup(ifr->ifr_name); @@ -174,12 +174,138 @@ getifaddrs2(struct ifaddrs **ifap, free(buf); return 0; error_out: + freeifaddrs(start); close(fd); free(buf); errno = ret; return -1; } +#if defined(HAVE_IPV6) && defined(SIOCGLIFCONF) && defined(SIOCGLIFFLAGS) +static int +getlifaddrs2(struct ifaddrs **ifap, + int af, int siocgifconf, int siocgifflags, + size_t ifreq_sz) +{ + int ret; + int fd; + size_t buf_size; + char *buf; + struct lifconf ifconf; + char *p; + size_t sz; + struct sockaddr sa_zero; + struct lifreq *ifr; + struct ifaddrs *start = NULL, **end = &start; + + buf = NULL; + + memset (&sa_zero, 0, sizeof(sa_zero)); + fd = socket(af, SOCK_DGRAM, 0); + if (fd < 0) + return -1; + + buf_size = 8192; + for (;;) { + buf = calloc(1, buf_size); + if (buf == NULL) { + ret = ENOMEM; + goto error_out; + } + ifconf.lifc_family = AF_UNSPEC; + ifconf.lifc_flags = 0; + ifconf.lifc_len = buf_size; + ifconf.lifc_buf = buf; + + /* + * Solaris returns EINVAL when the buffer is too small. + */ + if (ioctl (fd, siocgifconf, &ifconf) < 0 && errno != EINVAL) { + ret = errno; + goto error_out; + } + /* + * Can the difference between a full and a overfull buf + * be determined? + */ + + if (ifconf.lifc_len < buf_size) + break; + free (buf); + buf_size *= 2; + } + + for (p = ifconf.lifc_buf; + p < ifconf.lifc_buf + ifconf.lifc_len; + p += sz) { + struct lifreq ifreq; + struct sockaddr_storage *sa; + size_t salen; + + ifr = (struct lifreq *)p; + sa = &ifr->lifr_addr; + + sz = ifreq_sz; + salen = sizeof(struct sockaddr_storage); +#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN + salen = sa->sa_len; + sz = max(sz, sizeof(ifr->ifr_name) + sa->sa_len); +#endif +#ifdef SA_LEN + salen = SA_LEN(sa); + sz = max(sz, sizeof(ifr->ifr_name) + SA_LEN(sa)); +#endif + memset (&ifreq, 0, sizeof(ifreq)); + memcpy (ifreq.lifr_name, ifr->lifr_name, sizeof(ifr->lifr_name)); + + if (ioctl(fd, siocgifflags, &ifreq) < 0) { + ret = errno; + goto error_out; + } + + *end = malloc(sizeof(**end)); + + (*end)->ifa_next = NULL; + (*end)->ifa_name = strdup(ifr->lifr_name); + (*end)->ifa_flags = ifreq.lifr_flags; + (*end)->ifa_addr = malloc(salen); + memcpy((*end)->ifa_addr, sa, salen); + (*end)->ifa_netmask = NULL; + +#if 0 + /* fix these when we actually need them */ + if(ifreq.ifr_flags & IFF_BROADCAST) { + (*end)->ifa_broadaddr = malloc(sizeof(ifr->ifr_broadaddr)); + memcpy((*end)->ifa_broadaddr, &ifr->ifr_broadaddr, + sizeof(ifr->ifr_broadaddr)); + } else if(ifreq.ifr_flags & IFF_POINTOPOINT) { + (*end)->ifa_dstaddr = malloc(sizeof(ifr->ifr_dstaddr)); + memcpy((*end)->ifa_dstaddr, &ifr->ifr_dstaddr, + sizeof(ifr->ifr_dstaddr)); + } else + (*end)->ifa_dstaddr = NULL; +#else + (*end)->ifa_dstaddr = NULL; +#endif + + (*end)->ifa_data = NULL; + + end = &(*end)->ifa_next; + + } + *ifap = start; + close(fd); + free(buf); + return 0; + error_out: + freeifaddrs(start); + close(fd); + free(buf); + errno = ret; + return -1; +} +#endif /* defined(HAVE_IPV6) && defined(SIOCGLIFCONF) && defined(SIOCGLIFFLAGS) */ + int getifaddrs(struct ifaddrs **ifap) { @@ -190,6 +316,11 @@ getifaddrs(struct ifaddrs **ifap) ret = getifaddrs2 (ifap, AF_INET6, SIOCGIF6CONF, SIOCGIF6FLAGS, sizeof(struct in6_ifreq)); #endif +#if defined(HAVE_IPV6) && defined(SIOCGLIFCONF) && defined(SIOCGLIFFLAGS) + if (ret) + ret = getlifaddrs2 (ifap, AF_INET6, SIOCGLIFCONF, SIOCGLIFFLAGS, + sizeof(struct lifreq)); +#endif #if defined(HAVE_IPV6) && defined(SIOCGIFCONF) if (ret) ret = getifaddrs2 (ifap, AF_INET6, SIOCGIFCONF, SIOCGIFFLAGS, diff --git a/crypto/heimdal/lib/roken/getnameinfo.c b/crypto/heimdal/lib/roken/getnameinfo.c index 0f0cbd1..44fcb04 100644 --- a/crypto/heimdal/lib/roken/getnameinfo.c +++ b/crypto/heimdal/lib/roken/getnameinfo.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: getnameinfo.c,v 1.3 2001/02/09 14:45:30 assar Exp $"); +RCSID("$Id: getnameinfo.c,v 1.4 2001/07/09 15:14:19 assar Exp $"); #endif #include "roken.h" @@ -56,7 +56,7 @@ doit (int af, addrlen, af); if (he != NULL) { - strlcpy (host, he->h_name, hostlen); + strlcpy (host, hostent_find_fqdn(he), hostlen); if (flags & NI_NOFQDN) { char *dot = strchr (host, '.'); if (dot != NULL) diff --git a/crypto/heimdal/lib/roken/getprogname.c b/crypto/heimdal/lib/roken/getprogname.c new file mode 100644 index 0000000..fcd4a40 --- /dev/null +++ b/crypto/heimdal/lib/roken/getprogname.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +RCSID("$Id: getprogname.c,v 1.1 2001/07/09 14:56:51 assar Exp $"); +#endif + +#include "roken.h" + +#ifndef HAVE___PROGNAME +const char *__progname; +#endif + +#ifndef HAVE_GETPROGNAME +const char * +getprogname(void) +{ + return __progname; +} +#endif /* HAVE_GETPROGNAME */ + +const char * +get_progname (void) +{ + return getprogname (); +} + diff --git a/crypto/heimdal/lib/roken/glob.c b/crypto/heimdal/lib/roken/glob.c index e4bc0dc..295aa2d 100644 --- a/crypto/heimdal/lib/roken/glob.c +++ b/crypto/heimdal/lib/roken/glob.c @@ -94,6 +94,10 @@ #include "glob.h" #include "roken.h" +#ifndef ARG_MAX +#define ARG_MAX _POSIX_ARG_MAX +#endif + #define CHAR_DOLLAR '$' #define CHAR_DOT '.' #define CHAR_EOS '\0' diff --git a/crypto/heimdal/lib/roken/h_errno.c b/crypto/heimdal/lib/roken/h_errno.c new file mode 100644 index 0000000..c2d4452 --- /dev/null +++ b/crypto/heimdal/lib/roken/h_errno.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +RCSID("$Id: h_errno.c,v 1.1 2001/08/08 03:47:23 assar Exp $"); +#endif + +#ifndef HAVE_H_ERRNO +int h_errno = -17; /* Some magic number */ +#endif diff --git a/crypto/heimdal/lib/roken/hostent_find_fqdn.c b/crypto/heimdal/lib/roken/hostent_find_fqdn.c new file mode 100644 index 0000000..8e955a4 --- /dev/null +++ b/crypto/heimdal/lib/roken/hostent_find_fqdn.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +RCSID("$Id: hostent_find_fqdn.c,v 1.2 2001/07/10 11:58:23 assar Exp $"); +#endif + +#include "roken.h" + +/* + * Try to find a fqdn (with `.') in he if possible, else return h_name + */ + +const char * +hostent_find_fqdn (const struct hostent *he) +{ + const char *ret = he->h_name; + const char **h; + + if (strchr (ret, '.') == NULL) + for (h = (const char **)he->h_aliases; *h != NULL; ++h) { + if (strchr (*h, '.') != NULL) { + ret = *h; + break; + } + } + return ret; +} diff --git a/crypto/heimdal/lib/roken/hstrerror.c b/crypto/heimdal/lib/roken/hstrerror.c index 11b6a03..61897cc 100644 --- a/crypto/heimdal/lib/roken/hstrerror.c +++ b/crypto/heimdal/lib/roken/hstrerror.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: hstrerror.c,v 1.23 1999/12/05 13:18:55 assar Exp $"); +RCSID("$Id: hstrerror.c,v 1.24 2001/08/08 03:47:23 assar Exp $"); #endif #ifndef HAVE_HSTRERROR @@ -46,10 +46,6 @@ RCSID("$Id: hstrerror.c,v 1.23 1999/12/05 13:18:55 assar Exp $"); #undef hstrerror #endif -#ifndef HAVE_H_ERRNO -int h_errno = -17; /* Some magic number */ -#endif - #if !(defined(HAVE_H_ERRLIST) && defined(HAVE_H_NERR)) static const char *const h_errlist[] = { "Resolver Error 0 (no error)", diff --git a/crypto/heimdal/lib/roken/issuid.c b/crypto/heimdal/lib/roken/issuid.c index af2aae5..910d850 100644 --- a/crypto/heimdal/lib/roken/issuid.c +++ b/crypto/heimdal/lib/roken/issuid.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998 Kungliga Tekniska Högskolan + * Copyright (c) 1998 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: issuid.c,v 1.3 1999/12/02 16:58:47 joda Exp $"); +RCSID("$Id: issuid.c,v 1.4 2001/08/27 23:08:34 assar Exp $"); #endif #include "roken.h" @@ -41,6 +41,9 @@ RCSID("$Id: issuid.c,v 1.3 1999/12/02 16:58:47 joda Exp $"); int issuid(void) { +#if defined(HAVE_ISSETUGID) + return issetugid(); +#endif #if defined(HAVE_GETUID) && defined(HAVE_GETEUID) if(getuid() != geteuid()) return 1; diff --git a/crypto/heimdal/lib/roken/localtime_r.c b/crypto/heimdal/lib/roken/localtime_r.c new file mode 100644 index 0000000..310e24b --- /dev/null +++ b/crypto/heimdal/lib/roken/localtime_r.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2000 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +RCSID("$Id: localtime_r.c,v 1.1 2001/10/21 23:24:33 assar Exp $"); +#endif + +#include <time.h> + +#ifndef HAVE_LOCALTIME_R + +struct tm * +localtime_r(const time_t *timer, struct tm *result) +{ + struct tm *tm; + + tm = localtime((time_t *)timer); + if (tm == NULL) + return NULL; + *result = *tm; + return result; +} + +#endif diff --git a/crypto/heimdal/lib/roken/mini_inetd.c b/crypto/heimdal/lib/roken/mini_inetd.c index bb31962..39dd046 100644 --- a/crypto/heimdal/lib/roken/mini_inetd.c +++ b/crypto/heimdal/lib/roken/mini_inetd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: mini_inetd.c,v 1.28 2000/10/08 13:38:47 assar Exp $"); +RCSID("$Id: mini_inetd.c,v 1.29 2001/08/01 14:48:54 assar Exp $"); #endif #include <err.h> @@ -76,6 +76,7 @@ mini_inetd (int port) memset (&hints, 0, sizeof(hints)); hints.ai_flags = AI_PASSIVE; hints.ai_socktype = SOCK_STREAM; + hints.ai_family = PF_UNSPEC; snprintf (portstr, sizeof(portstr), "%d", ntohs(port)); @@ -95,14 +96,20 @@ mini_inetd (int port) for (i = 0, a = ai; a != NULL; a = a->ai_next) { fds[i] = socket (a->ai_family, a->ai_socktype, a->ai_protocol); if (fds[i] < 0) { - warn ("socket"); + warn ("socket af = %d", a->ai_family); continue; } socket_set_reuseaddr (fds[i], 1); - if (bind (fds[i], a->ai_addr, a->ai_addrlen) < 0) - err (1, "bind"); - if (listen (fds[i], SOMAXCONN) < 0) - err (1, "listen"); + if (bind (fds[i], a->ai_addr, a->ai_addrlen) < 0) { + warn ("bind af = %d", a->ai_family); + close(fds[i]); + continue; + } + if (listen (fds[i], SOMAXCONN) < 0) { + warn ("listen af = %d", a->ai_family); + close(fds[i]); + continue; + } if (fds[i] >= FD_SETSIZE) errx (1, "fd too large"); FD_SET(fds[i], &orig_read_set); diff --git a/crypto/heimdal/lib/roken/parse_bytes-test.c b/crypto/heimdal/lib/roken/parse_bytes-test.c index 499d942..6583f22 100644 --- a/crypto/heimdal/lib/roken/parse_bytes-test.c +++ b/crypto/heimdal/lib/roken/parse_bytes-test.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: parse_bytes-test.c,v 1.2 1999/12/02 16:58:51 joda Exp $"); +RCSID("$Id: parse_bytes-test.c,v 1.3 2001/09/04 09:56:00 assar Exp $"); #endif #include "roken.h" @@ -66,7 +66,7 @@ main(int argc, char **argv) for (i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i) { char buf[256]; int val = parse_bytes (tests[i].str, tests[i].def_unit); - size_t len; + int len; if (val != tests[i].val) { printf ("parse_bytes (%s, %s) = %d != %d\n", diff --git a/crypto/heimdal/lib/roken/parse_bytes.c b/crypto/heimdal/lib/roken/parse_bytes.c index f3c514f..7793e07 100644 --- a/crypto/heimdal/lib/roken/parse_bytes.c +++ b/crypto/heimdal/lib/roken/parse_bytes.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: parse_bytes.c,v 1.2 1999/12/02 16:58:51 joda Exp $"); +RCSID("$Id: parse_bytes.c,v 1.3 2001/09/04 09:56:00 assar Exp $"); #endif #include <parse_units.h> @@ -65,13 +65,13 @@ parse_bytes (const char *s, const char *def_unit) return parse_units (s, bytes_units, def_unit); } -size_t +int unparse_bytes (int t, char *s, size_t len) { return unparse_units (t, bytes_units, s, len); } -size_t +int unparse_bytes_short (int t, char *s, size_t len) { return unparse_units_approx (t, bytes_short_units, s, len); diff --git a/crypto/heimdal/lib/roken/parse_bytes.h b/crypto/heimdal/lib/roken/parse_bytes.h index 8116c1c..d7e759d 100644 --- a/crypto/heimdal/lib/roken/parse_bytes.h +++ b/crypto/heimdal/lib/roken/parse_bytes.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: parse_bytes.h,v 1.2 1999/12/02 16:58:51 joda Exp $ */ +/* $Id: parse_bytes.h,v 1.3 2001/09/04 09:56:00 assar Exp $ */ #ifndef __PARSE_BYTES_H__ #define __PARSE_BYTES_H__ @@ -39,10 +39,10 @@ int parse_bytes (const char *s, const char *def_unit); -size_t +int unparse_bytes (int t, char *s, size_t len); -size_t +int unparse_bytes_short (int t, char *s, size_t len); #endif /* __PARSE_BYTES_H__ */ diff --git a/crypto/heimdal/lib/roken/parse_units.c b/crypto/heimdal/lib/roken/parse_units.c index 2b32ad6..217d55e 100644 --- a/crypto/heimdal/lib/roken/parse_units.c +++ b/crypto/heimdal/lib/roken/parse_units.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: parse_units.c,v 1.13 2001/03/26 00:47:06 assar Exp $"); +RCSID("$Id: parse_units.c,v 1.14 2001/09/04 09:56:00 assar Exp $"); #endif #include <stdio.h> @@ -190,7 +190,7 @@ parse_flags (const char *s, const struct units *units, * with maximum length `len'. The actual length is the function value. */ -static size_t +static int unparse_something (int num, const struct units *units, char *s, size_t len, int (*print) (char *s, size_t len, int div, const char *name, int rem), @@ -198,7 +198,7 @@ unparse_something (int num, const struct units *units, char *s, size_t len, const char *zero_string) { const struct units *u; - size_t ret = 0, tmp; + int ret = 0, tmp; if (num == 0) return snprintf (s, len, "%s", zero_string); @@ -210,6 +210,8 @@ unparse_something (int num, const struct units *units, char *s, size_t len, if (div) { num = (*update) (num, u->mult); tmp = (*print) (s, len, div, u->name, num); + if (tmp < 0) + return tmp; len -= tmp; s += tmp; @@ -243,7 +245,7 @@ update_unit_approx (int in, unsigned mult) return update_unit (in, mult); } -size_t +int unparse_units (int num, const struct units *units, char *s, size_t len) { return unparse_something (num, units, s, len, @@ -252,7 +254,7 @@ unparse_units (int num, const struct units *units, char *s, size_t len) "0"); } -size_t +int unparse_units_approx (int num, const struct units *units, char *s, size_t len) { return unparse_something (num, units, s, len, @@ -306,7 +308,7 @@ update_flag (int in, unsigned mult) return in - mult; } -size_t +int unparse_flags (int num, const struct units *units, char *s, size_t len) { return unparse_something (num, units, s, len, diff --git a/crypto/heimdal/lib/roken/parse_units.h b/crypto/heimdal/lib/roken/parse_units.h index f159d30..29c5779 100644 --- a/crypto/heimdal/lib/roken/parse_units.h +++ b/crypto/heimdal/lib/roken/parse_units.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: parse_units.h,v 1.6 1999/12/02 16:58:51 joda Exp $ */ +/* $Id: parse_units.h,v 1.7 2001/09/04 09:56:00 assar Exp $ */ #ifndef __PARSE_UNITS_H__ #define __PARSE_UNITS_H__ @@ -57,14 +57,14 @@ int parse_flags (const char *s, const struct units *units, int orig); -size_t +int unparse_units (int num, const struct units *units, char *s, size_t len); -size_t +int unparse_units_approx (int num, const struct units *units, char *s, size_t len); -size_t +int unparse_flags (int num, const struct units *units, char *s, size_t len); void diff --git a/crypto/heimdal/lib/roken/resolve.c b/crypto/heimdal/lib/roken/resolve.c index 76df287..eddaa7d 100644 --- a/crypto/heimdal/lib/roken/resolve.c +++ b/crypto/heimdal/lib/roken/resolve.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -43,7 +43,9 @@ #endif #include "resolve.h" -RCSID("$Id: resolve.c,v 1.26 2000/06/27 01:15:53 assar Exp $"); +#include <assert.h> + +RCSID("$Id: resolve.c,v 1.30 2001/10/02 15:39:41 joda Exp $"); #if defined(HAVE_RES_SEARCH) && defined(HAVE_DN_EXPAND) @@ -360,6 +362,109 @@ dns_lookup(const char *domain, const char *type_name) return dns_lookup_int(domain, C_IN, type); } +static int +compare_srv(const void *a, const void *b) +{ + const struct resource_record *const* aa = a, *const* bb = b; + + if((*aa)->u.srv->priority == (*bb)->u.srv->priority) + return ((*aa)->u.srv->weight - (*bb)->u.srv->weight); + return ((*aa)->u.srv->priority - (*bb)->u.srv->priority); +} + +#ifndef HAVE_RANDOM +#define random() rand() +#endif + +/* try to rearrange the srv-records by the algorithm in RFC2782 */ +void +dns_srv_order(struct dns_reply *r) +{ + struct resource_record **srvs, **ss, **headp; + struct resource_record *rr; + int num_srv = 0; + +#if defined(HAVE_INITSTATE) && defined(HAVE_SETSTATE) + char state[256], *oldstate; +#endif + + for(rr = r->head; rr; rr = rr->next) + if(rr->type == T_SRV) + num_srv++; + + if(num_srv == 0) + return; + + srvs = malloc(num_srv * sizeof(*srvs)); + if(srvs == NULL) + return; /* XXX not much to do here */ + + /* unlink all srv-records from the linked list and put them in + a vector */ + for(ss = srvs, headp = &r->head; *headp; ) + if((*headp)->type == T_SRV) { + *ss = *headp; + *headp = (*headp)->next; + (*ss)->next = NULL; + ss++; + } else + headp = &(*headp)->next; + + /* sort them by priority and weight */ + qsort(srvs, num_srv, sizeof(*srvs), compare_srv); + +#if defined(HAVE_INITSTATE) && defined(HAVE_SETSTATE) + oldstate = initstate(time(NULL), state, sizeof(state)); +#endif + + headp = &r->head; + + for(ss = srvs; ss < srvs + num_srv; ) { + int sum, rnd, count; + struct resource_record **ee, **tt; + /* find the last record with the same priority and count the + sum of all weights */ + for(sum = 0, tt = ss; tt < srvs + num_srv; tt++) { + if(*tt == NULL) + continue; + if((*tt)->u.srv->priority != (*ss)->u.srv->priority) + break; + sum += (*tt)->u.srv->weight; + } + ee = tt; + /* ss is now the first record of this priority and ee is the + first of the next */ + while(ss < ee) { + rnd = random() % (sum + 1); + for(count = 0, tt = ss; ; tt++) { + if(*tt == NULL) + continue; + count += (*tt)->u.srv->weight; + if(count >= rnd) + break; + } + + assert(tt < ee); + + /* insert the selected record at the tail (of the head) of + the list */ + (*tt)->next = *headp; + *headp = *tt; + headp = &(*tt)->next; + sum -= (*tt)->u.srv->weight; + *tt = NULL; + while(ss < ee && *ss == NULL) + ss++; + } + } + +#if defined(HAVE_INITSTATE) && defined(HAVE_SETSTATE) + setstate(oldstate); +#endif + free(srvs); + return; +} + #else /* NOT defined(HAVE_RES_SEARCH) && defined(HAVE_DN_EXPAND) */ struct dns_reply * @@ -373,6 +478,11 @@ dns_free_data(struct dns_reply *r) { } +void +dns_srv_order(struct dns_reply *r) +{ +} + #endif #ifdef TEST @@ -386,6 +496,9 @@ main(int argc, char **argv) printf("No reply.\n"); return 1; } + if(r->q.type == T_SRV) + dns_srv_order(r); + for(rr = r->head; rr;rr=rr->next){ printf("%s %s %d ", rr->domain, dns_type_to_string(rr->type), rr->ttl); switch(rr->type){ diff --git a/crypto/heimdal/lib/roken/resolve.h b/crypto/heimdal/lib/roken/resolve.h index 1c2e9a7..6267214 100644 --- a/crypto/heimdal/lib/roken/resolve.h +++ b/crypto/heimdal/lib/roken/resolve.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: resolve.h,v 1.12 2000/10/15 21:28:56 assar Exp $ */ +/* $Id: resolve.h,v 1.13 2001/06/09 01:35:04 joda Exp $ */ #ifndef __RESOLVE_H__ #define __RESOLVE_H__ @@ -142,5 +142,6 @@ struct dns_reply* dns_lookup(const char *, const char *); void dns_free_data(struct dns_reply *); int dns_string_to_type(const char *name); const char *dns_type_to_string(int type); +void dns_srv_order(struct dns_reply*); #endif /* __RESOLVE_H__ */ diff --git a/crypto/heimdal/lib/roken/roken-common.h b/crypto/heimdal/lib/roken/roken-common.h index 2227336..99add53 100644 --- a/crypto/heimdal/lib/roken/roken-common.h +++ b/crypto/heimdal/lib/roken/roken-common.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: roken-common.h,v 1.42 2001/01/29 02:09:09 assar Exp $ */ +/* $Id: roken-common.h,v 1.48 2001/09/03 12:04:34 joda Exp $ */ #ifndef __ROKEN_COMMON_H__ #define __ROKEN_COMMON_H__ @@ -264,15 +264,19 @@ int ROKEN_LIB_FUNCTION simple_execlp(const char*, ...); int ROKEN_LIB_FUNCTION simple_execle(const char*, ...); int ROKEN_LIB_FUNCTION simple_execl(const char *file, ...); -void ROKEN_LIB_FUNCTION print_version(const char *); +int ROKEN_LIB_FUNCTION wait_for_process(pid_t); +int ROKEN_LIB_FUNCTION pipe_execv(FILE**, FILE**, FILE**, const char*, ...); -void *ROKEN_LIB_FUNCTION emalloc (size_t); -void *ROKEN_LIB_FUNCTION erealloc (void *, size_t); -char *ROKEN_LIB_FUNCTION estrdup (const char *); +void ROKEN_LIB_FUNCTION print_version(const char *); ssize_t ROKEN_LIB_FUNCTION eread (int fd, void *buf, size_t nbytes); ssize_t ROKEN_LIB_FUNCTION ewrite (int fd, const void *buf, size_t nbytes); +struct hostent; + +const char * +hostent_find_fqdn (const struct hostent *he); + void esetenv(const char *var, const char *val, int rewrite); @@ -298,6 +302,9 @@ void socket_set_port (struct sockaddr *sa, int port); void +socket_set_portrange (int sock, int restr, int af); + +void socket_set_debug (int sock); void diff --git a/crypto/heimdal/lib/roken/roken.h.in b/crypto/heimdal/lib/roken/roken.h.in index 538a530..c70097b 100644 --- a/crypto/heimdal/lib/roken/roken.h.in +++ b/crypto/heimdal/lib/roken/roken.h.in @@ -32,7 +32,7 @@ * SUCH DAMAGE. */ -/* $Id: roken.h.in,v 1.157 2001/05/18 18:00:12 assar Exp $ */ +/* $Id: roken.h.in,v 1.162 2001/10/21 23:24:33 assar Exp $ */ #include <stdio.h> #include <stdlib.h> @@ -92,12 +92,15 @@ struct sockaddr_dl; #ifdef HAVE_NETDB_H #include <netdb.h> #endif +#ifdef HAVE_ARPA_NAMESER_H +#include <arpa/nameser.h> +#endif +#ifdef HAVE_RESOLV_H +#include <resolv.h> +#endif #ifdef HAVE_SYSLOG_H #include <syslog.h> #endif -#ifdef HAVE_WINSOCK_H -#include <winsock.h> -#endif #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif @@ -567,6 +570,19 @@ char * strptime (const char *buf, const char *format, struct tm *timeptr); #endif +#ifndef HAVE_EMALLOC +void *emalloc (size_t); +#endif +#ifndef HAVE_ECALLOC +void *ecalloc(size_t num, size_t sz); +#endif +#ifndef HAVE_EREALLOC +void *erealloc (void *, size_t); +#endif +#ifndef HAVE_ESTRDUP +char *estrdup (const char *); +#endif + /* * kludges and such */ @@ -618,4 +634,9 @@ const char *getprogname(void); void set_progname(char *argv0); const char *get_progname(void); +#ifndef HAVE_LOCALTIME_R +struct tm * +localtime_r(const time_t *timer, struct tm *result); +#endif + ROKEN_CPP_END diff --git a/crypto/heimdal/lib/roken/setprogname.c b/crypto/heimdal/lib/roken/setprogname.c new file mode 100644 index 0000000..e66deab --- /dev/null +++ b/crypto/heimdal/lib/roken/setprogname.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +RCSID("$Id: setprogname.c,v 1.1 2001/07/09 14:56:51 assar Exp $"); +#endif + +#include "roken.h" + +#ifndef HAVE___PROGNAME +extern const char *__progname; +#endif + +#ifndef HAVE_SETPROGNAME +void +setprogname(const char *argv0) +{ +#ifndef HAVE___PROGNAME + char *p; + if(argv0 == NULL) + return; + p = strrchr(argv0, '/'); + if(p == NULL) + p = (char *)argv0; + else + p++; + __progname = p; +#endif +} +#endif /* HAVE_SETPROGNAME */ + +void +set_progname(char *argv0) +{ + setprogname ((const char *)argv0); +} diff --git a/crypto/heimdal/lib/roken/simple_exec.c b/crypto/heimdal/lib/roken/simple_exec.c index c7e22d9..1f27c00 100644 --- a/crypto/heimdal/lib/roken/simple_exec.c +++ b/crypto/heimdal/lib/roken/simple_exec.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1998 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: simple_exec.c,v 1.8 2000/11/05 16:41:06 joda Exp $"); +RCSID("$Id: simple_exec.c,v 1.10 2001/06/21 03:38:03 assar Exp $"); #endif #include <stdarg.h> @@ -64,8 +64,8 @@ RCSID("$Id: simple_exec.c,v 1.8 2000/11/05 16:41:06 joda Exp $"); 128- is 128 + signal that killed subprocess */ -static int -check_status(pid_t pid) +int +wait_for_process(pid_t pid) { while(1) { int status; @@ -83,6 +83,93 @@ check_status(pid_t pid) } int +pipe_execv(FILE **stdin_fd, FILE **stdout_fd, FILE **stderr_fd, + const char *file, ...) +{ + int in_fd[2], out_fd[2], err_fd[2]; + pid_t pid; + va_list ap; + char **argv; + + if(stdin_fd != NULL) + pipe(in_fd); + if(stdout_fd != NULL) + pipe(out_fd); + if(stderr_fd != NULL) + pipe(err_fd); + pid = fork(); + switch(pid) { + case 0: + va_start(ap, file); + argv = vstrcollect(&ap); + va_end(ap); + if(argv == NULL) + exit(-1); + + /* close pipes we're not interested in */ + if(stdin_fd != NULL) + close(in_fd[1]); + if(stdout_fd != NULL) + close(out_fd[0]); + if(stderr_fd != NULL) + close(err_fd[0]); + + /* pipe everything caller doesn't care about to /dev/null */ + if(stdin_fd == NULL) + in_fd[0] = open(_PATH_DEVNULL, O_RDONLY); + if(stdout_fd == NULL) + out_fd[1] = open(_PATH_DEVNULL, O_WRONLY); + if(stderr_fd == NULL) + err_fd[1] = open(_PATH_DEVNULL, O_WRONLY); + + /* move to proper descriptors */ + if(in_fd[0] != STDIN_FILENO) { + dup2(in_fd[0], STDIN_FILENO); + close(in_fd[0]); + } + if(out_fd[1] != STDOUT_FILENO) { + dup2(out_fd[1], STDOUT_FILENO); + close(out_fd[1]); + } + if(err_fd[1] != STDERR_FILENO) { + dup2(err_fd[1], STDERR_FILENO); + close(err_fd[1]); + } + + execv(file, argv); + exit((errno == ENOENT) ? EX_NOTFOUND : EX_NOEXEC); + case -1: + if(stdin_fd != NULL) { + close(in_fd[0]); + close(in_fd[1]); + } + if(stdout_fd != NULL) { + close(out_fd[0]); + close(out_fd[1]); + } + if(stderr_fd != NULL) { + close(err_fd[0]); + close(err_fd[1]); + } + return -2; + default: + if(stdin_fd != NULL) { + close(in_fd[0]); + *stdin_fd = fdopen(in_fd[1], "w"); + } + if(stdout_fd != NULL) { + close(out_fd[1]); + *stdout_fd = fdopen(out_fd[0], "r"); + } + if(stderr_fd != NULL) { + close(err_fd[1]); + *stderr_fd = fdopen(err_fd[0], "r"); + } + } + return pid; +} + +int simple_execvp(const char *file, char *const args[]) { pid_t pid = fork(); @@ -93,7 +180,7 @@ simple_execvp(const char *file, char *const args[]) execvp(file, args); exit((errno == ENOENT) ? EX_NOTFOUND : EX_NOEXEC); default: - return check_status(pid); + return wait_for_process(pid); } } @@ -109,7 +196,7 @@ simple_execve(const char *file, char *const args[], char *const envp[]) execve(file, args, envp); exit((errno == ENOENT) ? EX_NOTFOUND : EX_NOEXEC); default: - return check_status(pid); + return wait_for_process(pid); } } diff --git a/crypto/heimdal/lib/roken/snprintf-test.c b/crypto/heimdal/lib/roken/snprintf-test.c new file mode 100644 index 0000000..6904ba6 --- /dev/null +++ b/crypto/heimdal/lib/roken/snprintf-test.c @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2000 - 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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. Neither the name of KTH 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 KTH AND ITS 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 KTH OR ITS 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. */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "roken.h" +#include <limits.h> + +#include "snprintf-test.h" + +RCSID("$Id: snprintf-test.c,v 1.5 2001/09/13 01:01:16 assar Exp $"); + +static int +try (const char *format, ...) +{ + int ret; + va_list ap; + char buf1[256], buf2[256]; + + va_start (ap, format); + ret = vsnprintf (buf1, sizeof(buf1), format, ap); + if (ret >= sizeof(buf1)) + errx (1, "increase buf and try again"); + vsprintf (buf2, format, ap); + ret = strcmp (buf1, buf2); + if (ret) + printf ("failed: format = \"%s\", \"%s\" != \"%s\"\n", + format, buf1, buf2); + va_end (ap); + return ret; +} + +static int +cmp_with_sprintf_int (void) +{ + int tot = 0; + int int_values[] = {INT_MIN, -17, -1, 0, 1, 17, 4711, 65535, INT_MAX}; + int i; + + for (i = 0; i < sizeof(int_values) / sizeof(int_values[0]); ++i) { + tot += try ("%d", int_values[i]); + tot += try ("%x", int_values[i]); + tot += try ("%X", int_values[i]); + tot += try ("%o", int_values[i]); + tot += try ("%#x", int_values[i]); + tot += try ("%#X", int_values[i]); + tot += try ("%#o", int_values[i]); + tot += try ("%10d", int_values[i]); + tot += try ("%10x", int_values[i]); + tot += try ("%10X", int_values[i]); + tot += try ("%10o", int_values[i]); + tot += try ("%#10x", int_values[i]); + tot += try ("%#10X", int_values[i]); + tot += try ("%#10o", int_values[i]); + tot += try ("%-10d", int_values[i]); + tot += try ("%-10x", int_values[i]); + tot += try ("%-10X", int_values[i]); + tot += try ("%-10o", int_values[i]); + tot += try ("%-#10x", int_values[i]); + tot += try ("%-#10X", int_values[i]); + tot += try ("%-#10o", int_values[i]); + } + return tot; +} + +static int +cmp_with_sprintf_long (void) +{ + int tot = 0; + long long_values[] = {LONG_MIN, -17, -1, 0, 1, 17, 4711, 65535, LONG_MAX}; + int i; + + for (i = 0; i < sizeof(long_values) / sizeof(long_values[0]); ++i) { + tot += try ("%ld", long_values[i]); + tot += try ("%lx", long_values[i]); + tot += try ("%lX", long_values[i]); + tot += try ("%lo", long_values[i]); + tot += try ("%#lx", long_values[i]); + tot += try ("%#lX", long_values[i]); + tot += try ("%#lo", long_values[i]); + tot += try ("%10ld", long_values[i]); + tot += try ("%10lx", long_values[i]); + tot += try ("%10lX", long_values[i]); + tot += try ("%10lo", long_values[i]); + tot += try ("%#10lx", long_values[i]); + tot += try ("%#10lX", long_values[i]); + tot += try ("%#10lo", long_values[i]); + tot += try ("%-10ld", long_values[i]); + tot += try ("%-10lx", long_values[i]); + tot += try ("%-10lX", long_values[i]); + tot += try ("%-10lo", long_values[i]); + tot += try ("%-#10lx", long_values[i]); + tot += try ("%-#10lX", long_values[i]); + tot += try ("%-#10lo", long_values[i]); + } + return tot; +} + +#ifdef HAVE_LONG_LONG + +static int +cmp_with_sprintf_long_long (void) +{ + int tot = 0; + long long long_long_values[] = { + ((long long)LONG_MIN) -1, LONG_MIN, -17, -1, + 0, + 1, 17, 4711, 65535, LONG_MAX, ((long long)LONG_MAX) + 1}; + int i; + + for (i = 0; i < sizeof(long_long_values) / sizeof(long_long_values[0]); ++i) { + tot += try ("%lld", long_long_values[i]); + tot += try ("%llx", long_long_values[i]); + tot += try ("%llX", long_long_values[i]); + tot += try ("%llo", long_long_values[i]); + tot += try ("%#llx", long_long_values[i]); + tot += try ("%#llX", long_long_values[i]); + tot += try ("%#llo", long_long_values[i]); + tot += try ("%10lld", long_long_values[i]); + tot += try ("%10llx", long_long_values[i]); + tot += try ("%10llX", long_long_values[i]); + tot += try ("%10llo", long_long_values[i]); + tot += try ("%#10llx", long_long_values[i]); + tot += try ("%#10llX", long_long_values[i]); + tot += try ("%#10llo", long_long_values[i]); + tot += try ("%-10lld", long_long_values[i]); + tot += try ("%-10llx", long_long_values[i]); + tot += try ("%-10llX", long_long_values[i]); + tot += try ("%-10llo", long_long_values[i]); + tot += try ("%-#10llx", long_long_values[i]); + tot += try ("%-#10llX", long_long_values[i]); + tot += try ("%-#10llo", long_long_values[i]); + } + return tot; +} + +#endif + +#if 0 +static int +cmp_with_sprintf_float (void) +{ + int tot = 0; + double double_values[] = {-99999, -999, -17.4, -4.3, -3.0, -1.5, -1, + 0, 0.1, 0.2342374852, 0.2340007, + 3.1415926, 14.7845, 34.24758, 9999, 9999999}; + int i; + + for (i = 0; i < sizeof(double_values) / sizeof(double_values[0]); ++i) { + tot += try ("%f", double_values[i]); + tot += try ("%10f", double_values[i]); + tot += try ("%.2f", double_values[i]); + tot += try ("%7.0f", double_values[i]); + tot += try ("%5.2f", double_values[i]); + tot += try ("%0f", double_values[i]); + tot += try ("%#f", double_values[i]); + tot += try ("%e", double_values[i]); + tot += try ("%10e", double_values[i]); + tot += try ("%.2e", double_values[i]); + tot += try ("%7.0e", double_values[i]); + tot += try ("%5.2e", double_values[i]); + tot += try ("%0e", double_values[i]); + tot += try ("%#e", double_values[i]); + tot += try ("%E", double_values[i]); + tot += try ("%10E", double_values[i]); + tot += try ("%.2E", double_values[i]); + tot += try ("%7.0E", double_values[i]); + tot += try ("%5.2E", double_values[i]); + tot += try ("%0E", double_values[i]); + tot += try ("%#E", double_values[i]); + tot += try ("%g", double_values[i]); + tot += try ("%10g", double_values[i]); + tot += try ("%.2g", double_values[i]); + tot += try ("%7.0g", double_values[i]); + tot += try ("%5.2g", double_values[i]); + tot += try ("%0g", double_values[i]); + tot += try ("%#g", double_values[i]); + tot += try ("%G", double_values[i]); + tot += try ("%10G", double_values[i]); + tot += try ("%.2G", double_values[i]); + tot += try ("%7.0G", double_values[i]); + tot += try ("%5.2G", double_values[i]); + tot += try ("%0G", double_values[i]); + tot += try ("%#G", double_values[i]); + } + return tot; +} +#endif + +static int +test_null (void) +{ + return snprintf (NULL, 0, "foo") != 3; +} + +int +main (int argc, char **argv) +{ + int ret = 0; + + ret += cmp_with_sprintf_int (); + ret += cmp_with_sprintf_long (); +#ifdef HAVE_LONG_LONG + ret += cmp_with_sprintf_long_long (); +#endif + ret += test_null (); + return ret; +} diff --git a/crypto/heimdal/lib/roken/snprintf-test.h b/crypto/heimdal/lib/roken/snprintf-test.h new file mode 100644 index 0000000..5eb591b --- /dev/null +++ b/crypto/heimdal/lib/roken/snprintf-test.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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. Neither the name of KTH 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 KTH AND ITS 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 KTH OR ITS 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: snprintf-test.h,v 1.2 2001/07/19 18:39:14 assar Exp $ */ + +#ifndef __SNPRINTF_TEST_H__ +#define __SNPRINTF_TEST_H__ + +/* + * we cannot use the real names of the functions when testing, since + * they might have different prototypes as the system functions, hence + * these evil hacks + */ + +#define snprintf test_snprintf +#define asprintf test_asprintf +#define asnprintf test_asnprintf +#define vasprintf test_vasprintf +#define vasnprintf test_vasnprintf +#define vsnprintf test_vsnprintf + +#endif /* __SNPRINTF_TEST_H__ */ diff --git a/crypto/heimdal/lib/roken/snprintf.c b/crypto/heimdal/lib/roken/snprintf.c index 205dc58..afb9754 100644 --- a/crypto/heimdal/lib/roken/snprintf.c +++ b/crypto/heimdal/lib/roken/snprintf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995-2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995-2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: snprintf.c,v 1.28 2000/12/15 14:04:42 joda Exp $"); +RCSID("$Id: snprintf.c,v 1.33 2001/09/24 12:16:37 joda Exp $"); #endif #include <stdio.h> #include <stdarg.h> @@ -54,38 +54,37 @@ enum format_flags { * Common state */ -struct state { +struct snprintf_state { unsigned char *str; unsigned char *s; unsigned char *theend; size_t sz; size_t max_sz; - int (*append_char)(struct state *, unsigned char); - int (*reserve)(struct state *, size_t); + void (*append_char)(struct snprintf_state *, unsigned char); /* XXX - methods */ }; -#ifndef HAVE_VSNPRINTF +#if TEST_SNPRINTF +#include "snprintf-test.h" +#endif /* TEST_SNPRINTF */ + +#if !defined(HAVE_VSNPRINTF) || defined(TEST_SNPRINTF) static int -sn_reserve (struct state *state, size_t n) +sn_reserve (struct snprintf_state *state, size_t n) { return state->s + n > state->theend; } -static int -sn_append_char (struct state *state, unsigned char c) +static void +sn_append_char (struct snprintf_state *state, unsigned char c) { - if (sn_reserve (state, 1)) { - return 1; - } else { + if (!sn_reserve (state, 1)) *state->s++ = c; - return 0; - } } #endif static int -as_reserve (struct state *state, size_t n) +as_reserve (struct snprintf_state *state, size_t n) { if (state->s + n > state->theend) { int off = state->s - state->str; @@ -107,24 +106,41 @@ as_reserve (struct state *state, size_t n) return 0; } -static int -as_append_char (struct state *state, unsigned char c) +static void +as_append_char (struct snprintf_state *state, unsigned char c) { - if(as_reserve (state, 1)) - return 1; - else { + if(!as_reserve (state, 1)) *state->s++ = c; - return 0; - } +} + +/* longest integer types */ + +#ifdef HAVE_LONG_LONG +typedef unsigned long long u_longest; +typedef long long longest; +#else +typedef unsigned long u_longest; +typedef long longest; +#endif + +/* + * is # supposed to do anything? + */ + +static int +use_alternative (int flags, u_longest num, unsigned base) +{ + return flags & alternate_flag && (base == 16 || base == 8) && num != 0; } static int -append_number(struct state *state, - unsigned long num, unsigned base, char *rep, +append_number(struct snprintf_state *state, + u_longest num, unsigned base, char *rep, int width, int prec, int flags, int minusp) { int len = 0; int i; + u_longest n = num; /* given precision, ignore zero flag */ if(prec != -1) @@ -132,23 +148,21 @@ append_number(struct state *state, else prec = 1; /* zero value with zero precision -> "" */ - if(prec == 0 && num == 0) + if(prec == 0 && n == 0) return 0; do{ - if((*state->append_char)(state, rep[num % base])) - return 1; - len++; - num /= base; - }while(num); + (*state->append_char)(state, rep[n % base]); + ++len; + n /= base; + } while(n); prec -= len; /* pad with prec zeros */ while(prec-- > 0){ - if((*state->append_char)(state, '0')) - return 1; - len++; + (*state->append_char)(state, '0'); + ++len; } /* add length of alternate prefix (added later) to len */ - if(flags & alternate_flag && (base == 16 || base == 8)) + if(use_alternative(flags, num, base)) len += base / 8; /* pad with zeros */ if(flags & zero_flag){ @@ -156,32 +170,26 @@ append_number(struct state *state, if(minusp || (flags & space_flag) || (flags & plus_flag)) width--; while(width-- > 0){ - if((*state->append_char)(state, '0')) - return 1; + (*state->append_char)(state, '0'); len++; } } /* add alternate prefix */ - if(flags & alternate_flag && (base == 16 || base == 8)){ + if(use_alternative(flags, num, base)){ if(base == 16) - if((*state->append_char)(state, rep[10] + 23)) /* XXX */ - return 1; - if((*state->append_char)(state, '0')) - return 1; + (*state->append_char)(state, rep[10] + 23); /* XXX */ + (*state->append_char)(state, '0'); } /* add sign */ if(minusp){ - if((*state->append_char)(state, '-')) - return 1; - len++; + (*state->append_char)(state, '-'); + ++len; } else if(flags & plus_flag) { - if((*state->append_char)(state, '+')) - return 1; - len++; + (*state->append_char)(state, '+'); + ++len; } else if(flags & space_flag) { - if((*state->append_char)(state, ' ')) - return 1; - len++; + (*state->append_char)(state, ' '); + ++len; } if(flags & minus_flag) /* swap before padding with spaces */ @@ -192,9 +200,8 @@ append_number(struct state *state, } width -= len; while(width-- > 0){ - if((*state->append_char)(state, ' ')) - return 1; - len++; + (*state->append_char)(state, ' '); + ++len; } if(!(flags & minus_flag)) /* swap after padding with spaces */ @@ -203,60 +210,71 @@ append_number(struct state *state, state->s[-i-1] = state->s[-len+i]; state->s[-len+i] = c; } - - return 0; + return len; } +/* + * return length + */ + static int -append_string (struct state *state, - unsigned char *arg, +append_string (struct snprintf_state *state, + const unsigned char *arg, int width, int prec, int flags) { + int len = 0; + if(arg == NULL) - arg = (unsigned char*)"(null)"; + arg = (const unsigned char*)"(null)"; if(prec != -1) width -= prec; else - width -= strlen((char *)arg); + width -= strlen((const char *)arg); if(!(flags & minus_flag)) - while(width-- > 0) - if((*state->append_char) (state, ' ')) - return 1; + while(width-- > 0) { + (*state->append_char) (state, ' '); + ++len; + } if (prec != -1) { - while (*arg && prec--) - if ((*state->append_char) (state, *arg++)) - return 1; + while (*arg && prec--) { + (*state->append_char) (state, *arg++); + ++len; + } } else { - while (*arg) - if ((*state->append_char) (state, *arg++)) - return 1; + while (*arg) { + (*state->append_char) (state, *arg++); + ++len; + } } if(flags & minus_flag) - while(width-- > 0) - if((*state->append_char) (state, ' ')) - return 1; - return 0; + while(width-- > 0) { + (*state->append_char) (state, ' '); + ++len; + } + return len; } static int -append_char(struct state *state, +append_char(struct snprintf_state *state, unsigned char arg, int width, int flags) { - while(!(flags & minus_flag) && --width > 0) - if((*state->append_char) (state, ' ')) - return 1; - - if((*state->append_char) (state, arg)) - return 1; - while((flags & minus_flag) && --width > 0) - if((*state->append_char) (state, ' ')) - return 1; - + int len = 0; + + while(!(flags & minus_flag) && --width > 0) { + (*state->append_char) (state, ' ') ; + ++len; + } + (*state->append_char) (state, arg); + ++len; + while((flags & minus_flag) && --width > 0) { + (*state->append_char) (state, ' '); + ++len; + } return 0; } @@ -264,6 +282,20 @@ append_char(struct state *state, * This can't be made into a function... */ +#ifdef HAVE_LONG_LONG + +#define PARSE_INT_FORMAT(res, arg, unsig) \ +if (long_long_flag) \ + res = (unsig long long)va_arg(arg, unsig long long); \ +else if (long_flag) \ + res = (unsig long)va_arg(arg, unsig long); \ +else if (short_flag) \ + res = (unsig short)va_arg(arg, unsig int); \ +else \ + res = (unsig int)va_arg(arg, unsig int) + +#else + #define PARSE_INT_FORMAT(res, arg, unsig) \ if (long_flag) \ res = (unsig long)va_arg(arg, unsig long); \ @@ -272,23 +304,27 @@ else if (short_flag) \ else \ res = (unsig int)va_arg(arg, unsig int) +#endif + /* - * zyxprintf - return 0 or -1 + * zyxprintf - return length, as snprintf */ static int -xyzprintf (struct state *state, const char *char_format, va_list ap) +xyzprintf (struct snprintf_state *state, const char *char_format, va_list ap) { const unsigned char *format = (const unsigned char *)char_format; unsigned char c; + int len = 0; while((c = *format++)) { if (c == '%') { - int flags = 0; - int width = 0; - int prec = -1; - int long_flag = 0; - int short_flag = 0; + int flags = 0; + int width = 0; + int prec = -1; + int long_long_flag = 0; + int long_flag = 0; + int short_flag = 0; /* flags */ while((c = *format++)){ @@ -346,25 +382,28 @@ xyzprintf (struct state *state, const char *char_format, va_list ap) } else if (c == 'l') { long_flag = 1; c = *format++; + if (c == 'l') { + long_long_flag = 1; + c = *format++; + } } switch (c) { case 'c' : - if(append_char(state, va_arg(ap, int), width, flags)) - return -1; + append_char(state, va_arg(ap, int), width, flags); + ++len; break; case 's' : - if (append_string(state, - va_arg(ap, unsigned char*), - width, - prec, - flags)) - return -1; + len += append_string(state, + va_arg(ap, unsigned char*), + width, + prec, + flags); break; case 'd' : case 'i' : { - long arg; - unsigned long num; + longest arg; + u_longest num; int minusp = 0; PARSE_INT_FORMAT(arg, ap, signed); @@ -375,57 +414,51 @@ xyzprintf (struct state *state, const char *char_format, va_list ap) } else num = arg; - if (append_number (state, num, 10, "0123456789", - width, prec, flags, minusp)) - return -1; + len += append_number (state, num, 10, "0123456789", + width, prec, flags, minusp); break; } case 'u' : { - unsigned long arg; + u_longest arg; PARSE_INT_FORMAT(arg, ap, unsigned); - if (append_number (state, arg, 10, "0123456789", - width, prec, flags, 0)) - return -1; + len += append_number (state, arg, 10, "0123456789", + width, prec, flags, 0); break; } case 'o' : { - unsigned long arg; + u_longest arg; PARSE_INT_FORMAT(arg, ap, unsigned); - if (append_number (state, arg, 010, "01234567", - width, prec, flags, 0)) - return -1; + len += append_number (state, arg, 010, "01234567", + width, prec, flags, 0); break; } case 'x' : { - unsigned long arg; + u_longest arg; PARSE_INT_FORMAT(arg, ap, unsigned); - if (append_number (state, arg, 0x10, "0123456789abcdef", - width, prec, flags, 0)) - return -1; + len += append_number (state, arg, 0x10, "0123456789abcdef", + width, prec, flags, 0); break; } case 'X' :{ - unsigned long arg; + u_longest arg; PARSE_INT_FORMAT(arg, ap, unsigned); - if (append_number (state, arg, 0x10, "0123456789ABCDEF", - width, prec, flags, 0)) - return -1; + len += append_number (state, arg, 0x10, "0123456789ABCDEF", + width, prec, flags, 0); break; } case 'p' : { unsigned long arg = (unsigned long)va_arg(ap, void*); - if (append_number (state, arg, 0x10, "0123456789ABCDEF", - width, prec, flags, 0)) - return -1; + len += append_number (state, arg, 0x10, "0123456789ABCDEF", + width, prec, flags, 0); break; } case 'n' : { @@ -437,23 +470,24 @@ xyzprintf (struct state *state, const char *char_format, va_list ap) --format; /* FALLTHROUGH */ case '%' : - if ((*state->append_char)(state, c)) - return -1; + (*state->append_char)(state, c); + ++len; break; default : - if ( (*state->append_char)(state, '%') - || (*state->append_char)(state, c)) - return -1; + (*state->append_char)(state, '%'); + (*state->append_char)(state, c); + len += 2; break; } - } else - if ((*state->append_char) (state, c)) - return -1; + } else { + (*state->append_char) (state, c); + ++len; + } } - return 0; + return len; } -#ifndef HAVE_SNPRINTF +#if !defined(HAVE_SNPRINTF) || defined(TEST_SNPRINTF) int snprintf (char *str, size_t sz, const char *format, ...) { @@ -462,6 +496,7 @@ snprintf (char *str, size_t sz, const char *format, ...) va_start(args, format); ret = vsnprintf (str, sz, format, args); + va_end(args); #ifdef PARANOIA { @@ -472,19 +507,20 @@ snprintf (char *str, size_t sz, const char *format, ...) if (tmp == NULL) abort (); + va_start(args, format); ret2 = vsprintf (tmp, format, args); + va_end(args); if (ret != ret2 || strcmp(str, tmp)) abort (); free (tmp); } #endif - va_end(args); return ret; } #endif -#ifndef HAVE_ASPRINTF +#if !defined(HAVE_ASPRINTF) || defined(TEST_SNPRINTF) int asprintf (char **ret, const char *format, ...) { @@ -493,6 +529,7 @@ asprintf (char **ret, const char *format, ...) va_start(args, format); val = vasprintf (ret, format, args); + va_end(args); #ifdef PARANOIA { @@ -502,19 +539,20 @@ asprintf (char **ret, const char *format, ...) if (tmp == NULL) abort (); + va_start(args, format); ret2 = vsprintf (tmp, format, args); + va_end(args); if (val != ret2 || strcmp(*ret, tmp)) abort (); free (tmp); } #endif - va_end(args); return val; } #endif -#ifndef HAVE_ASNPRINTF +#if !defined(HAVE_ASNPRINTF) || defined(TEST_SNPRINTF) int asnprintf (char **ret, size_t max_sz, const char *format, ...) { @@ -544,7 +582,7 @@ asnprintf (char **ret, size_t max_sz, const char *format, ...) } #endif -#ifndef HAVE_VASPRINTF +#if !defined(HAVE_VASPRINTF) || defined(TEST_SNPRINTF) int vasprintf (char **ret, const char *format, va_list args) { @@ -553,13 +591,12 @@ vasprintf (char **ret, const char *format, va_list args) #endif -#ifndef HAVE_VASNPRINTF +#if !defined(HAVE_VASNPRINTF) || defined(TEST_SNPRINTF) int vasnprintf (char **ret, size_t max_sz, const char *format, va_list args) { int st; - size_t len; - struct state state; + struct snprintf_state state; state.max_sz = max_sz; state.sz = 1; @@ -571,10 +608,9 @@ vasnprintf (char **ret, size_t max_sz, const char *format, va_list args) state.s = state.str; state.theend = state.s + state.sz - 1; state.append_char = as_append_char; - state.reserve = as_reserve; st = xyzprintf (&state, format, args); - if (st) { + if (st > state.sz) { free (state.str); *ret = NULL; return -1; @@ -582,24 +618,23 @@ vasnprintf (char **ret, size_t max_sz, const char *format, va_list args) char *tmp; *state.s = '\0'; - len = state.s - state.str; - tmp = realloc (state.str, len+1); + tmp = realloc (state.str, st+1); if (tmp == NULL) { free (state.str); *ret = NULL; return -1; } *ret = tmp; - return len; + return st; } } #endif -#ifndef HAVE_VSNPRINTF +#if !defined(HAVE_VSNPRINTF) || defined(TEST_SNPRINTF) int vsnprintf (char *str, size_t sz, const char *format, va_list args) { - struct state state; + struct snprintf_state state; int ret; unsigned char *ustr = (unsigned char *)str; @@ -607,16 +642,12 @@ vsnprintf (char *str, size_t sz, const char *format, va_list args) state.sz = sz; state.str = ustr; state.s = ustr; - state.theend = ustr + sz - 1; + state.theend = ustr + sz - (sz > 0); state.append_char = sn_append_char; - state.reserve = sn_reserve; ret = xyzprintf (&state, format, args); - *state.s = '\0'; - if (ret) - return sz; - else - return state.s - state.str; + if (state.s != NULL) + *state.s = '\0'; + return ret; } #endif - diff --git a/crypto/heimdal/lib/roken/socket.c b/crypto/heimdal/lib/roken/socket.c index d8463d5..ad124fd 100644 --- a/crypto/heimdal/lib/roken/socket.c +++ b/crypto/heimdal/lib/roken/socket.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: socket.c,v 1.5 2000/07/27 04:41:06 assar Exp $"); +RCSID("$Id: socket.c,v 1.7 2001/09/03 12:04:23 joda Exp $"); #endif #include <roken.h> @@ -222,6 +222,31 @@ socket_set_port (struct sockaddr *sa, int port) } /* + * Set the range of ports to use when binding with port = 0. + */ +void +socket_set_portrange (int sock, int restr, int af) +{ +#if defined(IP_PORTRANGE) + if (af == AF_INET) { + int on = restr ? IP_PORTRANGE_HIGH : IP_PORTRANGE_DEFAULT; + if (setsockopt (sock, IPPROTO_IP, IP_PORTRANGE, &on, + sizeof(on)) < 0) + warn ("setsockopt IP_PORTRANGE (ignored)"); + } +#endif +#if defined(IPV6_PORTRANGE) + if (af == AF_INET6) { + int on = restr ? IPV6_PORTRANGE_HIGH : + IPV6_PORTRANGE_DEFAULT; + if (setsockopt (sock, IPPROTO_IPV6, IPV6_PORTRANGE, &on, + sizeof(on)) < 0) + warn ("setsockopt IPV6_PORTRANGE (ignored)"); + } +#endif +} + +/* * Enable debug on `sock'. */ diff --git a/crypto/heimdal/lib/roken/strftime.c b/crypto/heimdal/lib/roken/strftime.c index 6056073..dcd279b 100644 --- a/crypto/heimdal/lib/roken/strftime.c +++ b/crypto/heimdal/lib/roken/strftime.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -35,7 +35,7 @@ #endif #include "roken.h" -RCSID("$Id: strftime.c,v 1.11 2000/07/08 14:22:12 assar Exp $"); +RCSID("$Id: strftime.c,v 1.12 2001/09/04 09:53:51 assar Exp $"); static const char *abb_weekdays[] = { "Sun", @@ -172,7 +172,7 @@ strftime (char *buf, size_t maxsize, const char *format, const struct tm *tm) { size_t n = 0; - size_t ret; + int ret; while (*format != '\0' && n < maxsize) { if (*format == '%') { @@ -381,7 +381,7 @@ strftime (char *buf, size_t maxsize, const char *format, "%%%c", *format); break; } - if (ret >= maxsize - n) + if (ret < 0 || ret >= maxsize - n) return 0; n += ret; buf += ret; diff --git a/crypto/heimdal/lib/roken/vis.c b/crypto/heimdal/lib/roken/vis.c index 82a6ba5..8dd5832 100644 --- a/crypto/heimdal/lib/roken/vis.c +++ b/crypto/heimdal/lib/roken/vis.c @@ -38,7 +38,7 @@ #if 1 #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: vis.c,v 1.3 2000/12/10 23:10:48 assar Exp $"); +RCSID("$Id: vis.c,v 1.5 2001/09/03 05:37:23 assar Exp $"); #endif #include <roken.h> #ifndef _DIAGASSERT @@ -107,71 +107,73 @@ do { \ * extra: Pointer to the list of extra characters to be * backslash-protected. */ -#define SVIS(dst, c, flag, nextc, extra) \ -do { \ - int isextra, isc; \ - isextra = strchr(extra, c) != NULL; \ - if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) || \ - ((flag & VIS_SAFE) && issafe(c)))) { \ - *dst++ = c; \ - break; \ - } \ - isc = 0; \ - if (flag & VIS_CSTYLE) { \ - switch (c) { \ - case '\n': \ - isc = 1; *dst++ = '\\'; *dst++ = 'n'; \ - break; \ - case '\r': \ - isc = 1; *dst++ = '\\'; *dst++ = 'r'; \ - break; \ - case '\b': \ - isc = 1; *dst++ = '\\'; *dst++ = 'b'; \ - break; \ - case BELL: \ - isc = 1; *dst++ = '\\'; *dst++ = 'a'; \ - break; \ - case '\v': \ - isc = 1; *dst++ = '\\'; *dst++ = 'v'; \ - break; \ - case '\t': \ - isc = 1; *dst++ = '\\'; *dst++ = 't'; \ - break; \ - case '\f': \ - isc = 1; *dst++ = '\\'; *dst++ = 'f'; \ - break; \ - case ' ': \ - isc = 1; *dst++ = '\\'; *dst++ = 's'; \ - break; \ - case '\0': \ - isc = 1; *dst++ = '\\'; *dst++ = '0'; \ - if (isoctal(nextc)) { \ - *dst++ = '0'; \ - *dst++ = '0'; \ - } \ - } \ - } \ - if (isc) break; \ - if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \ - *dst++ = '\\'; \ - *dst++ = (u_char)(((unsigned)(u_char)c >> 6) & 03) + '0'; \ - *dst++ = (u_char)(((unsigned)(u_char)c >> 3) & 07) + '0'; \ - *dst++ = (c & 07) + '0'; \ - } else { \ - if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; \ - if (c & 0200) { \ - c &= 0177; *dst++ = 'M'; \ - } \ - if (iscntrl(c)) { \ - *dst++ = '^'; \ - if (c == 0177) \ - *dst++ = '?'; \ - else \ - *dst++ = c + '@'; \ - } else { \ - *dst++ = '-'; *dst++ = c; \ - } \ - } \ +#define SVIS(dst, c, flag, nextc, extra) \ +do { \ + int isextra, isc; \ + isextra = strchr(extra, c) != NULL; \ + if (!isextra && \ + isascii((unsigned char)c) && \ + (isgraph((unsigned char)c) || iswhite(c) || \ + ((flag & VIS_SAFE) && issafe(c)))) { \ + *dst++ = c; \ + break; \ + } \ + isc = 0; \ + if (flag & VIS_CSTYLE) { \ + switch (c) { \ + case '\n': \ + isc = 1; *dst++ = '\\'; *dst++ = 'n'; \ + break; \ + case '\r': \ + isc = 1; *dst++ = '\\'; *dst++ = 'r'; \ + break; \ + case '\b': \ + isc = 1; *dst++ = '\\'; *dst++ = 'b'; \ + break; \ + case BELL: \ + isc = 1; *dst++ = '\\'; *dst++ = 'a'; \ + break; \ + case '\v': \ + isc = 1; *dst++ = '\\'; *dst++ = 'v'; \ + break; \ + case '\t': \ + isc = 1; *dst++ = '\\'; *dst++ = 't'; \ + break; \ + case '\f': \ + isc = 1; *dst++ = '\\'; *dst++ = 'f'; \ + break; \ + case ' ': \ + isc = 1; *dst++ = '\\'; *dst++ = 's'; \ + break; \ + case '\0': \ + isc = 1; *dst++ = '\\'; *dst++ = '0'; \ + if (isoctal(nextc)) { \ + *dst++ = '0'; \ + *dst++ = '0'; \ + } \ + } \ + } \ + if (isc) break; \ + if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \ + *dst++ = '\\'; \ + *dst++ = (u_char)(((unsigned)(u_char)c >> 6) & 03) + '0'; \ + *dst++ = (u_char)(((unsigned)(u_char)c >> 3) & 07) + '0'; \ + *dst++ = (c & 07) + '0'; \ + } else { \ + if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; \ + if (c & 0200) { \ + c &= 0177; *dst++ = 'M'; \ + } \ + if (iscntrl((unsigned char)c)) { \ + *dst++ = '^'; \ + if (c == 0177) \ + *dst++ = '?'; \ + else \ + *dst++ = c + '@'; \ + } else { \ + *dst++ = '-'; *dst++ = c; \ + } \ + } \ } while (/*CONSTCOND*/0) diff --git a/crypto/heimdal/lib/roken/warnerr.c b/crypto/heimdal/lib/roken/warnerr.c index 0ebae25..0509d19 100644 --- a/crypto/heimdal/lib/roken/warnerr.c +++ b/crypto/heimdal/lib/roken/warnerr.c @@ -33,54 +33,12 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: warnerr.c,v 1.13 2001/05/16 23:54:19 assar Exp $"); +RCSID("$Id: warnerr.c,v 1.15 2001/07/09 14:56:51 assar Exp $"); #endif #include "roken.h" #include "err.h" -#ifndef HAVE___PROGNAME -const char *__progname; -#endif - -#ifndef HAVE_GETPROGNAME -const char * -getprogname(void) -{ - return __progname; -} -#endif - -#ifndef HAVE_SETPROGNAME -void -setprogname(const char *argv0) -{ -#ifndef HAVE___PROGNAME - char *p; - if(argv0 == NULL) - return; - p = strrchr(argv0, '/'); - if(p == NULL) - p = argv0; - else - p++; - __progname = p; -#endif -} -#endif /* HAVE_SETPROGNAME */ - -void -set_progname(char *argv0) -{ - setprogname ((const char *)argv0); -} - -const char * -get_progname (void) -{ - return getprogname (); -} - void warnerr(int doerrno, const char *fmt, va_list ap) { diff --git a/crypto/heimdal/lib/roken/write_pid.c b/crypto/heimdal/lib/roken/write_pid.c index ce02506..763b513 100644 --- a/crypto/heimdal/lib/roken/write_pid.c +++ b/crypto/heimdal/lib/roken/write_pid.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: write_pid.c,v 1.5 2001/02/20 01:44:55 assar Exp $"); +RCSID("$Id: write_pid.c,v 1.6 2001/09/02 23:58:15 assar Exp $"); #endif #include <stdio.h> @@ -90,6 +90,10 @@ pidfile(const char *basename) if(basename == NULL) basename = getprogname(); pidfile_path = pid_file_write(basename); +#if defined(HAVE_ATEXIT) atexit(pidfile_cleanup); +#elif defined(HAVE_ON_EXIT) + on_exit(pidfile_cleanup); +#endif } #endif diff --git a/crypto/heimdal/lib/roken/xdbm.h b/crypto/heimdal/lib/roken/xdbm.h index 429c3d1..4a7bc07 100644 --- a/crypto/heimdal/lib/roken/xdbm.h +++ b/crypto/heimdal/lib/roken/xdbm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -31,30 +31,27 @@ * SUCH DAMAGE. */ -/* $Id: xdbm.h,v 1.12 2000/08/16 03:57:21 assar Exp $ */ +/* $Id: xdbm.h,v 1.14 2001/09/03 05:03:00 assar Exp $ */ /* Generic *dbm include file */ #ifndef __XDBM_H__ #define __XDBM_H__ -#if defined(HAVE_DB_H) +#if HAVE_DB_NDBM #define DB_DBM_HSEARCH 1 #include <db.h> -#endif - -#ifndef DBM_INSERT -#if defined(HAVE_NDBM_H) -#include <ndbm.h> -#elif defined(HAVE_GDBM_NDBM_H) +#elif HAVE_NDBM +#if defined(HAVE_GDBM_NDBM_H) #include <gdbm/ndbm.h> +#elif defined(HAVE_NDBM_H) +#include <ndbm.h> #elif defined(HAVE_DBM_H) #include <dbm.h> -#elif defined(HAVE_RPCSVC_DBM_H) -#include <rpcsvc/dbm.h> -#endif #endif +#endif /* HAVE_NDBM */ +#if 0 /* Macros to convert ndbm names to dbm names. * Note that dbm_nextkey() cannot be simply converted using a macro, since * it is invoked giving the database, and nextkey() needs the previous key. @@ -75,5 +72,6 @@ typedef char DBM; #else #define dbm_next(db,key) dbm_nextkey(db) #endif +#endif #endif /* __XDBM_H__ */ |