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