2 * $Source: /afs/andrew/system/cvs/src/sasl/mac/kerberos_includes/lsb_addr_comp.h,v $
4 * $Header: /afs/andrew/system/cvs/src/sasl/mac/kerberos_includes/lsb_addr_comp.h,v 1.2 2001/12/04 02:06:05 rjs3 Exp $
6 * Copyright 1988 by the Massachusetts Institute of Technology.
8 * For copying and distribution information, please see the file
11 * Comparison macros to emulate LSBFIRST comparison results of network
12 * byte-order quantities
15 #ifndef _KERBEROS_LSB_ADDR_COMP_H
16 #define _KERBEROS_LSB_ADDR_COMP_H
18 #pragma ident "@(#)lsb_addr_comp.h 1.4 93/02/04 SMI"
20 #include <kerberos/mit-copyright.h>
21 #include <kerberos/osconf.h>
28 #define lsb_net_ulong_less(x, y) ((x < y) ? -1 : ((x > y) ? 1 : 0))
29 #define lsb_net_ushort_less(x, y) ((x < y) ? -1 : ((x > y) ? 1 : 0))
32 #define u_char_comp(x, y) \
33 (((x) > (y)) ? (1) : (((x) == (y)) ? (0) : (-1)))
34 /* This is gross, but... */
35 #define lsb_net_ulong_less(x, y) long_less_than((u_char *)&x, (u_char *)&y)
36 #define lsb_net_ushort_less(x, y) short_less_than((u_char *)&x, (u_char *)&y)
38 #define long_less_than(x, y) \
39 (u_char_comp((x)[3], (y)[3]) ? u_char_comp((x)[3], (y)[3]) : \
40 (u_char_comp((x)[2], (y)[2]) ? u_char_comp((x)[2], (y)[2]) : \
41 (u_char_comp((x)[1], (y)[1]) ? u_char_comp((x)[1], (y)[1]) : \
42 (u_char_comp((x)[0], (y)[0])))))
43 #define short_less_than(x, y) \
44 (u_char_comp((x)[1], (y)[1]) ? u_char_comp((x)[1], (y)[1]) : \
45 (u_char_comp((x)[0], (y)[0])))
53 #endif /* _KERBEROS_LSB_ADDR_COMP_H */