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