Add eXtensible Data Record (XDR) support
* configure.host: Build libc/xdr only on cygwin. * Makefile.am: Install xdr headers. * libc/configure.in: Support new libc/xdr subdirectory. * libc/Makefile.am: Support new libc/xdr subdirectory. * libc/include/rpc/types.h: New. * libc/include/rpc/xdr.h: New. * libc/xdr/README: New. * libc/xdr/Makefile.am: New. * libc/xdr/dummy.c: New. * libc/xdr/xdr.c: New. * libc/xdr/xdr_array.c: New. * libc/xdr/xdr_float.c: New. * libc/xdr/xdr_float_vax.c: New. * libc/xdr/xdr_mem.c: New. * libc/xdr/xdr_private.c: New. * libc/xdr/xdr_private.h: New. * libc/xdr/xdr_rec.c: New. * libc/xdr/xdr_reference.c: New. * libc/xdr/xdr_sizeof.c: New. * libc/xdr/xdr_stdio.c: New. Regenerate using ac-2.63 and am-1.11.1 * libc/xdr/Makefile.in: New. * Makefile.in: Regenerate. * libc/configure: Regenerate. * libc/Makefile.in: Regenerate. * libc/argz/Makefile.in: Regenerate. * libc/ctype/Makefile.in: Regenerate. * libc/errno/Makefile.in: Regenerate. * libc/iconv/ccs/binary/Makefile.in: Regenerate. * libc/iconv/ccs/Makefile.in: Regenerate. * libc/iconv/ces/Makefile.in: Regenerate. * libc/iconv/lib/Makefile.in: Regenerate. * libc/iconv/Makefile.in: Regenerate. * libc/locale/Makefile.in: Regenerate. * libc/misc/Makefile.in: Regenerate. * libc/posix/Makefile.in: Regenerate. * libc/reent/Makefile.in: Regenerate. * libc/search/Makefile.in: Regenerate. * libc/signal/Makefile.in: Regenerate. * libc/stdio/Makefile.in: Regenerate. * libc/stdio64/Makefile.in: Regenerate. * libc/stdlib/Makefile.in: Regenerate. * libc/string/Makefile.in: Regenerate. * libc/syscalls/Makefile.in: Regenerate. * libc/time/Makefile.in: Regenerate. * libc/unix/Makefile.in: Regenerate.
This commit is contained in:
parent
cf15694586
commit
3d7c4998ac
|
@ -1,3 +1,54 @@
|
|||
2010-03-02 Charles Wilson <cygwin@cwilson.fastmail.fm>
|
||||
|
||||
Add eXtensible Data Record (XDR) support
|
||||
* configure.host: Build libc/xdr only on cygwin.
|
||||
* Makefile.am: Install xdr headers.
|
||||
* libc/configure.in: Support new libc/xdr subdirectory.
|
||||
* libc/Makefile.am: Support new libc/xdr subdirectory.
|
||||
* libc/include/rpc/types.h: New.
|
||||
* libc/include/rpc/xdr.h: New.
|
||||
* libc/xdr/README: New.
|
||||
* libc/xdr/Makefile.am: New.
|
||||
* libc/xdr/dummy.c: New.
|
||||
* libc/xdr/xdr.c: New.
|
||||
* libc/xdr/xdr_array.c: New.
|
||||
* libc/xdr/xdr_float.c: New.
|
||||
* libc/xdr/xdr_float_vax.c: New.
|
||||
* libc/xdr/xdr_mem.c: New.
|
||||
* libc/xdr/xdr_private.c: New.
|
||||
* libc/xdr/xdr_private.h: New.
|
||||
* libc/xdr/xdr_rec.c: New.
|
||||
* libc/xdr/xdr_reference.c: New.
|
||||
* libc/xdr/xdr_sizeof.c: New.
|
||||
* libc/xdr/xdr_stdio.c: New.
|
||||
|
||||
Regenerate using ac-2.63 and am-1.11.1
|
||||
* libc/xdr/Makefile.in: New.
|
||||
* Makefile.in: Regenerate.
|
||||
* libc/configure: Regenerate.
|
||||
* libc/Makefile.in: Regenerate.
|
||||
* libc/argz/Makefile.in: Regenerate.
|
||||
* libc/ctype/Makefile.in: Regenerate.
|
||||
* libc/errno/Makefile.in: Regenerate.
|
||||
* libc/iconv/ccs/binary/Makefile.in: Regenerate.
|
||||
* libc/iconv/ccs/Makefile.in: Regenerate.
|
||||
* libc/iconv/ces/Makefile.in: Regenerate.
|
||||
* libc/iconv/lib/Makefile.in: Regenerate.
|
||||
* libc/iconv/Makefile.in: Regenerate.
|
||||
* libc/locale/Makefile.in: Regenerate.
|
||||
* libc/misc/Makefile.in: Regenerate.
|
||||
* libc/posix/Makefile.in: Regenerate.
|
||||
* libc/reent/Makefile.in: Regenerate.
|
||||
* libc/search/Makefile.in: Regenerate.
|
||||
* libc/signal/Makefile.in: Regenerate.
|
||||
* libc/stdio/Makefile.in: Regenerate.
|
||||
* libc/stdio64/Makefile.in: Regenerate.
|
||||
* libc/stdlib/Makefile.in: Regenerate.
|
||||
* libc/string/Makefile.in: Regenerate.
|
||||
* libc/syscalls/Makefile.in: Regenerate.
|
||||
* libc/time/Makefile.in: Regenerate.
|
||||
* libc/unix/Makefile.in: Regenerate.
|
||||
|
||||
2010-02-26 Craig Howland <howland@LGSInnovations.com>
|
||||
|
||||
* libm/common/s_ilogb.c: Fix typo in comments that causes doc
|
||||
|
|
|
@ -269,6 +269,10 @@ endif
|
|||
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/machine/`basename $$i`; \
|
||||
else true; fi ; \
|
||||
done; \
|
||||
$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/rpc; \
|
||||
for i in $(srcdir)/libc/include/rpc/*.h; do \
|
||||
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/rpc/`basename $$i`; \
|
||||
done; \
|
||||
$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/sys; \
|
||||
for i in $(srcdir)/libc/include/sys/*.h; do \
|
||||
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/sys/`basename $$i`; \
|
||||
|
|
|
@ -974,6 +974,10 @@ install-data-local: install-toollibLIBRARIES
|
|||
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/machine/`basename $$i`; \
|
||||
else true; fi ; \
|
||||
done; \
|
||||
$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/rpc; \
|
||||
for i in $(srcdir)/libc/include/rpc/*.h; do \
|
||||
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/rpc/`basename $$i`; \
|
||||
done; \
|
||||
$(mkinstalldirs) $(DESTDIR)$(tooldir)/include/sys; \
|
||||
for i in $(srcdir)/libc/include/sys/*.h; do \
|
||||
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/sys/`basename $$i`; \
|
||||
|
|
|
@ -55,6 +55,7 @@ posix_dir=
|
|||
signal_dir=signal
|
||||
stdio_dir=stdio
|
||||
stdio64_dir=
|
||||
xdr_dir=
|
||||
syscall_dir=
|
||||
unix_dir=
|
||||
mach_add_setjmp=
|
||||
|
@ -349,6 +350,7 @@ case "${host}" in
|
|||
*-*-cygwin*)
|
||||
posix_dir=posix
|
||||
stdio64_dir=stdio64
|
||||
xdr_dir=xdr
|
||||
;;
|
||||
*-*-netware*)
|
||||
signal_dir=
|
||||
|
|
|
@ -34,10 +34,15 @@ NEWLIB_ICONV_DIRS =
|
|||
NEWLIB_ICONV_LIBS =
|
||||
endif
|
||||
|
||||
if HAVE_XDR_DIR
|
||||
XDR_SUBDIR = xdr
|
||||
endif
|
||||
|
||||
# The order of SUBDIRS is important for the integrated documentation.
|
||||
# Do not change the order without considering the doc impact.
|
||||
SUBDIRS = argz stdlib ctype search $(STDIO_SUBDIR) $(STDIO64_SUBDIR) string $(SIGNAL_SUBDIR) time locale sys reent \
|
||||
$(extra_dir) errno misc machine $(UNIX_SUBDIR) $(POSIX_SUBDIR) $(SYSCALLS_SUBDIR) $(NEWLIB_ICONV_DIRS) .
|
||||
$(extra_dir) errno misc machine $(UNIX_SUBDIR) $(POSIX_SUBDIR) $(SYSCALLS_SUBDIR) $(NEWLIB_ICONV_DIRS) \
|
||||
$(XDR_SUBDIR) .
|
||||
|
||||
noinst_DATA = $(CRT0)
|
||||
|
||||
|
@ -50,6 +55,7 @@ SUBLIBS = \
|
|||
search/libsearch.$(aext) \
|
||||
$(LIBC_STDIO_LIB) \
|
||||
$(LIBC_STDIO64_LIB) \
|
||||
$(LIBC_XDR_LIB) \
|
||||
string/libstring.$(aext) \
|
||||
$(LIBC_SIGNAL_LIB) \
|
||||
time/libtime.$(aext) \
|
||||
|
@ -72,6 +78,7 @@ SUBLIBS = \
|
|||
search/lib.$(aext) \
|
||||
$(LIBC_STDIO_LIB) \
|
||||
$(LIBC_STDIO64_LIB) \
|
||||
$(LIBC_XDR_LIB) \
|
||||
string/lib.$(aext) \
|
||||
$(LIBC_SIGNAL_LIB) \
|
||||
time/lib.$(aext) \
|
||||
|
@ -125,6 +132,7 @@ SUBDEFS = \
|
|||
ctype/stmp-def \
|
||||
$(LIBC_STDIO_DEF) \
|
||||
$(LIBC_STDIO64_DEF) \
|
||||
$(LIBC_XDR_DEF) \
|
||||
string/stmp-def \
|
||||
$(LIBC_SIGNAL_DEF) \
|
||||
time/stmp-def \
|
||||
|
|
|
@ -68,19 +68,20 @@ am__DEPENDENCIES_1 =
|
|||
@USE_LIBTOOL_FALSE@am__DEPENDENCIES_3 = argz/lib.$(aext) \
|
||||
@USE_LIBTOOL_FALSE@ stdlib/lib.$(aext) ctype/lib.$(aext) \
|
||||
@USE_LIBTOOL_FALSE@ search/lib.$(aext) $(am__DEPENDENCIES_1) \
|
||||
@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1) string/lib.$(aext) \
|
||||
@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1) time/lib.$(aext) \
|
||||
@USE_LIBTOOL_FALSE@ locale/lib.$(aext) reent/lib.$(aext) \
|
||||
@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1) errno/lib.$(aext) \
|
||||
@USE_LIBTOOL_FALSE@ misc/lib.$(aext) $(am__DEPENDENCIES_1) \
|
||||
@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
|
||||
@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
|
||||
@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1)
|
||||
@USE_LIBTOOL_FALSE@ string/lib.$(aext) $(am__DEPENDENCIES_1) \
|
||||
@USE_LIBTOOL_FALSE@ time/lib.$(aext) locale/lib.$(aext) \
|
||||
@USE_LIBTOOL_FALSE@ reent/lib.$(aext) $(am__DEPENDENCIES_1) \
|
||||
@USE_LIBTOOL_FALSE@ errno/lib.$(aext) misc/lib.$(aext) \
|
||||
@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
|
||||
@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
|
||||
@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
|
||||
@USE_LIBTOOL_TRUE@am__DEPENDENCIES_3 = argz/libargz.$(aext) \
|
||||
@USE_LIBTOOL_TRUE@ stdlib/libstdlib.$(aext) \
|
||||
@USE_LIBTOOL_TRUE@ ctype/libctype.$(aext) \
|
||||
@USE_LIBTOOL_TRUE@ search/libsearch.$(aext) \
|
||||
@USE_LIBTOOL_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
|
||||
@USE_LIBTOOL_TRUE@ $(am__DEPENDENCIES_1) \
|
||||
@USE_LIBTOOL_TRUE@ string/libstring.$(aext) \
|
||||
@USE_LIBTOOL_TRUE@ $(am__DEPENDENCIES_1) time/libtime.$(aext) \
|
||||
@USE_LIBTOOL_TRUE@ locale/liblocale.$(aext) \
|
||||
|
@ -162,7 +163,7 @@ ETAGS = etags
|
|||
CTAGS = ctags
|
||||
DIST_SUBDIRS = argz stdlib ctype search stdio stdio64 string signal \
|
||||
time locale sys reent @extra_dir@ errno misc machine unix \
|
||||
posix syscalls iconv .
|
||||
posix syscalls iconv xdr .
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
|
@ -212,6 +213,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
@ -313,11 +316,13 @@ AUTOMAKE_OPTIONS = cygnus
|
|||
@ENABLE_NEWLIB_ICONV_TRUE@NEWLIB_ICONV_DIRS = iconv
|
||||
@ENABLE_NEWLIB_ICONV_FALSE@NEWLIB_ICONV_LIBS =
|
||||
@ENABLE_NEWLIB_ICONV_TRUE@NEWLIB_ICONV_LIBS = iconv/ces/lib.$(aext) iconv/ccs/lib.$(aext) iconv/lib/lib.$(aext)
|
||||
@HAVE_XDR_DIR_TRUE@XDR_SUBDIR = xdr
|
||||
|
||||
# The order of SUBDIRS is important for the integrated documentation.
|
||||
# Do not change the order without considering the doc impact.
|
||||
SUBDIRS = argz stdlib ctype search $(STDIO_SUBDIR) $(STDIO64_SUBDIR) string $(SIGNAL_SUBDIR) time locale sys reent \
|
||||
$(extra_dir) errno misc machine $(UNIX_SUBDIR) $(POSIX_SUBDIR) $(SYSCALLS_SUBDIR) $(NEWLIB_ICONV_DIRS) .
|
||||
$(extra_dir) errno misc machine $(UNIX_SUBDIR) $(POSIX_SUBDIR) $(SYSCALLS_SUBDIR) $(NEWLIB_ICONV_DIRS) \
|
||||
$(XDR_SUBDIR) .
|
||||
|
||||
noinst_DATA = $(CRT0)
|
||||
@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libc.la
|
||||
|
@ -328,6 +333,7 @@ noinst_DATA = $(CRT0)
|
|||
@USE_LIBTOOL_FALSE@ search/lib.$(aext) \
|
||||
@USE_LIBTOOL_FALSE@ $(LIBC_STDIO_LIB) \
|
||||
@USE_LIBTOOL_FALSE@ $(LIBC_STDIO64_LIB) \
|
||||
@USE_LIBTOOL_FALSE@ $(LIBC_XDR_LIB) \
|
||||
@USE_LIBTOOL_FALSE@ string/lib.$(aext) \
|
||||
@USE_LIBTOOL_FALSE@ $(LIBC_SIGNAL_LIB) \
|
||||
@USE_LIBTOOL_FALSE@ time/lib.$(aext) \
|
||||
|
@ -350,6 +356,7 @@ noinst_DATA = $(CRT0)
|
|||
@USE_LIBTOOL_TRUE@ search/libsearch.$(aext) \
|
||||
@USE_LIBTOOL_TRUE@ $(LIBC_STDIO_LIB) \
|
||||
@USE_LIBTOOL_TRUE@ $(LIBC_STDIO64_LIB) \
|
||||
@USE_LIBTOOL_TRUE@ $(LIBC_XDR_LIB) \
|
||||
@USE_LIBTOOL_TRUE@ string/libstring.$(aext) \
|
||||
@USE_LIBTOOL_TRUE@ $(LIBC_SIGNAL_LIB) \
|
||||
@USE_LIBTOOL_TRUE@ time/libtime.$(aext) \
|
||||
|
@ -379,6 +386,7 @@ SUBDEFS = \
|
|||
ctype/stmp-def \
|
||||
$(LIBC_STDIO_DEF) \
|
||||
$(LIBC_STDIO64_DEF) \
|
||||
$(LIBC_XDR_DEF) \
|
||||
string/stmp-def \
|
||||
$(LIBC_SIGNAL_DEF) \
|
||||
time/stmp-def \
|
||||
|
|
|
@ -159,6 +159,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -675,6 +675,10 @@ LIBC_UNIX_LIB
|
|||
HAVE_SYSCALL_DIR_FALSE
|
||||
HAVE_SYSCALL_DIR_TRUE
|
||||
LIBC_SYSCALL_LIB
|
||||
HAVE_XDR_DIR_FALSE
|
||||
HAVE_XDR_DIR_TRUE
|
||||
LIBC_XDR_DEF
|
||||
LIBC_XDR_LIB
|
||||
HAVE_STDIO64_DIR_FALSE
|
||||
HAVE_STDIO64_DIR_TRUE
|
||||
LIBC_STDIO64_DEF
|
||||
|
@ -12395,7 +12399,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 12398 "configure"
|
||||
#line 12402 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -12501,7 +12505,7 @@ else
|
|||
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
||||
lt_status=$lt_dlunknown
|
||||
cat > conftest.$ac_ext <<_LT_EOF
|
||||
#line 12504 "configure"
|
||||
#line 12508 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#if HAVE_DLFCN_H
|
||||
|
@ -12833,6 +12837,27 @@ else
|
|||
fi
|
||||
|
||||
|
||||
LIBC_XDR_LIB=
|
||||
LIBC_XDR_DEF=
|
||||
if test -n "${xdr_dir}"; then
|
||||
if test "${use_libtool}" = "yes"; then
|
||||
LIBC_XDR_LIB=${xdr_dir}/lib${xdr_dir}.${aext}
|
||||
else
|
||||
LIBC_XDR_LIB=${xdr_dir}/lib.${aext}
|
||||
fi
|
||||
LIBC_XDR_DEF=${xdr_dir}/stmp-def
|
||||
fi
|
||||
|
||||
|
||||
if test x${xdr_dir} != x; then
|
||||
HAVE_XDR_DIR_TRUE=
|
||||
HAVE_XDR_DIR_FALSE='#'
|
||||
else
|
||||
HAVE_XDR_DIR_TRUE='#'
|
||||
HAVE_XDR_DIR_FALSE=
|
||||
fi
|
||||
|
||||
|
||||
LIBC_SYSCALL_LIB=
|
||||
if test -n "${syscall_dir}"; then
|
||||
if test "${use_libtool}" = "yes"; then
|
||||
|
@ -12943,7 +12968,7 @@ fi
|
|||
|
||||
|
||||
|
||||
ac_config_files="$ac_config_files Makefile argz/Makefile ctype/Makefile errno/Makefile locale/Makefile misc/Makefile reent/Makefile search/Makefile stdio/Makefile stdio64/Makefile stdlib/Makefile string/Makefile time/Makefile posix/Makefile signal/Makefile syscalls/Makefile unix/Makefile iconv/Makefile iconv/ces/Makefile iconv/ccs/Makefile iconv/ccs/binary/Makefile iconv/lib/Makefile"
|
||||
ac_config_files="$ac_config_files Makefile argz/Makefile ctype/Makefile errno/Makefile locale/Makefile misc/Makefile reent/Makefile search/Makefile stdio/Makefile stdio64/Makefile stdlib/Makefile string/Makefile time/Makefile posix/Makefile signal/Makefile syscalls/Makefile unix/Makefile iconv/Makefile iconv/ces/Makefile iconv/ccs/Makefile iconv/ccs/binary/Makefile iconv/lib/Makefile xdr/Makefile"
|
||||
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
|
@ -13191,6 +13216,13 @@ $as_echo "$as_me: error: conditional \"HAVE_STDIO64_DIR\" was never defined.
|
|||
Usually this means the macro was only invoked conditionally." >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi
|
||||
if test -z "${HAVE_XDR_DIR_TRUE}" && test -z "${HAVE_XDR_DIR_FALSE}"; then
|
||||
{ { $as_echo "$as_me:$LINENO: error: conditional \"HAVE_XDR_DIR\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." >&5
|
||||
$as_echo "$as_me: error: conditional \"HAVE_XDR_DIR\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi
|
||||
if test -z "${HAVE_SYSCALL_DIR_TRUE}" && test -z "${HAVE_SYSCALL_DIR_FALSE}"; then
|
||||
{ { $as_echo "$as_me:$LINENO: error: conditional \"HAVE_SYSCALL_DIR\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." >&5
|
||||
|
@ -13994,6 +14026,7 @@ do
|
|||
"iconv/ccs/Makefile") CONFIG_FILES="$CONFIG_FILES iconv/ccs/Makefile" ;;
|
||||
"iconv/ccs/binary/Makefile") CONFIG_FILES="$CONFIG_FILES iconv/ccs/binary/Makefile" ;;
|
||||
"iconv/lib/Makefile") CONFIG_FILES="$CONFIG_FILES iconv/lib/Makefile" ;;
|
||||
"xdr/Makefile") CONFIG_FILES="$CONFIG_FILES xdr/Makefile" ;;
|
||||
|
||||
*) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
|
||||
$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
|
||||
|
|
|
@ -94,6 +94,20 @@ AC_SUBST(LIBC_STDIO64_LIB)
|
|||
AC_SUBST(LIBC_STDIO64_DEF)
|
||||
AM_CONDITIONAL(HAVE_STDIO64_DIR, test x${stdio64_dir} != x)
|
||||
|
||||
LIBC_XDR_LIB=
|
||||
LIBC_XDR_DEF=
|
||||
if test -n "${xdr_dir}"; then
|
||||
if test "${use_libtool}" = "yes"; then
|
||||
LIBC_XDR_LIB=${xdr_dir}/lib${xdr_dir}.${aext}
|
||||
else
|
||||
LIBC_XDR_LIB=${xdr_dir}/lib.${aext}
|
||||
fi
|
||||
LIBC_XDR_DEF=${xdr_dir}/stmp-def
|
||||
fi
|
||||
AC_SUBST(LIBC_XDR_LIB)
|
||||
AC_SUBST(LIBC_XDR_DEF)
|
||||
AM_CONDITIONAL(HAVE_XDR_DIR, test x${xdr_dir} != x)
|
||||
|
||||
LIBC_SYSCALL_LIB=
|
||||
if test -n "${syscall_dir}"; then
|
||||
if test "${use_libtool}" = "yes"; then
|
||||
|
@ -171,5 +185,5 @@ fi
|
|||
AC_SUBST(LIBC_MACHINE_LIB)
|
||||
AC_SUBST(machine_dir)
|
||||
|
||||
AC_CONFIG_FILES([Makefile argz/Makefile ctype/Makefile errno/Makefile locale/Makefile misc/Makefile reent/Makefile search/Makefile stdio/Makefile stdio64/Makefile stdlib/Makefile string/Makefile time/Makefile posix/Makefile signal/Makefile syscalls/Makefile unix/Makefile iconv/Makefile iconv/ces/Makefile iconv/ccs/Makefile iconv/ccs/binary/Makefile iconv/lib/Makefile])
|
||||
AC_CONFIG_FILES([Makefile argz/Makefile ctype/Makefile errno/Makefile locale/Makefile misc/Makefile reent/Makefile search/Makefile stdio/Makefile stdio64/Makefile stdlib/Makefile string/Makefile time/Makefile posix/Makefile signal/Makefile syscalls/Makefile unix/Makefile iconv/Makefile iconv/ces/Makefile iconv/ccs/Makefile iconv/ccs/binary/Makefile iconv/lib/Makefile xdr/Makefile])
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -172,6 +172,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -132,6 +132,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -138,6 +138,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -183,6 +183,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -124,6 +124,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -137,6 +137,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -130,6 +130,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2009, Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of Sun Microsystems, Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
|
||||
*
|
||||
* from: @(#)types.h 1.18 87/07/24 SMI
|
||||
* from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC
|
||||
* $FreeBSD: src/include/rpc/types.h,v 1.10.6.1 2003/12/18 00:59:50 peter Exp $
|
||||
* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Rpc additions to <sys/types.h>
|
||||
*/
|
||||
#ifndef _RPC_TYPES_H
|
||||
#define _RPC_TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(___int64_t_defined)
|
||||
typedef u_int64_t u_quad_t;
|
||||
typedef int64_t quad_t;
|
||||
#endif /* ___int64_t_defined */
|
||||
typedef int32_t bool_t;
|
||||
typedef int32_t enum_t;
|
||||
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
#define __dontcare__ -1
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef mem_alloc
|
||||
#define mem_alloc(bsize) calloc(1, bsize)
|
||||
#endif
|
||||
#ifndef mem_free
|
||||
#define mem_free(ptr, bsize) free(ptr)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_RPC_TYPES_H */
|
|
@ -0,0 +1,379 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2009, Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of Sun Microsystems, Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
|
||||
*
|
||||
* from: @(#)xdr.h 1.19 87/04/22 SMI
|
||||
* from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC
|
||||
* $FreeBSD: src/include/rpc/xdr.h,v 1.23 2003/03/07 13:19:40 nectar Exp $
|
||||
* $NetBSD: xdr.h,v 1.19 2000/07/17 05:00:45 matt Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* xdr.h, External Data Representation Serialization Routines.
|
||||
*
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _RPC_XDR_H
|
||||
#define _RPC_XDR_H
|
||||
#include <_ansi.h>
|
||||
#include <rpc/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XDR provides a conventional way for converting between C data
|
||||
* types and an external bit-string representation. Library supplied
|
||||
* routines provide for the conversion on built-in C data types. These
|
||||
* routines and utility routines defined here are used to help implement
|
||||
* a type encode/decode routine for each user-defined type.
|
||||
*
|
||||
* Each data type provides a single procedure which takes two arguments:
|
||||
*
|
||||
* bool_t
|
||||
* xdrproc(XDR *xdrs, <type> *argresp)
|
||||
*
|
||||
* xdrs is an instance of a XDR handle, to which or from which the data
|
||||
* type is to be converted. argresp is a pointer to the structure to be
|
||||
* converted. The XDR handle contains an operation field which indicates
|
||||
* which of the operations (ENCODE, DECODE * or FREE) is to be performed.
|
||||
*
|
||||
* XDR_DECODE may allocate space if the pointer argresp is null. This
|
||||
* data can be freed with the XDR_FREE operation.
|
||||
*
|
||||
* We write only one procedure per data type to make it easy
|
||||
* to keep the encode and decode procedures for a data type consistent.
|
||||
* In many cases the same code performs all operations on a user defined type,
|
||||
* because all the hard work is done in the component type routines.
|
||||
* decode as a series of calls on the nested data types.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Xdr operations. XDR_ENCODE causes the type to be encoded into the
|
||||
* stream. XDR_DECODE causes the type to be extracted from the stream.
|
||||
* XDR_FREE can be used to release the space allocated by an XDR_DECODE
|
||||
* request.
|
||||
*/
|
||||
enum xdr_op
|
||||
{
|
||||
XDR_ENCODE = 0,
|
||||
XDR_DECODE = 1,
|
||||
XDR_FREE = 2
|
||||
};
|
||||
|
||||
/*
|
||||
* This is the number of bytes per unit of external data.
|
||||
*/
|
||||
#define BYTES_PER_XDR_UNIT (4)
|
||||
#if 1
|
||||
/* faster version when BYTES_PER_XDR_UNIT is a power of two */
|
||||
# define RNDUP(x) (((x) + BYTES_PER_XDR_UNIT - 1) & ~(BYTES_PER_XDR_UNIT - 1))
|
||||
#else /* old version */
|
||||
#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \
|
||||
* BYTES_PER_XDR_UNIT)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The XDR handle.
|
||||
* Contains operation which is being applied to the stream,
|
||||
* an operations vector for the particular implementation (e.g. see xdr_mem.c),
|
||||
* and two private fields for the use of the particular implementation.
|
||||
*/
|
||||
typedef struct __rpc_xdr
|
||||
{
|
||||
enum xdr_op x_op; /* operation; fast additional param */
|
||||
_CONST struct xdr_ops
|
||||
{
|
||||
/* get a long from underlying stream */
|
||||
bool_t _EXFNPTR (x_getlong, (struct __rpc_xdr *, long *));
|
||||
|
||||
/* put a long to " */
|
||||
bool_t _EXFNPTR (x_putlong, (struct __rpc_xdr *, _CONST long *));
|
||||
|
||||
/* get some bytes from " */
|
||||
bool_t _EXFNPTR (x_getbytes, (struct __rpc_xdr *, char *, u_int));
|
||||
|
||||
/* put some bytes to " */
|
||||
bool_t _EXFNPTR (x_putbytes, (struct __rpc_xdr *, _CONST char *, u_int));
|
||||
|
||||
/* returns bytes off from beginning */
|
||||
u_int _EXFNPTR (x_getpostn, (struct __rpc_xdr *));
|
||||
|
||||
/* lets you reposition the stream */
|
||||
bool_t _EXFNPTR (x_setpostn, (struct __rpc_xdr *, u_int));
|
||||
|
||||
/* buf quick ptr to buffered data */
|
||||
int32_t * _EXFNPTR (x_inline, (struct __rpc_xdr *, u_int));
|
||||
|
||||
/* free privates of this xdr_stream */
|
||||
void _EXFNPTR (x_destroy, (struct __rpc_xdr *));
|
||||
|
||||
/* get an int32 from this xdr_stream */
|
||||
bool_t _EXFNPTR (x_getint32, (struct __rpc_xdr *, int32_t *));
|
||||
|
||||
/* put an int32 to the underlying stream */
|
||||
bool_t _EXFNPTR (x_putint32, (struct __rpc_xdr *, _CONST int32_t *));
|
||||
|
||||
} *x_ops;
|
||||
char *x_public; /* users' data */
|
||||
void *x_private; /* pointer to private data */
|
||||
char *x_base; /* private used for position info */
|
||||
u_int x_handy; /* extra private word */
|
||||
} XDR;
|
||||
|
||||
/*
|
||||
* A xdrproc_t exists for each data type which is to be encoded or decoded.
|
||||
*
|
||||
* The second argument to the xdrproc_t is a pointer to an opaque pointer.
|
||||
* The opaque pointer generally points to a structure of the data type
|
||||
* to be decoded. If this pointer is 0, then the type routines should
|
||||
* allocate dynamic storage of the appropriate size and return it.
|
||||
* bool_t (*xdrproc_t)(XDR *, some_type *)
|
||||
*/
|
||||
typedef bool_t _EXFNPTR(xdrproc_t, (XDR *, ...));
|
||||
|
||||
/*
|
||||
* Operations defined on a XDR handle
|
||||
*
|
||||
* XDR *xdrs;
|
||||
* long *longp;
|
||||
* char *addr;
|
||||
* u_int len;
|
||||
* u_int pos;
|
||||
*/
|
||||
#define XDR_GETINT32(xdrs, int32p) \
|
||||
(*(xdrs)->x_ops->x_getint32)(xdrs, int32p)
|
||||
#define xdr_getint32(xdrs, int32p) \
|
||||
(*(xdrs)->x_ops->x_getint32)(xdrs, int32p)
|
||||
|
||||
#define XDR_PUTINT32(xdrs, int32p) \
|
||||
(*(xdrs)->x_ops->x_putint32)(xdrs, int32p)
|
||||
#define xdr_putint32(xdrs, int32p) \
|
||||
(*(xdrs)->x_ops->x_putint32)(xdrs, int32p)
|
||||
|
||||
#define XDR_GETLONG(xdrs, longp) \
|
||||
(*(xdrs)->x_ops->x_getlong)(xdrs, longp)
|
||||
#define xdr_getlong(xdrs, longp) \
|
||||
(*(xdrs)->x_ops->x_getlong)(xdrs, longp)
|
||||
|
||||
#define XDR_PUTLONG(xdrs, longp) \
|
||||
(*(xdrs)->x_ops->x_putlong)(xdrs, longp)
|
||||
#define xdr_putlong(xdrs, longp) \
|
||||
(*(xdrs)->x_ops->x_putlong)(xdrs, longp)
|
||||
|
||||
#define XDR_GETBYTES(xdrs, addr, len) \
|
||||
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
|
||||
#define xdr_getbytes(xdrs, addr, len) \
|
||||
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
|
||||
|
||||
#define XDR_PUTBYTES(xdrs, addr, len) \
|
||||
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
|
||||
#define xdr_putbytes(xdrs, addr, len) \
|
||||
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
|
||||
|
||||
#define XDR_GETPOS(xdrs) \
|
||||
(*(xdrs)->x_ops->x_getpostn)(xdrs)
|
||||
#define xdr_getpos(xdrs) \
|
||||
(*(xdrs)->x_ops->x_getpostn)(xdrs)
|
||||
|
||||
#define XDR_SETPOS(xdrs, pos) \
|
||||
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
|
||||
#define xdr_setpos(xdrs, pos) \
|
||||
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
|
||||
|
||||
#define XDR_INLINE(xdrs, len) \
|
||||
(*(xdrs)->x_ops->x_inline)(xdrs, len)
|
||||
#define xdr_inline(xdrs, len) \
|
||||
(*(xdrs)->x_ops->x_inline)(xdrs, len)
|
||||
|
||||
#define XDR_DESTROY(xdrs) \
|
||||
do { \
|
||||
if ((xdrs)->x_ops->x_destroy) \
|
||||
(*(xdrs)->x_ops->x_destroy)(xdrs); \
|
||||
} while (0)
|
||||
#define xdr_destroy(xdrs) \
|
||||
do { \
|
||||
if ((xdrs)->x_ops->x_destroy) \
|
||||
(*(xdrs)->x_ops->x_destroy)(xdrs); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Support struct for discriminated unions.
|
||||
* You create an array of xdrdiscrim structures, terminated with
|
||||
* an entry with a null procedure pointer. The xdr_union routine gets
|
||||
* the discriminant value and then searches the array of structures
|
||||
* for a matching value. If a match is found the associated xdr routine
|
||||
* is called to handle that part of the union. If there is
|
||||
* no match, then a default routine may be called.
|
||||
* If there is no match and no default routine it is an error.
|
||||
*/
|
||||
#define NULL_xdrproc_t ((xdrproc_t)0)
|
||||
struct xdr_discrim
|
||||
{
|
||||
int value;
|
||||
xdrproc_t proc;
|
||||
};
|
||||
|
||||
/*
|
||||
* In-line routines for fast encode/decode of primitive data types.
|
||||
* Caveat emptor: these use single memory cycles to get the
|
||||
* data from the underlying buffer, and will fail to operate
|
||||
* properly if the data is not aligned. The standard way to use these
|
||||
* is to say:
|
||||
* if ((buf = XDR_INLINE(xdrs, count)) == NULL)
|
||||
* return (FALSE);
|
||||
* <<< macro calls >>>
|
||||
* where ``count'' is the number of bytes of data occupied
|
||||
* by the primitive data types.
|
||||
*
|
||||
* N.B. and frozen for all time: each data type here uses 4 bytes
|
||||
* of external representation.
|
||||
*/
|
||||
#define IXDR_GET_INT32(buf) ((int32_t)ntohl((u_int32_t)*(buf)++))
|
||||
#define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v))
|
||||
#define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf))
|
||||
#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v)))
|
||||
|
||||
/* Warning: inline long routines are broken for 64 bit platforms.
|
||||
* Because the other inline routines below are implemented in terms
|
||||
* of them, they are all also broken for 64 bit platforms.
|
||||
*/
|
||||
#define IXDR_GET_LONG(buf) ((long)ntohl((u_int32_t)*(buf)++))
|
||||
#define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v))
|
||||
#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf))
|
||||
#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), (v))
|
||||
|
||||
#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf))
|
||||
#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf))
|
||||
#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf))
|
||||
#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf))
|
||||
|
||||
#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), (v))
|
||||
#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), (v))
|
||||
#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), (v))
|
||||
#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), (v))
|
||||
|
||||
/*
|
||||
* These are the "generic" xdr routines.
|
||||
*/
|
||||
extern bool_t _EXFUN (xdr_void, (void));
|
||||
extern bool_t _EXFUN (xdr_short, (XDR *, short *));
|
||||
extern bool_t _EXFUN (xdr_u_short, (XDR *, u_short *));
|
||||
extern bool_t _EXFUN (xdr_int, (XDR *, int *));
|
||||
extern bool_t _EXFUN (xdr_u_int, (XDR *, u_int *));
|
||||
extern bool_t _EXFUN (xdr_long, (XDR *, long *));
|
||||
extern bool_t _EXFUN (xdr_u_long, (XDR *, u_long *));
|
||||
extern bool_t _EXFUN (xdr_int8_t, (XDR *, int8_t *));
|
||||
extern bool_t _EXFUN (xdr_uint8_t, (XDR *, uint8_t *));
|
||||
extern bool_t _EXFUN (xdr_u_int8_t, (XDR *, u_int8_t *));
|
||||
extern bool_t _EXFUN (xdr_int16_t, (XDR *, int16_t *));
|
||||
extern bool_t _EXFUN (xdr_uint16_t, (XDR *, uint16_t *));
|
||||
extern bool_t _EXFUN (xdr_u_int16_t, (XDR *, u_int16_t *));
|
||||
extern bool_t _EXFUN (xdr_int32_t, (XDR *, int32_t *));
|
||||
extern bool_t _EXFUN (xdr_uint32_t, (XDR *, uint32_t *));
|
||||
extern bool_t _EXFUN (xdr_u_int32_t, (XDR *, u_int32_t *));
|
||||
#if defined(___int64_t_defined)
|
||||
extern bool_t _EXFUN (xdr_int64_t, (XDR *, int64_t *));
|
||||
extern bool_t _EXFUN (xdr_uint64_t, (XDR *, uint64_t *));
|
||||
extern bool_t _EXFUN (xdr_u_int64_t, (XDR *, u_int64_t *));
|
||||
#endif /* ___int64_t_defined */
|
||||
extern bool_t _EXFUN (xdr_bool, (XDR *, bool_t *));
|
||||
extern bool_t _EXFUN (xdr_enum, (XDR *, enum_t *));
|
||||
extern bool_t _EXFUN (xdr_array, (XDR *, char **, u_int *, u_int, u_int, xdrproc_t));
|
||||
extern bool_t _EXFUN (xdr_bytes, (XDR *, char **, u_int *, u_int));
|
||||
extern bool_t _EXFUN (xdr_opaque, (XDR *, char *, u_int));
|
||||
extern bool_t _EXFUN (xdr_string, (XDR *, char **, u_int));
|
||||
extern bool_t _EXFUN (xdr_union, (XDR *, enum_t *, char *,
|
||||
_CONST struct xdr_discrim *, xdrproc_t));
|
||||
extern bool_t _EXFUN (xdr_char, (XDR *, char *));
|
||||
extern bool_t _EXFUN (xdr_u_char, (XDR *, u_char *));
|
||||
extern bool_t _EXFUN (xdr_vector, (XDR *, char *, u_int, u_int, xdrproc_t));
|
||||
extern bool_t _EXFUN (xdr_float, (XDR *, float *));
|
||||
extern bool_t _EXFUN (xdr_double, (XDR *, double *));
|
||||
/* extern bool_t _EXFUN (xdr_quadruple, (XDR *, long double *)); */
|
||||
extern bool_t _EXFUN (xdr_reference, (XDR *, char **, u_int, xdrproc_t));
|
||||
extern bool_t _EXFUN (xdr_pointer, (XDR *, char **, u_int, xdrproc_t));
|
||||
extern bool_t _EXFUN (xdr_wrapstring, (XDR *, char **));
|
||||
#if defined(___int64_t_defined)
|
||||
extern bool_t _EXFUN (xdr_hyper, (XDR *, quad_t *));
|
||||
extern bool_t _EXFUN (xdr_u_hyper, (XDR *, u_quad_t *));
|
||||
extern bool_t _EXFUN (xdr_longlong_t, (XDR *, quad_t *));
|
||||
extern bool_t _EXFUN (xdr_u_longlong_t, (XDR *, u_quad_t *));
|
||||
#endif /* ___int64_t_defined */
|
||||
extern u_long _EXFUN (xdr_sizeof, (xdrproc_t, void *));
|
||||
|
||||
/*
|
||||
* Common opaque bytes objects used by many rpc protocols;
|
||||
* declared here due to commonality.
|
||||
*/
|
||||
#define MAX_NETOBJ_SZ 1024
|
||||
struct netobj
|
||||
{
|
||||
u_int n_len;
|
||||
char *n_bytes;
|
||||
};
|
||||
typedef struct netobj netobj;
|
||||
extern bool_t _EXFUN (xdr_netobj, (XDR *, struct netobj *));
|
||||
|
||||
/*
|
||||
* These are the public routines for the various implementations of
|
||||
* xdr streams.
|
||||
*/
|
||||
|
||||
/* XDR using memory buffers */
|
||||
extern void _EXFUN (xdrmem_create, (XDR *, char *, u_int, enum xdr_op));
|
||||
|
||||
/* XDR using stdio library */
|
||||
#if defined(_STDIO_H_)
|
||||
extern void _EXFUN (xdrstdio_create, (XDR *, FILE *, enum xdr_op));
|
||||
#endif
|
||||
|
||||
/* XDR pseudo records for tcp */
|
||||
extern void _EXFUN (xdrrec_create, (XDR *, u_int, u_int, void *,
|
||||
int _EXPARM (, (void *, void *, int)),
|
||||
int _EXPARM (, (void *, void *, int))));
|
||||
|
||||
/* make end of xdr record */
|
||||
extern bool_t _EXFUN (xdrrec_endofrecord, (XDR *, bool_t));
|
||||
|
||||
/* move to beginning of next record */
|
||||
extern bool_t _EXFUN (xdrrec_skiprecord, (XDR *));
|
||||
|
||||
/* true if no more input */
|
||||
extern bool_t _EXFUN (xdrrec_eof, (XDR *));
|
||||
extern u_int _EXFUN (xdrrec_readbytes, (XDR *, caddr_t, u_int));
|
||||
|
||||
/* free memory buffers for xdr */
|
||||
extern void _EXFUN (xdr_free, (xdrproc_t, void *));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_RPC_XDR_H */
|
|
@ -144,6 +144,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -133,6 +133,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -170,6 +170,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -167,6 +167,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -151,6 +151,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -132,6 +132,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -263,6 +263,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -147,6 +147,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -232,6 +232,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -199,6 +199,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -149,6 +149,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -145,6 +145,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -152,6 +152,8 @@ LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
|||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
## Process this file with automake to generate Makefile.in
|
||||
|
||||
AUTOMAKE_OPTIONS = cygnus
|
||||
|
||||
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
||||
|
||||
GENERAL_SOURCES = \
|
||||
xdr_private.c \
|
||||
xdr.c \
|
||||
xdr_float.c \
|
||||
xdr_array.c \
|
||||
xdr_mem.c \
|
||||
xdr_rec.c \
|
||||
xdr_reference.c \
|
||||
xdr_sizeof.c
|
||||
|
||||
STDIO_SOURCES = \
|
||||
xdr_stdio.c
|
||||
|
||||
EXTRA_SOURCES = \
|
||||
xdr_float_vax.c
|
||||
|
||||
## None of these functions are specified by EL/IX
|
||||
if ELIX_LEVEL_1
|
||||
ELIX_SOURCES =
|
||||
else
|
||||
if ELIX_LEVEL_2
|
||||
ELIX_SOURCES =
|
||||
else
|
||||
if ELIX_LEVEL_3
|
||||
ELIX_SOURCES =
|
||||
else
|
||||
if ELIX_LEVEL_4
|
||||
ELIX_SOURCES =
|
||||
else
|
||||
if HAVE_STDIO_DIR
|
||||
ELIX_SOURCES = $(GENERAL_SOURCES) $(STDIO_SOURCES)
|
||||
else
|
||||
ELIX_SOURCES = $(GENERAL_SOURCES)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
EXTRA_DIST = README $(EXTRA_SOURCES)
|
||||
|
||||
libxdr_la_LDFLAGS = -Xcompiler -nostdlib
|
||||
|
||||
if USE_LIBTOOL
|
||||
noinst_LTLIBRARIES = libxdr.la
|
||||
libxdr_la_SOURCES = dummy.c $(ELIX_SOURCES)
|
||||
noinst_DATA = objectlist.awk.in
|
||||
else
|
||||
noinst_LIBRARIES = lib.a
|
||||
lib_a_SOURCES = dummy.c $(ELIX_SOURCES)
|
||||
lib_a_CFLAGS = $(AM_CFLAGS)
|
||||
noinst_DATA =
|
||||
endif # USE_LIBTOOL
|
||||
|
||||
SUFFIXES = .def
|
||||
|
||||
CHEWOUT_FILES =
|
||||
|
||||
CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
|
||||
|
||||
.c.def:
|
||||
$(CHEW) < $< > $*.def 2> $*.ref
|
||||
touch stmp-def
|
||||
|
||||
TARGETDOC = ../tmp.texi
|
||||
|
||||
doc: $(CHEWOUT_FILES)
|
||||
|
||||
CLEANFILES = $(CHEWOUT_FILES) *.ref
|
||||
|
||||
include $(srcdir)/../../Makefile.shared
|
|
@ -0,0 +1,582 @@
|
|||
# Makefile.in generated by automake 1.11.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
DIST_COMMON = $(srcdir)/../../Makefile.shared $(srcdir)/Makefile.in \
|
||||
$(srcdir)/Makefile.am
|
||||
subdir = xdr
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
|
||||
$(top_srcdir)/../../ltoptions.m4 \
|
||||
$(top_srcdir)/../../ltsugar.m4 \
|
||||
$(top_srcdir)/../../ltversion.m4 \
|
||||
$(top_srcdir)/../../lt~obsolete.m4 \
|
||||
$(top_srcdir)/../acinclude.m4 $(top_srcdir)/configure.in
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
LIBRARIES = $(noinst_LIBRARIES)
|
||||
ARFLAGS = cru
|
||||
lib_a_AR = $(AR) $(ARFLAGS)
|
||||
lib_a_LIBADD =
|
||||
am__objects_1 = lib_a-xdr_private.$(OBJEXT) lib_a-xdr.$(OBJEXT) \
|
||||
lib_a-xdr_float.$(OBJEXT) lib_a-xdr_array.$(OBJEXT) \
|
||||
lib_a-xdr_mem.$(OBJEXT) lib_a-xdr_rec.$(OBJEXT) \
|
||||
lib_a-xdr_reference.$(OBJEXT) lib_a-xdr_sizeof.$(OBJEXT) \
|
||||
lib_a-xdr_stdio.$(OBJEXT)
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@am__objects_2 = $(am__objects_1)
|
||||
@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = lib_a-dummy.$(OBJEXT) \
|
||||
@USE_LIBTOOL_FALSE@ $(am__objects_2)
|
||||
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
libxdr_la_LIBADD =
|
||||
am__objects_3 = xdr_private.lo xdr.lo xdr_float.lo xdr_array.lo \
|
||||
xdr_mem.lo xdr_rec.lo xdr_reference.lo xdr_sizeof.lo \
|
||||
xdr_stdio.lo
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@am__objects_4 = $(am__objects_3)
|
||||
@USE_LIBTOOL_TRUE@am_libxdr_la_OBJECTS = dummy.lo $(am__objects_4)
|
||||
libxdr_la_OBJECTS = $(am_libxdr_la_OBJECTS)
|
||||
libxdr_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(libxdr_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@USE_LIBTOOL_TRUE@am_libxdr_la_rpath =
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp =
|
||||
am__depfiles_maybe =
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
SOURCES = $(lib_a_SOURCES) $(libxdr_la_SOURCES)
|
||||
DATA = $(noinst_DATA)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCAS = @CCAS@
|
||||
CCASFLAGS = @CCASFLAGS@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CRT0 = @CRT0@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBC_EXTRA_DEF = @LIBC_EXTRA_DEF@
|
||||
LIBC_EXTRA_LIB = @LIBC_EXTRA_LIB@
|
||||
LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
|
||||
LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
|
||||
LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
|
||||
LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
|
||||
LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
|
||||
LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
|
||||
LIBC_STDIO_DEF = @LIBC_STDIO_DEF@
|
||||
LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
|
||||
LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
|
||||
LIBC_SYS_LIB = @LIBC_SYS_LIB@
|
||||
LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
|
||||
LIBC_XDR_DEF = @LIBC_XDR_DEF@
|
||||
LIBC_XDR_LIB = @LIBC_XDR_LIB@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NEWLIB_CFLAGS = @NEWLIB_CFLAGS@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
READELF = @READELF@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
aext = @aext@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
extra_dir = @extra_dir@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
libm_machine_dir = @libm_machine_dir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
lpfx = @lpfx@
|
||||
machine_dir = @machine_dir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
newlib_basedir = @newlib_basedir@
|
||||
oext = @oext@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
subdirs = @subdirs@
|
||||
sys_dir = @sys_dir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = cygnus
|
||||
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
||||
GENERAL_SOURCES = \
|
||||
xdr_private.c \
|
||||
xdr.c \
|
||||
xdr_float.c \
|
||||
xdr_array.c \
|
||||
xdr_mem.c \
|
||||
xdr_rec.c \
|
||||
xdr_reference.c \
|
||||
xdr_sizeof.c \
|
||||
xdr_stdio.c
|
||||
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@ELIX_SOURCES = $(GENERAL_SOURCES)
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_TRUE@ELIX_SOURCES =
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ELIX_SOURCES =
|
||||
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ELIX_SOURCES =
|
||||
@ELIX_LEVEL_1_TRUE@ELIX_SOURCES =
|
||||
libxdr_la_LDFLAGS = -Xcompiler -nostdlib
|
||||
@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libxdr.la
|
||||
@USE_LIBTOOL_TRUE@libxdr_la_SOURCES = dummy.c $(ELIX_SOURCES)
|
||||
@USE_LIBTOOL_FALSE@noinst_DATA =
|
||||
@USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in
|
||||
@USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a
|
||||
@USE_LIBTOOL_FALSE@lib_a_SOURCES = dummy.c $(ELIX_SOURCES)
|
||||
@USE_LIBTOOL_FALSE@lib_a_CFLAGS = $(AM_CFLAGS)
|
||||
SUFFIXES = .def
|
||||
CHEWOUT_FILES =
|
||||
CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
|
||||
TARGETDOC = ../tmp.texi
|
||||
CLEANFILES = $(CHEWOUT_FILES) *.ref
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .def .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../../Makefile.shared $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --cygnus xdr/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --cygnus xdr/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
clean-noinstLIBRARIES:
|
||||
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
|
||||
lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES)
|
||||
-rm -f lib.a
|
||||
$(lib_a_AR) lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD)
|
||||
$(RANLIB) lib.a
|
||||
|
||||
clean-noinstLTLIBRARIES:
|
||||
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
|
||||
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" != "$$p" || dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
libxdr.la: $(libxdr_la_OBJECTS) $(libxdr_la_DEPENDENCIES)
|
||||
$(libxdr_la_LINK) $(am_libxdr_la_rpath) $(libxdr_la_OBJECTS) $(libxdr_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
$(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
$(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
lib_a-dummy.o: dummy.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dummy.o `test -f 'dummy.c' || echo '$(srcdir)/'`dummy.c
|
||||
|
||||
lib_a-dummy.obj: dummy.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dummy.obj `if test -f 'dummy.c'; then $(CYGPATH_W) 'dummy.c'; else $(CYGPATH_W) '$(srcdir)/dummy.c'; fi`
|
||||
|
||||
lib_a-xdr_private.o: xdr_private.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_private.o `test -f 'xdr_private.c' || echo '$(srcdir)/'`xdr_private.c
|
||||
|
||||
lib_a-xdr_private.obj: xdr_private.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_private.obj `if test -f 'xdr_private.c'; then $(CYGPATH_W) 'xdr_private.c'; else $(CYGPATH_W) '$(srcdir)/xdr_private.c'; fi`
|
||||
|
||||
lib_a-xdr.o: xdr.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr.o `test -f 'xdr.c' || echo '$(srcdir)/'`xdr.c
|
||||
|
||||
lib_a-xdr.obj: xdr.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr.obj `if test -f 'xdr.c'; then $(CYGPATH_W) 'xdr.c'; else $(CYGPATH_W) '$(srcdir)/xdr.c'; fi`
|
||||
|
||||
lib_a-xdr_float.o: xdr_float.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_float.o `test -f 'xdr_float.c' || echo '$(srcdir)/'`xdr_float.c
|
||||
|
||||
lib_a-xdr_float.obj: xdr_float.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_float.obj `if test -f 'xdr_float.c'; then $(CYGPATH_W) 'xdr_float.c'; else $(CYGPATH_W) '$(srcdir)/xdr_float.c'; fi`
|
||||
|
||||
lib_a-xdr_array.o: xdr_array.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_array.o `test -f 'xdr_array.c' || echo '$(srcdir)/'`xdr_array.c
|
||||
|
||||
lib_a-xdr_array.obj: xdr_array.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_array.obj `if test -f 'xdr_array.c'; then $(CYGPATH_W) 'xdr_array.c'; else $(CYGPATH_W) '$(srcdir)/xdr_array.c'; fi`
|
||||
|
||||
lib_a-xdr_mem.o: xdr_mem.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_mem.o `test -f 'xdr_mem.c' || echo '$(srcdir)/'`xdr_mem.c
|
||||
|
||||
lib_a-xdr_mem.obj: xdr_mem.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_mem.obj `if test -f 'xdr_mem.c'; then $(CYGPATH_W) 'xdr_mem.c'; else $(CYGPATH_W) '$(srcdir)/xdr_mem.c'; fi`
|
||||
|
||||
lib_a-xdr_rec.o: xdr_rec.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_rec.o `test -f 'xdr_rec.c' || echo '$(srcdir)/'`xdr_rec.c
|
||||
|
||||
lib_a-xdr_rec.obj: xdr_rec.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_rec.obj `if test -f 'xdr_rec.c'; then $(CYGPATH_W) 'xdr_rec.c'; else $(CYGPATH_W) '$(srcdir)/xdr_rec.c'; fi`
|
||||
|
||||
lib_a-xdr_reference.o: xdr_reference.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_reference.o `test -f 'xdr_reference.c' || echo '$(srcdir)/'`xdr_reference.c
|
||||
|
||||
lib_a-xdr_reference.obj: xdr_reference.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_reference.obj `if test -f 'xdr_reference.c'; then $(CYGPATH_W) 'xdr_reference.c'; else $(CYGPATH_W) '$(srcdir)/xdr_reference.c'; fi`
|
||||
|
||||
lib_a-xdr_sizeof.o: xdr_sizeof.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_sizeof.o `test -f 'xdr_sizeof.c' || echo '$(srcdir)/'`xdr_sizeof.c
|
||||
|
||||
lib_a-xdr_sizeof.obj: xdr_sizeof.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_sizeof.obj `if test -f 'xdr_sizeof.c'; then $(CYGPATH_W) 'xdr_sizeof.c'; else $(CYGPATH_W) '$(srcdir)/xdr_sizeof.c'; fi`
|
||||
|
||||
lib_a-xdr_stdio.o: xdr_stdio.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_stdio.o `test -f 'xdr_stdio.c' || echo '$(srcdir)/'`xdr_stdio.c
|
||||
|
||||
lib_a-xdr_stdio.obj: xdr_stdio.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-xdr_stdio.obj `if test -f 'xdr_stdio.c'; then $(CYGPATH_W) 'xdr_stdio.c'; else $(CYGPATH_W) '$(srcdir)/xdr_stdio.c'; fi`
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
check-am:
|
||||
check: check-am
|
||||
all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA)
|
||||
installdirs:
|
||||
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
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
|
||||
clean-noinstLTLIBRARIES mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-noinstLIBRARIES clean-noinstLTLIBRARIES \
|
||||
ctags distclean distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags dvi dvi-am html html-am info \
|
||||
info-am install install-am install-data install-data-am \
|
||||
install-dvi install-dvi-am install-exec install-exec-am \
|
||||
install-html install-html-am install-info install-info-am \
|
||||
install-man install-pdf install-pdf-am install-ps \
|
||||
install-ps-am install-strip installcheck installcheck-am \
|
||||
installdirs maintainer-clean maintainer-clean-generic \
|
||||
mostlyclean mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
|
||||
uninstall-am
|
||||
|
||||
|
||||
.c.def:
|
||||
$(CHEW) < $< > $*.def 2> $*.ref
|
||||
touch stmp-def
|
||||
|
||||
doc: $(CHEWOUT_FILES)
|
||||
objectlist.awk.in: $(noinst_LTLIBRARIES)
|
||||
-rm -f objectlist.awk.in
|
||||
for i in `ls *.lo` ; \
|
||||
do \
|
||||
echo $$i `pwd`/$$i >> objectlist.awk.in ; \
|
||||
done
|
||||
|
||||
# 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:
|
|
@ -0,0 +1,192 @@
|
|||
INTRODUCTION
|
||||
======================
|
||||
This directory contains a port of the Sun RPC code (derived
|
||||
from the relicensed -- to 3-clause BSD -- implementation in
|
||||
Fedora 11's libtirpc package version 0.1.10-7). It has been
|
||||
adapted for newlib in the following ways:
|
||||
|
||||
1) xdr_* functions for fixed-width integral types have been
|
||||
added, such as xdr_int32_t() and similar. The implementation
|
||||
of stream-specific x_putlong() and x_getlong() functions
|
||||
has been modified to work properly whenever possible, even
|
||||
if sizeof(long) > 32bits -- and to correctly report failure
|
||||
when that is not possible.
|
||||
2) Use of DEFUN(), EXFUN(), and various other portability
|
||||
macros.
|
||||
3) Uses of 64bit types, such as xdr_hyper, xdr_u_longlong_t,
|
||||
and xdr_int64_t, as well as the xdr-specific typedefs
|
||||
quad_t and u_quad_t, are guarded by ___int64_t_defined.
|
||||
4) Out-of-memory conditions are indicated by returning FALSE
|
||||
and setting errno = ENOMEM, rather than by printing error
|
||||
messages to stderr. (See #8, below).
|
||||
5) Only xdrstdio.c requires stdio support, and it is only
|
||||
compiled if the target supports stdio (see stdio_dir in
|
||||
configure.host)
|
||||
6) Uses a local implementation of ntohl/htonl, rather than
|
||||
one provided elsewhere. No dependency on any networking
|
||||
functions.
|
||||
7) Floating point support refactored. Currently supports
|
||||
IEEE single and double precision, and VAX single and
|
||||
double precision.
|
||||
a) Those platforms which use float to represent double
|
||||
do not provide xdr_double().
|
||||
8) Error reporting can be customized using a private hook.
|
||||
This is described below.
|
||||
|
||||
xdr is compiled and supported only for those platforms which
|
||||
set xdr_dir nonempty in configure.host. At present, the list
|
||||
of platforms which do this is:
|
||||
cygwin
|
||||
|
||||
|
||||
PORTING
|
||||
======================
|
||||
To port XDR to a new newlib target, first enable building it
|
||||
by modifying configure.host. Search for the 'case' statement
|
||||
where various *_dir= variables are set, and look for your
|
||||
target's entry (or add one if not present). Set xdr_dir:
|
||||
|
||||
*-*-myplatform*)
|
||||
xdr_dir=xdr
|
||||
;;
|
||||
|
||||
If your platform does not use IEEE754 standard formats for
|
||||
floating point values (floats, doubles) you may need to add
|
||||
a new xdr_float_*.c implementation, and modify the bottom of
|
||||
xdr_float.c:
|
||||
|
||||
...
|
||||
#elif defined(__vax__)
|
||||
#include "xdr_float_vax.c"
|
||||
+#else defined(__my_platform__)
|
||||
+#include "xdr_float_my_platform.c"
|
||||
#endif
|
||||
|
||||
You may want to customize your platform's startup objects to set
|
||||
the error reporting callback for xdr (not likely, but see ERROR
|
||||
MESSAGES section).
|
||||
|
||||
You may also want to customize the memory allocation semantics
|
||||
employed by the xdr routines. As stated in the xdr.h header:
|
||||
|
||||
XDR_DECODE may allocate space if the pointer [to the location
|
||||
at which the decoded data is to be stored] is NULL. This
|
||||
data can be freed with the XDR_FREE operation.
|
||||
|
||||
The default implementation defines the following macros in
|
||||
rpc/types.h, used throughout xdr/ to deal with memory
|
||||
allocation:
|
||||
|
||||
#ifndef mem_alloc
|
||||
#define mem_alloc(bsize) calloc(1, bsize)
|
||||
#endif
|
||||
#ifndef mem_free
|
||||
#define mem_free(ptr, bsize) free(ptr)
|
||||
#endif
|
||||
|
||||
By arranging that these symbols are #defined to some other
|
||||
memory allocation functions, different memory semantics can be
|
||||
imposed. To disallow memory allocation entirely, use the
|
||||
following:
|
||||
|
||||
-D'mem_alloc(a)'=NULL -D'mem_free(a,b)'='do { ; } while(0)'
|
||||
|
||||
In this case, any operations which would otherwise require
|
||||
memory to be allocated, will instead fail (return FALSE),
|
||||
and set errno=ENOMEM.
|
||||
|
||||
|
||||
ERROR MESSAGES
|
||||
======================
|
||||
This implementation of xdr provides a special hook, so that
|
||||
error messages generated by xdr may be captured by a user-
|
||||
defined facility. For certain error conditions, the internal
|
||||
printf-like function
|
||||
xdr_warnx (fmt, ...)
|
||||
is called. However, that function simply delegates to an
|
||||
internal function pointer to a callback function if set;
|
||||
otherwise, xdr_warnx does nothing.
|
||||
|
||||
By setting this function pointer to a user-defined callback,
|
||||
the user can enable these messages to go to a syslog, stderr,
|
||||
or some other facility. The function should match the
|
||||
following typedef (see xdr_private.h):
|
||||
|
||||
typedef void (* xdr_vprintf_t) (const char *, va_list);
|
||||
|
||||
The desired callback can be registered by calling:
|
||||
|
||||
xdr_vprintf_t xdr_set_vprintf (xdr_vprintf_t fnptr);
|
||||
|
||||
The return value is the "old" function pointer, which may
|
||||
be NULL.
|
||||
|
||||
However, neither the typedef or the registration function
|
||||
are declared in the public headers. Clients wishing to use
|
||||
them must either declare the necessary symbols manually,
|
||||
or #include "xdr_private.h". More on this point, below.
|
||||
|
||||
For instance:
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
typedef void (* xdr_vprintf_t) (const char *, va_list);
|
||||
xdr_vprintf_t xdr_set_vprintf (xdr_vprintf_t fnptr);
|
||||
|
||||
void my_vwarnx (const char * fmt, va_list ap)
|
||||
{
|
||||
(void) fprintf (stderr, fmt, ap);
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
(void) xdr_set_vprintf (&my_vwarnx);
|
||||
...
|
||||
}
|
||||
|
||||
Will cause xdr-generated error messages to go to stderr.
|
||||
|
||||
It is not expected that end-user applications will make use
|
||||
of this facility. Rather, it is expected that IF certain
|
||||
*platforms* desire that these error messages be recorded,
|
||||
rather expecting client apps print error messages as
|
||||
necessary, then those platforms will, in their startup
|
||||
objects or static initialization, direct these messages to
|
||||
a logging facility, strace debug facility, etc.
|
||||
|
||||
Therefore, the platform startup code, if part of newlib, can
|
||||
#include "xdr_private.h", or simply copy the two declarations
|
||||
from that file.
|
||||
|
||||
However, most newlib targets will probably be satisfied with
|
||||
the default (silent) behavior. Note that the original Sun RPC,
|
||||
as well as the glibc implementation, print these error messages
|
||||
to stderr. Cygwin, for greater similarity to glibc, registers
|
||||
an error message handler similar to the example above, within
|
||||
its startup code.
|
||||
|
||||
(*) Client apps should already check for FALSE return values;
|
||||
in this case they would then check errno and act appropriately.
|
||||
|
||||
|
||||
LICENSING AND PEDIGREE
|
||||
======================
|
||||
For years, the Sun RPC code, and the XDR implementation, was in
|
||||
legal license limbo
|
||||
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=181493
|
||||
as its license terms, while open, were of debatable compatibility
|
||||
with the GPL. In February of 2009, that changed:
|
||||
http://blogs.sun.com/webmink/entry/old_code_and_old_licenses
|
||||
http://lwn.net/Articles/319648/
|
||||
|
||||
As documented in the libtirpc rpm.spec file from Fedora 11:
|
||||
* Tue May 19 2009 Tom "spot" Callaway <xxxx@redhat.com> 0.1.10-7
|
||||
- Replace the Sun RPC license with the BSD license, with the
|
||||
explicit permission of Sun Microsystems
|
||||
|
||||
So, in the XDR implementation from Fedora 11's libtirpc package,
|
||||
after the modification above by Tom Callaway, each file carries
|
||||
the 3-clause BSD license, and not the so-called "SunRPC" license.
|
||||
It is from this version that the newlib implementation here was
|
||||
derived, with the modifications described in the introduction,
|
||||
above.
|
||||
|
|
@ -0,0 +1 @@
|
|||
/* empty stub so there's at least one file to put in objectlist.awk.in */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,161 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2009, Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of Sun Microsystems, Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* xdr_array.c, Generic XDR routines impelmentation.
|
||||
*
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*
|
||||
* These are the "non-trivial" xdr primitives used to serialize and de-serialize
|
||||
* arrays. See xdr.h for more info on the interface to xdr.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
||||
#include "xdr_private.h"
|
||||
|
||||
/*
|
||||
* XDR an array of arbitrary elements
|
||||
* *addrp is a pointer to the array, *sizep is the number of elements.
|
||||
* If addrp is NULL (*sizep * elsize) bytes are allocated.
|
||||
* elsize is the size (in bytes) of each element, and elproc is the
|
||||
* xdr procedure to call to handle each element of the array.
|
||||
*/
|
||||
bool_t
|
||||
_DEFUN (xdr_array, (xdrs, addrp, sizep, maxsize, elsize, elproc),
|
||||
XDR * xdrs _AND
|
||||
caddr_t * addrp _AND
|
||||
u_int * sizep _AND
|
||||
u_int maxsize _AND
|
||||
u_int elsize _AND
|
||||
xdrproc_t elproc)
|
||||
{
|
||||
u_int i;
|
||||
caddr_t target = *addrp;
|
||||
u_int c; /* the actual element count */
|
||||
bool_t stat = TRUE;
|
||||
u_int nodesize;
|
||||
|
||||
/* like strings, arrays are really counted arrays */
|
||||
if (!xdr_u_int (xdrs, sizep))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
c = *sizep;
|
||||
if ((c > maxsize || UINT_MAX / elsize < c) && (xdrs->x_op != XDR_FREE))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
nodesize = c * elsize;
|
||||
|
||||
/*
|
||||
* if we are deserializing, we may need to allocate an array.
|
||||
* We also save time by checking for a null array if we are freeing.
|
||||
*/
|
||||
if (target == NULL)
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_DECODE:
|
||||
if (c == 0)
|
||||
return TRUE;
|
||||
*addrp = target = mem_alloc (nodesize);
|
||||
if (target == NULL)
|
||||
{
|
||||
xdr_warnx ("xdr_array: out of memory");
|
||||
errno = ENOMEM;
|
||||
return FALSE;
|
||||
}
|
||||
memset (target, 0, nodesize);
|
||||
break;
|
||||
|
||||
case XDR_FREE:
|
||||
return TRUE;
|
||||
|
||||
case XDR_ENCODE:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* now we xdr each element of array
|
||||
*/
|
||||
for (i = 0; (i < c) && stat; i++)
|
||||
{
|
||||
stat = (*elproc) (xdrs, target);
|
||||
target += elsize;
|
||||
}
|
||||
|
||||
/*
|
||||
* the array may need freeing
|
||||
*/
|
||||
if (xdrs->x_op == XDR_FREE)
|
||||
{
|
||||
mem_free (*addrp, nodesize);
|
||||
*addrp = NULL;
|
||||
}
|
||||
return (stat);
|
||||
}
|
||||
|
||||
/*
|
||||
* xdr_vector():
|
||||
*
|
||||
* XDR a fixed length array. Unlike variable-length arrays,
|
||||
* the storage of fixed length arrays is static and unfreeable.
|
||||
* > basep: base of the array
|
||||
* > size: size of the array
|
||||
* > elemsize: size of each element
|
||||
* > xdr_elem: routine to XDR each element
|
||||
*/
|
||||
bool_t
|
||||
_DEFUN (xdr_vector, (xdrs, basep, nelem, elemsize, xdr_elem),
|
||||
XDR * xdrs _AND
|
||||
char *basep _AND
|
||||
u_int nelem _AND
|
||||
u_int elemsize _AND
|
||||
xdrproc_t xdr_elem)
|
||||
{
|
||||
u_int i;
|
||||
char *elptr;
|
||||
|
||||
elptr = basep;
|
||||
for (i = 0; i < nelem; i++)
|
||||
{
|
||||
if (!(*xdr_elem) (xdrs, elptr))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
elptr += elemsize;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2009, Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of Sun Microsystems, Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* xdr_float.c, Generic XDR routines implementation.
|
||||
*
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*
|
||||
* These are the "floating point" xdr routines used to (de)serialize
|
||||
* most common data items. See xdr.h for more info on the interface to
|
||||
* xdr.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
||||
#include "xdr_private.h"
|
||||
|
||||
/*
|
||||
* NB: Not portable.
|
||||
* This routine works on machines with IEEE754 FP and Vaxen.
|
||||
* Assume that xdr_private.h arranges things so that one of
|
||||
* 1) __IEEE_LITTLE_ENDIAN
|
||||
* 2) __IEEE_BIG_ENDIAN
|
||||
* 3) __vax__
|
||||
* is #defined. Otherwise, expect errors.
|
||||
*/
|
||||
#ifndef XDR_FLOAT_C
|
||||
#define XDR_FLOAT_C
|
||||
#endif
|
||||
|
||||
#if defined(__IEEE_LITTLE_ENDIAN) || defined(__IEEE_BIG_ENDIAN)
|
||||
|
||||
bool_t
|
||||
_DEFUN (xdr_float, (xdrs, fp),
|
||||
XDR * xdrs _AND
|
||||
float *fp)
|
||||
{
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
|
||||
case XDR_ENCODE:
|
||||
return (XDR_PUTINT32 (xdrs, (int32_t *) fp));
|
||||
|
||||
case XDR_DECODE:
|
||||
return (XDR_GETINT32 (xdrs, (int32_t *) fp));
|
||||
|
||||
case XDR_FREE:
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if !defined(_DOUBLE_IS_32BITS)
|
||||
bool_t
|
||||
_DEFUN (xdr_double, (xdrs, dp),
|
||||
XDR * xdrs _AND
|
||||
double *dp)
|
||||
{
|
||||
int32_t *i32p;
|
||||
bool_t rv;
|
||||
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
|
||||
case XDR_ENCODE:
|
||||
i32p = (int32_t *) (void *) dp;
|
||||
#if defined(__IEEE_BIG_ENDIAN)
|
||||
rv = XDR_PUTINT32 (xdrs, i32p);
|
||||
if (!rv)
|
||||
return (rv);
|
||||
rv = XDR_PUTINT32 (xdrs, i32p + 1);
|
||||
#else /* must be __IEEE_LITTLE_ENDIAN */
|
||||
rv = XDR_PUTINT32 (xdrs, i32p + 1);
|
||||
if (!rv)
|
||||
return (rv);
|
||||
rv = XDR_PUTINT32 (xdrs, i32p);
|
||||
#endif /* __IEEE_LITTLE_ENDIAN */
|
||||
return (rv);
|
||||
|
||||
case XDR_DECODE:
|
||||
i32p = (int32_t *) (void *) dp;
|
||||
#if defined(__IEEE_BIG_ENDIAN)
|
||||
rv = XDR_GETINT32 (xdrs, i32p);
|
||||
if (!rv)
|
||||
return (rv);
|
||||
rv = XDR_GETINT32 (xdrs, i32p + 1);
|
||||
#else /* must be __IEEE_LITTLE_ENDIAN */
|
||||
rv = XDR_GETINT32 (xdrs, i32p + 1);
|
||||
if (!rv)
|
||||
return (rv);
|
||||
rv = XDR_GETINT32 (xdrs, i32p);
|
||||
#endif /* __IEEE_LITTLE_ENDIAN */
|
||||
return (rv);
|
||||
|
||||
case XDR_FREE:
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
#endif /* !_DOUBLE_IS_32BITS */
|
||||
|
||||
#elif defined(__vax__)
|
||||
#include "xdr_float_vax.c"
|
||||
#endif
|
||||
|
|
@ -0,0 +1,254 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2009, Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of Sun Microsystems, Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* xdr_float_vax.c, XDR floating point routines for vax.
|
||||
*
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*
|
||||
* These are the "floating point" xdr routines used to (de)serialize
|
||||
* most common data items. See xdr.h for more info on the interface to
|
||||
* xdr.
|
||||
*/
|
||||
#ifndef XDR_FLOAT_C
|
||||
#error "Must be included from xdr_float.c"
|
||||
#endif
|
||||
|
||||
/* What IEEE single precision floating point looks like on a Vax */
|
||||
struct ieee_single
|
||||
{
|
||||
unsigned int mantissa:23;
|
||||
unsigned int exp:8;
|
||||
unsigned int sign:1;
|
||||
};
|
||||
|
||||
/* Vax single precision floating point */
|
||||
struct vax_single
|
||||
{
|
||||
unsigned int mantissa1:7;
|
||||
unsigned int exp:8;
|
||||
unsigned int sign:1;
|
||||
unsigned int mantissa2:16;
|
||||
};
|
||||
|
||||
# define VAX_SNG_BIAS 0x81
|
||||
# define IEEE_SNG_BIAS 0x7f
|
||||
|
||||
/* *INDENT-OFF*
|
||||
*/
|
||||
static struct sgl_limits
|
||||
{
|
||||
struct vax_single s;
|
||||
struct ieee_single ieee;
|
||||
} sgl_limits[2] =
|
||||
{
|
||||
{
|
||||
{0x7f, 0xff, 0x0, 0xffff}, /* Max Vax */
|
||||
{0x0, 0xff, 0x0} /* Max IEEE */
|
||||
},
|
||||
{
|
||||
{0x0, 0x0, 0x0, 0x0}, /* Min Vax */
|
||||
{0x0, 0x0, 0x0} /* Min IEEE */
|
||||
}
|
||||
};
|
||||
/* *INDENT-ON*
|
||||
*/
|
||||
|
||||
bool_t
|
||||
_DEFUN (xdr_float, (xdrs, fp),
|
||||
XDR * xdrs _AND
|
||||
float *fp)
|
||||
{
|
||||
struct ieee_single is;
|
||||
struct vax_single vs, *vsp;
|
||||
struct sgl_limits *lim;
|
||||
int i;
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
|
||||
case XDR_ENCODE:
|
||||
vs = *((struct vax_single *) fp);
|
||||
for (i = 0, lim = sgl_limits;
|
||||
i < sizeof (sgl_limits) / sizeof (struct sgl_limits); i++, lim++)
|
||||
{
|
||||
if ((vs.mantissa2 == lim->s.mantissa2) &&
|
||||
(vs.exp == lim->s.exp) && (vs.mantissa1 == lim->s.mantissa1))
|
||||
{
|
||||
is = lim->ieee;
|
||||
goto shipit;
|
||||
}
|
||||
}
|
||||
is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
|
||||
is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2;
|
||||
shipit:
|
||||
is.sign = vs.sign;
|
||||
return (XDR_PUTINT32 (xdrs, (int32_t *) & is));
|
||||
|
||||
case XDR_DECODE:
|
||||
vsp = (struct vax_single *) fp;
|
||||
if (!XDR_GETINT32 (xdrs, (int32_t *) & is))
|
||||
return FALSE;
|
||||
for (i = 0, lim = sgl_limits;
|
||||
i < sizeof (sgl_limits) / sizeof (struct sgl_limits); i++, lim++)
|
||||
{
|
||||
if ((is.exp == lim->ieee.exp) &&
|
||||
(is.mantissa == lim->ieee.mantissa))
|
||||
{
|
||||
*vsp = lim->s;
|
||||
goto doneit;
|
||||
}
|
||||
}
|
||||
vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
|
||||
vsp->mantissa2 = is.mantissa;
|
||||
vsp->mantissa1 = (is.mantissa >> 16);
|
||||
doneit:
|
||||
vsp->sign = is.sign;
|
||||
return TRUE;
|
||||
|
||||
case XDR_FREE:
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if !defined(_DOUBLE_IS_32BITS)
|
||||
|
||||
/* What IEEE double precision floating point looks like on a Vax */
|
||||
struct ieee_double
|
||||
{
|
||||
unsigned int mantissa1:20;
|
||||
unsigned int exp:11;
|
||||
unsigned int sign:1;
|
||||
unsigned int mantissa2:32;
|
||||
};
|
||||
|
||||
/* Vax double precision floating point */
|
||||
struct vax_double
|
||||
{
|
||||
unsigned int mantissa1:7;
|
||||
unsigned int exp:8;
|
||||
unsigned int sign:1;
|
||||
unsigned int mantissa2:16;
|
||||
unsigned int mantissa3:16;
|
||||
unsigned int mantissa4:16;
|
||||
};
|
||||
|
||||
# define VAX_DBL_BIAS 0x81
|
||||
# define IEEE_DBL_BIAS 0x3ff
|
||||
# define MASK(nbits) ((1 << nbits) - 1)
|
||||
|
||||
/* *INDENT-OFF*
|
||||
*/
|
||||
static struct dbl_limits
|
||||
{
|
||||
struct vax_double d;
|
||||
struct ieee_double ieee;
|
||||
} dbl_limits[2] =
|
||||
{
|
||||
{
|
||||
{0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff}, /* Max Vax */
|
||||
{0x0, 0x7ff, 0x0, 0x0} /* Max IEEE */
|
||||
},
|
||||
{
|
||||
{0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */
|
||||
{0x0, 0x0, 0x0, 0x0} /* Min IEEE */
|
||||
}
|
||||
};
|
||||
/* *INDENT-ON*
|
||||
*/
|
||||
|
||||
bool_t
|
||||
_DEFUN (xdr_double, (xdrs, dp),
|
||||
XDR * xdrs _AND
|
||||
double *dp)
|
||||
{
|
||||
int32_t *lp;
|
||||
struct ieee_double id;
|
||||
struct vax_double vd;
|
||||
struct dbl_limits *lim;
|
||||
int i;
|
||||
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
|
||||
case XDR_ENCODE:
|
||||
vd = *((struct vax_double *) dp);
|
||||
for (i = 0, lim = dbl_limits;
|
||||
i < sizeof (dbl_limits) / sizeof (struct dbl_limits); i++, lim++)
|
||||
{
|
||||
if ((vd.mantissa4 == lim->d.mantissa4) &&
|
||||
(vd.mantissa3 == lim->d.mantissa3) &&
|
||||
(vd.mantissa2 == lim->d.mantissa2) &&
|
||||
(vd.mantissa1 == lim->d.mantissa1) && (vd.exp == lim->d.exp))
|
||||
{
|
||||
id = lim->ieee;
|
||||
goto shipit;
|
||||
}
|
||||
}
|
||||
id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
|
||||
id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3);
|
||||
id.mantissa2 = ((vd.mantissa2 & MASK (3)) << 29) |
|
||||
(vd.mantissa3 << 13) | ((vd.mantissa4 >> 3) & MASK (13));
|
||||
shipit:
|
||||
id.sign = vd.sign;
|
||||
lp = (int32_t *) & id;
|
||||
return (XDR_PUTINT32 (xdrs, lp++) && XDR_PUTINT32 (xdrs, lp));
|
||||
|
||||
case XDR_DECODE:
|
||||
lp = (int32_t *) & id;
|
||||
if (!XDR_GETINT32 (xdrs, lp++) || !XDR_GETINT32 (xdrs, lp))
|
||||
return FALSE;
|
||||
for (i = 0, lim = dbl_limits;
|
||||
i < sizeof (dbl_limits) / sizeof (struct dbl_limits); i++, lim++)
|
||||
{
|
||||
if ((id.mantissa2 == lim->ieee.mantissa2) &&
|
||||
(id.mantissa1 == lim->ieee.mantissa1) &&
|
||||
(id.exp == lim->ieee.exp))
|
||||
{
|
||||
vd = lim->d;
|
||||
goto doneit;
|
||||
}
|
||||
}
|
||||
vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
|
||||
vd.mantissa1 = (id.mantissa1 >> 13);
|
||||
vd.mantissa2 = ((id.mantissa1 & MASK (13)) << 3) | (id.mantissa2 >> 29);
|
||||
vd.mantissa3 = (id.mantissa2 >> 13);
|
||||
vd.mantissa4 = (id.mantissa2 << 3);
|
||||
doneit:
|
||||
vd.sign = id.sign;
|
||||
*dp = *((double *) &vd);
|
||||
return TRUE;
|
||||
|
||||
case XDR_FREE:
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
#endif /* !_DOUBLE_IS_32BITS */
|
||||
|
|
@ -0,0 +1,319 @@
|
|||
/*
|
||||
* Copyright (c) 2009, Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of Sun Microsystems, Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* xdr_mem.h, XDR implementation using memory buffers.
|
||||
*
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*
|
||||
* If you have some data to be interpreted as external data representation
|
||||
* or to be converted to external data representation in a memory buffer,
|
||||
* then this is the package for you.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
||||
#include "xdr_private.h"
|
||||
|
||||
#ifndef ntohl
|
||||
# define ntohl(x) xdr_ntohl(x)
|
||||
#endif
|
||||
#ifndef htonl
|
||||
# define htonl(x) xdr_htonl(x)
|
||||
#endif
|
||||
|
||||
static void _EXFUN (xdrmem_destroy, (XDR *));
|
||||
static bool_t _EXFUN (xdrmem_getlong_aligned, (XDR *, long *));
|
||||
static bool_t _EXFUN (xdrmem_putlong_aligned, (XDR *, _CONST long *));
|
||||
static bool_t _EXFUN (xdrmem_getlong_unaligned, (XDR *, long *));
|
||||
static bool_t _EXFUN (xdrmem_putlong_unaligned, (XDR *, _CONST long *));
|
||||
static bool_t _EXFUN (xdrmem_getbytes, (XDR *, char *, u_int));
|
||||
static bool_t _EXFUN (xdrmem_putbytes, (XDR *, _CONST char *, u_int));
|
||||
/* XXX: w/64-bit pointers, u_int not enough! */
|
||||
static u_int _EXFUN (xdrmem_getpos, (XDR *));
|
||||
static bool_t _EXFUN (xdrmem_setpos, (XDR *, u_int));
|
||||
static int32_t * _EXFUN (xdrmem_inline_aligned, (XDR *, u_int));
|
||||
static int32_t * _EXFUN (xdrmem_inline_unaligned, (XDR *, u_int));
|
||||
static bool_t _EXFUN (xdrmem_getint32_aligned, (XDR *, int32_t *));
|
||||
static bool_t _EXFUN (xdrmem_putint32_aligned, (XDR *, _CONST int32_t *));
|
||||
static bool_t _EXFUN (xdrmem_getint32_unaligned, (XDR *, int32_t *));
|
||||
static bool_t _EXFUN (xdrmem_putint32_unaligned, (XDR *, _CONST int32_t *));
|
||||
|
||||
static _CONST struct xdr_ops xdrmem_ops_aligned = {
|
||||
xdrmem_getlong_aligned,
|
||||
xdrmem_putlong_aligned,
|
||||
xdrmem_getbytes,
|
||||
xdrmem_putbytes,
|
||||
xdrmem_getpos,
|
||||
xdrmem_setpos,
|
||||
xdrmem_inline_aligned,
|
||||
xdrmem_destroy,
|
||||
xdrmem_getint32_aligned,
|
||||
xdrmem_putint32_aligned
|
||||
};
|
||||
|
||||
static _CONST struct xdr_ops xdrmem_ops_unaligned = {
|
||||
xdrmem_getlong_unaligned,
|
||||
xdrmem_putlong_unaligned,
|
||||
xdrmem_getbytes,
|
||||
xdrmem_putbytes,
|
||||
xdrmem_getpos,
|
||||
xdrmem_setpos,
|
||||
xdrmem_inline_unaligned,
|
||||
xdrmem_destroy,
|
||||
xdrmem_getint32_unaligned,
|
||||
xdrmem_putint32_unaligned
|
||||
};
|
||||
|
||||
/*
|
||||
* The procedure xdrmem_create initializes a stream descriptor for a
|
||||
* memory buffer.
|
||||
*/
|
||||
void
|
||||
_DEFUN (xdrmem_create, (xdrs, addr, size, op),
|
||||
XDR * xdrs _AND
|
||||
caddr_t addr _AND
|
||||
u_int size _AND
|
||||
enum xdr_op op)
|
||||
{
|
||||
xdrs->x_op = op;
|
||||
xdrs->x_ops = ((unsigned long)addr & (sizeof (int32_t) - 1))
|
||||
? (struct xdr_ops *)&xdrmem_ops_unaligned
|
||||
: (struct xdr_ops *)&xdrmem_ops_aligned;
|
||||
xdrs->x_private = xdrs->x_base = addr;
|
||||
xdrs->x_handy = size;
|
||||
}
|
||||
|
||||
static void
|
||||
_DEFUN (xdrmem_destroy, (xdrs),
|
||||
XDR * xdrs)
|
||||
{
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrmem_getlong_aligned, (xdrs, lp),
|
||||
XDR * xdrs _AND
|
||||
long *lp)
|
||||
{
|
||||
if (xdrs->x_handy < sizeof (int32_t))
|
||||
return FALSE;
|
||||
xdrs->x_handy -= sizeof (int32_t);
|
||||
*lp = (int32_t) ntohl (*(u_int32_t *) xdrs->x_private);
|
||||
xdrs->x_private = (char *) xdrs->x_private + sizeof (int32_t);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrmem_putlong_aligned, (xdrs, lp),
|
||||
XDR * xdrs _AND
|
||||
_CONST long *lp)
|
||||
{
|
||||
if (xdrs->x_handy < sizeof (int32_t))
|
||||
return FALSE;
|
||||
xdrs->x_handy -= sizeof (int32_t);
|
||||
*(u_int32_t *) xdrs->x_private = htonl ((u_int32_t) * lp);
|
||||
xdrs->x_private = (char *) xdrs->x_private + sizeof (int32_t);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrmem_getlong_unaligned, (xdrs, lp),
|
||||
XDR * xdrs _AND
|
||||
long *lp)
|
||||
{
|
||||
u_int32_t l;
|
||||
|
||||
if (xdrs->x_handy < sizeof (int32_t))
|
||||
return FALSE;
|
||||
xdrs->x_handy -= sizeof (int32_t);
|
||||
memmove (&l, xdrs->x_private, sizeof (int32_t));
|
||||
*lp = ntohl (l);
|
||||
xdrs->x_private = (char *) xdrs->x_private + sizeof (int32_t);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrmem_putlong_unaligned, (xdrs, lp),
|
||||
XDR * xdrs _AND
|
||||
_CONST long *lp)
|
||||
{
|
||||
u_int32_t l;
|
||||
|
||||
if (xdrs->x_handy < sizeof (int32_t))
|
||||
return FALSE;
|
||||
xdrs->x_handy -= sizeof (int32_t);
|
||||
l = htonl ((u_int32_t) * lp);
|
||||
memmove (xdrs->x_private, &l, sizeof (int32_t));
|
||||
xdrs->x_private = (char *) xdrs->x_private + sizeof (int32_t);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrmem_getbytes, (xdrs, addr, len),
|
||||
XDR * xdrs _AND
|
||||
char *addr _AND
|
||||
u_int len)
|
||||
{
|
||||
if (xdrs->x_handy < len)
|
||||
return FALSE;
|
||||
xdrs->x_handy -= len;
|
||||
memmove (addr, xdrs->x_private, len);
|
||||
xdrs->x_private = (char *) xdrs->x_private + len;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrmem_putbytes, (xdrs, addr, len),
|
||||
XDR * xdrs _AND
|
||||
_CONST char *addr _AND
|
||||
u_int len)
|
||||
{
|
||||
if (xdrs->x_handy < len)
|
||||
return FALSE;
|
||||
xdrs->x_handy -= len;
|
||||
memmove (xdrs->x_private, addr, len);
|
||||
xdrs->x_private = (char *) xdrs->x_private + len;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static u_int
|
||||
_DEFUN (xdrmem_getpos, (xdrs),
|
||||
XDR * xdrs)
|
||||
{
|
||||
/* XXX w/64-bit pointers, u_int not enough! */
|
||||
return (u_int) ((u_long) xdrs->x_private - (u_long) xdrs->x_base);
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrmem_setpos, (xdrs, pos),
|
||||
XDR * xdrs _AND
|
||||
u_int pos)
|
||||
{
|
||||
caddr_t newaddr = xdrs->x_base + pos;
|
||||
caddr_t lastaddr = (caddr_t) xdrs->x_private + xdrs->x_handy;
|
||||
size_t handy = lastaddr - newaddr;
|
||||
|
||||
if (newaddr > lastaddr
|
||||
|| newaddr < xdrs->x_base
|
||||
|| handy != (u_int) handy)
|
||||
return FALSE;
|
||||
|
||||
xdrs->x_private = newaddr;
|
||||
xdrs->x_handy = (u_int) handy;
|
||||
/* XXX sizeof(u_int) <? sizeof(ptrdiff_t) */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int32_t *
|
||||
_DEFUN (xdrmem_inline_aligned, (xdrs, len),
|
||||
XDR * xdrs _AND
|
||||
u_int len)
|
||||
{
|
||||
int32_t *buf = 0;
|
||||
|
||||
if (xdrs->x_handy >= len)
|
||||
{
|
||||
xdrs->x_handy -= len;
|
||||
buf = (int32_t *) xdrs->x_private;
|
||||
xdrs->x_private = (char *) xdrs->x_private + len;
|
||||
}
|
||||
return (buf);
|
||||
}
|
||||
|
||||
static int32_t *
|
||||
_DEFUN (xdrmem_inline_unaligned, (xdrs, len),
|
||||
XDR * xdrs _AND
|
||||
u_int len)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrmem_getint32_aligned, (xdrs, ip),
|
||||
XDR *xdrs _AND
|
||||
int32_t *ip)
|
||||
{
|
||||
if (xdrs->x_handy < sizeof(int32_t))
|
||||
return FALSE;
|
||||
xdrs->x_handy -= sizeof(int32_t);
|
||||
*ip = (int32_t) ntohl (*(u_int32_t *) xdrs->x_private);
|
||||
xdrs->x_private = (char *) xdrs->x_private + sizeof (int32_t);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrmem_putint32_aligned, (xdrs, ip),
|
||||
XDR *xdrs _AND
|
||||
_CONST int32_t *ip)
|
||||
{
|
||||
if (xdrs->x_handy < sizeof(int32_t))
|
||||
return FALSE;
|
||||
xdrs->x_handy -= sizeof(int32_t);
|
||||
*(u_int32_t *) xdrs->x_private = htonl ((u_int32_t) * ip);
|
||||
xdrs->x_private = (char *) xdrs->x_private + sizeof (int32_t);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrmem_getint32_unaligned, (xdrs, ip),
|
||||
XDR *xdrs _AND
|
||||
int32_t *ip)
|
||||
{
|
||||
u_int32_t l;
|
||||
|
||||
if (xdrs->x_handy < sizeof(int32_t))
|
||||
return FALSE;
|
||||
xdrs->x_handy -= sizeof(int32_t);
|
||||
memmove (&l, xdrs->x_private, sizeof (int32_t));
|
||||
*ip = (int32_t) ntohl (l);
|
||||
xdrs->x_private = (char *) xdrs->x_private + sizeof (int32_t);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrmem_putint32_unaligned, (xdrs, ip),
|
||||
XDR *xdrs _AND
|
||||
_CONST int32_t *ip)
|
||||
{
|
||||
u_int32_t l;
|
||||
|
||||
if (xdrs->x_handy < sizeof(int32_t))
|
||||
return FALSE;
|
||||
xdrs->x_handy -= sizeof(int32_t);
|
||||
l = htonl ((u_int32_t) * ip);
|
||||
memmove (xdrs->x_private, &l, sizeof (int32_t));
|
||||
xdrs->x_private = (char *) xdrs->x_private + sizeof (int32_t);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/* xdr_private.c - utility functions for porting xdr
|
||||
*
|
||||
* Copyright (c) 2009 Charles S. Wilson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include "xdr_private.h"
|
||||
|
||||
static xdr_vprintf_t xdr_vprintf = NULL;
|
||||
|
||||
xdr_vprintf_t
|
||||
_DEFUN (xdr_set_vprintf, (fnptr),
|
||||
xdr_vprintf_t fnptr)
|
||||
{
|
||||
xdr_vprintf_t tmp = xdr_vprintf;
|
||||
xdr_vprintf = fnptr;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void
|
||||
_DEFUN (xdr_vwarnx, (format, ap),
|
||||
_CONST char *format _AND
|
||||
va_list ap)
|
||||
{
|
||||
if (xdr_vprintf)
|
||||
{
|
||||
(*xdr_vprintf)(format, ap);
|
||||
return;
|
||||
}
|
||||
/* otherwise, do nothing */
|
||||
}
|
||||
|
||||
void
|
||||
_DEFUN (xdr_warnx, (fmt),
|
||||
_CONST char *fmt _DOTS)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
xdr_vwarnx (fmt, ap);
|
||||
va_end (ap);
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/* xdr_private.h - declarations of utility functions for porting xdr
|
||||
*
|
||||
* Copyright (c) 2009 Charles S. Wilson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef _XDR_PRIVATE_H
|
||||
#define _XDR_PRIVATE_H
|
||||
|
||||
#include <_ansi.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
/* avoid including stdio header here */
|
||||
#ifndef __VALIST
|
||||
#ifdef __GNUC__
|
||||
#define __VALIST __gnuc_va_list
|
||||
#else
|
||||
#define __VALIST char*
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void _EXFNPTR (xdr_vprintf_t, (const char *, va_list));
|
||||
|
||||
xdr_vprintf_t _EXFUN (xdr_set_vprintf, (xdr_vprintf_t));
|
||||
|
||||
void _EXFUN (xdr_vwarnx, (const char *, __VALIST)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 1, 0))));
|
||||
|
||||
void _EXFUN (xdr_warnx, (const char *, ...)
|
||||
_ATTRIBUTE ((__format__ (__printf__, 1, 2))));
|
||||
|
||||
/* endian issues */
|
||||
#include <machine/endian.h>
|
||||
|
||||
/* byteswap and ntohl stuff; platform may provide optimzed version
|
||||
* of this, but we don't have access to that here.*/
|
||||
_ELIDABLE_INLINE uint32_t xdr_ntohl (uint32_t x)
|
||||
{
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
return x;
|
||||
#elif BYTE_ORDER == LITTLE_ENDIAN
|
||||
u_char *s = (u_char *)&x;
|
||||
return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
|
||||
#else
|
||||
# error Unsupported endian type
|
||||
#endif
|
||||
}
|
||||
#define xdr_htonl(x) xdr_ntohl(x)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _XDR_PRIVATE_H */
|
||||
|
|
@ -0,0 +1,926 @@
|
|||
|
||||
/*
|
||||
* Copyright (c) 2009, Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of Sun Microsystems, Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* xdr_rec.c, Implements TCP/IP based XDR streams with a "record marking"
|
||||
* layer above tcp (for rpc's use).
|
||||
*
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*
|
||||
* These routines interface XDRSTREAMS to a tcp/ip connection.
|
||||
* There is a record marking layer between the xdr stream
|
||||
* and the tcp transport level. A record is composed on one or more
|
||||
* record fragments. A record fragment is a thirty-two bit header followed
|
||||
* by n bytes of data, where n is contained in the header. The header
|
||||
* is represented as a htonl(u_long). Thegh order bit encodes
|
||||
* whether or not the fragment is the last fragment of the record
|
||||
* (1 => fragment is last, 0 => more fragments to follow.
|
||||
* The other 31 bits encode the byte length of the fragment.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
||||
#include "xdr_private.h"
|
||||
|
||||
#ifndef ntohl
|
||||
# define ntohl(x) xdr_ntohl(x)
|
||||
#endif
|
||||
#ifndef htonl
|
||||
# define htonl(x) xdr_htonl(x)
|
||||
#endif
|
||||
|
||||
enum xprt_stat
|
||||
{
|
||||
XPRT_DIED,
|
||||
XPRT_MOREREQS,
|
||||
XPRT_IDLE
|
||||
};
|
||||
|
||||
static bool_t _EXFUN (xdrrec_getlong, (XDR *, long *));
|
||||
static bool_t _EXFUN (xdrrec_putlong, (XDR *, _CONST long *));
|
||||
static bool_t _EXFUN (xdrrec_getbytes, (XDR *, char *, u_int));
|
||||
static bool_t _EXFUN (xdrrec_putbytes, (XDR *, _CONST char *, u_int));
|
||||
static u_int _EXFUN (xdrrec_getpos, (XDR *));
|
||||
static bool_t _EXFUN (xdrrec_setpos, (XDR *, u_int));
|
||||
static int32_t * _EXFUN (xdrrec_inline, (XDR *, u_int));
|
||||
static void _EXFUN (xdrrec_destroy, (XDR *));
|
||||
static bool_t _EXFUN (xdrrec_getint32, (XDR *, int32_t *));
|
||||
static bool_t _EXFUN (xdrrec_putint32, (XDR *, _CONST int32_t *));
|
||||
|
||||
static _CONST struct xdr_ops xdrrec_ops = {
|
||||
xdrrec_getlong,
|
||||
xdrrec_putlong,
|
||||
xdrrec_getbytes,
|
||||
xdrrec_putbytes,
|
||||
xdrrec_getpos,
|
||||
xdrrec_setpos,
|
||||
xdrrec_inline,
|
||||
xdrrec_destroy,
|
||||
xdrrec_getint32,
|
||||
xdrrec_putint32
|
||||
};
|
||||
|
||||
/*
|
||||
* A record is composed of one or more record fragments.
|
||||
* A record fragment is a four-byte header followed by zero to
|
||||
* 2**32-1 bytes. The header is treated as a long unsigned and is
|
||||
* encode/decoded to the network via htonl/ntohl. The low order 31 bits
|
||||
* are a byte count of the fragment. The highest order bit is a boolean:
|
||||
* 1 => this fragment is the last fragment of the record,
|
||||
* 0 => this fragment is followed by more fragment(s).
|
||||
*
|
||||
* The fragment/record machinery is not general; it is constructed to
|
||||
* meet the needs of xdr and rpc based on tcp.
|
||||
*/
|
||||
|
||||
#define LAST_FRAG ((u_int32_t)(UINT32_C(1) << 31))
|
||||
|
||||
typedef struct rec_strm
|
||||
{
|
||||
caddr_t tcp_handle;
|
||||
/*
|
||||
* out-goung bits
|
||||
*/
|
||||
caddr_t out_buffer; /* buffer as allocated; may not be aligned */
|
||||
int (*writeit) (void *, void *, int);
|
||||
caddr_t out_base; /* output buffer (points to frag header) */
|
||||
caddr_t out_finger; /* next output position */
|
||||
caddr_t out_boundry; /* data cannot up to this address */
|
||||
u_int32_t *frag_header; /* beginning of curren fragment */
|
||||
bool_t frag_sent; /* true if buffer sent in middle of record */
|
||||
/*
|
||||
* in-coming bits
|
||||
*/
|
||||
caddr_t in_buffer; /* buffer as allocated; may not be aligned */
|
||||
int (*readit) (void *, void *, int);
|
||||
u_long in_size; /* fixed size of the input buffer */
|
||||
caddr_t in_base;
|
||||
caddr_t in_finger; /* location of next byte to be had */
|
||||
caddr_t in_boundry; /* can read up to this location */
|
||||
long fbtbc; /* fragment bytes to be consumed */
|
||||
bool_t last_frag;
|
||||
u_int sendsize; /* must be <= INT_MAX */
|
||||
u_int recvsize; /* must be <= INT_MAX */
|
||||
|
||||
bool_t nonblock;
|
||||
bool_t in_haveheader;
|
||||
u_int32_t in_header;
|
||||
char *in_hdrp;
|
||||
int in_hdrlen;
|
||||
int in_reclen;
|
||||
int in_received;
|
||||
int in_maxrec;
|
||||
} RECSTREAM;
|
||||
|
||||
static u_int fix_buf_size (u_int);
|
||||
static bool_t flush_out (RECSTREAM *, bool_t);
|
||||
static bool_t fill_input_buf (RECSTREAM *);
|
||||
static bool_t get_input_bytes (RECSTREAM *, char *, size_t);
|
||||
static bool_t set_input_fragment (RECSTREAM *);
|
||||
static bool_t skip_input_bytes (RECSTREAM *, long);
|
||||
static bool_t realloc_stream (RECSTREAM *, int);
|
||||
|
||||
bool_t _EXFUN (__xdrrec_getrec, (XDR *, enum xprt_stat *, bool_t));
|
||||
bool_t _EXFUN (__xdrrec_setnonblock, (XDR *, int));
|
||||
|
||||
/*
|
||||
* Create an xdr handle for xdrrec
|
||||
* xdrrec_create fills in xdrs. Sendsize and recvsize are
|
||||
* send and recv buffer sizes (0 => use default), and must be <= INT_MAX.
|
||||
* tcp_handle is an opaque handle that is passed as the first parameter to
|
||||
* the procedures readit and writeit. Readit and writeit are read and
|
||||
* write respectively. They are like the system
|
||||
* calls except that they take an opaque handle rather than an fd.
|
||||
*/
|
||||
void
|
||||
_DEFUN (xdrrec_create, (xdrs, sendsize, recvsize, tcp_handle, readit, writeit),
|
||||
XDR * xdrs _AND
|
||||
u_int sendsize _AND
|
||||
u_int recvsize _AND
|
||||
void *tcp_handle _AND
|
||||
int _EXPARM (readit, (void *, void *, int)) _AND
|
||||
int _EXPARM (writeit, (void *, void *, int)))
|
||||
{
|
||||
RECSTREAM *rstrm;
|
||||
/* Although sendsize and recvsize are u_int, we require
|
||||
* that they be less than INT_MAX, because often we need
|
||||
* to compare against values held in (signed) integers.
|
||||
* Please don't try to use send/recv buffers > 2GB...
|
||||
*/
|
||||
assert (sendsize < (u_int)INT_MAX);
|
||||
assert (recvsize < (u_int)INT_MAX);
|
||||
|
||||
rstrm = (RECSTREAM *) mem_alloc (sizeof (RECSTREAM));
|
||||
if (rstrm == NULL)
|
||||
{
|
||||
xdr_warnx ("xdrrec_create: out of memory");
|
||||
/*
|
||||
* This is bad. Should rework xdrrec_create to
|
||||
* return a handle, and in this case return NULL
|
||||
*/
|
||||
errno = ENOMEM;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* allocate send buffer; insure BYTES_PER_UNIT alignment */
|
||||
rstrm->sendsize = sendsize = fix_buf_size (sendsize);
|
||||
rstrm->out_buffer = mem_alloc (rstrm->sendsize + BYTES_PER_XDR_UNIT);
|
||||
if (rstrm->out_buffer == NULL)
|
||||
{
|
||||
xdr_warnx ("xdrrec_create: out of memory");
|
||||
mem_free (rstrm, sizeof (RECSTREAM));
|
||||
errno = ENOMEM;
|
||||
return;
|
||||
}
|
||||
for (rstrm->out_base = rstrm->out_buffer;
|
||||
(long) rstrm->out_base % BYTES_PER_XDR_UNIT != 0; rstrm->out_base++)
|
||||
;
|
||||
|
||||
/* allocate recv buffer; insure BYTES_PER_UNIT alignment */
|
||||
rstrm->recvsize = recvsize = fix_buf_size (recvsize);
|
||||
rstrm->in_buffer = mem_alloc (recvsize + BYTES_PER_XDR_UNIT);
|
||||
if (rstrm->in_buffer == NULL)
|
||||
{
|
||||
xdr_warnx ("xdrrec_create: out of memory");
|
||||
mem_free (rstrm->out_buffer, sendsize + BYTES_PER_XDR_UNIT);
|
||||
mem_free (rstrm, sizeof (RECSTREAM));
|
||||
errno = ENOMEM;
|
||||
return;
|
||||
}
|
||||
for (rstrm->in_base = rstrm->in_buffer;
|
||||
(long) rstrm->in_base % BYTES_PER_XDR_UNIT != 0; rstrm->in_base++)
|
||||
;
|
||||
|
||||
/*
|
||||
* now the rest ...
|
||||
*/
|
||||
xdrs->x_ops = &xdrrec_ops;
|
||||
xdrs->x_private = rstrm;
|
||||
rstrm->tcp_handle = tcp_handle;
|
||||
rstrm->readit = readit;
|
||||
rstrm->writeit = writeit;
|
||||
rstrm->out_finger = rstrm->out_boundry = rstrm->out_base;
|
||||
rstrm->frag_header = (u_int32_t *) (void *) rstrm->out_base;
|
||||
rstrm->out_finger += sizeof (u_int32_t);
|
||||
rstrm->out_boundry += sendsize;
|
||||
rstrm->frag_sent = FALSE;
|
||||
rstrm->in_size = recvsize;
|
||||
rstrm->in_boundry = rstrm->in_base;
|
||||
rstrm->in_finger = (rstrm->in_boundry += recvsize);
|
||||
rstrm->fbtbc = 0;
|
||||
rstrm->last_frag = TRUE;
|
||||
rstrm->in_haveheader = FALSE;
|
||||
rstrm->in_hdrlen = 0;
|
||||
rstrm->in_hdrp = (char *) (void *) &rstrm->in_header;
|
||||
rstrm->nonblock = FALSE;
|
||||
rstrm->in_reclen = 0;
|
||||
rstrm->in_received = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The reoutines defined below are the xdr ops which will go into the
|
||||
* xdr handle filled in by xdrrec_create.
|
||||
*/
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrrec_getlong, (xdrs, lp),
|
||||
XDR * xdrs _AND
|
||||
long *lp)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
|
||||
int32_t *buflp = (int32_t *) (void *) (rstrm->in_finger);
|
||||
int32_t mylong;
|
||||
|
||||
/* first try the inline, fast case */
|
||||
if ((rstrm->fbtbc >= sizeof (int32_t)) &&
|
||||
(((long) rstrm->in_boundry - (long) buflp) >= sizeof (int32_t)))
|
||||
{
|
||||
*lp = (long) ntohl ((u_int32_t) (*buflp));
|
||||
rstrm->fbtbc -= sizeof (int32_t);
|
||||
rstrm->in_finger += sizeof (int32_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!xdrrec_getbytes (xdrs, (char *) (void *) &mylong,
|
||||
sizeof (int32_t)))
|
||||
return FALSE;
|
||||
*lp = (long) ntohl ((u_int32_t) mylong);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrrec_putlong, (xdrs, lp),
|
||||
XDR * xdrs _AND
|
||||
_CONST long *lp)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
|
||||
int32_t *dest_lp = ((int32_t *) (void *) (rstrm->out_finger));
|
||||
|
||||
if ((rstrm->out_finger += sizeof (int32_t)) > rstrm->out_boundry)
|
||||
{
|
||||
/*
|
||||
* this case should almost never happen so the code is
|
||||
* inefficient
|
||||
*/
|
||||
rstrm->out_finger -= sizeof (int32_t);
|
||||
rstrm->frag_sent = TRUE;
|
||||
if (!flush_out (rstrm, FALSE))
|
||||
return FALSE;
|
||||
dest_lp = ((int32_t *) (void *) (rstrm->out_finger));
|
||||
rstrm->out_finger += sizeof (int32_t);
|
||||
}
|
||||
*dest_lp = (int32_t) htonl ((u_int32_t) (*lp));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t /* must manage buffers, fragments, and records */
|
||||
_DEFUN (xdrrec_getbytes, (xdrs, addr, len),
|
||||
XDR * xdrs _AND
|
||||
char *addr _AND
|
||||
u_int len)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
|
||||
size_t current;
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
current = (int) rstrm->fbtbc;
|
||||
if (current == 0)
|
||||
{
|
||||
if (rstrm->last_frag)
|
||||
return FALSE;
|
||||
if (!set_input_fragment (rstrm))
|
||||
return FALSE;
|
||||
continue;
|
||||
}
|
||||
current = (len < current) ? len : current;
|
||||
if (!get_input_bytes (rstrm, addr, current))
|
||||
return FALSE;
|
||||
addr += current;
|
||||
rstrm->fbtbc -= current;
|
||||
len -= current;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrrec_putbytes, (xdrs, addr, len),
|
||||
XDR * xdrs _AND
|
||||
_CONST char *addr _AND
|
||||
u_int len)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
|
||||
size_t current;
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
current = (size_t) ((u_long) rstrm->out_boundry -
|
||||
(u_long) rstrm->out_finger);
|
||||
current = (len < current) ? len : current;
|
||||
memmove (rstrm->out_finger, addr, current);
|
||||
rstrm->out_finger += current;
|
||||
addr += current;
|
||||
len -= current;
|
||||
if (rstrm->out_finger == rstrm->out_boundry)
|
||||
{
|
||||
rstrm->frag_sent = TRUE;
|
||||
if (!flush_out (rstrm, FALSE))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static u_int
|
||||
_DEFUN (xdrrec_getpos, (xdrs),
|
||||
XDR * xdrs)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
off_t pos;
|
||||
|
||||
pos = lseek ((int) (u_long) rstrm->tcp_handle, (off_t) 0, 1);
|
||||
if (pos != -1)
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
|
||||
case XDR_ENCODE:
|
||||
pos += rstrm->out_finger - rstrm->out_base;
|
||||
break;
|
||||
|
||||
case XDR_DECODE:
|
||||
pos -= rstrm->in_boundry - rstrm->in_finger;
|
||||
break;
|
||||
|
||||
default:
|
||||
pos = (off_t) - 1;
|
||||
break;
|
||||
}
|
||||
return ((u_int) pos);
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrrec_setpos, (xdrs, pos),
|
||||
XDR * xdrs _AND
|
||||
u_int pos)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
u_int currpos = xdrrec_getpos (xdrs);
|
||||
int delta = currpos - pos;
|
||||
char *newpos;
|
||||
|
||||
if ((int) currpos != -1)
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
|
||||
case XDR_ENCODE:
|
||||
newpos = rstrm->out_finger - delta;
|
||||
if ((newpos > (char *) (void *) (rstrm->frag_header)) &&
|
||||
(newpos < rstrm->out_boundry))
|
||||
{
|
||||
rstrm->out_finger = newpos;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case XDR_DECODE:
|
||||
newpos = rstrm->in_finger - delta;
|
||||
if ((delta < (int) (rstrm->fbtbc)) &&
|
||||
(newpos <= rstrm->in_boundry) && (newpos >= rstrm->in_base))
|
||||
{
|
||||
rstrm->in_finger = newpos;
|
||||
rstrm->fbtbc -= delta;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case XDR_FREE:
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int32_t *
|
||||
_DEFUN (xdrrec_inline, (xdrs, len),
|
||||
XDR * xdrs _AND
|
||||
u_int len)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
int32_t *buf = NULL;
|
||||
/* len represents the number of bytes to extract
|
||||
* from the buffer. The number of bytes remaining
|
||||
* in the buffer is rstrm->fbtbc, which is a long.
|
||||
* Thus, the buffer size maximum is 2GB (!), and
|
||||
* we require that no one ever try to read more
|
||||
* than than number of bytes at once.
|
||||
*/
|
||||
assert (len < (u_int)LONG_MAX);
|
||||
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
|
||||
case XDR_ENCODE:
|
||||
if ((rstrm->out_finger + len) <= rstrm->out_boundry)
|
||||
{
|
||||
buf = (int32_t *) (void *) rstrm->out_finger;
|
||||
rstrm->out_finger += len;
|
||||
}
|
||||
break;
|
||||
|
||||
case XDR_DECODE:
|
||||
if (((long)len <= rstrm->fbtbc) &&
|
||||
((rstrm->in_finger + len) <= rstrm->in_boundry))
|
||||
{
|
||||
buf = (int32_t *) (void *) rstrm->in_finger;
|
||||
rstrm->fbtbc -= len;
|
||||
rstrm->in_finger += len;
|
||||
}
|
||||
break;
|
||||
|
||||
case XDR_FREE:
|
||||
break;
|
||||
}
|
||||
return (buf);
|
||||
}
|
||||
|
||||
static void
|
||||
_DEFUN (xdrrec_destroy, (xdrs),
|
||||
XDR * xdrs)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
|
||||
|
||||
mem_free (rstrm->out_buffer, rstrm->sendsize + BYTES_PER_XDR_UNIT);
|
||||
mem_free (rstrm->in_buffer, rstrm->recvsize + BYTES_PER_XDR_UNIT);
|
||||
mem_free (rstrm, sizeof (RECSTREAM));
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrrec_getint32, (xdrs, ip),
|
||||
XDR *xdrs _AND
|
||||
int32_t *ip)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
|
||||
int32_t *bufip = (int32_t *) (void *) (rstrm->in_finger);
|
||||
int32_t mylong;
|
||||
|
||||
/* first try the inline, fast case */
|
||||
if ((rstrm->fbtbc >= sizeof (int32_t)) &&
|
||||
(( rstrm->in_boundry - (char *) bufip) >= sizeof (int32_t)))
|
||||
{
|
||||
*ip = (int32_t) ntohl (*bufip);
|
||||
rstrm->fbtbc -= sizeof (int32_t);
|
||||
rstrm->in_finger += sizeof (int32_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!xdrrec_getbytes (xdrs, (char *) (void *) &mylong,
|
||||
sizeof (int32_t)))
|
||||
return FALSE;
|
||||
*ip = (int32_t) ntohl (mylong);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrrec_putint32, (xdrs, ip),
|
||||
XDR *xdrs _AND
|
||||
_CONST int32_t *ip)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
|
||||
int32_t *dest_ip = ((int32_t *) (void *) (rstrm->out_finger));
|
||||
|
||||
if ((rstrm->out_finger += sizeof (int32_t)) > rstrm->out_boundry)
|
||||
{
|
||||
/*
|
||||
* this case should almost never happen so the code is
|
||||
* inefficient
|
||||
*/
|
||||
rstrm->out_finger -= sizeof (int32_t);
|
||||
rstrm->frag_sent = TRUE;
|
||||
if (!flush_out (rstrm, FALSE))
|
||||
return FALSE;
|
||||
dest_ip = ((int32_t *) (void *) (rstrm->out_finger));
|
||||
rstrm->out_finger += sizeof (int32_t);
|
||||
}
|
||||
*dest_ip = (int32_t) htonl (*ip);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Exported routines to manage xdr records
|
||||
*/
|
||||
|
||||
/*
|
||||
* Before reading (deserializing from the stream, one should always call
|
||||
* this procedure to guarantee proper record alignment.
|
||||
*/
|
||||
bool_t
|
||||
_DEFUN (xdrrec_skiprecord, (xdrs),
|
||||
XDR * xdrs)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
|
||||
enum xprt_stat xstat;
|
||||
|
||||
if (rstrm->nonblock)
|
||||
{
|
||||
if (__xdrrec_getrec (xdrs, &xstat, FALSE))
|
||||
{
|
||||
rstrm->fbtbc = 0;
|
||||
return TRUE;
|
||||
}
|
||||
if (rstrm->in_finger == rstrm->in_boundry && xstat == XPRT_MOREREQS)
|
||||
{
|
||||
rstrm->fbtbc = 0;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while (rstrm->fbtbc > 0 || (!rstrm->last_frag))
|
||||
{
|
||||
if (!skip_input_bytes (rstrm, rstrm->fbtbc))
|
||||
return FALSE;
|
||||
rstrm->fbtbc = 0;
|
||||
if ((!rstrm->last_frag) && (!set_input_fragment (rstrm)))
|
||||
return FALSE;
|
||||
}
|
||||
rstrm->last_frag = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Look ahead function.
|
||||
* Returns TRUE iff there is no more input in the buffer
|
||||
* after consuming the rest of the current record.
|
||||
*/
|
||||
bool_t
|
||||
_DEFUN (xdrrec_eof, (xdrs),
|
||||
XDR * xdrs)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
|
||||
|
||||
while (rstrm->fbtbc > 0 || (!rstrm->last_frag))
|
||||
{
|
||||
if (!skip_input_bytes (rstrm, rstrm->fbtbc))
|
||||
return TRUE;
|
||||
rstrm->fbtbc = 0;
|
||||
if ((!rstrm->last_frag) && (!set_input_fragment (rstrm)))
|
||||
return TRUE;
|
||||
}
|
||||
if (rstrm->in_finger == rstrm->in_boundry)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* The client must tell the package when an end-of-record has occurred.
|
||||
* The second paraemters tells whether the record should be flushed to the
|
||||
* (output) tcp stream. (This let's the package support batched or
|
||||
* pipelined procedure calls.) TRUE => immmediate flush to tcp connection.
|
||||
*/
|
||||
bool_t
|
||||
_DEFUN (xdrrec_endofrecord, (xdrs, sendnow),
|
||||
XDR * xdrs _AND
|
||||
bool_t sendnow)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
|
||||
u_long len; /* fragment length */
|
||||
|
||||
if (sendnow || rstrm->frag_sent ||
|
||||
((u_long) rstrm->out_finger + sizeof (u_int32_t) >=
|
||||
(u_long) rstrm->out_boundry))
|
||||
{
|
||||
rstrm->frag_sent = FALSE;
|
||||
return (flush_out (rstrm, TRUE));
|
||||
}
|
||||
len = (u_long) (rstrm->out_finger) - (u_long) (rstrm->frag_header) -
|
||||
sizeof (u_int32_t);
|
||||
*(rstrm->frag_header) = htonl ((u_int32_t) len | LAST_FRAG);
|
||||
rstrm->frag_header = (u_int32_t *) (void *) rstrm->out_finger;
|
||||
rstrm->out_finger += sizeof (u_int32_t);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill the stream buffer with a record for a non-blocking connection.
|
||||
* Return true if a record is available in the buffer, false if not.
|
||||
*/
|
||||
bool_t
|
||||
_DEFUN (__xdrrec_getrec, (xdrs, statp, expectdata),
|
||||
XDR * xdrs _AND
|
||||
enum xprt_stat * statp _AND
|
||||
bool_t expectdata)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
|
||||
ssize_t n;
|
||||
int fraglen;
|
||||
|
||||
if (!rstrm->in_haveheader)
|
||||
{
|
||||
n = rstrm->readit (rstrm->tcp_handle, rstrm->in_hdrp,
|
||||
(int) sizeof (rstrm->in_header) - rstrm->in_hdrlen);
|
||||
if (n == 0)
|
||||
{
|
||||
*statp = expectdata ? XPRT_DIED : XPRT_IDLE;
|
||||
return FALSE;
|
||||
}
|
||||
if (n < 0)
|
||||
{
|
||||
*statp = XPRT_DIED;
|
||||
return FALSE;
|
||||
}
|
||||
rstrm->in_hdrp += n;
|
||||
rstrm->in_hdrlen += n;
|
||||
if (rstrm->in_hdrlen < sizeof (rstrm->in_header))
|
||||
{
|
||||
*statp = XPRT_MOREREQS;
|
||||
return FALSE;
|
||||
}
|
||||
rstrm->in_header = ntohl (rstrm->in_header);
|
||||
fraglen = (int) (rstrm->in_header & ~LAST_FRAG);
|
||||
if (fraglen == 0 || fraglen > rstrm->in_maxrec ||
|
||||
(rstrm->in_reclen + fraglen) > rstrm->in_maxrec)
|
||||
{
|
||||
*statp = XPRT_DIED;
|
||||
return FALSE;
|
||||
}
|
||||
rstrm->in_reclen += fraglen;
|
||||
if (rstrm->in_reclen > (int)rstrm->recvsize) /* guaranteed recvsize < INT_MAX */
|
||||
realloc_stream (rstrm, rstrm->in_reclen);
|
||||
if (rstrm->in_header & LAST_FRAG)
|
||||
{
|
||||
rstrm->in_header &= ~LAST_FRAG;
|
||||
rstrm->last_frag = TRUE;
|
||||
}
|
||||
/*
|
||||
* We can only reasonably expect to read once from a
|
||||
* non-blocking stream. Reading the fragment header
|
||||
* may have drained the stream.
|
||||
*/
|
||||
expectdata = FALSE;
|
||||
}
|
||||
|
||||
n = rstrm->readit (rstrm->tcp_handle,
|
||||
rstrm->in_base + rstrm->in_received,
|
||||
(rstrm->in_reclen - rstrm->in_received));
|
||||
|
||||
if (n < 0)
|
||||
{
|
||||
*statp = XPRT_DIED;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
*statp = expectdata ? XPRT_DIED : XPRT_IDLE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
rstrm->in_received += n;
|
||||
|
||||
if (rstrm->in_received == rstrm->in_reclen)
|
||||
{
|
||||
rstrm->in_haveheader = FALSE;
|
||||
rstrm->in_hdrp = (char *) (void *) &rstrm->in_header;
|
||||
rstrm->in_hdrlen = 0;
|
||||
if (rstrm->last_frag)
|
||||
{
|
||||
rstrm->fbtbc = rstrm->in_reclen;
|
||||
rstrm->in_boundry = rstrm->in_base + rstrm->in_reclen;
|
||||
rstrm->in_finger = rstrm->in_base;
|
||||
rstrm->in_reclen = rstrm->in_received = 0;
|
||||
*statp = XPRT_MOREREQS;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
*statp = XPRT_MOREREQS;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t
|
||||
_DEFUN (__xdrrec_setnonblock, (xdrs, maxrec),
|
||||
XDR * xdrs _AND
|
||||
int maxrec)
|
||||
{
|
||||
RECSTREAM *rstrm = (RECSTREAM *) (xdrs->x_private);
|
||||
|
||||
rstrm->nonblock = TRUE;
|
||||
if (maxrec == 0)
|
||||
maxrec = rstrm->recvsize;
|
||||
rstrm->in_maxrec = maxrec;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal useful routines
|
||||
*/
|
||||
static bool_t
|
||||
_DEFUN (flush_out, (rstrm, eor),
|
||||
RECSTREAM * rstrm _AND
|
||||
bool_t eor)
|
||||
{
|
||||
u_int32_t eormask = (eor == TRUE) ? LAST_FRAG : 0;
|
||||
u_int32_t len = (u_int32_t) ((u_long) (rstrm->out_finger) -
|
||||
(u_long) (rstrm->frag_header) -
|
||||
sizeof (u_int32_t));
|
||||
|
||||
*(rstrm->frag_header) = htonl (len | eormask);
|
||||
len = (u_int32_t) ((u_long) (rstrm->out_finger) -
|
||||
(u_long) (rstrm->out_base));
|
||||
if ((*(rstrm->writeit)) (rstrm->tcp_handle, rstrm->out_base, (int) len)
|
||||
!= (int) len)
|
||||
return FALSE;
|
||||
rstrm->frag_header = (u_int32_t *) (void *) rstrm->out_base;
|
||||
rstrm->out_finger = (char *) rstrm->out_base + sizeof (u_int32_t);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t /* knows nothing about records! Only about input buffers */
|
||||
_DEFUN (fill_input_buf, (rstrm),
|
||||
RECSTREAM * rstrm)
|
||||
{
|
||||
char *where;
|
||||
u_int32_t i;
|
||||
int len;
|
||||
|
||||
if (rstrm->nonblock)
|
||||
return FALSE;
|
||||
|
||||
where = rstrm->in_base;
|
||||
i = (u_int32_t) ((u_long) rstrm->in_boundry % BYTES_PER_XDR_UNIT);
|
||||
where += i;
|
||||
len = (u_int32_t) (rstrm->in_size - i);
|
||||
if ((len = (*(rstrm->readit)) (rstrm->tcp_handle, where, len)) == -1)
|
||||
return FALSE;
|
||||
rstrm->in_finger = where;
|
||||
where += len;
|
||||
rstrm->in_boundry = where;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t /* knows nothing about records! Only about input buffers */
|
||||
_DEFUN (get_input_bytes, (rstrm, addr, len),
|
||||
RECSTREAM * rstrm _AND
|
||||
char *addr _AND
|
||||
size_t len)
|
||||
{
|
||||
size_t current;
|
||||
|
||||
if (rstrm->nonblock)
|
||||
{
|
||||
if ((rstrm->in_boundry < rstrm->in_finger) || /* <-- should never happen, but avoids... */
|
||||
(len > (size_t) (rstrm->in_boundry - rstrm->in_finger))) /* <-- signed/unsigned comparison */
|
||||
return FALSE;
|
||||
memcpy (addr, rstrm->in_finger, (size_t) len);
|
||||
rstrm->in_finger += len;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
current = (size_t) ((long) rstrm->in_boundry - (long) rstrm->in_finger);
|
||||
if (current == 0)
|
||||
{
|
||||
if (!fill_input_buf (rstrm))
|
||||
return FALSE;
|
||||
continue;
|
||||
}
|
||||
current = (len < current) ? len : current;
|
||||
memmove (addr, rstrm->in_finger, current);
|
||||
rstrm->in_finger += current;
|
||||
addr += current;
|
||||
len -= current;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t /* next two bytes of the input stream are treated as a header */
|
||||
_DEFUN (set_input_fragment, (rstrm),
|
||||
RECSTREAM * rstrm)
|
||||
{
|
||||
u_int32_t header;
|
||||
|
||||
if (rstrm->nonblock)
|
||||
return FALSE;
|
||||
if (!get_input_bytes (rstrm, (char *) (void *) &header, sizeof (header)))
|
||||
return FALSE;
|
||||
header = ntohl (header);
|
||||
rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE;
|
||||
/*
|
||||
* Sanity check. Try not to accept wildly incorrect
|
||||
* record sizes. Unfortunately, the only record size
|
||||
* we can positively identify as being 'wildly incorrect'
|
||||
* is zero. Ridiculously large record sizes may look wrong,
|
||||
* but we don't have any way to be certain that they aren't
|
||||
* what the client actually intended to send us.
|
||||
*/
|
||||
if (header == 0)
|
||||
return FALSE;
|
||||
rstrm->fbtbc = header & (~LAST_FRAG);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t /* consumes input bytes; knows nothing about records! */
|
||||
_DEFUN (skip_input_bytes, (rstrm, cnt),
|
||||
RECSTREAM * rstrm _AND
|
||||
long cnt)
|
||||
{
|
||||
size_t current;
|
||||
|
||||
while (cnt > 0)
|
||||
{
|
||||
current = (size_t) ((long) rstrm->in_boundry - (long) rstrm->in_finger);
|
||||
if (current == 0)
|
||||
{
|
||||
if (!fill_input_buf (rstrm))
|
||||
return FALSE;
|
||||
continue;
|
||||
}
|
||||
/* in this loop (prior to last line), cnt > 0 so size_t cast is safe*/
|
||||
current = (size_t) (((size_t)cnt < current) ? (size_t)cnt : current);
|
||||
rstrm->in_finger += current;
|
||||
cnt -= current;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static u_int
|
||||
_DEFUN (fix_buf_size, (s),
|
||||
u_int s)
|
||||
{
|
||||
|
||||
if (s < 100)
|
||||
s = 4000;
|
||||
return (RNDUP (s));
|
||||
}
|
||||
|
||||
/*
|
||||
* Reallocate the input buffer for a non-block stream.
|
||||
*/
|
||||
static bool_t
|
||||
_DEFUN (realloc_stream, (rstrm, size),
|
||||
RECSTREAM * rstrm _AND
|
||||
int size)
|
||||
{
|
||||
ptrdiff_t diff;
|
||||
char *buf;
|
||||
char *buf_algn;
|
||||
|
||||
if (size > (int)rstrm->recvsize) /* recvsize guaranteed < INT_MAX */
|
||||
{
|
||||
buf = realloc (rstrm->in_buffer, (size_t) (size + BYTES_PER_XDR_UNIT));
|
||||
if (buf == NULL)
|
||||
return FALSE;
|
||||
for (buf_algn = buf;
|
||||
(long) buf_algn % BYTES_PER_XDR_UNIT != 0; buf_algn++)
|
||||
;
|
||||
diff = buf_algn - rstrm->in_base;
|
||||
rstrm->in_finger += diff;
|
||||
rstrm->in_base = buf_algn;
|
||||
rstrm->in_buffer = buf;
|
||||
rstrm->in_boundry = buf_algn + size;
|
||||
rstrm->recvsize = size;
|
||||
rstrm->in_size = size;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* Copyright (c) 2009, Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of Sun Microsystems, Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* xdr_reference.c, Generic XDR routines impelmentation.
|
||||
*
|
||||
* Copyright (C) 1987, Sun Microsystems, Inc.
|
||||
*
|
||||
* These are the "non-trivial" xdr primitives used to serialize and de-serialize
|
||||
* "pointers". See xdr.h for more info on the interface to xdr.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
||||
#include "xdr_private.h"
|
||||
|
||||
#define LASTUNSIGNED ((u_int)0-1)
|
||||
|
||||
/*
|
||||
* XDR an indirect pointer
|
||||
* xdr_reference is for recursively translating a structure that is
|
||||
* referenced by a pointer inside the structure that is currently being
|
||||
* translated. pp references a pointer to storage. If *pp is null
|
||||
* the necessary storage is allocated.
|
||||
* size is the sizeof the referneced structure.
|
||||
* proc is the routine to handle the referenced structure.
|
||||
*/
|
||||
bool_t
|
||||
_DEFUN (xdr_reference, (xdrs, pp, size, proc),
|
||||
XDR * xdrs _AND
|
||||
caddr_t * pp _AND
|
||||
u_int size _AND
|
||||
xdrproc_t proc)
|
||||
{
|
||||
caddr_t loc = *pp;
|
||||
bool_t stat;
|
||||
|
||||
if (loc == NULL)
|
||||
switch (xdrs->x_op)
|
||||
{
|
||||
case XDR_FREE:
|
||||
return TRUE;
|
||||
|
||||
case XDR_DECODE:
|
||||
*pp = loc = (caddr_t) mem_alloc (size);
|
||||
if (loc == NULL)
|
||||
{
|
||||
xdr_warnx ("xdr_reference: out of memory");
|
||||
errno = ENOMEM;
|
||||
return FALSE;
|
||||
}
|
||||
memset (loc, 0, size);
|
||||
break;
|
||||
|
||||
case XDR_ENCODE:
|
||||
break;
|
||||
}
|
||||
|
||||
stat = (*proc) (xdrs, loc, LASTUNSIGNED);
|
||||
|
||||
if (xdrs->x_op == XDR_FREE)
|
||||
{
|
||||
mem_free (loc, size);
|
||||
*pp = NULL;
|
||||
}
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* xdr_pointer():
|
||||
*
|
||||
* XDR a pointer to a possibly recursive data structure. This
|
||||
* differs with xdr_reference in that it can serialize/deserialiaze
|
||||
* trees correctly.
|
||||
*
|
||||
* What's sent is actually a union:
|
||||
*
|
||||
* union object_pointer switch (boolean b) {
|
||||
* case TRUE: object_data data;
|
||||
* case FALSE: void nothing;
|
||||
* }
|
||||
*
|
||||
* > objpp: Pointer to the pointer to the object.
|
||||
* > obj_size: size of the object.
|
||||
* > xdr_obj: routine to XDR an object.
|
||||
*
|
||||
*/
|
||||
bool_t
|
||||
_DEFUN (xdr_pointer, (xdrs, objpp, obj_size, xdr_obj),
|
||||
XDR * xdrs _AND
|
||||
char **objpp _AND
|
||||
u_int obj_size _AND
|
||||
xdrproc_t xdr_obj)
|
||||
{
|
||||
bool_t more_data;
|
||||
|
||||
more_data = (*objpp != NULL);
|
||||
if (!xdr_bool (xdrs, &more_data))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!more_data)
|
||||
{
|
||||
*objpp = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
return (xdr_reference (xdrs, objpp, obj_size, xdr_obj));
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
* Copyright (c) 2009, Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of Sun Microsystems, Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
/*
|
||||
* xdr_sizeof.c
|
||||
*
|
||||
* Copyright 1990 Sun Microsystems, Inc.
|
||||
*
|
||||
* General purpose routine to see how much space something will use
|
||||
* when serialized using XDR.
|
||||
*/
|
||||
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "xdr_private.h"
|
||||
|
||||
/* ARGSUSED */
|
||||
static bool_t
|
||||
_DEFUN (x_putlong, (xdrs, longp),
|
||||
XDR * xdrs _AND
|
||||
_CONST long *longp)
|
||||
{
|
||||
xdrs->x_handy += BYTES_PER_XDR_UNIT;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static bool_t
|
||||
_DEFUN (x_putbytes, (xdrs, bp, len),
|
||||
XDR * xdrs _AND
|
||||
const char *bp _AND
|
||||
u_int len)
|
||||
{
|
||||
xdrs->x_handy += len;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static u_int
|
||||
_DEFUN (x_getpostn, (xdrs),
|
||||
XDR * xdrs)
|
||||
{
|
||||
return xdrs->x_handy;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static bool_t
|
||||
_DEFUN (x_setpostn, (xdrs, pos),
|
||||
XDR * xdrs _AND
|
||||
u_int pos)
|
||||
{
|
||||
/* This is not allowed */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int32_t *
|
||||
_DEFUN (x_inline, (xdrs, len),
|
||||
XDR * xdrs _AND
|
||||
u_int len)
|
||||
{
|
||||
if (len == 0)
|
||||
return NULL;
|
||||
if (xdrs->x_op != XDR_ENCODE)
|
||||
return NULL;
|
||||
if (len < (u_int) (long int) xdrs->x_base)
|
||||
{
|
||||
/* x_private was already allocated */
|
||||
xdrs->x_handy += len;
|
||||
return (int32_t *) xdrs->x_private;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Free the earlier space and allocate new area */
|
||||
if (xdrs->x_private)
|
||||
mem_free (xdrs->x_private, sizeof (xdrs->x_private));
|
||||
if ((xdrs->x_private = (caddr_t) mem_alloc (len)) == NULL)
|
||||
{
|
||||
xdrs->x_base = 0;
|
||||
return NULL;
|
||||
}
|
||||
xdrs->x_base = (caddr_t) (intptr_t) len;
|
||||
xdrs->x_handy += len;
|
||||
return (int32_t *) xdrs->x_private;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_DEFUN_VOID (harmless)
|
||||
{
|
||||
/* Always return FALSE/NULL, as the case may be */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_DEFUN (x_destroy, (xdrs),
|
||||
XDR * xdrs)
|
||||
{
|
||||
xdrs->x_handy = 0;
|
||||
xdrs->x_base = 0;
|
||||
if (xdrs->x_private)
|
||||
{
|
||||
mem_free (xdrs->x_private, sizeof (xdrs->x_private));
|
||||
xdrs->x_private = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (x_putint32, (xdrs, int32p),
|
||||
XDR *xdrs _AND
|
||||
_CONST int32_t *int32p)
|
||||
{
|
||||
xdrs->x_handy += BYTES_PER_XDR_UNIT;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
unsigned long
|
||||
_DEFUN (xdr_sizeof, (func, data),
|
||||
xdrproc_t func _AND
|
||||
_PTR data)
|
||||
{
|
||||
XDR x;
|
||||
struct xdr_ops ops;
|
||||
bool_t stat;
|
||||
/* to stop ANSI-C compiler from complaining */
|
||||
typedef bool_t _EXFNPTR (dummyfunc1, (XDR *, long *));
|
||||
typedef bool_t _EXFNPTR (dummyfunc2, (XDR *, caddr_t, u_int));
|
||||
typedef bool_t _EXFNPTR (dummyfunc3, (XDR *, int32_t *));
|
||||
|
||||
ops.x_putlong = x_putlong;
|
||||
ops.x_putbytes = x_putbytes;
|
||||
ops.x_inline = x_inline;
|
||||
ops.x_getpostn = x_getpostn;
|
||||
ops.x_setpostn = x_setpostn;
|
||||
ops.x_destroy = x_destroy;
|
||||
ops.x_putint32 = x_putint32;
|
||||
|
||||
/* the other harmless ones */
|
||||
ops.x_getlong = (dummyfunc1) harmless;
|
||||
ops.x_getbytes = (dummyfunc2) harmless;
|
||||
ops.x_getint32 = (dummyfunc3) harmless;
|
||||
|
||||
x.x_op = XDR_ENCODE;
|
||||
x.x_ops = &ops;
|
||||
x.x_handy = 0;
|
||||
x.x_private = (caddr_t) NULL;
|
||||
x.x_base = (caddr_t) 0;
|
||||
|
||||
stat = func (&x, data);
|
||||
if (x.x_private)
|
||||
mem_free (x.x_private, sizeof (x.x_private));
|
||||
return (stat == TRUE ? x.x_handy : 0);
|
||||
}
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
/*
|
||||
* Copyright (c) 2009, Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - 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.
|
||||
* - Neither the name of Sun Microsystems, Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* xdr_stdio.c, XDR implementation on standard i/o file.
|
||||
*
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*
|
||||
* This set of routines implements a XDR on a stdio stream.
|
||||
* XDR_ENCODE serializes onto the stream, XDR_DECODE de-serializes
|
||||
* from the stream.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <rpc/types.h>
|
||||
#include <rpc/xdr.h>
|
||||
|
||||
#include "xdr_private.h"
|
||||
|
||||
#ifndef ntohl
|
||||
# define ntohl(x) xdr_ntohl(x)
|
||||
#endif
|
||||
#ifndef htonl
|
||||
# define htonl(x) xdr_htonl(x)
|
||||
#endif
|
||||
|
||||
static void _EXFUN (xdrstdio_destroy, (XDR *));
|
||||
static bool_t _EXFUN (xdrstdio_getlong, (XDR *, long *));
|
||||
static bool_t _EXFUN (xdrstdio_putlong, (XDR *, _CONST long *));
|
||||
static bool_t _EXFUN (xdrstdio_getbytes, (XDR *, char *, u_int));
|
||||
static bool_t _EXFUN (xdrstdio_putbytes, (XDR *, _CONST char *, u_int));
|
||||
static u_int _EXFUN (xdrstdio_getpos, (XDR *));
|
||||
static bool_t _EXFUN (xdrstdio_setpos, (XDR *, u_int));
|
||||
static int32_t * _EXFUN (xdrstdio_inline, (XDR *, u_int));
|
||||
static bool_t _EXFUN (xdrstdio_getint32, (XDR*, int32_t *));
|
||||
static bool_t _EXFUN (xdrstdio_putint32, (XDR*, _CONST int32_t *));
|
||||
|
||||
/*
|
||||
* Ops vector for stdio type XDR
|
||||
*/
|
||||
static _CONST struct xdr_ops xdrstdio_ops = {
|
||||
xdrstdio_getlong, /* deseraialize a long int */
|
||||
xdrstdio_putlong, /* seraialize a long int */
|
||||
xdrstdio_getbytes, /* deserialize counted bytes */
|
||||
xdrstdio_putbytes, /* serialize counted bytes */
|
||||
xdrstdio_getpos, /* get offset in the stream */
|
||||
xdrstdio_setpos, /* set offset in the stream */
|
||||
xdrstdio_inline, /* prime stream for inline macros */
|
||||
xdrstdio_destroy, /* destroy stream */
|
||||
xdrstdio_getint32, /* deseraialize an int */
|
||||
xdrstdio_putint32 /* seraialize an long int */
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize a stdio xdr stream.
|
||||
* Sets the xdr stream handle xdrs for use on the stream file.
|
||||
* Operation flag is set to op.
|
||||
*/
|
||||
void
|
||||
_DEFUN (xdrstdio_create, (xdrs, file, op),
|
||||
XDR * xdrs _AND
|
||||
FILE * file _AND
|
||||
enum xdr_op op)
|
||||
{
|
||||
xdrs->x_op = op;
|
||||
xdrs->x_ops = (struct xdr_ops *) &xdrstdio_ops;
|
||||
xdrs->x_private = (void *) file;
|
||||
xdrs->x_handy = 0;
|
||||
xdrs->x_base = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroy a stdio xdr stream.
|
||||
* Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create.
|
||||
*/
|
||||
static void
|
||||
_DEFUN (xdrstdio_destroy, (xdrs),
|
||||
XDR * xdrs)
|
||||
{
|
||||
(void) fflush ((FILE *) xdrs->x_private);
|
||||
/* XXX: should we close the file ?? */
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrstdio_getlong, (xdrs, lp),
|
||||
XDR * xdrs _AND
|
||||
long *lp)
|
||||
{
|
||||
u_int32_t temp;
|
||||
|
||||
if (fread (&temp, sizeof (int32_t), 1, (FILE *) xdrs->x_private) != 1)
|
||||
return FALSE;
|
||||
*lp = (long) (int32_t) ntohl (temp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrstdio_putlong, (xdrs, lp),
|
||||
XDR * xdrs _AND
|
||||
_CONST long *lp)
|
||||
{
|
||||
u_int32_t temp = htonl ((u_int32_t) * lp);
|
||||
|
||||
if (fwrite (&temp, sizeof (int32_t), 1, (FILE *) xdrs->x_private) != 1)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrstdio_getbytes, (xdrs, addr, len),
|
||||
XDR * xdrs _AND
|
||||
char *addr _AND
|
||||
u_int len)
|
||||
{
|
||||
if ((len != 0) && (fread (addr, (size_t) len, 1,
|
||||
(FILE *) xdrs->x_private) != 1))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrstdio_putbytes, (xdrs, addr, len),
|
||||
XDR * xdrs _AND
|
||||
_CONST char *addr _AND
|
||||
u_int len)
|
||||
{
|
||||
if ((len != 0) && (fwrite (addr, (size_t) len, 1,
|
||||
(FILE *) xdrs->x_private) != 1))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static u_int
|
||||
_DEFUN (xdrstdio_getpos, (xdrs),
|
||||
XDR * xdrs)
|
||||
{
|
||||
return ((u_int) ftell ((FILE *) xdrs->x_private));
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrstdio_setpos, (xdrs, pos),
|
||||
XDR * xdrs _AND
|
||||
u_int pos)
|
||||
{
|
||||
return ((fseek ((FILE *) xdrs->x_private, (long) pos, 0) < 0) ?
|
||||
FALSE : TRUE);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int32_t *
|
||||
_DEFUN (xdrstdio_inline, (xdrs, len),
|
||||
XDR * xdrs _AND
|
||||
u_int len)
|
||||
{
|
||||
/*
|
||||
* Must do some work to implement this: must insure
|
||||
* enough data in the underlying stdio buffer,
|
||||
* that the buffer is aligned so that we can indirect through a
|
||||
* long *, and stuff this pointer in xdrs->x_buf. Doing
|
||||
* a fread or fwrite to a scratch buffer would defeat
|
||||
* most of the gains to be had here and require storage
|
||||
* management on this buffer, so we don't do this.
|
||||
*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrstdio_getint32, (xdrs, ip),
|
||||
XDR *xdrs _AND
|
||||
int32_t *ip)
|
||||
{
|
||||
int32_t temp;
|
||||
|
||||
if (fread (&temp, sizeof (int32_t), 1, (FILE *) xdrs->x_private) != 1)
|
||||
return FALSE;
|
||||
*ip = ntohl (temp);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool_t
|
||||
_DEFUN (xdrstdio_putint32, (xdrs, ip),
|
||||
XDR *xdrs _AND
|
||||
_CONST int32_t *ip)
|
||||
{
|
||||
int32_t temp = htonl (*ip);
|
||||
|
||||
if (fwrite (&temp, sizeof (int32_t), 1, (FILE *) xdrs->x_private) != 1)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue