src/error.c File Reference

#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "rdd.h"
#include "rdd_internals.h"
#include "error.h"

Include dependency graph for error.c:

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>"


Define Documentation

#define CONSOLE   1

Definition at line 59 of file error.c.

#define LOGFP   ((logfp) == NULL ? stderr : (logfp))

Definition at line 78 of file error.c.

#define NO_CONSOLE   0

Definition at line 58 of file error.c.


Function Documentation

void bug ( char *  fmt,
  ... 
)

Reports a bug and aborts program execution.

Parameters:
fmt a printf-style message format string
The format string must be followed by its arguments, just like a printf-style format string. This function prints the message and then calls 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.

Here is the call graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

void error ( char *  fmt,
  ... 
)

Prints an error message and terminates the program.

Parameters:
fmt a printf-style message format string
The format string 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.

Definition at line 165 of file error.c.

References CONSOLE, log_flush(), log_printf(), log_vprintf(), and progname.

Here is the call graph for this function:

static void log_flush ( void   )  [static]

Definition at line 129 of file error.c.

References logfp.

static void log_printf ( int  console,
char *  fmt,
  ... 
) [static]

Definition at line 119 of file error.c.

References log_vprintf().

Here is the call graph for this function:

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().

Here is the call graph for this function:

void rdd_error ( int  errcode,
char *  fmt,
  ... 
)

Prints an rdd error message and terminates the program.

Parameters:
errcode an rdd error code
fmt a printf-style message format string
The 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().

Here is the call graph for this function:

void set_logfile ( FILE *  fp  ) 

Sets the log file.

Parameters:
fp a valid file pointer (open for writing)
This function sets the log file. All messages produced by this module are sent to the console or, if there is no console, to the standard error stream (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  ) 

Sets the program name that is used in future error messages.

Parameters:
name the program's name
This function must be called before any routine that produces a message.

Definition at line 135 of file error.c.

References progname.

void unix_error ( char *  fmt,
  ... 
)

Prints a Unix error message.

Parameters:
fmt a printf-style message format string
The format string 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 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.

Here is the call graph for this function:

void unix_warn ( char *  fmt,
  ... 
)

Prints a Unix warning message.

Parameters:
fmt a printf-style message format string
The format string must be followed by its arguments, just like a printf-style format string. This function prints the message. The message is followed by the error message that the program. The message is followed the error message that corresponds with the current value of Unix error variable 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.

Here is the call graph for this function:

void warn ( char *  fmt,
  ... 
)

Reports an warning message and terminates the program.

Parameters:
fmt a printf-style message format string
The format string must be followed by its arguments, just like a printf-style format string. This function prints the message. It does not terminate the program.

Definition at line 179 of file error.c.

References CONSOLE, log_flush(), log_printf(), log_vprintf(), and progname.

Here is the call graph for this function:


Variable Documentation

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"

Definition at line 64 of file error.c.

char copyright[] [static]

Initial value:

"@(#) Copyright (c) 2002\n\
    Netherlands Forensic Institute.  All rights reserved.\n"

Definition at line 39 of file error.c.

char* email_addr = PACKAGE_BUGREPORT [static]

Definition at line 62 of file error.c.

FILE* logfp = NULL [static]

Definition at line 72 of file error.c.

int new_line = 1 [static]

Definition at line 73 of file error.c.

char* progname = "<unknown program>" [static]

Definition at line 61 of file error.c.


Generated on Sun Feb 6 12:36:06 2011 for rdd by  doxygen 1.5.6