]> andersk Git - openssh.git/blame - getput.h
- (djm) Merge OpenBSD changes:
[openssh.git] / getput.h
CommitLineData
8efc0c15 1/*
5260325f 2 * Author: Tatu Ylonen <ylo@cs.hut.fi>
5260325f 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved
5260325f 5 * Macros for storing and retrieving data in msb first and lsb first order.
6ae2364d 6 *
bcbf86ec 7 * As far as I am concerned, the code I have written for this software
8 * can be used freely for any purpose. Any derived versions of this
9 * software must be clearly marked as such, and if the derived work is
10 * incompatible with the protocol description in the RFC file, it must be
11 * called by a name other than "ssh" or "Secure Shell".
5260325f 12 */
8efc0c15 13
bcbf86ec 14/* RCSID("$OpenBSD: getput.h,v 1.5 2000/09/07 20:27:51 deraadt Exp $"); */
8efc0c15 15
16#ifndef GETPUT_H
17#define GETPUT_H
18
19/*------------ macros for storing/extracting msb first words -------------*/
20
21#define GET_32BIT(cp) (((unsigned long)(unsigned char)(cp)[0] << 24) | \
6ae2364d 22 ((unsigned long)(unsigned char)(cp)[1] << 16) | \
8efc0c15 23 ((unsigned long)(unsigned char)(cp)[2] << 8) | \
24 ((unsigned long)(unsigned char)(cp)[3]))
25
26#define GET_16BIT(cp) (((unsigned long)(unsigned char)(cp)[0] << 8) | \
27 ((unsigned long)(unsigned char)(cp)[1]))
28
29#define PUT_32BIT(cp, value) do { \
30 (cp)[0] = (value) >> 24; \
31 (cp)[1] = (value) >> 16; \
32 (cp)[2] = (value) >> 8; \
33 (cp)[3] = (value); } while (0)
34
35#define PUT_16BIT(cp, value) do { \
36 (cp)[0] = (value) >> 8; \
37 (cp)[1] = (value); } while (0)
38
39/*------------ macros for storing/extracting lsb first words -------------*/
40
41#define GET_32BIT_LSB_FIRST(cp) \
42 (((unsigned long)(unsigned char)(cp)[0]) | \
43 ((unsigned long)(unsigned char)(cp)[1] << 8) | \
44 ((unsigned long)(unsigned char)(cp)[2] << 16) | \
45 ((unsigned long)(unsigned char)(cp)[3] << 24))
46
47#define GET_16BIT_LSB_FIRST(cp) \
48 (((unsigned long)(unsigned char)(cp)[0]) | \
49 ((unsigned long)(unsigned char)(cp)[1] << 8))
50
51#define PUT_32BIT_LSB_FIRST(cp, value) do { \
52 (cp)[0] = (value); \
53 (cp)[1] = (value) >> 8; \
54 (cp)[2] = (value) >> 16; \
55 (cp)[3] = (value) >> 24; } while (0)
56
57#define PUT_16BIT_LSB_FIRST(cp, value) do { \
58 (cp)[0] = (value); \
59 (cp)[1] = (value) >> 8; } while (0)
60
5260325f 61#endif /* GETPUT_H */
This page took 0.08662 seconds and 5 git commands to generate.