ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/uudeview.h
Revision: 1.14
Committed: Sat Sep 24 07:35:02 2022 UTC (20 months, 1 week ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.13: +57 -1 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 __UUDEVIEW_H__
18 #define __UUDEVIEW_H__
19
20 #include <stdint.h>
21
22 /*
23 * This include file features all the definitions that should
24 * be externally visible. This isn't much.
25 */
26
27 #ifndef _ANSI_ARGS_
28 #ifdef PROTOTYPES
29 #define _ANSI_ARGS_(c) c
30 #else
31 #define _ANSI_ARGS_(c) ()
32 #endif
33 #endif
34
35 /*
36 * Message Types
37 */
38
39 #define UUMSG_MESSAGE (0) /* just a message, nothing important */
40 #define UUMSG_NOTE (1) /* something that should be noticed */
41 #define UUMSG_WARNING (2) /* important msg, processing continues */
42 #define UUMSG_ERROR (3) /* processing has been terminated */
43 #define UUMSG_FATAL (4) /* decoder cannot process further requests */
44 #define UUMSG_PANIC (5) /* recovery impossible, app must terminate */
45
46 /*
47 * Return Values
48 */
49
50 #define UURET_OK (0) /* everything went fine */
51 #define UURET_IOERR (1) /* I/O Error - examine errno */
52 #define UURET_NOMEM (2) /* not enough memory */
53 #define UURET_ILLVAL (3) /* illegal value for operation */
54 #define UURET_NODATA (4) /* decoder didn't find any data */
55 #define UURET_NOEND (5) /* encoded data wasn't ended properly */
56 #define UURET_UNSUP (6) /* unsupported function (encoding) */
57 #define UURET_EXISTS (7) /* file exists (decoding) */
58 #define UURET_CONT (8) /* continue -- special from ScanPart */
59 #define UURET_CANCEL (9) /* operation canceled */
60
61 /*
62 * File states, may be OR'ed
63 */
64
65 #define UUFILE_READ (0) /* Read in, but not further processed */
66 #define UUFILE_MISPART (1) /* Missing Part(s) detected */
67 #define UUFILE_NOBEGIN (2) /* No 'begin' found */
68 #define UUFILE_NOEND (4) /* No 'end' found */
69 #define UUFILE_NODATA (8) /* File does not contain valid uudata */
70 #define UUFILE_OK (16) /* All Parts found, ready to decode */
71 #define UUFILE_ERROR (32) /* Error while decoding */
72 #define UUFILE_DECODED (64) /* Successfully decoded */
73 #define UUFILE_TMPFILE (128) /* Temporary decoded file exists */
74
75 /*
76 * Encoding Types
77 */
78
79 #define UU_ENCODED (1) /* UUencoded data */
80 #define B64ENCODED (2) /* Mime-Base64 data */
81 #define XX_ENCODED (3) /* XXencoded data */
82 #define BH_ENCODED (4) /* Binhex encoded */
83 #define PT_ENCODED (5) /* Plain-Text encoded (MIME) */
84 #define QP_ENCODED (6) /* Quoted-Printable (MIME) */
85 #define YENC_ENCODED (7) /* yEnc encoded */
86
87 /*
88 * Option indices for GetOption / SetOption
89 */
90
91 #define UUOPT_RBUF (90) /* file read I/O buffer size */
92 #define UUOPT_WBUF (91) /* file write I/O buffer size */
93 #define UUOPT_VERSION (0) /* version number MAJOR.MINORplPATCH (ro) */
94 #define UUOPT_FAST (1) /* assumes only one part per file */
95 #define UUOPT_DUMBNESS (2) /* switch off the program's intelligence */
96 #define UUOPT_BRACKPOL (3) /* give numbers in [] higher precendence */
97 #define UUOPT_VERBOSE (4) /* generate informative messages */
98 #define UUOPT_DESPERATE (5) /* try to decode incomplete files */
99 #define UUOPT_IGNREPLY (6) /* ignore RE:plies (off by default) */
100 #define UUOPT_OVERWRITE (7) /* whether it's OK to overwrite ex. files */
101 #define UUOPT_SAVEPATH (8) /* prefix to save-files on disk */
102 #define UUOPT_IGNMODE (9) /* ignore the original file mode */
103 #define UUOPT_DEBUG (10) /* print messages with FILE/LINE info */
104 #define UUOPT_ERRNO (14) /* get last error code for UURET_IOERR (ro) */
105 #define UUOPT_PROGRESS (15) /* retrieve progress information */
106 #define UUOPT_USETEXT (16) /* handle text messages */
107 #define UUOPT_PREAMB (17) /* handle Mime preambles/epilogues */
108 #define UUOPT_TINYB64 (18) /* detect short B64 outside of Mime */
109 #define UUOPT_ENCEXT (19) /* extension for single-part encoded files */
110 #define UUOPT_REMOVE (20) /* remove input files after decoding */
111 #define UUOPT_MOREMIME (21) /* strict MIME adherence */
112 #define UUOPT_DOTDOT (22) /* .. unescaping has not yet been done on input files */
113 #define UUOPT_AUTOCHECK (23) /* call checkgloballist after every part */
114
115 /*
116 * Code for the "action" in the progress structure
117 */
118
119 #define UUACT_IDLE (0) /* we don't do anything */
120 #define UUACT_SCANNING (1) /* scanning an input file */
121 #define UUACT_DECODING (2) /* decoding into a temp file */
122 #define UUACT_COPYING (3) /* copying temp to target */
123 #define UUACT_ENCODING (4) /* encoding a file */
124
125 /*
126 * forward definition
127 */
128
129 struct _uufile;
130
131 /*
132 * Structure for holding the list of files that have been found
133 * uufile items are inserted into this list with UUInsertPartToList
134 * After inserting a bunch of files, UUCheckGlobalList must be called
135 * to update the states.
136 */
137
138 typedef struct _uulist {
139 struct _uulist *NEXT; /* next item of the list */
140 struct _uulist *PREV; /* previous item of the list */
141
142 uint8_t state; /* Status as described by the macros above */
143 uint8_t flags; /* flags, especially for single-part files */
144 uint8_t uudet; /* Encoding type (see macros above) */
145
146 int begin; /* part number where begin was detected */
147 int end; /* part number where end was detected */
148
149 uint32_t filename_hash; /* hash of filename for faster comparisons */
150 uint32_t mimeid_hash; /* hash of filename for faster comparisons */
151 uint16_t mode; /* file mode as found on begin line */
152
153 char *filename; /* malloc'ed file name */
154 char *subfname; /* malloc'ed ID from subject line */
155 char *mimeid; /* malloc'ed MIME-ID, if available */
156 char *mimetype; /* malloc'ed Content-Type, if available */
157
158 char *binfile; /* name of temp file, if already decoded */
159 long size; /* approximate size of resulting file */
160
161 struct _uufile *thisfile; /* linked list of this file's parts */
162
163 int *haveparts; /* the parts we have (max. 256 are listed) */
164 int *misparts; /* list of missing parts (max. 256) */
165 } uulist;
166
167 /*
168 * The "progress" structure which is passed to the Busy Callback
169 */
170
171 typedef struct {
172 int action; /* see UUACT_* definitions above */
173 char curfile[256]; /* the file we are working on, incl. path */
174 int partno; /* part we're currently decoding */
175 int numparts; /* total number of parts of this file */
176 long fsize; /* size of the current file */
177 int percent; /* % of _current part_ */
178 long foffset; /* file offset -- internal use only */
179 long totsize; /* file total size -- internal use only */
180 } uuprogress;
181
182 /*
183 * Structure that holds the information for a single file / part of
184 * a file. If a subject line is encountered, it is copied to subject;
185 * if a begin is found, the mode and name of the file is extracted.
186 * flags are set if 'begin' or 'end' is detected and 'uudet' if valid
187 * uuencoded data is found. If the file contains a 'From:' line with
188 * a '@' in it (indicating an origin email address), it is preserved
189 * in 'origin'.
190 **/
191
192 typedef struct _fileread {
193 char *subject; /* Whole subject line */
194 char *filename; /* Only filled in if begin detected */
195 char *origin; /* Whole 'From:' line */
196 char *mimeid; /* the ID for Mime-encoded files */
197 char *mimetype; /* Content-Type */
198 int begin; /* begin detected */
199 int end; /* end detected */
200 long yefilesize; /* the yencode file size, or 0 */
201
202 uint16_t mode; /* Mode of File (from 'begin') */
203 uint8_t flags; /* associated flags */
204 uint8_t uudet; /* valid encoded data. value indicates encoding */
205 int partno; /* Mime-files have a part number within */
206 int maxpno; /* ... plus the total number of parts */
207
208 char *sfname; /* Associated source file */
209 long startpos; /* ftell() position where data starts */
210 long length; /* length of data */
211 } fileread;
212
213 /*
214 * Structure for holding one part of a file, with some more information
215 * about it. The UUPreProcessPart() function takes one a fileread structure
216 * and produces this uufile structure.
217 * Linked List, ordered by partno.
218 **/
219
220 typedef struct _uufile {
221 struct _uufile *NEXT;
222 char *filename;
223 char *subfname;
224 char *mimeid;
225 char *mimetype;
226 fileread *data;
227 long yefilesize;
228 int partno;
229 } uufile;
230
231 /*
232 * Externally visible functions and variables
233 */
234
235 #ifndef UUEXPORT
236 #define UUEXPORT
237 #endif
238
239 #ifdef __cplusplus
240 extern "C" {
241 #endif
242
243 extern uulist *UUGlobalFileList;
244
245 extern void (*uu_MsgCallback) (void *, char *, int);
246 extern int (*uu_BusyCallback) (void *, uuprogress *);
247 extern int (*uu_FileCallback) (void *, char *, char *, int);
248 extern char * (*uu_FNameFilter) (void *, char *);
249 extern char * (*uu_FileNameCallback)(void *, char *, char *);
250
251 int UUEXPORT UUInitialize _ANSI_ARGS_((void));
252 int UUEXPORT UUGetOption _ANSI_ARGS_((int, int *, char *, int));
253 int UUEXPORT UUSetOption _ANSI_ARGS_((int, int, char *));
254 char * UUEXPORT UUstrerror _ANSI_ARGS_((int));
255 int UUEXPORT UUSetMsgCallback _ANSI_ARGS_((void *,
256 void (*) (void *,
257 char *,
258 int)));
259 int UUEXPORT UUSetBusyCallback _ANSI_ARGS_((void *,
260 int (*) (void *,
261 uuprogress *),
262 long));
263 int UUEXPORT UUSetFileCallback _ANSI_ARGS_((void *,
264 int (*) (void *, char *,
265 char *, int)));
266 int UUEXPORT UUSetFNameFilter _ANSI_ARGS_((void *,
267 char * (*) (void *,
268 char *)));
269 int UUEXPORT UUSetFileNameCallback _ANSI_ARGS_((void *,
270 char * (*) (void *,
271 char *, char *)));
272 char * UUEXPORT UUFNameFilter _ANSI_ARGS_((char *));
273 int UUEXPORT UULoadFile _ANSI_ARGS_((char *, char *, int, int *));
274 int UUEXPORT UULoadFileWithPartNo _ANSI_ARGS_((char *, char *, int, int, int *));
275 uulist *UUEXPORT UUGetFileListItem _ANSI_ARGS_((int));
276 int UUEXPORT UURenameFile _ANSI_ARGS_((uulist *, char *));
277 int UUEXPORT UUDecodeToTemp _ANSI_ARGS_((uulist *));
278 int UUEXPORT UURemoveTemp _ANSI_ARGS_((uulist *));
279 int UUEXPORT UUDecodeFile _ANSI_ARGS_((uulist *, char *));
280 int UUEXPORT UUInfoFile _ANSI_ARGS_((uulist *, void *,
281 int (*) (void *,
282 char *)));
283 int UUEXPORT UUSmerge _ANSI_ARGS_((int));
284 int UUEXPORT UUCleanUp _ANSI_ARGS_((void));
285
286 int UUEXPORT UUQuickDecode _ANSI_ARGS_((FILE *, FILE *,
287 char *, long));
288
289 int UUEXPORT UUEncodeMulti _ANSI_ARGS_((FILE *, FILE *,
290 char *, int,
291 char *, char *, int));
292 int UUEXPORT UUEncodePartial _ANSI_ARGS_((FILE *, FILE *,
293 char *, int,
294 char *, char *,
295 int, int, long,
296 unsigned int *));
297 int UUEXPORT UUEncodeToStream _ANSI_ARGS_((FILE *, FILE *,
298 char *, int,
299 char *, int));
300 int UUEXPORT UUEncodeToFile _ANSI_ARGS_((FILE *, char *, int,
301 char *, char *, long));
302 int UUEXPORT UUE_PrepSingle _ANSI_ARGS_((FILE *, FILE *,
303 char *, int,
304 char *, int,
305 char *, char *,
306 char *, int));
307 int UUEXPORT UUE_PrepPartial _ANSI_ARGS_((FILE *, FILE *,
308 char *, int,
309 char *, int,
310 int, long, long, char *,
311 char *, char *, int));
312
313 int UUEXPORT UUE_PrepSingleExt _ANSI_ARGS_((FILE *, FILE *,
314 char *, int,
315 char *, int,
316 char *, char *,
317 char *, char *,
318 int));
319 int UUEXPORT UUE_PrepPartialExt _ANSI_ARGS_((FILE *, FILE *,
320 char *, int,
321 char *, int,
322 int, long, long, char *,
323 char *, char *, char *,
324 int));
325 void UUEXPORT UUCheckGlobalList (void);
326 #ifdef __cplusplus
327 }
328 #endif
329 #endif