25 #include <ndn-cpp/c/data-types.h>
27 #include "key-locator.h"
39 static __inline
void ndn_Signature_initialize(
struct ndn_Signature *
self,
struct ndn_NameComponent *keyNameComponents,
size_t maxKeyNameComponents) {
40 self->type = (ndn_SignatureType)-1;
41 ndn_Blob_initialize(&self->signature, 0, 0);
42 ndn_KeyLocator_initialize(&self->keyLocator, keyNameComponents, maxKeyNameComponents);
50 static __inline
void ndn_Signature_clear(
struct ndn_Signature *
self)
52 ndn_Signature_initialize
53 (
self, self->keyLocator.keyName.components,
54 self->keyLocator.keyName.maxComponents);
64 static __inline ndn_Error
65 ndn_Signature_setFromSignature
72 return NDN_ERROR_success;
74 ndn_Blob_setFromBlob(&self->signature, &other->signature);
75 if ((error = ndn_KeyLocator_setFromKeyLocator
76 (&self->keyLocator, &other->keyLocator)))
79 return NDN_ERROR_success;
86 static __inline
void ndn_MetaInfo_initialize(
struct ndn_MetaInfo *
self)
88 self->timestampMilliseconds = -1;
89 self->type = ndn_ContentType_BLOB;
90 self->freshnessPeriod = -1;
91 ndn_NameComponent_initialize(&self->finalBlockId, 0, 0);
97 static __inline
int ndn_MetaInfo_getFreshnessSeconds(
const struct ndn_MetaInfo *
self)
99 return self->freshnessPeriod < 0 ? -1 : (int)round(self->freshnessPeriod / 1000.0);
105 static __inline
void ndn_MetaInfo_setFreshnessSeconds(
struct ndn_MetaInfo *
self,
int freshnessSeconds)
107 self->freshnessPeriod = freshnessSeconds < 0 ? -1.0 : (double)freshnessSeconds * 1000.0;
117 static __inline ndn_Error
118 ndn_MetaInfo_setFromMetaInfo
123 return NDN_ERROR_success;
126 self->type = other->
type;
128 ndn_NameComponent_setFromNameComponent(&self->finalBlockId, &other->
finalBlockId);
130 return NDN_ERROR_success;
142 static __inline
void ndn_Data_initialize
146 ndn_Signature_initialize(&self->signature, keyNameComponents, maxKeyNameComponents);
147 ndn_Name_initialize(&self->name, nameComponents, maxNameComponents);
148 ndn_MetaInfo_initialize(&self->metaInfo);
149 ndn_Blob_initialize(&self->content, 0, 0);
159 static __inline ndn_Error
166 return NDN_ERROR_success;
168 if ((error = ndn_Signature_setFromSignature
169 (&self->signature, &other->signature)))
171 if ((error = ndn_Name_setFromName(&self->name, &other->name)))
173 if ((error = ndn_MetaInfo_setFromMetaInfo
174 (&self->metaInfo, &other->metaInfo)))
176 ndn_Blob_setFromBlob(&self->content, &other->
content);
178 return NDN_ERROR_success;
Definition: data-types.h:74
struct ndn_Blob content
A Blob with a pointer to the content.
Definition: data-types.h:78
Copyright (C) 2015-2016 Regents of the University of California.
Definition: name-types.h:33
An ndn_Signature struct holds the signature bits and other info representing the signature in a data ...
Definition: data-types.h:58