/*
 * some macros to permit a couple of new features while remaining compatible 
 * and reasonably portable...
 * could tighten up 0 and 3 a little, but I've left them like this for now 
 * for ease of understanding.
 * assumes sizeof(long) == 4, but then, so does the rest of AFS...
 */
#ifndef KAPORT_H
#define KAPORT_H

#define unpack_long(src, dst) { \
dst[0] = ((unsigned char)(((unsigned long)(src) & 0xff000000) >> 24) & 0xff); \
dst[1] = ((unsigned char)(((unsigned long)(src) & 0x00ff0000) >> 16) & 0xff); \
dst[2] = ((unsigned char)(((unsigned long)(src) & 0x0000ff00) >>  8) & 0xff); \
dst[3] = ((unsigned char)(((unsigned long)(src) & 0x000000ff) >>  0) & 0xff); }

#define pack_long(src) ( \
(unsigned long) ( \
		 ((unsigned long) ((src)[0] & 0xff) << 24) | \
		 ((unsigned long) ((src)[1] & 0xff) << 16) | \
		 ((unsigned long) ((src)[2] & 0xff) <<  8) | \
		 ((unsigned long) ((src)[3] & 0xff) <<  0) ) )

#endif /* KAPORT_H */
