aboutsummaryrefslogtreecommitdiffstats
path: root/util/alevt/misc.c
diff options
context:
space:
mode:
authorMark Purcell <msp@debian.org>2010-02-25 21:13:46 +1100
committeretobi <git@e-tobi.net>2013-09-03 09:48:46 +0200
commit665818f1969f893f05edf5b70eb1804c89b2829e (patch)
tree34ba68cee03c52d769a5a51b456b7e9d63cd091a /util/alevt/misc.c
parent109c7947d6a11a2a54eff1b19615ed80ea2f0602 (diff)
parent9fe4d4ea9c054e539ab679ed2e9c076c35beb69d (diff)
downloadlinux-dvb-apps-3a4100597b16fb9c0845fab3a54b14f0af8aa62b.tar.gz
Imported Debian patch 1.1.1+rev1355-1debian/1.1.1+rev1355-1
Diffstat (limited to '')
-rw-r--r--util/alevt/misc.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/util/alevt/misc.c b/util/alevt/misc.c
new file mode 100644
index 0000000..32d0595
--- /dev/null
+++ b/util/alevt/misc.c
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include "misc.h"
+
+char *prgname = 0;
+
+extern char *strrchr(const char *, int);
+NORETURN(exit(int));
+
+
+void setprgname(char *str)
+{
+ char *x = strrchr(str, '/');
+ prgname = x ? x+1 : str;
+}
+
+
+static void print_prgname(void)
+{
+ if (prgname && *prgname)
+ fprintf(stderr, "%s: ", prgname);
+}
+
+
+void error(const char *str, ...)
+{
+ va_list args;
+ va_start(args, str);
+ print_prgname();
+ vfprintf(stderr, str, args);
+ fputc('\n', stderr);
+}
+
+
+void ioerror(const char *str)
+{
+ print_prgname();
+ perror(str);
+}
+
+
+void fatal(const char *str, ...)
+{
+ va_list args;
+ va_start(args, str);
+ print_prgname();
+ vfprintf(stderr, str, args);
+ fputc('\n', stderr);
+ exit(2);
+}
+
+
+void fatal_ioerror(const char *str)
+{
+ print_prgname();
+ perror(str);
+ exit(2);
+}
+
+
+void out_of_mem(int size)
+{
+ if (size > 0)
+ fatal("out of memory allocating %d bytes.", size);
+ fatal("out of memory.");
+}