}
+static inline char *switch_lc_strdup(const char *it)
+{
+ char *dup;
+ char *p;
+
+ if (it) {
+ dup = strdup(it);
+ for(p = dup; p && *p; p++) {
+ *p = tolower(*p);
+ }
+ return dup;
+ }
+
+ return NULL;
+}
+
+
+static inline char *switch_uc_strdup(const char *it)
+{
+ char *dup;
+ char *p;
+
+ if (it) {
+ dup = strdup(it);
+ for(p = dup; p && *p; p++) {
+ *p = toupper(*p);
+ }
+ return dup;
+ }
+
+ return NULL;
+}
+
+
/*!
\brief Test if one string is inside another with extra case checking
\param s the inner string
apr_pool_clear(p);
}
+SWITCH_DECLARE(unsigned int) switch_ci_hashfunc_default(const char *char_key, switch_ssize_t *klen)
+
+{
+ unsigned int hash = 0;
+ const unsigned char *key = (const unsigned char *)char_key;
+ const unsigned char *p;
+ apr_ssize_t i;
+
+ if (*klen == APR_HASH_KEY_STRING) {
+ for (p = key; *p; p++) {
+ hash = hash * 33 + tolower(*p);
+ }
+ *klen = p - key;
+ }
+ else {
+ for (p = key, i = *klen; i; i--, p++) {
+ hash = hash * 33 + tolower(*p);
+ }
+ }
+
+ return hash;
+}
+
+
SWITCH_DECLARE(unsigned int) switch_hashfunc_default(const char *key, switch_ssize_t *klen)
{
return apr_hashfunc_default(key, klen);
SWITCH_DECLARE(char *) switch_event_get_header(switch_event_t *event, const char *header_name)
{
switch_event_header_t *hp;
+ switch_ssize_t hlen = -1;
+ unsigned long hash = 0;
+
switch_assert(event);
- if (!header_name)
- return NULL;
+ if (!header_name) return NULL;
+
+ hash = switch_ci_hashfunc_default(header_name, &hlen);
+
for (hp = event->headers; hp; hp = hp->next) {
- if (!strcasecmp(hp->name, header_name)) {
+ if ((!hp->hash || hash == hp->hash) && !strcasecmp(hp->name, header_name) ) {
return hp->value;
}
}
switch_event_header_t *hp, *lp = NULL, *tp;
switch_status_t status = SWITCH_STATUS_FALSE;
int x = 0;
+ switch_ssize_t hlen = -1;
+ unsigned long hash = 0;
+
tp = event->headers;
while (tp) {
hp = tp;
x++;
switch_assert(x < 1000);
- if (!strcasecmp(header_name, hp->name)) {
+ hash = switch_ci_hashfunc_default(header_name, &hlen);
+
+ if ((!hp->hash || hash == hp->hash) && !strcasecmp(header_name, hp->name)) {
if (lp) {
lp->next = hp->next;
} else {
switch_status_t switch_event_base_add_header(switch_event_t *event, switch_stack_t stack, const char *header_name, char *data)
{
switch_event_header_t *header;
+ switch_ssize_t hlen = -1;
void *pop;
if (switch_queue_trypop(EVENT_HEADER_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
header->name = DUP(header_name);
header->value = data;
-
+ header->hash = switch_ci_hashfunc_default(header->name, &hlen);
+
if (stack == SWITCH_STACK_TOP) {
header->next = event->headers;
event->headers = header;