Imported Upstream version 2.1.19
[platform/upstream/gpg2.git] / common / ksba-io-support.h
1 /* ksba-io-support.h - Supporting functions for ksba reader and writer
2  * Copyright (C) 2017  Werner Koch
3  *
4  * This file is part of GnuPG.
5  *
6  * This file 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  * This file is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, see <https://www.gnu.org/licenses/>.
28  */
29
30 #ifndef GNUPG_KSBA_IO_SUPPORT_H
31 #define GNUPG_KSBA_IO_SUPPORT_H
32
33 /* Flags used with gnupg_ksba_create_reader and
34  * gnupg_ksba_create_writer.  */
35 #define GNUPG_KSBA_IO_PEM         1  /* X.509 PEM format.  */
36 #define GNUPG_KSBA_IO_BASE64      2  /* Plain Base64 format.  */
37 #define GNUPG_KSBA_IO_AUTODETECT  4  /* Try to autodetect the format.  */
38 #define GNUPG_KSBA_IO_MULTIPEM    8  /* Allow more than one PEM chunk.  */
39
40
41 /* Context object.  */
42 typedef struct gnupg_ksba_io_s *gnupg_ksba_io_t;
43
44
45
46 gpg_error_t gnupg_ksba_create_reader (gnupg_ksba_io_t *ctx,
47                                       unsigned int flags,
48                                       estream_t fp,
49                                       ksba_reader_t *r_reader);
50
51 int gnupg_ksba_reader_eof_seen (gnupg_ksba_io_t ctx);
52 void gnupg_ksba_destroy_reader (gnupg_ksba_io_t ctx);
53
54 gpg_error_t gnupg_ksba_create_writer (gnupg_ksba_io_t *ctx,
55                                       unsigned int flags,
56                                       const char *pem_name,
57                                       estream_t stream,
58                                       ksba_writer_t *r_writer);
59
60 gpg_error_t gnupg_ksba_finish_writer (gnupg_ksba_io_t ctx);
61 void gnupg_ksba_destroy_writer (gnupg_ksba_io_t ctx);
62
63
64
65
66 #endif /*GNUPG_KSBA_IO_SUPPORT_H*/