From 9fd0e87072c84f538123a6bb5d7f6ec82fae5eb1 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Wed, 29 Aug 1990 11:38:33 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1058 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/addr_order.c | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/lib/krb5/krb/addr_order.c diff --git a/src/lib/krb5/krb/addr_order.c b/src/lib/krb5/krb/addr_order.c new file mode 100644 index 000000000..2060c586b --- /dev/null +++ b/src/lib/krb5/krb/addr_order.c @@ -0,0 +1,55 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * krb5_address_order() + */ + +#if !defined(lint) && !defined(SABER) +static char rcsid_addr_order_c[] = +"$Id$"; +#endif /* !lint & !SABER */ + +#include +#include +#include + +#ifndef min +#define min(a,b) ((a) > (b) ? (a) : (b)) +#endif + +/* + * Return an ordering on two addresses: 0 if the same, + * < 0 if first is less than 2nd, > 0 if first is greater than 2nd. + */ +int +krb5_address_order(addr1, addr2) +const register krb5_address *addr1; +const register krb5_address *addr2; +{ + int dir; + register int i; + const int minlen = min(addr1->length, addr2->length); + + if (addr1->addrtype != addr2->addrtype) + return(FALSE); + + dir = addr1->length - addr2->length; + + + for (i = 0; i < minlen; i++) { + if ((unsigned char) addr1->contents[i] < + (unsigned char) addr2->contents[i]) + return -1; + else if ((unsigned char) addr1->contents[i] > + (unsigned char) addr2->contents[i]) + return 1; + } + /* compared equal so far...which is longer? */ + return dir; +} -- 2.26.2