From 946798634a2cf31b08fcc674cf10f44a1d6338d3 Mon Sep 17 00:00:00 2001 From: bdc Date: Tue, 31 Oct 1995 21:52:04 +0000 Subject: [PATCH] *** empty log message *** --- Makefile.in | 3 ++- configure.in | 2 +- scsh/endian.scm | 36 ++++++++++++++++++++++++++++++++++++ scsh/network.scm | 37 ------------------------------------- 4 files changed, 39 insertions(+), 39 deletions(-) create mode 100644 scsh/endian.scm diff --git a/Makefile.in b/Makefile.in index f2ec48d..ba7e48e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -311,7 +311,7 @@ clean: clean-scsh distclean: clean $(RM) Makefile sysdep.h config.status config.log config.cache \ - scsh/machine scsh/regexp/Makefile scsh/network.scm + scsh/machine scsh/regexp/Makefile scsh/endian.scm man: $(MANPAGE) @@ -537,6 +537,7 @@ scsh: cig scsh/scsh scsh/scsh.image SCHEME =scsh/awk.scm \ scsh/char-set.scm \ scsh/defrec.scm \ + scsh/endian.scm \ scsh/enumconst.scm \ scsh/fdports.scm \ scsh/fileinfo.scm \ diff --git a/configure.in b/configure.in index a4c357a..7eb61aa 100644 --- a/configure.in +++ b/configure.in @@ -325,4 +325,4 @@ AC_SUBST(ENDIAN) AC_SUBST(LDFLAGS) AC_SUBST(LDFLAGS_AIX) -AC_OUTPUT(Makefile scsh/regexp/Makefile scsh/network.scm) +AC_OUTPUT(Makefile scsh/regexp/Makefile scsh/endian.scm) diff --git a/scsh/endian.scm b/scsh/endian.scm new file mode 100644 index 0000000..9394439 --- /dev/null +++ b/scsh/endian.scm @@ -0,0 +1,36 @@ +;;; Endian routines for the Scheme Shell +;;; Copyright (c) 1995 by Brian D. Carlstrom. + +;; Big Endian - Motorola, Sparc, HPPA, etc +(define (net-to-host-32-big num32) + (and (<= 0 num32 #xffffffff) + num32)) + +(define (net-to-host-16-big num16) + (and (<= 0 num16 #xffffffff) + num16)) + +;; Little Endian - Intel, Vax, Alpha +(define (net-to-host-32-little num32) + (and (<= 0 num32 #xffffffff) + (let* ((num24 (arithmetic-shift num32 -8)) + (num16 (arithmetic-shift num24 -8)) + (num08 (arithmetic-shift num16 -8)) + (byte0 (bitwise-and #b11111111 num08)) + (byte1 (bitwise-and #b11111111 num16)) + (byte2 (bitwise-and #b11111111 num24)) + (byte3 (bitwise-and #b11111111 num32))) + (+ (arithmetic-shift byte3 24) + +(define (net-to-host-16-little num16) + (and (<= 0 num16 #xffffffff) + (let* ((num08 (arithmetic-shift num16 -8)) + (byte0 (bitwise-and #b11111111 num08)) + (byte1 (bitwise-and #b11111111 num16)) + (+ (arithmetic-shift byte1 8) + byte0)))) + +(define net-to-host-32 net-to-host-32-@ENDIAN@) +(define net-to-host-16 net-to-host-16-@ENDIAN@) +(define host-to-net-32 host-to-net-32-@ENDIAN@) +(define host-to-net-16 host-to-net-16-@ENDIAN@) diff --git a/scsh/network.scm b/scsh/network.scm index 64e9222..3af8b85 100644 --- a/scsh/network.scm +++ b/scsh/network.scm @@ -935,43 +935,6 @@ (C char**) ; alias list integer) ; protocol number -;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -;;; Endian Conversion routines -;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -;; Big Endian - Motorola, Sparc, HPPA, etc -(define (net-to-host-32-big num32) - (and (<= 0 num32 #xffffffff) - num32)) - -(define (net-to-host-16-big num16) - (and (<= 0 num16 #xffffffff) - num16)) - -;; Little Endian - Intel, Vax, Alpha -(define (net-to-host-32-little num32) - (and (<= 0 num32 #xffffffff) - (let* ((num24 (arithmetic-shift num32 -8)) - (num16 (arithmetic-shift num24 -8)) - (num08 (arithmetic-shift num16 -8)) - (byte0 (bitwise-and #b11111111 num08)) - (byte1 (bitwise-and #b11111111 num16)) - (byte2 (bitwise-and #b11111111 num24)) - (byte3 (bitwise-and #b11111111 num32))) - (+ (arithmetic-shift byte3 24) - -(define (net-to-host-16-little num16) - (and (<= 0 num16 #xffffffff) - (let* ((num08 (arithmetic-shift num16 -8)) - (byte0 (bitwise-and #b11111111 num08)) - (byte1 (bitwise-and #b11111111 num16)) - (+ (arithmetic-shift byte1 8) - byte0)))) - -(define net-to-host-32 net-to-host-32-@ENDIAN@) -(define net-to-host-16 net-to-host-16-@ENDIAN@) -(define host-to-net-32 host-to-net-32-@ENDIAN@) -(define host-to-net-16 host-to-net-16-@ENDIAN@) - ;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ;;; Lowlevel junk ;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-