1 /* 2 * Copyright 2001-2009, 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 9 10 11 #include <sys/cdefs.h> 12 13 #include <SupportDefs.h> 14 15 16 namespace QueryParser { 17 18 19 enum match { 20 NO_MATCH = 0, 21 MATCH_OK = 1, 22 23 MATCH_BAD_PATTERN = -2, 24 MATCH_INVALID_CHARACTER 25 }; 26 27 // return values from isValidPattern() 28 enum { 29 PATTERN_INVALID_ESCAPE = -3, 30 PATTERN_INVALID_RANGE, 31 PATTERN_INVALID_SET 32 }; 33 34 35 __BEGIN_DECLS 36 37 38 void skipWhitespace(char** expr, int32 skip = 0); 39 void skipWhitespaceReverse(char** expr, char* stop); 40 int compareKeys(uint32 type, const void* key1, size_t length1, 41 const void* key2, size_t length2); 42 uint32 utf8ToUnicode(char** string); 43 int32 getFirstPatternSymbol(char* string); 44 status_t isValidPattern(char* pattern); 45 status_t matchString(char* pattern, char* string); 46 47 48 __END_DECLS 49 50 51 static inline bool 52 isPattern(char* string) 53 { 54 return getFirstPatternSymbol(string) >= 0 ? true : false; 55 } 56 57 58 } // namespace QueryParser 59 60 61 #endif // _FILE_SYSTEMS_QUERY_PARSER_UTILS_H 62