blob: 97c48e5ed074808218bf52bf265a45b568032268 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
* ZMap Copyright 2013 Regents of the University of Michigan
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
#ifndef XMAP_EXPRESSION_H
#define XMAP_EXPRESSION_H
#include "fieldset.h"
enum operation { GT, LT, EQ, NEQ, AND, OR, LT_EQ, GT_EQ };
enum node_type { OP, FIELD, STRING, INT };
struct field_id {
int index;
char *fieldname;
};
union node_value {
struct field_id field;
char *string_literal;
uint64_t int_literal;
enum operation op;
};
typedef struct node_st {
struct node_st *left_child;
struct node_st *right_child;
enum node_type type;
union node_value value;
} node_t;
node_t *make_op_node(enum operation op);
node_t *make_field_node(char *fieldname);
node_t *make_string_node(char *literal);
node_t *make_int_node(int literal);
int evaluate_expression(node_t *root, fieldset_t *fields);
void print_expression(node_t *root);
#endif // XMAP_EXPRESSION_H
|