File: error.c

package info (click to toggle)
slurm 0.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 860 kB
  • ctags: 226
  • sloc: sh: 3,491; ansic: 2,722; makefile: 54
file content (54 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download | duplicates (7)
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
54
/*****************************************************************************
 *
 * 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