| OLD | NEW |
| (Empty) |
| 1 /* This Source Code Form is subject to the terms of the Mozilla Public | |
| 2 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
| 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
| 4 | |
| 5 /* | |
| 6 * shexp.h: Defines and prototypes for shell exp. match routines | |
| 7 * | |
| 8 * This routine will match a string with a shell expression. The expressions | |
| 9 * accepted are based loosely on the expressions accepted by zsh. | |
| 10 * | |
| 11 * o * matches anything | |
| 12 * o ? matches one character | |
| 13 * o \ will escape a special character | |
| 14 * o $ matches the end of the string | |
| 15 * Bracketed expressions: | |
| 16 * o [abc] matches one occurence of a, b, or c. | |
| 17 * o [^abc] matches any character except a, b, or c. | |
| 18 * To be matched between [ and ], these characters must be escaped: \ ] | |
| 19 * No other characters need be escaped between brackets. | |
| 20 * Unnecessary escaping is permitted. | |
| 21 * o [a-z] matches any character between a and z, inclusive. | |
| 22 * The two range-definition characters must be alphanumeric ASCII. | |
| 23 * If one is upper case and the other is lower case, then the ASCII | |
| 24 * non-alphanumeric characters between Z and a will also be in range. | |
| 25 * o [^a-z] matches any character except those between a and z, inclusive. | |
| 26 * These forms cannot be combined, e.g [a-gp-z] does not work. | |
| 27 * o Exclusions: | |
| 28 * As a top level, outter-most expression only, the expression | |
| 29 * foo~bar will match the expression foo, provided it does not also | |
| 30 * match the expression bar. Either expression or both may be a union. | |
| 31 * Except between brackets, any unescaped ~ is an exclusion. | |
| 32 * At most one exclusion is permitted. | |
| 33 * Exclusions cannot be nested (contain other exclusions). | |
| 34 * example: *~abc will match any string except abc | |
| 35 * o Unions: | |
| 36 * (foo|bar) will match either the expression foo, or the expression bar. | |
| 37 * At least one '|' separator is required. More are permitted. | |
| 38 * Expressions inside unions may not include unions or exclusions. | |
| 39 * Inside a union, to be matched and not treated as a special character, | |
| 40 * these characters must be escaped: \ ( | ) [ ~ except when they occur | |
| 41 * inside a bracketed expression, where only \ and ] require escaping. | |
| 42 * | |
| 43 * The public interface to these routines is documented below. | |
| 44 * | |
| 45 */ | |
| 46 | |
| 47 #ifndef SHEXP_H | |
| 48 #define SHEXP_H | |
| 49 | |
| 50 #include "utilrename.h" | |
| 51 /* | |
| 52 * Requires that the macro MALLOC be set to a "safe" malloc that will | |
| 53 * exit if no memory is available. | |
| 54 */ | |
| 55 | |
| 56 | |
| 57 /* --------------------------- Public routines ---------------------------- */ | |
| 58 | |
| 59 | |
| 60 /* | |
| 61 * shexp_valid takes a shell expression exp as input. It returns: | |
| 62 * | |
| 63 * NON_SXP if exp is a standard string | |
| 64 * INVALID_SXP if exp is a shell expression, but invalid | |
| 65 * VALID_SXP if exp is a valid shell expression | |
| 66 */ | |
| 67 | |
| 68 #define NON_SXP -1 | |
| 69 #define INVALID_SXP -2 | |
| 70 #define VALID_SXP 1 | |
| 71 | |
| 72 SEC_BEGIN_PROTOS | |
| 73 | |
| 74 extern int PORT_RegExpValid(const char *exp); | |
| 75 | |
| 76 extern int PORT_RegExpSearch(const char *str, const char *exp); | |
| 77 | |
| 78 /* same as above but uses case insensitive search */ | |
| 79 extern int PORT_RegExpCaseSearch(const char *str, const char *exp); | |
| 80 | |
| 81 SEC_END_PROTOS | |
| 82 | |
| 83 #endif | |
| OLD | NEW |