1 /***********************************************************************
2 This file is part of HA, a general purpose file archiver.
3 Copyright (C) 1995 Harri Hirvola
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 ************************************************************************
19 HA error handling
20 ***********************************************************************/
21
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <stdarg.h>
25 #include "ha.h"
26 #include "error.h"
27
28 int inerror=0,lasterror=0;
29
30 char *error_string[]={
31 "Error in error handling !!!",
32 "Unknown error",
33 "Command %c not implemented",
34 "Could not open archive %s",
35 "Out of memory in %s",
36 "%s is not a HA archive",
37 "Write error on %s",
38 "Read error on %s",
39 "Got signal %d",
40 "No files found",
41 "Could not remove %s",
42 "Invalid switch %c",
43 "Archive needs newer version of HA",
44 "Archive made with unsupported version",
45 "Unknown compression method %d",
46 "Lseek error in %s",
47 "Could not open file %s",
48 "Could not make directory %s",
49 "CRC error",
50 "Write error",
51 "Could not get file status for %s",
52 "Could not open directory %s",
53 "Archive corrupted !",
54 "Wrong size for %s",
55 "Don't know how to handle %s",
56 "Could not read symlink %s",
57 "Could not link %s to %s",
58 "Could not make fifo %s",
59 };
60
61
error(int fatal,int number,...)62 void error(int fatal, int number, ...) {
63
64 va_list argptr;
65
66 fflush(stdout);
67 if (inerror) {
68 fprintf(stderr,"\n%s: ",myname);
69 fprintf(stderr,error_string[0]);
70 fprintf(stderr,"\n");
71 fflush(stderr);
72 exit(inerror);
73 }
74 inerror=number;
75 fprintf(stderr,"\n%s: ",myname);
76 va_start(argptr,number);
77 vfprintf(stderr,error_string[number],argptr);
78 fprintf(stderr,"\n");
79 fflush(stderr);
80 if (!fatal) {
81 lasterror=inerror;
82 inerror=0;
83 return;
84 }
85 cu_do(NULL);
86 exit(number);
87 }
88
89