File: error.c

package info (click to toggle)
nagircbot 0.0.33-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 296 kB
  • sloc: cpp: 3,293; sh: 208; makefile: 90; ansic: 66
file content (22 lines) | stat: -rw-r--r-- 427 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
#include <syslog.h>

void error_exit(char *format, ...)
{
	char buffer[4096];
	va_list ap;

	va_start(ap, format);
	vsnprintf(buffer, sizeof(buffer), format, ap);
	va_end(ap);

	fprintf(stderr, "%s: errno=%d (if applicable)\n", buffer, errno);
	syslog(LOG_ERR, "'%s': %m", buffer);

	exit(EXIT_FAILURE);
}