mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
switch all uses of [v]snprintf to evutil
svn:r889
This commit is contained in:
parent
877fa44dda
commit
130a8a1308
@ -1,5 +1,6 @@
|
||||
Changes in 1.4.6-stable:
|
||||
o evutil.h now includes <stdarg.h> directly
|
||||
o switch all uses of [v]snprintf over to evutil
|
||||
|
||||
Changes in 1.4.5-stable:
|
||||
o Fix connection keep-alive behavior for HTTP/1.0
|
||||
|
8
buffer.c
8
buffer.c
@ -63,6 +63,7 @@
|
||||
|
||||
#include "event.h"
|
||||
#include "config.h"
|
||||
#include "evutil.h"
|
||||
|
||||
struct evbuffer *
|
||||
evbuffer_new(void)
|
||||
@ -154,12 +155,7 @@ evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap)
|
||||
#endif
|
||||
va_copy(aq, ap);
|
||||
|
||||
#ifdef WIN32
|
||||
sz = vsnprintf(buffer, space - 1, fmt, aq);
|
||||
buffer[space - 1] = '\0';
|
||||
#else
|
||||
sz = vsnprintf(buffer, space, fmt, aq);
|
||||
#endif
|
||||
sz = evutil_vsnprintf(buffer, space, fmt, aq);
|
||||
|
||||
va_end(aq);
|
||||
|
||||
|
16
evdns.c
16
evdns.c
@ -140,7 +140,6 @@ typedef unsigned int uint;
|
||||
#define u8 ev_uint8_t
|
||||
|
||||
#ifdef WIN32
|
||||
#define snprintf _snprintf
|
||||
#define open _open
|
||||
#define read _read
|
||||
#define close _close
|
||||
@ -385,7 +384,7 @@ debug_ntoa(u32 address)
|
||||
{
|
||||
static char buf[32];
|
||||
u32 a = ntohl(address);
|
||||
snprintf(buf, sizeof(buf), "%d.%d.%d.%d",
|
||||
evutil_snprintf(buf, sizeof(buf), "%d.%d.%d.%d",
|
||||
(int)(u8)((a>>24)&0xff),
|
||||
(int)(u8)((a>>16)&0xff),
|
||||
(int)(u8)((a>>8 )&0xff),
|
||||
@ -416,11 +415,7 @@ _evdns_log(int warn, const char *fmt, ...)
|
||||
if (!evdns_log_fn)
|
||||
return;
|
||||
va_start(args,fmt);
|
||||
#ifdef WIN32
|
||||
_vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
#else
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
#endif
|
||||
evutil_vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
evdns_log_fn(warn, buf);
|
||||
va_end(args);
|
||||
@ -706,7 +701,8 @@ reply_handle(struct request *const req, u16 flags, u32 ttl, struct reply *reply)
|
||||
/* we regard these errors as marking a bad nameserver */
|
||||
if (req->reissue_count < global_max_reissues) {
|
||||
char msg[64];
|
||||
snprintf(msg, sizeof(msg), "Bad response %d (%s)",
|
||||
evutil_snprintf(msg, sizeof(msg),
|
||||
"Bad response %d (%s)",
|
||||
error, evdns_err_to_string(error));
|
||||
nameserver_failed(req->ns, msg);
|
||||
if (!request_reissue(req)) return;
|
||||
@ -1564,7 +1560,7 @@ evdns_server_request_add_ptr_reply(struct evdns_server_request *req, struct in_a
|
||||
assert(!(in && inaddr_name));
|
||||
if (in) {
|
||||
a = ntohl(in->s_addr);
|
||||
snprintf(buf, sizeof(buf), "%d.%d.%d.%d.in-addr.arpa",
|
||||
evutil_snprintf(buf, sizeof(buf), "%d.%d.%d.%d.in-addr.arpa",
|
||||
(int)(u8)((a )&0xff),
|
||||
(int)(u8)((a>>8 )&0xff),
|
||||
(int)(u8)((a>>16)&0xff),
|
||||
@ -2283,7 +2279,7 @@ int evdns_resolve_reverse(struct in_addr *in, int flags, evdns_callback_type cal
|
||||
u32 a;
|
||||
assert(in);
|
||||
a = ntohl(in->s_addr);
|
||||
snprintf(buf, sizeof(buf), "%d.%d.%d.%d.in-addr.arpa",
|
||||
evutil_snprintf(buf, sizeof(buf), "%d.%d.%d.%d.in-addr.arpa",
|
||||
(int)(u8)((a )&0xff),
|
||||
(int)(u8)((a>>8 )&0xff),
|
||||
(int)(u8)((a>>16)&0xff),
|
||||
|
Loading…
x
Reference in New Issue
Block a user