UNIXworkcode

1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 * 4 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 5 * 6 * THE BSD LICENSE 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * 11 * Redistributions of source code must retain the above copyright notice, this 12 * list of conditions and the following disclaimer. 13 * Redistributions in binary form must reproduce the above copyright notice, 14 * this list of conditions and the following disclaimer in the documentation 15 * and/or other materials provided with the distribution. 16 * 17 * Neither the name of the nor the names of its contributors may be 18 * used to endorse or promote products derived from this software without 19 * specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 25 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #ifndef BASE_SHEXP_H 35 #define BASE_SHEXP_H 36 37 #ifndef NOINTNSAPI 38 #define INTNSAPI 39 #endif /* !NOINTNSAPI */ 40 41 /* 42 * shexp.h: Defines and prototypes for shell exp. match routines 43 * 44 * 45 * This routine will match a string with a shell expression. The expressions 46 * accepted are based loosely on the expressions accepted by zsh. 47 * 48 * o * matches anything 49 * o ? matches one character 50 * o \ will escape a special character 51 * o $ matches the end of the string 52 * o [abc] matches one occurence of a, b, or c. The only character that needs 53 * to be escaped in this is ], all others are not special. 54 * o [a-z] matches any character between a and z 55 * o [^az] matches any character except a or z 56 * o ~ followed by another shell expression will remove any pattern 57 * matching the shell expression from the match list 58 * o (foo|bar) will match either the substring foo, or the substring bar. 59 * These can be shell expressions as well. 60 * 61 * The public interface to these routines is documented in 62 * public/base/shexp.h. 63 * 64 * Rob McCool 65 * 66 */ 67 68 /* 69 * Requires that the macro MALLOC be set to a "safe" malloc that will 70 * exit if no memory is available. If not under MCC httpd, define MALLOC 71 * to be the real malloc and play with fire, or make your own function. 72 */ 73 74 #ifndef NETSITE_H 75 #include "../daemon/netsite.h" 76 #endif /* !NETSITE_H */ 77 78 #ifndef OS_CTYPE_H 79 #include <ctype.h> /* isalnum */ 80 #define OS_CTYPE_H 81 #endif /* !OS_CTYPE_H */ 82 83 #ifndef OS_STRING_H 84 #include <string.h> /* strlen */ 85 #define OS_STRING_H 86 #endif /* !OS_STRING_H */ 87 88 /* See public/base/shexp.h or public/base/regexp.h concerning USE_REGEX */ 89 90 /* 91 * This little bit of nonsense is because USE_REGEX is currently 92 * supposed to be recognized only by the proxy. If that's the 93 * case, only the proxy should define USE_REGEX, but I'm playing 94 * it safe. XXXHEP 12/96 95 */ 96 #ifndef MCC_PROXY 97 #ifdef USE_REGEX 98 #define SAVED_USE_REGEX USE_REGEX 99 #undef USE_REGEX 100 #endif /* USE_REGEX */ 101 #endif /* !MCC_PROXY */ 102 103 /* --- Begin function prototypes --- */ 104 105 #ifdef INTNSAPI 106 107 #ifdef __cplusplus 108 extern "C" { 109 #endif 110 111 NSAPI_PUBLIC int INTshexp_valid(const char *exp); 112 113 NSAPI_PUBLIC int INTshexp_match(const char *str, const char *exp); 114 115 NSAPI_PUBLIC int INTshexp_cmp(const char *str, const char *exp); 116 117 NSAPI_PUBLIC int INTshexp_noicmp(const char *str, const char *exp); 118 119 NSAPI_PUBLIC int INTshexp_casecmp(const char *str, const char *exp); 120 121 #ifdef __cplusplus 122 } 123 #endif 124 125 /* --- End function prototypes --- */ 126 127 #define shexp_valid INTshexp_valid 128 #define shexp_match INTshexp_match 129 #define shexp_cmp INTshexp_cmp 130 #define shexp_noicmp INTshexp_noicmp 131 #define shexp_casecmp INTshexp_casecmp 132 133 #endif /* INTNSAPI */ 134 135 /* Restore USE_REGEX definition for non-proxy. See above. */ 136 #ifdef SAVED_USE_REGEX 137 #define USE_REGEX SAVED_USE_REGEX 138 #undef SAVED_USE_REGEX 139 #endif /* SAVED_USE_REGEX */ 140 141 #ifdef USE_REGEX 142 #include "base/regexp.h" 143 #endif /* USE_REGEX */ 144 145 #endif /* !BASE_SHEXP_H */ 146