1 /*
2  * $Id: detach.h 1025 2008-04-08 22:59:38Z hubert@u.washington.edu $
3  *
4  * ========================================================================
5  * Copyright 2013-2021 Eduardo Chappa
6  * Copyright 2006-2008 University of Washington
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * ========================================================================
15  */
16 
17 #ifndef PITH_DETACH_INCLUDED
18 #define PITH_DETACH_INCLUDED
19 
20 
21 #include "../pith/filttype.h"
22 #include "../pith/store.h"
23 
24 
25 /*
26  * Data used to keep track of partial fetches...
27  */
28 typedef struct _fetch_read {
29     unsigned	   free_me:1;
30     unsigned	   we_turned_on:1;
31     MAILSTREAM	  *stream;		/* stream of open mailbox */
32     unsigned long  msgno;		/* message number within mailbox */
33     char	  *section,		/* MIME section within message */
34 		  *chunk,		/* block of partial fetched data */
35 		  *chunkp,		/* pointer to next char in block */
36 		  *endp,		/* cell past last char in block */
37 		  *error;		/* Error message to report */
38     unsigned long  read,		/* bytes read so far */
39 		   size,		/* total bytes to read */
40 		   chunksize,		/* size of chunk block */
41 		   allocsize;		/* allocated size of chunk block */
42     long	   flags,		/* flags to use fetching block */
43 		   fetchtime;		/* usecs avg per chunk fetch */
44     gf_io_t	   readc;
45     STORE_S	  *cache;
46 } FETCH_READC_S;
47 
48 
49 extern FETCH_READC_S *g_fr_desc;
50 
51 #define	AVOID_MICROSOFT_SSL_CHUNKING_BUG ((unsigned long)(12 * 1024L))
52 
53 
54 /*
55  * This lazily gets combined with FT_ flags from c-client so make
56  * it different from all those possible values.
57  */
58 #define DT_NODFILTER   (long) 0x010000
59 #define DT_NOINTR      (long) 0x020000
60 #define DT_BINARY      (long) 0x040000
61 #define DT_EXTERNAL    (long) 0x080000
62 #define DT_ALLIMAGES   (long) 0x100000
63 
64 /* exported prototypes */
65 char	   *detach_raw(MAILSTREAM *, long, char *, gf_io_t, int);
66 char	   *detach(MAILSTREAM *, long, char *, long, long *, gf_io_t, FILTLIST_S *, long);
67 int	    valid_filter_command(char **);
68 void	    fetch_readc_init(FETCH_READC_S *, MAILSTREAM *, long, char *,
69 			     unsigned long, long, long);
70 
71 #endif /* PITH_DETACH_INCLUDED */
72