ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/uulib/uuint.h
Revision: 1.17
Committed: Sat Sep 24 10:55:42 2022 UTC (20 months, 2 weeks ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.16: +14 -10 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 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 root 1.17 #include <stdio.h>
21    
22     #include "uudeview.h"
23    
24 root 1.1 /*
25     * This file describes the internal structures, variables and definitions
26     * of UUDeview. It should not be included from other packages. Subject to
27     * change without notice. Do not depend on anything here.
28     */
29    
30 root 1.16 #if COMPILE_SEPERATELY
31     #define UULIBINT_VAR extern
32     #define UULIBINT_FUNC
33     #else
34     #define UULIBINT_VAR extern
35     #define UULIBINT_FUNC static
36     #endif
37    
38 root 1.1 /*
39     * Busy Polls will be made after processing ... lines
40     */
41    
42     #define BUSY_LINE_TICKS 50
43    
44     /*
45     * States of MIME scanner
46     */
47    
48     #define MS_HEADERS 1 /* still inside of headers */
49     #define MS_BODY 2 /* body of `simple' messages */
50     #define MS_PREAMBLE 3 /* preamble of Multipart/Mixed */
51     #define MS_SUBPART 4 /* within one of the Multiparts */
52     #define MS_EPILOGUE 5 /* epilogue of Multipart/Mixed */
53    
54     /*
55     * Number of subsequent encoded lines we require to believe this
56     * is valid data.
57     */
58    
59     #define ELC_COUNT 4
60    
61     /*
62     * Flags a part may have. FL_PROPER means that we are sure about the file's
63     * encoding, beginning and end, and don't have to use special care when de-
64     * coding.
65     */
66    
67     #define FL_NONE 0 /* no flag, just plain normal */
68     #define FL_SINGLE 1 /* standalone MSG, do not mix */
69     #define FL_PARTIAL 2 /* from Message/Partial */
70     #define FL_PROPER 4 /* proper MIME part */
71     #define FL_TOEND 8 /* part continues to EOF */
72    
73     /*
74     * Auxiliary macro: compute the percentage of a against b.
75     * The obvious answer is (100*a)/b, but this overflows for large a.
76     * a/(b/100) is better; we use a/((b/100)+1) so that we don't divide
77     * by zero for b<100 and the result doesn't become larger than 100%
78     */
79    
80     #define UUPERCENT(a,b) ((int) ((unsigned long)(a) / \
81     (((unsigned long)(b)/100)+1)))
82 root 1.10
83 root 1.1 /*
84     * Make the Busy Callback easier. The macro returns true if the BusyCallback
85     * wants us to terminate.
86     */
87    
88 root 1.16 UULIBINT_VAR unsigned long uuyctr;
89 root 1.1 #define UUBUSYPOLL(a,b) (((++uuyctr%BUSY_LINE_TICKS)==0) ? (progress.percent=UUPERCENT((a),(b)),UUBusyPoll()):0)
90    
91     /*
92     * How many lines of headers do we need to believe another mail
93     * header is approaching? Use more restrictive values for MIME
94     * mails, less restrictive for Freestyle
95     */
96    
97     typedef struct {
98     int restart; /* restarting after a MIME body (not subpart) */
99     int afterdata; /* after we had useful data in freestyle mode */
100     int afternl; /* after an empty line in freestyle mode */
101     } headercount;
102    
103 root 1.16 UULIBINT_VAR headercount hlcount;
104 root 1.1
105     /*
106     * Information from the headers of a message. Each instance must
107     * have its very own copy of the strings. If `mimevers' is NULL,
108     * then this message does not comply to the MIME standard.
109     */
110    
111     typedef struct _headers {
112     char *from; /* From: */
113     char *subject; /* Subject: */
114     char *rcpt; /* To: */
115     char *date; /* Date: */
116     char *mimevers; /* MIME-Version: */
117     char *ctype; /* Content-Type: */
118     char *ctenc; /* Content-Transfer-Encoding: */
119     char *fname; /* Potential Filename from Content-Type Parameter */
120     char *boundary; /* MIME-Boundary from Content-Type Parameter */
121     char *mimeid; /* MIME-Id for Message/Partial */
122     int partno; /* part number for Message/Partial */
123     int numparts; /* number of parts for Message/Partial */
124     } headers;
125    
126     /*
127     * Scanner state
128     */
129    
130     typedef struct _scanstate {
131     int isfolder; /* if we think this is a valid email folder */
132     int ismime; /* if we are within a valid MIME message */
133     int mimestate; /* state of MIME scanner */
134     int mimeenc; /* encoding of this MIME file */
135     char *source; /* source filename */
136     headers envelope; /* mail envelope headers */
137     } scanstate;
138    
139 root 1.16 UULIBINT_VAR void *uu_MsgCBArg;
140     UULIBINT_VAR void *uu_BusyCBArg;
141     UULIBINT_VAR void *uu_FileCBArg;
142     UULIBINT_VAR void *uu_FFCBArg;
143     UULIBINT_VAR void *uu_FNCBArg;
144 root 1.1
145     /*
146     * variables
147     */
148    
149 root 1.16 UULIBINT_VAR int uu_autocheck;
150     UULIBINT_VAR int uu_rbuf;
151     UULIBINT_VAR int uu_wbuf;
152 root 1.7 #define UUSETBUF(fp,buff,size) if (size) setvbuf ((fp), ((buff) = malloc (size)), _IOFBF, (size))
153     #define UUCLRBUF(size,buff) if (size) free (buff)
154    
155 root 1.16 UULIBINT_VAR int uu_fast_scanning;
156     UULIBINT_VAR int uu_bracket_policy;
157     UULIBINT_VAR int uu_verbose;
158     UULIBINT_VAR int uu_desperate;
159     UULIBINT_VAR int uu_ignreply;
160     UULIBINT_VAR int uu_debug;
161     UULIBINT_VAR int uu_errno;
162     UULIBINT_VAR int uu_dumbness;
163     UULIBINT_VAR int uu_overwrite;
164     UULIBINT_VAR int uu_ignmode;
165     UULIBINT_VAR int uu_headercount;
166     UULIBINT_VAR int uu_usepreamble;
167     UULIBINT_VAR int uu_handletext;
168     UULIBINT_VAR int uu_tinyb64;
169     UULIBINT_VAR int uu_remove_input;
170     UULIBINT_VAR int uu_more_mime;
171     UULIBINT_VAR int uu_dotdot;
172 root 1.1
173 root 1.16 UULIBINT_VAR char *uusavepath;
174     UULIBINT_VAR char *uuencodeext;
175 root 1.1
176     /*
177     * Encoding/Decoding tables
178     */
179    
180 root 1.16 UULIBINT_VAR unsigned char UUEncodeTable[];
181     UULIBINT_VAR unsigned char XXEncodeTable[];
182     UULIBINT_VAR unsigned char B64EncodeTable[];
183     UULIBINT_VAR unsigned char BHEncodeTable[];
184 root 1.1
185     /*
186     * String tables from uustring.c
187     */
188    
189 root 1.16 UULIBINT_VAR char *msgnames[];
190     UULIBINT_VAR char *codenames[];
191     UULIBINT_VAR char *uuretcodes[];
192 root 1.1
193     /*
194     * State of MIME variables and current progress
195     */
196    
197 root 1.16 UULIBINT_VAR int nofnum, mssdepth;
198     UULIBINT_VAR int mimseqno, lastvalid;
199     UULIBINT_VAR int lastenc;
200     UULIBINT_VAR scanstate multistack[];
201     UULIBINT_VAR headers localenv;
202     UULIBINT_VAR scanstate sstate;
203     UULIBINT_VAR uuprogress progress;
204 root 1.1
205     /*
206     * mallocable areas
207     */
208    
209 root 1.16 UULIBINT_VAR char *uugen_fnbuffer, *uugen_inbuffer;
210     UULIBINT_VAR char *uucheck_lastname, *uucheck_tempname;
211     UULIBINT_VAR char *uuestr_itemp, *uuestr_otemp;
212     UULIBINT_VAR char *uulib_msgstring, *uuncdl_fulline;
213     UULIBINT_VAR char *uuncdp_oline, *uuscan_shlline, *uuscan_shlline2;
214     UULIBINT_VAR char *uuscan_pvvalue, *uuscan_phtext;
215     UULIBINT_VAR char *uuscan_sdline, *uuscan_sdbhds1;
216     UULIBINT_VAR char *uuscan_sdbhds2, *uuscan_spline;
217     UULIBINT_VAR char *uuutil_bhwtmp;
218     UULIBINT_VAR char *uunconc_UUxlat, *uunconc_UUxlen;
219     UULIBINT_VAR char *uunconc_B64xlat, *uunconc_XXxlat;
220     UULIBINT_VAR char *uunconc_BHxlat, *uunconc_save;
221 root 1.1
222     #ifdef __cplusplus
223     extern "C" {
224     #endif
225    
226     /*
227     * Functions from uulib.c that aren't defined in <uudeview.h>
228     * Be careful about the definition with variable arguments.
229     */
230    
231 root 1.17 #define UUMessage(level, ...) UUMessage_ (__FILE__, __LINE__ * 16 + level, __VA_ARGS__)
232     UULIBINT_FUNC int UUMessage_ (const char *, int, const char *, ...);
233 root 1.16 UULIBINT_FUNC int UUBusyPoll (void);
234 root 1.1
235     /*
236     * Functions from uucheck.c
237     */
238    
239 root 1.16 UULIBINT_FUNC uufile * UUPreProcessPart (fileread *, int *);
240     UULIBINT_FUNC int UUInsertPartToList (uufile *);
241 root 1.1
242     /*
243     * Functions from uuutil.c
244     */
245    
246 root 1.16 UULIBINT_FUNC void UUkillfread (fileread *);
247     UULIBINT_FUNC void UUkillfile (uufile *);
248     UULIBINT_FUNC void UUkilllist (uulist *);
249     UULIBINT_FUNC void UUkillheaders (headers *);
250    
251 root 1.17 UULIBINT_FUNC fileread *UUScanPart (FILE *, char *, int *);
252 root 1.16
253     UULIBINT_FUNC int UUbhdecomp (char *, char *,
254     char *, int *,
255     size_t, size_t,
256     size_t *);
257     UULIBINT_FUNC size_t UUbhwrite (char *, size_t, size_t, FILE *);
258 root 1.1
259     /*
260     * Functions from uunconc.c
261     */
262    
263 root 1.16 UULIBINT_FUNC int UURepairData (FILE *, char *, int, int *);
264 root 1.1
265 root 1.17 UULIBINT_FUNC void UUInitConc (void);
266     UULIBINT_FUNC int UUValidData (char *, int, int *);
267     UULIBINT_FUNC size_t UUDecodeLine (char *, char *, int);
268     UULIBINT_FUNC int UUDecodeField (char *, char *, int);
269     UULIBINT_FUNC int UUDecodePart (FILE *, FILE *, int *,
270     long, int, int, char *);
271     UULIBINT_FUNC int UUDecode (uulist *);
272 root 1.1
273     /*
274     * Message retrieval from uustring.c
275     */
276    
277 root 1.16 UULIBINT_FUNC char * uustring (int);
278 root 1.1
279     /*
280     * From uuscan.c
281     */
282    
283 root 1.16 UULIBINT_FUNC int UUScanHeader (FILE *, headers *);
284 root 1.1
285     #ifdef __cplusplus
286     }
287     #endif
288     #endif