Made error code consistent with the other text parsing functions.
[gnutls.git] / lib / opencdk / stream.h
blob72c227cb3e59dd5949acf2730108968d7d819e2c
1 /* stream.h - internal definiton for the STREAM object
2 * Copyright (C) 2002-2012 Free Software Foundation, Inc.
4 * Author: Timo Schulz
6 * This file is part of OpenCDK.
8 * The OpenCDK library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 #ifndef CDK_STREAM_H
24 #define CDK_STREAM_H
26 /* The default buffer size for the stream. */
27 #define STREAM_BUFSIZE 8192
29 enum
31 fDUMMY = 0,
32 fARMOR = 1,
33 fCIPHER = 2,
34 fLITERAL = 3,
35 fCOMPRESS = 4,
36 fHASH = 5,
37 fTEXT = 6
40 /* Type definition for the filter function. */
41 typedef cdk_error_t (*filter_fnct_t) (void *uint8_t, int ctl, FILE * in,
42 FILE * out);
44 /* The stream filter context structure. */
45 struct stream_filter_s
47 struct stream_filter_s *next;
48 filter_fnct_t fnct;
49 void *uint8_t;
50 FILE *tmp;
51 union
53 armor_filter_t afx;
54 cipher_filter_t cfx;
55 literal_filter_t pfx;
56 compress_filter_t zfx;
57 text_filter_t tfx;
58 md_filter_t mfx;
59 } u;
60 struct
62 unsigned enabled:1;
63 unsigned rdonly:1;
64 unsigned error:1;
65 } flags;
66 unsigned type;
67 unsigned ctl;
71 /* The stream context structure. */
72 struct cdk_stream_s
74 struct stream_filter_s *filters;
75 int fmode;
76 int error;
77 size_t blkmode;
78 struct
80 unsigned filtrated:1;
81 unsigned eof:1;
82 unsigned write:1;
83 unsigned temp:1;
84 unsigned reset:1;
85 unsigned no_filter:1;
86 unsigned compressed:3;
87 } flags;
88 struct
90 unsigned char *buf;
91 unsigned on:1;
92 size_t size;
93 size_t alloced;
94 } cache;
95 char *fname;
96 FILE *fp;
97 unsigned int fp_ref:1;
98 struct cdk_stream_cbs_s cbs;
99 void *cbs_hd;
102 #endif /* CDK_STREAM_H */