44 #define DEBUG DEBUG_NONE 47 static unsigned char char_buf[DB_MAX_CHAR_SIZE_PER_ROW];
48 static uint8_t next_free_offset;
50 static aql_attribute_t *
51 get_attribute(aql_adt_t *adt,
char *name)
55 for(i = 0; i < AQL_ATTRIBUTE_COUNT(adt); i++) {
56 if(strcmp(adt->attributes[i].name, name) == 0) {
57 return &adt->attributes[i];
63 static unsigned char *
64 save_char(
unsigned char *ptr,
size_t length)
66 unsigned char *start_ptr;
68 if(length + next_free_offset > DB_MAX_CHAR_SIZE_PER_ROW) {
72 start_ptr = char_buf + next_free_offset;
73 memcpy(start_ptr, ptr, length);
74 next_free_offset += length;
80 aql_clear(aql_adt_t *adt)
85 adt->optype = AQL_TYPE_NONE;
86 adt->relation_count = 0;
87 adt->attribute_count = 0;
90 memset(adt->aggregators, 0,
sizeof(adt->aggregators));
94 aql_add_relation(aql_adt_t *adt,
const char *name)
96 if(adt->relation_count >= AQL_RELATION_LIMIT) {
97 return DB_LIMIT_ERROR;
100 strncpy(adt->relations[adt->relation_count], name,
101 sizeof(adt->relations[0]) - 1);
102 adt->relations[adt->relation_count][
sizeof(adt->relations[0]) - 1] =
'\0';
103 adt->relation_count++;
109 aql_add_attribute(aql_adt_t *adt,
char *name, domain_t domain,
110 unsigned element_size,
int processed_only)
112 aql_attribute_t *attr;
114 if(adt->attribute_count == AQL_ATTRIBUTE_LIMIT) {
115 return DB_LIMIT_ERROR;
118 if(processed_only && get_attribute(adt, name)) {
124 attr = &adt->attributes[adt->attribute_count++];
126 if(strlen(name) + 1 >
sizeof(attr->name)) {
127 return DB_LIMIT_ERROR;
130 strcpy(attr->name, name);
131 attr->domain = domain;
132 attr->element_size = element_size;
133 attr->flags = processed_only ? ATTRIBUTE_FLAG_NO_STORE : 0;
139 aql_add_value(aql_adt_t *adt, domain_t domain,
void *value_ptr)
141 attribute_value_t *value;
143 if(adt->value_count == AQL_ATTRIBUTE_LIMIT) {
144 return DB_LIMIT_ERROR;
147 value = &adt->values[adt->value_count++];
148 value->domain = domain;
152 VALUE_LONG(value) = *(
long *)value_ptr;
155 VALUE_STRING(value) = save_char(value_ptr, strlen(value_ptr) + 1);
156 if(VALUE_STRING(value) != NULL) {
160 return DB_TYPE_ERROR;
A set of debugging macros for the IP stack
Definitions and declarations for AQL, the Antelope Query Language.