Jeff Thompson | f1ba9bd | 2013-08-12 17:43:08 -0700 | [diff] [blame] | 1 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 Regents of the University of California. |
| 3 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | f1ba9bd | 2013-08-12 17:43:08 -0700 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "util/ndn_memory.h" |
| 8 | #include "name.h" |
| 9 | |
| 10 | int 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. |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 17 | size_t i; |
Jeff Thompson | f1ba9bd | 2013-08-12 17:43:08 -0700 | [diff] [blame] | 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 | } |