Jeff Thompson | 8dc775b | 2013-08-29 17:16:42 -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 | 8dc775b | 2013-08-29 17:16:42 -0700 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NDN_BLOB_H |
| 8 | #define NDN_BLOB_H |
| 9 | |
| 10 | #ifdef __cplusplus |
| 11 | extern "C" { |
| 12 | #endif |
| 13 | |
| 14 | /** |
| 15 | * An ndn_Blob holds a pointer to a read-only pre-allocated buffer and its length. |
| 16 | */ |
| 17 | struct ndn_Blob { |
| 18 | unsigned char *value; /**< pointer to the pre-allocated buffer for the value. Must be treated as read only. */ |
| 19 | unsigned int valueLength; /**< the number of bytes in value. */ |
| 20 | }; |
| 21 | |
| 22 | /** |
| 23 | * Initialize the ndn_Blob struct with the given value. |
| 24 | * @param self pointer to the ndn_Blob struct. |
| 25 | * @param value The pre-allocated buffer for the value, or 0 for none. |
| 26 | * @param valueLength The number of bytes in value. |
| 27 | */ |
| 28 | static inline void ndn_Blob_initialize(struct ndn_Blob *self, unsigned char *value, unsigned int valueLength) |
| 29 | { |
| 30 | self->value = value; |
| 31 | self->valueLength = valueLength; |
| 32 | } |
| 33 | |
| 34 | #ifdef __cplusplus |
| 35 | } |
| 36 | #endif |
| 37 | |
| 38 | #endif |