vfs: check userland buffers before reading them.
[haiku.git] / headers / private / file_systems / QueryParserUtils.h
blob84860ee196bec6b3615d4cb7060dc01110f0a803
1 /*
2 * Copyright 2001-2014, Axel Dörfler, axeld@pinc-software.de.
3 * Copyright 2010, Clemens Zeidler <haiku@clemens-zeidler.de>
4 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
5 * This file may be used under the terms of the MIT License.
6 */
7 #ifndef _FILE_SYSTEMS_QUERY_PARSER_UTILS_H
8 #define _FILE_SYSTEMS_QUERY_PARSER_UTILS_H
11 #include <sys/cdefs.h>
13 #ifdef FS_SHELL
14 # include <new>
16 # include "fssh_api_wrapper.h"
17 # include "fssh_auto_deleter.h"
18 #else
19 # include <SupportDefs.h>
20 #endif // !FS_SHELL
23 namespace QueryParser {
26 enum match {
27 NO_MATCH = 0,
28 MATCH_OK = 1,
30 MATCH_BAD_PATTERN = -2,
31 MATCH_INVALID_CHARACTER
34 // return values from isValidPattern()
35 enum {
36 PATTERN_INVALID_ESCAPE = -3,
37 PATTERN_INVALID_RANGE,
38 PATTERN_INVALID_SET
42 __BEGIN_DECLS
45 void skipWhitespace(char** expr, int32 skip = 0);
46 void skipWhitespaceReverse(char** expr, char* stop);
47 int compareKeys(uint32 type, const void* key1, size_t length1,
48 const void* key2, size_t length2);
49 uint32 utf8ToUnicode(char** string);
50 int32 getFirstPatternSymbol(char* string);
51 status_t isValidPattern(char* pattern);
52 status_t matchString(char* pattern, char* string);
55 __END_DECLS
58 static inline bool
59 isPattern(char* string)
61 return getFirstPatternSymbol(string) >= 0 ? true : false;
65 } // namespace QueryParser
68 #endif // _FILE_SYSTEMS_QUERY_PARSER_UTILS_H