* exec.c (make_tempdir) [_WIN32]: Modified to properly handle
[gnupg.git] / g10 / filter.h
blobbb06ecc6e7e28f2da162c53e918a40a408dfc0ac
1 /* filter.h
2 * Copyright (C) 1998, 1999, 2000, 2001, 2003,
3 * 2005 Free Software Foundation, Inc.
5 * This file is part of GnuPG.
7 * GnuPG is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * GnuPG is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * USA.
22 #ifndef G10_FILTER_H
23 #define G10_FILTER_H
25 #include "types.h"
26 #include "cipher.h"
28 typedef struct {
29 MD_HANDLE md; /* catch all */
30 MD_HANDLE md2; /* if we want to calculate an alternate hash */
31 size_t maxbuf_size;
32 } md_filter_context_t;
34 typedef struct {
35 /* these fields may be initialized */
36 int what; /* what kind of armor headers to write */
37 int only_keyblocks; /* skip all headers but ".... key block" */
38 const char *hdrlines; /* write these headerlines */
40 /* these fileds must be initialized to zero */
41 int no_openpgp_data; /* output flag: "No valid OpenPGP data found" */
43 /* the following fields must be initialized to zero */
44 int inp_checked; /* set if the input has been checked */
45 int inp_bypass; /* set if the input is not armored */
46 int in_cleartext; /* clear text message */
47 int not_dash_escaped; /* clear text is not dash escaped */
48 int hashes; /* detected hash algorithms */
49 int faked; /* we are faking a literal data packet */
50 int truncated; /* number of truncated lines */
51 int qp_detected;
52 int pgp2mode;
53 byte eol[3]; /* The end of line characters as a
54 zero-terminated string. Defaults
55 (eol[0]=='\0') to whatever the local
56 platform uses. */
58 byte *buffer; /* malloced buffer */
59 unsigned buffer_size; /* and size of this buffer */
60 unsigned buffer_len; /* used length of the buffer */
61 unsigned buffer_pos; /* read position */
63 byte radbuf[4];
64 int idx, idx2;
65 u32 crc;
67 int status; /* an internal state flag */
68 int cancel;
69 int any_data; /* any valid armored data seen */
70 int pending_lf; /* used together with faked */
71 } armor_filter_context_t;
73 struct unarmor_pump_s;
74 typedef struct unarmor_pump_s *UnarmorPump;
77 struct compress_filter_context_s {
78 int status;
79 void *opaque; /* (used for z_stream) */
80 byte *inbuf;
81 unsigned inbufsize;
82 byte *outbuf;
83 unsigned outbufsize;
84 int algo; /* compress algo */
85 int algo1hack;
86 int new_ctb;
87 void (*release)(struct compress_filter_context_s*);
89 typedef struct compress_filter_context_s compress_filter_context_t;
92 typedef struct {
93 DEK *dek;
94 u32 datalen;
95 CIPHER_HANDLE cipher_hd;
96 int header;
97 MD_HANDLE mdc_hash;
98 byte enchash[20];
99 int create_mdc; /* flag will be set by the cipher filter */
100 } cipher_filter_context_t;
104 typedef struct {
105 byte *buffer; /* malloced buffer */
106 unsigned buffer_size; /* and size of this buffer */
107 unsigned buffer_len; /* used length of the buffer */
108 unsigned buffer_pos; /* read position */
109 int truncated; /* number of truncated lines */
110 int not_dash_escaped;
111 int escape_from;
112 MD_HANDLE md;
113 int pending_lf;
114 int pending_esc;
115 } text_filter_context_t;
118 typedef struct {
119 char *what; /* description */
120 u32 last_time; /* last time reported */
121 unsigned long last; /* last amount reported */
122 unsigned long offset; /* current amount */
123 unsigned long total; /* total amount */
124 } progress_filter_context_t;
126 /* encrypt_filter_context_t defined in main.h */
128 /*-- mdfilter.c --*/
129 int md_filter( void *opaque, int control, IOBUF a, byte *buf, size_t *ret_len);
130 void free_md_filter_context( md_filter_context_t *mfx );
132 /*-- armor.c --*/
133 int use_armor_filter( IOBUF a );
134 int armor_filter( void *opaque, int control,
135 IOBUF chain, byte *buf, size_t *ret_len);
136 UnarmorPump unarmor_pump_new (void);
137 void unarmor_pump_release (UnarmorPump x);
138 int unarmor_pump (UnarmorPump x, int c);
140 /*-- compress.c --*/
141 void push_compress_filter(IOBUF out,compress_filter_context_t *zfx,int algo);
142 void push_compress_filter2(IOBUF out,compress_filter_context_t *zfx,
143 int algo,int rel);
145 /*-- cipher.c --*/
146 int cipher_filter( void *opaque, int control,
147 IOBUF chain, byte *buf, size_t *ret_len);
149 /*-- textfilter.c --*/
150 int text_filter( void *opaque, int control,
151 IOBUF chain, byte *buf, size_t *ret_len);
152 int copy_clearsig_text( IOBUF out, IOBUF inp, MD_HANDLE md,
153 int escape_dash, int escape_from, int pgp2mode );
155 /*-- progress.c --*/
156 int progress_filter (void *opaque, int control,
157 IOBUF a, byte *buf, size_t *ret_len);
158 void handle_progress (progress_filter_context_t *pfx,
159 IOBUF inp, const char *name);
161 #endif /*G10_FILTER_H*/