pcre_config.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*************************************************
  2. * Perl-Compatible Regular Expressions *
  3. *************************************************/
  4. /* PCRE is a library of functions to support regular expressions whose syntax
  5. and semantics are as close as possible to those of the Perl 5 language.
  6. Written by Philip Hazel
  7. Copyright (c) 1997-2012 University of Cambridge
  8. -----------------------------------------------------------------------------
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. * Redistributions of source code must retain the above copyright notice,
  12. this list of conditions and the following disclaimer.
  13. * Redistributions in binary form must reproduce the above copyright
  14. notice, this list of conditions and the following disclaimer in the
  15. documentation and/or other materials provided with the distribution.
  16. * Neither the name of the University of Cambridge nor the names of its
  17. contributors may be used to endorse or promote products derived from
  18. this software without specific prior written permission.
  19. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  23. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  24. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  25. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  28. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29. POSSIBILITY OF SUCH DAMAGE.
  30. -----------------------------------------------------------------------------
  31. */
  32. /* This module contains the external function pcre_config(). */
  33. #ifdef HAVE_CONFIG_H
  34. #include "pcre_config.h"
  35. #endif
  36. /* Keep the original link size. */
  37. static int real_link_size = LINK_SIZE;
  38. #include "pcre_internal.h"
  39. /*************************************************
  40. * Return info about what features are configured *
  41. *************************************************/
  42. /* This function has an extensible interface so that additional items can be
  43. added compatibly.
  44. Arguments:
  45. what what information is required
  46. where where to put the information
  47. Returns: 0 if data returned, negative on error
  48. */
  49. #if defined COMPILE_PCRE8
  50. PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
  51. pcre_config(int what, void *where)
  52. #elif defined COMPILE_PCRE16
  53. PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
  54. pcre16_config(int what, void *where)
  55. #elif defined COMPILE_PCRE32
  56. PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
  57. pcre32_config(int what, void *where)
  58. #endif
  59. {
  60. switch (what)
  61. {
  62. case PCRE_CONFIG_UTF8:
  63. #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
  64. *((int *)where) = 0;
  65. return PCRE_ERROR_BADOPTION;
  66. #else
  67. #if defined SUPPORT_UTF
  68. *((int *)where) = 1;
  69. #else
  70. *((int *)where) = 0;
  71. #endif
  72. break;
  73. #endif
  74. case PCRE_CONFIG_UTF16:
  75. #if defined COMPILE_PCRE8 || defined COMPILE_PCRE32
  76. *((int *)where) = 0;
  77. return PCRE_ERROR_BADOPTION;
  78. #else
  79. #if defined SUPPORT_UTF
  80. *((int *)where) = 1;
  81. #else
  82. *((int *)where) = 0;
  83. #endif
  84. break;
  85. #endif
  86. case PCRE_CONFIG_UTF32:
  87. #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
  88. *((int *)where) = 0;
  89. return PCRE_ERROR_BADOPTION;
  90. #else
  91. #if defined SUPPORT_UTF
  92. *((int *)where) = 1;
  93. #else
  94. *((int *)where) = 0;
  95. #endif
  96. break;
  97. #endif
  98. case PCRE_CONFIG_UNICODE_PROPERTIES:
  99. #ifdef SUPPORT_UCP
  100. *((int *)where) = 1;
  101. #else
  102. *((int *)where) = 0;
  103. #endif
  104. break;
  105. case PCRE_CONFIG_JIT:
  106. #ifdef SUPPORT_JIT
  107. *((int *)where) = 1;
  108. #else
  109. *((int *)where) = 0;
  110. #endif
  111. break;
  112. case PCRE_CONFIG_JITTARGET:
  113. #ifdef SUPPORT_JIT
  114. *((const char **)where) = PRIV(jit_get_target)();
  115. #else
  116. *((const char **)where) = NULL;
  117. #endif
  118. break;
  119. case PCRE_CONFIG_NEWLINE:
  120. *((int *)where) = NEWLINE;
  121. break;
  122. case PCRE_CONFIG_BSR:
  123. #ifdef BSR_ANYCRLF
  124. *((int *)where) = 1;
  125. #else
  126. *((int *)where) = 0;
  127. #endif
  128. break;
  129. case PCRE_CONFIG_LINK_SIZE:
  130. *((int *)where) = real_link_size;
  131. break;
  132. case PCRE_CONFIG_POSIX_MALLOC_THRESHOLD:
  133. *((int *)where) = POSIX_MALLOC_THRESHOLD;
  134. break;
  135. case PCRE_CONFIG_PARENS_LIMIT:
  136. *((unsigned long int *)where) = PARENS_NEST_LIMIT;
  137. break;
  138. case PCRE_CONFIG_MATCH_LIMIT:
  139. *((unsigned long int *)where) = MATCH_LIMIT;
  140. break;
  141. case PCRE_CONFIG_MATCH_LIMIT_RECURSION:
  142. *((unsigned long int *)where) = MATCH_LIMIT_RECURSION;
  143. break;
  144. case PCRE_CONFIG_STACKRECURSE:
  145. #ifdef NO_RECURSE
  146. *((int *)where) = 0;
  147. #else
  148. *((int *)where) = 1;
  149. #endif
  150. break;
  151. default: return PCRE_ERROR_BADOPTION;
  152. }
  153. return 0;
  154. }
  155. /* End of pcre_config.c */