44 lines
901 B
C
44 lines
901 B
C
#ifndef GETCHAR_H
|
|
#define GETCHAR_H
|
|
/* shamlesses stolen from pppd sources */
|
|
|
|
/*
|
|
* Inline versions of get/put char/short/long.
|
|
* Pointer is advanced; we assume that both arguments
|
|
* are lvalues and will already be in registers.
|
|
* cp MUST be u_char *.
|
|
*/
|
|
#define GETCHAR(c, cp) { \
|
|
(c) = *(cp)++; \
|
|
}
|
|
#define PUTCHAR(c, cp) { \
|
|
*(cp)++ = (u_char) (c); \
|
|
}
|
|
|
|
|
|
#define GETSHORT(s, cp) { \
|
|
(s) = *(cp)++ << 8; \
|
|
(s) |= *(cp)++; \
|
|
}
|
|
#define PUTSHORT(s, cp) { \
|
|
*(cp)++ = (u_char) ((s) >> 8); \
|
|
*(cp)++ = (u_char) (s); \
|
|
}
|
|
|
|
#define GETLONG(l, cp) { \
|
|
(l) = *(cp)++ << 8; \
|
|
(l) |= *(cp)++; (l) <<= 8; \
|
|
(l) |= *(cp)++; (l) <<= 8; \
|
|
(l) |= *(cp)++; \
|
|
}
|
|
#define PUTLONG(l, cp) { \
|
|
*(cp)++ = (u_char) ((l) >> 24); \
|
|
*(cp)++ = (u_char) ((l) >> 16); \
|
|
*(cp)++ = (u_char) ((l) >> 8); \
|
|
*(cp)++ = (u_char) (l); \
|
|
}
|
|
|
|
#define INCPTR(n, cp) ((cp) += (n))
|
|
#define DECPTR(n, cp) ((cp) -= (n))
|
|
|
|
#endif
|