#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "rdd.h"
#include "rdd_internals.h"
#include "error.h"
Go to the source code of this file.
Defines | |
#define | CONSOLE 1 |
#define | LOGFP ((logfp) == NULL ? stderr : (logfp)) |
#define | NO_CONSOLE 0 |
Functions | |
void | bug (char *fmt,...) |
Reports a bug and aborts program execution. | |
void | errlog (char *fmt,...) |
Prints a message. | |
void | errlognl (char *fmt,...) |
Appends a newline to a message and then prints that message. | |
void | error (char *fmt,...) |
Prints an error message and terminates the program. | |
static void | log_flush (void) |
static void | log_printf (int console, char *fmt,...) |
static void | log_vprintf (int console, char *fmt, va_list ap) |
Sends a formatted message to a log file and optionally to the console. | |
void | rdd_error (int errcode, char *fmt,...) |
Prints an rdd error message and terminates the program. | |
void | set_logfile (FILE *fp) |
Sets the log file. | |
void | set_progname (char *name) |
Sets the program name that is used in future error messages. | |
void | unix_error (char *fmt,...) |
Prints a Unix error message. | |
void | unix_warn (char *fmt,...) |
Prints a Unix warning message. | |
void | warn (char *fmt,...) |
Reports an warning message and terminates the program. | |
Variables | |
static char * | bug_message_fmt |
static char | copyright [] |
static char * | email_addr = PACKAGE_BUGREPORT |
static FILE * | logfp = NULL |
static int | new_line = 1 |
static char * | progname = "<unknown program>" |
void bug | ( | char * | fmt, | |
... | ||||
) |
Reports a bug and aborts program execution.
fmt | a printf-style message format string |
abort()
to terminate the program.
Definition at line 150 of file error.c.
References bug_message_fmt, CONSOLE, email_addr, log_flush(), log_printf(), log_vprintf(), and progname.
void errlog | ( | char * | fmt, | |
... | ||||
) |
Prints a message.
Definition at line 221 of file error.c.
References CONSOLE, log_printf(), log_vprintf(), new_line, and rdd_ctime().
void errlognl | ( | char * | fmt, | |
... | ||||
) |
Appends a newline to a message and then prints that message.
Definition at line 235 of file error.c.
References CONSOLE, log_flush(), log_printf(), log_vprintf(), new_line, and rdd_ctime().
void error | ( | char * | fmt, | |
... | ||||
) |
Prints an error message and terminates the program.
fmt | a printf-style message format string |
exit()
to terminate the program.
Definition at line 165 of file error.c.
References CONSOLE, log_flush(), log_printf(), log_vprintf(), and progname.
static void log_printf | ( | int | console, | |
char * | fmt, | |||
... | ||||
) | [static] |
Definition at line 119 of file error.c.
References log_vprintf().
static void log_vprintf | ( | int | console, | |
char * | fmt, | |||
va_list | ap | |||
) | [static] |
Sends a formatted message to a log file and optionally to the console.
Definition at line 85 of file error.c.
References logfp, and rdd_cons_vprintf().
void rdd_error | ( | int | errcode, | |
char * | fmt, | |||
... | ||||
) |
Prints an rdd error message and terminates the program.
errcode | an rdd error code | |
fmt | a printf-style message format string |
fmt
must be followed by its arguments, just like a printf-style format string. This function prints the message and then calls exit()
to terminate the program. The message is followed by the error message that corresponds with rdd error code rc
.
Definition at line 251 of file error.c.
References CONSOLE, log_flush(), log_printf(), log_vprintf(), progname, RDD_NOMEM, RDD_OK, and rdd_strerror().
void set_logfile | ( | FILE * | fp | ) |
Sets the log file.
fp | a valid file pointer (open for writing) |
stderr
). If a valid log file (not NULL
) is specified then all messages are also written to that log file.
Definition at line 141 of file error.c.
References logfp.
void set_progname | ( | char * | name | ) |
void unix_error | ( | char * | fmt, | |
... | ||||
) |
Prints a Unix error message.
fmt | a printf-style message format string |
exit()
to terminate the program. The message is followed by the error message that corresponds with the current value of Unix error variable errno
.
Definition at line 206 of file error.c.
References CONSOLE, log_flush(), log_printf(), log_vprintf(), and progname.
void unix_warn | ( | char * | fmt, | |
... | ||||
) |
Prints a Unix warning message.
fmt | a printf-style message format string |
errno
. This function does not terminate the program.
Definition at line 192 of file error.c.
References CONSOLE, log_flush(), log_printf(), log_vprintf(), and progname.
void warn | ( | char * | fmt, | |
... | ||||
) |
Reports an warning message and terminates the program.
fmt | a printf-style message format string |
Definition at line 179 of file error.c.
References CONSOLE, log_flush(), log_printf(), log_vprintf(), and progname.
char* bug_message_fmt [static] |
Initial value:
"Rdd has crashed. Please do the following:\n" " 1. Write down the time of day reported by your computer.\n" " 2. If rdd dumped core, save a copy of the core file.\n" " 3. Save a copy of /var/log/messages.\n" " 4. Save a copy of your rdd binary.\n" " 4. Report this problem to %s.\n"
char copyright[] [static] |
char* email_addr = PACKAGE_BUGREPORT [static] |