aboutsummaryrefslogtreecommitdiff
path: root/client/global.c
blob: bf5bf2e2bd49ec2758339831fe10df2c55383278 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include "global.h"

__attribute__((noreturn, format(printf, 1, 2)))
void die(const char *format,...){
	fprintf(stderr,"DIE: ");
	va_list ap;
	va_start(ap,format);
	vfprintf(stderr,format,ap);
	va_end(ap);
	fputc('\n',stderr);
	exit(1);
}

__attribute__((noreturn))
void die_perror(const char *func){
	fprintf(stderr,"DIE: %s: %s\n",func,strerror(errno));
	exit(1);
}

__attribute__((format (printf, 1, 2)))
void debug(const char *format,...){
	fprintf(stderr,"DEBUG: ");
	va_list ap;
	va_start(ap,format);
	vfprintf(stderr,format,ap);
	va_end(ap);
	fputc('\n',stderr);
}