/**
 * @author: Jeff Thompson
 * See COPYING for copyright and distribution information.
 */

#ifndef NDN_DATA_H
#define NDN_DATA_H

#include "name.h"
#include "publisher-public-key-digest.h"
#include "key.h"

#ifdef __cplusplus
extern "C" {
#endif

struct ndn_Signature {
  unsigned char *digestAlgorithm;      /**< pointer to pre-allocated buffer.  0 for none.
                                        *   If none, default is 2.16.840.1.101.3.4.2.1 (sha-256). */
  unsigned int digestAlgorithmLength;  /**< length of digestAlgorithm.  0 for none */
  unsigned char *witness;              /**< pointer to pre-allocated buffer.  0 for none. */
  unsigned int witnessLength;          /**< length of witness.  0 for none */
  unsigned char *signature;
  unsigned int signatureLength;
};

static inline void ndn_Signature_initialize(struct ndn_Signature *self) {
  self->digestAlgorithm = 0;
  self->digestAlgorithmLength = 0;
  self->witness = 0;
  self->witnessLength = 0;
  self->signature = 0;
  self->signatureLength = 0;
}

typedef enum {
  ndn_ContentType_DATA = 0,
  ndn_ContentType_ENCR = 1,
  ndn_ContentType_GONE = 2,
  ndn_ContentType_KEY =  3,
  ndn_ContentType_LINK = 4,
  ndn_ContentType_NACK = 5
} ndn_ContentType;

struct ndn_MetaInfo {
  struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest;
  double timestampMilliseconds;    /**< milliseconds since 1/1/1970. -1 for none */
  ndn_ContentType type;            /**< default is ndn_ContentType_DATA. -1 for none */
  int freshnessSeconds;            /**< -1 for none */
  unsigned char *finalBlockID;     /**< pointer to pre-allocated buffer.  0 for none */
  unsigned int finalBlockIDLength; /**< length of finalBlockID.  0 for none */
  struct ndn_KeyLocator keyLocator;
};

/**
 * Initialize the ndn_MetaInfo struct with values for none and the type to the default ndn_ContentType_DATA.
 * @param self A pointer to the ndn_MetaInfo struct.
 * @param keyNameComponents The pre-allocated array of ndn_NameComponent for the keyLocator.
 * @param maxKeyNameComponents The number of elements in the allocated keyNameComponents array.
 */
static inline void ndn_MetaInfo_initialize
  (struct ndn_MetaInfo *self, struct ndn_NameComponent *keyNameComponents, unsigned int maxKeyNameComponents) {
  ndn_PublisherPublicKeyDigest_initialize(&self->publisherPublicKeyDigest);
  self->type = ndn_ContentType_DATA;
  self->freshnessSeconds = -1;
  self->finalBlockID = 0;
  self->finalBlockIDLength = 0;
  ndn_KeyLocator_initialize(&self->keyLocator, keyNameComponents, maxKeyNameComponents);
}

struct ndn_Data {
  struct ndn_Signature signature;
  struct ndn_Name name;
  struct ndn_MetaInfo metaInfo;
  unsigned char *content;     /**< pointer to the content */
  unsigned int contentLength; /**< length of content */
};

/**
 * Initialize an ndn_Data struct with the pre-allocated nameComponents and keyNameComponents,
 * and defaults for all the values.
 * @param self A pointer to the ndn_Data struct.
 * @param nameComponents The pre-allocated array of ndn_NameComponent.
 * @param maxNameComponents The number of elements in the allocated nameComponents array.
 * @param keyNameComponents The pre-allocated array of ndn_NameComponent for the metaInfo.keyLocator.
 * @param maxKeyNameComponents The number of elements in the allocated keyNameComponents array.
 */
static inline void ndn_Data_initialize
  (struct ndn_Data *self, struct ndn_NameComponent *nameComponents, unsigned int maxNameComponents, 
   struct ndn_NameComponent *keyNameComponents, unsigned int maxKeyNameComponents) 
{
  ndn_Signature_initialize(&self->signature);
  ndn_Name_initialize(&self->name, nameComponents, maxNameComponents);
  ndn_MetaInfo_initialize(&self->metaInfo, keyNameComponents, maxKeyNameComponents);
  self->content = 0;
  self->contentLength = 0;
}

#ifdef __cplusplus
}
#endif

#endif
