home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / kerberosIV / include / addr_comp.h next >
Encoding:
C/C++ Source or Header  |  1989-01-22  |  1.1 KB  |  40 lines

  1. /*
  2.  * $Source: /mit/kerberos/src/include/RCS/addr_comp.h,v $
  3.  * $Author: jtkohl $
  4.  * $Header: addr_comp.h,v 4.0 89/01/23 09:57:44 jtkohl Exp $
  5.  *
  6.  * Copyright 1987, 1988, 1989 by the Massachusetts Institute of Technology. 
  7.  *
  8.  * For copying and distribution information, please see the file
  9.  * <mit-copyright.h>. 
  10.  *
  11.  * Include file for address comparison macros.
  12.  */
  13.  
  14. #include <mit-copyright.h>
  15.  
  16. #ifndef ADDR_COMP_DEFS
  17. #define ADDR_COMP_DEFS
  18.  
  19. /*
  20. ** Look boys and girls, a big kludge
  21. ** We need to compare the two internet addresses in network byte order, not
  22. **   local byte order.  This is a *really really slow way of doing that*
  23. ** But.....
  24. **         .....it works
  25. ** so we run with it
  26. **
  27. ** long_less_than gets fed two (u_char *)'s....
  28. */
  29.  
  30. #define u_char_comp(x,y) \
  31.         (((x)>(y))?(1):(((x)==(y))?(0):(-1)))
  32.  
  33. #define long_less_than(x,y) \
  34.         (u_char_comp((x)[0],(y)[0])?u_char_comp((x)[0],(y)[0]): \
  35.      (u_char_comp((x)[1],(y)[1])?u_char_comp((x)[1],(y)[1]): \
  36.       (u_char_comp((x)[2],(y)[2])?u_char_comp((x)[2],(y)[2]): \
  37.        (u_char_comp((x)[3],(y)[3])))))
  38.  
  39. #endif /* ADDR_COMP_DEFS */
  40.