blob: a2569f992cedc24c744b05cca5c5334e00201599 [file] [log] [blame]
Jeff Thompsonf1ba9bd2013-08-12 17:43:08 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompsonf1ba9bd2013-08-12 17:43:08 -07004 * See COPYING for copyright and distribution information.
5 */
6
7#include "util/ndn_memory.h"
8#include "name.h"
9
10int ndn_Name_match(struct ndn_Name *self, struct ndn_Name *name)
11{
12 // This name is longer than the name we are checking it against.
13 if (self->nComponents > name->nComponents)
14 return 0;
15
16 // Check if at least one of given components doesn't match.
17 unsigned int i;
18 for (i = 0; i < self->nComponents; ++i) {
19 struct ndn_NameComponent *selfComponent = self->components + i;
20 struct ndn_NameComponent *nameComponent = name->components + i;
21
22 if (selfComponent->valueLength != nameComponent->valueLength ||
23 ndn_memcmp(selfComponent->value, nameComponent->value, selfComponent->valueLength) != 0)
24 return 0;
25 }
26
27 return 1;
28}