ndn-lite
Functions | Variables
ndn-rule-storage.c File Reference
#include "ndn-rule-storage.h"

Functions

int _check_buffer_all_zeros (const uint8_t *buf, int buf_size)
 
ndn_rule_storage_tget_ndn_rule_storage_instance (void)
 There should be only one ndn_rule_storage_t. More...
 
void ndn_rule_storage_init (void)
 Init the rule storage singleton. More...
 
const ndn_trust_schema_rule_tndn_rule_storage_get_rule (const char *rule_name)
 Get a rule from the rule storage. More...
 
int ndn_rule_storage_add_rule (const char *rule_name, const ndn_trust_schema_rule_t *rule)
 Add a rule to the rule storage. More...
 
int ndn_rule_storage_remove_rule (const char *rule_name)
 Remove a rule from the rule storage. More...
 

Variables

static ndn_rule_storage_t ndn_rule_storage
 

Function Documentation

◆ _check_buffer_all_zeros()

int _check_buffer_all_zeros ( const uint8_t *  buf,
int  buf_size 
)

◆ get_ndn_rule_storage_instance()

ndn_rule_storage_t* get_ndn_rule_storage_instance ( void  )

There should be only one ndn_rule_storage_t.

Use this function to get the singleton instance. If the instance has not been initialized, call ndn_rule_storage_init first.

◆ ndn_rule_storage_add_rule()

int ndn_rule_storage_add_rule ( const char *  rule_name,
const ndn_trust_schema_rule_t rule 
)

Add a rule to the rule storage.

Will do a deep copy of the rule passed in.

Parameters
rule_name.Input. The string to associate with the rule added. The storage will not allow the adding of a rule with the same name as one already in storage.
rule.Input. The rule that will be deep copied into the rule storage.
Returns
0 if the rule is successfully added.

◆ ndn_rule_storage_get_rule()

const ndn_trust_schema_rule_t* ndn_rule_storage_get_rule ( const char *  rule_name)

Get a rule from the rule storage.

Parameters
rule_name.Input. The string representing the name of the rule to get from storage.
Returns
A pointer to the rule if it is found in storage. NULL otherwise.

◆ ndn_rule_storage_init()

void ndn_rule_storage_init ( void  )

Init the rule storage singleton.

This function will clear the rule storage.

◆ ndn_rule_storage_remove_rule()

int ndn_rule_storage_remove_rule ( const char *  rule_name)

Remove a rule from the rule storage.

Parameters
rule_name.Input. The name of the rule to remove.
Returns
0 if the rule corresponding to rule_name is successfully removed.

Variable Documentation

◆ ndn_rule_storage

ndn_rule_storage_t ndn_rule_storage
static