$(OBJ_DIR)\timeval.obj $(OBJ_DIR)\transfer.obj &
$(OBJ_DIR)\url.obj $(OBJ_DIR)\version.obj &
$(OBJ_DIR)\slist.obj $(OBJ_DIR)\nonblock.obj &
- $(OBJ_DIR)\curl_rand.obj
+ $(OBJ_DIR)\curl_rand.obj $(OBJ_DIR)\curl_memrchr.obj
#
# Use $(OBJS) as a template to generate $(OBJS_STAT) and $(OBJS_DYN).
..\include\curl\multi.h urldata.h cookie.h ..\include\curl\curl.h &
formdata.h timeval.h http_chunks.h hostip.h hash.h llist.h &
curl_addrinfo.h splay.h strequal.h strtok.h sendf.h curl_memory.h share.h &
- strtoofft.h rawstr.h memdebug.h
+ strtoofft.h rawstr.h memdebug.h curl_memrchr.h
$(OBJ_DIR)\http.obj: http.c setup.h config-win32.h ..\include\curl\curlbuild.h &
..\include\curl\curlrules.h setup_once.h urldata.h cookie.h &
..\include\curl\curl.h ..\include\curl\curlver.h &
..\include\curl\curlrules.h ..\include\curl\easy.h &
..\include\curl\multi.h ..\include\curl\curl.h curl_rand.h &
..\include\curl\mprintf.h curl_memory.h memdebug.h
+$(OBJ_DIR)\curl_memrchr.obj: curl_memrchr.c setup.h config-win32.h &
+ ..\include\curl\curlbuild.h ..\include\curl\curlrules.h setup_once.h &
+ ..\include\curl\curl.h ..\include\curl\curlver.h &
+ ..\include\curl\curlrules.h ..\include\curl\easy.h &
+ ..\include\curl\multi.h ..\include\curl\curl.h curl_memrchr.h &
+ ..\include\curl\mprintf.h curl_memory.h memdebug.h
hostares.c hostasyn.c hostip4.c hostip6.c hostsyn.c hostthre.c \
inet_ntop.c parsedate.c select.c gtls.c sslgen.c tftp.c splay.c \
strdup.c socks.c ssh.c nss.c qssl.c rawstr.c curl_addrinfo.c \
- socks_gssapi.c socks_sspi.c curl_sspi.c slist.c nonblock.c
+ socks_gssapi.c socks_sspi.c curl_sspi.c slist.c nonblock.c \
+ curl_memrchr.c
HHEADERS = arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h \
progress.h formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h \
strtoofft.h strerror.h inet_ntop.h curlx.h curl_memory.h setup.h \
transfer.h select.h easyif.h multiif.h parsedate.h sslgen.h gtls.h \
tftp.h sockaddr.h splay.h strdup.h setup_once.h socks.h ssh.h nssg.h \
- curl_base64.h rawstr.h curl_addrinfo.h curl_sspi.h slist.h nonblock.h
+ curl_base64.h rawstr.h curl_addrinfo.h curl_sspi.h slist.h nonblock.h \
+ curl_memrchr.h
+
o.security o.select o.sendf o.speedcheck o.ssluse \
o.strequal o.strtok o.telnet o.timeval \
o.transfer o.url o.version o.strtoofft o.sslgen o.gtls \
- o.rawstr o.curl_addrinfo o.slist o.nonblock o.curl_rand
+ o.rawstr o.curl_addrinfo o.slist o.nonblock o.curl_rand \
+ o.curl_memrchr
+
# Compile options:
linkopts = -o libcurl
o.curl_addrinfo: c.curl_addrinfo
gcc $(compileropts) -c -o curl_addrinfo.o c.curl_addrinfo
+o.curl_memrchr: c.curl_memrchr
+ gcc $(compileropts) -c -o curl_memrchr.o c.curl_memrchr
+
o.curl_rand: c.curl_rand
gcc $(compileropts) -c -o curl_rand.o c.curl_rand
$(DIROBJ)\content_encoding.obj \\r
$(DIROBJ)\cookie.obj \\r
$(DIROBJ)\curl_addrinfo.obj \\r
+ $(DIROBJ)\curl_memrchr.obj \\r
$(DIROBJ)\curl_rand.obj \\r
$(DIROBJ)\curl_sspi.obj \\r
$(DIROBJ)\dict.obj \\r
#include "share.h"
#include "strtoofft.h"
#include "rawstr.h"
+#include "curl_memrchr.h"
/* The last #include file should be: */
#include "memdebug.h"
}
-/*
- * The memrchr() function is like the memchr() function, except that it
- * searches backwards from the end of the n bytes pointed to by s instead of
- * forwards from the front.
- *
- * Exists in glibc but is not widely available on other systems.
- */
-static void *memrchr(const char *s, int c, size_t n)
-{
- while(n--) {
- if(s[n] == c)
- return &s[n];
- }
- return NULL;
-}
-
-
/****************************************************************************
*
* Curl_cookie_add()
--- /dev/null
+/***************************************************************************\r
+ * _ _ ____ _\r
+ * Project ___| | | | _ \| |\r
+ * / __| | | | |_) | |\r
+ * | (__| |_| | _ <| |___\r
+ * \___|\___/|_| \_\_____|\r
+ *\r
+ * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.\r
+ *\r
+ * This software is licensed as described in the file COPYING, which\r
+ * you should have received as part of this distribution. The terms\r
+ * are also available at http://curl.haxx.se/docs/copyright.html.\r
+ *\r
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell\r
+ * copies of the Software, and permit persons to whom the Software is\r
+ * furnished to do so, under the terms of the COPYING file.\r
+ *\r
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY\r
+ * KIND, either express or implied.\r
+ *\r
+ * $Id$\r
+ ***************************************************************************/\r
+\r
+#include "setup.h"\r
+\r
+#include "curl_memrchr.h"\r
+\r
+#define _MPRINTF_REPLACE /* use our functions only */\r
+#include <curl/mprintf.h>\r
+\r
+#include "curl_memory.h"\r
+/* The last #include file should be: */\r
+#include "memdebug.h"\r
+\r
+#ifndef HAVE_MEMRCHR\r
+\r
+/*\r
+ * Curl_memrchr()\r
+ *\r
+ * Our memrchr() function clone for systems which lack this function. The\r
+ * memrchr() function is like the memchr() function, except that it searches\r
+ * backwards from the end of the n bytes pointed to by s instead of forward\r
+ * from the beginning.\r
+ */\r
+\r
+void *\r
+Curl_memrchr(const void *s, int c, size_t n)\r
+{\r
+ const unsigned char *p = s;\r
+ const unsigned char *q = s;\r
+\r
+ p += n - 1;\r
+\r
+ while (p >= q) {\r
+ if (*p == (unsigned char)c)\r
+ return (void *)p;\r
+ p--;\r
+ }\r
+\r
+ return NULL;\r
+}\r
+\r
+#endif /* HAVE_MEMRCHR */\r
--- /dev/null
+#ifndef HEADER_CURL_MEMRCHR_H\r
+#define HEADER_CURL_MEMRCHR_H\r
+/***************************************************************************\r
+ * _ _ ____ _\r
+ * Project ___| | | | _ \| |\r
+ * / __| | | | |_) | |\r
+ * | (__| |_| | _ <| |___\r
+ * \___|\___/|_| \_\_____|\r
+ *\r
+ * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.\r
+ *\r
+ * This software is licensed as described in the file COPYING, which\r
+ * you should have received as part of this distribution. The terms\r
+ * are also available at http://curl.haxx.se/docs/copyright.html.\r
+ *\r
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell\r
+ * copies of the Software, and permit persons to whom the Software is\r
+ * furnished to do so, under the terms of the COPYING file.\r
+ *\r
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY\r
+ * KIND, either express or implied.\r
+ *\r
+ * $Id$\r
+ ***************************************************************************/\r
+\r
+#include "setup.h"\r
+\r
+#ifdef HAVE_MEMRCHR\r
+\r
+#ifdef HAVE_STRING_H\r
+# include <string.h>\r
+#endif\r
+#ifdef HAVE_STRINGS_H\r
+# include <strings.h>\r
+#endif\r
+\r
+#else /* HAVE_MEMRCHR */\r
+\r
+void *Curl_memrchr(const void *s, int c, size_t n);\r
+\r
+#define memrchr(x,y,z) Curl_memrchr((x),(y),(z))\r
+\r
+#endif /* HAVE_MEMRCHR */\r
+\r
+#endif /* HEADER_CURL_MEMRCHR_H */\r
progress.c security.c select.c sendf.c share.c speedcheck.c ssluse.c \
strequal.c strtok.c telnet.c timeval.c transfer.c url.c version.c \
sslgen.c gtls.c strerror.c rawstr.c curl_addrinfo.c curl_rand.c \
- socks_gssapi.c socks_sspi.c curl_sspi.c slist.c nonblock.c
+ socks_gssapi.c socks_sspi.c curl_sspi.c slist.c nonblock.c \
+ curl_memrchr.c
+
all: $(OBJS:.c=.o)
ar cru libcurl.a $(OBJS:.c=.o)
inet_ntop.c parsedate.c select.c gtls.c sslgen.c tftp.c splay.c \
strdup.c socks.c ssh.c nss.c qssl.c rawstr.c curl_addrinfo.c \
socks_gssapi.c socks_sspi.c curl_sspi.c slist.c nonblock.c \
- curl_rand.c
+ curl_rand.c curl_memrchr.c
USERINCLUDE ../../../lib ../../../include/curl
#ifdef ENABLE_SSL
C_SRC += content_encoding.c
C_SRC += cookie.c
C_SRC += curl_addrinfo.c
+C_SRC += curl_memrchr.c
C_SRC += curl_rand.c
C_SRC += curl_sspi.c
C_SRC += dict.c