* gpg.texi (GPG Configuration Options): Make http_proxy option
[gnupg.git] / g10 / filter.h
blob13f6b38d505f016e8b7b658b647a25bb0a2a3a9a
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 gcry_md_hd_t md; /* catch all */
30 gcry_md_hd_t md2; /* if we want to calculate an alternate hash */
31 size_t maxbuf_size;
32 } md_filter_context_t;
34 typedef struct {
35 int refcount; /* Initialized to 1. */
37 /* these fields may be initialized */
38 int what; /* what kind of armor headers to write */
39 int only_keyblocks; /* skip all headers but ".... key block" */
40 const char *hdrlines; /* write these headerlines */
42 /* these fields must be initialized to zero */
43 int no_openpgp_data; /* output flag: "No valid OpenPGP data found" */
45 /* the following fields must be initialized to zero */
46 int inp_checked; /* set if the input has been checked */
47 int inp_bypass; /* set if the input is not armored */
48 int in_cleartext; /* clear text message */
49 int not_dash_escaped; /* clear text is not dash escaped */
50 int hashes; /* detected hash algorithms */
51 int faked; /* we are faking a literal data packet */
52 int truncated; /* number of truncated lines */
53 int qp_detected;
54 int pgp2mode;
55 byte eol[3]; /* The end of line characters as a
56 zero-terminated string. Defaults
57 (eol[0]=='\0') to whatever the local
58 platform uses. */
60 byte *buffer; /* malloced buffer */
61 unsigned buffer_size; /* and size of this buffer */
62 unsigned buffer_len; /* used length of the buffer */
63 unsigned buffer_pos; /* read position */
65 byte radbuf[4];
66 int idx, idx2;
67 u32 crc;
69 int status; /* an internal state flag */
70 int cancel;
71 int any_data; /* any valid armored data seen */
72 int pending_lf; /* used together with faked */
73 } armor_filter_context_t;
75 struct unarmor_pump_s;
76 typedef struct unarmor_pump_s *UnarmorPump;
79 struct compress_filter_context_s {
80 int status;
81 void *opaque; /* (used for z_stream) */
82 byte *inbuf;
83 unsigned inbufsize;
84 byte *outbuf;
85 unsigned outbufsize;
86 int algo; /* compress algo */
87 int algo1hack;
88 int new_ctb;
89 void (*release)(struct compress_filter_context_s*);
91 typedef struct compress_filter_context_s compress_filter_context_t;
94 typedef struct {
95 DEK *dek;
96 u32 datalen;
97 gcry_cipher_hd_t cipher_hd;
98 int header;
99 gcry_md_hd_t mdc_hash;
100 byte enchash[20];
101 int create_mdc; /* flag will be set by the cipher filter */
102 } cipher_filter_context_t;
106 typedef struct {
107 byte *buffer; /* malloced buffer */
108 unsigned buffer_size; /* and size of this buffer */
109 unsigned buffer_len; /* used length of the buffer */
110 unsigned buffer_pos; /* read position */
111 int truncated; /* number of truncated lines */
112 int not_dash_escaped;
113 int escape_from;
114 gcry_md_hd_t md;
115 int pending_lf;
116 int pending_esc;
117 } text_filter_context_t;
120 typedef struct {
121 char *what; /* description */
122 u32 last_time; /* last time reported */
123 unsigned long last; /* last amount reported */
124 unsigned long offset; /* current amount */
125 unsigned long total; /* total amount */
126 int refcount;
127 } progress_filter_context_t;
129 /* encrypt_filter_context_t defined in main.h */
131 /*-- mdfilter.c --*/
132 int md_filter( void *opaque, int control, iobuf_t a, byte *buf, size_t *ret_len);
133 void free_md_filter_context( md_filter_context_t *mfx );
135 /*-- armor.c --*/
136 armor_filter_context_t *new_armor_context (void);
137 void release_armor_context (armor_filter_context_t *afx);
138 int push_armor_filter (armor_filter_context_t *afx, iobuf_t iobuf);
139 int use_armor_filter( iobuf_t a );
140 UnarmorPump unarmor_pump_new (void);
141 void unarmor_pump_release (UnarmorPump x);
142 int unarmor_pump (UnarmorPump x, int c);
144 /*-- compress.c --*/
145 void push_compress_filter(iobuf_t out,compress_filter_context_t *zfx,int algo);
146 void push_compress_filter2(iobuf_t out,compress_filter_context_t *zfx,
147 int algo,int rel);
149 /*-- cipher.c --*/
150 int cipher_filter( void *opaque, int control,
151 iobuf_t chain, byte *buf, size_t *ret_len);
153 /*-- textfilter.c --*/
154 int text_filter( void *opaque, int control,
155 iobuf_t chain, byte *buf, size_t *ret_len);
156 int copy_clearsig_text (iobuf_t out, iobuf_t inp, gcry_md_hd_t md,
157 int escape_dash, int escape_from, int pgp2mode);
159 /*-- progress.c --*/
160 progress_filter_context_t *new_progress_context (void);
161 void release_progress_context (progress_filter_context_t *pfx);
162 void handle_progress (progress_filter_context_t *pfx,
163 iobuf_t inp, const char *name);
165 #endif /*G10_FILTER_H*/