2 Unix SMB/CIFS implementation.
3 Main metadata server / Spotlight routines / Elasticsearch backend
5 Copyright (C) Ralph Boehme 2019
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "rpc_server/mdssvc/es_parser.tab.h"
26 #define mdsyylalloc SMB_MALLOC
27 #define mdsyylrealloc SMB_REALLOC
29 static char *strip_quote(const char *phrase);
32 %option nounput noyyalloc noyyrealloc prefix="mdsyyl"
34 ASC [a-zA-Z0-9_\*\:\-\.]
39 SPECIAL [\!\#\$\%\&\'\(\)\+\,\.\/\;\<\=\>\?\@\[\]\^\`\{\}\|\~\\]
43 UANY {ASC}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
44 UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
45 UPHRASE {UANY}|{SPECIAL}|{BLANK}|\\{ESCHAR}
48 InRange return FUNC_INRANGE;
49 \$time\.iso return DATE_ISO;
50 false {mdsyyllval.bval = false; return BOOLEAN;}
51 true {mdsyyllval.bval = true; return BOOLEAN;}
63 {UANY}+ {mdsyyllval.sval = talloc_strdup(talloc_tos(), yytext); return WORD;}
64 \"{UPHRASE}+\" {mdsyyllval.sval = strip_quote(yytext); return PHRASE;}
68 static char *strip_quote(const char *phrase)
70 size_t phrase_len = 0;
71 char *stripped_phrase = NULL;
77 phrase_len = strlen(phrase);
80 phrase[phrase_len - 1] != '\"')
82 return talloc_strdup(talloc_tos(), phrase);
87 stripped_phrase = talloc_strndup(talloc_tos(), phrase, phrase_len - 2);
88 if (stripped_phrase == NULL) {
91 return stripped_phrase;