1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/io/nsWildCard.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * nsWildCard.h: Defines and prototypes for shell exp. match routines 1.11 + * 1.12 + * See nsIZipReader.findEntries docs in nsIZipReader.idl for a description of 1.13 + * the supported expression syntax. 1.14 + * 1.15 + * Note that the syntax documentation explicitly says the results of certain 1.16 + * expressions are undefined. This is intentional to require less robustness 1.17 + * in the code. Regular expression parsing is hard; the smaller the set of 1.18 + * features and interactions this code must support, the easier it is to 1.19 + * ensure it works. 1.20 + * 1.21 + */ 1.22 + 1.23 +#ifndef nsWildCard_h__ 1.24 +#define nsWildCard_h__ 1.25 + 1.26 +#include "nscore.h" 1.27 + 1.28 +/* --------------------------- Public routines ---------------------------- */ 1.29 + 1.30 + 1.31 +/* 1.32 + * NS_WildCardValid takes a shell expression exp as input. It returns: 1.33 + * 1.34 + * NON_SXP if exp is a standard string 1.35 + * INVALID_SXP if exp is a shell expression, but invalid 1.36 + * VALID_SXP if exp is a valid shell expression 1.37 + */ 1.38 + 1.39 +#define NON_SXP -1 1.40 +#define INVALID_SXP -2 1.41 +#define VALID_SXP 1 1.42 + 1.43 +int NS_WildCardValid(const char *expr); 1.44 + 1.45 +int NS_WildCardValid(const char16_t *expr); 1.46 + 1.47 +/* return values for the search routines */ 1.48 +#define MATCH 0 1.49 +#define NOMATCH 1 1.50 +#define ABORTED -1 1.51 + 1.52 +/* 1.53 + * NS_WildCardMatch 1.54 + * 1.55 + * Takes a prevalidated shell expression exp, and a string str. 1.56 + * 1.57 + * Returns 0 on match and 1 on non-match. 1.58 + */ 1.59 + 1.60 +int NS_WildCardMatch(const char *str, const char *expr, 1.61 + bool case_insensitive); 1.62 + 1.63 +int NS_WildCardMatch(const char16_t *str, const char16_t *expr, 1.64 + bool case_insensitive); 1.65 + 1.66 +#endif /* nsWildCard_h__ */