Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: fusl/src/legacy/err.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/legacy/daemon.c ('k') | fusl/src/legacy/euidaccess.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/legacy/err.c
diff --git a/fusl/src/legacy/err.c b/fusl/src/legacy/err.c
new file mode 100644
index 0000000000000000000000000000000000000000..0d6ab5242d9b769b31ced7fcc1a62fd5273a402c
--- /dev/null
+++ b/fusl/src/legacy/err.c
@@ -0,0 +1,67 @@
+#include <err.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+extern char *__progname;
+
+void vwarn(const char *fmt, va_list ap)
+{
+ fprintf (stderr, "%s: ", __progname);
+ if (fmt) {
+ vfprintf(stderr, fmt, ap);
+ fputs (": ", stderr);
+ }
+ perror(0);
+}
+
+void vwarnx(const char *fmt, va_list ap)
+{
+ fprintf (stderr, "%s: ", __progname);
+ if (fmt) vfprintf(stderr, fmt, ap);
+ putc('\n', stderr);
+}
+
+_Noreturn void verr(int status, const char *fmt, va_list ap)
+{
+ vwarn(fmt, ap);
+ exit(status);
+}
+
+_Noreturn void verrx(int status, const char *fmt, va_list ap)
+{
+ vwarnx(fmt, ap);
+ exit(status);
+}
+
+void warn(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vwarn(fmt, ap);
+ va_end(ap);
+}
+
+void warnx(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vwarnx(fmt, ap);
+ va_end(ap);
+}
+
+_Noreturn void err(int status, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ verr(status, fmt, ap);
+ va_end(ap);
+}
+
+_Noreturn void errx(int status, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ verrx(status, fmt, ap);
+ va_end(ap);
+}
« no previous file with comments | « fusl/src/legacy/daemon.c ('k') | fusl/src/legacy/euidaccess.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698