1 | /* |
---|
2 | |
---|
3 | getput.h |
---|
4 | |
---|
5 | Author: Tatu Ylonen <ylo@cs.hut.fi> |
---|
6 | |
---|
7 | Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
---|
8 | All rights reserved |
---|
9 | |
---|
10 | Created: Wed Jun 28 22:36:30 1995 ylo |
---|
11 | |
---|
12 | Macros for storing and retrieving data in msb first and lsb first order. |
---|
13 | |
---|
14 | */ |
---|
15 | |
---|
16 | /* |
---|
17 | * $Id: getput.h,v 1.1.1.2 1999-03-08 17:43:33 danw Exp $ |
---|
18 | * $Log: not supported by cvs2svn $ |
---|
19 | * Revision 1.1.1.1 1996/02/18 21:38:11 ylo |
---|
20 | * Imported ssh-1.2.13. |
---|
21 | * |
---|
22 | * Revision 1.2 1995/07/13 01:24:09 ylo |
---|
23 | * Removed "Last modified" header. |
---|
24 | * Added cvs log. |
---|
25 | * |
---|
26 | * $Endlog$ |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef GETPUT_H |
---|
30 | #define GETPUT_H |
---|
31 | |
---|
32 | /*------------ macros for storing/extracting msb first words -------------*/ |
---|
33 | |
---|
34 | #define GET_32BIT(cp) (((unsigned long)(unsigned char)(cp)[0] << 24) | \ |
---|
35 | ((unsigned long)(unsigned char)(cp)[1] << 16) | \ |
---|
36 | ((unsigned long)(unsigned char)(cp)[2] << 8) | \ |
---|
37 | ((unsigned long)(unsigned char)(cp)[3])) |
---|
38 | |
---|
39 | #define GET_16BIT(cp) (((unsigned long)(unsigned char)(cp)[0] << 8) | \ |
---|
40 | ((unsigned long)(unsigned char)(cp)[1])) |
---|
41 | |
---|
42 | #define PUT_32BIT(cp, value) do { \ |
---|
43 | (cp)[0] = (value) >> 24; \ |
---|
44 | (cp)[1] = (value) >> 16; \ |
---|
45 | (cp)[2] = (value) >> 8; \ |
---|
46 | (cp)[3] = (value); } while (0) |
---|
47 | |
---|
48 | #define PUT_16BIT(cp, value) do { \ |
---|
49 | (cp)[0] = (value) >> 8; \ |
---|
50 | (cp)[1] = (value); } while (0) |
---|
51 | |
---|
52 | /*------------ macros for storing/extracting lsb first words -------------*/ |
---|
53 | |
---|
54 | #define GET_32BIT_LSB_FIRST(cp) \ |
---|
55 | (((unsigned long)(unsigned char)(cp)[0]) | \ |
---|
56 | ((unsigned long)(unsigned char)(cp)[1] << 8) | \ |
---|
57 | ((unsigned long)(unsigned char)(cp)[2] << 16) | \ |
---|
58 | ((unsigned long)(unsigned char)(cp)[3] << 24)) |
---|
59 | |
---|
60 | #define GET_16BIT_LSB_FIRST(cp) \ |
---|
61 | (((unsigned long)(unsigned char)(cp)[0]) | \ |
---|
62 | ((unsigned long)(unsigned char)(cp)[1] << 8)) |
---|
63 | |
---|
64 | #define PUT_32BIT_LSB_FIRST(cp, value) do { \ |
---|
65 | (cp)[0] = (value); \ |
---|
66 | (cp)[1] = (value) >> 8; \ |
---|
67 | (cp)[2] = (value) >> 16; \ |
---|
68 | (cp)[3] = (value) >> 24; } while (0) |
---|
69 | |
---|
70 | #define PUT_16BIT_LSB_FIRST(cp, value) do { \ |
---|
71 | (cp)[0] = (value); \ |
---|
72 | (cp)[1] = (value) >> 8; } while (0) |
---|
73 | |
---|
74 | #endif /* GETPUT_H */ |
---|
75 | |
---|