[hackers] [ubase] Add weprintf() || sin
commit 6df1301594433963840b29d6ae42fb6de4b056c8
Author: sin <sin_AT_2f30.org>
Date: Wed Mar 12 16:18:29 2014 +0200
Add weprintf()
diff --git a/util.h b/util.h
index c478579..76feaa9 100644
--- a/util.h
+++ b/util.h
_AT_@ -19,3 +19,4 @@ size_t strlcat(char *, const char *, size_t);
#undef strlcpy
size_t strlcpy(char *, const char *, size_t);
char *ttytostr(int, int);
+void weprintf(const char *, ...);
diff --git a/util/eprintf.c b/util/eprintf.c
index 6d6fa65..bd4e090 100644
--- a/util/eprintf.c
+++ b/util/eprintf.c
_AT_@ -44,3 +44,20 @@ venprintf(int status, const char *fmt, va_list ap)
exit(status);
}
+
+void
+weprintf(const char *fmt, ...)
+{
+ va_list ap;
+
+ fprintf(stderr, "%s: ", argv0);
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+
+ if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
+ fputc(' ', stderr);
+ perror(NULL);
+ }
+}
Received on Wed Mar 12 2014 - 15:23:25 CET
This archive was generated by hypermail 2.3.0
: Wed Mar 12 2014 - 15:24:14 CET