Initialize Tizen 2.3
[external/nettle.git] / tools / input.h
1 /* input.h */
2
3 /* nettle, low-level cryptographics library
4  *
5  * Copyright (C) 2002, 2003 Niels Möller
6  *  
7  * The nettle library is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at your
10  * option) any later version.
11  * 
12  * The nettle library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15  * License for more details.
16  * 
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with the nettle library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA 02111-1307, USA.
21  */
22
23 #ifndef NETTLE_TOOLS_INPUT_H_INCLUDED
24 #define NETTLE_TOOLS_INPUT_H_INCLUDED
25
26 #include "misc.h"
27
28 #include "base16.h"
29 #include "base64.h"
30 #include "buffer.h"
31 #include "nettle-meta.h"
32
33 #include <stdio.h>
34
35 /* Special marks in the input stream */
36 enum sexp_char_type
37   {
38     SEXP_NORMAL_CHAR = 0,
39     SEXP_EOF_CHAR, SEXP_END_CHAR,
40   };
41
42 struct sexp_input
43 {
44   FILE *f;
45
46   /* Character stream, consisting of ordinary characters,
47    * SEXP_EOF_CHAR, and SEXP_END_CHAR. */
48   enum sexp_char_type ctype;
49   uint8_t c;
50   
51   const struct nettle_armor *coding;
52
53   union {
54     struct base64_decode_ctx base64;
55     struct base16_decode_ctx hex;
56   } state;
57
58   /* Terminator for current coding */
59   uint8_t terminator;
60   
61   /* Type of current token */
62   enum sexp_token token;
63 };
64
65 void
66 sexp_input_init(struct sexp_input *input, FILE *f);
67
68 void
69 sexp_get_char(struct sexp_input *input);
70
71 void
72 sexp_get_token(struct sexp_input *input, enum sexp_mode mode,
73                struct nettle_buffer *string);
74
75
76 #endif /* NETTLE_TOOLS_INPUT_H_INCLUDED */