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
|
/* 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 <dusaint@earthlink.net>
*
* Started around 10 November 2001.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#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);
}
|