1bf7a1d77cda6056ab5c1371fc26627ecb7d2d51
[monkeysphere.git] / gnutls-helpers.h
1 /* Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net> */
2 /* Date: Fri, 04 Apr 2008 19:31:16 -0400 */
3 /* License: GPL v3 or later */
4
5
6 #include <gnutls/gnutls.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <errno.h>
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 #include <unistd.h>
14 #include <stdarg.h>
15
16 /* Functions to help dealing with GnuTLS for monkeysphere key
17    translation projects: */
18
19 /* set everything up, including logging levels.  Return 0 on
20    success */
21 int init_gnutls();
22
23 /* logging and output functions: */
24
25 void err(const char* fmt, ...);
26 void logfunc(int level, const char* string);
27
28 /* basic datum manipulations: */
29
30 void init_datum(gnutls_datum_t* d);
31 void copy_datum(gnutls_datum_t* dest, const gnutls_datum_t* src);
32 int compare_data(const gnutls_datum_t* a, const gnutls_datum_t* b);
33 void free_datum(gnutls_datum_t* d);
34
35 /* functions to get data into datum objects: */
36
37 /* read the passed-in string, store in a single datum */
38 int set_datum_string(gnutls_datum_t* d, const char* s);
39
40 /* read the passed-in file descriptor until EOF, store in a single
41    datum */
42 int set_datum_fd(gnutls_datum_t* d, int fd);
43
44 /* read the file indicated (by na1me) in the fname parameter.  store
45    its entire contents in a single datum. */
46 int set_datum_file(gnutls_datum_t* d, const char* fname);