shexp.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. #ifndef BASE_SHEXP_H
  42. #define BASE_SHEXP_H
  43. #ifndef NOINTNSAPI
  44. #define INTNSAPI
  45. #endif /* !NOINTNSAPI */
  46. /*
  47. * shexp.h: Defines and prototypes for shell exp. match routines
  48. *
  49. *
  50. * This routine will match a string with a shell expression. The expressions
  51. * accepted are based loosely on the expressions accepted by zsh.
  52. *
  53. * o * matches anything
  54. * o ? matches one character
  55. * o \ will escape a special character
  56. * o $ matches the end of the string
  57. * o [abc] matches one occurence of a, b, or c. The only character that needs
  58. * to be escaped in this is ], all others are not special.
  59. * o [a-z] matches any character between a and z
  60. * o [^az] matches any character except a or z
  61. * o ~ followed by another shell expression will remove any pattern
  62. * matching the shell expression from the match list
  63. * o (foo|bar) will match either the substring foo, or the substring bar.
  64. * These can be shell expressions as well.
  65. *
  66. * The public interface to these routines is documented in
  67. * public/base/shexp.h.
  68. *
  69. * Rob McCool
  70. *
  71. */
  72. /*
  73. * Requires that the macro MALLOC be set to a "safe" malloc that will
  74. * exit if no memory is available. If not under MCC httpd, define MALLOC
  75. * to be the real malloc and play with fire, or make your own function.
  76. */
  77. #ifndef NETSITE_H
  78. #include "../netsite.h"
  79. #endif /* !NETSITE_H */
  80. #ifndef OS_CTYPE_H
  81. #include <ctype.h> /* isalnum */
  82. #define OS_CTYPE_H
  83. #endif /* !OS_CTYPE_H */
  84. #ifndef OS_STRING_H
  85. #include <string.h> /* strlen */
  86. #define OS_STRING_H
  87. #endif /* !OS_STRING_H */
  88. /* See public/base/shexp.h or public/base/regexp.h concerning USE_REGEX */
  89. /*
  90. * This little bit of nonsense is because USE_REGEX is currently
  91. * supposed to be recognized only by the proxy. If that's the
  92. * case, only the proxy should define USE_REGEX, but I'm playing
  93. * it safe. XXXHEP 12/96
  94. */
  95. #ifndef MCC_PROXY
  96. #ifdef USE_REGEX
  97. #define SAVED_USE_REGEX USE_REGEX
  98. #undef USE_REGEX
  99. #endif /* USE_REGEX */
  100. #endif /* !MCC_PROXY */
  101. /* --- Begin function prototypes --- */
  102. #ifdef INTNSAPI
  103. NSPR_BEGIN_EXTERN_C
  104. NSAPI_PUBLIC int INTshexp_valid(char *exp);
  105. NSAPI_PUBLIC int INTshexp_match(char *str, char *exp);
  106. NSAPI_PUBLIC int INTshexp_cmp(char *str, char *exp);
  107. NSAPI_PUBLIC int INTshexp_casecmp(char *str, char *exp);
  108. NSPR_END_EXTERN_C
  109. /* --- End function prototypes --- */
  110. #define shexp_valid INTshexp_valid
  111. #define shexp_match INTshexp_match
  112. #define shexp_cmp INTshexp_cmp
  113. #define shexp_casecmp INTshexp_casecmp
  114. #endif /* INTNSAPI */
  115. /* Restore USE_REGEX definition for non-proxy. See above. */
  116. #ifdef SAVED_USE_REGEX
  117. #define USE_REGEX SAVED_USE_REGEX
  118. #undef SAVED_USE_REGEX
  119. #endif /* SAVED_USE_REGEX */
  120. #ifdef USE_REGEX
  121. #include "base/regexp.h"
  122. #endif /* USE_REGEX */
  123. #endif /* !BASE_SHEXP_H */