aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/server/Makefile.inc2
-rw-r--r--tests/server/rtspd.c6
-rw-r--r--tests/server/sws.c6
-rw-r--r--tests/server/util.c84
-rw-r--r--tests/server/util.h4
5 files changed, 93 insertions, 9 deletions
diff --git a/tests/server/Makefile.inc b/tests/server/Makefile.inc
index 3490e7872..c3ea664b6 100644
--- a/tests/server/Makefile.inc
+++ b/tests/server/Makefile.inc
@@ -3,7 +3,6 @@ noinst_PROGRAMS = getpart resolve rtspd sockfilt sws tftpd fake_ntlm
CURLX_SRCS = \
../../lib/mprintf.c \
../../lib/nonblock.c \
- ../../lib/strcase.c \
../../lib/strtoofft.c \
../../lib/timeval.c \
../../lib/warnless.c
@@ -11,7 +10,6 @@ CURLX_SRCS = \
CURLX_HDRS = \
../../lib/curlx.h \
../../lib/nonblock.h \
- ../../lib/strcase.h \
../../lib/strtoofft.h \
../../lib/timeval.h \
../../lib/warnless.h
diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c
index 96310cf89..db95917a9 100644
--- a/tests/server/rtspd.c
+++ b/tests/server/rtspd.c
@@ -590,7 +590,7 @@ static int ProcessRequest(struct httprequest *req)
if(got_exit_signal)
return 1; /* done */
- if((req->cl==0) && curlx_strncasecompare("Content-Length:", line, 15)) {
+ if((req->cl==0) && strncasecompare("Content-Length:", line, 15)) {
/* If we don't ignore content-length, we read it and we read the whole
request including the body before we return. If we've been told to
ignore the content-length, we will return as soon as all headers
@@ -616,8 +616,8 @@ static int ProcessRequest(struct httprequest *req)
logmsg("... but will abort after %zu bytes", req->cl);
break;
}
- else if(curlx_strncasecompare("Transfer-Encoding: chunked", line,
- strlen("Transfer-Encoding: chunked"))) {
+ else if(strncasecompare("Transfer-Encoding: chunked", line,
+ strlen("Transfer-Encoding: chunked"))) {
/* chunked data coming in */
chunked = TRUE;
}
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 801a7b83f..c94e23453 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -697,7 +697,7 @@ static int ProcessRequest(struct httprequest *req)
if(got_exit_signal)
return 1; /* done */
- if((req->cl==0) && curlx_strncasecompare("Content-Length:", line, 15)) {
+ if((req->cl==0) && strncasecompare("Content-Length:", line, 15)) {
/* If we don't ignore content-length, we read it and we read the whole
request including the body before we return. If we've been told to
ignore the content-length, we will return as soon as all headers
@@ -723,8 +723,8 @@ static int ProcessRequest(struct httprequest *req)
logmsg("... but will abort after %zu bytes", req->cl);
break;
}
- else if(curlx_strncasecompare("Transfer-Encoding: chunked", line,
- strlen("Transfer-Encoding: chunked"))) {
+ else if(strncasecompare("Transfer-Encoding: chunked", line,
+ strlen("Transfer-Encoding: chunked"))) {
/* chunked data coming in */
chunked = TRUE;
}
diff --git a/tests/server/util.c b/tests/server/util.c
index d99336397..e65470786 100644
--- a/tests/server/util.c
+++ b/tests/server/util.c
@@ -305,3 +305,87 @@ void clear_advisor_read_lock(const char *filename)
logmsg("Error removing lock file %s error: %d %s",
filename, error, strerror(error));
}
+
+
+/* Portable, consistent toupper (remember EBCDIC). Do not use toupper() because
+ its behavior is altered by the current locale. */
+static char raw_toupper(char in)
+{
+#if !defined(CURL_DOES_CONVERSIONS)
+ if(in >= 'a' && in <= 'z')
+ return (char)('A' + in - 'a');
+#else
+ switch (in) {
+ case 'a':
+ return 'A';
+ case 'b':
+ return 'B';
+ case 'c':
+ return 'C';
+ case 'd':
+ return 'D';
+ case 'e':
+ return 'E';
+ case 'f':
+ return 'F';
+ case 'g':
+ return 'G';
+ case 'h':
+ return 'H';
+ case 'i':
+ return 'I';
+ case 'j':
+ return 'J';
+ case 'k':
+ return 'K';
+ case 'l':
+ return 'L';
+ case 'm':
+ return 'M';
+ case 'n':
+ return 'N';
+ case 'o':
+ return 'O';
+ case 'p':
+ return 'P';
+ case 'q':
+ return 'Q';
+ case 'r':
+ return 'R';
+ case 's':
+ return 'S';
+ case 't':
+ return 'T';
+ case 'u':
+ return 'U';
+ case 'v':
+ return 'V';
+ case 'w':
+ return 'W';
+ case 'x':
+ return 'X';
+ case 'y':
+ return 'Y';
+ case 'z':
+ return 'Z';
+ }
+#endif
+
+ return in;
+}
+
+int strncasecompare(const char *first, const char *second, size_t max)
+{
+ while(*first && *second && max) {
+ if(raw_toupper(*first) != raw_toupper(*second)) {
+ break;
+ }
+ max--;
+ first++;
+ second++;
+ }
+ if(0 == max)
+ return 1; /* they are equal this far */
+
+ return raw_toupper(*first) == raw_toupper(*second);
+}
diff --git a/tests/server/util.h b/tests/server/util.h
index 2a19a613b..c90fcdf32 100644
--- a/tests/server/util.h
+++ b/tests/server/util.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -63,4 +63,6 @@ void set_advisor_read_lock(const char *filename);
void clear_advisor_read_lock(const char *filename);
+int strncasecompare(const char *first, const char *second, size_t max);
+
#endif /* HEADER_CURL_SERVER_UTIL_H */