blob: a80e3d588c54d2bf33e30a6c3362df9c809cd02e [file] [log] [blame]
Jeff Thompson5d89cb92013-06-27 15:57:15 -07001/*
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
11extern "C" {
12#endif
13
Jeff Thompsonb0fd64f2013-06-27 16:02:36 -070014struct ndn_NameComponent {
Jeff Thompson08d56292013-06-27 18:20:44 -070015 unsigned char *value; /**< pointer to the component value */
16 unsigned int valueLength; /**< the number of bytes in value */
Jeff Thompson5d89cb92013-06-27 15:57:15 -070017};
18
Jeff Thompsonb0fd64f2013-06-27 16:02:36 -070019static 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 Thompson5d89cb92013-06-27 15:57:15 -070024
25struct ndn_Name {
Jeff Thompson08d56292013-06-27 18:20:44 -070026 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 Thompson5d89cb92013-06-27 15:57:15 -070029};
30
Jeff Thompson08d56292013-06-27 18:20:44 -070031/**
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 */
37static inline void ndn_Name_init(struct ndn_Name *self, struct ndn_NameComponent *components, unsigned int maxComponents)
Jeff Thompsonb0fd64f2013-06-27 16:02:36 -070038{
Jeff Thompson08d56292013-06-27 18:20:44 -070039 self->components = components;
40 self->maxComponents = maxComponents;
Jeff Thompsonb0fd64f2013-06-27 16:02:36 -070041 self->nComponents = 0;
42}
Jeff Thompson5d89cb92013-06-27 15:57:15 -070043
44#ifdef __cplusplus
45}
46#endif
47
Jeff Thompson08d56292013-06-27 18:20:44 -070048#endif
Jeff Thompson5d89cb92013-06-27 15:57:15 -070049