security/nss/lib/util/portreg.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/util/portreg.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +/*
     1.9 + * shexp.h: Defines and prototypes for shell exp. match routines
    1.10 + * 
    1.11 + * This routine will match a string with a shell expression. The expressions
    1.12 + * accepted are based loosely on the expressions accepted by zsh.
    1.13 + * 
    1.14 + * o * matches anything
    1.15 + * o ? matches one character
    1.16 + * o \ will escape a special character
    1.17 + * o $ matches the end of the string
    1.18 + * Bracketed expressions:
    1.19 + * o [abc] matches one occurence of a, b, or c.  
    1.20 + * o [^abc] matches any character except a, b, or c.
    1.21 + *     To be matched between [ and ], these characters must be escaped: \ ]
    1.22 + *     No other characters need be escaped between brackets. 
    1.23 + *     Unnecessary escaping is permitted.
    1.24 + * o [a-z] matches any character between a and z, inclusive.
    1.25 + *     The two range-definition characters must be alphanumeric ASCII.
    1.26 + *     If one is upper case and the other is lower case, then the ASCII
    1.27 + *     non-alphanumeric characters between Z and a will also be in range.
    1.28 + * o [^a-z] matches any character except those between a and z, inclusive.
    1.29 + *     These forms cannot be combined, e.g [a-gp-z] does not work.
    1.30 + * o Exclusions:
    1.31 + *   As a top level, outter-most expression only, the expression
    1.32 + *   foo~bar will match the expression foo, provided it does not also 
    1.33 + *     match the expression bar.  Either expression or both may be a union.
    1.34 + *     Except between brackets, any unescaped ~ is an exclusion. 
    1.35 + *     At most one exclusion is permitted.
    1.36 + *     Exclusions cannot be nested (contain other exclusions).
    1.37 + *     example: *~abc will match any string except abc
    1.38 + * o Unions:
    1.39 + *   (foo|bar) will match either the expression foo, or the expression bar.
    1.40 + *     At least one '|' separator is required.  More are permitted.
    1.41 + *     Expressions inside unions may not include unions or exclusions.
    1.42 + *     Inside a union, to be matched and not treated as a special character,
    1.43 + *     these characters must be escaped: \ ( | ) [ ~ except when they occur
    1.44 + *     inside a bracketed expression, where only \ and ] require escaping.
    1.45 + *
    1.46 + * The public interface to these routines is documented below.
    1.47 + * 
    1.48 + */
    1.49 + 
    1.50 +#ifndef SHEXP_H
    1.51 +#define SHEXP_H
    1.52 +
    1.53 +#include "utilrename.h"
    1.54 +/*
    1.55 + * Requires that the macro MALLOC be set to a "safe" malloc that will 
    1.56 + * exit if no memory is available. 
    1.57 + */
    1.58 +
    1.59 +
    1.60 +/* --------------------------- Public routines ---------------------------- */
    1.61 +
    1.62 +
    1.63 +/*
    1.64 + * shexp_valid takes a shell expression exp as input. It returns:
    1.65 + * 
    1.66 + *  NON_SXP      if exp is a standard string
    1.67 + *  INVALID_SXP  if exp is a shell expression, but invalid
    1.68 + *  VALID_SXP    if exp is a valid shell expression
    1.69 + */
    1.70 +
    1.71 +#define NON_SXP -1
    1.72 +#define INVALID_SXP -2
    1.73 +#define VALID_SXP 1
    1.74 +
    1.75 +SEC_BEGIN_PROTOS
    1.76 +
    1.77 +extern int PORT_RegExpValid(const char *exp);
    1.78 +
    1.79 +extern int PORT_RegExpSearch(const char *str, const char *exp);
    1.80 +
    1.81 +/* same as above but uses case insensitive search */
    1.82 +extern int PORT_RegExpCaseSearch(const char *str, const char *exp);
    1.83 +
    1.84 +SEC_END_PROTOS
    1.85 +
    1.86 +#endif

mercurial