blob: 06dbce1391cf6800d9d6173ea4b64c943bb8ee90 [file] [log] [blame]
Jeff Thompson8dc775b2013-08-29 17:16:42 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson8dc775b2013-08-29 17:16:42 -07004 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NDN_BLOB_H
8#define NDN_BLOB_H
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14/**
15 * An ndn_Blob holds a pointer to a read-only pre-allocated buffer and its length.
16 */
17struct ndn_Blob {
Jeff Thompson93034532013-10-08 11:52:43 -070018 uint8_t *value; /**< pointer to the pre-allocated buffer for the value. Must be treated as read only. */
19 size_t length; /**< the number of bytes in value. */
Jeff Thompson8dc775b2013-08-29 17:16:42 -070020};
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.
Jeff Thompson93034532013-10-08 11:52:43 -070026 * @param length The number of bytes in value.
Jeff Thompson8dc775b2013-08-29 17:16:42 -070027 */
Jeff Thompson93034532013-10-08 11:52:43 -070028static inline void ndn_Blob_initialize(struct ndn_Blob *self, uint8_t *value, size_t length)
Jeff Thompson8dc775b2013-08-29 17:16:42 -070029{
30 self->value = value;
Jeff Thompson93034532013-10-08 11:52:43 -070031 self->length = length;
Jeff Thompson8dc775b2013-08-29 17:16:42 -070032}
33
34#ifdef __cplusplus
35}
36#endif
37
38#endif