key-locator.h
1 
21 #ifndef NDN_KEY_LOCATOR_H
22 #define NDN_KEY_LOCATOR_H
23 
24 #include <ndn-cpp/c/key-types.h>
25 #include "name.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
37 static __inline void ndn_KeyLocator_initialize
38  (struct ndn_KeyLocator *self, struct ndn_NameComponent *keyNameComponents, size_t maxKeyNameComponents) {
39  self->type = (ndn_KeyLocatorType)-1;
40  ndn_Blob_initialize(&self->keyData, 0, 0);
41  ndn_Name_initialize(&self->keyName, keyNameComponents, maxKeyNameComponents);
42  self->keyNameType = (ndn_KeyNameType)-1;
43 }
44 
52 static __inline ndn_Error
53 ndn_KeyLocator_setFromKeyLocator
54  (struct ndn_KeyLocator *self, const struct ndn_KeyLocator *other)
55 {
56  ndn_Error error;
57 
58  if (other == self)
59  // Setting to itself. Do nothing.
60  return NDN_ERROR_success;
61 
62  self->type = other->type;
63  ndn_Blob_setFromBlob(&self->keyData, &other->keyData);
64  if ((error = ndn_Name_setFromName(&self->keyName, &other->keyName)))
65  return error;
66  self->keyNameType = other->keyNameType;
67 
68  return NDN_ERROR_success;
69 }
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif
struct ndn_Blob keyData
A Blob whose value is a pointer to a pre-allocated buffer for the key data as follows: If type is ndn...
Definition: key-types.h:53
ndn_KeyLocatorType type
-1 for none
Definition: key-types.h:52
ndn_KeyNameType keyNameType
The type of data for keyName, -1 for none.
Definition: key-types.h:64
An ndn_KeyLocator holds the type of key locator and related data.
Definition: key-types.h:51
Copyright (C) 2015 Regents of the University of California.
Definition: name-types.h:33
struct ndn_Name keyName
The key name (only used if type is ndn_KeyLocatorType_KEYNAME.)
Definition: key-types.h:62