Jeff Thompson | 5d89cb9 | 2013-06-27 15:57:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Author: Jeff Thompson |
| 3 | * |
| 4 | * BSD license, See the LICENSE file for more information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NDN_NAME_H |
| 8 | #define NDN_NAME_H |
| 9 | |
| 10 | #ifdef __cplusplus |
| 11 | extern "C" { |
| 12 | #endif |
| 13 | |
Jeff Thompson | b0fd64f | 2013-06-27 16:02:36 -0700 | [diff] [blame] | 14 | struct ndn_NameComponent { |
Jeff Thompson | 08d5629 | 2013-06-27 18:20:44 -0700 | [diff] [blame^] | 15 | unsigned char *value; /**< pointer to the component value */ |
| 16 | unsigned int valueLength; /**< the number of bytes in value */ |
Jeff Thompson | 5d89cb9 | 2013-06-27 15:57:15 -0700 | [diff] [blame] | 17 | }; |
| 18 | |
Jeff Thompson | b0fd64f | 2013-06-27 16:02:36 -0700 | [diff] [blame] | 19 | static inline void ndn_NameComponent_init(struct ndn_NameComponent *self, unsigned char *value, unsigned int valueLength) |
| 20 | { |
| 21 | self->value = value; |
| 22 | self->valueLength = valueLength; |
| 23 | } |
Jeff Thompson | 5d89cb9 | 2013-06-27 15:57:15 -0700 | [diff] [blame] | 24 | |
| 25 | struct ndn_Name { |
Jeff Thompson | 08d5629 | 2013-06-27 18:20:44 -0700 | [diff] [blame^] | 26 | struct ndn_NameComponent *components; /**< pointer to the array of components. */ |
| 27 | unsigned int maxComponents; /**< the number of elements in the allocated components array */ |
| 28 | unsigned int nComponents; /**< the number of components in the name */ |
Jeff Thompson | 5d89cb9 | 2013-06-27 15:57:15 -0700 | [diff] [blame] | 29 | }; |
| 30 | |
Jeff Thompson | 08d5629 | 2013-06-27 18:20:44 -0700 | [diff] [blame^] | 31 | /** |
| 32 | * Initialize an ndn_Name struct with the components array. |
| 33 | * @param self pointer to the ndn_Name struct |
| 34 | * @param components the array of ndn_NameComponent already allocated |
| 35 | * @param maxComponents the number of elements in the allocated components array |
| 36 | */ |
| 37 | static inline void ndn_Name_init(struct ndn_Name *self, struct ndn_NameComponent *components, unsigned int maxComponents) |
Jeff Thompson | b0fd64f | 2013-06-27 16:02:36 -0700 | [diff] [blame] | 38 | { |
Jeff Thompson | 08d5629 | 2013-06-27 18:20:44 -0700 | [diff] [blame^] | 39 | self->components = components; |
| 40 | self->maxComponents = maxComponents; |
Jeff Thompson | b0fd64f | 2013-06-27 16:02:36 -0700 | [diff] [blame] | 41 | self->nComponents = 0; |
| 42 | } |
Jeff Thompson | 5d89cb9 | 2013-06-27 15:57:15 -0700 | [diff] [blame] | 43 | |
| 44 | #ifdef __cplusplus |
| 45 | } |
| 46 | #endif |
| 47 | |
Jeff Thompson | 08d5629 | 2013-06-27 18:20:44 -0700 | [diff] [blame^] | 48 | #endif |
Jeff Thompson | 5d89cb9 | 2013-06-27 15:57:15 -0700 | [diff] [blame] | 49 | |