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 }
43 
51 static __inline ndn_Error
52 ndn_KeyLocator_setFromKeyLocator
53  (struct ndn_KeyLocator *self, const struct ndn_KeyLocator *other)
54 {
55  ndn_Error error;
56 
57  if (other == self)
58  // Setting to itself. Do nothing.
59  return NDN_ERROR_success;
60 
61  self->type = other->type;
62  ndn_Blob_setFromBlob(&self->keyData, &other->keyData);
63  if ((error = ndn_Name_setFromName(&self->keyName, &other->keyName)))
64  return error;
65 
66  return NDN_ERROR_success;
67 }
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #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:40
ndn_KeyLocatorType type
-1 for none
Definition: key-types.h:39
An ndn_KeyLocator holds the type of key locator and related data.
Definition: key-types.h:38
Copyright (C) 2015-2016 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:43