forked from mattthias/slurm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.c
53 lines (48 loc) · 1.3 KB
/
error.c
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*****************************************************************************
*
* error.c - generic error handling function
*
*****************************************************************************
* $Id: error.c,v 1.1 2003/05/25 14:45:23 hscholz Exp $
****************************************************************************/
#ifndef _ERROR_C
#define _ERROR_C
#include "error.h"
/*****************************************************************************
*
* error()
*
* print error message and exit if asked for
*
****************************************************************************/
void error(int level, char *msg, ...)
{
va_list arguments;
int debug = 1;
va_start(arguments, msg);
switch (level) {
case ERR_DEBUG:
if (debug != 0)
fprintf(stderr, "DEBUG: ");
break;
case ERR_NOTICE:
fprintf(stderr, "NOTICE: ");
break;
case ERR_WARNING:
fprintf(stderr, "WARNING: ");
break;
case ERR_ERROR:
fprintf(stderr, "ERROR: ");
break;
case ERR_FATAL:
fprintf(stderr, "FATAL: ");
break;
}
/* print the remaining arguments */
vfprintf(stderr, msg, arguments);
va_end(arguments);
fprintf(stderr, "\n");
if (level == ERR_FATAL)
exit(1);
}
#endif