summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJohn Kohl <jtkohl@mit.edu>1990-08-29 11:38:33 +0000
committerJohn Kohl <jtkohl@mit.edu>1990-08-29 11:38:33 +0000
commit9fd0e87072c84f538123a6bb5d7f6ec82fae5eb1 (patch)
tree611e63d5f9997e50d396bad58d07a3cd5c91cbf7 /src/lib
parent23dd4faf1439ff3dcd5a442c0e6c16998429f2f4 (diff)
*** empty log message ***
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1058 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/krb5/krb/addr_order.c55
1 files changed, 55 insertions, 0 deletions
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/copyright.h>.
+ *
+ * krb5_address_order()
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_addr_order_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+#include <krb5/ext-proto.h>
+
+#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;
+}