@@ -248,8 +248,78 @@ using socket_t = int;
248
248
#include < thread>
249
249
#include < unordered_map>
250
250
#include < unordered_set>
251
+
252
+ #ifdef NO_DUCKDB_RE2
253
+ namespace duckdb_re2 {
254
+ enum class RegexOptions : uint8_t { NONE, CASE_INSENSITIVE };
255
+ class Regex {
256
+ public:
257
+ explicit Regex (const std::string &pattern, RegexOptions options = RegexOptions::NONE): re(pattern) {}
258
+ explicit Regex (const char *pattern, RegexOptions options = RegexOptions::NONE) : Regex(std::string(pattern)) {
259
+ }
260
+ // const duckdb_re2::RE2 &GetRegex() const {
261
+ // return *regex;
262
+ // }
263
+ std::regex re;
264
+ };
265
+ struct GroupMatch {
266
+ std::string text;
267
+ uint32_t position;
268
+
269
+ const std::string &str () const { // NOLINT
270
+ return text;
271
+ }
272
+ operator std::string () const { // NOLINT: allow implicit cast
273
+ return text;
274
+ }
275
+ };
276
+
277
+ struct Match {
278
+
279
+ GroupMatch GetGroup (uint64_t index) {
280
+ return {str (index), static_cast <uint32_t >(position (index))};
281
+ }
282
+
283
+ std::string str (uint64_t index) { // NOLINT
284
+ return m.str (index);
285
+ }
286
+
287
+ uint64_t position (uint64_t index) { // NOLINT
288
+ return m.position (index);
289
+ }
290
+
291
+ uint64_t length (uint64_t index) { // NOLINT
292
+ throw std::runtime_error (" uint64_t length(uint64_t index) - NA" );
293
+ }
294
+
295
+ GroupMatch operator [](uint64_t i) {
296
+ return GetGroup (i);
297
+ }
298
+ std::cmatch m;
299
+ };
300
+
301
+ bool RegexSearch (const std::string &input, Match &match, const Regex ®ex) {
302
+ throw std::runtime_error (" bool RegexSearch(const std::string &input, Match &match, const Regex ®ex) - NA" );
303
+ }
304
+
305
+ bool RegexMatch (const std::string &input, Match &match, const Regex ®ex) {
306
+ return std::regex_match (input.c_str (), match.m , regex.re );
307
+ }
308
+
309
+ bool RegexMatch (const char *start, const char *end, Match &match, const Regex ®ex) {
310
+ throw std::runtime_error (" bool RegexMatch(const char *start, const char *end, Match &match, const Regex ®ex) - NA" );
311
+ }
312
+
313
+ bool RegexMatch (const std::string &input, const Regex ®ex) {
314
+ std::cmatch m;
315
+ return std::regex_match (input.c_str (), m, regex.re );
316
+ }
317
+ }
318
+
319
+ #else
251
320
#include " duckdb/common/re2_regex.hpp"
252
321
#include " duckdb/common/random_engine.hpp"
322
+ #endif
253
323
254
324
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
255
325
#ifdef _WIN32
@@ -4643,6 +4713,9 @@ inline std::string to_lower(const char *beg, const char *end) {
4643
4713
}
4644
4714
4645
4715
inline std::string make_multipart_data_boundary () {
4716
+ #ifdef NO_DUCKDB_RE2
4717
+ throw std::runtime_error (" NA" );
4718
+ #else
4646
4719
static const char data[] =
4647
4720
" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ;
4648
4721
@@ -4653,6 +4726,7 @@ inline std::string make_multipart_data_boundary() {
4653
4726
}
4654
4727
4655
4728
return result;
4729
+ #endif
4656
4730
}
4657
4731
4658
4732
inline bool is_multipart_boundary_chars_valid (const std::string &boundary) {
@@ -5109,6 +5183,7 @@ inline bool parse_www_authenticate(const Response &res,
5109
5183
if (type == " Basic" ) {
5110
5184
return false ;
5111
5185
} else if (type == " Digest" ) {
5186
+ #ifndef NO_DUCKDB_RE2
5112
5187
s = s.substr (pos + 1 );
5113
5188
auto matches = duckdb_re2::RegexFindAll (s, re);
5114
5189
for (auto &m : matches) {
@@ -5122,6 +5197,9 @@ inline bool parse_www_authenticate(const Response &res,
5122
5197
auth[key] = val;
5123
5198
}
5124
5199
return true ;
5200
+ #else
5201
+ throw std::runtime_error (" parse_www_authenticate- NA" );
5202
+ #endif
5125
5203
}
5126
5204
}
5127
5205
}
@@ -8166,6 +8244,10 @@ inline SSL *ssl_new(socket_t sock, SSL_CTX *ctx, std::mutex &ctx_mutex,
8166
8244
}
8167
8245
8168
8246
if (ssl) {
8247
+ #ifdef NO_DUCKDB_RE2
8248
+ SSL_set_msg_callback (ssl, SSL_trace);
8249
+ SSL_set_msg_callback_arg (ssl, BIO_new_fp (stdout, 0 ));
8250
+ #endif
8169
8251
set_nonblocking (sock, true );
8170
8252
auto bio = BIO_new_socket (static_cast <int >(sock), BIO_NOCLOSE);
8171
8253
BIO_set_nbio (bio, 1 );
0 commit comments