2013-08-06 11:16:27 +00:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "../util.h"
|
|
|
|
|
|
|
|
char *argv0;
|
|
|
|
|
|
|
|
static void venprintf(int, const char *, va_list);
|
|
|
|
|
|
|
|
void
|
|
|
|
eprintf(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
venprintf(EXIT_FAILURE, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
enprintf(int status, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
venprintf(status, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
venprintf(int status, const char *fmt, va_list ap)
|
|
|
|
{
|
2013-08-12 10:03:53 +00:00
|
|
|
/*fprintf(stderr, "%s: ", argv0);*/
|
|
|
|
|
2013-08-06 11:16:27 +00:00
|
|
|
vfprintf(stderr, fmt, ap);
|
|
|
|
|
|
|
|
if(fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
|
|
|
fputc(' ', stderr);
|
|
|
|
perror(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit(status);
|
|
|
|
}
|