1/* 2 * Copyright 2004-2008, François Revol, <revol@free.fr>. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef _K_QUERY_H 6#define _K_QUERY_H 7 8#include <OS.h> 9 10#ifndef _QUERY_H 11/* already defined in Query.h */ 12typedef enum { 13 B_INVALID_OP = 0, 14 B_EQ, 15 B_GT, 16 B_GE, 17 B_LT, 18 B_LE, 19 B_NE, 20 B_CONTAINS, 21 B_BEGINS_WITH, 22 B_ENDS_WITH, 23 B_AND = 0x101, 24 B_OR, 25 B_NOT, 26 _B_RESERVED_OP_ = 0x100000 27} query_op; 28#endif 29 30struct query_exp; 31 32struct query_term { 33 struct query_exp *exp; 34 char *str; 35/* uint32 type; 36 union { 37 int32 int32v; 38 uint32 uint32v; 39 int64 int64v; 40 uint64 uint64v; 41 bigtime_t bigtimev; 42 char *strv; 43 } val; 44*/ 45}; 46 47typedef struct query_exp { 48 query_op op; 49 struct query_term lv; 50 struct query_term rv; 51} query_exp; 52 53/* this one dups the string */ 54extern char *query_unescape_string(const char *q, const char **newq, char delim); 55 56/* this oen is in-place */ 57extern char *query_strip_bracketed_Cc(char *str); 58 59extern status_t query_parse(const char *query, query_exp **tree); 60 61#endif /* _K_QUERY_H */ 62