summaryrefslogtreecommitdiff
path: root/lib/opencdk/filters.h
blob: 47b0200a8638e56fc3deb819df43596dee47041b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* filters.h - Filter structs
 * Copyright (C) 2002-2003, 2008, 2010-2012 Free Software Foundation,
 * Inc.
 *
 * Author: Timo Schulz
 *
 * This file is part of OpenCDK.
 *
 * The OpenCDK library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
#ifndef CDK_FILTERS_H
#define CDK_FILTERS_H

enum
{
  STREAMCTL_READ = 0,
  STREAMCTL_WRITE = 1,
  STREAMCTL_FREE = 2
};

typedef struct
{
  cipher_hd_st hd;
  digest_hd_st mdc;
  int mdc_method;
  u32 datalen;
  struct
  {
    size_t on;
    off_t size;
    off_t nleft;
  } blkmode;
  cdk_stream_t s;
} cipher_filter_t;

typedef struct
{
  int digest_algo;
  digest_hd_st md;
  int md_initialized;
} md_filter_t;

typedef struct
{
  const char *le;               /* line endings */
  const char *hdrlines;
  u32 crc;
  int crc_okay;
  int idx, idx2;
} armor_filter_t;

typedef struct
{
  cdk_lit_format_t mode;
  char *orig_filename;          /* This original name of the input file. */
  char *filename;
  digest_hd_st md;
  int md_initialized;
  struct
  {
    size_t on;
    off_t size;
  } blkmode;
} literal_filter_t;

typedef struct
{
  size_t inbufsize;
  byte inbuf[8192];
  size_t outbufsize;
  byte outbuf[8192];
  int algo;                     /* compress algo */
  int level;
} compress_filter_t;

typedef struct
{
  const char *lf;
} text_filter_t;


/*-- armor.c -*/
int _cdk_filter_armor (void *opaque, int ctl, FILE * in, FILE * out);

/*-- cipher.c --*/
cdk_error_t _cdk_filter_hash (void *opaque, int ctl, FILE * in, FILE * out);
cdk_error_t _cdk_filter_cipher (void *opaque, int ctl, FILE * in, FILE * out);

/*-- literal.c --*/
int _cdk_filter_literal (void *opaque, int ctl, FILE * in, FILE * out);
int _cdk_filter_text (void *opaque, int ctl, FILE * in, FILE * out);

/*-- compress.c --*/
cdk_error_t _cdk_filter_compress (void *opaque, int ctl,
                                  FILE * in, FILE * out);

#endif /* CDK_FILTERS_H */