PageRenderTime 35ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/include/common/regex.h

https://github.com/kjwierenga/haproxy-icey
C Header | 64 lines | 28 code | 9 blank | 27 comment | 0 complexity | 8c163c2642eeaeec62b99954847b4d2b MD5 | raw file
  1. /*
  2. include/common/regex.h
  3. This file defines everything related to regular expressions.
  4. Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation, version 2.1
  8. exclusively.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  16. */
  17. #ifndef _COMMON_REGEX_H
  18. #define _COMMON_REGEX_H
  19. #include <common/config.h>
  20. #ifdef USE_PCRE
  21. #include <pcre.h>
  22. #include <pcreposix.h>
  23. #else
  24. #include <regex.h>
  25. #endif
  26. /* what to do when a header matches a regex */
  27. #define ACT_ALLOW 0 /* allow the request */
  28. #define ACT_REPLACE 1 /* replace the matching header */
  29. #define ACT_REMOVE 2 /* remove the matching header */
  30. #define ACT_DENY 3 /* deny the request */
  31. #define ACT_PASS 4 /* pass this header without allowing or denying the request */
  32. #define ACT_TARPIT 5 /* tarpit the connection matching this request */
  33. #define ACT_SETBE 6 /* switch the backend */
  34. struct hdr_exp {
  35. struct hdr_exp *next;
  36. const regex_t *preg; /* expression to look for */
  37. int action; /* ACT_ALLOW, ACT_REPLACE, ACT_REMOVE, ACT_DENY */
  38. const char *replace; /* expression to set instead */
  39. };
  40. extern regmatch_t pmatch[MAX_MATCH];
  41. int exp_replace(char *dst, char *src, const char *str, const regmatch_t *matches);
  42. const char *check_replace_string(const char *str);
  43. const char *chain_regex(struct hdr_exp **head, const regex_t *preg,
  44. int action, const char *replace);
  45. #endif /* _COMMON_REGEX_H */
  46. /*
  47. * Local variables:
  48. * c-indent-level: 8
  49. * c-basic-offset: 8
  50. * End:
  51. */