/* * This file is part of uudeview, the simple and friendly multi-part multi- * file uudecoder program (c) 1994-2001 by Frank Pilhofer. The author may * be contacted at fp@fpx.de * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #ifndef __UUINT_H__ #define __UUINT_H__ #include #include "uudeview.h" /* * This file describes the internal structures, variables and definitions * of UUDeview. It should not be included from other packages. Subject to * change without notice. Do not depend on anything here. */ #if COMPILE_SEPERATELY #define UULIBINT_VAR extern #define UULIBINT_FUNC #else #define UULIBINT_VAR extern #define UULIBINT_FUNC static #endif /* * Busy Polls will be made after processing ... lines */ #define BUSY_LINE_TICKS 50 /* * States of MIME scanner */ #define MS_HEADERS 1 /* still inside of headers */ #define MS_BODY 2 /* body of `simple' messages */ #define MS_PREAMBLE 3 /* preamble of Multipart/Mixed */ #define MS_SUBPART 4 /* within one of the Multiparts */ #define MS_EPILOGUE 5 /* epilogue of Multipart/Mixed */ /* * Number of subsequent encoded lines we require to believe this * is valid data. */ #define ELC_COUNT 4 /* * Flags a part may have. FL_PROPER means that we are sure about the file's * encoding, beginning and end, and don't have to use special care when de- * coding. */ #define FL_NONE 0 /* no flag, just plain normal */ #define FL_SINGLE 1 /* standalone MSG, do not mix */ #define FL_PARTIAL 2 /* from Message/Partial */ #define FL_PROPER 4 /* proper MIME part */ #define FL_TOEND 8 /* part continues to EOF */ /* * Auxiliary macro: compute the percentage of a against b. * The obvious answer is (100*a)/b, but this overflows for large a. * a/(b/100) is better; we use a/((b/100)+1) so that we don't divide * by zero for b<100 and the result doesn't become larger than 100% */ #define UUPERCENT(a,b) ((int) ((unsigned long)(a) / \ (((unsigned long)(b)/100)+1))) /* * Make the Busy Callback easier. The macro returns true if the BusyCallback * wants us to terminate. */ UULIBINT_VAR unsigned long uuyctr; #define UUBUSYPOLL(a,b) (((++uuyctr%BUSY_LINE_TICKS)==0) ? (progress.percent=UUPERCENT((a),(b)),UUBusyPoll()):0) /* * How many lines of headers do we need to believe another mail * header is approaching? Use more restrictive values for MIME * mails, less restrictive for Freestyle */ typedef struct { int restart; /* restarting after a MIME body (not subpart) */ int afterdata; /* after we had useful data in freestyle mode */ int afternl; /* after an empty line in freestyle mode */ } headercount; UULIBINT_VAR headercount hlcount; /* * Information from the headers of a message. Each instance must * have its very own copy of the strings. If `mimevers' is NULL, * then this message does not comply to the MIME standard. */ typedef struct _headers { char *from; /* From: */ char *subject; /* Subject: */ char *rcpt; /* To: */ char *date; /* Date: */ char *mimevers; /* MIME-Version: */ char *ctype; /* Content-Type: */ char *ctenc; /* Content-Transfer-Encoding: */ char *fname; /* Potential Filename from Content-Type Parameter */ char *boundary; /* MIME-Boundary from Content-Type Parameter */ char *mimeid; /* MIME-Id for Message/Partial */ int partno; /* part number for Message/Partial */ int numparts; /* number of parts for Message/Partial */ } headers; /* * Scanner state */ typedef struct _scanstate { int isfolder; /* if we think this is a valid email folder */ int ismime; /* if we are within a valid MIME message */ int mimestate; /* state of MIME scanner */ int mimeenc; /* encoding of this MIME file */ char *source; /* source filename */ headers envelope; /* mail envelope headers */ } scanstate; UULIBINT_VAR void *uu_MsgCBArg; UULIBINT_VAR void *uu_BusyCBArg; UULIBINT_VAR void *uu_FileCBArg; UULIBINT_VAR void *uu_FFCBArg; UULIBINT_VAR void *uu_FNCBArg; /* * variables */ UULIBINT_VAR int uu_autocheck; UULIBINT_VAR int uu_rbuf; UULIBINT_VAR int uu_wbuf; #define UUSETBUF(fp,buff,size) if (size) setvbuf ((fp), ((buff) = malloc (size)), _IOFBF, (size)) #define UUCLRBUF(size,buff) if (size) free (buff) UULIBINT_VAR int uu_fast_scanning; UULIBINT_VAR int uu_bracket_policy; UULIBINT_VAR int uu_verbose; UULIBINT_VAR int uu_desperate; UULIBINT_VAR int uu_ignreply; UULIBINT_VAR int uu_debug; UULIBINT_VAR int uu_errno; UULIBINT_VAR int uu_dumbness; UULIBINT_VAR int uu_overwrite; UULIBINT_VAR int uu_ignmode; UULIBINT_VAR int uu_headercount; UULIBINT_VAR int uu_usepreamble; UULIBINT_VAR int uu_handletext; UULIBINT_VAR int uu_tinyb64; UULIBINT_VAR int uu_remove_input; UULIBINT_VAR int uu_more_mime; UULIBINT_VAR int uu_dotdot; UULIBINT_VAR char *uusavepath; UULIBINT_VAR char *uuencodeext; /* * Encoding/Decoding tables */ UULIBINT_VAR unsigned char UUEncodeTable[]; UULIBINT_VAR unsigned char XXEncodeTable[]; UULIBINT_VAR unsigned char B64EncodeTable[]; UULIBINT_VAR unsigned char BHEncodeTable[]; /* * String tables from uustring.c */ UULIBINT_VAR char *msgnames[]; UULIBINT_VAR char *codenames[]; UULIBINT_VAR char *uuretcodes[]; /* * State of MIME variables and current progress */ UULIBINT_VAR int nofnum, mssdepth; UULIBINT_VAR int mimseqno, lastvalid; UULIBINT_VAR int lastenc; UULIBINT_VAR scanstate multistack[]; UULIBINT_VAR headers localenv; UULIBINT_VAR scanstate sstate; UULIBINT_VAR uuprogress progress; /* * mallocable areas */ UULIBINT_VAR char *uugen_fnbuffer, *uugen_inbuffer; UULIBINT_VAR char *uucheck_lastname, *uucheck_tempname; UULIBINT_VAR char *uuestr_itemp, *uuestr_otemp; UULIBINT_VAR char *uulib_msgstring, *uuncdl_fulline; UULIBINT_VAR char *uuncdp_oline, *uuscan_shlline, *uuscan_shlline2; UULIBINT_VAR char *uuscan_pvvalue, *uuscan_phtext; UULIBINT_VAR char *uuscan_sdline, *uuscan_sdbhds1; UULIBINT_VAR char *uuscan_sdbhds2, *uuscan_spline; UULIBINT_VAR char *uuutil_bhwtmp; UULIBINT_VAR char *uunconc_UUxlat, *uunconc_UUxlen; UULIBINT_VAR char *uunconc_B64xlat, *uunconc_XXxlat; UULIBINT_VAR char *uunconc_BHxlat, *uunconc_save; #ifdef __cplusplus extern "C" { #endif /* * Functions from uulib.c that aren't defined in * Be careful about the definition with variable arguments. */ #define UUMessage(level, ...) UUMessage_ (__FILE__, __LINE__ * 16 + level, __VA_ARGS__) UULIBINT_FUNC int UUMessage_ (const char *, int, const char *, ...); UULIBINT_FUNC int UUBusyPoll (void); /* * Functions from uucheck.c */ UULIBINT_FUNC uufile * UUPreProcessPart (fileread *, int *); UULIBINT_FUNC int UUInsertPartToList (uufile *); /* * Functions from uuutil.c */ UULIBINT_FUNC void UUkillfread (fileread *); UULIBINT_FUNC void UUkillfile (uufile *); UULIBINT_FUNC void UUkilllist (uulist *); UULIBINT_FUNC void UUkillheaders (headers *); UULIBINT_FUNC fileread *UUScanPart (FILE *, char *, int *); UULIBINT_FUNC int UUbhdecomp (char *, char *, char *, int *, size_t, size_t, size_t *); UULIBINT_FUNC size_t UUbhwrite (char *, size_t, size_t, FILE *); /* * Functions from uunconc.c */ UULIBINT_FUNC int UURepairData (FILE *, char *, int, int *); UULIBINT_FUNC void UUInitConc (void); UULIBINT_FUNC int UUValidData (char *, int, int *); UULIBINT_FUNC size_t UUDecodeLine (char *, char *, int); UULIBINT_FUNC int UUDecodeField (char *, char *, int); UULIBINT_FUNC int UUDecodePart (FILE *, FILE *, int *, long, int, int, char *); UULIBINT_FUNC int UUDecode (uulist *); /* * Message retrieval from uustring.c */ UULIBINT_FUNC char * uustring (int); /* * From uuscan.c */ UULIBINT_FUNC int UUScanHeader (FILE *, headers *); #ifdef __cplusplus } #endif #endif