ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/uuint.h
Revision: 1.15
Committed: Sat Sep 24 06:25:44 2022 UTC (20 months, 1 week ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.14: +0 -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
26 /*
27 * Busy Polls will be made after processing ... lines
28 */
29
30 #define BUSY_LINE_TICKS 50
31
32 /*
33 * States of MIME scanner
34 */
35
36 #define MS_HEADERS 1 /* still inside of headers */
37 #define MS_BODY 2 /* body of `simple' messages */
38 #define MS_PREAMBLE 3 /* preamble of Multipart/Mixed */
39 #define MS_SUBPART 4 /* within one of the Multiparts */
40 #define MS_EPILOGUE 5 /* epilogue of Multipart/Mixed */
41
42 /*
43 * Number of subsequent encoded lines we require to believe this
44 * is valid data.
45 */
46
47 #define ELC_COUNT 4
48
49 /*
50 * Flags a part may have. FL_PROPER means that we are sure about the file's
51 * encoding, beginning and end, and don't have to use special care when de-
52 * coding.
53 */
54
55 #define FL_NONE 0 /* no flag, just plain normal */
56 #define FL_SINGLE 1 /* standalone MSG, do not mix */
57 #define FL_PARTIAL 2 /* from Message/Partial */
58 #define FL_PROPER 4 /* proper MIME part */
59 #define FL_TOEND 8 /* part continues to EOF */
60
61 /*
62 * Auxiliary macro: compute the percentage of a against b.
63 * The obvious answer is (100*a)/b, but this overflows for large a.
64 * a/(b/100) is better; we use a/((b/100)+1) so that we don't divide
65 * by zero for b<100 and the result doesn't become larger than 100%
66 */
67
68 #define UUPERCENT(a,b) ((int) ((unsigned long)(a) / \
69 (((unsigned long)(b)/100)+1)))
70
71 /*
72 * Make the Busy Callback easier. The macro returns true if the BusyCallback
73 * wants us to terminate.
74 */
75
76 extern unsigned long uuyctr;
77 #define UUBUSYPOLL(a,b) (((++uuyctr%BUSY_LINE_TICKS)==0) ? (progress.percent=UUPERCENT((a),(b)),UUBusyPoll()):0)
78
79 /*
80 * How many lines of headers do we need to believe another mail
81 * header is approaching? Use more restrictive values for MIME
82 * mails, less restrictive for Freestyle
83 */
84
85 typedef struct {
86 int restart; /* restarting after a MIME body (not subpart) */
87 int afterdata; /* after we had useful data in freestyle mode */
88 int afternl; /* after an empty line in freestyle mode */
89 } headercount;
90
91 extern headercount hlcount;
92
93 /*
94 * Information from the headers of a message. Each instance must
95 * have its very own copy of the strings. If `mimevers' is NULL,
96 * then this message does not comply to the MIME standard.
97 */
98
99 typedef struct _headers {
100 char *from; /* From: */
101 char *subject; /* Subject: */
102 char *rcpt; /* To: */
103 char *date; /* Date: */
104 char *mimevers; /* MIME-Version: */
105 char *ctype; /* Content-Type: */
106 char *ctenc; /* Content-Transfer-Encoding: */
107 char *fname; /* Potential Filename from Content-Type Parameter */
108 char *boundary; /* MIME-Boundary from Content-Type Parameter */
109 char *mimeid; /* MIME-Id for Message/Partial */
110 int partno; /* part number for Message/Partial */
111 int numparts; /* number of parts for Message/Partial */
112 } headers;
113
114 /*
115 * Scanner state
116 */
117
118 typedef struct _scanstate {
119 int isfolder; /* if we think this is a valid email folder */
120 int ismime; /* if we are within a valid MIME message */
121 int mimestate; /* state of MIME scanner */
122 int mimeenc; /* encoding of this MIME file */
123 char *source; /* source filename */
124 headers envelope; /* mail envelope headers */
125 } scanstate;
126
127 /*
128 * Structure that holds the information for a single file / part of
129 * a file. If a subject line is encountered, it is copied to subject;
130 * if a begin is found, the mode and name of the file is extracted.
131 * flags are set if 'begin' or 'end' is detected and 'uudet' if valid
132 * uuencoded data is found. If the file contains a 'From:' line with
133 * a '@' in it (indicating an origin email address), it is preserved
134 * in 'origin'.
135 **/
136
137 typedef struct _fileread {
138 char *subject; /* Whole subject line */
139 char *filename; /* Only filled in if begin detected */
140 char *origin; /* Whole 'From:' line */
141 char *mimeid; /* the ID for Mime-encoded files */
142 char *mimetype; /* Content-Type */
143 int begin; /* begin detected */
144 int end; /* end detected */
145 long yefilesize; /* the yencode file size, or 0 */
146
147 uint16_t mode; /* Mode of File (from 'begin') */
148 uint8_t flags; /* associated flags */
149 uint8_t uudet; /* valid encoded data. value indicates encoding */
150 int partno; /* Mime-files have a part number within */
151 int maxpno; /* ... plus the total number of parts */
152
153 char *sfname; /* Associated source file */
154 long startpos; /* ftell() position where data starts */
155 long length; /* length of data */
156 } fileread;
157
158 /*
159 * Structure for holding one part of a file, with some more information
160 * about it. The UUPreProcessPart() function takes one a fileread structure
161 * and produces this uufile structure.
162 * Linked List, ordered by partno.
163 **/
164
165 typedef struct _uufile {
166 struct _uufile *NEXT;
167 char *filename;
168 char *subfname;
169 char *mimeid;
170 char *mimetype;
171 fileread *data;
172 long yefilesize;
173 int partno;
174 } uufile;
175
176 extern void *uu_MsgCBArg;
177 extern void *uu_BusyCBArg;
178 extern void *uu_FileCBArg;
179 extern void *uu_FFCBArg;
180 extern void *uu_FNCBArg;
181
182 /*
183 * variables
184 */
185
186 extern int uu_autocheck;
187 extern int uu_rbuf;
188 extern int uu_wbuf;
189 #define UUSETBUF(fp,buff,size) if (size) setvbuf ((fp), ((buff) = malloc (size)), _IOFBF, (size))
190 #define UUCLRBUF(size,buff) if (size) free (buff)
191
192 extern int uu_fast_scanning;
193 extern int uu_bracket_policy;
194 extern int uu_verbose;
195 extern int uu_desperate;
196 extern int uu_ignreply;
197 extern int uu_debug;
198 extern int uu_errno;
199 extern int uu_dumbness;
200 extern int uu_overwrite;
201 extern int uu_ignmode;
202 extern int uu_headercount;
203 extern int uu_usepreamble;
204 extern int uu_handletext;
205 extern int uu_tinyb64;
206 extern int uu_remove_input;
207 extern int uu_more_mime;
208 extern int uu_dotdot;
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) (void *, char *, int);
266 extern int (*uu_BusyCallback) (void *, uuprogress *);
267 extern int (*uu_FileCallback) (void *, char *, char *, int);
268 extern char * (*uu_FNameFilter) (void *, char *);
269 extern char * (*uu_FileNameCallback)(void *, char *, char *);
270
271 /*
272 * Functions from uulib.c that aren't defined in <uudeview.h>
273 * Be careful about the definition with variable arguments.
274 */
275
276 #define UUMessage(level, ...) UUMessage_ (__FILE__, __LINE__, level, __VA_ARGS__)
277 int UUMessage_ (char *, int, int, char *, ...);
278 int UUBusyPoll (void);
279
280 /*
281 * Functions from uucheck.c
282 */
283
284 uufile * UUPreProcessPart (fileread *, int *);
285 int UUInsertPartToList (uufile *);
286
287 /*
288 * Functions from uuutil.c
289 */
290
291 void UUkillfread (fileread *);
292 void UUkillfile (uufile *);
293 void UUkilllist (uulist *);
294 void UUkillheaders (headers *);
295
296 fileread * ScanPart (FILE *, char *, int *);
297
298 int UUbhdecomp (char *, char *,
299 char *, int *,
300 size_t, size_t,
301 size_t *);
302 size_t UUbhwrite (char *, size_t, size_t, FILE *);
303
304 /*
305 * Functions from uunconc.c
306 */
307
308 int UURepairData (FILE *, char *, int, int *);
309
310 void UUInitConc _ANSI_ARGS_((void));
311 int UUValidData _ANSI_ARGS_((char *, int, int *));
312 size_t UUDecodeLine _ANSI_ARGS_((char *, char *, int));
313 int UUDecodeField _ANSI_ARGS_((char *, char *, int));
314 int UUDecodePart _ANSI_ARGS_((FILE *, FILE *, int *,
315 long, int, int, char *));
316 int UUDecode _ANSI_ARGS_((uulist *));
317
318 /*
319 * Message retrieval from uustring.c
320 */
321
322 char * uustring (int);
323
324 /*
325 * From uuscan.c
326 */
327
328 int UUScanHeader (FILE *, headers *);
329
330 #ifdef __cplusplus
331 }
332 #endif
333 #endif