ndn-lite
ndn-trust-schema-pattern-component.h
Go to the documentation of this file.
1 
2 #ifndef NDN_TRUST_SCHEMA_PATTERN_COMPONENT_H
3 #define NDN_TRUST_SCHEMA_PATTERN_COMPONENT_H
4 
5 #include <stdint.h>
6 #include <string.h>
7 
8 #include "../../util/re.h"
9 
10 #include "../../ndn-constants.h"
11 #include "../../ndn-error-code.h"
12 #include "../name-component.h"
13 
15 
16 #include <stdio.h>
17 
25  uint32_t type;
41  uint8_t subpattern_info;
45  uint32_t size;
47 
57 static inline int
59  const uint8_t* value, uint32_t size)
60 {
62  return NDN_OVERSIZE;
63  component->type = type;
64  memcpy(component->value, value, size);
65  component->size = size;
66  return 0;
67 }
68 
76 static inline uint32_t
78 {
81  }
82  else if (re_match(_single_wildcard_rgxp, string) != TINY_REGEX_C_FAIL) {
84  }
85  else if (re_match(_single_name_rgxp, string) != TINY_REGEX_C_FAIL) {
87  }
88  else if (re_match(_subpattern_index_rgxp, string) != TINY_REGEX_C_FAIL) {
90  }
91  else if (re_match(_function_ref_rgxp, string) != TINY_REGEX_C_FAIL) {
93  }
94  else if (re_match(_rule_ref_rgxp, string) != TINY_REGEX_C_FAIL) {
96  }
97  else {
99  }
100 }
101 
110 int
111 ndn_trust_schema_pattern_component_from_string(ndn_trust_schema_pattern_component_t* component, const char* string, uint32_t size);
112 
119 int
121 
129 int
131 
132 
133 #endif // NDN_TRUST_SCHEMA_PATTERN_COMPONENT_H
static int TINY_REGEX_C_FAIL
Definition: ndn-trust-schema-common.h:12
uint32_t type
The component type.
Definition: ndn-trust-schema-pattern-component.h:25
uint8_t subpattern_info
A bit field for storing information regarding subpattern indexing information.
Definition: ndn-trust-schema-pattern-component.h:41
The structure to represent an NDN Trust Schema Pattern Component.
Definition: ndn-trust-schema-pattern-component.h:21
int re_match(const char *pattern, const char *text)
Find matches of the txt pattern inside text (will compile automatically first).
Definition: re.c:74
static char _function_ref_rgxp[]
Definition: ndn-trust-schema-common.h:9
#define NDN_TRUST_SCHEMA_WILDCARD_SPECIALIZER
Definition: ndn-constants.h:141
struct ndn_trust_schema_pattern_component ndn_trust_schema_pattern_component_t
The structure to represent an NDN Trust Schema Pattern Component.
#define NDN_TRUST_SCHEMA_RULE_REF
Definition: ndn-constants.h:142
#define NDN_TRUST_SCHEMA_SINGLE_NAME_COMPONENT
Definition: ndn-constants.h:139
static char _single_name_rgxp[]
Definition: ndn-trust-schema-common.h:5
static int ndn_trust_schema_pattern_component_from_buffer(ndn_trust_schema_pattern_component_t *component, uint32_t type, const uint8_t *value, uint32_t size)
Init an NDN Trust Schema pattern Component structure from caller supplied memory block.
Definition: ndn-trust-schema-pattern-component.h:58
static char _rule_ref_rgxp[]
Definition: ndn-trust-schema-common.h:10
static char _single_wildcard_rgxp[]
Definition: ndn-trust-schema-common.h:6
int ndn_trust_schema_pattern_component_copy(const ndn_trust_schema_pattern_component_t *lhs, ndn_trust_schema_pattern_component_t *rhs)
Copy lhs pattern component to rhs pattern component.
Definition: ndn-trust-schema-pattern-component.c:75
static uint32_t _probe_trust_schema_pattern_component_type(const char *string)
Probes a string to get its trust schema pattern component type.
Definition: ndn-trust-schema-pattern-component.h:77
static char _subpattern_index_rgxp[]
Definition: ndn-trust-schema-common.h:8
int ndn_trust_schema_pattern_component_compare(const ndn_trust_schema_pattern_component_t *pattern_component, const name_component_t *name_component)
Compare a trust schema pattern component and a name component.
Definition: ndn-trust-schema-pattern-component.c:88
#define NDN_TRUST_SCHEMA_WILDCARD_NAME_COMPONENT_SEQUENCE
Definition: ndn-constants.h:137
uint32_t size
The size of component value buffer.
Definition: ndn-trust-schema-pattern-component.h:45
static char _multiple_wildcard_rgxp[]
Definition: ndn-trust-schema-common.h:7
uint8_t value[NDN_TRUST_SCHEMA_PATTERN_COMPONENT_BUFFER_SIZE]
The value which the trust schema pattern component holds.
Definition: ndn-trust-schema-pattern-component.h:30
The structure to represent the Name Component.
Definition: name-component.h:23
#define NDN_OVERSIZE
The object given is larger than expected.
Definition: ndn-error-code.h:33
int ndn_trust_schema_pattern_component_from_string(ndn_trust_schema_pattern_component_t *component, const char *string, uint32_t size)
Init an NDN Trust Schema Pattern Component structure from string.
Definition: ndn-trust-schema-pattern-component.c:11
#define NDN_TRUST_SCHEMA_PATTERN_COMPONENT_BUFFER_SIZE
Definition: ndn-constants.h:131
#define NDN_TRUST_SCHEMA_SUBPATTERN_INDEX
Definition: ndn-constants.h:140
#define NDN_TRUST_SCHEMA_PATTERN_COMPONENT_UNRECOGNIZED_TYPE
Definition: ndn-error-code.h:233
#define NDN_TRUST_SCHEMA_WILDCARD_NAME_COMPONENT
Definition: ndn-constants.h:138
#define NDN_NAME_COMPONENT_BUFFER_SIZE
Definition: ndn-constants.h:15