Added ndn_Exclude_compareComponents.
diff --git a/ndn-cpp/c/interest.c b/ndn-cpp/c/interest.c
new file mode 100644
index 0000000..361412e
--- /dev/null
+++ b/ndn-cpp/c/interest.c
@@ -0,0 +1,18 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "util/ndn_memory.h"
+#include "interest.h"
+
+int ndn_Exclude_compareComponents(struct ndn_NameComponent *component1, struct ndn_NameComponent *component2)
+{
+ if (component1->valueLength < component2->valueLength)
+ return -1;
+ if (component1->valueLength > component2->valueLength)
+ return 1;
+
+ // The components are equal length. Just do a byte compare.
+ return ndn_memcmp(component1->value, component2->value, component1->valueLength);
+}
diff --git a/ndn-cpp/c/interest.h b/ndn-cpp/c/interest.h
index b596c50..bdb28b1 100644
--- a/ndn-cpp/c/interest.h
+++ b/ndn-cpp/c/interest.h
@@ -62,6 +62,15 @@
self->nEntries = 0;
}
+/**
+ * Compare the components using NDN component ordering.
+ * A component is less if it is shorter, otherwise if equal length do a byte comparison.
+ * @param component1 A pointer to the first name component.
+ * @param component2 A pointer to the second name component.
+ * @return -1 if component1 is less than component2, 1 if greater or 0 if equal.
+ */
+int ndn_Exclude_compareComponents(struct ndn_NameComponent *component1, struct ndn_NameComponent *component2);
+
enum {
ndn_Interest_CHILD_SELECTOR_LEFT = 0,
ndn_Interest_CHILD_SELECTOR_RIGHT = 1,