MINOR: ist: Add the function isteqi

This new function does the same as isteq, but ignoring the case.
This commit is contained in:
Christopher Faulet 2018-06-06 16:33:53 +02:00 committed by Willy Tarreau
parent 5f8ef13d5d
commit 20761453fb
1 changed files with 19 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#ifndef _COMMON_IST_H
#define _COMMON_IST_H
#include <ctype.h>
#include <string.h>
#include <common/config.h>
@ -243,6 +244,24 @@ static inline int isteq(const struct ist ist1, const struct ist ist2)
return 1;
}
/* returns non-zero if <ist1> equals <ist2>, ignoring the case (empty strings are equal) */
static inline int isteqi(const struct ist ist1, const struct ist ist2)
{
struct ist l = ist1;
struct ist r = ist2;
if (l.len != r.len)
return 0;
while (l.len--) {
if (tolower(*l.ptr) != tolower(*r.ptr))
return 0;
l.ptr++;
r.ptr++;
}
return 1;
}
/* returns non-zero if <ist1> equals <ist2> on the first <count> characters
* (empty strings are equal).
*/