-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.cpp
248 lines (229 loc) · 5.3 KB
/
errors.cpp
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
// MaxiM: Ported, not changed
#include "partoss.h"
#include "globext.h"
#include "errors.h"
#include "lowlevel.h"
#include "morfiles.h"
#include "partsqd.h"
#if defined (__linux__) || defined (__FreeBSD__)
#include "locks.h"
#endif
void errexit(short error, char *file, unsigned short line)
{
short retcode = 0, asis = 0;
/* long bloglen=0; */
char hfile[DirSize + 1];
switch (error)
{
case 0:
retcode = 0;
break;
case 1:
sprintf(logout, "!!! Memory allocation error");
retcode = -1;
break;
case 2:
sprintf(logout, "!!! File %s open/create error, OS error %d", errname, errno);
retcode = -1;
break;
case 3:
#ifdef __DOS__
sprintf(logout, "!!! SWAP error - not enough memory or disk space for swapping");
#else
sprintf(logout, "!!! SPAWN error - not enough resources for run external progpam");
#endif
retcode = -2;
break;
case 4:
sprintf(logout, "!!! Internal program error, OS error %d", errno);
retcode = -3;
break;
case 5:
sprintf(logout, "!!! Unknown area name %s", errname);
retcode = 11;
break;
case 6:
sprintf(logout, "!!! Can't find file %s", errname);
retcode = 10;
break;
case 7:
sprintf(logout, "!!! Read/write error, OS error %d", errno);
retcode = -1;
break;
case 8:
case 9:
sprintf(logout, "!!! Can't find %s", error == 8 ? "BadArea" : "DupeArea");
retcode = 11;
break;
case 10:
ccprintf("\r\nUsage:\r\n ParToss [<key...>] <command...> [<node>],\r\n\r\n");
ccprintf("Keys: -c<filename> | -f<filename> | -q | -t\r\n");
ccprintf("Commands: In, Out, Pack, Send, Squash, Link, LinkF, Post, PostF, PostD,\r\n");
ccprintf(" Purge, Kill, Serv, Hand, HandN, ReScan, Bad, ReLink, UnToss\r\n");
ccprintf("Node - full or short 4-D FTN address\r\n\r\n");
ccprintf("For further information about keys and commands read ParToss.Doc\r\n");
retcode = 9;
break;
case 11:
sprintf(logout, "!!! Write error (maybe disk full)");
retcode = -1;
break;
case 12:
sprintf(logout, "!!! Area %s damaged, use SQFix", rcurarea);
retcode = 12;
break;
case 13:
sprintf(logout, "!!! Error while file %s rename/move", errname);
retcode = 13;
break;
case 14:
sprintf(logout, "!!! It's seems that ParToss already ran");
retcode = 14;
break;
case 15:
sprintf(logout, "!!! Emergency exit - internal error");
retcode = 15;
break;
}
closesqd(newarea, 0);
closesqd(persarea, 0);
closesqd(badmess, 0);
closesqd(dupes, 0);
if(bsyname[0])
unlink(bsyname);
if(bsynamef[0])
unlink(bsynamef);
if(retcode && retcode != 9)
{
if(logfileok)
logwrite(1, 1);
ccprintf("%s\r\n", logout);
}
if(retcode < 0)
{
sprintf(logout, "!!! Error was encountered in line %u of source file %s", line, file);
if(logfileok)
logwrite(1, 1);
ccprintf("%s\r\n", logout);
}
if(tottoss || totsent || totpers || totdupes || totbad)
{
asis = 0;
sprintf(logout, "Total:");
if(tottoss)
{
sprintf(areasbbs, " toss - %u", tottoss);
mystrncat(logout, (char *)areasbbs, DirSize, BufSize);
asis = 1;
}
if(totsent)
{
sprintf(areasbbs, "%s sent - %u", asis ? "," : "", totsent);
mystrncat(logout, areasbbs, DirSize, BufSize);
asis = 1;
}
if(totpers)
{
sprintf(areasbbs, "%s personal - %u", asis ? "," : "", totpers);
mystrncat(logout, areasbbs, DirSize, BufSize);
asis = 1;
}
if(totdupes)
{
sprintf(areasbbs, "%s dupes - %u", asis ? "," : "", totdupes);
mystrncat(logout, areasbbs, DirSize, BufSize);
asis = 1;
}
if(totbad)
{
sprintf(areasbbs, "%s bad - %u", asis ? "," : "", totbad);
mystrncat(logout, areasbbs, DirSize, BufSize);
asis = 1;
}
if(logfileok)
logwrite(1, 1);
ccprintf("\r\n%s\r\n", logout);
}
if(ttempl)
{
Close(ttempl);
ttempl = 0;
mystrncpy(hfile, bcfg.workdir, DirSize);
mystrncat(hfile, "keytempl.$$$", DirSize, DirSize);
unlink(hfile);
}
if(temppkt)
{
Close(temppkt);
temppkt = 0;
unlink(temppktn);
}
if(areaset)
{
Close(areaset);
areaset = 0;
}
#if defined (__linux__) || defined (__FreeBSD__)
removelock(lockname);
lck = 0;
#endif
cfname[strlen(cfname) - 1] = 'a';
unlink(cfname);
if(areandx)
{
Close(areandx);
areandx = 0;
}
cfname[strlen(cfname) - 1] = 'i';
unlink(cfname);
if(areadesc)
{
Close(areadesc);
areadesc = 0;
}
cfname[strlen(cfname) - 1] = 'd';
unlink(cfname);
if(areapool)
{
Close(areapool);
areapool = 0;
}
cfname[strlen(cfname) - 1] = 'p';
unlink(cfname);
if(compset)
{
Close(compset);
compset = 0;
}
cfname[strlen(cfname) - 1] = 'c';
unlink(cfname);
if(logfileok)
{
sprintf(logout, "End, ParToss %s\r\n", version);
logwrite(1, 1);
Close(logfile);
logfile = 0;
logfileok = 0;
}
ccprintf("The Parma Tosser version %s finished.\r\n", version);
if(alog)
{
Close(alog);
alog = 0;
}
if(dupreserv)
{
Close(dupreserv);
dupreserv = 0;
}
#ifdef __DOS__
unclosed = closeHandles();
if(unclosed)
ccprintf("%d unclosed handle(s) found\r\n", unclosed);
disableHandles();
#endif
#ifdef __NT__
SetConsoleTitle("ParToss was here");
#endif
exit(retcode);
}