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