Update kris/util.c strlcpy

This commit is contained in:
Kris Maglione 2009-09-23 11:26:48 -04:00
parent 14e430ac5b
commit 2b85380411
4 changed files with 11 additions and 10 deletions

1
kris/Makefile Symbolic link
View File

@ -0,0 +1 @@
../Makefile

1
kris/config.mk Symbolic link
View File

@ -0,0 +1 @@
../config.mk

View File

@ -28,14 +28,6 @@ static char channel[256];
static time_t trespond; static time_t trespond;
static FILE *srv; static FILE *srv;
#define va_buf(buf, fmt) {\
va_list ap; \
\
va_start(ap, fmt); \
vsnprintf(buf, sizeof buf, fmt, ap); \
va_end(ap); \
}
#include "util.c" #include "util.c"
static void static void
@ -167,7 +159,7 @@ main(int argc, char *argv[]) {
if(++i < argc) password = argv[i]; if(++i < argc) password = argv[i];
break; break;
case 'v': case 'v':
eprint("sic-"VERSION", ? 2005-2007 Anselm R. Garbe, Nico Golde\n"); eprint("sic-"VERSION", ©2005-2009 Kris Maglione, Anselm R. Garbe, Nico Golde\n");
default: default:
eprint("usage: sic [-h host] [-p port] [-n nick] [-k keyword] [-v]\n"); eprint("usage: sic [-h host] [-p port] [-n nick] [-k keyword] [-v]\n");
} }

View File

@ -2,6 +2,13 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/socket.h> #include <sys/socket.h>
#define va_buf(buf, fmt) {\
va_list ap; \
va_start(ap, fmt); \
vsnprintf(buf, sizeof buf, fmt, ap); \
va_end(ap); \
}
static void static void
eprint(const char *fmt, ...) { eprint(const char *fmt, ...) {
@ -34,7 +41,7 @@ dial(char *host, int port) {
#define strlcpy _strlcpy #define strlcpy _strlcpy
static void static void
strlcpy(char *to, const char *from, int l) { strlcpy(char *to, const char *from, int l) {
strncpy(to, from, l-1); memccpy(to, from, '\0', l);
to[l-1] = '\0'; to[l-1] = '\0';
} }