1 |
/* |
2 |
* This file is part of uudeview, the simple and friendly multi-part multi- |
3 |
* file uudecoder program (c) 1994-2001 by Frank Pilhofer. The author may |
4 |
* be contacted at fp@fpx.de |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
*/ |
16 |
|
17 |
#ifndef __UUINT_H__ |
18 |
#define __UUINT_H__ |
19 |
|
20 |
/* |
21 |
* This file describes the internal structures, variables and definitions |
22 |
* of UUDeview. It should not be included from other packages. Subject to |
23 |
* change without notice. Do not depend on anything here. |
24 |
*/ |
25 |
|
26 |
#if COMPILE_SEPERATELY |
27 |
#define UULIBINT_VAR extern |
28 |
#define UULIBINT_FUNC |
29 |
#else |
30 |
#define UULIBINT_VAR extern |
31 |
#define UULIBINT_FUNC static |
32 |
#endif |
33 |
|
34 |
/* |
35 |
* Busy Polls will be made after processing ... lines |
36 |
*/ |
37 |
|
38 |
#define BUSY_LINE_TICKS 50 |
39 |
|
40 |
/* |
41 |
* States of MIME scanner |
42 |
*/ |
43 |
|
44 |
#define MS_HEADERS 1 /* still inside of headers */ |
45 |
#define MS_BODY 2 /* body of `simple' messages */ |
46 |
#define MS_PREAMBLE 3 /* preamble of Multipart/Mixed */ |
47 |
#define MS_SUBPART 4 /* within one of the Multiparts */ |
48 |
#define MS_EPILOGUE 5 /* epilogue of Multipart/Mixed */ |
49 |
|
50 |
/* |
51 |
* Number of subsequent encoded lines we require to believe this |
52 |
* is valid data. |
53 |
*/ |
54 |
|
55 |
#define ELC_COUNT 4 |
56 |
|
57 |
/* |
58 |
* Flags a part may have. FL_PROPER means that we are sure about the file's |
59 |
* encoding, beginning and end, and don't have to use special care when de- |
60 |
* coding. |
61 |
*/ |
62 |
|
63 |
#define FL_NONE 0 /* no flag, just plain normal */ |
64 |
#define FL_SINGLE 1 /* standalone MSG, do not mix */ |
65 |
#define FL_PARTIAL 2 /* from Message/Partial */ |
66 |
#define FL_PROPER 4 /* proper MIME part */ |
67 |
#define FL_TOEND 8 /* part continues to EOF */ |
68 |
|
69 |
/* |
70 |
* Auxiliary macro: compute the percentage of a against b. |
71 |
* The obvious answer is (100*a)/b, but this overflows for large a. |
72 |
* a/(b/100) is better; we use a/((b/100)+1) so that we don't divide |
73 |
* by zero for b<100 and the result doesn't become larger than 100% |
74 |
*/ |
75 |
|
76 |
#define UUPERCENT(a,b) ((int) ((unsigned long)(a) / \ |
77 |
(((unsigned long)(b)/100)+1))) |
78 |
|
79 |
/* |
80 |
* Make the Busy Callback easier. The macro returns true if the BusyCallback |
81 |
* wants us to terminate. |
82 |
*/ |
83 |
|
84 |
UULIBINT_VAR unsigned long uuyctr; |
85 |
#define UUBUSYPOLL(a,b) (((++uuyctr%BUSY_LINE_TICKS)==0) ? (progress.percent=UUPERCENT((a),(b)),UUBusyPoll()):0) |
86 |
|
87 |
/* |
88 |
* How many lines of headers do we need to believe another mail |
89 |
* header is approaching? Use more restrictive values for MIME |
90 |
* mails, less restrictive for Freestyle |
91 |
*/ |
92 |
|
93 |
typedef struct { |
94 |
int restart; /* restarting after a MIME body (not subpart) */ |
95 |
int afterdata; /* after we had useful data in freestyle mode */ |
96 |
int afternl; /* after an empty line in freestyle mode */ |
97 |
} headercount; |
98 |
|
99 |
UULIBINT_VAR headercount hlcount; |
100 |
|
101 |
/* |
102 |
* Information from the headers of a message. Each instance must |
103 |
* have its very own copy of the strings. If `mimevers' is NULL, |
104 |
* then this message does not comply to the MIME standard. |
105 |
*/ |
106 |
|
107 |
typedef struct _headers { |
108 |
char *from; /* From: */ |
109 |
char *subject; /* Subject: */ |
110 |
char *rcpt; /* To: */ |
111 |
char *date; /* Date: */ |
112 |
char *mimevers; /* MIME-Version: */ |
113 |
char *ctype; /* Content-Type: */ |
114 |
char *ctenc; /* Content-Transfer-Encoding: */ |
115 |
char *fname; /* Potential Filename from Content-Type Parameter */ |
116 |
char *boundary; /* MIME-Boundary from Content-Type Parameter */ |
117 |
char *mimeid; /* MIME-Id for Message/Partial */ |
118 |
int partno; /* part number for Message/Partial */ |
119 |
int numparts; /* number of parts for Message/Partial */ |
120 |
} headers; |
121 |
|
122 |
/* |
123 |
* Scanner state |
124 |
*/ |
125 |
|
126 |
typedef struct _scanstate { |
127 |
int isfolder; /* if we think this is a valid email folder */ |
128 |
int ismime; /* if we are within a valid MIME message */ |
129 |
int mimestate; /* state of MIME scanner */ |
130 |
int mimeenc; /* encoding of this MIME file */ |
131 |
char *source; /* source filename */ |
132 |
headers envelope; /* mail envelope headers */ |
133 |
} scanstate; |
134 |
|
135 |
UULIBINT_VAR void *uu_MsgCBArg; |
136 |
UULIBINT_VAR void *uu_BusyCBArg; |
137 |
UULIBINT_VAR void *uu_FileCBArg; |
138 |
UULIBINT_VAR void *uu_FFCBArg; |
139 |
UULIBINT_VAR void *uu_FNCBArg; |
140 |
|
141 |
/* |
142 |
* variables |
143 |
*/ |
144 |
|
145 |
UULIBINT_VAR int uu_autocheck; |
146 |
UULIBINT_VAR int uu_rbuf; |
147 |
UULIBINT_VAR int uu_wbuf; |
148 |
#define UUSETBUF(fp,buff,size) if (size) setvbuf ((fp), ((buff) = malloc (size)), _IOFBF, (size)) |
149 |
#define UUCLRBUF(size,buff) if (size) free (buff) |
150 |
|
151 |
UULIBINT_VAR int uu_fast_scanning; |
152 |
UULIBINT_VAR int uu_bracket_policy; |
153 |
UULIBINT_VAR int uu_verbose; |
154 |
UULIBINT_VAR int uu_desperate; |
155 |
UULIBINT_VAR int uu_ignreply; |
156 |
UULIBINT_VAR int uu_debug; |
157 |
UULIBINT_VAR int uu_errno; |
158 |
UULIBINT_VAR int uu_dumbness; |
159 |
UULIBINT_VAR int uu_overwrite; |
160 |
UULIBINT_VAR int uu_ignmode; |
161 |
UULIBINT_VAR int uu_headercount; |
162 |
UULIBINT_VAR int uu_usepreamble; |
163 |
UULIBINT_VAR int uu_handletext; |
164 |
UULIBINT_VAR int uu_tinyb64; |
165 |
UULIBINT_VAR int uu_remove_input; |
166 |
UULIBINT_VAR int uu_more_mime; |
167 |
UULIBINT_VAR int uu_dotdot; |
168 |
|
169 |
UULIBINT_VAR char *uusavepath; |
170 |
UULIBINT_VAR char *uuencodeext; |
171 |
|
172 |
/* |
173 |
* Encoding/Decoding tables |
174 |
*/ |
175 |
|
176 |
UULIBINT_VAR unsigned char UUEncodeTable[]; |
177 |
UULIBINT_VAR unsigned char XXEncodeTable[]; |
178 |
UULIBINT_VAR unsigned char B64EncodeTable[]; |
179 |
UULIBINT_VAR unsigned char BHEncodeTable[]; |
180 |
|
181 |
/* |
182 |
* String tables from uustring.c |
183 |
*/ |
184 |
|
185 |
UULIBINT_VAR char *msgnames[]; |
186 |
UULIBINT_VAR char *codenames[]; |
187 |
UULIBINT_VAR char *uuretcodes[]; |
188 |
|
189 |
/* |
190 |
* State of MIME variables and current progress |
191 |
*/ |
192 |
|
193 |
UULIBINT_VAR int nofnum, mssdepth; |
194 |
UULIBINT_VAR int mimseqno, lastvalid; |
195 |
UULIBINT_VAR int lastenc; |
196 |
UULIBINT_VAR scanstate multistack[]; |
197 |
UULIBINT_VAR headers localenv; |
198 |
UULIBINT_VAR scanstate sstate; |
199 |
UULIBINT_VAR uuprogress progress; |
200 |
|
201 |
/* |
202 |
* mallocable areas |
203 |
*/ |
204 |
|
205 |
UULIBINT_VAR char *uugen_fnbuffer, *uugen_inbuffer; |
206 |
UULIBINT_VAR char *uucheck_lastname, *uucheck_tempname; |
207 |
UULIBINT_VAR char *uuestr_itemp, *uuestr_otemp; |
208 |
UULIBINT_VAR char *uulib_msgstring, *uuncdl_fulline; |
209 |
UULIBINT_VAR char *uuncdp_oline, *uuscan_shlline, *uuscan_shlline2; |
210 |
UULIBINT_VAR char *uuscan_pvvalue, *uuscan_phtext; |
211 |
UULIBINT_VAR char *uuscan_sdline, *uuscan_sdbhds1; |
212 |
UULIBINT_VAR char *uuscan_sdbhds2, *uuscan_spline; |
213 |
UULIBINT_VAR char *uuutil_bhwtmp; |
214 |
UULIBINT_VAR char *uunconc_UUxlat, *uunconc_UUxlen; |
215 |
UULIBINT_VAR char *uunconc_B64xlat, *uunconc_XXxlat; |
216 |
UULIBINT_VAR char *uunconc_BHxlat, *uunconc_save; |
217 |
|
218 |
#ifdef __cplusplus |
219 |
extern "C" { |
220 |
#endif |
221 |
|
222 |
/* |
223 |
* Functions from uulib.c that aren't defined in <uudeview.h> |
224 |
* Be careful about the definition with variable arguments. |
225 |
*/ |
226 |
|
227 |
#define UUMessage(level, ...) UUMessage_ (__FILE__, __LINE__, level, __VA_ARGS__) |
228 |
UULIBINT_FUNC int UUMessage_ (char *, int, int, char *, ...); |
229 |
UULIBINT_FUNC int UUBusyPoll (void); |
230 |
|
231 |
/* |
232 |
* Functions from uucheck.c |
233 |
*/ |
234 |
|
235 |
UULIBINT_FUNC uufile * UUPreProcessPart (fileread *, int *); |
236 |
UULIBINT_FUNC int UUInsertPartToList (uufile *); |
237 |
|
238 |
/* |
239 |
* Functions from uuutil.c |
240 |
*/ |
241 |
|
242 |
UULIBINT_FUNC void UUkillfread (fileread *); |
243 |
UULIBINT_FUNC void UUkillfile (uufile *); |
244 |
UULIBINT_FUNC void UUkilllist (uulist *); |
245 |
UULIBINT_FUNC void UUkillheaders (headers *); |
246 |
|
247 |
UULIBINT_FUNC fileread *ScanPart (FILE *, char *, int *); |
248 |
|
249 |
UULIBINT_FUNC int UUbhdecomp (char *, char *, |
250 |
char *, int *, |
251 |
size_t, size_t, |
252 |
size_t *); |
253 |
UULIBINT_FUNC size_t UUbhwrite (char *, size_t, size_t, FILE *); |
254 |
|
255 |
/* |
256 |
* Functions from uunconc.c |
257 |
*/ |
258 |
|
259 |
UULIBINT_FUNC int UURepairData (FILE *, char *, int, int *); |
260 |
|
261 |
UULIBINT_FUNC void UUInitConc _ANSI_ARGS_((void)); |
262 |
UULIBINT_FUNC int UUValidData _ANSI_ARGS_((char *, int, int *)); |
263 |
UULIBINT_FUNC size_t UUDecodeLine _ANSI_ARGS_((char *, char *, int)); |
264 |
UULIBINT_FUNC int UUDecodeField _ANSI_ARGS_((char *, char *, int)); |
265 |
UULIBINT_FUNC int UUDecodePart _ANSI_ARGS_((FILE *, FILE *, int *, |
266 |
long, int, int, char *)); |
267 |
UULIBINT_FUNC int UUDecode _ANSI_ARGS_((uulist *)); |
268 |
|
269 |
/* |
270 |
* Message retrieval from uustring.c |
271 |
*/ |
272 |
|
273 |
UULIBINT_FUNC char * uustring (int); |
274 |
|
275 |
/* |
276 |
* From uuscan.c |
277 |
*/ |
278 |
|
279 |
UULIBINT_FUNC int UUScanHeader (FILE *, headers *); |
280 |
|
281 |
#ifdef __cplusplus |
282 |
} |
283 |
#endif |
284 |
#endif |