Skip to content

Commit

Permalink
rename strlcpy so that it does not conflict with other tests; from
Browse files Browse the repository at this point in the history
Nick Mathewson.


svn:r306
  • Loading branch information
provos committed Jan 3, 2007
1 parent 894b636 commit 0db257b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ SYS_INCLUDES =
endif

libevent_la_SOURCES = event.c buffer.c evbuffer.c log.c event_tagging.c \
http.c evhttp.h http-internal.h evdns.c evdns.h evrpc.c \
evrpc.h evrpc-internal.h $(SYS_SRC)
http.c evhttp.h http-internal.h evdns.c evdns.h evrpc.c strlcpy.c \
evrpc.h evrpc-internal.h strlcpy-internal.h $(SYS_SRC)
libevent_la_LIBADD = @LTLIBOBJS@ $(SYS_LIBS)
libevent_la_LDFLAGS = -release @VERSION@ -version-info 1:3:0

Expand Down
3 changes: 1 addition & 2 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ AC_C_INLINE
AC_HEADER_TIME

dnl Checks for library functions.
AC_CHECK_FUNCS(gettimeofday vasprintf fcntl clock_gettime strtok_r strsep getaddrinfo getnameinfo)
AC_REPLACE_FUNCS(strlcpy)
AC_CHECK_FUNCS(gettimeofday vasprintf fcntl clock_gettime strtok_r strsep getaddrinfo getnameinfo strlcpy)

if test "x$ac_cv_func_clock_gettime" = "xyes"; then
AC_DEFINE(DNS_USE_CPU_CLOCK_FOR_ID, 1, [Define if clock_gettime is available in libc])
Expand Down
1 change: 1 addition & 0 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#undef timeout_pending
#undef timeout_initialized

#include "strlcpy-internal.h"
#include "event.h"
#include "evhttp.h"
#include "log.h"
Expand Down
23 changes: 23 additions & 0 deletions strlcpy-internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef _STRLCPY_INTERNAL_H_
#define _STRLCPY_INTERNAL_H_

#ifdef __cplusplus
extern "C" {
#endif

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */

#ifndef HAVE_STRLCPY
#include <string.h>
size_t _event_strlcpy(char *dst, const char *src, size_t siz);
#define strlcpy _event_strlcpy
#endif

#ifdef __cplusplus
}
#endif

#endif

6 changes: 4 additions & 2 deletions strlcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ static char *rcsid = "$OpenBSD: strlcpy.c,v 1.5 2001/05/13 15:40:16 deraadt Exp
#include "config.h"
#endif /* HAVE_CONFIG_H */

#include <string.h>
#ifndef HAVE_STRLCPY
#include "strlcpy-internal.h"

/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
size_t
strlcpy(dst, src, siz)
_event_strlcpy(dst, src, siz)
char *dst;
const char *src;
size_t siz;
Expand All @@ -72,3 +73,4 @@ strlcpy(dst, src, siz)

return(s - src - 1); /* count does not include NUL */
}
#endif
4 changes: 2 additions & 2 deletions test/regress_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ http_readcb(struct bufferevent *bev, void *arg)

event_debug(("%s: %s\n", __func__, EVBUFFER_DATA(bev->input)));

if (evbuffer_find(bev->input, what, strlen(what)) != NULL) {
if (evbuffer_find(bev->input, (const unsigned char*) what, strlen(what)) != NULL) {
struct evhttp_request *req = evhttp_request_new(NULL, NULL);
req->kind = EVHTTP_RESPONSE;
int done = evhttp_parse_lines(req, bev->input);
Expand Down Expand Up @@ -445,7 +445,7 @@ void
http_failure_readcb(struct bufferevent *bev, void *arg)
{
const char *what = "400 Bad Request";
if (evbuffer_find(bev->input, what, strlen(what)) != NULL) {
if (evbuffer_find(bev->input, (const unsigned char*) what, strlen(what)) != NULL) {
test_ok = 2;
bufferevent_disable(bev, EV_READ);
event_loopexit(NULL);
Expand Down

0 comments on commit 0db257b

Please sign in to comment.