Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
vaxshort.c
Go to the documentation of this file.
1 /*
2  * V A X S H O R T
3  *
4  * Code to manipulate 16-bit integers in VAX order in a
5  * machine independent manner.
6  *
7  * (VAX is a trademark of Digital Equipment Corporation)
8  *
9  * Author -
10  * Michael John Muuss
11  *
12  * Source -
13  * SECAD/VLD Computing Consortium, Bldg 394
14  * The U. S. Army Ballistic Research Laboratory
15  * Aberdeen Proving Ground, Maryland 21005-5066
16  *
17  * Distribution Status -
18  * Public Domain, Distribution Unlimitied.
19  */
20 #ifndef lint
21 static char RCSid[] = "@(#)$Id: vaxshort.c,v 3.0 90/08/03 15:21:30 spencer Exp $ (BRL)";
22 #endif
23 
24 /*
25  * V A X _ G S H O R T
26  *
27  * Obtain a 16-bit signed integer from two adjacent characters,
28  * stored in VAX order, regardless of word alignment.
29  */
30 int
32 char *msgp;
33 {
34  register unsigned char *p = (unsigned char *) msgp;
35  register int i;
36 
37  if( (i = (p[1] << 8) | p[0]) & 0x8000 )
38  return(i | ~0xFFFF); /* Sign extend */
39  return(i);
40 }
41 
42 /*
43  * V A X _ P S H O R T
44  */
45 char *
47 register char *msgp;
48 register unsigned short s;
49 {
50 
51  msgp[0] = s & 0xFF;
52  msgp[1] = s >> 8;
53  return(msgp+2);
54 }
static char RCSid[]
Definition: vaxshort.c:21
int vax_gshort(char *msgp)
Definition: vaxshort.c:31
char * vax_pshort(char *msgp, unsigned short s)
Definition: vaxshort.c:46