about summary refs log tree commit diff
path: root/urt/vaxshort.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
commit1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch)
tree64c8c96cf54d8718847339a403e5e67b922e8c3f /urt/vaxshort.c
downloadnetpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'urt/vaxshort.c')
-rw-r--r--urt/vaxshort.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/urt/vaxshort.c b/urt/vaxshort.c
new file mode 100644
index 00000000..4b57b516
--- /dev/null
+++ b/urt/vaxshort.c
@@ -0,0 +1,50 @@
+/*
+ *			V A X S H O R T
+ *
+ *  Code to manipulate 16-bit integers in VAX order in a
+ *  machine independent manner.
+ *
+ *  (VAX is a trademark of Digital Equipment Corporation)
+ *
+ *  Author -
+ *	Michael John Muuss
+ *  
+ *  Source -
+ *	SECAD/VLD Computing Consortium, Bldg 394
+ *	The U. S. Army Ballistic Research Laboratory
+ *	Aberdeen Proving Ground, Maryland  21005-5066
+ *  
+ *  Distribution Status -
+ *	Public Domain, Distribution Unlimitied.
+ */
+
+#include "vaxshort.h"
+
+/*
+ *			V A X _ G S H O R T
+ *
+ *  Obtain a 16-bit signed integer from two adjacent characters,
+ *  stored in VAX order, regardless of word alignment.
+ */
+int
+vax_gshort(char *msgp)
+{
+	register unsigned char *p = (unsigned char *) msgp;
+	register int	i;
+
+	if( (i = (p[1] << 8) | p[0]) & 0x8000 )
+		return(i | ~0xFFFF);	/* Sign extend */
+	return(i);
+}
+
+/*
+ *			V A X _ P S H O R T
+ */
+char *
+vax_pshort(char *msgp, unsigned short s)
+{
+
+	msgp[0] = s & 0xFF;
+	msgp[1] = s >> 8;
+	return(msgp+2);
+}