ERRORS(3)

NAME
errors - error handling subroutines fatal_error, coredump_error, warning, init_nnsubs, exit_nnsubs, get_program_name, get_command_line

SYNOPSIS

fatal_error(format [ , arg... ] )
char *format;

coredump_error(format [ , arg...] )
char *format;

warning(format [ , arg...] )
char *format;

init_nnsubs(argc, argv, rcsid)
int argc;
char *argv[];
char *rcsid;

exit_nnsubs()

char *get_program_name()

char *get_command_line()

DESCRIPTION
This is a package of error handling routines. The error routines, fatal_error, coredump_error and warning, take arguments of the sort used by printf. The errors are formatted and printed to the standard error stream stderr. When fatal_error is called, the error message is printed and the program exits with a value of -1. When coredump_error is called, the program writes a core file before exiting. When warning is called, an error message is printed to stderr. If the same warning is given multiple times, the message is printed once and the number of times it is repeated is counted. When the error message changes or exit_nnsubs is called, the number of times that same warning was given is printed. If init_nnsubs has been used, when an error is printed, the name of the program and the command line will also be printed. The arguments to init_nnsubs are the arguments of the main routine, argc and argv, and a third argument which is a string with some information about the version of the program being run. When init_nnsubs is used at the start of a program, it is necessary to call exit_nnsubs at the end. exit_nnsubs frees space allocated by init_nnsubs and finishes the printing of repeated warnings. The commands get_program_name and get_command_line return pointers to the strings stored when init_nnsubs was called.

EXAMPLES
main(argc, argv)
int argc;
char **argv;
{
  static char *rcsid = "version 1";
  init_nnsubs(argc, argv, rcsid);
  if(problem)
    warning("There is a problem with command %d", 1);
  if(big_problem)
    fatal_error("We can't continue because of %s",
                "problems with something");
  if(really_big_problem)
     coredump_error("%s %s","We have an error",
                    "and you had better check it out");
  exit_nnsubs();
}

SEE ALSO
printf(3)