/* error.c * This file is part of Decomp - a decompiler. In this file are * various error routines and the message table used by * error_out (). * * Copyright (C) 2001, Jonathan duSaint * * Started around 10 November 2001. */ #include #include #include #include #include "decomp.h" char *message_table[] = { "internal error", "need input file name", "unable to get information on input file", "unable to deallocate resources used by input file", "unable to open a file", "unable to read input file", "invalid input file", "unrecognized file format", "unable to read entire section", }; /* panic * A library function failed that really shouldn't have and to try * to continue would be senseless. */ void panic (long line, char *file) { fprintf (stderr, "%s: PANIC at %ld of %s: %s\n", pname, line, file, strerror (errno)); abort (); } /* error_out * Some kind of error occurred which isn't necessarily disastrous, but * it would be kind of hard to continue. */ void error_out_internal (int error_index, long where, char *location) { fprintf (stderr, "%s: %s at %ld in %s%s%s\n", pname, message_table[error_index], where, location, (errno != 0) ? ": " : "", (errno != 0) ? strerror (errno) : ""); exit (EXIT_FAILURE); }