libevhtp
libevhtp copied to clipboard
info: libevhtp relies on onigposix.h, which is disabled in onig>=6.9.5_rev1
While packaging libevhtp I just found out that it relies on oniguruma's POSIX API headers (onigposix.h
), which are not generated by default since ing-6.9.5_rev1 kkos/oniguruma#195
So starting from that version, libevhtp need to be built against an oniguruma configured with the flag --enable-posix-api=yes
to work properly. This needs to be documented.
Alternatively libevhtp could be refactored to use the oniguruma.h
API instead.
I ran into the same problem and made this change to evhtp.c to use oniguruma.h. I did it quite some time ago so I don't remember how it works, but it does appear to work.
#include "regint.h" /* def for oniguruma regex_t (aka 're_pattern_buffer')*/
#include "oniguruma.h"
...
static evhtp_callback_t *
htp__callback_find_(evhtp_callbacks_t * cbs,
const char * path,
unsigned int * start_offset,
unsigned int * end_offset)
{
size_t path_len;
evhtp_callback_t * callback;
//#ifndef EVHTP_DISABLE_REGEX
// regmatch_t pmatch[28];
//#endif
if (evhtp_unlikely(cbs == NULL)) {
return NULL;
}
path_len = strlen(path);
TAILQ_FOREACH(callback, cbs, next) {
switch (callback->type) {
/* added exact match type -ajf */
case evhtp_callback_type_exact:
if (strcmp(path, callback->val.path) == 0) {
*start_offset = 0;
*end_offset = path_len;
return callback;
}
break;
case evhtp_callback_type_hash:
if (strncmp(path, callback->val.path, callback->len) == 0) {
*start_offset = 0;
*end_offset = path_len;
return callback;
}
break;
#ifndef EVHTP_DISABLE_REGEX
case evhtp_callback_type_regex:
/* switched to normal onig calls (instead of the onigposix.h ones) -ajf */
{
int r;
OnigRegion *region= onig_region_new();
UChar *str=(UChar*)path;
UChar *end=(UChar* )path + onigenc_str_bytelen_null(ONIG_ENCODING_UTF8, (UChar* )path);
unsigned char *start=str, *range=end;
r = onig_search(callback->val.regex, str, end,
start, range, region, ONIG_OPTION_NONE);
if( r >= 0)
{
*start_offset = region->beg[0];
*end_offset = region->end[0];
onig_region_free(region, 1);
return callback;
}
}
break;
#endif
...
I also removed #include <onigposix.h>
from libevhtp/include/evhtp/evhtp.h