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