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 55 56 57 58
|
/*
* lib/util/error.c
*
* Copyright (C) 1997,1998 Russell King
*/
#include <stdarg.h>
#include <stdio.h>
#include "util/error.h"
static char errmsg[2048];
static int error_set;
/* Function: void set_error (const char *fmt, ...)
* Purpose : Set error string
* Params : fmt - printf-like format
*/
void set_error (const char *fmt, ...)
{
va_list ap;
if (fmt) {
va_start (ap, fmt);
vsprintf (errmsg, fmt, ap);
va_end (ap);
error_set = 1;
} else {
errmsg[0] = '\0';
error_set = 0;
}
}
/* Function: const char *get_error(void)
* Purpose : Get error string
* Returns : const pointer to error message buffer
*/
const char *get_error(void)
{
error_set = 0;
return errmsg;
}
/* Function: u_int is_error_set(void)
* Purpose : check to see if an error is set
* Returns : FALSE if not set
*/
u_int is_error_set(void)
{
return error_set;
}
/* Function: void clear_error(void)
* Purpose : clear error condition
*/
void clear_error(void)
{
error_set = 0;
}
|