X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/9486289ce452ab82ca8b3f16fae8c2ef5247a923..7a6421fa764dd0f609e2a5024ec8b3bc577575a1:/util.c diff --git a/util.c b/util.c index 59f94182..9b28cb03 100644 --- a/util.c +++ b/util.c @@ -446,58 +446,12 @@ void kill_all(int sig) } } -/* this is the rsync debugging function. Call it with FINFO or FERROR */ -void rprintf(int fd, const char *format, ...) +/* like strncpy but does not 0 fill the buffer and always null + terminates (thus it can use maxlen+1 space in d) */ +void strlcpy(char *d, char *s, int maxlen) { - va_list ap; - char buf[1024]; - int len; - FILE *f=NULL; - - va_start(ap, format); - -#if HAVE_VSNPRINTF - len = vsnprintf(buf, sizeof(buf)-1, format, ap); -#else - len = vsprintf(buf, format, ap); -#endif - va_end(ap); - - if (len < 0) exit_cleanup(1); - - if (fd == FERROR) { - f = stderr; - } - - if (fd == FINFO) { - extern int am_server; - if (am_server) - f = stderr; - else - f = stdout; - } - - if (!f) exit_cleanup(1); - - if (fwrite(buf, len, 1, f) != 1) exit_cleanup(1); -} - -void rflush(int fd) -{ - FILE *f = NULL; - - if (fd == FERROR) { - f = stderr; - } - - if (fd == FINFO) { - extern int am_server; - if (am_server) - f = stderr; - else - f = stdout; - } - - if (!f) exit_cleanup(1); - fflush(f); + int len = strlen(s); + if (len > maxlen) len = maxlen; + memcpy(d, s, len); + d[len] = 0; }