ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/uuint.h
Revision: 1.2.2.4
Committed: Thu Nov 6 13:08:24 2003 UTC (20 years, 6 months ago) by root
Content type: text/plain
Branch: UUDEVIEW
CVS Tags: UUDEVIEW-0-5-19
Changes since 1.2.2.3: +3 -2 lines
Log Message:
*** empty log message ***

File Contents

# Content
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 * $Id: uuint.h,v 1.19 2003/04/12 23:18:31 fp Exp $
26 */
27
28 #ifndef _ANSI_ARGS_
29 #ifdef PROTOTYPES
30 #define _ANSI_ARGS_(c) c
31 #else
32 #define _ANSI_ARGS_(c) ()
33 #endif
34 #endif
35
36 /*
37 * Busy Polls will be made after processing ... lines
38 */
39
40 #define BUSY_LINE_TICKS 50
41
42 /*
43 * States of MIME scanner
44 */
45
46 #define MS_HEADERS 1 /* still inside of headers */
47 #define MS_BODY 2 /* body of `simple' messages */
48 #define MS_PREAMBLE 3 /* preamble of Multipart/Mixed */
49 #define MS_SUBPART 4 /* within one of the Multiparts */
50 #define MS_EPILOGUE 5 /* epilogue of Multipart/Mixed */
51
52 /*
53 * Number of subsequent encoded lines we require to believe this
54 * is valid data.
55 */
56
57 #define ELC_COUNT 4
58
59 /*
60 * Flags a part may have. FL_PROPER means that we are sure about the file's
61 * encoding, beginning and end, and don't have to use special care when de-
62 * coding.
63 */
64
65 #define FL_NONE 0 /* no flag, just plain normal */
66 #define FL_SINGLE 1 /* standalone MSG, do not mix */
67 #define FL_PARTIAL 2 /* from Message/Partial */
68 #define FL_PROPER 4 /* proper MIME part */
69 #define FL_TOEND 8 /* part continues to EOF */
70
71 /*
72 * Auxiliary macro: compute the percentage of a against b.
73 * The obvious answer is (100*a)/b, but this overflows for large a.
74 * a/(b/100) is better; we use a/((b/100)+1) so that we don't divide
75 * by zero for b<100 and the result doesn't become larger than 100%
76 */
77
78 #define UUPERCENT(a,b) ((int) ((unsigned long)(a) / \
79 (((unsigned long)(b)/100)+1)))
80
81 /*
82 * Make the Busy Callback easier. The macro returns true if the BusyCallback
83 * wants us to terminate.
84 */
85
86 extern unsigned long uuyctr;
87 #define UUBUSYPOLL(a,b) (((++uuyctr%BUSY_LINE_TICKS)==0) ? (progress.percent=UUPERCENT((a),(b)),UUBusyPoll()):0)
88
89 /*
90 * How many lines of headers do we need to believe another mail
91 * header is approaching? Use more restrictive values for MIME
92 * mails, less restrictive for Freestyle
93 */
94
95 typedef struct {
96 int restart; /* restarting after a MIME body (not subpart) */
97 int afterdata; /* after we had useful data in freestyle mode */
98 int afternl; /* after an empty line in freestyle mode */
99 } headercount;
100
101 extern headercount hlcount;
102
103 /*
104 * Information from the headers of a message. Each instance must
105 * have its very own copy of the strings. If `mimevers' is NULL,
106 * then this message does not comply to the MIME standard.
107 */
108
109 typedef struct _headers {
110 char *from; /* From: */
111 char *subject; /* Subject: */
112 char *rcpt; /* To: */
113 char *date; /* Date: */
114 char *mimevers; /* MIME-Version: */
115 char *ctype; /* Content-Type: */
116 char *ctenc; /* Content-Transfer-Encoding: */
117 char *fname; /* Potential Filename from Content-Type Parameter */
118 char *boundary; /* MIME-Boundary from Content-Type Parameter */
119 char *mimeid; /* MIME-Id for Message/Partial */
120 int partno; /* part number for Message/Partial */
121 int numparts; /* number of parts for Message/Partial */
122 } headers;
123
124 /*
125 * Scanner state
126 */
127
128 typedef struct _scanstate {
129 int isfolder; /* if we think this is a valid email folder */
130 int ismime; /* if we are within a valid MIME message */
131 int mimestate; /* state of MIME scanner */
132 int mimeenc; /* encoding of this MIME file */
133 char *source; /* source filename */
134 headers envelope; /* mail envelope headers */
135 } scanstate;
136
137 /*
138 * Structure that holds the information for a single file / part of
139 * a file. If a subject line is encountered, it is copied to subject;
140 * if a begin is found, the mode and name of the file is extracted.
141 * flags are set if 'begin' or 'end' is detected and 'uudet' if valid
142 * uuencoded data is found. If the file contains a 'From:' line with
143 * a '@' in it (indicating an origin email address), it is preserved
144 * in 'origin'.
145 **/
146
147 typedef struct _fileread {
148 char *subject; /* Whole subject line */
149 char *filename; /* Only filled in if begin detected */
150 char *origin; /* Whole 'From:' line */
151 char *mimeid; /* the ID for Mime-encoded files */
152 char *mimetype; /* Content-Type */
153 short mode; /* Mode of File (from 'begin') */
154 int begin; /* begin detected */
155 int end; /* end detected */
156 int flags; /* associated flags */
157
158 short uudet; /* valid encoded data. value indicates encoding */
159 short partno; /* Mime-files have a part number within */
160 short maxpno; /* ... plus the total number of parts */
161
162 char *sfname; /* Associated source file */
163 long startpos; /* ftell() position where data starts */
164 long length; /* length of data */
165 } fileread;
166
167 /*
168 * Structure for holding one part of a file, with some more information
169 * about it. The UUPreProcessPart() function takes one a fileread structure
170 * and produces this uufile structure.
171 * Linked List, ordered by partno.
172 **/
173
174 typedef struct _uufile {
175 char *filename;
176 char *subfname;
177 char *mimeid;
178 char *mimetype;
179 short partno;
180 fileread *data;
181 struct _uufile *NEXT;
182 } uufile;
183
184 extern void *uu_MsgCBArg;
185 extern void *uu_BusyCBArg;
186 extern void *uu_FileCBArg;
187 extern void *uu_FFCBArg;
188
189 /*
190 * variables
191 */
192
193 extern int uu_fast_scanning;
194 extern int uu_bracket_policy;
195 extern int uu_verbose;
196 extern int uu_desperate;
197 extern int uu_ignreply;
198 extern int uu_debug;
199 extern int uu_errno;
200 extern int uu_dumbness;
201 extern int uu_overwrite;
202 extern int uu_ignmode;
203 extern int uu_headercount;
204 extern int uu_usepreamble;
205 extern int uu_handletext;
206 extern int uu_tinyb64;
207 extern int uu_remove_input;
208 extern int uu_more_mime;
209
210 extern char *uusavepath;
211 extern char *uuencodeext;
212
213 /*
214 * Encoding/Decoding tables
215 */
216
217 extern unsigned char UUEncodeTable[];
218 extern unsigned char XXEncodeTable[];
219 extern unsigned char B64EncodeTable[];
220 extern unsigned char BHEncodeTable[];
221
222 /*
223 * String tables from uustring.c
224 */
225
226 extern char *msgnames[];
227 extern char *codenames[];
228 extern char *uuretcodes[];
229
230 extern uulist *UUGlobalFileList;
231
232 /*
233 * State of MIME variables and current progress
234 */
235
236 extern int nofnum, mssdepth;
237 extern int mimseqno, lastvalid;
238 extern int lastenc;
239 extern scanstate multistack[];
240 extern headers localenv;
241 extern scanstate sstate;
242 extern uuprogress progress;
243
244 /*
245 * mallocable areas
246 */
247
248 extern char *uugen_fnbuffer, *uugen_inbuffer;
249 extern char *uucheck_lastname, *uucheck_tempname;
250 extern char *uuestr_itemp, *uuestr_otemp;
251 extern char *uulib_msgstring, *uuncdl_fulline;
252 extern char *uuncdp_oline, *uuscan_shlline, *uuscan_shlline2;
253 extern char *uuscan_pvvalue, *uuscan_phtext;
254 extern char *uuscan_sdline, *uuscan_sdbhds1;
255 extern char *uuscan_sdbhds2, *uuscan_spline;
256 extern char *uuutil_bhwtmp;
257 extern char *uunconc_UUxlat, *uunconc_UUxlen;
258 extern char *uunconc_B64xlat, *uunconc_XXxlat;
259 extern char *uunconc_BHxlat, *uunconc_save;
260
261 #ifdef __cplusplus
262 extern "C" {
263 #endif
264
265 extern void (*uu_MsgCallback) _ANSI_ARGS_((void *, char *, int));
266 extern int (*uu_BusyCallback) _ANSI_ARGS_((void *, uuprogress *));
267 extern int (*uu_FileCallback) _ANSI_ARGS_((void *, char *, char *, int));
268 extern char * (*uu_FNameFilter) _ANSI_ARGS_((void *, char *));
269
270 /*
271 * Functions from uulib.c that aren't defined in <uudeview.h>
272 * Be careful about the definition with variable arguments.
273 */
274
275 #if defined(STDC_HEADERS) || defined(HAVE_STDARG_H)
276 int UUMessage _ANSI_ARGS_((char *, int,
277 int, char *, ...));
278 #else
279 int UUMessage ();
280 #endif
281 int UUBusyPoll _ANSI_ARGS_((void));
282
283 /*
284 * Functions from uucheck.c
285 */
286
287 uufile * UUPreProcessPart _ANSI_ARGS_((fileread *, int *));
288 int UUInsertPartToList _ANSI_ARGS_((uufile *));
289 uulist * UUCheckGlobalList _ANSI_ARGS_((void));
290
291 /*
292 * Functions from uuutil.c
293 */
294
295 void UUkillfread _ANSI_ARGS_((fileread *));
296 void UUkillfile _ANSI_ARGS_((uufile *));
297 void UUkilllist _ANSI_ARGS_((uulist *));
298 void UUkillheaders _ANSI_ARGS_((headers *));
299
300 fileread * ScanPart _ANSI_ARGS_((FILE *, char *, int *));
301
302 int UUbhdecomp _ANSI_ARGS_((char *, char *,
303 char *, int *,
304 size_t, size_t,
305 size_t *));
306 size_t UUbhwrite _ANSI_ARGS_((char *, size_t, size_t,
307 FILE *));
308
309 /*
310 * Functions from uunconc.c
311 */
312
313 int UURepairData _ANSI_ARGS_((FILE *, char *,
314 int, int *));
315
316 void UUInitConc _ANSI_ARGS_((void));
317 int UUValidData _ANSI_ARGS_((char *, int, int *));
318 size_t UUDecodeLine _ANSI_ARGS_((char *, char *, int));
319 int UUDecodeField _ANSI_ARGS_((char *, char *, int));
320 int UUDecodePart _ANSI_ARGS_((FILE *, FILE *, int *,
321 long, int, int, char *));
322 int UUDecode _ANSI_ARGS_((uulist *));
323
324 /*
325 * Message retrieval from uustring.c
326 */
327
328 char * uustring _ANSI_ARGS_((int));
329
330 /*
331 * From uuscan.c
332 */
333
334 int UUScanHeader _ANSI_ARGS_((FILE *, headers *));
335
336 #ifdef __cplusplus
337 }
338 #endif
339 #endif