shexp.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. #ifndef BASE_SHEXP_H
  13. #define BASE_SHEXP_H
  14. #ifndef NOINTNSAPI
  15. #define INTNSAPI
  16. #endif /* !NOINTNSAPI */
  17. /*
  18. * shexp.h: Defines and prototypes for shell exp. match routines
  19. *
  20. *
  21. * This routine will match a string with a shell expression. The expressions
  22. * accepted are based loosely on the expressions accepted by zsh.
  23. *
  24. * o * matches anything
  25. * o ? matches one character
  26. * o \ will escape a special character
  27. * o $ matches the end of the string
  28. * o [abc] matches one occurence of a, b, or c. The only character that needs
  29. * to be escaped in this is ], all others are not special.
  30. * o [a-z] matches any character between a and z
  31. * o [^az] matches any character except a or z
  32. * o ~ followed by another shell expression will remove any pattern
  33. * matching the shell expression from the match list
  34. * o (foo|bar) will match either the substring foo, or the substring bar.
  35. * These can be shell expressions as well.
  36. *
  37. * The public interface to these routines is documented in
  38. * public/base/shexp.h.
  39. *
  40. * Rob McCool
  41. *
  42. */
  43. /*
  44. * Requires that the macro MALLOC be set to a "safe" malloc that will
  45. * exit if no memory is available. If not under MCC httpd, define MALLOC
  46. * to be the real malloc and play with fire, or make your own function.
  47. */
  48. #ifndef NETSITE_H
  49. #include "../netsite.h"
  50. #endif /* !NETSITE_H */
  51. #ifndef OS_CTYPE_H
  52. #include <ctype.h> /* isalnum */
  53. #define OS_CTYPE_H
  54. #endif /* !OS_CTYPE_H */
  55. #ifndef OS_STRING_H
  56. #include <string.h> /* strlen */
  57. #define OS_STRING_H
  58. #endif /* !OS_STRING_H */
  59. /* See public/base/shexp.h or public/base/regexp.h concerning USE_REGEX */
  60. /*
  61. * This little bit of nonsense is because USE_REGEX is currently
  62. * supposed to be recognized only by the proxy. If that's the
  63. * case, only the proxy should define USE_REGEX, but I'm playing
  64. * it safe. XXXHEP 12/96
  65. */
  66. #ifndef MCC_PROXY
  67. #ifdef USE_REGEX
  68. #define SAVED_USE_REGEX USE_REGEX
  69. #undef USE_REGEX
  70. #endif /* USE_REGEX */
  71. #endif /* !MCC_PROXY */
  72. /* --- Begin function prototypes --- */
  73. #ifdef INTNSAPI
  74. NSPR_BEGIN_EXTERN_C
  75. NSAPI_PUBLIC int INTshexp_valid(char *exp);
  76. NSAPI_PUBLIC int INTshexp_match(char *str, char *exp);
  77. NSAPI_PUBLIC int INTshexp_cmp(char *str, char *exp);
  78. NSAPI_PUBLIC int INTshexp_casecmp(char *str, char *exp);
  79. NSPR_END_EXTERN_C
  80. /* --- End function prototypes --- */
  81. #define shexp_valid INTshexp_valid
  82. #define shexp_match INTshexp_match
  83. #define shexp_cmp INTshexp_cmp
  84. #define shexp_casecmp INTshexp_casecmp
  85. #endif /* INTNSAPI */
  86. /* Restore USE_REGEX definition for non-proxy. See above. */
  87. #ifdef SAVED_USE_REGEX
  88. #define USE_REGEX SAVED_USE_REGEX
  89. #undef SAVED_USE_REGEX
  90. #endif /* SAVED_USE_REGEX */
  91. #ifdef USE_REGEX
  92. #include "base/regexp.h"
  93. #endif /* USE_REGEX */
  94. #endif /* !BASE_SHEXP_H */