summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2007-05-10 02:37:22 +0000
committerKen Raeburn <raeburn@mit.edu>2007-05-10 02:37:22 +0000
commit86ef9dd0422b95ccf2b29f18847c47b6b9e2e6c5 (patch)
tree083595efb37a3c68d86276a7cf705b22a9cf51c3 /src/include
parent9ad9a49b388bee85020e9800050df2fcc8954250 (diff)
downloadkrb5-86ef9dd0422b95ccf2b29f18847c47b6b9e2e6c5.tar.gz
krb5-86ef9dd0422b95ccf2b29f18847c47b6b9e2e6c5.tar.xz
krb5-86ef9dd0422b95ccf2b29f18847c47b6b9e2e6c5.zip
Define and use some inline helper functions for comparing data and authdata structures, instead
of open-coding checks of multiple fields everywhere. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19544 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/include')
-rw-r--r--src/include/k5-int.h39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/include/k5-int.h b/src/include/k5-int.h
index 98f106475..93a0b1abb 100644
--- a/src/include/k5-int.h
+++ b/src/include/k5-int.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1989,1990,1991,1992,1993,1994,1995,2000,2001, 2003,2006 by the Massachusetts Institute of Technology,
+ * Copyright (C) 1989,1990,1991,1992,1993,1994,1995,2000,2001, 2003,2006,2007 by the Massachusetts Institute of Technology,
* Cambridge, MA, USA. All Rights Reserved.
*
* This software is being provided to you, the LICENSEE, by the
@@ -2479,4 +2479,41 @@ void KRB5_CALLCONV krb5_realm_iterator_free
void KRB5_CALLCONV krb5_free_realm_string
(krb5_context context, char *str);
+/* Some data comparison and conversion functions. */
+#if 0
+static inline int data_cmp(krb5_data d1, krb5_data d2)
+{
+ if (d1.length < d2.length) return -1;
+ if (d1.length > d2.length) return 1;
+ return memcmp(d1.data, d2.data, d1.length);
+}
+static inline int data_eq (krb5_data d1, krb5_data d2)
+{
+ return data_cmp(d1, d2) == 0;
+}
+#else
+static inline int data_eq (krb5_data d1, krb5_data d2)
+{
+ return (d1.length == d2.length
+ && !memcmp(d1.data, d2.data, d1.length));
+}
+#endif
+static inline krb5_data string2data (char *str)
+{
+ krb5_data d;
+ d.magic = KV5M_DATA;
+ d.length = strlen(str);
+ d.data = str;
+ return d;
+}
+static inline int data_eq_string (krb5_data d, char *s)
+{
+ return data_eq(d, string2data(s));
+}
+static inline int authdata_eq (krb5_authdata a1, krb5_authdata a2)
+{
+ return (a1.ad_type == a2.ad_type
+ && a1.length == a2.length
+ && !memcmp(a1.contents, a2.contents, a1.length));
+}
#endif /* _KRB5_INT_H */