Initialize Tizen 2.3
[external/nettle.git] / examples / io.h
1 /* io.c
2  *
3  * Miscellaneous functions used by the example programs.
4  */
5
6 /* nettle, low-level cryptographics library
7  *
8  * Copyright (C) 2002 Niels Möller
9  *  
10  * The nettle library is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or (at your
13  * option) any later version.
14  * 
15  * The nettle library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
18  * License for more details.
19  * 
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with the nettle library; see the file COPYING.LIB.  If not, write to
22  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23  * MA 02111-1307, USA.
24  */
25
26 #ifndef NETTLE_EXAMPLES_IO_H_INCLUDED
27 #define NETTLE_EXAMPLES_IO_H_INCLUDED
28
29 #include "nettle-meta.h"
30 #include "yarrow.h"
31
32 #include <stdio.h>
33
34 extern int quiet_flag;
35
36 void *
37 xalloc(size_t size);
38
39 void
40 werror(const char *format, ...)
41 #if __GNUC___
42      __attribute__((__format__ (__printf__,1, 2)))
43 #endif
44      ;
45
46 /* If size is > 0, read at most that many bytes. If size == 0,
47  * read until EOF. Allocates the buffer dynamically. */
48 unsigned
49 read_file(const char *name, unsigned size, char **buffer);
50
51 int
52 write_file(const char *name, unsigned size, const char *buffer);
53
54 int
55 write_string(FILE *f, unsigned size, const char *buffer);
56
57 int
58 simple_random(struct yarrow256_ctx *ctx, const char *name);
59
60 int
61 hash_file(const struct nettle_hash *hash, void *ctx, FILE *f);
62
63 #if WITH_HOGWEED
64 struct rsa_public_key;
65 struct rsa_private_key;
66
67 int
68 read_rsa_key(const char *name,
69              struct rsa_public_key *pub,
70              struct rsa_private_key *priv);
71 #endif /* WITH_HOGWEED */
72
73 #endif /* NETTLE_EXAMPLES_IO_H_INCLUDED */