librpc: Fix error path cleanups in start_rpc_host_send()
[Samba.git] / libcli / wsp / wsp_aqs.h
blobb34dd522d6d3e93375b0e508d4854c1837ccc455
1 /*
2 * Window Search Service
4 * Copyright (c) Noel Power
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef __WSP_AQS_H__
21 #define __WSP_AQS_H__
22 #include "librpc/gen_ndr/wsp.h"
24 typedef enum nodetype
26 eAND,
27 eOR,
28 eNOT,
29 eVALUE,
30 } t_nodetype;
32 typedef enum op
34 eLT = PRLT,
35 eLE = PRLE,
36 eGT = PRGT,
37 eGE = PRGE,
38 eEQ = PREQ,
39 eNE = PRNE,
40 eSTARTSWITH,
41 eEQUALS,
43 * eMATCHES,
45 * not sure we can express the above in the grammar without
46 * some custom operator :/
48 } t_optype;
50 struct restr;
52 typedef enum {
53 NUMBER,
54 STRING,
55 BOOL,
56 RESTR,
57 VALUE_RANGE,
58 } value_type;
60 typedef enum {
61 eTODAY,
62 eYESTERDAY,
63 eLASTWEEK,
64 eTHISWEEK,
65 eTHISMONTH,
66 eLASTMONTH,
67 eTHISYEAR,
68 eLASTYEAR,
69 } daterange_type;
71 typedef enum {
72 eEMPTY,
73 eTINY,
74 eSMALL,
75 eMEDIUM,
76 eLARGE,
77 eHUGE,
78 eGIGANTIC,
79 } sizerange_type;
81 struct value_range;
83 typedef struct {
84 value_type type;
85 union {
86 bool boolean;
87 const char *string;
88 uint64_t number;
89 struct restr *restr_tree;
90 struct value_range *value_range;
91 } value;
92 } t_value_holder;
94 struct value_range
96 t_value_holder *lower;
97 t_value_holder *upper;
99 typedef struct basic_restr
101 uint32_t prop_type;
102 t_optype op;
103 t_value_holder *values;
104 } t_basic_restr;
106 typedef struct basic_query
108 struct GUID guid;
109 const struct full_propset_info *prop_info;
110 char *prop;
111 t_basic_restr *basic_restriction;
112 } t_basic_query;
114 t_basic_query *create_basic_query(TALLOC_CTX *ctx, const char *prop, t_basic_restr *restr);
116 typedef struct restr
118 t_nodetype type;
119 struct restr *left;
120 struct restr *right;
121 t_basic_restr *basic_restr;
122 } t_restr;
124 t_restr *create_restr(TALLOC_CTX *ctx, t_nodetype op, t_restr *left, t_restr *right, t_basic_restr *value);
126 t_basic_restr *create_basic_restr(TALLOC_CTX *ctx,
127 uint32_t prop_type,
128 t_optype op,
129 t_value_holder *values);
131 typedef struct query
133 t_nodetype type;
134 struct query *left;
135 struct query *right;
136 struct wsp_crestriction *restriction;
137 } t_query;
139 t_query *create_query_node(TALLOC_CTX *ctx, t_nodetype op, t_query *left, t_query *right, t_basic_query *value);
142 typedef struct col_list {
143 int num_cols;
144 char **cols;
145 } t_col_list;
147 typedef struct select_stmt {
148 t_col_list *cols;
149 t_query *where;
150 } t_select_stmt;
152 t_col_list *create_cols(TALLOC_CTX *ctx, const char *col, t_col_list *append_list);
153 t_select_stmt *create_select(TALLOC_CTX *ctx, t_col_list *cols, t_query *where);
155 t_select_stmt *get_wsp_sql_tree(const char *expr);
156 t_value_holder *create_string_val(TALLOC_CTX*, const char *text);
157 t_value_holder *create_num_val(TALLOC_CTX*, int64_t val);
158 t_value_holder *create_bool_val(TALLOC_CTX*, bool val);
159 t_value_holder *create_value_range(TALLOC_CTX*,
160 t_value_holder *left,
161 t_value_holder *right);
162 t_value_holder *create_date_range_shortcut(TALLOC_CTX *ctx,
163 daterange_type daterange);
164 t_value_holder *create_size_range_shortcut(TALLOC_CTX *ctx,
165 sizerange_type size);
166 #endif /* __WSP_AQS_H__ */