uuint.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of uudeview, the simple and friendly multi-part multi-
00003  * file uudecoder program (c) 1994-2001 by Frank Pilhofer. The author may
00004  * be contacted at [email protected]
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  * GNU General Public License for more details.
00015  */
00016 
00017 #ifndef __UUINT_H__
00018 #define __UUINT_H__
00019 
00020 /*
00021  * This file describes the internal structures, variables and definitions
00022  * of UUDeview. It should not be included from other packages. Subject to
00023  * change without notice. Do not depend on anything here.
00024  *
00025  * $Id: uuint.h 2 2006-10-02 20:45:58Z csk $
00026  */
00027 
00028 #ifndef _ANSI_ARGS_
00029 #ifdef PROTOTYPES
00030 #define _ANSI_ARGS_(c) c
00031 #else
00032 #define _ANSI_ARGS_(c) ()
00033 #endif
00034 #endif
00035 
00036 /*
00037  * Busy Polls will be made after processing ... lines
00038  */
00039 
00040 #define BUSY_LINE_TICKS 50
00041 
00042 /*
00043  * States of MIME scanner
00044  */
00045 
00046 #define MS_HEADERS 1 /* still inside of headers */
00047 #define MS_BODY 2 /* body of `simple' messages */
00048 #define MS_PREAMBLE 3 /* preamble of Multipart/Mixed */
00049 #define MS_SUBPART 4 /* within one of the Multiparts */
00050 #define MS_EPILOGUE 5 /* epilogue of Multipart/Mixed */
00051 
00052 /*
00053  * Number of subsequent encoded lines we require to believe this
00054  * is valid data.
00055  */
00056 
00057 #define ELC_COUNT 4
00058 
00059 /*
00060  * Flags a part may have. FL_PROPER means that we are sure about the file's
00061  * encoding, beginning and end, and don't have to use special care when de-
00062  * coding.
00063  */
00064 
00065 #define FL_NONE 0 /* no flag, just plain normal */
00066 #define FL_SINGLE 1 /* standalone MSG, do not mix */
00067 #define FL_PARTIAL 2 /* from Message/Partial */
00068 #define FL_PROPER 4 /* proper MIME part */
00069 #define FL_TOEND 8 /* part continues to EOF */
00070 
00071 /*
00072  * Auxiliary macro: compute the percentage of a against b.
00073  * The obvious answer is (100*a)/b, but this overflows for large a.
00074  * a/(b/100) is better; we use a/((b/100)+1) so that we don't divide
00075  * by zero for b
00076  */
00077 
00078 #define UUPERCENT(a,b) ((int) ((unsigned long)(a) / \
00079  (((unsigned long)(b)/100)+1)))
00080      
00081 /*
00082  * Make the Busy Callback easier. The macro returns true if the BusyCallback
00083  * wants us to terminate.
00084  */
00085 
00086 extern unsigned long uuyctr;
00087 #define UUBUSYPOLL(a,b) (((++uuyctr%BUSY_LINE_TICKS)==0) ? (progress.percent=UUPERCENT((a),(b)),UUBusyPoll()):0)
00088 
00089 /*
00090  * How many lines of headers do we need to believe another mail
00091  * header is approaching? Use more restrictive values for MIME
00092  * mails, less restrictive for Freestyle
00093  */
00094 
00095 typedef struct {
00096   int restart;          /* restarting after a MIME body (not subpart) */
00097   int afterdata;        /* after we had useful data in freestyle mode */
00098   int afternl;          /* after an empty line in freestyle mode */
00099 } headercount;
00100 
00101 extern headercount hlcount;
00102 
00103 /*
00104  * Information from the headers of a message. Each instance must
00105  * have its very own copy of the strings. If `mimevers' is NULL,
00106  * then this message does not comply to the MIME standard.
00107  */
00108 
00109 typedef struct _headers {
00110   char *from;           /* From: */
00111   char *subject;        /* Subject: */
00112   char *rcpt;           /* To: */
00113   char *date;           /* Date: */
00114   char *mimevers;       /* MIME-Version: */
00115   char *ctype;          /* Content-Type: */
00116   char *ctenc;          /* Content-Transfer-Encoding: */
00117   char *fname;          /* Potential Filename from Content-Type Parameter */
00118   char *boundary;       /* MIME-Boundary from Content-Type Parameter */
00119   char *mimeid;         /* MIME-Id for Message/Partial */
00120   int partno;           /* part number for Message/Partial */
00121   int numparts;         /* number of parts for Message/Partial */
00122 } headers;
00123 
00124 /*
00125  * Scanner state
00126  */
00127 
00128 typedef struct _scanstate {
00129   int isfolder;         /* if we think this is a valid email folder */
00130   int ismime;           /* if we are within a valid MIME message */
00131   int mimestate;        /* state of MIME scanner */
00132   int mimeenc;          /* encoding of this MIME file */
00133   char *source;         /* source filename */
00134   headers envelope;     /* mail envelope headers */
00135 } scanstate;
00136 
00137 /*
00138  * Structure that holds the information for a single file / part of
00139  * a file. If a subject line is encountered, it is copied to subject;
00140  * if a begin is found, the mode and name of the file is extracted.
00141  * flags are set if 'begin' or 'end' is detected and 'uudet' if valid
00142  * uuencoded data is found. If the file contains a 'From:' line with
00143  * a '@' in it (indicating an origin email address), it is preserved
00144  * in 'origin'.
00145  **/
00146 
00147 typedef struct _fileread {
00148   char *subject;        /* Whole subject line */
00149   char *filename;       /* Only filled in if begin detected */
00150   char *origin;         /* Whole 'From:' line */
00151   char *mimeid;         /* the ID for Mime-encoded files */
00152   char *mimetype;       /* Content-Type */
00153   short mode;           /* Mode of File (from 'begin') */
00154   int   begin;          /* begin detected */
00155   int   end;            /* end detected */
00156   int   flags;          /* associated flags */
00157 
00158   short uudet;          /* valid encoded data. value indicates encoding */
00159   short partno;         /* Mime-files have a part number within */
00160   short maxpno;         /* ... plus the total number of parts */
00161 
00162   char *sfname;         /* Associated source file */
00163   long startpos;        /* ftell() position where data starts */
00164   long length;          /* length of data */
00165 } fileread;
00166 
00167 /*
00168  * Structure for holding one part of a file, with some more information
00169  * about it. The UUPreProcessPart() function takes one a fileread structure
00170  * and produces this uufile structure.
00171  * Linked List, ordered by partno.
00172  **/
00173 
00174 typedef struct _uufile {
00175   char     *filename;
00176   char     *subfname;
00177   char     *mimeid;
00178   char     *mimetype;
00179   short     partno;
00180   fileread *data;
00181   struct _uufile *NEXT;
00182 } uufile;
00183 
00184 extern void *uu_MsgCBArg;
00185 extern void *uu_BusyCBArg;
00186 extern void *uu_FileCBArg;
00187 extern void *uu_FFCBArg;
00188 
00189 /*
00190  * variables
00191  */
00192 
00193 extern int uu_fast_scanning;
00194 extern int uu_bracket_policy;
00195 extern int uu_verbose;
00196 extern int uu_desperate;
00197 extern int uu_ignreply;
00198 extern int uu_debug;
00199 extern int uu_errno;
00200 extern int uu_dumbness;
00201 extern int uu_overwrite;
00202 extern int uu_ignmode;
00203 extern int uu_headercount;
00204 extern int uu_usepreamble;
00205 extern int uu_handletext;
00206 extern int uu_tinyb64;
00207 extern int uu_remove_input;
00208 extern int uu_more_mime;
00209 
00210 extern char *uusavepath;
00211 extern char *uuencodeext;
00212 
00213 /*
00214  * Encoding/Decoding tables
00215  */
00216 
00217 extern unsigned char UUEncodeTable[];
00218 extern unsigned char XXEncodeTable[];
00219 extern unsigned char B64EncodeTable[];
00220 extern unsigned char BHEncodeTable[];
00221 
00222 /*
00223  * String tables from uustring.c
00224  */
00225 
00226 extern char *msgnames[];
00227 extern char *codenames[];
00228 extern char *uuretcodes[];
00229 
00230 extern uulist *UUGlobalFileList;
00231 
00232 /*
00233  * State of MIME variables and current progress
00234  */
00235 
00236 extern int nofnum, mssdepth;
00237 extern int mimseqno, lastvalid;
00238 extern int lastenc;
00239 extern scanstate  multistack[];
00240 extern headers    localenv;
00241 extern scanstate  sstate;
00242 extern uuprogress progress;
00243 
00244 /*
00245  * mallocable areas
00246  */
00247 
00248 extern char *uugen_fnbuffer, *uugen_inbuffer;
00249 extern char *uucheck_lastname, *uucheck_tempname;
00250 extern char *uuestr_itemp, *uuestr_otemp;
00251 extern char *uulib_msgstring, *uuncdl_fulline;
00252 extern char *uuncdp_oline, *uuscan_shlline, *uuscan_shlline2;
00253 extern char *uuscan_pvvalue, *uuscan_phtext;
00254 extern char *uuscan_sdline, *uuscan_sdbhds1;
00255 extern char *uuscan_sdbhds2;
00256 extern char *uuscan_spline;
00257 extern char *uuutil_bhwtmp;
00258 extern char *uunconc_UUxlat, *uunconc_UUxlen;
00259 extern char *uunconc_B64xlat, *uunconc_XXxlat;
00260 extern char *uunconc_BHxlat, *uunconc_save;
00261 
00262 #define UUSCAN_SPLINE_LEN 4096
00263 #define UUSCAN_SDLINE_LEN 4096
00264 #define UUGEN_FNBUFFER_LEN 4096
00265 
00266 #ifdef __cplusplus
00267 extern "C" {
00268 #endif
00269 
00270 extern void   (*uu_MsgCallback)  _ANSI_ARGS_((void *, char *, int));
00271 extern int    (*uu_BusyCallback) _ANSI_ARGS_((void *, uuprogress *));
00272 extern int    (*uu_FileCallback) _ANSI_ARGS_((void *, char *, char *, int));
00273 extern char * (*uu_FNameFilter)  _ANSI_ARGS_((void *, char *));
00274 
00275 /*
00276  * Functions from uulib.c that aren't defined in 
00277  * Be careful about the definition with variable arguments.
00278  */
00279 
00280 #if defined(STDC_HEADERS) || defined(HAVE_STDARG_H)
00281 int             UUMessage               _ANSI_ARGS_((char *, int,
00282                                                      int, char *, ...));
00283 #else
00284 int             UUMessage               ();
00285 #endif
00286 int             UUBusyPoll              _ANSI_ARGS_((void));
00287 
00288 /*
00289  * Functions from uucheck.c
00290  */
00291 
00292 uufile *        UUPreProcessPart        _ANSI_ARGS_((fileread *, int *));
00293 int             UUInsertPartToList      _ANSI_ARGS_((uufile *));
00294 uulist *        UUCheckGlobalList       _ANSI_ARGS_((void));
00295 
00296 /*
00297  * Functions from uuutil.c
00298  */
00299 
00300 void            UUkillfread             _ANSI_ARGS_((fileread *));
00301 void            UUkillfile              _ANSI_ARGS_((uufile *));
00302 void            UUkilllist              _ANSI_ARGS_((uulist *));
00303 void            UUkillheaders           _ANSI_ARGS_((headers *));
00304 
00305 fileread *      ScanPart                _ANSI_ARGS_((FILE *, char *, int *));
00306 
00307 int             UUbhdecomp              _ANSI_ARGS_((char *, char *,
00308                                                      char *, int *,
00309                                                      size_t, size_t, 
00310                                                      size_t *));
00311 size_t          UUbhwrite               _ANSI_ARGS_((char *, size_t, size_t,
00312                                                      FILE *));
00313 
00314 /*
00315  * Functions from uunconc.c
00316  */
00317 
00318 int             UURepairData            _ANSI_ARGS_((FILE *, char *,
00319                                                      int, int *));
00320 
00321 void            UUInitConc              _ANSI_ARGS_((void));
00322 int             UUValidData             _ANSI_ARGS_((char *, int, int *));
00323 size_t          UUDecodeLine            _ANSI_ARGS_((char *, char *, int));
00324 int             UUDecodeField           _ANSI_ARGS_((char *, char *, int));
00325 int             UUDecodePart            _ANSI_ARGS_((FILE *, FILE *, int *,
00326                                                      long, int, int, char *));
00327 int             UUDecode                _ANSI_ARGS_((uulist *));
00328 
00329 /*
00330  * Message retrieval from uustring.c
00331  */
00332 
00333 char *          uustring                _ANSI_ARGS_((int));
00334 
00335 /*
00336  * From uuscan.c
00337  */
00338 
00339 int             UUScanHeader            _ANSI_ARGS_((FILE *, headers *));
00340 
00341 #ifdef __cplusplus
00342 }
00343 #endif
00344 #endif

Generated on Sun Oct 12 01:45:30 2008 for NNTPGrab by  1.5.4