Debian Codegraph @

src/reader.h

raw
1 /* reader.h - internl definitions for the reder object.
2 * Copyright (C) 2001, 2010, 2012 g10 Code GmbH
3 *
4 * This file is part of KSBA.
5 *
6 * KSBA is free software; you can redistribute it and/or modify
7 * it under the terms of either
8 *
9 * - the GNU Lesser General Public License as published by the Free
10 * Software Foundation; either version 3 of the License, or (at
11 * your option) any later version.
12 *
13 * or
14 *
15 * - the GNU General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at
17 * your option) any later version.
18 *
19 * or both in parallel, as here.
20 *
21 * KSBA is distributed in the hope that it will be useful, but WITHOUT
22 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
24 * License for more details.
25 *
26 * You should have received a copies of the GNU General Public License
27 * and the GNU Lesser General Public License along with this program;
28 * if not, see <http://www.gnu.org/licenses/>.
29 */
30
31 #ifndef READER_H
32 #define READER_H 1
33
34 #include <stdio.h>
35
36 enum reader_type {
37 READER_TYPE_NONE = 0,
38 READER_TYPE_MEM,
39 READER_TYPE_FD,
40 READER_TYPE_FILE,
41 READER_TYPE_CB
42 };
43
44
45 struct ksba_reader_s {
46 int eof;
47 int error; /* If an error occured, takes the value of errno. */
48 unsigned long nread;
49 struct {
50 unsigned char *buf;
51 size_t size; /* allocated size */
52 size_t length; /* used size */
53 size_t readpos; /* offset where to start the next read */
54 } unread;
55 enum reader_type type;
56 union {
57 struct {
58 unsigned char *buffer;
59 size_t size;
60 size_t readpos;
61 } mem; /* for READER_TYPE_MEM */
62 int fd; /* for READER_TYPE_FD */
63 FILE *file; /* for READER_TYPE_FILE */
64 struct {
65 int (*fnc)(void*,char *,size_t,size_t*);
66 void *value;
67 } cb; /* for READER_TYPE_CB */
68 } u;
69 void (*notify_cb)(void*,ksba_reader_t);
70 void *notify_cb_value;
71 };
72
73
74
75
76 #endif /*READER_H*/