ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/uudeview.h
Revision: 1.11
Committed: Sat Dec 12 10:48:39 2020 UTC (3 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.10: +13 -7 lines
Log Message:
*** empty log message ***

File Contents

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